LaTeX/定理编号
With "theorem" we can mean any kind of labelled enunciation that we want to look separated from the rest of the text and with sequential numbers next to it. This approach is commonly used for theorems in mathematics, but can be used for anything. LaTeX provides a command that will let you easily define any theorem-like enunciation.
基本定理
编辑首先,需要引用宏包 amsthm。
\usepackage{amsthm}
The easiest is the following:
\newtheorem{name}{Printed output}
put it in the preamble. The first argument is the name you will use to reference it, the second argument is the output LaTeX will print whenever you use it. For example:
\newtheorem{mydef}{Definition}
will define the mydef
environment; if you use it like this:
\begin{mydef}
Here is a new definition
\end{mydef}
It will look like this:
- Definition 3 Here is a new definition
with line breaks separating it from the rest of the text.
Theorem counters
编辑Often the counters are determined by section, for example "Theorem 2.3" refers to the 3rd theorem in the 2nd section of a document. In this case, specify the theorem as follows:
\newtheorem{name}{Printed output}[numberby]
where numberby specifies the section level (section/subsection/etc.) at which the numbering is to take place.
By default, each theorem uses its own counter. However it is common for similar types of theorems (e.g. Theorems, Lemmas and Corollaries) to share a counter. In this case, define subsequent theorems as:
\newtheorem{name}[counter]{Printed output}
where counter is the name of the counter to be used. Usually this will be the name of the master theorem.
You can also create a theorem environment that is not numbered by using the newtheorem*
command[1]. For instance,
\newtheorem*{mydef}{Definition}
defines the mydef
environment, which will generate definitions without numbering. This requires amsthm
package.
Proofs
编辑The proof
environment[1] can be used for adding the proof of a theorem. The basic usage is:
\begin{proof}
Here is my proof
\end{proof}
It just adds Proof in italics at the beginning of the text given as argument and a white square (Q.E.D symbol, also known as a tombstone) at the end of it. If you are writing in another language than English, just use babel with the right argument and the word Proof printed in the output will be translated accordingly; anyway, in the source the name of the environment remains proof
.
If you would like to manually name the proof, include the name in square brackets:
\begin{proof}[Proof of important theorem]
Here is my important proof
\end{proof}
If the last line of the proof is displayed math then the Q.E.D. symbol will appear on a subsequent empty line. To put the Q.E.D. symbol at the end of the last line, use the \qedhere
command:
\begin{proof}
Here is my proof:
\[
a^2 + b^2 = c^2 \qedhere
\]
\end{proof}
The method above does not work with the deprecated environment eqnarray*
. Here is a workaround:
\begin{proof}
Here is my proof:
\begin{eqnarray*}
a^2 + b^2 = c^2
\end{eqnarray*}
\vspace{-1.3cm}\[\qedhere\]
\end{proof}
To use a custom Q.E.D. symbol, redefine the \qedsymbol command. To hide the Q.E.D. symbol altogether, redefine it to be blank:
\renewcommand{\qedsymbol}{}
Theorem styles
编辑It adds the possibility to change the output of the environments defined by \newtheorem
using the \theoremstyle
command[1] command in the header:
\theoremstyle{stylename}
the argument is the style you want to use. All subsequently defined theorems will use this style. Here is a list of the possible pre-defined styles:
stylename | Description |
---|---|
plain | Used for theorems, lemmas, propositions, etc. (default) |
definition | Used for definitions and examples |
remark | Used for remarks and notes |
Custom styles
编辑To define your own style, use the \newtheoremstyle
command[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
(Any arguments that are left blank will assume their default value). Here is an example headspec:
\thmname{#1}\thmnumber{ #2}:\thmnote{ #3}
which would look something like:
Definition 2: Topology
for the following:
\begin{definition}[Topology]...
(The note argument, which in this case is Topology, is always optional, but will not appear by default unless you specify it as above in the head spec).
Conflicts
编辑The theorem environment conflicts with other environments, for example wrapfigure. A work around is to redefine theorem, for example the following way:
% 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}
In this case theorem looks like:
\begin{thm}{Claim}\label{lyt-prob}
Let it be.
Then you know.
\end{thm}
附記
编辑其他連結
编辑