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_iSum from i = 1 to n.
\sum_{n=0}^{\infty} a_nInfinite series.
\sum_{i \in S} x_iSum over the elements of a set.
\sum\limits_{i=1}^{n}Forces the limits above and below, even inline.
\sum\nolimits_{i=1}^{n}Forces the limits to the side, even in a display.
\displaystyle\sum_{i=1}^{n}Full display size inside a line of text.
\sum_{\substack{0 \le i \le m \\ 0 < j < n}}Two-line condition under the sigma (amsmath).
\prod_{i=1}^{n} a_iProduct; takes limits the same way.
\SigmaThe 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.
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
LaTeX\sum_{k=1}^{n} k = \frac{n(n+1)}{2}Geometric series
LaTeX\sum_{n=0}^{\infty} r^n = \frac{1}{1-r}, \quad |r| < 1Basel problem
LaTeX\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}Mean
LaTeX\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_iDouble sum
LaTeX\sum_{i=1}^{m} \sum_{j=1}^{n} a_{ij}Two-line condition
LaTeX\sum_{\substack{1 \le i \le n \\ i \text{ odd}}} i^2\substackstacks conditions with\\between them.Binomial theorem
LaTeX(x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^{k}Inline sum with limits below
LaTeX\textstyle \sum\limits_{i=1}^{n} x_iHow 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.
\[
\sum_{i=1}^{n} x_i \qquad \prod_{i=1}^{n} x_i \qquad \bigcup_{i=1}^{n} A_i
\]Common mistakes
\Sigmais the Greek letter: it does not grow and its limits stay as small scripts.Instead of\Sigma_{i=1}^{n} x_iWrite\sum_{i=1}^{n} x_iWithout braces only
iis the subscript and=1is ordinary text after it.Instead of\sum_i=1^n x_iWrite\sum_{i=1}^{n} x_iA 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,\limitsand\displaystylework in any document;\substackand\binomneed\usepackage{amsmath}. The amsmath optionnosumlimitsmoves 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.\substackand\limitsare 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
\sumwith 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
\inftyas the upper limit:\sum_{n=1}^{\infty} \frac{1}{n^2}. - How do I put two conditions under a sum?
- Use
\substackfrom amsmath:\sum_{\substack{i < j \\ i, j \in S}}stacks the conditions on two lines.
Related LaTeX reference
- Integral in LaTeX\int with lower and upper limits, \iint and \iiint, contour integrals, evaluation bars and the thin space before dx.
- Limit in LaTeX\lim_{x \to a}, one-sided limits, limits at infinity, limsup and liminf, and how to keep the condition under lim in running text.
- Greek Letters in LaTeXEvery lowercase and uppercase Greek letter with its command, the var- forms, and bold or upright Greek.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
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