# LaTeX Mathematics

There are many fine points to mathematical typesetting that are easy to overlook when we simply read math books. A partial list and discussion follows.

- Math Mode: As noted in other pages on this site, mathematics typesetting
uses a special "math italic" font, and a different spacing
from ordinary text. Thus, whenever we need to type any mathematical
symbol, we must go into "math mode". In a line this is done
by surrounding our mathematical text with dollar signs: vis.
`$x$`, or alternatively using a begin and end symbol:`\(x\)`. If we want to display the expression (make it centered, on its own line, with extra space around it, and a more expansive format), we must use a display math environment.

\begin{displaymath} f(x) = x^2+2 \end{displaymath}

or

$$f(x) = x^2+2$$.

- Equation environment: To have your equations numbered automatically
as well as set in a display mode, use the equation environment.

\begin{equation} f(x) = x^2+2 \end{equation}

- Large fenced items: Frequently we want to enclose large expressions
or matrices in parentheses or braces. For this we use the \left and
\right commands. For example, here is a set.

`$S = \left\{ 1, 2, \left( \frac{2}{3} \right) \right\}$`. - More than one equation in display mode: Frequently we must align equations,
or force expressions onto more than one line. The environment for this
is "eqnarray".

\begin{eqnarray} f(x) &=& (x-1)(x+1)\\

We should note several things here

\nonumber &=& x^2-1 \end{eqnarray}

- Think of the alignment as a table with three columns. The ampersand characters (&) separate the columns.
- We make a new line with the double-backslash. Thus, we should not put a double-backslash on the last line. The expression above has two lines - if we ended the second with a double-backslash, it would have three lines.
- Every line gets an equation number. If we do not want a separate
equation number for a line, we should put the command
`\nonumber`on that line.

- The amsmath package provides a number of environments to do alignments.
These are more specific than
"eqnarray", but they are superior in appearance. In particular
the "align" environment provides a better way to align
operators for a collection of equations.

\begin{align} f(x) &= (x-1)(x+1)\\

\nonumber &= x^2-1 \end{align}- This time the alignment only has two columns. The ampersand character (&) separates the columns.
- Every line gets an equation number. If we do not want any
equation numbers for a line, we should use the "align*"
environment. That suppresses all equation numbers. The
`\nonumber`macro works here as well.

- A matrix is another kind of alignment. There are several ways to do this.
The LaTeX way is to use the "array" environment. This does not put
in parentheses or brackets - they must be inserted using
`\left`and`\right`. Alternatively, if using the amsmath package, there are "pmatrix" and "bmatrix" environments, the first for a matrix encompassed by parentheses, the second for one encompassed by brackets. The columns of the matrix are again separated by ampersands; rows of the matrix are ended by double backslashes.\begin{pmatrix} 1 & 2\\ 0 & 4 \end{pmatrix}

- Special Functions: It is traditional to distinguish special functions
from multiplied symbols by typesetting them in a standard font. For
example, we want sin(
*x*) to look different from*s i n (x)*; i.e.*s*times*i*times*n*times (*x*). LaTeX provides special commands for this, usually preceding the special function name by a backslash. For example, we may use \sin, \exp, and \log

- Negative space: Sometimes we want to emphasize that two letters are
not symbols being multiplied, or we want to have one symbol overlap
another. LaTeX provides negative space for this. The negative thin space
command is \!. For example we might make an antiderivative as
`$\int x t d\!t$`; the x and t are multiplied, but d and t form a single math italic symbol.

A solution for the
final is available.