Theorems & proofs (amsthm)

Theorems, lemmas, definitions, and proofs follow a fixed look: a bold opener like Theorem 3.1, an italic body, an automatically assigned running number, and a small hollow square (□) at the end of a proof. Setting all of that by hand is tedious, so **amsthm** — a sibling of amsmath — gives you a way to *declare* theorem-like environments once, plus a dedicated proof environment. This page covers declaring environments with \newtheorem, sharing counters and numbering within a section, unnumbered variants, switching the look with \theoremstyle, the proof environment and its end-of-proof symbol, and the modern higher-level interface thmtools.

Declaring a theorem environment

A theorem-like structure is first declared as an environment in the preamble, and then used in the body. You declare it with \newtheorem. The first argument is the name of the environment (what you write in \begin{…}), and the second is the word printed in bold in the heading. For instance, the following makes a theorem environment available.

latex
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}        % プリアンブルで宣言 / declare in the preamble

With that in place, each use of the theorem environment in the body gets a bold heading and a running number — Theorem 1, Theorem 2 — and the text inside is set in italic (in the default style). The number is managed by a LaTeX counter, so inserting a theorem in the middle automatically renumbers the ones after it.

latex
\begin{theorem}
  素数は無限に存在する。
\end{theorem}

\begin{theorem}
  There are infinitely many primes.
\end{theorem}

Note that \newtheorem is also part of base LaTeX (standard LaTeX2e). Plain \newtheorem can make numbered theorem environments on its own, but the **style switching (\theoremstyle), the unnumbered starred form (\newtheorem*), the proof environment, and the end-of-proof symbol** described below are all extensions that become available only once you load amsthm. For mathematical writing, loading amsthm (alongside amsmath) is the standard move.

Controlling the numbering

Numbering theorems, lemmas, and corollaries each on their own counter scatters the same numbers about — “Theorem 1, Lemma 1, Theorem 2, Lemma 2…” — which is confusing. Most mathematical writing instead gives them a shared number, running “Theorem 1, Lemma 2, Theorem 3…”. The optional argument (in square brackets) of \newtheorem lets you control this precisely. The key is that the bracket means different things depending on where it sits.

To share a counter, give an existing environment name in brackets immediately after the new name. In the example below lemma uses the same counter as theorem, so theorems and lemmas draw from one shared sequence of numbers.

latex
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}   % theorem と番号を共有 / share theorem’s counter

To instead restart the count in each chapter or section and prefix the section number — giving “Theorem 2.1, Theorem 2.2” — put the bracket with a parent counter (such as section) after the second argument. The theorem number then resets to 1 at every new section and is shown combined with the section number.

latex
\newtheorem{theorem}{Theorem}[section]   % 節ごとにリセットし「2.1」形式 / reset per section, “2.1” style

You cannot use both brackets at once, but you can also subordinate a counter to another environment. For example \newtheorem{corollary}{Corollary}[theorem] makes the corollary number reset every time a theorem appears, so it carries the parent theorem number, as in “Corollary 3.1 (the first corollary attached to Theorem 3).” The table sorts out where the bracket goes and what it does.

DeclarationEffect
\newtheorem{theorem}{Theorem}Its own independent running numberNumbered 1, 2, 3, … on its own counter
\newtheorem{lemma}[theorem]{Lemma}Shares the theorem counter (one sequence)Lemmas and theorems share one number sequence
\newtheorem{theorem}{Theorem}[section]Resets each section; prefixed as “2.1”Restarts at every \section, prefixed by section no.
\newtheorem{corollary}{Corollary}[theorem]Resets at each theorem; shown as “3.1”Subordinate to the theorem counter

Unnumbered, and adding a name

For a theorem-like environment you do not want numbered — something that appears only once, such as a “Remark” or a “Main Theorem” — use the **starred \newtheorem*** that amsthm provides. It assigns no number at all and prints only the heading word. Its syntax matches the unstarred \newtheorem, differing only in that it takes no counter-related arguments.

latex
\newtheorem*{remark}{Remark}   % 番号なし(amsthm が必要) / unnumbered (needs amsthm)

You can also attach a specific name or attribution to an individual theorem. When you open the environment in the body, pass a name in brackets right after \begin{theorem}, and it is shown in parentheses following the number. The example below, for instance, produces a heading like “Theorem 1 (Pythagorean theorem).”

latex
\begin{theorem}[Pythagorean theorem]
  直角三角形において $a^2 + b^2 = c^2$ が成り立つ。
\end{theorem}

This bracket is independent of whether the environment is numbered. For a numbered environment you get “number + (name),” and for an unnumbered one made with \newtheorem* you get “heading word + (name)” — in both cases the name is appended in parentheses.

Choosing the look: \theoremstyle

amsthm provides **\theoremstyle** to switch the look of theorem-like environments. There are three built-in styles, differing in the combination of fonts for the heading (head) and the text (body). The crucial point is that \theoremstyle{…} **applies to every \newtheorem declared after it**. So you set the style *before* the \newtheorem declarations, grouping declarations by style. If you set nothing, the default is **plain**.

  • plain: bold heading, italic body**. For assertions you state emphatically — theorems, lemmas, propositions, corollaries. This is the default when nothing is set.
  • definition: bold heading, upright (roman) body**. For things meant to read as ordinary prose — definitions, examples, problems, conditions.
  • remark: italic heading**, upright body. For asides — remarks, notes, claims.

