Writing Latex
Writing Latex
Writing Latex
Jendrik Stelzner
Available at https://github.com/cionx/writing-latex.
Please send comments and corrections to stelzner@uni-bonn.de.
Preface
Das Auge liest mit.
German saying
This text presents some thoughts about what (not) to do in mathematical typesetting
using LATEX. Examples are provided using the environment tcblisting from the
package tcolorbox. This text is not intended as a first introduction to LATEX. Some of
the following remarks are subject to individual taste.
ii
Contents
Preface ii
iii
Contents
3 Writing text 47
3.1 Obey orthography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.2 Proper punctuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.2.1 A sentence ends with punctuation . . . . . . . . . . . . . . . . 47
3.2.2 Punctuation in commutative diagrams? . . . . . . . . . . . . . 48
3.2.3 Lists contain punctuation . . . . . . . . . . . . . . . . . . . . . 50
3.2.4 Hyphen and dashes . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.2.5 Correct spacing after a period . . . . . . . . . . . . . . . . . . . 53
3.3 Text layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.3.1 Use non-breakable space . . . . . . . . . . . . . . . . . . . . . . 56
3.3.2 Don’t use \\ or \newline . . . . . . . . . . . . . . . . . . . . . . 57
3.3.3 Text consisting of lists . . . . . . . . . . . . . . . . . . . . . . . 58
3.4 Mathematics in text . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.4.1 Don’t break inline mathematics . . . . . . . . . . . . . . . . . . 61
3.4.2 Don’t begin a sentence with a mathematical symbol . . . . . . 62
3.4.3 Don’t put two formulas next to each other . . . . . . . . . . . . 63
3.4.4 Don’t begin a line with a mathematical symbol (optional) . . . 64
3.5 Text in mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.5.1 Use \text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.5.2 Put space around text in display mathematics . . . . . . . . . . 66
3.5.3 Use \intertext and \shortintertext . . . . . . . . . . . . . . . 67
3.6 Mathematics as text . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.6.1 Don’t abuse math as text . . . . . . . . . . . . . . . . . . . . . 70
3.6.2 Logical symbols don’t replace text . . . . . . . . . . . . . . . . 71
3.6.3 Don’t use “iff” . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
iv
Contents
5 Mathematical layout 97
5.1 Environments for display mathematics . . . . . . . . . . . . . . . . . . 97
5.1.1 Don’t use $$ $$ or eqnarray . . . . . . . . . . . . . . . . . . . . 97
5.1.2 The environments \[ \] and equation* . . . . . . . . . . . . . 97
5.1.3 The environment gather* . . . . . . . . . . . . . . . . . . . . . 98
5.1.4 The environments align* and alignat* . . . . . . . . . . . . . 99
5.1.5 Don’t use center plus $ $ . . . . . . . . . . . . . . . . . . . . . 101
5.1.6 The environments gathered, aligned and alignedat . . . . . . . 101
5.1.7 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
5.2 Where to break and align formulas . . . . . . . . . . . . . . . . . . . . 102
5.2.1 When to break a formula . . . . . . . . . . . . . . . . . . . . . 103
5.2.2 Where to break and align a formula . . . . . . . . . . . . . . . 106
5.2.3 Don’t break formulas badly . . . . . . . . . . . . . . . . . . . . 110
5.3 Aligning nearly aligned formulas . . . . . . . . . . . . . . . . . . . . . 113
5.4 Proper spacing before multi-line display mode environments . . . . . . 115
5.5 Use the cases environment . . . . . . . . . . . . . . . . . . . . . . . . 116
5.6 Proper placement of the qed-symbol . . . . . . . . . . . . . . . . . . . 117
5.7 Tagging and numbering . . . . . . . . . . . . . . . . . . . . . . . . . . 121
5.7.1 Don’t autonumber all formulas . . . . . . . . . . . . . . . . . . 121
5.7.2 \tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
5.7.3 \notag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
5.8 Multi-line set descriptions . . . . . . . . . . . . . . . . . . . . . . . . . 123
Bibliography 124
v
Contents
Index 131
vi
List of tables
2.1 The commands \*name*ref. . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Possible labels for the environment enumerate. . . . . . . . . . . . . . . 23
vii
List of figures
1.1 Splitting up a project into files. . . . . . . . . . . . . . . . . . . . . . . 5
viii
Chapter 1
Before you start writing
A dozen mistakes and bad choices can be made before even the first word of actual text
is written. In this chapter we talk about how to prevent this from happening. Some
of the points – those about code quality and code management – are not unique to
writing LATEX.
1
1.3 Code quality
1 \[\begin{pmatrix*}[r]a^2+b^2&a^2-b^2\\-a^2+b^2&-a^2-b^2\end{pmatrix*}\]
1 \[
2 \begin{pmatrix*}[r]
3 a^2 + b^2 & a^2 - b^2 \\
4 -a^2 + b^2 & -a^2 - b^2
5 \end{pmatrix*}
6 \]
1 \[
2 \begin{pmatrix*}[r]
3 a^2 + b^2
4 &
5 a^2 - b^2
6 \\
7 - a^2 + b^2
8 &
9 - a^2 - b^2
10 \end{pmatrix*}
11 \]
1 $y=\sin(x)-e^x$
2
1.3 Code quality
1 $y = \sin(x) - e^x$
One could (and probably should) go even further and do the following:
Example 1.6: Unrelated symbols are separated even better
1 $y = \sin ( x ) - e^x$
1
1 Here is some text.
Here is some text.
2 \footnote{Here is a footnote for
1 Here is a footnote for this text.
this text.}
Note the unwanted space between the period and the superscript of the footnote. This
unwanted space comes from the line break that occurs between them in the source
code. By ending the first line with % we can “comment out” this line break. We hence
do the following:
3
1.4 Splitting up a project into multiple files
• The commands \include and \input insert the text of the specified documents
at the position where they are used, but have slight differences:
◦ The command \include ensures that the specified content starts on a new
page, and also that the following content begins on a new page. The
command \input simply inserts the specified content at the given position
without any such additional formatting.
◦ The command \include cannot be nested: The specified file is not allowed
to include the command \include again.
One should use the command \include for chapters and the command \input for
any smaller level of text organization. One should in particular break the main text
into smaller units until each of them can be put into its own file of sensible length.
Suppose for example that your text consists of three chapters, each of which consists
of two sections. Then you should have at least ten files:
• A master file main.tex. This file includes all other files in some way, and this is
the file which needs to be compiled.
• A file mystyle.sty in which packages are included and options are set.
• Three files like chapter1.tex, chapter2.tex and chapter3.tex for the chapters.
• Six files for the sections, say section1.tex up to section6.tex.
These files should include each other as shown in Figure 1.1. We suppose for simplicity
that all ten files are contained in the same directory. The master file main.tex should
look roughly as follows:
4
1.4 Splitting up a project into multiple files
main
1 \documentclass[a4paper, 10pt]{scrreprt}
2
3 \usepackage{mystyle}
4
5 \title{A Report}
6 \author{John Doe}
7
8 \begin{document}
9
10 \maketitle
11
12 \include{chapter1}
13 \include{chapter2}
14
15 \end{document}
1 %%%%% PACKAGES
2
3 % general mathematics
4 \usepackage{mathtools}
5 \usepackage{amssymb}
6
7 % commutative diagrams
8 \usepackage{tikz-cd}
9
5
1.4 Splitting up a project into multiple files
12 % new operators
13 \DeclareMathOperator{\End}{End}
14 \DeclareMathOperator{\Hom}{Hom}
5 \input{section1}
6 \input{section2}
1 \documentclass[a4paper, 10pt]{scrreprt}
2
3 \begin{document}
4
5 \include{chapter1}
6 \include{chapter2}
7
8 \end{document}
6
1.4 Splitting up a project into multiple files
1 \documentclass[a4paper, 10pt]{scrreprt}
2
3 \includeonly{chapter1}
4 \begin{document}
5
6 \include{chapter1}
7 \include{chapter2}
8
9 \end{document}
If in the above situation chapter 1 contains some references to chapter 2 then these
references will still compile correctly, even though only chapter 1 is compiled.
The command \includeonly has two quirks, which follow from the way LATEX handles
referencing:
When LATEX compiles the file main.tex an auxiliary file main.aux is created. This
file contains various information about the compiled document. It does in particular
contain a list of all labels found in main.tex during the compilation process. The next
compilation process can then access these information to properly properly typeset all
references that refer to these labels.
A feature of the command \include (which the command \input does not have)
is that such an auxiliary file is also generated for the included file. So in the above
example the files chapter1.aux and chapter2.aux will be created. These files will in
particular contain lists of all the labels found in chapter1.tex and chapter2.tex. This
allows LATEX to access the labels in chapter2.tex even though only chapter1.tex is
compiled.
The auxiliary file chapter2.aux remains unchanged because LATEX does not go trough
the file chapter2.tex as long as the code \includeonly{chapter1} is used. This leads
to the two quirks mentioned above:
• Before inserting the code \includeonly{chapter1} one needs to compile the whole
document, including chapter2.tex, a least once. This needs to be done so that
LATEX can properly create the auxiliary file chapter2.aux.
• Changes made to the file chapter2.tex will not be noticed by LATEX while the
code \includeonly{chapter1} is present. This means in particular that LATEX
won’t notice any new labels that are added in this file. In this case one need to
stop excluding chapter1.tex for at least on compilation process to ensure that
the auxiliary file chapter2.aux is refreshed.
The command \includeonly actually accepts as its argument a list of files to be
included:
7
1.5 Choosing the document class
• The default font of the KOMA-Script classes for headings and description labels
is a bold sans-serif font. It can be changed to the standard serif font with help of
the command \setkomafont.
Example 1.17: Changing KOMA fonts
1 \addtokomafont{disposition}{\rmfamily}
2 \addtokomafont{descriptionlabel}{\rmfamily}
8
1.5 Choosing the document class
3 \begin{document}
4
5 \begin{abstract}
6 Our results are cool and our proofs have no details.
7 \end{abstract}
8
9 \end{document}
The class scrreprt extends the previous class: It provides the additional sectioning
command \chapter that precedes \section. The title is now printed its own page,
although this can by setting the option titlepage to false:
Example 1.20: Using the option titlepage
It also provides the sectioning command \abstract after which all chapters will be
counted towards the appendix. The abstract environment is still available in the same
way as before. (But the abstract is printed only on the second page, after the title
page.)
The class scrbook provides the additional sectioning command \part that pre-
cedes \chapter. This class also provides the (very useful) additional sectioning com-
mands \frontmatter, \mainmatter and \backmatter. The abstract environment isn’t
available anymore. This class distinguish between left and right pages, i.e. even and
odd pages. This can be disabled by using the option oneside:
Example 1.21: Using the option oneside
By default chapters will begin on the right side. This can be disabled with the
option openany:
Example 1.22: Using the option openany
When the option oneside is used then chapters can start on both the left pages and
the right pages. So option openany is then not needed.
In practice one should use the class scrartcl if only sections and subsections are used,
and otherwise the class scrbook. Instead of scrreprt one should directly use scrbook:
The additional commands \frontmatter, \mainmatter and \backmatter that scrbook pro-
vides are extremely useful (see Section 1.6), and the visual difference between scrreprt
9
1.6 Use \frontmatter and its friends
and scrbook (which is their main difference) can easily be adjusted by passing the
option openany to \documentclass:
Example 1.23: Using the option openany
• The front part uses lower case roman numerals for page numbers. In the generated
Pagepdf-file these pages will again be numbered with roman numerals (this will
be important for the main part). Chapters in this part of the document will not
be numbered, but will appear in the table of contents.
This part of the document should include the title page, preface, table of content
and introduction. Basically everything that occurs before the first chapter.
• The main part uses Arabic numerals for page numbers and the page number is
reset when the main part starts. The first page of the main part is therefore
numbered “1”. In the generated pdf-file this first page will also be numbered as
such. This means that going to page 15 of the pdf-file will indeed give page 15
of the document. The chapters in this part of the document are numbered and
appear in the table of contents.
This part of the document does contain the vast amount of the document. It
contains all the chapters excluding the ones belonging into the appendix.
• The appendix part continues the numbering of the main part. It both resets the
chapter number and changes its style to upper case letters. The first chapter in
this part will hence be numbered “A”. If the option chapterprefix = true is set
then the word “Chapter” at the beginning of a new \chapter will be replaced
by “Appendix”.
This part of the document should contain all appendices.
• The back part continues the numbering of the appendix (and thus the numbering
of the main part). The chapters appearing in this part of the document are again
unnumbered, and no “Chapter” is printed at the beginning of a new \chapter is
printed.
This part of the document should contain the bibliography and the index. An
entry for the bibliography can be added to the table of contents by setting the
option bibliography to totoc.
The document layout with scrbook should therefore look roughly as follows:
10
1.7 Be consistent
1 \documentclass[a4paper, 10pt,bibliography=totocnumbered]{scrbook}
2
3 % preamble
4
5 \begin{document}
6
7 \frontmatter
8 \maketitle
9 % dedication
10 % preface
11 \tableofcontents
12 % introduction
13
14 \mainmatter
15 % most of the document
16
17 \appendix
18 % the appendices
19
20 \backmatter
21 \printbibliography
22 % index
23 \end{document}
1.7 Be consistent
One of the most important aspects of both mathematical writing and the use of
mathematical notation is consistency. If you’re making crappy choices then at least do
them consistently, in the same way. Consider the following example:
Example 1.25: Inconsistency looks bad
1 If $X$ and $Y$ are two objects in a category $\mathcal{C}$ then it may happen
that the set $\operatorname{Hom}_{\mathcal{C}}(X,Y)$ is empty even though the
set $Hom_{\mathcal{C}}(Y,X)$ is non-empty.
If X and Y are two objects in a category C then it may happen that the set
HomC (X, Y ) is empty even though the set HomC (Y, X) is non-empty.
The inconsistent use of Hom and Hom makes the already bad Hom even worse.
11
Chapter 2
Useful and important packages
2.1 microtype for better typesetting
Use the package microtype. It makes your document look nicer and helps you to
circumvent overfull hboxes. Simply including the package is enough to let it work its
magic
1 % in the preamble
2 \newtheorem{proposition}{Proposition}
3 % in the main body
12
2.3 amsthm for theorem-like environments
4 \begin{proposition}
5 Every finite subgroup of $k^\times$ is cyclic.
6 \end{proposition}
1 % in the preamble
2 \newtheorem*{claim}{Claim}
3 % in the main body
4 \begin{claim}
5 The symmetric group $S_3$ is the smallest non-abelian group.
6 \end{claim}
If multiple theorem-like environments are defined then their have by default indepen-
dent counters:
Example 2.4: Theorem-like environment use different counters by default
For mathematical texts this behavior is pretty bad, as it makes it harder to find a
specified result.1
To solve this problem we define a new counter alltheorems and tell all theorem-
like environments to use this counter. To define the now counter we use the com-
1 If page 492 features Lemma 112 and Proposition 43 then where is Remark 20?
13
2.3 amsthm for theorem-like environments
mand \newcounter:
1 \newcounter{name}[dependence]
1 % in the preamble
2 \newcounter{alltheorems}
3
4 \newtheorem{assumption}[alltheorems]{Assumption}
5 \newtheorem{consequence}[alltheorems]{Consequence}
6
12 \begin{assumption}
13 Tigers are cats.
14 \end{assumption}
15
16 \begin{consequence}
17 Tigers hunt mice.
18 \end{consequence}
In practice one often wants the counter to be bound to the surround section or even
chapter. This can be achieved by binding the new counter to the section counter:
Example 2.7: Binding a new counter to the section level
1 % in the preamble
2 \newcounter{sometheorems}[section]
3 \renewcommand{\thesometheorems}{\thesection.\arabic{sometheorems}}
4 \newtheorem{corollary}[sometheorems]{Corollary}
5
14
2.4 tikz-cd for commutative diagrams
9 \begin{corollary}
10 Every subgroup of a free abelian group is again free abelian.
11 \end{corollary}
12
13 \begin{corollary}
14 Every subgroup of $\mathbb{Z}^n$ admits a basis.
15 \end{corollary}
16
19 \begin{corollary}
20 Every subgroup of a subgroup of $\mathbb{Z}^n$ admits a basis.
21 \end{corollary}
The addition [section] to the definition of the new counter ensures that the resulting
counter sometheorems resets every time the counter section is increased (which happens
every time a new section begins). We also change the way the counter sometheorems
is printed, namely printing it in the form “(section number).(counter number)” with
both numbers printed in Arabic numerals.
15
2.5 cleveref and hyperref for referencing
1 \label{labelname}
There are multiple commands for referencing this label, the most basic of which is \ref:
1 \ref{labelname}
Referencing a label with \ref will print the number of whatever the specified label
appears in.
Example 2.10: Using the commands \label and \ref
1 \begin{theorem}
2 \label{vector spaces are free}
3 Every vector space admits a basis.
4 \end{theorem}
5 It follows from \ref{vector spaces are free} that every $k$-vector space is
isomorphic to $k^{\oplus I}$ for some suitable index set $I$.
Instead of giving just a simple number it is customary to also specify what hides
behinds this number, e.g. a theorem, table or figure. The specified name and number
should then be separated by a tie ~ (as explained in Section 3.3.1) to ensure that no
line break occurs at this position. The name of the referred to environment is usually
capitalised.
16
2.5 cleveref and hyperref for referencing
1 \begin{theorem}
2 \label{every vector space has a basis}
3 Every vector space admits a basis.
4 \end{theorem}
5 It follows from Theorem~\ref{vector spaces are free} that every $k$-vector
space is isomorphic to $k^{\oplus I}$ for some suitable index set $I$.
\eqref
1 \eqref{labelname}
The command \eqref is used in the same way as the original \ref:
1 + 1 = 2. (2.1)
Note that the identity (2.1) shows that Fermat’s conjecture on the sum
an + bn = cn cannot be generalized to the case n = 1.
Always use descriptive label names. Cryptic sequences of seemingly random letters
will backfire on you down the road.
17
2.5 cleveref and hyperref for referencing
2.5.2 cleveref
There are two related problems with the above way of using hardcoding the type of
a reference: One has to remember or look up what type of environment the label
labelname refers to, and if this type is changed (e.g. by promoting a proposition to a
theorem) then the hardcorded types need to be manually adjusted.
These problems can be circumvented by using the cleveref package. The author
recommends to load this package with the options capitalise and noabbrev:
Example 2.14: Loading the package cleveref
1 \usepackage[capitalise, noabbrev]{cleveref}
1 \cref{labelname}
The command \cref differs from the more primitive \ref in that it automatically
inserts the right kind of type before the reference.
Example 2.16: Using the command \cref
1 \begin{lemma}
2 \label{dim is well-defined}
3 Every two bases of a vector space have the same cardinality.
4 \end{lemma}
5
6 \begin{remark}
7 One can generalize \cref{dim is well-defined} to non-commutative rings:
8 If $R$ is some ring and $M$ is a semisimple $R$-module then for every
irreducible $R$-module $L$ the multiplicity of $L$ in $M$ is well-defined.
9 \end{remark}
Lemma 3. Every two bases of a vector space have the same cardinality.
Remark 4. One can generalize Lemma 3 to non-commutative rings: If R is
some ring and M is a semisimple R-module then for every irreducible R-module
L the multiplicity of L in M is well-defined.
The used options options capitalise and noabbrev have the following effects:
• The option capitalise ensures that the printed type of the reference will begin
with an upper case letter. In Example 14 we would otherwise get “lemma 3”
18
2.5 cleveref and hyperref for referencing
The package cleveref provides another family of useful commands aside from \cref
and \Cref. An overview of these commands can be found in Table 2.1. They can be
used to print the type of a reference without its number. This can be used be used to
circumvent hardcoding types into the source code:
Example 2.17: Using \lcnamecref
1 \begin{theorem}
2 \label{weak cayley}
3 Every group embeds into a non-abelian group.
4 \end{theorem}
5 The above \lcnamecref{weak cayley} is actually a corollary of ’Cayleys~theorem.
By using the various referencing commands introduced so far it is now possible to avoid
(nearly?) every kind of hardcorded type.
2.5.3 hyperref
If the resulting pdf-file is supposed to be navigated digitally then the package hyperref
should be used. This package puts hyperlinks in the pdf-file whenever some kind of
reference is used.
19
2.6 csquotes for quotation marks
1 % most packages
2 ...
3 \usepackage{amsthm}
4 ...
5
1 \enquote{text}
20
2.6 csquotes for quotation marks
The command \enquote can automatically adjust the quotation marks to conventions
of the used language when this language is specified through the package babel. This
is done by loading the package csquotes which the option babel set to true.
Example 2.21: \enquote chooses the right kind of quotation marks
1 \begin{tabular}{@{}ll@{}}
2 \toprule
3 American English
4 &
5 \selectlanguage{american}
6 \enquote{quote}
7 \\
8 British English
9 &
10 \selectlanguage{british}
11 \enquote{quotation}
12 \\
13 German
14 &
15 \selectlanguage{ngerman}
16 \enquote{Zitat}
17 \\
18 French
19 &
20 \selectlanguage{french}
21 \enquote{citation}
22 \\
23 \bottomrule
24 \end{tabular}
1
“This is a ‘quote’ inside a quote.”
\enquote{This is a \enquote{quote}
inside a quote.}
So for dealing with quotes of any kind use the package csquotes.
21
2.7 enumitem for configuration of lists
1 \begin{enumerate}
2 \item
3 Assumption 1. Assumption
4 \item
5 ??? 2. ???
6 \item
7 Contradiction 3. Contradiction
8 \end{enumerate}
1 \begin{itemize}
2 \item
3 This is a list item. • This is a list item.
4 \item
5 This is also a list item. • This is also a list item.
6 \item
7 And yet another list item. • And yet another list item.
8 \end{itemize}
The environment description uses no predefined symbols for the list items and instead
expects a descriptive text from the user:
Example 2.25: Using the environment description
1 \begin{description}
2 \item[Field]
3 A special kind of ring. Field A special kind of ring.
4 \item[Ring]
5 A generalization of fields. Ring A generalization of fields.
6 \end{description}
The package enumitem is immensely useful for configuring the style and behavior of
these list environments. It provides (among others) the following features:
22
2.7 enumitem for configuration of lists
option description
\alph* lower case alphabetic
\Alph* upper case alphabetic
\roman* lower case Roman numerals
\Roman* upper case Roman numerals
\arabic* Arabic numerals
1 \begin{enumerate}[label = (\alph*)]
2 \item
3 First entry. (a) First entry.
4 \item
5 Second entry. (b) Second entry.
6 \item
7 Third entry. (c) Third entry.
8 \end{enumerate}
For a list of possible labels see Table 2.2. One can similarly change the symbol
for itemize lists via the option label:
Example 2.27: Changing the symbol for itemize lists
23
2.7 enumitem for configuration of lists
24
2.7 enumitem for configuration of lists
2.7.3 Spacing
One can change the various spacings involved in the list environments. For a full
overview we refer to [CTN19a], and in particular to [CTN19a, Figure 1]. We give here
only some of the more important configurations.
1 \begin{enumerate}
2 \item
3 Lorem ipsum dolor sit amet, 1. Lorem ipsum dolor sit amet,
consectetur adipiscing elit, sed do consectetur adipiscing elit, sed
eiusmod tempor incididunt ut labore do eiusmod tempor incididunt
et dolore magna. ut labore et dolore magna.
4
One can adjust the indentation of the paragraphs with the option listparindent and
the additional vertical spacing between paragraphs with the option parsep. With this
we can regain the standard indentation pattern in lists:
Example 2.30: Indentation and distance of pararaphs in lists, changed behavior
1 \begin{enumerate}[listparindent =
\parindent, parsep = 0pt]
2 \item
3 Lorem ipsum dolor sit amet,
1. Lorem ipsum dolor sit amet,
consectetur adipiscing elit, sed do consectetur adipiscing elit, sed
eiusmod tempor incididunt ut labore do eiusmod tempor incididunt
et dolore magna. ut labore et dolore magna.
4 In massa tempor nec feugiat.
5 In massa tempor nec feugiat. Nunc aliquet bibendum enim
Nunc aliquet bibendum enim facilisis gravida.
facilisis gravida.
6 \end{enumerate}
25
2.7 enumitem for configuration of lists
Indentation
The environment enumerate has by default two kinds of indentation: An indentation of
the labels with respect to the left margin, and an indentation of the list items with
respect to the label.
Example 2.32: enumerate environment with standard indentation
We can remove both indentations by using the option wide with the value 0pt:
26
2.7 enumitem for configuration of lists
We can add back the identation between the item labels and the item text by setting
the option leftmargin to the value *:
Example 2.34: enumerate environments with only identitation between label
and text
One can also add back the indentation between the left margin and the item labels by
also using the option labelindent:
Example 2.35: enumerate environment with indentation between margin and
label, and label and text
One can also combine the above two indentations to regain something that looks like
the standard indentation:
27
2.7 enumitem for configuration of lists
But Example 36 does actually have an advantage over the standard indentation, namely
that it properly handels long labels:
Example 2.37: enumerate environment with indentation between margin and
label, and label and text
(Latin 1) Dolor sed viverra ipsum nunc aliquet bibendum enim. In massa
tempor nec feugiat.
The identitation for the environment itemize can be adjusted in the same way as for
the environment description.
For the environment description we can proceed similarly as for enumerate. We
first observe the standard identation for this environment: There is a fixed identation
between the left margin and the items texts. The item labels are aligned at the
28
2.7 enumitem for configuration of lists
left margin.
Example 2.38: description environment with standard indentation
1 \setlist[kind of list]{options}
29
2.7 enumitem for configuration of lists
1 \setlist[enumerate]{label =
\roman*)}
2 \begin{enumerate}
3 \item i) First entry.
4 First entry.
5 \item ii) Second entry.
6 Second entry.
7 \end{enumerate}
1 \begin{enumerate}[label = \Roman*)]
2 \item
3 First entry.
4 \begin{enumerate}[label = \alph*)]
5 \item
6 First entry, first subentry.
7 \item
8 First entry, second subentry.
9 \end{enumerate}
10 \item
11 Second entry.
12 \begin{enumerate}[label = \arabic*)]
13 \item
14 Second entry, first subentry.
15 \item
16 Second entry, second subentry.
17 \end{enumerate}
18 \end{enumerate}
I) First entry.
a) First entry, first subentry.
b) First entry, second subentry.
II) Second entry.
1) Second entry, first subentry.
2) Second entry, second subentry.
30
2.7 enumitem for configuration of lists
One can also use different global settings for different depths:
Example 2.43: Global settings depending on level
The counter of the first depth and second depth can be accessed via the counters enumi
and enumii:
Example 2.44: Accessing level counters in settings for list environments
31
2.7 enumitem for configuration of lists
8 Again an entry.
9 \item
10 Again an entry.
11 \end{enumerate}
12 \item
13 Another entry.
14 \begin{enumerate}
15 \item
16 Yet another entry.
17 \item
18 Yet another entry.
19 \end{enumerate}
20 \end{enumerate}
(1) An entry.
(1.a) Again an entry.
(1.b) Again an entry.
(2) Another entry.
(2.a) Yet another entry.
(2.b) Yet another entry.
One can then set global options for this new list type without changing the global
options for the original type. This can be used to construct list environments that
serve special purposes. In the following example we create a new list environment that
is meant for listing equivalent statements:
Example 2.46: Custom clones of list environments
32
2.8 biblatex for bibliography
33
2.8 biblatex for bibliography
1 \usepackage[backend = biber]{biblatex}
1 @type{label,
2 key1 = {value1},
3 key2 = {value2},
4 key3 = {value3},
5 ...
6 }
Instead of curly braces { } one can also use quotation marks " " on the right hand
side of the equality signs.
The specifier @type in Example 48 will be be replaced by something like @book
or @article to explain what kind of work this entry is. A list of all possible types can
be found in [CTN19c, 2.1]. This specified type will determine which of the given data
will be printed in the bibliography and how these printed date are formatted.
The given text label has no influence on the bibliography itself. It will be used to
add the citations to this reference in the main text.
34
2.8 biblatex for bibliography
• How the printed data are to be formatted is for LATEX – and more specifically
biblatex – to decide. So don’t try to preformat the provided date in the bib-file.
Try in particular to give full, unabbreviated names whenever possible.
If you feels strongly about certain data being printed, or how certain data should be
formatted when printed out, then you should not try to abuse the bib-file for this.
Instead tell these complains to biblatex by changing the appropriate settings.
Some good sources for finding the data that a bibliography requires are MathSciNet
and the websites of the publishers. (Springer is quite good at providing all the needed
information on the websites of their books.) Most of the needed data can also be found
in the cited resource – e.g. book or article – itself.
In the following we will look at some specific examples of bib-file entries.
1 @book{fultonharris2004,
2 title = {Representation Theory},
3 subtitle = {A First Course},
4 author = {Fulton, William and Harris, Joe},
5 edition = {1},
6 year = {2004},
7 pagetotal = {xv+551},
8 publisher = {Springer-Verlag New York},
9 series = {Graduate Texts in Mathematics},
10 number = {129},
11 isbn = {978-0-387-97527-6},
12 doi = {10.1007/978-1-4612-0979-9}
13 }
The resulting output in the bibliography (see Example 58) will look as follows:
William Fulton and Joe Harris. Representation Theory. A First Course. 1st ed.
Graduate Texts in Mathematics 129. Springer-Verlag New York, 2004, pp. iv–
15. xv+551 pp. isbn: 978-0-387-97527-6. doi: 10.1007/978-1-4612-0979-9
The type @books tells LATEX that the entry is a (single) book. The various keys have
the following functions:
title This key specifies the title of the book. The expected value of this key is a text.
subtitle This key specifies the subtitle of the book. The expected value of this key is
a text.
author This key specifies the author(s) of the book. There are some things to be aware
of here:
35
2.8 biblatex for bibliography
• The name of an author needs to be given in the format Lastname, Firstname. This
is needed so that biber can properly process this data.
• If multiple authors are given then they need to be separated by the word and.
edition This key specifies the edition of the book. The value should be given as a
number for proper processing, but can in an emergency also be given as a text.
year This key specifies the year the book was published. One could also specify a moth
with the key month. The values for both keys are expected to be numbers.
One could also use the key date takes arguments of the form year, year-month
or year-month-day. Here the value of year is expected to be a four digit number, and
the values of month and day are expected to be two digit numbers (which may contain
a leading zero).
pagetotal This key specifies the total number of pages of the book. The value should
be an integer but can also be an arbitrary text.
There is however a drawback to simply providing a text: Normally the number of
pages is followed by the text “pp.” or “p.”, depending on whether the reference consists
of only a single page. To do so biblatex always tried to interpret the input as a number.
But if this interpretation fails then neither “pp.” nor “p.” will be added.
Books often start with pages that are numbered with Roman numbers, followed by
pages that are numbered by Arabic numbers. In this case the total number of pages
should be given in the form “(Roman number)+(Arabic number)”.
As explained above, this will lead to the problem of biblatex being unable to interpret
the input as a number, which leads by default to a missing “pp.” in the output. For
this problem one can adjust the settings of biblatex to always include “pp.” after the
total page number of a book. This can be done as follows:
Example 2.50: Adjusting the formatting of pagestotal
1 \DeclareFieldFormat[book]{pagetotal}{#1~\ppno}
publisher This key specifies the publisher of the book. The expected value is a text.
Note that “Springer” is not a proper reference for a publisher.
series Many mathematical books are part of some series, e.g. “Graduate Texts is
Mathematics” or “Cambridge Studies in Advanced Mathematics”. Such a series can be
specified with the key series, which expects as its value a text.
number This key specifies the number of the book in the previously specified series.
The values of this key is (counterintuitively) treated as a text.
If you copy your bibliography data from somewhere else then there is a very high
chance that instead of the key number the key volume is used. This is relicts from the
past that isn’t correct with biblatex.
isbn This key specifies the isbn number of the book. The value of this field is treated
as a text.
doi This key specifies the DOI of the book (if it has one).
36
2.8 biblatex for bibliography
1 @mvbook{benson,
2 title = {Representations and Cohomology},
3 author = {Benson, David John},
4 publisher = {Cambridge University Press},
5 series = {Cambridge Studies in Advanced Mathematics},
6 volumes = {2}
7 }
8
9 @book{benson1991,
10 crossref = {benson},
11 volume = {1},
12 number = {30},
13 title = {Basic Representation Theory of Finite Groups and Associative
Algebras},
14 edition = {1},
15 year = {1991},
16 pagetotal = {xii+246},
17 isbn = {978-0-521-36134-7},
18 doi = {10.1017/CBO9780511623615}
19 }
We can then refer to the entry of type @book as usual, to get the following output in
the bibliography (see Example 58):
David John Benson. Representations and Cohomology. Vol. 1: Basic Represen-
tation Theory of Finite Groups and Associative Algebras. 2 vols. Cambridge
Studies in Advanced Mathematics 30. Cambridge University Press, 1991,
pp. xii+246. isbn: 978-0-521-36134-7. doi: 10.1017/CBO9780511623615
There are three new keys to talk about here:
volumes This key describes the total number of volumes. The value of this key is
expected to be an integer.
volume This key describes the volumes of the specified volume. The value of this key is
expected to be an integer.
crossref This key expresses that the given entry is subordinate to some other entry.
The expected value is the label of the superior entry.
37
2.8 biblatex for bibliography
1 @article {diamond_lemma,
2 title = {The Diamond Lemma for Ring Theory},
3 author = {Bergman, George Mark},
4 year = {1978},
5 month = {2},
6 journaltitle = {Advances in Mathematics},
7 issn = {0001-8708},
8 volume = {29},
9 number = {2},
10 pages = {178--218},
11 doi = {10.1016/0001-8708(78)90010-5}
12 }
The output in the bibliography (see Example 58) will look as follows:
George Mark Bergman. “The Diamond Lemma for Ring Theory.” In: Advances
in Mathematics 29.2 (February 1978), pp. 178–218. doi: 10 . 1016 / 0001 -
8708(78)90010-5
The type @article tells LATEX that the entry is for a (journal) article. Many fields
are as for the type @book, so we will focus on the changes:
journaltitle This key specifies the name of the journal that the article was published
in. The expected value for this key is a text.
issn This key specifies the ISSN (International Standard Serial Number) of the journal
in question. The value is treated as a text.
volume, number These keys specify in which volume of the journal the article appeared,
and in which number of the volume. The value for volume should be an integer, and
the value for number should be an integer too (although it is treated as text).
pages This key specifies in which page range the article appeared. It doesn’t matter
how many dashes are used to separate the two page numbers. It also doesn’t matter if
the dash(es) are surrounded by space.
It is customary to specify page ranges in the form pages = number--number because
this gives a right looking output even if this argument were simply to be interpreted as
text. (Which lesser packages than biblatex may do.)
38
2.8 biblatex for bibliography
1 @online{cayley_graph,
2 title = {Cayley graphs and the geometry of groups},
3 author = {Tao, Terence},
4 date = {2010-06-10},
5 url =
{https://terrytao.wordpress.com/cayley-graphs-and-the-geometry-of-groups},
6 urldate = {2019-09-06}
7 }
The output in the bibliography (see Example 58) will look as follows:
Terence Tao. Cayley graphs and the geometry of groups. July 10, 2010.
url: https://terrytao.wordpress.com/cayley-graphs-and-the-geometry-of-
groups (visited on September 6, 2019)
1 @online{leinster2014,
2 title = {The bijection between projective indecomposable and simple
modules},
3 author = {Leinster, Tom},
4 date = {2014-10-14},
5 eprint = {1410.3671v1},
6 eprinttype = {arxiv},
7 eprintclass = {math.RA},
8 urldate = {2019-09-12}
9 }
The output in the bibliography (see Example 58) will look as follows:
39
2.8 biblatex for bibliography
1 \cite[details]{label}
2 One can also refer to the overall collection:
3 \testcite{benson}
Let’s consider an example where we cite the references given in the previous examples:
Example 2.56: Using the command \cite
1 We assume that the reader is familiar with the representation theory of the
symmetric groups as discussed in \cite[\S 4]{fultonharris2004}.
2 The reader may also want to check out \cite{benson1991} and \cite{cayley_graph}.
3 For a nice proof of the Poincaré--Birkhoff--Witt~Theorem we refer to \cite[\S
3]{diamond_lemma}.
We assume that the reader is familiar with the representation theory of the sym-
metric groups as discussed in [FH04, §4]. The reader may also want to check out
[Ben91] and [Tao10]. For a nice proof of the Poincaré–Birkhoff–Witt Theorem
we refer to [Ber78, §3].
We will also need to add the bibliography into the LATEX document. Suppose for
this that the bib-file is called references.bib. We then have to do two things:
• We need to tell LATEX how the bib-file is called. This is done via the com-
mand \bibliography:
Example 2.57: Syntax of \bibliography
1 \bibliography{name of bib-file}
40
2.8 biblatex for bibliography
1 \printbibliography
Bibliography
[Ben91] David John Benson. Representations and Cohomology. Vol. 1: Basic
Representation Theory of Finite Groups and Associative Algebras.
2 vols. Cambridge Studies in Advanced Mathematics 30. Cambridge
University Press, 1991, pp. xii+246. isbn: 978-0-521-36134-7. doi:
10.1017/CBO9780511623615.
[Ber78] George Mark Bergman. “The Diamond Lemma for Ring Theory.”
In: Advances in Mathematics 29.2 (February 1978), pp. 178–218.
doi: 10.1016/0001-8708(78)90010-5.
[FH04] William Fulton and Joe Harris. Representation Theory. A First
Course. 1st ed. Graduate Texts in Mathematics 129. Springer-Verlag
New York, 2004, pp. iv–15. xv+551 pp. isbn: 978-0-387-97527-6.
doi: 10.1007/978-1-4612-0979-9.
[Lei14] Tom Leinster. The bijection between projective indecomposable and
simple modules. October 14, 2014. arXiv: 1410.3671v1 [math.RA].
(Visited on September 12, 2019).
[Tao10] Terence Tao. Cayley graphs and the geometry of groups. July 10,
2010. url: https://terrytao.wordpress.com/cayley-graphs-and-
the-geometry-of-groups (visited on September 6, 2019).
41
2.9 booktabs for tables
1. We compile the document main.tex. The compiler will note down in an auxiliary
file main.bcf which labels are cited in this document
2. The back end program biber will go through the auxiliary files main.bcf and
write down all the requested information in a new auxiliary file main.bbl.
3. We compile the document main.tex again. The compiler will read the various
data given in the auxiliary file main.bll and, using the settings and commands
from the package biblatex, will typeset both the citations in the main text and
create a bibliography.
If you’re using a specialized LATEX editor or IDE (like TEXStudio, kile, etc.) and have
everything properly configured then your editor should take care of the above steps
automatically when(ever) the document is compiled. But if you’re compiling by hand
in the console then you will need three commands:
Example 2.59: Compiling in the console (with bibliography)
1 latex main.tex
2 biber main.bcf
3 latex main.tex
1 \begin{tabular}{lcr}
2 longtext & text & text \\
3 text & longtext & text \\
4 text & text & longtext
5 \end{tabular}
The labels l, c, r specify the alignment of the corresponding column (left aligned,
centered, and right aligned).
42
2.9 booktabs for tables
Horizontal lines
The command \hline at the beginning of a row introduces a horizontal line that
separates this row from the previous one. To get multiple parallel lines (e.g. a double
line) one uses multiple instances of \hline directly after each other.
Example 2.61: Full horizontal lines in tables
1 \begin{center}
2 \begin{tabular}{ccc}
3 top left & top center & top right \\
4 \hline\hline
5 text & text & text \\
6 \hline
7 text & text & text
8 \end{tabular}
9 \end{center}
1 \begin{center}
2 \begin{tabular}{ccccc}
3 text & text & text & text & text \\
4 \cline{2-4}
5 text & text & text & text & text \\
6 \cline{1-2} \cline{4-5}
7 text & text & text & text & text
8 \end{tabular}
9 \end{center}
43
2.9 booktabs for tables
1 \begin{tabular}{l||c|c}
2 first row & text & text \\
3 second row & text & text \\
4 third row & text & text
5 \end{tabular}
1 \begin{center}
2 \begin{tabular}{|l||l|r|}
3 \hline
4 \textbf{Country} & \textbf{Town} & \textbf{Population} \\
5 \hline\hline
6 France & Paris & 2,229,621 \\
7 \cline{2-3}
8 {} & Marseille & 855,393 \\
9 \hline
10 Germany & Berlin & 3,520,031 \\
11 \cline{2-3}
12 {} & Hamburg & 1,787,408 \\
13 \hline
14 Japan & Tokyo & 8,637,098 \\
44
2.9 booktabs for tables
15 \cline{2-3}
16 {} & Yokohama & 3,697,894 \\
17 \hline
18 \end{tabular}
19 \end{center}
One should also try to minimize the number of horizontal lines. The above example
should hence look as follows:
Example 2.66: Using the rules of booktabs
1 \begin{center}
2 \begin{tabular}{llr}
3 \toprule
4 \textbf{Country} & \textbf{Town} & \textbf{Population} \\
5 \midrule
45
2.9 booktabs for tables
Note that we could leave out all non-essential horizontal lines because the table has
a very regular form. We refer to [CTN16] for more information about typing tables.
46
Chapter 3
Writing text
Un texte mathématique est,
d’abord, un texte.
In this chapter we will talk about the more text focused aspects of writing mathematics
with LATEX. We will in particular talk about the interplay between the mathematical
content and the text that surrounds it.
1
It follows that
It follows that
2 \[
3 a^2 + b^2 = c^2
a2 + b2 = c2
4 \]
5
. This formula is important.
.
6 This formula is important.
47
3.2 Proper punctuation
But it is even better if we add some slight spacing between the formula and the period.
Example 3.5: Best punctuation in an equation
This last approach is taken from [TSE14], which we strongly encourage the reader to
check out.
48
3.2 Proper punctuation
There are two standard ways to achieve this: One can finish up the sentence that
precedes a commutative diagram beforehand:
Example 3.6: Finishing the sentence before the commutative diagram
A A0
C C0
But it often better to incorporate the diagram in the surrounding sentence in such a
way that it contains no punctuation:
Example 3.7: Incorporating the commutative diagram in the sentence
49
3.2 Proper punctuation
11 C
12 \arrow{r}
13 &
14 C'
15 \end{tikzcd}
16 \]
17 both horizontal arrows are isomorphisms.
A A0
C C0
A set B is a basis of V if
1. B is linearly independent
2. B is a generating set
To figure out the correct punctuation simply remove the surrounding list and consider
the resulting text. In the above example this gives the following:
A set B is a basis of V if B is linearly independent B is a generating set
This is not a proper sentence, and should be the following instead:
A set B is a basis of V if B is linearly independent and B is a generating set.
The above counterexample should hence read as follows:
50
3.2 Proper punctuation
A set B is a basis of V if
1. B is linearly independent and
2. B is a generating set.
51
3.2 Proper punctuation
1 Let~$A$ be a $\mathbb{Z}-$module.
Let A be a Z−module.
We can see that we don’t get a hyphen but a minus sign. We hence need to place the
symbol - outside of the math environment.
52
3.2 Proper punctuation
x. x x. X x. x X. x
X. x X. X x. X X. X
Table 3.3: Spacings after a period (with a zoom of factor 3.5).
1 Let~$A$ be a $\mathbb{Z}$-module.
Let A be a Z-module.
The solution
We can use the command “\ ” – which we will write for readability as \(space) – to
tell LATEX that a preceding period is not meant to end a sentence. We can similarly use
the command \@ to tell LATEX that the following period is ending a sentence. Consider
the following example:
Example 3.13: Proper spacing after periods
1 Imagine now some old and long-dead English kings, e.g.\ Henry III and Henry
IV\@.
53
3.2 Proper punctuation
Imagine now some old and long-dead English kings, e.g. Henry III and Henry
IV. (Kings not named Henry are also okay.)
Note that in the above example one should also use ties ~ (as explained in Section 3.3.1)
to ensure that the Henries don’t lose their number.
Example 3.14: Proper spacing after periods, and using ~
1 Imagine now some old and long-dead English kings, e.g.\ Henry~III and
Henry~IV\@.
2 (Kings not named Henry are also okay.)
Imagine now some old and long-dead English kings, e.g. Henry III and Henry IV.
(Kings not named Henry are also okay.)
1 Many colours (e.g. red, blue, etc.) are supported by \enquote{ColorX}. Even
purple! \\
2 Many colours (e.g.\ red, blue, etc.) are supported by \enquote{ColorX}. Even
purple! \\
3 Many colours (e.g.\ red, blue, etc.)\ are supported by \enquote{ColorX}. Even
purple! \\
4 Many colours (e.g.\ red, blue, etc.)\ are supported by \enquote{ColorX}\@. Even
purple!
Many colours (e.g. red, blue, etc.) are supported by “ColorX”. Even purple!
Many colours (e.g. red, blue, etc.) are supported by “ColorX”. Even purple!
Many colours (e.g. red, blue, etc.) are supported by “ColorX”. Even purple!
Many colours (e.g. red, blue, etc.) are supported by “ColorX”. Even purple!
The problem of a sentence ending with an upper case letter does not occur if this
letter is in math mode.
Example 3.16: Upper case mathematics followed by a period
54
3.2 Proper punctuation
In view of Section 3.3.1 we get a problem: What if we want the space after an
abbreviation, as in “i.e. word”, not to be broken? Should we then write i.e.\ word
or i.e.~word?
In this case we write i.e.~word, since the tie ~ already contains the effect of \(space).
Consider for this the following example:
Example 3.17: Spacing of ~ and “\ ”
55
3.3 Text layout
1 It follows from the above Lemma 5 It follows from the above Lemma 5
that the integer $2$ is prime. that the integer 2 is prime.
We don’t want a line break to occur in the term “Lemma 5” and thus introduce a
tie. In the above example it is also a good idea to prevent a possible line break in the
term “integer 2”. We therefore get the following code:
Example 3.19: Using ~ to prevent unwanted line breaks at spaces
1 It follows from the above Lemma~5 It follows from the above Lemma 5
that the integer~$2$ is prime. that the integer 2 is prime.
1 The sphere $S^2$ will be our very first non-trivial example of a smooth
$2$-manifold (without boundary).
The sphere S 2 will be our very first non-trivial example of a smooth 2-manifold
(without boundary).
56
3.3 Text layout
1 The sphere $S^2$ will be our very first non-trivial example of a smooth
$2${\nbd}manifold (without boundary).
The sphere S 2 will be our very first non-trivial example of a smooth 2-manifold
(without boundary).
The command \nobreakdash works not only with hyphens but also with en dashes and
em dashes.
The use of \\ and \newline is only for starting new rows in matrices, tables and arrays.
Don’t use is to separate paragraphs.
57
3.3 Text layout
1 \begin{theorem}
2 Let $G$ be a finite group.
3 \begin{enumerate}
4 \item
5 If $H$ is subgroup of $G$ then $\operatorname{ord}(H)$ divides
$\operatorname{ord}(G)$.
6 \item
7 If $a$ is any element of $G$ then $\operatorname{ord}(a)$ divides
$\operatorname{ord}(G)$.
8 \item
9 Every group of prime order is cyclic.
10 \item
11 If $p$ is a prime divisor of $\operatorname{ord}(G)$ then $G$ contains an
element of order $p$.
12 \end{enumerate}
13 \end{theorem}
In such cases one should remove the identation between the left margin of the text
area and the item labels, as explained in Section 2.7.3.
58
3.3 Text layout
1 \begin{theorem}
2 Let $G$ be a finite group.
3 \begin{enumerate}[wide = 0pt, leftmargin=*]
4 \item
5 If $H$ is subgroup of $G$ then $\operatorname{ord}(H)$ divides
$\operatorname{ord}(G)$.
6 \item
7 If $a$ is any element of $G$ then $\operatorname{ord}(a)$ divides
$\operatorname{ord}(G)$.
8 \item
9 Every group of prime order is cyclic.
10 \item
11 If $p$ is a prime divisor of $\operatorname{ord}(G)$ then $G$ contains an
element of order $p$.
12 \end{enumerate}
13 \end{theorem}
1 \begin{lemma}
2 \begin{enumerate}
3 \item
4 Every group~$G$ is isomorphic to its opposite group~$G^{\mathrm{op}}$.
5 \item
6 A group~$G$ equals its opposite group~$G^{\mathrm{op}}$ if and only if it
is abelian.
7 \end{enumerate}
8 \end{lemma}
59
3.3 Text layout
One way to circumvent this problem is by inserting the command \leavevmode before
the beginning of the list.
Example 3.27: Proper aligned of list items with \leavevmode
1 \begin{lemma}
2 \leavevmode
3 \begin{enumerate}
4 \item
5 Every group~$G$ is isomorphic to its opposite group~$G^{\mathrm{op}}$.
6 \item
7 A group~$G$ equals its opposite group~$G^{\mathrm{op}}$ if and only if it
is abelian.
8 \end{enumerate}
9 \end{lemma}
Lemma 4.
The problem with this approach is that it allows a line break to occur at the position
of \leavevmode. So it may happen that the header of the theorem-like environment of
proof environment occurs at the very bottom of the page while the list appears only on
the next page. (This looks quite horrible.)
As far as the author is aware there exists no good solution for this problem.2 A good
way of coping with this problem is to circumvent it by introducing some text before
the list environment:
Example 3.28: Proper aligned of list items by introducing text
1 \begin{lemma}
2 Let $G$ be a group with opposite group $G^{\mathrm{op}}$.
3 \begin{enumerate}
4 \item
5 The groups $G$ and $G^{\mathrm{op}}$ are isomorphic.
6 \item
2 Thepackage ntheorem is allegedly able to address this problem, at the price of introducing new
problems.
60
3.4 Mathematics in text
7 The groups $G$ and $G^{\mathrm{op}}$ are equal if and only if $G$ is
abelian.
8 \end{enumerate}
9 \end{lemma}
An seen above we should also eliminate the indentation between the left margin of the
text area and the item labels:
Example 3.29: Proper aligned of list items by introducing text
1 \begin{lemma}
2 Let $G$ be a group with opposite group $G^{\mathrm{op}}$.
3 \begin{enumerate}[wide = 0pt, leftmargin=*]
4 \item
5 The groups $G$ and $G^{\mathrm{op}}$ are isomorphic.
6 \item
7 The groups $G$ and $G^{\mathrm{op}}$ are equal if and only if $G$ is
abelian.
8 \end{enumerate}
9 \end{lemma}
61
3.4 Mathematics in text
This horrible affront to nature can thankfully be completely stopped by setting the
penalties \binoppenalty and \relpenalty to their maximum value, which can be accessed
via the command \maxdimen.
Example 3.31: Preventing inline math in inline math
1 % in the preamble:
2 \binoppenalty = \maxdimen
3 \relpenalty = \maxdimen
4 % in the main text:
5 The most important formula of all times is without a doubt is my mind $1 + 2 +
3 + 4 = 10 - 5$.
6 Truly a work of genius!
1 \begin{theorem}
2 $\mathbf{Mod}(R)$ is an abelian category.
3 \end{theorem}
1 \begin{theorem}
2 The category $\mathbf{Mod}(R)$ is abelian.
3 \end{theorem}
62
3.4 Mathematics in text
An exception to the above rule are lists, in which short entries may start with a
math symbol. Consider for this the following example.
Example 3.34: List items beginning with mathematics
Let V be a finite dimensional vector space. Let U and W be two linear subspaces
of V of complementary dimensions, i.e. such that dim V = dim U + dim W .
Then the following conditions are equivalent:
i) V = U ⊕ W ,
ii) V = U + W ,
iii) V = U ∩ W .
But this betrays the actual content of the sentence. This problem can be fixed by
introducing some text. One solution is the following:
63
3.5 Text in mathematics
This next one looks a bit better, but is still not okay:
64
3.5 Text in mathematics
definition
name set
:=
math
A {:}
math math
x ∈ [0, 1] x is rational
math text
Instead do this:
Example 3.41: Right way of using text in math mode
Note that the right code reflects the structure of the displayed expression: Indeed, the
diagram in Figure 3.1 shows the structure of the given expression. To get the right
kind of code we assign to each node of this diagram the desired content, and whether
this node is mathematics or text. If a node contains both mathematics and text then
it is primary a text, which just happens to contain some mathematics. We arrive
at the diagram in Figure 3.2. By transforming this diagram node-wise into code we
arrive at Example 41. Note that both the nodes “x ∈ [0, 1]” and “x is rational” both
65
3.5 Text in mathematics
contain mathematics, but that the second is actually a text. It is therefore not proper
to combine these two math modes, as done in Example 40.
1 Therefore
2 \[
3 g h g^{-1}
4 =
5 h
6 \text{for all $g, h \in G$}.
7 \]
Therefore
ghg −1 = hfor all g, h ∈ G.
In such a case one needs to put space between the mathematics and the text. This
space should not be part of the text:
Example 3.43: Wrong spacing around text in math mode II
1 Therefore
2 \[
3 g h g^{-1}
4 =
5 h
6 \text{ for all $g, h \in G$.}
7 \]
Therefore
ghg −1 = h for all g, h ∈ G.
Instead it should be put between the formula and the text. In the above example,
where a single block of mathematics is follows by a single block of text which contains
quantifiers for the previous formula, one should use the spacing \qquad:
Example 3.44: Right spacing around text in math mode I
1 Therefore
2 \[
3 g h g^{-1}
4 =
66
3.5 Text in mathematics
5 h
6 \qquad
7 \text{for all $g, h \in G$.}
8 \]
Therefore
ghg −1 = h for all g, h ∈ G.
Sometimes two blocks of mathematics are separated by a short text. In this case one
should use the spacing \quad on both sides of the text:
Example 3.45: Right spacing around text in math mode II
It may even be appropriate to use \qquad on both sides when more space is needed.
67
3.5 Text in mathematics
9 \begin{align*}
10 I
11 &= d_1 + d_2 + d_3 + d_4 + d_5 + d_6 \\
12 &= e_1 + e_2 + e_3 \\
13 &= f_1 + f_2 + f_3 + f_4 + f_5 \,.
14 \end{align*}
H = a1 + a2 + a3 + a4
= b1 + b2 + b3 + b4 + b5 + b6
= c1 + c2 + c3 + c4 + c5
and
I = d1 + d2 + d3 + d4 + d5 + d6
= e1 + e2 + e3
= f1 + f2 + f3 + f4 + f5 .
Note the annoying misalignment of the equality signs of the two align* environments.
We can solve this problem by using only one align* environment and inserting the
text “and” by using the command \intertext:
Example 3.47: Two aligned blocks
The command \shortintertext works in the same way as \intertext but inserts less
vertical space around it. To see the effects of \shortintertext let us start with the
following example:
68
3.5 Text in mathematics
1 First we have some lengthy text above the mathematical formulas, followed by
the formulas
2 \[
3 a = b
4 \]
5 and
6 \[
7 b = a \,.
8 \]
9 We finish off by writing some more text after the above mathematical two
formulas.
First we have some lengthy text above the mathematical formulas, followed by
the formulas
a=b
and
b = a.
We finish off by writing some more text after the above mathematical two
formulas.
We naturally want to align the two equality signs, which we by using a single \align* en-
vironment together with \intertext, as explained above:
Example 3.49: Two aligned equalities with too much space
1 First we have some lengthy text above the mathematical formulas, followed by
the formulas
2 \begin{align*}
3 a &= b
4 \intertext{and}
5 b &= a \,.
6 \end{align*}
7 We finish off by writing some more text after the above mathematical two
formulas.
First we have some lengthy text above the mathematical formulas, followed by
the formulas
a=b
and
b = a.
69
3.6 Mathematics as text
We finish off by writing some more text after the above mathematical two
formulas.
But we can see that the inserted \intersect puts a large space between the two formulas,
far too large for our taste. We can solve this problem by using \shortintertext instead
of \intertext, as the following example shows:
Example 3.50: Two aligned equalities with proper space
1 First we have some lengthy text above the mathematical formulas, followed by
the formulas
2 \begin{align*}
3 a &= b
4 \shortintertext{and}
5 b &= a \,.
6 \end{align*}
7 We finish off by writing some more text after the above mathematical two
formulas.
First we have some lengthy text above the mathematical formulas, followed by
the formulas
a=b
and
b = a.
We finish off by writing some more text after the above mathematical two
formulas.
But this use of mathematics should be treated with care, and not abused:
70
3.6 Mathematics as text
∃, ∀, =⇒ , ⇐⇒
as replacements for written out words. This is okay in handwriting and on blackboards,
but it is not okay in a properly written out mathematical text.
Example 3.53: Abuse of quantifiers
1 It follows that $\forall y \in B$ that $\exists x \in A$ with $f(x) = y$.
1 It follows that for every element $y \in B$ there exists an element $x \in A$
with $f(x) = y$.
In this example one should also write out the element relation:
Example 3.55: Best use of quantifiers
1 It follows that for every element $y$ of $B$ there exists an element $x$ of $A$
with $f(x) = y$.
The use of the above logical symbols is of course okay if they are used in their actual
logical function:
71
3.6 Mathematics as text
f is an epimorphism
⇐⇒ ∀Z ∈ Ob(C) : ∀g, h ∈ C(Y, Z) : g ◦ f = h ◦ f =⇒ g = h
72
Chapter 4
Good behaviour inside math mode
4.1 Using the right commands and symbols
4.1.1 General symbols
Use the right symbols. Table 4.1 shows some popular sources of this problem. Note
that the commands \rightarrow and \to give the same arrow. So use whichever is
more appropriate in the given situation.
4.1.2 Operations
Many mathematical operations have both a binary version and an operator version
where the operation can range over some index set. One should not confuse the two of
them. Table 4.2 shows some popular binary operations and their operator counterpart.
The command \bigsqcap requires the package stmaryrd.
4.1.3 Negations
For some mathematical symbols there also exists a negated version, which is formed
by diagonal line through the symbol. A general way of introducing such a line is the
command \not.
Example 4.1: Using \not
But in practice this command should seldom be used, as it often produces very bad
looking output. Consider the following example:
Example 4.2: Why not to use \not
Hence A 6 =⇒ B.
73
4.1 Using the right commands and symbols
1 Consider
2 \[
3 A \centernot\ni x
4 \quad\text{versus}\quad
5 \quad
6 A \not\ni x \,.
7 \]
8 Consider also
74
4.1 Using the right commands and symbols
sum
P
+ a+b \sum i xi
multiplication
Q
\cdot a·b \prod i xi
direct sum
L
\oplus A⊕B \bigoplus i Xi
tensor product
N
\otimes A⊗B \bigotimes i Xi
wedge
V
\wedge a∧b \bigwedge i Xi
union
S
\cup A∪B \bigcup i Xi
intersection
T
\cap A∩B \bigcap i Xi
product
Q
\times A×B \prod i Xi
d
\sqcap AuB \bigsqcap i Xi
coproduct
`
\amalg AqB \coprod i Xi
F
\sqcup AtB \bigsqcup i Xi
right wrong
\notin ∈
/ \not\in 6∈
\nexists @ \not\exists 6∃
\neq 6 = \not = 6=
\nleq \not\leq 6≤
\nrightarrow 9 \not\rightarrow 6 →
9 \[
10 A \centernot\implies B
11 \quad\text{versus}\quad
12 A \not\implies B \,.
13 \]
Consider
A 63 x versus A 63 x .
Consider also
A =⇒
6 B versus A 6 =⇒ B .
75
4.1 Using the right commands and symbols
1 \[
2 \sum\limits_{k=1}^n k n
X n(n + 1)
3 = k=
4 \frac{n(n+1)}{2}
2
k=1
5 \]
But this is not only unnecessary, but also dangerous. It is unnecessary because (most
of) the commands in questions already have this functionality built in:
Example 4.5: Using built-in limits
1 \[
2 \sum_{k=1}^n k n
X n(n + 1)
3 = k=
4 \frac{n(n+1)}{2}
2
k=1
5 \]
This built-in limits have the advantage that they can distinguish between inline math
and display math math:
Example 4.6: Inline math vs. display math with built-in limits
We can see that the inline version does not only use the smaller summation sign but
also sets the limits to the right of the summation sign. This is a feature which \limits
version is missing:
76
4.1 Using the right commands and symbols
The limits are still placed above the top and below the summation sign. This has its
price: The line in which the sum resides breaks the usual vertical space between lines,
which gives the text an inconsistent and unorganized look. Compare this to the version
without \limits:
Example 4.8: Inline with built-in limits
Here the line distance is nicely consistent and pleasing to the eye.
The usual predefined commands on which one would expect limits already have them
defined, e.g. \sum, \prod or \lim, as the following example shows:
Example 4.9: Inline vs. display for different commands with built-in limits
77
4.1 Using the right commands and symbols
Compare the inline versions k=0 k and k=1 k and limn→∞ an with the display
Pn Qn
versions
n n
lim an .
X Y
k, k,
n→∞
k=0 k=1
1 \DeclareMathOperator*{\colim}{colim}
colim
0
F (X 0 ) .
X ≤X
1 \[
2 X
3 \overset{f}{\longrightarrow}
4 Y
5 \underset{g \circ h \circ k}{\longrightarrow}
6 Z
7 \]
78
4.1 Using the right commands and symbols
f
X −→ Y −→ Z
g◦h◦k
We can see above that the length of the arrow does not adjust to the size of the text
above it or below it. The proper way to put text on top of an arrow or bellow an arrow
of the form “→” is therefore the command \xrightarrow:
Example 4.13: Using \xrightarrow to put text above or below an arrow
1 \[
2 X
3 \xrightarrow{f}
4 Y
5 \xrightarrow[g \circ h \circ k]{}
6 Z \,.
7 \]
f
X−
→ Y −−−−→ Z .
g◦h◦k
The package amsmath defines only the two most basic extensible arrows. Many more
kinds of extensible arrows are provided by the package mathtools and some more are
contained in the package extarrows. An overview of the various kinds of extensible
arrows can be found in Table 4.4.
The author recommends to define custom commands as shortcuts for the most used
arrows.
Example 4.14: Defining arrow commands as shortcuts
1 \newcommand{\xto}{\xrightarrow}
2 \newcommand{\xlongto}[1]{\xlongrightarrow{\;#1\;}}
3 The function $A \xto{f} B$ is the same as
4 \[
5 A \xlongto{f} B \,.
6 \]
The function A −
→ B is the same as
f
f
A−
−→ B .
79
4.1 Using the right commands and symbols
f f
amsmath A−
→B A←
−B
\xrightarrow \xleftarrow
A=
f f f
mathtools A 7−
→B A←
→B ⇒B
\xmapsto \xleftrightarrow \xRightarrow
f
=B
f f
A⇐ A⇐
⇒B A←
−- B
\xLeftarrow \xLeftrightarrow \xhookleftarrow
f f f
→B
A ,− A−
+B A−
*B
\xhookrightarrow \xrightharpoondown \xrightharpoonup
f f f
−
*
A)
−B −B
A) −B
A(
\xrightleftharpoons \xleftharpoondown \xleftharpoonup
f
−B
A(
−
+
\xleftrightharpoons
A == B
f f f
extarrows A←
→B A⇐
⇒B
\xlongequal \xleftrightarrow \xLeftrightarrow
f f f
A ←−
−B A −→ B A ←−
−→ B
\xlongleftarrow \xlongrightarrow \xlongleftrightarrow
=B A =⇒ B =⇒ B
f f f
A ⇐= A ⇐=
\xLongleftarrow \xLongrightarrow \xLongleftrightarrow
Each of these have they own role and (mostly) distinct look and feel. There are two
groups of ellipses. The first group consists of \dotsb, \dotsc, \dotsm, \dotsi,\dotso,
whereas the second group consists of \cdots, \ddots, \vdots, \ldots.
The ellipses in the first group are named after their function, see Table 4.5. Note
that the members of this group all have names of the form \dots*, where * is a letter
that specifies the semantic use of the dots.
The ellipses in the second group are not named after their function but after their
orientation, see Table 4.6 The ellipses \cdots, \ddots and \vdots are typically used in
matrices.
80
4.1 Using the right commands and symbols
1 \[
2 \begin{pmatrix}
3 a_{11} & \cdots & a_{1n} \\
4 \vdots & \ddots & \vdots \\
5 a_{n1} & \cdots & a_{nn}
6 \end{pmatrix}
7 \]
a11 ··· a1n
.. .. ..
. . .
an1 ··· ann
The command \ldots may be used to denote left out digits or symbols.
81
4.1 Using the right commands and symbols
1 We find that
2 \[
3 x = 0.1234567891011\ldots
4 \]
5 Consider the word $w = a_1 \ldots a_n$ where $a_1, \dotsc, a_n$ are letters in
an alphabet $\Sigma$.
We find that
x = 0.1234567891011 . . .
Consider the word w = a1 . . . an where a1 , . . . , an are letters in an alphabet Σ.
Note that the members of this second group of dots all have names of the form \*dots,
where * is a letter that specified the positioning of these dots.
So overall one should use the ellipses \cdots, \ddots and \vdots for matrices, and
otherwise the ellipses \dotsb, \dotsc, \dotsm, \dotsi and occasionally \dotso.
There also exists the generic command \dots which tries to automagically use the
right kind of positioning and spacing. But the author recommends no using this
command as it can lead to inconsistent results:
Example 4.17: Inconsistent results with \dots
1 The ellipses in $x_1 \leq x_2 \leq \dots \leq x_n$ and $y_1 \leq y_2 \leq
\dots$ should look the same.
1 \[
2 \begin{matrix}
3 a & b \\ a b
4 c & d c d
5 \end{matrix}
6 \]
There are five more variants of this basic matrix environment, that put different
delimiters around the matrix. The package mathtools also provides small versions of
all six kinds of matrices. See Table 4.7 for a table of all these kinds of matrices.
82
4.1 Using the right commands and symbols
size matrices
a b a b a b
normal c d c d c d
matrix pmatrix bmatrix
a b a b
a b
c d c d
c d
Bmatrix vmatrix Vmatrix
a b a b
a b
small c d c d c d
smallmatrix psmallmatrix bsmallmatrix
a b
a b
a b
c d c d c d
Bsmallmatrix vsmallmatrix Vsmallmatrix
The package mathtools also provides starred versions of the matrices in Table 4.7.
These starred versions allow to specify as an optional argument the alignment of the
columns. The three possible arguments are l for left-alignment, c for centered alignment
and r for right-alignment. The standard alignment is c.
Example 4.19: Aligning matrix entries
1 \[
2 \begin{bmatrix*}[l]
3 a & -b \\
4 -c & d
5 \end{bmatrix*}
6 \qquad
7 \begin{bmatrix*}[c]
8 a & -b \\
9 -c & d
10 \end{bmatrix*}
11 \qquad
12 \begin{bmatrix*}[r]
13 a & -b \\
14 -c & d
15 \end{bmatrix*}
16 \qquad
17 \begin{bmatrix}
18 a & -b \\
19 -c & d
83
4.2 Avoid bad notation
20 \end{bmatrix}
21 \]
a −b a −b a −b a −b
−c d −c d −c d −c d
One should choose the kind of matrix, its size and alignment dependent on convention,
usage and the matrix entries.
Example 4.20: Using the right kind of matrix
84
4.2 Avoid bad notation
1 \[
2 \int_a^b f(x) dx Z b Z b
3 \quad f (x)dx f (x)dx
4 \int_a^b f(x) \mathrm{d}x a a
5 \]
1 \[ Z b
2 \int_a^b f(x) \,\mathrm{d}x f (x) dx
3 \] a
85
4.3 Defining new commands
Don’t use funky fractions like ab. They’ll make you go blind and burn down your
house.
1 Use $\sin(x)$ instead of $sin x$, use $\dim V$ instead of $dim V$ and use
$\lim_{n \to \infty} a_n$ instead of $lim_{n \to \infty} a_n$.
Use sin(x) instead of sinx, use dim V instead of dimV and use limn→∞ an
instead of limn→∞ an .
4.3.1 \DeclareMathOperator
Commands of the form \Word that are supposed to give the output Word can easily be
defined using the command \DeclareMathOperator.
Example 4.26: Syntax of \DeclareMathOperator
1 \DeclareMathOperator{\Word}{Word}
1 % in the preamble:
2 \DeclareMathOperator{\End}{End}
86
4.3 Defining new commands
When a command \Word is defined with \DeclareMathOperator then LATEX will auto-
matically insert some space around \Word when needed:
Example 4.29: Automatic spacing of \DeclareMathOperator
1 \begin{align*}
2 &x \End V
3 \\ x End V
4 &x \End(V)
x End(V )
5 \\
6 &x \End {(V)} x End (V )
7 \end{align*}
Note that in the first expression LATEX inserts some spacing both to the left and to the
right of End. In the second expression LATEX observes that the used math operator is
follows by a parenthesis and thus inserts no additional spacing. For the third expression
we prevent LATEX from making such an observation by using a pair of curly brackets.
This behavior leads to a bad looking output when \DeclareMathoperator is abused.
Suppose that we want a command \Complex that inserts the code \mathbb{C}.
Example 4.30: Wrong way of using \DeclareMathOperator
1 % in the preamble:
2 \DeclareMathOperator{\Complex}{\mathbb{C}}
1 The span of $x_1, \dotsc, x_n \in \Complex^m$ equals $\Complex x_1 + \dotsb +
\Complex x_n$.
We expect the output Cx1 + · · · + Cxn but get some unwanted spacing instead.
4.3.2 \operatorname
The command \operatorname can be used to give the formatting of a mathemical
operator without defining a new command.
Example 4.32: Using \operatorname
87
4.3 Defining new commands
If the same command is used multiple times then one should use \DeclareMathOperator
instead of \operatorname, to keep the code clean.
4.3.4 \newcommand
A very general way of defining new commands is given by \newcommand. Its syntax is as
follows:
Example 4.34: Syntax of \newcommand
1 \newcommand{\bimodule}[2]{#1-#2-bimodule}
2 Let $M$ be an \bimodule{$A$}{$B$}.
Let M be an A-B-bimodule.
1 \newcommand{\Ouv}{\operatorname{Ouv}}
2 $\Ouv X$
Ouv X
Trying to define an already existing command with \newcommand will lead to an error.
To overwrite an already existing command one can use \renewcommand instead. But
this shouldn’t really be used (unless you really, really know what you’re doing): Even
88
4.3 Defining new commands
if you don’t like a particular command there is a chance that some package that you’re
using relies on it. So overwriting a command can easily surprise you with some new
problems.
4.3.5 \DeclarePairedDelimiter
Mathematical operations like the absolute value |·| and a norm k·k are denoted by putting
certain delimiters to the left and right of the argument. To define a corresponding LATEX
command like \abs or \norm one should use the command \DeclarePairedDelimiter
(which is provided by the package mathtools):
Example 4.37: Syntax of \DeclarePairedDelimiter
1 \DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
1 \[
2 \abs{-5} = 5
3 \]
|−5| = 5
1 \begin{align*}
2 \abs{-\frac{1}{2}}
3 &=
4 \frac{1}{2} \,,
5 \\
6 \abs*{-\frac{1}{2}}
7 &=
8 \frac{1}{2} \,,
89
4.3 Defining new commands
9 \\
10 \abs[\bigg]{-\frac{1}{2}}
11 &=
12 \frac{1}{2}
13 \end{align*}
1 1
|− | = ,
2 2
1 1
− = ,
2 2
1 1
− =
2 2
1 \DeclarePairedDelimiterX{\name}
2 [number of arguments n]
3 {left delimiter}{right delimiter}
4 {expression build from #1, #2, ..., #n}
If the built up expression contains a delimiter, and by prefixing this delimiter with the
command \delimsize will ensure that the delimiter scales in the same way as the two
surrounding delimiters. As an example we define a command \inner for inner product.
Example 4.42: Using \DeclarePairedDelimiterX for more advanced delimiters
The defined command \inner takes two arguments and inserts a line (\vert) with some
surrounding space (\,) between them.
Example 4.43: Using more advanced delimiters
1 \[
2 \inner{\psi_1}{\psi_2}
3 \quad
4 \inner*{\frac{f}{g}}{\frac{h}{k}}
5 \]
f h
hψ1 | ψ2 i
gk
90
4.3 Defining new commands
There is also the variant \DeclarePairedDelimiterXPP that is even more flexible than
\DeclarePairedDelimiterX.
1 \NewDocumentCommand{\name}{arguments}{definition}
The field arguments specifies what kinds of arguments the command \name will take:
Mandatory arguments
Mandatory arguments can be declared with the option m:
Example 4.45: Mandatory arguments with \NewDocumentCommand II
1 % in the preamble
2 \NewDocumentCommand{\double}{m}{#1 #1}
3 % in the main text
4 \double{sometext}
sometext sometext
1 % in the preamble
2 \NewDocumentCommand{\swap}{m m}{#2 #1}
3 % in the main text
4 \swap{first}{second}
second first
91
4.3 Defining new commands
1 \IfValueTF{#number of argument}
2 {if the argument has been set}
3 {if the argument has not been set}
One can similarly use \IfNoValueTF instead of \IfNoValueTF. This has the same effect
as switching the cases in Example 47.
Example 4.48: Optional arguments with \NewDocumentCommand, I
1 % in the preamble
2 \NewDocumentCommand{\module}{m o}{\IfNoValueTF{#2}{#1-module}{#1-#2-bimodule}}
3 % in the main text
4 Let $M$ be an \module{$R$} and let $N$ be an \module{$R$}[$S$].
1 % in the preamble
2 \NewDocumentCommand{\restrict}{m m O{}}{#1|_{#2}^{#3}}
3 % in the main text
4 Let $f = \restrict{g}{X}$ and $f' = \restrict{g'}{X}[Y]$
Starred versions
One can use the argument * together with the command \IfBooleanTF to check for the
occurrence of a star. This can be used to also define a starred version of a command.
Example 4.50: Starred versions with \NewDocumentCommand
1 % in the preamble
2 \NewDocumentCommand{\choice}{s m m}{\IfBooleanTF{#1}{#3}{#2}}
3 % in the main text’
4 Dont confuse \choice{first}{second} with \choice*{first}{second}.
92
4.4 Stretch your arrows
1 \[
2 \begin{tikzcd}
3 X \arrow{r}{f \circ g - g \circ f} \arrow{d}
4 &
5 Y \arrow{r}{k} \arrow{d}
6 &
7 Z \arrow[equal]{d}
8 \\
9 X' \arrow[dashed]{r}{h'}
10 &
11 Y' \arrow{r}{k'}
12 &
13 Z'
14 \end{tikzcd}
15 \]
f ◦g−g◦f k
X Y Z
h0 k0
X0 Y0 Z0
The column distance of a commutative diagram is governed by the option column sep.
The value of column sep is expected to be a distance, e.g. 4em. Some standard distances
are predefined, see Table 4.8. With column sep one can fix the above diagram.
Example 4.52: Using column sep
1 \[
2 \begin{tikzcd}[column sep = huge]
3 X \arrow{r}{f \circ g - g \circ f} \arrow{d}
93
4.5 Beware of spacings
4 &
5 Y \arrow{r}{k} \arrow{d}
6 &
7 Z \arrow[equal]{d}
8 \\
9 X' \arrow[dashed]{r}{h'}
10 &
11 Y' \arrow{r}{k'}
12 &
13 Z'
14 \end{tikzcd}
15 \]
f ◦g−g◦f k
X Y Z
h0 k0
X0 Y0 Z0
One can similarly use the option row sep to change the distance of the rows. Some
predefined distances can be found in Table 4.9. They are the same as for column sep
but scaled down by a factor of 0.75.
1 \[
2 a = b \qquad a < b \qquad a + b \qquad a \cdot b
94
4.5 Beware of spacings
3 \]
1 \[
2 a {=} b \qquad a {<} b \qquad a {+} b \qquad a {\cdot} b
3 \]
The automatic spacing can become a problem, as the following examples illustrate:
Example 4.55: Clashing spacings around symbols
1 \[
2 X/\sim
3 \quad
4 R/\operatorname{J}(R) X/ ∼ R/ J(R) id ⊗h
5 \quad
6 \operatorname{id} \otimes h
7 \]
This problem can be fixed by surround the respective symbols in curly brackets.
Example 4.56: Preventing a clash of spacings
1 \[
2 X/{\sim}
3 \quad
4 R/{\operatorname{J}(R)} X/∼ R/J(R) id ⊗ h
5 \quad
6 {\operatorname{id}} \otimes h
7 \]
95
4.5 Beware of spacings
1 \[
2 a | b
3 \quad
4 a \mathop{|} b
5 \quad a|b a | b a|b a|b
6 a \mathrel{|} b
7 \quad
8 a \mathbin{|} b
9 \]
1 \newcommand{\divides}{\mathrel{|}}
2 \[
3 n \divides m n|m
4 \]
96
Chapter 5
Mathematical layout
5.1 Environments for display mathematics
5.1.1 Don’t use $$ $$ or eqnarray
There are many good ways to put mathematical content into display mode, but
$$ $$ and eqnarray are none of them. The method $$ $$ is too low level, and the
environment eqnarray has too many problems and has been deprecated since forever.
One can use any of the following, depending on the planned usage.
1
Suppose that both the formula
Suppose that both the formula
2 \[
3 a + b = c
a+b=c
4 \]
5
and the formula
and the formula
6 \begin{equation*}
7 2a - b = c \,.
2a − b = c .
8 \end{equation*}
9
hold. Then a and b are unique.
hold.
10 Then $a$ and $b$ are unique.
97
5.1 Environments for display mathematics
In particular
p0 = 1 , p1 = 1 + x , p 2 = 1 + x + x2 , p 3 = 1 + x + x2 + x3 ,
p4 = 1 + x + x2 + x3 + x4 , p5 = 1 + x + x2 + x3 + x4 + x5 .
98
5.1 Environments for display mathematics
p0 = 1 , p1 = 1 + x , p 2 = 1 + x + x2 , p 3 = 1 + x + x2 + x3 ,
(5.2)
p 4 = 1 + x + x2 + x3 + x4 , p 5 = 1 + x + x2 + x3 + x4 + x5 . (5.3)
1 We find that
2 \begin{align*}
3 a + b + c
4 &= We find that
5 d + e + f + g
6 \\ a+b+c=d+e+f +g
7 &=
=h+i+j
8 h + i + j
9 \\ = k + l + m + n.
10 &=
11 k + l + m + n \,.
12 \end{align*}
99
5.1 Environments for display mathematics
One can also use multiple aligned columns, which then need to be separated by an
additional &. For n aligned columns we hence need 2n + 1 occurrences of & per line.
Example 5.7: Using align* with multiple columns
x1 = 1 , x2 = 2 , x3 = 3 ,
x4 = 4 , x5 = 5 , x6 = 6 ,
x7 = 7 , x8 = 8 , x9 = 9 .
The environment alignat* is similar to the environment align* but doesn’t add any
built-in spacing between the aligned columns. Any such spacing must therefore by
added by hand. One also has to specify the number of columns beforehand.
Example 5.8: Using the environment alignat*
100
5.1 Environments for display mathematics
y1 = 9 , y2 = 8 , y3 = 7 ,
y4 = 6 , y5 = 5 , y6 = 4 ,
y7 = 3 , y8 = 2 , y9 = 1 .
For aligning multiple columns one should use alignat* instead of align* to get (manu-
ally) a good looking distance between the aligned columns. The environment alignat
works the same way as alignat* but automatically numbers the lines.
1 \[
2 \left\{
3 \begin{aligned} ( )
4 a + b &= c \\ a+b=c
5 d &= e + f d=e+f
6 \end{aligned}
7 \right\}
8 \]
5.1.7 Overview
One should always use the most basic environment that does the job: Using overpowered
environments can lead to unexpected problems. Consider the following example:
101
5.2 Where to break and align formulas
1 \begin{align*}
2 ABCD = EF = GHI = JKL = M = NOP
3 \\
4 QRS = TUV = WX = Y = Z
5 \end{align*}
The environment align* automatically alignes both lines on the right since no infor-
mation about alignment was given. In the above situation one should use gather*
instead.
Example 5.12: Using gather* for non-aligned equations
1 \begin{gather*}
2 ABCD = EF = GHI = JKL = M = NOP
3 \\
4 QRS = TUV = WX = Y = Z
5 \end{gather*}
If a multi-line display mode environment is used for a single line then one can get
spacing issues, see Section 5.4.
The flowchart in Figure 5.1 explains how to choose the correct display environment.
(This flowchart is partly inspired by [Kot15].)
If a formula is broken among multiple lines then one has to choose at which places the
formula is broken, and how the resulting parts of the formula will be aligned. In this
section we present some standard ways of doing so.
102
5.2 Where to break and align formulas
formula
no \[ \]
multi-line? equation*
yes
no
alignment? gather*
yes
no
multiple columns? align*
yes
alignat*
1 It follows from
2 \[
3 aaaaaaa
4 =
5 bbbbbbb
6 =
7 ccccccc
8 \leq
9 ddddddd
10 =
103
5.2 Where to break and align formulas
11 eeeeeee
12 =
13 fffffff
14 \leq
15 ggggggg
16 =
17 hhhhhhh
18 \]
19 that $a \leq h$.
It follows from
that a ≤ h.
The formula in the above example does actually not go over the margin. But it has
stretched the displaymode over its visual limits. The formula does therefore need to be
broken up.
Expressing structure
Often the breaking up of a formula is done to better express the structure–and thus
content–of the displayed formula. Consider the following example:
104
5.2 Where to break and align formulas
The above output still has an appropriate length to be put into a single line, and if
space is spare then this is an acceptable solution. But this single-line approach to the
formula does not help to display its internal structure. This can be done by splitting
up the formula as done in the next example:
Example 5.16: Broken up version of Example 15
105
5.2 Where to break and align formulas
This form makes it clear where the equalities and isomorphisms occur.
106
5.2 Where to break and align formulas
107
5.2 Where to break and align formulas
(r, s) ∈ (R × S)×
⇐⇒ there exist (r0 , s0 ) ∈ R × S with (r, s)(r0 , s0 ) = (1, 1)
⇐⇒ there exist r0 ∈ R and s0 ∈ S with rr0 = r and ss0 = 1
⇐⇒ r ∈ R× and s ∈ S ×
⇐⇒ (r, s) ∈ R× × S × ,
The empty pair of curly brackets in \iff{}& ensures that the spacings coming from
\iffand & do not interfere with each other. Otherwise something like this happens:
Example 5.19: Wrong spacing when alignment points are set wrong
1 \begin{align*}
2 &\text{some stuff} \\
3 =&\text{some other stuff}
4 \end{align*}
some stuff
=some other stuff
1 \begin{align*}
2 & a + b + c + \\ a + b + c+
3 & d + e
d+e
4 \end{align*}
108
5.2 Where to break and align formulas
1 \begin{align*}
2 & a + b + c \\ a+b+c
3 & + d + e
+d+e
4 \end{align*}
If a formula is broken at relation symbols and one of the resulting terms is broken at a
binary operator, then the operator is not aligned together with the relation symbols.
Instead the binary operator appears after the relation symbols. The following example
does it wrong:
Example 5.22: Wrong breaking at a binary operator II
1 \begin{align*}
2 a + a
3 &=
4 b + b + b + b
5 \\ a+a=b+b+b+b
6 &+
+b+b+b+b
7 b + b + b + b
8 \\ =c+c+c+c+c
9 &=
10 c + c + c + c + c
11 \end{align*}
1 \begin{align*}
2 a + a
3 ={}&
4 b + b + b + b
5 \\ a+a=b+b+b+b
6 {}&
+b+b+b+b
7 +b + b + b + b
8 \\ =c+c+c+c+c
9 ={}&
10 c + c + c + c + c
11 \end{align*}
109
5.2 Where to break and align formulas
1 It follows that
2 \begin{align*}
3 aaaaaaaaaaaa
4 =
5 bbbbbbbbbbb
6 =
7 cccccccccc
8 =
9 ddddddddd
10 &=
11 eeeeeeee
12 \\
13 &=
14 ffffff
15 \end{align*}
16 and hence $2 + 2 = 5$.
It follows that
and hence 2 + 2 = 5.
1 It follows that
2 \begin{align*}
3 aaaaaaaaa
4 &=
5 bbbbbbbbbbb
6 =
7 cccccccc
8 \leq
9 dddddd
110
5.2 Where to break and align formulas
10 =
11 eeeeeee
12 \\
13 &=
14 eee
15 \leq
16 fffffff
17 =
18 gggggggg
19 \leq
20 hhhhhhhhh
21 \\
22 &<
23 kkkkkkk
24 =
25 llll
26 \leq
27 mmmma
28 =
29 nnnnnnn
30 =
31 pp \,.
32 \end{align*}
It follows that
In such a case the breaking of the formula should be done in a consistent way. There
seems to be two sensible approaches in this example:
Align everything
One can align all occurring relation symbols:
Example 5.26: Aligning all relation symbols
1 It follows that
2 \begin{align*}
3 aaaaaaaaa
4 &= bbbbbbbbbbb \\
5 &= cccccccc \\
6 &\leq dddddd \\
111
5.2 Where to break and align formulas
7 &= eeeeeee \\
8 &= eee \\
9 &\leq fffffff \\
10 &= gggggggg \\
11 &\leq hhhhhhhhh \\
12 &< kkkkkkk \\
13 &= llll \\
14 &\leq mmmma \\
15 &= nnnnnnn \\
16 &= pp \,.
17 \end{align*}
It follows that
aaaaaaaaa = bbbbbbbbbbb
= cccccccc
≤ dddddd
= eeeeeee
= eee
≤ fffffff
= gggggggg
≤ hhhhhhhhh
< kkkkkkk
= llll
≤ mmmma
= nnnnnnn
= pp .
This approach has the advantage of being very consistent. But it has the disadvantage
of taking a lot of space. It also may not reflect the structure of the formula particularly
well, as this layout gives all (in)equalities the same importance.
Align at inequalities
On could align all the inequality symbols, to make it clear where these occur:
Example 5.27: Aligning all inequalities
1 It follows that
2 \begin{align*}
3 aaaaaaaaa
4 &= bbbbbbbbbbb
112
5.3 Aligning nearly aligned formulas
5 = cccccccc
6 \\
7 &\leq
8 dddddd
9 = eeeeeee
10 = eee
11 \\
12 &\leq
13 fffffff
14 = gggggggg
15 \\
16 &\leq
17 hhhhhhhhh
18 \\
19 &<
20 kkkkkkk
21 = llll \\
22 &\leq mmmma
23 = nnnnnnn
24 \\
25 &= pp \,.
26 \end{align*}
It follows that
This layout emphasizes the importance of the inequalities, while relegating the equalities
to a less important position. Note that we have also aligned the first and last equality
signs to make it clear where the manipulations begin and end. If some other equalities
are also particularly important (e.g. if they follows from some previously hard-earned
proposition) then they too should be aligned
113
5.3 Aligning nearly aligned formulas
1 \begin{gather*}
2 KK^{-1} = 1 = K^{-1}K \,,
3 \quad
4 EF - FE = \frac{ K - K^{-1} }{ q - q^{-1} } \,,
5 \\
6 KE = q^2 EK \,,
7 \quad
8 KF = q^{-2} FK \,.
9 \end{gather*}
K − K −1
KK −1 = 1 = K −1 K , EF − F E = ,
q − q −1
KE = q 2 EK , KF = q −2 F K .
Note that the first line of the output looks slightly shifted to the left when compared to
the second line. But properly aligning both lines this impression vanishes and instead
gives rise to more coherent look and fell.
Example 5.29: Intentional well-aligned expressions
1 \begin{align*}
2 KK^{-1} = 1 = K^{-1}K \,,
3 \quad
4 &EF - FE = \frac{ K - K^{-1} }{ q - q^{-1} } \,,
5 \\
6 KE = q^2 EK \,,
7 \quad
8 &KF = q^{-2} FK \,.
9 \end{align*}
K − K −1
KK −1 = 1 = K −1 K , EF − F E = ,
q − q −1
KE = q 2 EK , KF = q −2 F K .
114
5.4 Proper spacing before multi-line display mode environments
If the line before a display mode environment is too short then this vertical spacing
may be visually too large. The one-line display environments \[ \] and do therefore
automatically adjust this spacing. Observe that in the following example the distance
between the first two text lines is far shorter than the distance between the second and
third text lines.
Example 5.31: Adjusted spacing before one-line display mode
1 Lorem
2 \[
Lorem
3 a = b a=b
4 \]
ipsum dolor sit amet, consectetur
5 ipsum dolor sit amet, consectetur
6 \[
a = b.
7 a = b \,.
8 \]
ipsum elit.
9 ipsum elit.
We can say more precisely that the additional spacing inserted by LATEX is either
\abovedisplayskip or its shorter version \abovedisplayshortskip.
The multi-line display mode environments (like align*) don’t have this feature. It
always uses the spacing \abovedisplayskip (for technical reasons). This can lead to
some unpleasant spacing:
115
5.5 Use the cases environment
1 text text text text text text text text text text text text text text text
text text text
2 \begin{alignat*}{1}
3 x &= y_i x = yi
4 \shortintertext{text}
5 x &= z_{i+1}
text
6 \end{alignat*} x = zi+1
7 text text text text text text text
text text text text text text text text text
The package mathools provides a partial fix to this problem: By putting the com-
mand \SwapAboveDisplaySkip at the beginning of a multi-line display mode environment
we force LATEX to use the shorter spacing \abovedisplayshortskip.
Example 5.33: Pleasant spacing around a multi-line environment
1 It follows that
2 \[
3 A(x)
4 =
5 \begin{cases}
6 x^2 & \text{if $x \leq 0$,} \\
7 3x & \text{if $x = 0$.}
8 \end{cases}
9 \]
116
5.6 Proper placement of the qed-symbol
It follows that
if x ≤ 0,
(
x2
A(x) =
3x if x = 0.
In most cases one should actually use the environment cases*, which ensures that the
second column will be treated as text.
Example 5.35: Using cases*
1 It follows that
2 \[
3 A(x)
4 =
5 \begin{cases*}
6 x^2 & if $x \leq 0$, \\
7 3x & if $x = 0$.
8 \end{cases*}
9 \]
It follows that
if x ≤ 0,
(
x2
A(x) =
3x if x = 0.
The package mathtools defines some more useful variants of the environment cases.
We refer to [CTN19b, 3.4.3] for more information on this.
1 \begin{proof}
2 This is obviously a proof.
3 \end{proof}
It can happen that this automatic placement of the qed-symbol gives a bad looking
result. The general rule is that the qed-symbol should not occur at the end of an
otherwise empty line. To fix such a bad placement one can use the command \qedhere
117
5.6 Proper placement of the qed-symbol
1 \begin{proof}
2 This proof consists of a list.
3 \begin{enumerate}
4 \item
5 Some part of the proof.
6 \item
7 Another part of the proof.
8 \end{enumerate}
9 \end{proof}
1 \begin{proof}
2 This proof consists of a list.
3 \begin{enumerate}
4 \item
5 Some part of the proof.
6 \item
7 Another part of the proof.
8 \qedhere
9 \end{enumerate}
10 \end{proof}
But one has to be careful no to introduce a new line before the command \qedhere.
118
5.6 Proper placement of the qed-symbol
1 \begin{proof}
2 This proof consists of a list.
3 \begin{enumerate}
4 \item
5 Some part of the proof.
6 \item
7 Another part of the proof.
8
9 \qedhere
10 \end{enumerate}
11 \end{proof}
1 \begin{proof}
2 This proof ends with a some display~mode mathematics, namely
3 \[
4 \sin(x+y)
5 =
6 \cos(x)\sin(y) + \sin(x)\cos(y) \,.
7 \]
8 \end{proof}
Proof. This proof ends with a some display mode mathematics, namely
119
5.6 Proper placement of the qed-symbol
Example 5.41: Somewhat proper placement of the qed-symbol after display mode
1 \begin{proof}
2 This proof ends with a some display~mode mathematics, namely
3 \[
4 \sin(x+y)
5 =
6 \cos(x)\sin(y) + \sin(x)\cos(y) \,.
7 \qedhere
8 \]
9 \end{proof}
Proof. This proof ends with a some display mode mathematics, namely
But this approach does not work if the (last line) of the display environment has
additional height. Then the mathematical formula go below the line on which the
qed-symbol rests.
Example 5.42: Improper placement of the qed-symbol after display mode II
1 \begin{proof}
2 This proof ends with a some display~mode mathematics, namely
3 \[
4 1
5 + \frac{a}{b - a}
6 =
7 \frac{(b - a) + a}{b - a}
8 =
9 \frac{b}{b - a} \,.
10 \qedhere
11 \]
12 \end{proof}
Proof. This proof ends with a some display mode mathematics, namely
a (b − a) + a b
1+ = = .
b−a b−a b−a
The author is the opinion that in such a cases there is no good placement for the
qed-symbol.
Aside the placement of the qed-symbol there is another problem to ending a proof
with a display environment: One of the functions of display mode is to put an emphasis
on the displayed mathematical content. Putting such an emphasis directly before the
120
5.7 Tagging and numbering
5.7.2 \tag
With the command \tag a custom tag can be set. This is useful for marking selected
equations by special symbols:
Example 5.43: Using \tag for marking a line
The argument of \tag is in text mode, and the resulting tag is automatically enclosed
in parentheses. These parentheses can be removed by using the starred command \tag*
instead.
121
5.7 Tagging and numbering
The command \tag should not be used for regular numbering of equations. It should
be used to tag only certain (often a single) equations in a special way.
It can also be used to express that certain transformations have been used, as the
following example demonstrates:
Example 5.44: Using \tag to explain steps
5.7.3 \notag
According to Section 5.7.1 a formula should be numbered only if it needs to be referred to.
But if this formula occurs in a multi-line environment like align* then by switching align
all lines will be numbered. The prevent the numbering of the unrequired lines the
command \notag can then be used:
Example 5.45: Using \notag to prevent selected line numbers
1 \begin{align}
2 a a=b
3 &= b \notag \\
4 &= c \\
=c (5.7)
5 &= d \notag \\ =d
6 &= e
=e (5.8)
7 \end{align}
122
5.8 Multi-line set descriptions
can be typeset by using a tabular environment for the right hand side of the set
description:
Example 5.46: Multi-line set descriptions with tabular
1 \[
2 \left\{
3 x \in X
4 \,\middle|\,
x satisfies
5 \begin{tabular}{@{}c@{}}
x∈X
certain conditions
6 $x$ satisfies \\
7 certain conditions
8 \end{tabular}
9 \right\}
10 \]
Note that the entries of the environment tabular are automatically in text mode. The
argument {} ensure that the environment tabular does not insert additional spacing to
its left and right.
123
Bibliography
[Bel18] Pieter Belmans. My good practice concerning inline mathematical formulas.
December 18, 2018. url: https://pbelmans.ncag.info/blog/2010/12/18/
my-good-practice-concerning-inline-mathematical-formulas (visited on
September 4, 2019).
[CMS17] The Chicago Manual of Style. The Essential Guide for Writers, Editors and
Publishers. 17th ed. The University of Chicago Press, 2017. xvii+1144 pp.
isbn: 978-0-226-28705-8. doi: 10.7208/cmos17.
[CTN16] Simon Fear. Publication quality tables in LATEX. Version 1.618033. April 29,
2016. 17 pp. url: https://www.ctan.org/pkg/booktabs (visited on Septem-
ber 1, 2019).
[CTN18] Augusto Stoffel. {tikzcd}. Commutative diagrams with TikZ. Version 0.9f.
November 19, 2018. 17 pp. url: https://ctan.org/pkg/tikz-cd (visited
on September 4, 2019).
[CTN19a] Javier Bezos. Customizing lists with the enumitem package. Version 3.9.
June 20, 2019. 23 pp. url: https://ctan.org/pkg/enumitem (visited on
September 14, 2019).
[CTN19b] Morten Høgholm and Lars Madsen. The mathtools package. Version 1.22.
July 31, 2019. 37 pp. url: https://ctan.org/pkg/mathtools (visited on
September 12, 2019).
[CTN19c] Philip Kime, Moritz Wemheuer, and Philipp Lehman. The biblatex Pack-
age. Programmable Bibliographies and Citations. Version 3.13. August 17,
2019. 336 pp. url: https://ctan.org/pkg/biblatex (visited on Septem-
ber 6, 2019).
[Kot15] Stefan Kottwitz. Example: Flowchart. August 29, 2015. url: http : / /
www.texample.net/tikz/examples/math-flowchart/(visited on August 27,
2019).
[L2M19] LATEX2e. An unofficial reference manual. June 2019. ix + 262 pp. url:
https://latexref.xyz (visited on September 4, 2019).
[TSE11] Nobby. What is the difference between \mathbin vs. \mathrel? December 21,
2011. url: https://tex.stackexchange.com/questions/38982/what-is-the-
difference-between-mathbin-vs-mathrel (visited on August 19, 2019).
[TSE14] Lupino. For formal articles, should a displayed equation be followed by a
punctuation to conform to the language grammar ? April 10, 2014. url:
https://tex.stackexchange.com/a/170691/108717 (visited on August 18,
2019).
124
List of examples
1.1 Code is too cramped . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Code is less cramped . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Code isn’t cramped . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Unrelated symbols need to be separated . . . . . . . . . . . . . . . . . 2
1.5 Unrelated symbols are separated . . . . . . . . . . . . . . . . . . . . . 3
1.6 Unrelated symbols are separated even better . . . . . . . . . . . . . . 3
1.7 Wrong spacing before a footnote . . . . . . . . . . . . . . . . . . . . . 3
1.8 Right spacing before a footnote . . . . . . . . . . . . . . . . . . . . . 4
1.9 Layout of main.tex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.10 Layout of mystyle.sty . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.11 Layout of chapter1.tex . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.12 Layout of section1.tex . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.13 Basic example of main.tex . . . . . . . . . . . . . . . . . . . . . . . . 6
1.14 Using the command \includeonly . . . . . . . . . . . . . . . . . . . . 7
1.15 Syntax of \includeonly . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.16 Using the option chapterprefix . . . . . . . . . . . . . . . . . . . . . 8
1.17 Changing KOMA fonts . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.18 Using the option egregdoesnotlikesansseriftitles . . . . . . . . . . 8
1.19 Using the environment abstract . . . . . . . . . . . . . . . . . . . . . 9
1.20 Using the option titlepage . . . . . . . . . . . . . . . . . . . . . . . . 9
1.21 Using the option oneside . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.22 Using the option openany . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.23 Using the option openany . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.24 General document layout with scrbook . . . . . . . . . . . . . . . . . 11
1.25 Inconsistency looks bad . . . . . . . . . . . . . . . . . . . . . . . . . . 11
125
List of examples
126
List of examples
127
List of examples
128
List of examples
129
List of examples
130
Index
\(space), 53 \Leftrightarrow, 74
\@, 53 \notrightarrow, 75
$ $, 101 \Rightarrow, 74
$$ $$, 97 \rightarrow, 73
%, 3 \to, 73
&, 99, 100 \xhookleftarrow, 80
~, 56 \xhookrightarrow, 80
\|, 74 \xLeftarrow, 80
\\, 57 \xleftarrow, 80
\[ \], 97, 115 \xleftharpoondown, 80
\xleftharpoonup, 80
abstract, 8 \xLeftrightarrow, 80
\addtokomafont, 8 \xleftrightarrow, 80
align, 99 \xleftrightharpoons, 80
align*, 67, 99, 115 \xlongequal, 80
alignat, 101 \xLongleftarrow, 80
alignat*, 100 \xlongleftarrow, 80
aligned, 101 \xlongleftrightarrow, 80
alignedat, 101 \xLongrightarrow, 80
aligning formulas, 67, 106–110, 113–114 \xlongrightarrow, 80
see also \align* \xmapsto, 80
see also \alignat* \xRightarrow, 80
Alph*, 23 \xrightarrow, 79, 80
alph*, 23 \xrightharpoondown, 80
amsmath, 12, 79, 82, 97 \xrightharpoonup, 80
amssymb, 12 \xrightleftharpoons, 80
amsthm, 12 @article, 38
\newtheorem, 12 article, 8
proof, 59, 117 arXiv, 39
\appendix, 10 author, 35
Arabic numeral, 23
Arabic numerals, 10, 36 babel,21
arabic*, 23 babel,21
arrows backend, 33
extensible, 79 \backepsilon, 74
\Leftarrow, 74 \backmatter, 9, 10
131
Index
\backslash, 74 bibliography,
10, 41
before a footnote, 3 \cite,
40
bib-file, 33–39 MathSciNet, 35
biber, 33, 42 \printbibliography, 41
biblatex, 33 \bibliography, 40
\cite, 40 bibliography, 10, 41
keys \big, 89
author, 35 \bigg, 89
crossref, 37 \binoppenality, 62
date, 36, 39 Bmatrix, 83
doi, 36 bmatrix, 83
edition, 36 @book, 35
isbn, 36 book, 8
issn, 38 booktabs, 45
journaltitle, 38 \bottomrule, 45
number,36, 38 \cmidrule, 45
pages, 38 \midrule, 45
pagetotal, 36 \toprule, 45
publisher, 36 \bottomrule, 45
series, 36 Bsmallmatrix, 83
subtitle, 35 bsmallmatrix, 83
title, 35
url, 39 c, 42, 83
urldate, 39 capitalise, 18
volume, 37, 38 cases, 116
volumes, 37 cases*, 117
year, 36 \cdots, 81
options center, 101
backend, 33 \centernot, 74
dateabbrev, 34 centernot, 74
style, 34 \chapter, 9
urldate, 34 chapterprefix, 8
\printbibliography, 41 \cite, 40
types cleveref, 18
@article, 38 babel, 21
@book, 35 capitalise, 18
@mvbook, 37 \Cref, 19
@online, 38 \cref, 18
bibliography, 10, 33–42 \lcnamecref, 19
arXiv, 39 \lcnamecrefs, 19
back end, 33 \nameCref, 19
bib-file, 33–39 \namecref, 19
biber, 33, 42 \nameCrefs, 19
biblatex, 33 \namecrefs, 19
\bibliography, 40 noabbrev, 18
132
Index
\cline, 43 $$ $$, 97
\cmidrule, 45 \[ \], 97, 115
\colon, 74 align, 99
\coloneqq, 74 align*, 67, 99, 115
column sep, 93 alignat, 101
commutative diagrams, 15, 48–50 alignat*, 100
consistency, 11 eqnarray, 97
corollary, 12 equation, 97
counter, 13 equation*, 97, 115
\Cref, 19 gather, 98
\cref, 18 gather*, 67, 98
crossref, 37 document class, 8
csquotes, 20 classes
\enquote, 20 article, 8
book, 8
date, 36, 39 report, 8
dateabbrev, 34 scrartcl, 8
\ddots, 81 scrbook, 8
\DeclareMathOperator, 78, 86 scrreprt, 8
\DeclareMathOperator*, 78 options
\DeclarePairedDelimiter, 89 abstract, 8
\DeclarePairedDelimiterX, 90 bibliography, 10, 41
\DeclarePairedDelimiterXPP, 91 chapterprefix, 8
defining commands egregdoesnotlikesansserif-
\DeclareMathOperator, 78, 86 titles,
\DeclareMathOperator*, 78 8
\DeclarePairedDelimiter, 89 oneside, 9
\DeclarePairedDelimiterX, 90 openany, 9, 10
\DeclarePairedDelimiterXPP, 91 titlepage, 9
\newcommand, 88 doi, 36
\NewDocumentCommand, 91 dots
\operatorname, 78, 87 see ellipsis
\operatorname*, 78 \dots, 82
\renewcommand, 88 \dotsb, 81
delimiters \dotsc, 81
\|, 74 \dotsi, 81
\langle, 74 \dotsm, 81
\lVert, 74 \dotso, 81
\rangle, 74
\rVert, 74 edition, 36
see also \DeclarePairedDelimiter egregdoesnotlikesansseriftitles, 8
\delimsize, 90 ellipses, 79–82
description, 22, 28 \cdots, 81
differential, 85 \ddots, 81
display math environment \dots, 82
133
Index
\dotsb, 81 \include, 4
\dotsc, 81 \includeonly, 6
\dotsi, 81 \input, 4
\dotsm, 81 \usepackage, 4
\dotso, 81 fonts
\ldots, 81 \addtokomafont, 8
\vdots, 81 footnote, 3
\emptyset, 74 fractions, 85–86
em dash, 51, 57 \frontmatter, 9, 10
\enquote, 20
enumerate, 22, 26 gather,98
see also enumitem gather*,67, 98
enumi, 31 gathered, 101
enumii, 31 Git, 1
enumitem, 22
\hline, 43
Alph*, 23
huge,93, 94
alph*, 23
arabic*, 23
hyperlink, 19
hyperref, 19
enumi, 31
enumii, 31
hyphen, 51, 52, 56
itemsep, 25
\IfBooleanTF, 92
label, 22, 23
iff, 72
leftmargin, 27
\iff, 74
listparindent, 25
\impliedby, 74
\newlist, 32
\implies, 74
parsep, 25
\in, 74
resume, 24
\include, 4
resume*, 24
\includeonly, 6
Roman*, 23
including files
roman*, 23
see file inclusion
setlist, 29
indent, 26
wide, 26, 29
indentation
en dash, 51, 57
for list environments, 26–29
\epsilon, 74
in source code, 3
eqnarray, 97
of paragraphs, 25, 57
\eqqcolon, 74
\infty, 74
\eqref, 17
\input, 4
equation, 97
integral, 81, 85
equation*, 97, 115
\intertext, 67
error, 1, 3
introduction, 10
extarrows, 12, 79
isbn, 36
extensible arrows, 79
issn, 38
itemize, 22, 28
Facebook, 1
itemsep, 25
file inclusion
134
Index
135
Index
\nameCref,19 @online, 38
\namecref,19 openany, 9, 10
\nameCrefs, 19 \operatorname, 78, 87
\namecrefs, 19 \operatorname*, 78
negation orthography, 47
\centernot, 74 \overset, 78
\neq, 75
\nexists, 75 packages
\nleq, 75 amsmath, 12, 79, 82, 97
\not, 73 amssymb, 12
\notin, 75 amsthm, 12
\notrightarrow, 75 babel, 21
\neq, 75 biblatex, 33
\newcommand, 88 booktabs, 45
\newcounter, 14 centernot, 74
\NewDocumentCommand, 91 cleveref, 18
\IfBooleanTF, 92 csquotes, 20
mandatory argument, 91 enumitem, 22
optional argument extarrows, 12, 79
with default value, 92 hyperref, 19
without default value, 91 mathtools, 12, 79, 82, 83, 117
\newline, 57 microtype, 12
\newlist, 32 ntheorem, 60
\newtheorem, 12 stmaryrd, 12
\newtheorem*, 13 tikz-cd, 15
\nexists, 75 xparse, 91
\ni, 74 pages, 38
\nleq, 75 pagetotal, 36
noabbrev, 18 paragraphs, 25, 57
\nobreakdash, 56 parsep, 25
normal, 93, 94 \part, 9
\not, 73 penalties
\notin, 75 \binoppenality, 62
\notrightarrow, 75 \relpenalty, 62
\nsubseteq, 84 \phi, 74
ntheorem, 60 pmatrix, 83
number, 36, 38 preface, 10
numerals \printbibliography, 41
Arabic, 10, 23, 36 proof, 59, 117
Roman, 23, 36 proposition, 12
roman, 10 psmallmatrix, 83
publisher, 36
o, 91 punctuation
O{ }, 92 em dash, 51, 57
oneside, 9 en dash, 51, 57
136
Index
137
Index
138
Index
warning, 1, 3
wide, 26, 29
XƎLATEX, 1
\xhookleftarrow, 80
\xhookrightarrow, 80
\xLeftarrow, 80
\xleftarrow, 80
\xleftharpoondown, 80
\xleftharpoonup, 80
\xLeftrightarrow, 80
\xleftrightarrow, 80
\xleftrightharpoons, 80
\xlongequal, 80
\xLongleftarrow, 80
\xlongleftarrow, 80
\xlongleftrightarrow, 80
\xLongrightarrow, 80
\xlongrightarrow, 80
\xmapsto, 80
xparse, 91
\xRightarrow, 80
\xrightarrow, 79, 80
\xrightharpoondown, 80
\xrightharpoonup, 80
\xrightleftharpoons, 80
year, 36
139