Theorems, Proofs, and Advanced Mathematics
Use amsthm to define theorem, lemma, and definition environments, and proof to typeset proofs. amsmath and amssymb provide common operators, blackboard-bold sets, and mathematical symbols.
EasyLaTeX compiler setting: pdfLaTeX; load amsmath, amsthm, and amssymb.
Defining Theorem Environments
Declare environments in the preamble with \newtheorem. This setup numbers theorems by section, such as “Theorem 1.1”:
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
[section] restarts numbering at each \section; [theorem] makes lemmas and definitions share the theorem counter. Choose one consistent scheme that meets the document requirements rather than mixing schemes arbitrarily.
Theorems, Lemmas, and Definitions
Once declared, use the corresponding environments in the body:
\begin{theorem}[Pythagorean theorem]
In a right triangle, the sum of the squares of the legs equals the square of the hypotenuse.
\end{theorem}
\begin{definition}
If the set \(A\) has finitely many elements, then \(A\) is a finite set.
\end{definition}
The optional title in square brackets identifies the theorem. The definition style in amsthm normally uses upright body text and suits definitions, examples, and remarks.
Proofs
The proof environment supplied by amsthm automatically adds an end-of-proof symbol:
\begin{proof}
Assume \(a=b\). Adding \(c\) to both sides gives \(a+c=b+c\).
\end{proof}
When a proof ends with a displayed equation, you may need to place the symbol explicitly inside it:
\begin{proof}
\[
(a+b)^2 = a^2 + 2ab + b^2. \qedhere
\]
\end{proof}
\qedhere puts the symbol at the end of the equation instead of on a separate line.
Common Operators and Sets
Use built-in operator commands rather than typing operator names as separate italic letters:
\[
\sin x + \log y = \lim_{n \to \infty} a_n.
\]
Use \mathbb for standard number sets:
\[
\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}.
\]
amssymb provides \mathbb. Where notation for probability, expectation, rank, or similar concepts varies, define its meaning when first used.
Custom Operators
Define frequently used multi-letter operators in the preamble with \DeclareMathOperator:
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator*{\argmax}{arg\,max}
The starred form places limits directly below or above the operator in display math:
\[
\argmax_{x \in \mathbb{R}} f(x).
\]
Do not repeatedly imitate an operator with \mathrm{rank}: it does not handle spacing and limits like a real operator.
Common Problems
Undefined Environment
For Environment theorem undefined or Environment proof undefined, check that the preamble loads \usepackage{amsthm} and declares \newtheorem before the body starts.
Theorem Headings Do Not Match the Template
Check the default output against your institution's or publisher's template. If the template already defines theorem environments, reuse their names and numbering rules instead of declaring the same names again.
Undefined \mathbb
Load \usepackage{amssymb}. For any undefined symbol or command, identify the package that provides it rather than copying an unexplained collection of package settings.
Complete Example
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\DeclareMathOperator{\rank}{rank}
\begin{document}
\section{Example}
\begin{definition}
If \(A \subseteq \mathbb{R}\), then \(A\) is a subset of the real numbers.
\end{definition}
\begin{theorem}
For any real numbers \(a\) and \(b\), we have \((a+b)^2=a^2+2ab+b^2\).
\end{theorem}
\begin{proof}
Expanding \((a+b)(a+b)\) gives
\[
(a+b)^2 = a^2 + 2ab + b^2. \qedhere
\]
\end{proof}
\end{document}