The following preamble is a typical setup: it mixes the three styles while sharing one counter across theorem, lemma, and corollary. Under \theoremstyle{plain} it declares theorem, lemma, and corollary; under \theoremstyle{definition}, definition and example; and under \theoremstyle{remark}, remark.

latex
\usepackage{amsmath, amsthm}

\theoremstyle{plain}              % 本文イタリック / italic body
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}

\theoremstyle{definition}        % 本文立体 / upright body
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}

\theoremstyle{remark}            % 見出しイタリック / italic head
\newtheorem*{remark}{Remark}

With this setup, theorem, lemma, corollary, definition, and example all share one per-section number (“Theorem 2.1, Definition 2.2, Lemma 2.3…”); the bodies of theorems, lemmas, and corollaries are italic, while those of definitions and examples are upright. Only remark is unnumbered, with its “Remark” heading in italic. Take care with placement: if you put \theoremstyle *after* a \newtheorem, that declaration is unaffected and keeps the previous style (or plain if none was set yet).

The proof environment and the QED symbol

amsthm also provides a dedicated **proof environment** (again, not in base LaTeX — this is an amsthm feature). The proof environment automatically places an italic “Proof.” heading at the start and an end-of-proof symbol at the end — by default a small hollow square (□, the tombstone or QED symbol).

latex
\begin{proof}
  $\sqrt{2}$ が有理数だと仮定して矛盾を導く。……よって $\sqrt{2}$ は無理数である。
\end{proof}

The heading word can be changed. The proof environment also accepts a per-instance bracket argument, so writing \begin{proof}[Proof of Theorem 1] replaces the heading with “Proof of Theorem 1.” (or, say, \begin{proof}[Proof of the lemma]).

The placement of the end-of-proof symbol needs care. amsthm tries to set the symbol at the end of the last line of text, but when a proof ends with a displayed equation or a list environment, the symbol can drop onto a line of its own. To handle this, put an explicit **\qedhere** where you want the symbol. Placed at the end of a display, for instance, it tucks the □ at the right of that equation’s line.

latex
\begin{proof}
  両辺を整理すると、次を得る。
  \[
    a^2 + b^2 = c^2. \qedhere
  \]
\end{proof}

The symbol itself can be changed too. Redefine \qedsymbol to use a filled square (■), a text string, or any end marker you like; to remove it entirely, redefine it as empty. Put one of these in the preamble.

latex
\renewcommand{\qedsymbol}{$\blacksquare$}   % 黒い四角に / filled square
% \renewcommand{\qedsymbol}{}              % 記号を消す / remove the symbol

thmtools: a modern higher-level interface

As declarations multiply, specifying numbering through the position of \newtheorem’s brackets gets hard to read. **thmtools is a higher-level interface on top of** amsthm (or ntheorem) that offers \declaretheorem, where everything is given as key=value options. thmtools itself holds no numbering machinery — it calls amsthm’s \newtheorem as its backend — so you load it alongside amsthm.

At its simplest you pass just the environment name, and write numbering control as keys. Subordination to a section is numberwithin= (the synonyms parent= and within= also work); sharing a counter is sibling= (synonyms numberlike= and sharecounter=); unnumbered is numbered=no; the heading word is name= (synonyms title= and heading=); and the style is style=. The example below writes nearly the same setup as the amsthm version above, using thmtools.

latex
\usepackage{amsthm, thmtools}

\declaretheorem[numberwithin=section]{theorem}
\declaretheorem[sibling=theorem]{lemma}
\declaretheorem[style=definition, sibling=theorem]{definition}
\declaretheorem[numbered=no, name=Remark]{remark}

The strength of thmtools is that it makes advanced features — awkward with amsthm alone — quick to use. A prime example is restating (restatable). Load the thm-restate package (bundled with thmtools) and write a theorem in a restatable environment, and its content is stored as a macro so you can restate the same theorem later, keeping its original number. The restatable environment’s first (optional) argument is a name, the second is the theorem environment to use, and the third is the macro name that remembers the content.

latex
\usepackage{amsthm, thmtools, thm-restate}
\declaretheorem{theorem}

% 本編:内容を \firsteuclid に保存 / store the content in \firsteuclid
\begin{restatable}[Euclid]{theorem}{firsteuclid}
  \label{thm:euclid}
  There are infinitely many primes.
\end{restatable}

% 付録などで同じ定理・同じ番号を再掲 / restate later with the same number
\firsteuclid*

Expanding the stored macro \firsteuclid later sets that theorem again with its original number (the number stays fixed to the original occurrence, as do any displayed-equation numbers within). Adding a star, \firsteuclid*, restates it while keeping cross-references (\label/\ref) pointed at the original declaration rather than the restated copy. This is handy when you want to state a result with its number in the main text but place its proof in an appendix.

Another convenience is a list of theorems. Writing \listoftheorems auto-generates a contents-like list of theorems, lemmas, and so on. You can narrow it by first excluding everything with ignoreall and then naming the environments to include with show={…}. Using onlynamed (or onlynamed={…}) lists only the theorems you gave a name to, as in \begin{…}[name].

latex
\listoftheorems                                  % すべて / everything
\listoftheorems[ignoreall, show={theorem, lemma}]   % theorem と lemma だけ / only these

To craft your own look, define a new style with thmtools\declaretheoremstyle and invoke it via \declaretheorem[style=…]{…}. You can set, by key, the heading font (headfont), body font (bodyfont), space above and below (spaceabove, spacebelow), the braces around the note (notebraces), the gap after the head (postheadspace), the end symbol (qed), and more. You need not reach for it when plain amsthm suffices, but it is a powerful option for elaborate theorem setups.