Sums and products in LaTeX (sum, prod)
\sum draws the summation sign and \prod the product sign. The limits follow with _ and ^, as in \sum_{i=1}^{n} a_i.
Preamble
The snippets on this page need these lines before \begin{document}:
\usepackage{amsmath}Sum and product with limits
The lower limit follows _ and the upper limit follows ^, each in braces. In a display formula LaTeX sets them below and above the sign.
\[
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
\qquad
\prod_{k=1}^{n} k = n!
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Limits in a line of text
In a line of text LaTeX moves the limits to the right of the sign to keep the line height. \limits after the sign forces them below and above, \nolimits forces them to the side.
Beside the sign: $\sum_{i=1}^{n} a_i$,
below and above: $\sum\limits_{i=1}^{n} a_i$.Several conditions below the sign
\substack from amsmath stacks several lines in a limit. \\ separates the lines, and each line is centred.
\[
\sum_{\substack{0 \le i \le m \\ 0 < j < n}} P(i,j)
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Union, intersection and other large operators
\bigcup, \bigcap, \bigoplus, \bigotimes and \coprod take limits in the same way as \sum.
\[
\bigcup_{i=1}^{n} A_i
\qquad
\bigcap_{i \in I} B_i
\qquad
\bigoplus_{k=1}^{m} V_k
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Pitfalls
- Do not use the Greek letters
\Sigmaand\Pias operators. They are ordinary letters: smaller than\sumand\prod, and their limits always end up at the side. \limitsafter a symbol that is not an operator stops with Limit controls must follow a math operator.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Package
amsmath - How-to Limits in LaTeX
- How-to Integrals in LaTeX
- How-to Inline and display math in LaTeX
- Error Limit controls must follow a math operator