Theorems, lemmas and proofs in LaTeX (newtheorem, amsthm)

\newtheorem{theorem}{Theorem} in the preamble creates a numbered theorem environment. The amsthm package adds the proof environment, three styles and unnumbered versions.

Preamble

The snippets on this page need these lines before \begin{document}:

\usepackage{amsthm}
\newtheorem{theorem}{Theorem}

Define and use a theorem

The first argument of \newtheorem is the name of the environment, the second the heading that is printed. Each theorem gets the next number. An optional argument of \begin{theorem}[...] appears in parentheses after the number.

Complete document:

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[Pythagoras]
  In a right triangle with legs $a$ and $b$ and hypotenuse $c$,
  $a^2 + b^2 = c^2$.
\end{theorem}
\end{document}
Result
The compiled example

Open in the editor

Write a proof

The proof environment from amsthm starts with "Proof." in italics and ends with a small square at the right margin. An optional argument replaces the heading: \begin{proof}[Proof of Theorem 1]. With babel the heading follows the language, for example "Beweis" with ngerman.

\begin{proof}
  Four copies of the triangle fit into a square with side $a + b$.
  Comparing the areas gives the claim.
\end{proof}
Result
The compiled example

Open in the editor

Lemmas and numbering per section

An optional argument in the middle names an existing environment whose counter is shared: Theorem 1 is followed by Lemma 2. An optional argument at the end names a sectioning unit: the number becomes 1.1, 1.2 and restarts in every section.

This goes into the preamble.

\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}{Proposition}[section]

Open in the editor

Definitions, remarks and unnumbered statements

\theoremstyle applies to the \newtheorem lines after it. plain, the default, prints a bold heading and italic text. definition prints a bold heading and upright text, remark an italic heading and upright text. \newtheorem* creates an environment without a number.

This goes into the preamble.

\theoremstyle{definition}
\newtheorem{definition}{Definition}
\theoremstyle{remark}
\newtheorem{remark}{Remark}
\newtheorem*{claim}{Claim}

Open in the editor

A proof that ends with a formula

When a proof ends with a display formula or a list, the square lands on an empty line below it. \qedhere at the end of the formula or the last item moves the square into that line.

\begin{proof}
  The claim follows from
  \[
    a^2 + b^2 = c^2. \qedhere
  \]
\end{proof}
Result
The compiled example

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages