All documentation

Fractions, sums, integrals and limits in LaTeX

The formulas written most often in LaTeX — a fraction, a power, a root, a sum, an integral, a limit, a derivative — each with the source to copy. Every example below is an ordinary formula: in Texifine, type it in an Equation block, or between dollar signs inside a sentence.

Fractions

\frac takes the numerator, then the denominator, each in braces:

\frac{a}{b} \qquad \frac{x + 1}{x - 1} \qquad \frac{1}{1 + \frac{1}{x}}

A binomial coefficient is written the same way, with \binom:

\binom{n}{k} = \frac{n!}{k!\,(n-k)!}

Inside a sentence a fraction is set smaller, to fit the line. \dfrac forces the full size there, and \tfrac forces the small one in a formula on its own line.

Powers and indices

^ raises, _ lowers. Without braces they apply to one character: anything longer goes in braces.

x^2 \qquad x_i \qquad x^{2n} \qquad a_{ij} \qquad x_i^2 \qquad e^{-x^2}

Writing x^2n prints x² followed by n — the most common slip in a first formula.

Roots

\sqrt{x} \qquad \sqrt{x^2 + y^2} \qquad \sqrt[3]{x}

The optional argument in square brackets is the index of the root.

Sums and products

The bounds are an index and a power on the symbol:

\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
\qquad
\prod_{k=1}^{n} k = n!

Integrals

\int_0^1 x^2 \,dx = \frac{1}{3}
\qquad
\int_{-\infty}^{+\infty} e^{-x^2} \,dx = \sqrt{\pi}

\, adds the thin space that separates the function from dx. For multiple and contour integrals:

\iint_D f(x,y) \,dx\,dy \qquad \oint_C \mathbf{F} \cdot d\mathbf{r}

Limits

\lim_{x \to 0} \frac{\sin x}{x} = 1
\qquad
\lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n = e

\to is the arrow, \infty the infinity sign. Function names — \sin, \cos, \tan, \log, \ln, \exp, \max, \min — are commands: written without the backslash, they are printed in italics as a product of letters.

Derivatives

f'(x) \qquad \frac{df}{dx} \qquad \frac{\partial f}{\partial x} \qquad \frac{\partial^2 f}{\partial x^2}

Brackets that grow

Ordinary parentheses keep the height of a line. \left( and \right) take the height of what they enclose; they work with [ ], \{ \} and | too, and always come as a pair.

\left( \frac{a}{b} \right)^2 \qquad \left[ \sum_{i=1}^{n} x_i \right] \qquad \left| \frac{x}{y} \right|

On its own line or inside a sentence

LaTeX sets the same source in two ways. On its own line, the bounds of a sum go above and below the symbol and fractions are full size. Inside a sentence, bounds move to the side and everything is made smaller, so that the line keeps its height.

In Texifine:

  • an Equation block is the formula on its own line, centred and numbered;
  • a formula inside a sentence is typed between dollar signs — $\frac{a}{b}$ — or started with Ctrl+M. See Writing text.

To give a formula inside a sentence the look it has on its own line, start it with \displaystyle. The lines around it move apart to make room.

Words inside a formula

Letters in a formula are variables, set in italics without spaces. For words, use \text{…}:

P(A \mid B) = \frac{P(A \cap B)}{P(B)} \quad \text{if } P(B) > 0

Without typing the commands

In the editor, the Symbols tab of the left column writes a command at the caret, complete with its empty braces: \frac{}{}, \sqrt{}, \sum_{}^{}. The caret waits in the first pair, and Tab moves to the next one. The same list, with each command, is on the Symbols page.

See also