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.

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

Open this formula in the editor

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$.
Result
The compiled example

Open in the editor

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.

∑0≤i≤m0<j<nP(i,j)\sum_{\substack{0 \le i \le m \\ 0 < j < n}} P(i,j)

Open this formula in the editor

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.

⋃i=1nAi⋂i∈IBi⨁k=1mVk\bigcup_{i=1}^{n} A_i \qquad \bigcap_{i \in I} B_i \qquad \bigoplus_{k=1}^{m} V_k

Open this formula in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages