> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/zh-tw/te-ding-ling-yu/01-theorems-and-proofs.md).

# 定理與證明

## 簡介

數學文件包含一些需要特殊格式與編號的元素，例如定理、定義、命題、備註、推論、引理等等。本文說明如何在 LaTeX 中定義這些環境。

LaTeX 中的編號環境可以透過指令 `\newtheorem` 來定義，這個指令接受兩個參數：

```latex
\newtheorem{theorem}{Theorem}
```

* 第一個是所定義之環境的名稱
* 第二個是在環境開頭以粗體字印出的詞語。

一旦這個新環境被定義後，就可以在文件中正常使用，並由以下標記界定： `\begin{theorem}` 和 `\end{theorem}`。以下 प्रस्तुत一個範例：

```latex
\documentclass{article}
\usepackage[english]{babel}
\newtheorem{theorem}{Theorem}
\begin{document}

\section{簡介}
定理可以很容易地定義：

\begin{theorem}
設 \(f\) 為一個在每一點皆存在導數的函數，則 \(f\)
是一個連續函數。
\end{theorem}
\end{document}
```

[在 Overleaf 中開啟此範例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=newtheorem+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cnewtheorem%7Btheorem%7D%7BTheorem%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5Csection%7BIntroduction%7D%0ATheorems+can+easily+be+defined%3A%0A%0A%5Cbegin%7Btheorem%7D%0ALet+%5C%28f%5C%29+be+a+function+whose+derivative+exists+in+every+point%2C+then+%5C%28f%5C%29+%0Ais+a+continuous+function.%0A%5Cend%7Btheorem%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![OLV2TheoremsProofsEx1.png](/files/baa1ab6b7cc81c7060f1f28d00f5803ce02f03c3)

## 編號的定理、定義、推論與引理

這些環境的編號可以透過在 `\newtheorem` 指令中加入兩個額外參數來控制。讓我們來看看：

```latex
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}

\begin{document}
\section{簡介}
定理可以很容易地定義：

\begin{theorem}
設 \(f\) 為一個在每一點皆存在導數的函數，則 \(f\) 是
一個連續函數。
\end{theorem}

\begin{theorem}[畢氏定理]
\label{pythagorean}
這是一個關於直角三角形的定理，可以概括為下一個
equation
\[ x^2 + y^2 = z^2 \]
\end{theorem}

而定理 \ref{pythagorean} 的一個推論是下一個
推論。

\begin{corollary}
不存在邊長為 3cm、4cm 與 6cm 的直角長方形。
\end{corollary}

當指定了標籤時，你可以引用像 \ref{pythagorean} 這樣的定理。

\begin{lemma}
給定兩條線段，其長度分別為 \(a\) 與 \(b\)，則存在一個
實數 \(r\) 使得 \(b=ra\)。
\end{lemma}
```

[在 Overleaf 中開啟此範例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Numbering+of+theorems\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cnewtheorem%7Btheorem%7D%7BTheorem%7D%5Bsection%5D%0A%5Cnewtheorem%7Bcorollary%7D%7BCorollary%7D%5Btheorem%5D%0A%5Cnewtheorem%7Blemma%7D%5Btheorem%5D%7BLemma%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Csection%7BIntroduction%7D%0ATheorems+can+easily+be+defined%3A%0A%0A%5Cbegin%7Btheorem%7D%0ALet+%5C%28f%5C%29+be+a+function+whose+derivative+exists+in+every+point%2C+then+%5C%28f%5C%29+is+%0Aa+continuous+function.%0A%5Cend%7Btheorem%7D%0A%0A%5Cbegin%7Btheorem%7D%5BPythagorean+theorem%5D%0A%5Clabel%7Bpythagorean%7D%0AThis+is+a+theorem+about+right+triangles+and+can+be+summarised+in+the+next+%0Aequation+%0A%5C%5B+x%5E2+%2B+y%5E2+%3D+z%5E2+%5C%5D%0A%5Cend%7Btheorem%7D%0A%0AAnd+a+consequence+of+theorem+%5Cref%7Bpythagorean%7D+is+the+statement+in+the+next+%0Acorollary.%0A%0A%5Cbegin%7Bcorollary%7D%0AThere%27s+no+right+rectangle+whose+sides+measure+3cm%2C+4cm%2C+and+6cm.%0A%5Cend%7Bcorollary%7D%0A%0AYou+can+reference+theorems+such+as+%5Cref%7Bpythagorean%7D+when+a+label+is+assigned.%0A%0A%5Cbegin%7Blemma%7D%0AGiven+two+line+segments+whose+lengths+are+%5C%28a%5C%29+and+%5C%28b%5C%29+respectively+there+is+a+%0Areal+number+%5C%28r%5C%29+such+that+%5C%28b%3Dra%5C%29.%0A%5Cend%7Blemma%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![OLV2TheoremsProofsEx2-updated.png](/files/513035bd4dea6e0211646593d69b81f573d57392)

在前言中定義了三個新環境。

**\newtheorem{theorem}{Theorem}\[section]**

這是導言中 प्रस्तुत的範例，但它多了額外參數 \[section]，會在每個新章節開始時重設定理計數器。

**\newtheorem{corollary}{Corollary}\[theorem]**

會建立一個名為 corollary 的環境，當每次使用新的 theorem 環境時，這個新環境的計數器都會重設。

**\newtheorem{lemma}\[theorem]{Lemma}**

在這種情況下，雖然建立了一個名為 lemma 的新環境，但它會與 theorem 環境使用相同的計數器。

有些著名定理有自己的名稱，在這些情況下，你可以在環境開啟指令中的括號裡加入該名稱。在此範例中，這一行 `\begin{theorem}[畢氏定理]` 會在段落開頭印出「畢氏定理」。

如同 LaTeX 中許多其他帶編號的元素一樣，指令 `\label` 可用來在文件中引用類定理環境。

## 無編號的類定理環境

在數學文件中，若有一個無編號的類定理環境可用來加入備註、評論或範例，會很有幫助。 `amsthm` 套件提供了這項功能。

```latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsthm}

\newtheorem*{remark}{Remark}

\begin{document}
也可以使用無編號的類定理環境。

\begin{remark}
我猜這個敘述是真的。
\end{remark}
\end{document}
```

[在 Overleaf 中開啟此範例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Unnumbered+theorem-like+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cusepackage%7Bamsthm%7D%0A%0A%5Cnewtheorem%2A%7Bremark%7D%7BRemark%7D%0A%0A%5Cbegin%7Bdocument%7D%0AUnnumbered+theorem-like+environments+are+also+possible.%0A%0A%5Cbegin%7Bremark%7D%0AThis+statement+is+true%2C+I+guess.%0A%5Cend%7Bremark%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![OLV2heoremsProofsEx3.png](/files/5a74a3ea7b4df848ed9eb97e3f3fa71882fc4377)

指令 `\newtheorem*` 的語法與非星號版本相同，唯獨計數器參數不同。在這個範例中，建立了一個名為 `remark` 的全新無編號環境。

## 定理樣式

在撰寫數學文件時，一個重要的功能是能夠透過格式輕鬆區分，例如將定義與定理區別開來。 `amsthm` 套件提供了特殊指令來完成這件事。

```latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{definition}{定義}[section]

\theoremstyle{remark}
\newtheorem*{remark}{Remark}

\begin{document}
\section{簡介}
也可以使用無編號的類定理環境。

\begin{remark}
我猜這個敘述是真的。
\end{remark}

接下來是一個稍微不那麼正式的定義

\begin{definition}[纖維化]
纖維化是介於兩個拓撲空間之間的一個映射，對每個空間 \(X\) 都具有同倫提升性質。
\end{definition}
\end{document}
```

[在 Overleaf 中開啟此範例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=An+amsthm+package+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cusepackage%7Bamsthm%7D%0A%0A%5Ctheoremstyle%7Bdefinition%7D%0A%5Cnewtheorem%7Bdefinition%7D%7BDefinition%7D%5Bsection%5D%0A%0A%5Ctheoremstyle%7Bremark%7D%0A%5Cnewtheorem%2A%7Bremark%7D%7BRemark%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Csection%7BIntroduction%7D%0AUnnumbered+theorem-like+environments+are+also+possible.%0A%0A%5Cbegin%7Bremark%7D%0AThis+statement+is+true%2C+I+guess.%0A%5Cend%7Bremark%7D%0A%0AAnd+the+next+is+a+somewhat+informal+definition%0A%0A%5Cbegin%7Bdefinition%7D%5BFibration%5D%0AA+fibration+is+a+mapping+between+two+topological+spaces+that+has+the+homotopy+lifting+property+for+every+space+%5C%28X%5C%29.%0A%5Cend%7Bdefinition%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![OLV2TheoremsProofsEx4.png](/files/7377f24e7c45944518089cc64558c31aedd5933d)

命令 `\theoremstyle{ }` 會設定其下方所定義的編號環境的樣式。在上面的範例中，使用了 *remark* 和 *definition* 樣式。請注意，備註現在是斜體，而環境中的文字使用一般（羅馬）字體；相對地，定義中的文字也使用羅馬字體，但「Definition」一詞則以粗體字印出。

請參閱 [參考指南](#reference-guide) 以取得更多定理樣式。

## 證明

證明是數學論文與書籍的核心，通常會在視覺上與文件中的一般文字區分開來。 `amsthm` 套件提供了環境 `proof` 供此用途。

```latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}

\begin{document}
\section{簡介}
\begin{lemma}
給定兩條線段，其長度分別為 \(a\) 與 \(b\)，則
存在一個實數 \(r\) 使得 \(b=ra\)。
\end{lemma}

\begin{proof}
要用反證法證明它，可嘗試假設這個敘述為假，
再從那裡繼續推導，某個時刻你會得到矛盾。
\end{proof}
\end{document}
```

[在 Overleaf 中開啟此範例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+of+amsthm+proof+environment\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cusepackage%7Bamsthm%7D%0A%0A%5Cnewtheorem%7Btheorem%7D%7BTheorem%7D%5Bsection%5D%0A%5Cnewtheorem%7Blemma%7D%5Btheorem%5D%7BLemma%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Csection%7BIntroduction%7D%0A%5Cbegin%7Blemma%7D%0AGiven+two+line+segments+whose+lengths+are+%5C%28a%5C%29+and+%5C%28b%5C%29+respectively+there+%0Ais+a+real+number+%5C%28r%5C%29+such+that+%5C%28b%3Dra%5C%29.%0A%5Cend%7Blemma%7D%0A%0A%5Cbegin%7Bproof%7D%0ATo+prove+it+by+contradiction+try+and+assume+that+the+statement+is+false%2C%0Aproceed+from+there+and+at+some+point+you+will+arrive+to+a+contradiction.%0A%5Cend%7Bproof%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![OLV2TheoremsProofsEx5.png](/files/0243f101997ca3503da96bc032a4baa340016850)

這個詞 `Proof` 是斜體，且還有一些額外間距；另外，結尾處會使用一個特殊符號來標示證明結束。這個符號很容易更改，如何更改請見下一節。

## 更改 QED 符號

印在證明結尾的符號稱為「QED 符號」。引述 [QED 的含義](https://en.wikipedia.org/wiki/Q.E.D.) 自維基百科：

> QED 是拉丁語片語的首字母縮寫 *quod erat demonstrandum*，意為「因此已得證明」

你可以很直接地使用你選擇的符號或文字來表示 QED 符號。指令

```latex
\renewcommand\qedsymbol{$\blacksquare$}
```

可用來將預設的白色方塊替換為由 `$\blacksquare$`印出的黑色方塊，也就是大括號內的參數。或者，你也可以明確寫出 QED 一詞：

```latex
\renewcommand\qedsymbol{QED}
```

以下是示範這兩種選項的範例：

```latex
\documentclass{article}

\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{amssymb}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}

\begin{document}
\section{簡介}

\begin{lemma}
給定兩條線段，其長度分別為 \(a\) 與 \(b\)，則
存在一個實數 \(r\) 使得 \(b=ra\)。
\end{lemma}

\renewcommand\qedsymbol{$\blacksquare$}

\begin{proof}
要用反證法證明它，可嘗試假設這個敘述為假，
再從那裡繼續推導，某個時刻你會得到矛盾。
\end{proof}

\renewcommand\qedsymbol{QED}

\begin{proof}
要用反證法證明它，可嘗試假設這個敘述為假，
再從那裡繼續推導，某個時刻你會得到矛盾。
\end{proof}
\end{document}
```

[在 Overleaf 中開啟此範例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Changing+the+QED+symbol\&snip=%5Cdocumentclass%7Barticle%7D%0A%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cusepackage%7Bamsthm%7D%0A%5Cusepackage%7Bamssymb%7D%0A%0A%5Cnewtheorem%7Btheorem%7D%7BTheorem%7D%5Bsection%5D%0A%5Cnewtheorem%7Blemma%7D%5Btheorem%5D%7BLemma%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Csection%7BIntroduction%7D%0A%0A%5Cbegin%7Blemma%7D%0AGiven+two+line+segments+whose+lengths+are+%5C%28a%5C%29+and+%5C%28b%5C%29+respectively+there+%0Ais+a+real+number+%5C%28r%5C%29+such+that+%5C%28b%3Dra%5C%29.%0A%5Cend%7Blemma%7D%0A%0A%5Crenewcommand%5Cqedsymbol%7B%24%5Cblacksquare%24%7D%0A%0A%5Cbegin%7Bproof%7D%0ATo+prove+it+by+contradiction+try+and+assume+that+the+statement+is+false%2C%0Aproceed+from+there+and+at+some+point+you+will+arrive+to+a+contradiction.%0A%5Cend%7Bproof%7D%0A%0A%5Crenewcommand%5Cqedsymbol%7BQED%7D%0A%0A%5Cbegin%7Bproof%7D%0ATo+prove+it+by+contradiction+try+and+assume+that+the+statement+is+false%2C%0Aproceed+from+there+and+at+some+point+you+will+arrive+to+a+contradiction.%0A%5Cend%7Bproof%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![OLV2TheoremsProofsEx6.png](/files/0e7420ece93a6d82d7d91b3d9f448135c3e7b8e1)

## 參考指南

***定理樣式***

* `definition` 粗體標題、羅馬體內容。常用於定義、條件、問題與範例。
* `plain` 粗體標題、斜體內容。常用於定理、引理、推論、命題與猜想。
* `remark` 斜體標題、羅馬體內容。常用於備註、註解、標註、聲明、情況、致謝與結論。

## 延伸閱讀

詳情請見：

* [數學表達式](/latex/zh-tw/shu-xue/01-mathematical-expressions.md)
* [環境](/latex/zh-tw/zhi-ling/02-environments.md)
* [數學模式中的顯示樣式](/latex/zh-tw/shu-xue/10-display-style-in-math-mode.md)
* [希臘字母與數學符號列表](/latex/zh-tw/shu-xue/11-list-of-greek-letters-and-math-symbols.md)
* [數學字型](/latex/zh-tw/shu-xue/12-mathematical-fonts.md)
* [多檔案 LaTeX 專案](/latex/zh-tw/wen-jian-jie-gou/08-multi-file-latex-projects.md)
* [章節與方程式交叉參照](/latex/zh-tw/wen-jian-jie-gou/03-cross-referencing-sections-equations-and-floats.md)
* [超連結](/latex/zh-tw/wen-jian-jie-gou/09-hyperlinks.md)
* [該 **amsthm** 套件說明文件](http://www.ctan.org/pkg/amsthm)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/zh-tw/te-ding-ling-yu/01-theorems-and-proofs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
