Avoidable Mistakes

This is a compilation of classic mistakes that I have seen in many LaTeX documents.

Abbreviations

The letters between abbreviations should have half spaces:

z.\,B.
d.\,h.

i.e. is not enough, i. e. is too much.

Spacing behind Commands

A command has to be ended with a space, LaTeX would otherwise interpret that as belonging to that command:

\LaTeXist
\LaTeX ist

The colors tell you that in the first line, the “ist” belongs to the command. That is okay.

The problem is, that the space in front of the “ist” in the second line will only end the command, but not create a space! The output is “LaTeXist”. The command has to be ended with another method, preferably with an empty token: {}:

\LaTeX{} ist

Even if the command \LaTeX does not take any arguments, you will need braces here!

Quotation Marks

The correct quotes for German Text are „ and “: 99 and 66. For English text, they are “ and ”, 66 and 99. With LaTeX, you have several possibilities:

  1. Enter the quotes directly. On a German keyboard with Kubuntu they are Alt-Gr v and Alt-Gr b for the German ones, and Alt-Gr b and Alt-Gr n for the English ones.

    On a US International layout, the English ones are on Alt-Gr Shift [ and ]. The leading German one has to be entered with the compose key, where you compose " with ,.

  2. Use "` and "'. This makes the code pretty hard to read, so I would not do that.

  3. You can work with \glqq and \glqq for the German quotes. The English quotes are without the leading g. You have to watch the Spacing behind Commands issue though. For that, I defined myself a German quoting command like so:

    \newcommand[1]{\gqq}{\glqq #1 \grqq}
    

LaTeX will make `` and '' English quotes. Additionally, a " might become a diaeresis on the next letter. See Escaping umlauts.

Overwriting Commands

With \newcommand, you can define new commands. It could even be a good idea to create new names for existing commands, wee Semantic Markup.

It happens that a given name is already taken. The imaginary unit, \mathrm i should be roman, to be able to distinguish it from the index i. Since \mathrm i is a lot to write and is not semantic, a new command should be created:

\newcommand{\i}{\mathrm i}

The problem is that the command \i already exists. It is important to use another name (\iup or \ii). Do not overwrite that command with \renewcommand! If the command \i is needed, it would not exist any more.

Missing commands can be added easily, overwritten commands are lost.

The overwriting is allowed, if it does not change anything with the semantics. It is allowed to overwrite \vec to change for bold vectors. It would not be okay if it was used for something else.

Decimal separator

In German texts, the decimal separator has to be a comma, not a period. The package siunitx supports that with the option output-decimal-marker={,}. All numbers have to be printed with the command \num{123.45}

\usepackage[output-decimal-marker={,}]{siunitx}

Units

Physical units must be printed in roman (non-italic) font and with a thin space (\.) after the number. This works great with the siunitx package.

eqnarray

Use align from the amsmath package instead of eqnarray. The latter has wrong spacing and might overwrite the equation number.

Fixed numbers and references

Numbered equations, like equation, get a number like “(1)”. If you refer to that equation, it might be convenient to just write “(1)” in your text. This number will change whenever you add another equation before the first one.

One should use \label to assign an internal name to the equation and refer to it with \eqref later on. Other things can be referred to with \ref.

\section{Feldstärketensor}
\label{section:Feldstärketensor}

\begin{equation}
    \label{eq:Bianchi}
    \nabla^{[\alpha} F^{\beta\gamma]} = 0
\end{equation}

% Viel Text, ein anderer Abschnitt vielleicht …

Mit der Identität \eqref{eq:Bianchi} aus Abschnitt
\ref{section:Feldstärketensor} ...

It might be a good idea to use namespaces for each type of object, like eq:, section:, theorem:, example:.

Formula numbers for multiple formulas

If multiple formulas should have the same label (like a system of equations), one should use the subequations package:

\begin{subequations}
    \label{eq:Axiome}
    \begin{gather}
        \label{eq:Axiom2}
        F = m a \\
        \label{eq:Axiom3}
        F_{1,2} = F_{2,1}
    \end{gather}
\end{subequations}

Die Newton'schen Axiome \eqref{eq:Axiome} bestehen aus dem zweiten Axiom
\eqref{eq:Axiom2} und dem dritten Axiom \eqref{eq:Axiom3}.

Let the equations be numbered with (1a) and (1b). The text will be rendered to:

Die Newton’schen Axiome (1) bestehen aus dem zweiten Axiom (1a) und dem dritten Axiom (1b).

Manual accumulation has the problem that your number will not become a label and that it will not be displayed right next to the formula. So do not do the following:

\begin{equation*}
    \left.
        \begin{gathered}
            F = m a \\
            F_{1,2} = F_{2,1}
        \end{gathered}
    \right\rbrace
    \quad
    \text{(1)}
\end{equation*}

Die Newton'schen Axiome (1) …

Ordered lists

There are unordered and ordered lists. The former just have a bullet point in front of each element, the latter have numbers in front. The numbers can be Arabic numerals, roman numerals or roman letters. In every case, the numbering should be done automatically.

An ordered list can be created like so:

\begin{enumerate}
    \item erster Listenpunkt
    \item zweiter Listenpunkt
\end{enumerate}

It will appear like this:

  1. erster Listenpunkt
  2. zweiter Listenpunkt

Under no circumstances should one try to number the list by hand. I have seen the following, where each list item of an unordered list got a number like this:

\begin{itemize}
    \item[a)] erster Listenpunkt
    \item[b)] zweiter Listenpunkt
