# The Not So Short Introduction to LaTeX 2

Chapter 1 - Things You Need to Know
\documentclass{article}
\begin{document}
Small is beautiful.
\end{document}

latex foo.tex
dvipdf foo.dvi
Chapter 2 - Typesetting Text
break a line: \\ or \newline
start a new line without starting a new paragraph \\*
\newpage
\linebreak[n], \nolinebreak[n], \pagebreak[n], \nopagebreak[n]

For the article class:
\section{}
\subsection{}
\subsubsection{}
\paragraph{}
\subparagraph{}
\part{}
\chapter{}
\tableofcontents{}
\footnote{footnote text}
Chapter 3 - Typesetting Mathematical Formulae

3.1 The AMS-LATEX bundle
If you want to typeset (advanced) mathematics, you should use AMS-LATEX.  The AMS-LATEX bundle is a collection of packages and classes for mathematical typesetting.  AMS-LATEX is produced by The American Mathematical Society and it is used extensively for mathematical typesetting.  LATEX itself does provide some basic features and environments for mathematics, but they are limited and in some cases inconsistent.

AMS-LATEX is a part of the required distribution and is provided with all recent LATEX distributions.  We assume amsmath is loaded in the preamble; \usepackage{amsmath}.

3.2 Single Equations
A mathematical formula can be typeset in-line within a paragraph (text style), or the paragraph can be broken and the formula typeset separately (display style).  Mathematical equations within a paragraph are entered between $and$.
$$a^2 + b^2 = c^2$$
$$\lim_{x \to 2} f(x) = 5$$
$$\lim_{n \to \infty} \sum_{k=1}^n \frac{1}{k^2} = \frac{\pi^2}{6}$$

If you want to name the equation something specific, you \tag it instead.

3.2.1 Math Mode
There are also differences between math mode and text mode.  For example, in math mode:
1. Most spaces and line breaks to not have any significance, as all spaces are either derived logically from the mathematical expressions, or have to be specified with special commands such as \, \quad or \qquad
2. Empty lines are not allowed.  Only one paragraph per formula.
3. Each letter is considered to be the name of a variable and will be typeset as such.

$$\forall x \in \mathbf{R}: \qquad x^{2} \geq 0$$
$$x^{2} \geq 0\qquad \text{for all }x\in\mathbf{R}$$

3.3 Building Blocks of a Mathematical Formula
Most of the commands in this section will not require amsmath, but load it anyways.

Lowercase Greek Letters are entered as \alpha, \beta, \gamma, and uppercase letters are entered as \Gamma, \Delta, ...
$$\lambda, \xi, \pi, \theta, \mu, \Phi, \Omega, \Delta$$

Exponents, Superscripts, and Subscripts can be specified using the ^ and _ characters.  Most math mode commands act only on the next character, so if you want a command to affect several characters, you have to group them together using curly braces: {...}.
$$p^3_{ij}$$
$$m_\text{Knuth}$$
$$\sum_{k=1}^3 k$$
$$a^x+y \neq a^{x+y}$$
$$e^{x^2}$$
$${e^x}^2$$

The square root is entered as \sqrt; the nth root is generated with \sqrt[n].  The size of the root sign is determined automatically by LaTeX.
$$\sqrt{x} \Leftrightarrow x^{1/2}$$
$$\sqrt[3]{2}$$
$$\sqrt{x^{2} + \sqrt{y}}$$
$$\surd[x^2 + y^2]$$

The dot sign to indicate the multiplication operation is normally left out, it is sometimes written tho help the eye in grouping a formula.  Use \cdot to typeset a single centered dot.  \cdots is three centered dots while \ldots sets the dots low (on the baseline).  Besides that, there are \vdots for vertical and \ddots for diagonal dots.
$$\Psi = v_1 \cdot v_2 \cdot \ldots$$
$$n! = 1 \cdot 2 \cdots (n-1) \cdot n$$

The commands \overline and \underline create horizontal lines directly over or under an expression.
$$0.\overline{3}$$

The commands \overbrace and \underbrace create long horizontal braces over or under an expression.
no \overbrace{a+b+c}
no \underbrace{a+b+c}

To add mathematical accents such as small arrows or tilde signs to variables, wide hats and tildes covering several characters are generated with \widetilde and \widehat.
The apostrophe mark ' gives a prime.
$$f(x) = x^2$$
$$f'(x) = 2x$$
$$f''(x) = 2$$
$$\hat{xy}$$
no \widehat{XY}
$$\bar{x_0}$$
$$\bar{x}_0$$

