LaTeX Cookbook

Inline and Displayed Formulas

$x=\frac{1+y}{1+2z^2}$
(inline)
$$x=\frac{1+y}{1+2z^2}$$
(displayed)
$\int_0^\infty e^{-x^2} dx=\frac{\sqrt{\pi}}{2}$
(inline)
$$\int_0^\infty e^{-x^2} dx=\frac{\sqrt{\pi}}{2}$$
(displayed)
$\displaystyle \int_0^\infty e^{-x^2} dx$
(inline)
$$
 \frac{1}{\displaystyle 1+
   \frac{1}{\displaystyle 2+
   \frac{1}{\displaystyle 3+x}}} +
 \frac{1}{1+\frac{1}{2+\frac{1}{3+x}}}
$$

Spaces and Text in Formulas

$\sqrt{2} \sin x$, $\sqrt{2}\,\sin x$
$\int \!\! \int f(x,y)\,\mathrm{d}x\mathrm{d}y$
$$
 \mathop{\int \!\!\! \int}_{\mathbf{x} \in \mathbf{R}^2} 
 \! \langle \mathbf{x},\mathbf{y}\rangle 
 \,d\mathbf{x}
$$
$$ x_1 = a+b \mbox{ and } x_2=a-b $$
$$ x_1 = a+b ~~\mbox{and}~~ x_2=a-b $$

Multiple Line Equations

\begin{eqnarray}
 y &=& x^4 + 4      \nonumber \\
   &=& (x^2+2)^2 -4x^2 \nonumber \\
   &\le&(x^2+2)^2
\end{eqnarray}
\begin{eqnarray*}
 e^x &\approx& 1+x+x^2/2! + \\
   && {}+x^3/3! + x^4/4! + \\
   && + x^5/5!
\end{eqnarray*}
\begin{eqnarray*}
 \lefteqn{w+x+y+z = }\\
   && a+b+c+d+e+\\
   && {}+f+g+h+i
\end{eqnarray*}
\begin{eqnarray*}
 x&=&\sin \alpha = \cos \beta\\
  &=&\cos(\pi-\alpha) = \sin(\pi-\beta)
\end{eqnarray*}
{\setlength\arraycolsep{0.1em}
 \begin{eqnarray*}
  x&=&\sin \alpha = \cos \beta\\
   &=&\cos(\pi-\alpha) = \sin(\pi-\beta)
 \end{eqnarray*}
}
$$\setlength\arraycolsep{0.1em}
 \begin{array}{rclcl}
  x&=&\sin \alpha &=& \cos \beta\\
   &=&\cos(\pi-\alpha) &=& \sin(\pi-\beta)
 \end{array}
$$

Formula Numbering

\begin{equation} x=y+3 \label{eq:xdef}
\end{equation}
In equation (\ref{eq:xdef}) we saw $\dots$
\usepackage{leqno}
...
\begin{equation} x=y+3 \label{eq:xdef}
\end{equation}
In equation (\ref{eq:xdef}) we saw $\dots$
\begin{equation}
\begin{array}{l}
\displaystyle \int 1 = x + C\\
\displaystyle \int x = \frac{x^2}{2} + C \\
\displaystyle \int x^2 = \frac{x^3}{3} + C
\end{array} 
\label{eq:xdef}
\end{equation}
\begin{eqnarray}
&& \int 1 = x + C \nonumber\\
&& \int x = \frac{x^2}{2} + C \nonumber\\
&& \int x^2 = \frac{x^3}{3} + C \label{eq:xdef}
\end{eqnarray}

Braces

$\left] 0,1
\right[
 + \lceil x \rfloor - \langle x,y\rangle$
$$
{n+1\choose k} = {n\choose k} + {n \choose k-1}
$$
$$
|x| = \left\{ \begin{array}{rl}
 -x &\mbox{ if $x<0$} \\
  x &\mbox{ otherwise}
       \end{array} \right.
$$
$$
F(x,y)=0 ~~\mbox{and}~~
\left| \begin{array}{ccc}
  F''_{xx} & F''_{xy} &  F'_x \\
  F''_{yx} & F''_{yy} &  F'_y \\
  F'_x     & F'_y     & 0 
  \end{array}\right| = 0
$$
$$
\underbrace{n(n-1)(n-2)\dots(n-m+1)}_
{\mbox{total of $m$ factors}}
$$

Accents

Accents in text mode:
gar\c con \'\i{} i
t\`o\'s\.g\^o na\"\i ve na\"ive
Ha\v cek 
\r Angstr\"om
Accents in math mode:
$\hat{x}$, $\check{x}$, $\tilde{a}$, 
$\bar{\ell}$, $\dot{y}$, $\ddot{y}$, 
$\vec{z_1}$, $\vec{z}_1$
Wide accents, under and overline:
$\hat{T} = \widehat{T}$,
$\bar{T} = \overline{T}$, $\widetilde{xyz}$,
$\overbrace{a+\underbrace{b+c}+d}$
$$
 \overline{\overline{a}^2+\underline{xy}
 +\overline{\overline{z}}}
$$
Sub and superscripts to braces:
$$
\underbrace{a+\overbrace{b+\cdots}^{{}=t}+z}
_{\mathrm{total}} ~~
a+{\overbrace{b+\cdots}}^{126}+z
$$