How to write a subscript in LaTeX
In math mode, _ makes a subscript and^ makes a superscript. No package is needed.
\documentclass{article}
\begin{document}
Inline: $x_1$ and $x^2$.
Display:
\[
x_i^2 + y_{ij}
\]
\end{document}Both characters work only in math mode. Outside it, LaTeX stops withMissing $ inserted.
More than one character: use braces
_ and ^ apply to the next single character or the next braced group. Without braces, only the first character moves.
$x_10$ % wrong: 1 is lowered, 0 is not
$x_{10}$ % right
$e^{-x^2}$ % braces nestSubscript and superscript together
Write them in either order. LaTeX stacks them at the same position rather than one after the other.
\[
x_i^2 \qquad A_{ij}^{k} \qquad \sum_{i=1}^{n} x_i
\]To put a subscript on a symbol that already has a superscript, such as a prime, keep the order explicit: f'_n isf-prime with subscript n.
Words in a subscript
Math mode sets letters in italic as if they were variables. A label such as "max" or "total" should be upright, so wrap it in\text{...}. That command comes fromamsmath. \mathrm{...} is the core alternative.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$v_{\text{max}}$ \quad $v_{max}$ \quad $T_{\mathrm{in}}$
\end{document}The middle one, v_{max}, is set as the productm·a·x. That is the most common subscript mistake.
Subscripts in ordinary text
Outside math mode, use \textsubscript{...} for a subscript and \textsuperscript{...} for a superscript. Both are core LaTeX.
H\textsubscript{2}O, the 3\textsuperscript{rd} sampleChemical formulas
For one or two formulas, $\mathrm{H_2O}$ is enough. For a document with many, load the mhchem package and write\ce{H2O}, \ce{CO2} or\ce{SO4^2-}. It sets the subscripts, charges and upright type for you.
\documentclass{article}
\usepackage[version=4]{mhchem}
\begin{document}
\ce{H2O} \quad \ce{CO2} \quad \ce{SO4^2-}
\end{document}Common mistakes
- Double subscript.
x_a_braises "Double subscript". Group it:x_{a_b}. - Subscript on nothing. A script with no base, such as the mass number in an isotope, spaces badly. Put an empty group first:
{}_2^4\mathrm{He}. - Underscore in text. A bare
_outside math mode errors. Write\_for a literal underscore. - Position above and below. On big operators such as
\sum, limits move above and below in display math. Seesums and integrals.
Templates that use this
Units, chemical formulas and indices lean on sub- and superscripts. See the laboratory report templates, the simple lab report, or theamsart article for maths-heavy papers.
Related
Subscripts are heavily used inmatrices andfractions. The same symbols appear in themath symbols reference. New to LaTeX? Start with LaTeX for beginners, or pick up a document from thethesis templates.