LaTeX theorems and proofs Theorems & Proofs
Original text: Theorems and proofs
Translator: Xovee
Translation time: July 8, 2023
Article Directory
introduce
Mathematics documents usually have a lot of content that requires special formatting, such as theorems, definitions, propositions, arguments, corollaries, lemmas, and so on. This article describes how to define these environments in LaTeX.
LaTeX environments with numbering can \newtheorem
be created by the command, which takes two arguments:
\newtheorem{theorem}{Theorem}
- The first parameter is the name of the environment
- The second parameter is the text that the environment will display in the document. These texts are formatted in bold and appear at the beginning of the environment.
\documentclass{article}
\usepackage[english]{babel}
\newtheorem{theorem}{Theorem}
\begin{document}
\section{Introduction}
Theorems can easily be defined:
\begin{theorem}
Let \(f\) be a function whose derivative exists in every point, then \(f\)
is a continuous function.
\end{theorem}
\end{document}
The output of this example is:
Numbered theorems, definitions, corollaries, and lemmas (Theorems, Definitions, Corollaries, and Lemmas)
Environments with numbers are controlled by two additional parameters, for example in \newtheorem
:
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\begin{document}
\section{Introduction}
Theorems can easily be defined:
\begin{theorem}
Let \(f\) be a function whose derivative exists in every point, then \(f\) is
a continuous function.
\end{theorem}
\begin{theorem}[Pythagorean theorem]
\label{pythagorean}
This is a theorem about right triangles and can be summarised in the next
equation
\[ x^2 + y^2 = z^2 \]
\end{theorem}
And a consequence of theorem \ref{pythagorean} is the statement in the next
corollary.
\begin{corollary}
There's no right rectangle whose sides measure 3cm, 4cm, and 6cm.
\end{corollary}
You can reference theorems such as \ref{pythagorean} when a label is assigned.
\begin{lemma}
Given two line segments whose lengths are \(a\) and \(b\) respectively there is a
real number \(r\) such that \(b=ra\).
\end{lemma}
The output of this example is:
In this example, we define three new environments.
-
\newtheorem{theorem}{Theorem}[section]
We have added an extra parameter at the end[section]
, which is used to recount the environment in each new section. For example 1.1, 1.2, 1.3, 1.4, 2.1, 2.2, … -
\newtheorem{corollary}{Corollary}[theorem]
Similarly, each time a newtheorem
definition is made, the environment is recounted. -
\newtheorem{lemma}[theorem]{Lemma}
In this example,lemma
the environment we defined will usetheorem
the same count as the environment.
Some well-known theorems have their own names, and you can output their names explicitly: \begin{theorem}[Pythagorean theorem]
.
Like many other numbered environments in LaTeX, you can \label
refer to them using commands.
unnumbered theorem-like environment
You can also create theorem-like environments without numbers, for purposes such as comments or examples. amsthm
package provides this functionality.
\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsthm}
\newtheorem*{remark}{Remark}
\begin{document}
Unnumbered theorem-like environments are also possible.
\begin{remark}
This statement is true, I guess.
\end{remark}
\end{document}
The output of this example is: The syntax of
the command is the same as that of the version without the asterisk (except for the counter argument). \newtheorem*
In the above example, we created remark
the unnumbered environment named .
Theorem style
Sometimes we need to use styles to distinguish different environments, for example, in a document, use different styles to distinguish "theorem" and "definition". We can amsthm
do this using packages:
\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\theoremstyle{remark}
\newtheorem*{remark}{Remark}
\begin{document}
\section{Introduction}
Unnumbered theorem-like environments are also possible.
\begin{remark}
This statement is true, I guess.
\end{remark}
And the next is a somewhat informal definition
\begin{definition}[Fibration]
A fibration is a mapping between two topological spaces that has the homotopy lifting property for every space \(X\).
\end{definition}
\end{document}
The output of this example is:
The command \theoremstyle{ }
sets the style for this numbering environment. In this example, we used two styles: style
and definition
. Style
Styles use italic and Roman fonts, while definition
styles use bold and Roman fonts.
See the end of the article for more types of styles.
prove
Proofs are a very important part of mathematical documentation. Its style also usually needs to be differentiated from the body text. amsthm
The package provides proof
the environment:
\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\begin{document}
\section{Introduction}
\begin{lemma}
Given two line segments whose lengths are \(a\) and \(b\) respectively there
is a real number \(r\) such that \(b=ra\).
\end{lemma}
\begin{proof}
To prove it by contradiction try and assume that the statement is false,
proceed from there and at some point you will arrive to a contradiction.
\end{proof}
\end{document}
The output of this example is:
We can see that the font of Proof is italic, there is a small blank space between it and the following text, and there is a special symbol at the end of the proof (in this example, it is a box, we can use other special symbols).
Change QED symbol
Prove that the special symbol at the end is called the QED symbol:
QED is an initialism of the Latin phrase quod erat demonstrandum, meaning “thus it has been demonstrated” – Wikipedia
You can easily change the QED notation:
\renewcommand\qedsymbol{$\blacksquare$}
You can also directly use QED
three letters as the QED symbol:
\renewcommand\qedsymbol{QED}
See the example below:
\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{amssymb}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\begin{document}
\section{Introduction}
\begin{lemma}
Given two line segments whose lengths are \(a\) and \(b\) respectively there
is a real number \(r\) such that \(b=ra\).
\end{lemma}
\renewcommand\qedsymbol{$\blacksquare$}
\begin{proof}
To prove it by contradiction try and assume that the statement is false,
proceed from there and at some point you will arrive to a contradiction.
\end{proof}
\renewcommand\qedsymbol{QED}
\begin{proof}
To prove it by contradiction try and assume that the statement is false,
proceed from there and at some point you will arrive to a contradiction.
\end{proof}
\end{document}
optional theorem style
definition
: Title in bold, Roman text. Generally used in definitions (definition), conditions (condition), problems (problem) and examples (example).plain
: Headings in bold, text in italics. Generally used in theorem (theorem), lemma (lemma), inference (corollary), proposition (proposition) and conjecture (conjecture).remark
: Title in italics, Roman text. Generally used in comments (remark), notes (notes), annotation (annotation), statement (claim), case (case), acknowledgment (acknowledgment) and conclusion (conclusion).