Vectors are often specified by adding small arrow symbols on the tops of variables.  This is done with the \vec command.  The two commands \overrightarrow and \overleftarrow are useful to denote the vector from A to B.
$$\vec{a}$$
$$\vec{AB}$$
no \overrightarrow{AB}
$$\lim_{X \rightarrow 0} \frac{\sin x}{x}=1$$
no \DeclareMathOperator
no a\bmod b
no x\equiv a \pmod{b}

A built-up fraction is typeset with the \frac{...}{...} command.
$$3/8$$
$$\frac{3}{8}$$
$$\tfrac{3}{8}$$
In text style: $$1\frac{1}{2}$$
$$1\dfrac{1}{2}$$ hours

\partial command for partial derivatives is used.
$$\sqrt{\frac{x^2}{k+1}}$$
$$x^\frac{2}{k+1}$$
$$\frac{\partial^2f} {\partial x^2}$$

To typeset binomial coefficients or similar structures, use the command \binom from amsmath.
$$\binom{n}{k} = \binom{n-1}{k} + \binom{n-1}{k-1}$$
no f_n(x) \stackrel{*}{\approx} 1

The integral operator is generated with \int, the sum operator with \sum, and the product operator with \prod.  The upper and lower limits are specified with ^ and _ like subscripts and superscripts.
$$\sum_{i=1}^n$$
$$\int_0^{\frac{\pi}{2}}$$
$$\prod_\epsilon$$

LaTeX provides all sorts of symbols for bracketing and other delimiters.
$${a,b,c} \neq \{a,b,c\}$$

If you put \left in front of an opening delimiter and \right in front of a closing delimiter, LaTeX will automatically determine the correct size of the delimiter.
$$1 + \left(\frac{1}{1-x^{2}} \right)^3$$

3.4 Single Equations that are Too Long: multline
If an equation is too long, we have to wrap it somehow.  Unfortunately, wrapped equations are usually less easy to read than not wrapped ones.  To improve the readability, there are certain rules on how to do the wrapping:
1. In general one should always wrap an equation before an equality sign or an operator.
2. A wrap before an equality sign is preferable to a wrap before any operator.
3. A wrap before a plus- or minus-operator is preferable to a wrap before a multiplication-operator.
4. Any other type of wrap should be avoided if at all possible.
problems with multline

3.5 Multiple Equations

no \begin{align}
no \begin{eqnarray}

3.5.2 IEEEeqnarray Environment
The IEEEeqnarray environment is a very powerful command with many options.  First of all, in order to be able to use the IEEEeqnarray environment one needs to load the package IEEEtrantools.  The strength of IEEEeqnarray is the ability to specify the number of columns in the equation array.

3.5.3 Common Usage

3.6 Arrays and Matrices
To typeset arrays, use the array environment.  It works somewhat similar to the tabular environment.  The \\ command is used to break the line.

3.7 Spacing in Math Mode
If the spacing within formulae chosen by LaTeX is not satisfactory, it can be adjusted by inserting special commands.
$$\int_1^2 \ln x \mathrm{d}x$$
$$\int_1^2 \ln x \,\mathrm{d}x$$

3.7.1 Phantoms
When vertically aligned text using ^ and _ LaTeX is sometimes just a little too helpful.  Using the \phantom command you can reserve space for characters that do not show up in the final output.
$${}^{14}_{6}\text{C}$$ vs. $${}^{14}_{\phantom{1}6}\text{C}$$

3.8 Fiddling with the Math Fonts
Changing styles generally affects the way big operators and limits are displayed.

3.8.1 Bold Symbols
It is quite difficult to get bold symbols in LaTeX; this is probably intentional as amateur typesetters tend to overuse them.  The font change command \mathbf gives bold letters, but these are roman (upright) whereas mathematical symbols are normally italic, and furthermore it doesn't work on lower case Greek letters.  There is a \boldmath command, but this can only be used outside math mode.

\mu, M $$\mu, M$$
\mathbf{\mu}, \mathbf{M} $$\mathbf{\mu}, \mathbf{M}$$
no \boldmath{\$\mu, M}

3.9 Theorems, Lemmas,...
When writing mathematical documents, you probably need a way to typeset "Lemmas", "Definitions", Axioms" and similar structures.
\newtheorem{name}[counter]{text}[section]
The name argument is a short keyword used to identify the "theorem".  With the text argument you define the actual name of the "theorem", which will be printed in the final document.  The arguments in square brackets are optional.  They are both used to specify the numbering used on the "theorem".  Use the counter argument to specify the name of a previously declared "theorem".  The new "theorem" will then be numbered in the same sequence.  The section argument allows you to specify the sectional unit within which the "theorem" should get its numbers.

3.9.1 Proofs and End-of-Proof Symbol
The amsthm package also provides the proof environment.

3.10 List of Mathematical Symbols
An even more comprehensive list of symbols can be found at CTAN:info/symbols/comprehensive