Mathematical documents include elements that require special formatting and numbering such as theorems, definitions, propositions, remarks, corollaries, lemmas and so on. This article explains how to define these environments in LaTeX.

Numbered environments in LaTeX can be defined by means of the command `\newtheorem`

. An example is presented below:

```
\documentclass{article}
\usepackage[utf8]{inputenc}
\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 command `\newtheorem{theorem}{Theorem}`

has two parameters, the first one is the name of the environment that is defined, the second one is the word that will be printed, in boldface font, at the beginning of the environment. Once this new environment is defined it can be used normally within the document, delimited it with the marks `\begin{theorem}`

and `\end{theorem}`

.

The numbering of the environments can be controlled by means of two additional parameters in the `\newtheorem`

command. Let's see:

```
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\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 theorema 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}
```

There are three new environments defined in the preamble.

`\newtheorem{theorem}{Theorem}[section]`

- This is the example presented in the introduction but it has the additional parameter
`[section]`

that restarts the theorem counter at every new section.

`\newtheorem{corollary}{Corollary}[theorem]`

- A environment called
*corollary*is created, the counter of this new environment will be reset every time a new*theorem*environment is used.

`\newtheorem{lemma}[theorem]{Lemma}`

- In this case, the even though a new environment called
*lemma*is created, it will use the same counter as the*theorem*environment.

Some famous theorems have their own names, for these cases you can add said name inside brackets in the environment opening command. In the example the line `\begin{theorem}[Pythagorean theorem]`

prints "Pythagorean theorem" at the beginning of the paragraph.

As with many other numbered elements in LaTeX, the command `\label`

can be used to reference theorem-like environments within the document.

Sometimes it becomes handy to have an unnumbered theorem-like environments to add remarks, comments or examples to a mathematical document. The package **amsthm** provides this functionality.

```
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsthm}
\newtheorem*{remark}{Remark}
\begin{document}
Unnumbered theorem-like environments are also posible.
\begin{remark}
This statement is true, I guess.
\end{remark}
\end{document}
```

The syntax of the command `\newtheorem*`

is the same as the non-starred version, except for the counter parameters. In this example a new unnumbered environment called *remark* is created.

A feature that is important when working in a mathematical document is to easily tell apart, say, definitions from theorems by its formatting. The package **amsthm** provide special commands to accomplish this.

```
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\theoremstyle{remark}
\newtheorem*{remark}{Remark}
\begin{document}
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
\theoremstyle{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 command `\theoremstyle{ }`

sets the styling for the numbered environment defined right below it. In the example above the styles *remark* and *definition* are used. Notice that the remark is now in italics and the text in the environment uses normal (Roman) typeface, the definition on the other hand also uses Roman typeface for the text within but the word "Definition" is printed in boldface font.

See the reference guide for more theorem styles.

Proofs are the core of mathematical papers and books and is customary to keep them visually apart from the normal text in the document. The package **amsthm** provides the environment *proof* for this.

```
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsthm}
\begin{document}
\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 word *Proof* is italicized and there is some extra spacing, also a special symbol is used to mark the end of the proof. This symbol can be easily changed, to learn how see the next section.

To change the symbol printed at the end of a proof is straightforward.

```
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsthm}
\renewcommand\qedsymbol{$\blacksquare$}
\begin{document}
\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 statemenet is false,
proceed from there and at some point you will arrive to a contradiction.
\end{proof}
\end{document}
```

The command `\renewcommand\qedsymbol{$\blacksquare$}`

changed the default white square for a black square that is printed by `$\blacksquare$`

, the parameter inside the braces. You can change this for any other symbol or text, for instance you can use

```
\renewcommand\qedsymbol{QED}
```

To print the traditional * QED* (quod erat demonstrandum) at the end of a proof.

**Theorem styles**

`definition`

boldface title, romand body. Commonly used in definitions, conditions, problems and examples.`plain`

boldface title, italicized body. Commonly used in theorems, lemmas, corollaries, propositions and conjectures.`remark`

italicized title, romman body. Commonly used in remarks, notes, annotations, claims, cases, acknowledgments and conclusions.

For more information see:

- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides

- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors

- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts

- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package

- Bibliography management in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles

- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish

- Sections and chapters
- Table of contents
- Cross referencing sections and equations
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks

- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes

- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typing exams in LaTeX
- Knitr
- Attribute Value Matrices

- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
- Tips