Summation in LaTeX

Write a sum with \sum in math mode, the lower limit after _ and the upper limit after ^: \sum_{i=1}^{n} x_i. In a displayed equation the limits sit above and below the sigma; inside a line of text they move to the side to keep the line short.

Summation commands

  • \sum_{i=1}^{n} a_i
    ∑ i = 1 n a i

    Sum from i = 1 to n.

  • \sum_{n=0}^{\infty} a_n
    ∑ n = 0 ∞ a n

    Infinite series.

  • \sum_{i \in S} x_i
    ∑ i ∈ S x i

    Sum over the elements of a set.

  • \sum\limits_{i=1}^{n}
    ∑ i = 1 n

    Forces the limits above and below, even inline.

  • \sum\nolimits_{i=1}^{n}
    ∑ i = 1 n

    Forces the limits to the side, even in a display.

  • \displaystyle\sum_{i=1}^{n}
    ∑ i = 1 n

    Full display size inside a line of text.

  • \sum_{\substack{0 \le i \le m \\ 0 < j < n}}
    ∑ 0 ≤ i ≤ m 0 < j < n

    Two-line condition under the sigma (amsmath).

  • \prod_{i=1}^{n} a_i
    ∏ i = 1 n a i

    Product; takes limits the same way.

  • \Sigma
    Σ

    The Greek capital letter only, not the summation operator.

Try it live

Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.

Templates

Summation examples

Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.

  • Sum of the first n integers

    ∑ k = 1 n k = n ( n + 1 ) 2
    LaTeX
    \sum_{k=1}^{n} k = \frac{n(n+1)}{2}
  • Geometric series

    ∑ n = 0 ∞ r n = 1 1 − r , | r | < 1
    LaTeX
    \sum_{n=0}^{\infty} r^n = \frac{1}{1-r}, \quad |r| < 1
  • Basel problem

    ∑ n = 1 ∞ 1 n 2 = π 2 6
    LaTeX
    \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}
  • Mean

    x ¯ = 1 n ∑ i = 1 n x i
    LaTeX
    \bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i
  • Double sum

    ∑ i = 1 m ∑ j = 1 n a i j
    LaTeX
    \sum_{i=1}^{m} \sum_{j=1}^{n} a_{ij}
  • Two-line condition

    ∑ 1 ≤ i ≤ n i  odd i 2
    LaTeX
    \sum_{\substack{1 \le i \le n \\ i \text{ odd}}} i^2

    \substack stacks conditions with \\ between them.

  • Binomial theorem

    ( x + y ) n = ∑ k = 0 n ( n k ) x n − k y k
    LaTeX
    (x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^{k}
  • Inline sum with limits below

    ∑ i = 1 n x i
    LaTeX
    \textstyle \sum\limits_{i=1}^{n} x_i

    How a sum in running text looks with \limits: small sigma, limits above and below.

Inline or displayed: where the limits go

In \[ … \] or an equation environment, \sum_{i=1}^{n} puts the limits above and below a large sigma. Written between $ … $ inside a paragraph, the same code gives a smaller sigma with the limits to its right, so the line spacing stays even.

To change one sum, add \limits (limits above and below) or \nolimits (limits beside) right after \sum. \displaystyle in front makes an inline sum display size, which also stretches the line, so use it sparingly.

Sums, products and sigma

\sum is a large operator that grows in displays and takes limits. \Sigma is just the capital letter and stays letter-sized, so it is the wrong choice for a sum. Products use \prod, coproducts \coprod, and unions and intersections over an index use \bigcup and \bigcap with the same limit syntax.

LaTeX
\[
  \sum_{i=1}^{n} x_i \qquad \prod_{i=1}^{n} x_i \qquad \bigcup_{i=1}^{n} A_i
\]

Common mistakes

  • \Sigma is the Greek letter: it does not grow and its limits stay as small scripts.

    Instead of
    \Sigma_{i=1}^{n} x_i
    Write
    \sum_{i=1}^{n} x_i
  • Without braces only i is the subscript and =1 is ordinary text after it.

    Instead of
    \sum_i=1^n x_i
    Write
    \sum_{i=1}^{n} x_i
  • A line break is only allowed inside \substack (amsmath); on its own it causes an error.

    Instead of
    \sum_{i=1 \\ j=1}
    Write
    \sum_{\substack{i=1 \\ j=1}}

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    \sum, \prod, \limits and \displaystyle work in any document; \substack and \binom need \usepackage{amsmath}. The amsmath option nosumlimits moves display limits to the side for the whole document.

  • MathJax and KaTeX

    MathJax and KaTeX follow the same inline and display rules, so $…$ in Markdown gives side limits and $$…$$ gives limits above and below. \substack and \limits are supported.

  • Microsoft Word

    Word has a summation template of its own, but pasted LaTeX is not converted reliably. Build the sum here and use Copy for Word to paste it as an editable Word equation.

Summation in LaTeX: questions

How do I write sigma notation in LaTeX?
Use \sum with limits: \sum_{i=1}^{n} a_i. The command draws the large sigma and places the limits for you.
Why are my sum limits next to the sigma instead of above and below?
The sum is inline (between $ … $). Put it in a displayed equation, or write \sum\limits_{i=1}^{n} to force the limits above and below in that one place.
How do I write a sum to infinity?
Use \infty as the upper limit: \sum_{n=1}^{\infty} \frac{1}{n^2}.
How do I put two conditions under a sum?
Use \substack from amsmath: \sum_{\substack{i < j \\ i, j \in S}} stacks the conditions on two lines.

Have the formula as a picture?

Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.

Convert an image to LaTeX