Sums, integrals, and limits
Write sums, products, integrals, and limits with their bounds, and decide whether the bounds go above and below the symbol or beside it.
Sums and products
\sum and \prod take their bounds as a subscript and a superscript. In a display the bounds are set below and above the symbol. Inline they move to the side, so that the line keeps its height.
\[
\sum_{k=1}^{n} k = \frac{n(n+1)}{2}
\qquad
\prod_{k=1}^{n} k = n!
\]
Inline, the same sum is $\sum_{k=1}^{n} k$.The other large operators behave the same way, among them \bigcup, \bigcap, \bigoplus, and \coprod.
Integrals
\int takes bounds in the same way, but keeps them beside the symbol even in a display. For multiple integrals use \iint and \iiint, which set the signs closer together than repeated \int would. \oint is the contour integral.
\[
\int_0^\infty e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2}
\qquad
\iint_D f(x, y) \, dx \, dy
\qquad
\oint_C \mathbf{F} \cdot d\mathbf{r}
\]Differentials
TeX reads dx as the product of d and x and sets it tight against the integrand. Add a thin space, \,, before each differential.
Some styles, including the ISO standard, set the d upright. If you want that, define a command once so that every differential in the document agrees. The one below also supplies the thin space itself.
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\[
\int_a^b f(x) dx
\qquad
\int_a^b f(x) \, dx
\qquad
\int_a^b f(x) \diff x
\]In a real document the \newcommand line belongs in the preamble. See Custom commands.
Limits
\lim takes what the variable tends to as a subscript. \max, \min, \sup, \inf, \limsup, and \liminf work the same way.
\[
\lim_{x \to 0} \frac{\sin x}{x} = 1
\qquad
\lim_{n \to \infty} \left( 1 + \frac{1}{n} \right)^{n} = e
\qquad
\max_{0 \leq x \leq 1} x(1 - x) = \frac{1}{4}
\]Moving the bounds
Put \limits straight after the operator to force the bounds above and below, or \nolimits to force them beside it. The choice applies to that one operator.
Forced above and below in text: $\sum\limits_{k=1}^{n} k$.
\[
\int\limits_0^1 x \, dx
\qquad
\sum\nolimits_{k=1}^{n} k
\]\limits inline pushes the lines of the paragraph apart, so use it rarely. If an inline formula needs that much room, display it instead.
Conditions on several lines
When the condition under a sum is long, stack it with \substack. Lines are separated by \\ and centered.
\[
\sum_{\substack{1 \leq i \leq n \\ i \neq j}} a_{ij}
\qquad
\prod_{\substack{p \leq x \\ p \text{ prime}}}
\left( 1 - \frac{1}{p} \right)
\]In TeXeR, press Shift + Space and open the Math group: Sum, Integral, and Limit each insert the operator with its bounds ready to edit.
Common mistakes
- Bounds without braces.
\sum_i=1^nattaches onlyiand1to the sum. Write\sum_{i=1}^{n}. - Operator names without a backslash.
lim,max, andsintyped as letters come out italic, as a product of variables, and cannot take a bound underneath. Use\lim,\max, and\sin. \limitsafter something that is not an operator.x\limits_astops withLimit controls must follow a math operator. To put text under an ordinary symbol, use\underset, or declare an operator as described in Math fonts.\int\intfor a double integral. The two signs stand too far apart. Use\iint.