LaTeX/定理
用“定理”,我們可以指代任何我們想要將其從文字中分離出來的帶標籤的陳述,並在其旁邊顯示順序編號。這種方法通常用於數學定理,但可以用於任何內容。LaTeX 提供了一個命令,可以讓你輕鬆地定義任何類似定理的陳述。
首先,確保你啟用了 amsthm 包。
\usepackage{amsthm}
最簡單的方法如下
\newtheorem{name}{Printed output}
將它放在序言中。第一個引數是你用來引用它的名稱,第二個引數是 LaTeX 在你使用它時會列印的輸出。例如
\newtheorem{mydef}{Definition}
將定義 mydef 環境;如果你像這樣使用它
\begin{mydef}
Here is a new definition
\end{mydef}
它將看起來像這樣
用換行符將其與文字的其餘部分分開。
通常,計數器由節決定,例如,“定理 2.3” 指的是文件第 2 節中的第 3 個定理。在這種情況下,在序言中指定定理如下
\newtheorem{theorem}{Theorem}[section]
並在需要時使用它
\begin{theorem}
If $A$ is positive definite symmetric,
\end{theorem}
或者,使用一個通用的“名稱”來輸出“列印的輸出”,新增“numberby”
\newtheorem{name}{Printed output}[numberby]
其中 numberby 是要進行編號的 節級別(節/小節/等)。
預設情況下,每個定理都使用它自己的計數器。但是,類似型別的定理(例如定理、引理和推論)通常共享一個計數器。在這種情況下,將後續定理定義為
\newtheorem{name}[counter]{Printed output}
其中 counter 是要使用的計數器的名稱。通常,這將是主定理的名稱。
\newtheorem 命令最多可以有一個可選引數。
你也可以使用 newtheorem* 命令[1] 建立一個不編號的定理環境。例如,
\newtheorem*{mydef}{Definition}
定義了 mydef 環境,它將生成不帶編號的定義。這需要 amsthm 包。
proof 環境[1] 可用於新增定理的證明。基本用法是
\begin{proof}
Here is my proof
\end{proof}
它只是在作為引數給出的文字開頭新增斜體的 Proof,並在結尾新增一個白色正方形 (Q.E.D. 符號,也稱為 墓碑符號)。如果你用的是英語以外的語言,只需使用帶正確引數的 babel,輸出中列印的 Proof 字樣就會相應地翻譯;無論如何,在原始碼中,環境的名稱仍然是 proof。
如果你想手動命名證明,將名稱包含在方括號中
\begin{proof}[Proof of important theorem]
Here is my important proof
\end{proof}
如果證明的最後一行是顯示數學公式,則 Q.E.D. 符號將出現在後續的空行中。要在最後一行末尾放置 Q.E.D. 符號,請使用 \qedhere 命令
\begin{proof}
Here is my proof:
\[
a^2 + b^2 = c^2 \qedhere
\]
\end{proof}
上述方法不適用於已棄用的 eqnarray* 環境。請改用 align*。
要使用自定義 Q.E.D. 符號,請重新定義\qedsymbol命令。要完全隱藏 Q.E.D. 符號,請將其重新定義為空
\renewcommand{\qedsymbol}{}
它增加了透過使用標題中的 \theoremstyle 命令[1] 來更改 \newtheorem 定義的環境的輸出的可能性
\theoremstyle{stylename}
引數是要使用的樣式。所有後續定義的定理都將使用此樣式。以下是可能的預定義樣式列表
| stylename | 描述 | 外觀 |
|---|---|---|
| plain | 用於定理、引理、命題等(預設) | 定理 1. 定理文字。 |
| definition | 用於定義和示例 | 定義 2. 定義文字。 |
| remark | 用於備註和註釋 | 備註 3. 備註文字。 |
要定義你自己的樣式,請使用 \newtheoremstyle 命令[1]
\newtheoremstyle{stylename}% name of the style to be used
{spaceabove}% measure of space to leave above the theorem. E.g.: 3pt
{spacebelow}% measure of space to leave below the theorem. E.g.: 3pt
{bodyfont}% name of font to use in the body of the theorem
{indent}% measure of space to indent
{headfont}% name of head font
{headpunctuation}% punctuation between head and body
{headspace}% space after theorem head; " " = normal interword space
{headspec}% Manually specify head
(任何留空的引數都將假設其預設值)。以下是一個示例 headspec
\thmname{#1}\thmnumber{ #2}:\thmnote{ #3}
它看起來像這樣
定義 2:拓撲
對於以下內容
\begin{definition}[Topology]...
(註釋引數,在本例中是拓撲,始終是可選的,但預設情況下不會出現,除非你像上面在頭部規範中指定的那樣。)
定理環境與其他環境衝突,例如 wrapfigure。一種解決方法是重新定義定理,例如以下方式
% Fix latex
\def\smallskip{\vskip\smallskipamount}
\def\medskip{\vskip\medskipamount}
\def\bigskip{\vskip\bigskipamount}
% Hand made theorem
\newcounter{thm}[section]
\renewcommand{\thethm}{\thesection.\arabic{thm}}
\def\claim#1{\par\medskip\noindent\refstepcounter{thm}\hbox{\bf \arabic{chapter}.\arabic{section}.\arabic{thm}. #1.}
\it\ %\ignorespaces
}
\def\endclaim{
\par\medskip}
\newenvironment{thm}{\claim}{\endclaim}
在這種情況下,定理看起來像
\begin{thm}{Claim}\label{lyt-prob}
Let it be.
Then you know.
\end{thm}