> 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-cn/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/7124066474066dd26e04732b37cef936ecceb8c8)

## 带编号的定理、定义、推论和引理

这些环境的编号可以通过在 `\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}[Pythagorean 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/50908ca79a2aefa944552cf77dd9470df71c4408)

导言区定义了三个新环境。

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

这是引言中给出的示例，但它额外带有参数 \[section]，该参数会在每个新节开始时重置定理计数器。

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

创建了一个名为 corollary 的环境，这个新环境的计数器会在每次使用新的 theorem 环境时重置。

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

在这种情况下，尽管创建了一个名为 lemma 的新环境，它将使用与 theorem 环境相同的计数器。

有些著名定理有自己的名称，对于这些情况，你可以在环境开始命令中的方括号里添加该名称。在示例中，该行 `\begin{theorem}[Pythagorean theorem]` 会在段落开头打印“Pythagorean 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/38666a5008fe69d7fb1b3ea3b92f28cec51858ca)

命令 `\newtheorem*` 的语法与非星号版本相同，除了计数器参数之外。在这个例子中，创建了一个名为 `备注` 的新的无编号环境。

## 定理样式

在处理数学文档时，一个重要的功能是能通过格式轻松区分，例如，定义和定理。 `amsthm` 包提供了特殊命令来实现这一点。

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

\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]

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

\begin{document}
\section{引言}
也可以使用无编号的类定理环境。

\begin{remark}
我猜这句话是真的。
\end{remark}

下面是一个稍微非正式的定义

\begin{definition}[Fibration]
纤维化是两个拓扑空间之间的一种映射，它对每个空间 \(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/31cfa8a3e8d315855e877299f9d33482d7217779)

命令 `\theoremstyle{ }` 用于设置其下方定义的带编号环境的样式。在上面的例子中，使用了 *备注* 和 *定义* 样式。请注意，remark 现在是斜体，而环境中的文本使用普通（罗马）字体；另一方面，definition 中的文本也使用罗马字体，但“Definition”一词以粗体打印。

参见 [参考指南](#reference-guide) 以了解更多定理样式。

## 证明

证明是数学论文和书籍的核心，通常会将它们在视觉上与文档中的普通文本分开。 `amsthm` 包提供了 `证明` 环境，用于此目的。

```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/4eac4a421533b2c835f54a3f4562805c0cd7014f)

单词 `证明` 采用斜体，并且有一些额外间距，此外还使用了一个特殊符号来标记证明的结束。这个符号很容易更改，如何更改请看下一节。

## 更改 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/062819ca3d8285e32d4c0ff3a35e5c772df91220)

## 参考指南

***定理样式***

* `定义` 粗体标题，罗马体正文。通常用于定义、条件、问题和示例。
* `plain` 粗体标题，斜体正文。通常用于定理、引理、推论、命题和猜想。
* `备注` 斜体标题，罗马体正文。通常用于备注、注释、说明、断言、情况、致谢和结论。

## 进一步阅读

更多信息请参见：

* [数学表达式](/latex/zh-cn/shu-xue/01-mathematical-expressions.md)
* [环境](/latex/zh-cn/ming-ling/02-environments.md)
* [数学模式中的显示样式](/latex/zh-cn/shu-xue/10-display-style-in-math-mode.md)
* [希腊字母和数学符号列表](/latex/zh-cn/shu-xue/11-list-of-greek-letters-and-math-symbols.md)
* [数学字体](/latex/zh-cn/shu-xue/12-mathematical-fonts.md)
* [多文件 LaTeX 项目](/latex/zh-cn/wen-dang-jie-gou/08-multi-file-latex-projects.md)
* [章节和公式的交叉引用](/latex/zh-cn/wen-dang-jie-gou/03-cross-referencing-sections-equations-and-floats.md)
* [超链接](/latex/zh-cn/wen-dang-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-cn/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.
