Subscripts and Superscripts in LaTeX

The _ and ^ characters, the brace rule that causes most errors, stacking both on one symbol, and limits written on big operators.

Subscripts use _, superscripts use ^. Both take exactly one token unless you give them braces — and that single-token rule is responsible for almost every mis-rendered formula people paste into a converter. Once the index is understood as a group rather than a character, everything else on this page follows: stacking both marks, nesting one index inside another, and the bounds on a big operator. Summation applies the same rule to sigma, Limits to lim, and Align to whole lines.

Which one to use

Situation Write this Because
A one-character index
x^2, a_i
Braces optional: there is nothing to group.
A multi-character index
x^{10}, a_{ij}
Without braces only the first token is consumed.
Both at the same symbol
x_i^2
Order does not matter; they stack.
Bounds on a big operator
\sum_{i=1}^{n}
Placement follows display vs inline maths.
An index on an index
x_{i_j}
Each level needs its own braces.
A derivative prime
f'(x), f''(x)
A superscript with its own spacing — see derivatives.

The commands

What Type this Renders as
Single subscript One character, so no braces needed.
a_1
a_1
Multi-character subscript Without the braces this prints a₁2 — only the 1 is subscripted.
a_{12}
a_{12}
Superscript Exponents always need braces once they are more than a single symbol.
x^{2n+1}
x^{2n+1}
Both at once Order does not matter; they stack on the same symbol either way.
x_i^2
x_i^2
Nested A superscript inside a superscript. Braces are what make this parse at all.
e^{-x^2}
e^{-x^2}
Sub-subscript Rare and hard to read. Flatten it if you can.
a_{b_{c}}
a_{b_{c}}
Pre-superscript The empty group before ^ is required, otherwise the superscript attaches to nothing.
{}^5_2\mathrm{He}
{}^5_2\mathrm{He}
Prime and derivative Primes are superscripts too, and they sit higher than ^2 does.
f'(x) \qquad f''(x)
f'(x) \qquad f''(x)

Worked examples

The brace rule in one line

x^10 \quad \text{versus} \quad x^{10}
x^10 \quad \text{versus} \quad x^{10}

The first prints x¹0. Two characters, one token.

A sum with both bounds

\sum_{i=1}^{n} i^2
\sum_{i=1}^{n} i^2

On a big operator in display maths the bounds go above and below; inline they sit to the side.

Function with a subscripted argument

f(x_0) = y_0
f(x_0) = y_0

The subscript belongs to the x, not to the whole parenthesis.

Common mistakes

  • a_12 when a_{12} was meant. This is the most frequent LaTeX error in transcribed maths.
  • Putting ^ before a group with nothing to attach to, e.g. starting a line with ^2. Prefix an empty group {}^2.
  • Using \limits in inline maths and wondering why nothing moves — the bounds are already to the side by design there.
  • Mixing a subscript on an operator with a subscript on its argument: \sum_i a_i is two different things both using _, and braces keep them straight.

Questions about this notation

Why does my exponent only highlight the first digit?
Because ^ and _ each take exactly one token. x^12 is x to the power 1, followed by a normal 2. Write x^{12}.
How do I force subscript limits under a sum sign?
In display maths it happens automatically. Inline, either wrap the expression in a displayed equation or use \limits explicitly: \sum\limits_{i=1}^n.
Can a subscript be a word?
Yes, if it is braced: a_{\text{max}}. Use \text{} so the word is set upright rather than as a product of italic variables.
How do I stack a subscript and a superscript, or put a subscript on a subscript?
Write both after one base and LaTeX stacks them: x_i^2, in either order. A script on a script shrinks again, so x_{i_1} is legal but hard to read — x_{i,1} with a comma is the form most journals prefer. Under an operator such as sum or lim the two go one above the other in display maths and beside it in inline maths; \limits and \nolimits force either.

Keep reading

Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.