Math formulas

Produce mathematical text by putting LaTeX into math mode or display math mode (see Modes). This example shows both.

The wave equation for \( u \) is
\begin{displaymath}
  \frac{\partial^2u}{\partial t^2} = c^2\nabla^2u
\end{displaymath}
where \( \nabla^2 \) is the spatial Laplacian and \( c \) is constant.

Math mode is for inline mathematics. In the above example it is invoked by the starting \( and finished by the matching ending \). Display math mode is for displayed equations and here is invoked by the displaymath environment. Note that any mathematical text whatever, including mathematical text consisting of just one character, is handled in math mode.

When in math mode or display math mode, LaTeX handles many aspects of your input text differently than in other text modes. For example,

contrast x+y with \( x+y \)

in math mode the letters are in italics and the spacing around the plus sign is different.

There are three ways to make inline formulas, to put LaTeX in math mode.

\( mathematical material \)
$ mathematical material $
\begin{math} mathematical material \end{math}

The first form is preferred and the second is quite common, but the third form is rarely used. You can sometimes use one and sometimes another, as in \(x\) and $y$. You can use these in paragraph mode or in LR mode (see Modes).

To make displayed formulas, put LaTeX into display math mode with either:

\begin{displaymath}
  mathematical material
\end{displaymath}

or

\begin{equation}
  mathematical material
\end{equation}

(see displaymath, see equation). The only difference is that with the equation environment, LaTeX puts a formula number alongside the formula. The construct \[ math \] is equivalent to \begin{displaymath} math \end{displaymath}. These environments can only be used in paragraph mode (see Modes).

The two mathematics modes are similar, but there are some differences. One involves the placement of subscripts and superscripts; in display math mode they are further apart and in inline math mode they are closer together.

Sometimes you want the display math typographical treatment to happen in the inline math mode. For this, the \displaystyle declaration forces the size and style of the formula to be that of displaymath. Thus \(\displaystyle \sum_{n=0}^\infty x_n\) will have the limits above and below the summation sign, not next to it. Another example is that

\begin{tabular}{r|cc}
  \textsc{Name}  &\textsc{Series}  &\textsc{Sum}  \\  \hline
  Arithmetic     &\( a+(a+b)+(a+2b)+\cdots+(a+(n-1)b) \)
                   &\( na+(n-1)n\cdot\frac{b}{2}\)  \\
  Geometric      &\( a+ab+ab^2+\cdots+ab^{n-1} \)
                   &\(\displaystyle a\cdot\frac{1-b^n}{1-b}\)  \\
\end{tabular}

because it has no \displaystyle, the ‘Arithmetic’ line’s fraction will be scrunched. But, because of its \displaystyle, the ‘Geometric’ line’s fraction will be easy to read, with characters the same size as in the rest of the line.

The American Mathematical Society has made freely available a set of packages that greatly expand your options for writing mathematics, amsmath and amssymb (also be aware of the mathtools package that is an extension to, and loads, amsmath). New documents that will have mathematical text should use these packages. Descriptions of these packages is outside the scope of this document; see their documentation on CTAN.

© 2007–2018 Karl Berry
Public Domain Software
http://latexref.xyz/Math-formulas.html