\end{itemize}

Numbering the points by hand is too much work. It is error prone. It also invites to refer via “a)” instead of using proper references. Better use enumerate right away. If your desired style is not included, try the paralist package.

\begin{enumerate}[a)]
    \item
        \label{enum:erster}
        erster Listenpunkt

    \item
        zweiter Listenpunkt
\end{enumerate}

Der Punkt \ref{enum:erster} ist der erste in der Liste.

Semantic markup

LaTeX source code should be written with “What does this mean?” in mind, not with “How should it look in the end?”.

A striking example: Headings should be big and bold (and maybe sans-serif). Almost everybody uses the correct command:

\section{Überschrift}

One could also do the following (but should not):

{\large\bf Überschrift}

There are the following problems:

  1. The result looks similar, except that it is not a heading. It is big, bold text. If you use the package hyperref, it will appear in the PDF table of contents with the correct version. The incorrect version will not get put into the table of contents.

    If you use \tableofcontents, the latter will not show up either. One might think about creating the table of contents by hand …

  2. The section number is missing. This could be added manually, but see Fixed numbers and references on why you should not do this.

  3. In the source code, the heading does not appear as one. TeXMaker offers an outline, which does not pick up the wrong version either.

  4. Headings cannot be formatted differently at a central spot, because they are not headings in the first place. If all headings should be without serifs, you will have to add a \sffamily to every single one.

  5. \bf is TeX, you should use \bfseries instead.

One should use commands that show which structure something has, not which appearance.

There are a lot more examples like this:

Implications

A mathematical implication is shown with a \implies arrow. Often, people use \Rightarrow \Rightarrow, that is too short and does not have enough spacing. Therefore, you must use the \implies command. That not only is the right symbol, but also the correct name in the source code.

With \Rightarrow:

a \Rightarrow b

With \implies:

a \implies b

The \Longrightarrow \Longrightarrow is longer, but the spacing does not fit either:

a \Longrightarrow b

Equivalence

Similarly, the equivalence is denoted by \iff. Some use \Leftrightarrow \Leftrightarrow or \Longleftrightarrow \Longleftrightarrow. Correct is \iff.

Text in math mode

Text within math mode should be roman:

F_\text{Schwerkraft}

It might be tempting to use \mathrm instead. It does not display umlauts correctly and does not show any spacing. \mbox does not do that, but is not semantic. One should use \text.

F_\text{Schwerkraft}

Emphasis

Emphasis on the blackboard is done with underlines, italic and bold are not possible. LaTeX is able to print italic text, which is the first choice for simple emphasis. But do not use \textit. Use \emph instead, because it is semantic.

Mathematical proofs

A mathematical proof should be withing the proof environment from the amsthm package:

\begin{proof}\end{proof}

Please do not use a contraption like this:

\textit{Beweis}. \ \\square

TeX instead of LaTeX

Unnumbered equations are done with \[ and \] in LaTeX. TeX uses $$ on both sides. If you use LaTeX (with pdflatex for example), only use the LaTeX style. Document options like fleqn do not affect TeX style equations.

Escaping umlauts

Like every other programming language, umlauts and other special characters can cause trouble, if the encoding is not selected properly. It is extremely useful to use UTF-8. The editor has to be set to UTF-8, but LaTeX has to be told as well:

\usepackage[utf8]{inputenc}

With that, umlauts can be entered as such.

Back in the day (or if you have not set it up correctly) the umlauts did not work right. You can enter a “ü” with "u or \"u. This has the minuscule advantage that your document can be rendered correctly with wrong encodings, but it is unreadable and breaks spell checking.

Nested lists

If two lists are nested, i. e. a list is used as a list element, you have to fill the line with \hfill.

Without \hfill:

\begin{description}
    \item[objektorientiert]
        \begin{itemize}
            \item Java
            \item C++
        \end{itemize}

    \item[Templatesprache]
        \begin{itemize}
            \item PHP
            \item Jinja 2
        \end{itemize}
\end{description}

It looks the following:

../../_images/list.png

With \hfill:

\begin{description}
    \item[objektorientiert]\hfill
        \begin{itemize}
            \item Java
            \item C++
        \end{itemize}

    \item[Templatesprache]\hfill
        \begin{itemize}
            \item PHP
            \item Jinja 2
        \end{itemize}
\end{description}
../../_images/list-hfill.png

The same principle applies if a list should be first in a theorem or a proof:

\begin{proof}\hfill
    \begin{itemize}
        \item\end{itemize}
\end{proof}

Line break after align

The last line of an align or gather environment must not be ended with \\. This is a line separator, not a line ending. Correct is the following:

\begin{gather*}
    x = 1 \\
    y = 0 \\
    z = 1
\end{gather*}

Spacing after a period

If you use “english spacing”, that is more spacing between sentences, you have to be careful when using a full stop (“.”) within the sentence. The space behind that has to be marked as an inter-sentence-space with \@ like so:

This is a period.\@ within a sentence. That was not.

Too large parentheses, spacing

With the commath package, you get a simple \del command which will create \left( and \right) for you. It is tempting to use this for things like \del x where you try to get (x). However, there will be too much space in front of the ( when you do this that way:

f(x) \quad f \left( x \right)

The first is f(x), the latter is f \left( x \right).

So just use \left( or \del if you need bigger parentheses.