# LaTeX/Theorems

With "theorem" we can mean any kind of labelled enunciation that we want to look separated from the rest of the text and with sequential numbers next to it. This approach is commonly used for theorems in mathematics, but can be used for anything. LaTeX provides a command that will let you easily define any theorem-like enunciation.

## Basic theorems

First of all, make sure you have the amsthm package enabled:
The easiest is the following:
put it in the preamble. The first argument is the name you will use to reference it, the second argument is the output LaTeX will print whenever you use it. For example:
will define the mydef environment; if you use it like this:
It will look like this:
with line breaks separating it from the rest of the text.

## Theorem counters

Often the counters are determined by section, for example "Theorem 2.3" refers to the 3rd theorem in the 2nd section of a document. In this case, specify the theorem in the preamble as follows:
and use it when needed:
or, with a generic 'name' to output 'Printed output', add 'numberby':
where numberby is the name of the section level (section/subsection/etc.) at which the numbering is to take place.
By default, each theorem uses its own counter. However it is common for similar types of theorems (e.g. Theorems, Lemmas and Corollaries) to share a counter. In this case, define subsequent theorems as:
where counter is the name of the counter to be used. Usually this will be the name of the master theorem.
The \newtheorem command may have at most one optional argument.
You can also create a theorem environment that is not numbered by using the newtheorem* command. For instance,
defines the mydef environment, which will generate definitions without numbering. This requires amsthm package.

## Proofs

The proof environment can be used for adding the proof of a theorem. The basic usage is:
It just adds Proof in italics at the beginning of the text given as argument and a white square (Q.E.D. symbol, also known as a tombstone) at the end of it. If you are writing in another language than English, just use babel with the right argument and the word Proof printed in the output will be translated accordingly; anyway, in the source the name of the environment remains proof.
If you would like to manually name the proof, include the name in square brackets:
If the last line of the proof is displayed math then the Q.E.D. symbol will appear on a subsequent empty line. To put the Q.E.D. symbol at the end of the last line, use the \qedhere command:
The method above does not work with the deprecated environment eqnarray*. Use align* instead.
To use a custom Q.E.D. symbol, redefine the \qedsymbol command. To hide the Q.E.D. symbol altogether, redefine it to be blank:

## Theorem styles

It adds the possibility to change the output of the environments defined by \newtheorem using the \theoremstyle command in the header:
the argument is the style you want to use. All subsequently defined theorems will use this style. Here is a list of the possible pre-defined styles:
| stylename | Description | Appearance |
| plain | Used for theorems, lemmas, propositions, etc. (default) | Theorem 1. Theorem text. |
| definition | Used for definitions and examples | Definition 2. Definition text. |
| remark | Used for remarks and notes | Remark 3. Remark text. |

### Custom styles

To define your own style, use the \newtheoremstyle command:
(Any arguments that are left blank will assume their default value). Here is an example headspec:
which would look something like: Definition 2: Topology for the following:
(The note argument, which in this case is Topology, is always optional, but will not appear by default unless you specify it as above in the head spec).

## Conflicts

The theorem environment conflicts with other environments, for example wrapfigure. A work around is to redefine theorem, for example the following way:
In this case theorem looks like:

## Notes

* 1 2 3 4 Requires the amsthm package

## External links

* amsthm v2.20.3 documentation