Math and Equations

How to use subscript in LaTeX?

Use subscripts in LaTeX with an underscore in math mode, braces for longer subscripts, combined sub- and superscripts, and textsubscript for plain text.

On this page
  1. Subscripts in math mode
  2. Longer subscripts need braces
  3. Subscript and superscript together
  4. Text inside a subscript
  5. Subscripts outside math mode
  6. Left subscripts and superscripts
  7. Subscripts on operators
  8. Common errors

To write a subscript in LaTeX, type an underscore before the character, inside math mode, such as $x_1$. If the subscript has more than one character, wrap it in curly braces, as in $x_{i+1}$. In running text outside math mode, use \textsubscript{}.

Subscripts in math mode

Subscripts work only in math mode, so wrap the expression in $...$, \(...\) or \[...\]:

Let $x_1$ be the first term and $x_n$ the last term.

\[
  a_0 + a_1 x + a_2 x^2
\]

Longer subscripts need braces

LaTeX attaches only the next character to the underscore. $x_12$ puts a subscript 1 and then a normal-size 2 after it. $x_{12}$ puts the whole 12 in the subscript.

Use braces for any index with more than one character or symbol, such as $x_{i+1}$ or $a_{\max}$. Greek letters work the same way, as in $\rho_{12}$ in the rho symbol guide.

Subscript and superscript together

Attach a subscript and a superscript to the same symbol with _ and ^. The order does not matter:

$x_1^2$ and $x^2_1$ both give x with a subscript 1 and a superscript 2.

Text inside a subscript

Subscripts are set in math italic by default, so $X_{max}$ shows the letters as variables. To keep a word upright, use \text{} from amsmath:

$X_{\text{max}}$

Subscripts outside math mode

\textsubscript{} sets a subscript in running text, without math mode. The text formatting guide covers it alongside the other text commands. Recent LaTeX releases include it in the kernel:

The formula for water is H\textsubscript{2}O.

For chemical formulas, the mhchem package handles the spacing and formatting, so \ce{H2O} is enough.

Left subscripts and superscripts

Some notation puts an index to the left of a symbol. The mass number and atomic number of an isotope are one example. Use an empty group {} as the base, and attach the scripts to it:

${}^{14}_{6}\mathrm{C}$

The empty braces give the scripts nothing to attach to, so they sit before the C. A “lower index” is the same thing as a subscript, which the sections above cover.

Subscripts on operators

Sums, limits and suprema take subscripts too:

\[
  \sum_{i=1}^{n} x_i
\]

In display math, \sum places its limits above and below the symbol. In inline math, it places them to the side. Add \limits to force them underneath. The advanced mathematics guide shows this for \sup and other operators.

Common errors

  • Missing $ inserted: an underscore or caret appears outside math mode. Wrap the expression in $...$.
  • Double subscript: writing $x_1_2$ puts two subscripts on one symbol. Combine them with braces, as in $x_{1,2}$.
  • Only the first character is subscripted: add braces around the whole index.
  • Words set in italics: use \text{} for words inside a subscript.

The complete guide to math and equations

Advanced Mathematics in LaTeX: Operators, Theorems and Proofs
Read the guide

Keep exploring

Guides from other topics

All topics →