LaTeX Subscript and Superscript

A LaTeX subscript is written with _ and a superscript with ^ inside math mode: $x_1$ gives x₁ and $x^2$ gives x². When the script is longer than one character, wrap it in braces: $x^{10}$.

LaTeX
$x_1$, \quad $x^2$, \quad $x_1^2$, \quad $e^{i\pi} + 1 = 0$
Outputx sub 1, x squared, x sub 1 squared, and e to the i pi plus 1 equals 0.
Full document you can compile
example.tex
\documentclass{article}
\begin{document}
$x_1$, \quad $x^2$, \quad $x_1^2$, \quad $e^{i\pi} + 1 = 0$
\end{document}

How do you write a LaTeX subscript and superscript together?

Put both after the base, in either order: x_1^2 and x^2_1 give the same result, with the subscript set below the superscript. Both only work in math mode, between $…$ or in an equation. Outside math, _ and ^ stop the compile with ! Missing $ inserted.

Why does x^10 show only the 1 raised?

Without braces, _ and ^ take exactly one character. $x^10$ raises the 1 and leaves the 0 on the baseline, and $a_ij$ lowers only the i. Braces group the whole script.

LaTeX
Without braces: $x^10$ and $a_ij$

With braces: $x^{10}$ and $a_{ij}$
Outputx to the 1 followed by 0 and a sub i followed by j without braces; x to the 10 and a sub ij with braces.
Full document you can compile
example.tex
\documentclass{article}
\begin{document}
Without braces: $x^10$ and $a_ij$

With braces: $x^{10}$ and $a_{ij}$
\end{document}

How do you put a subscript in normal text?

Use \textsubscript{…} and \textsuperscript{…}. They work outside math, keep the text font, and need no package in current LaTeX. This is the right choice for chemical formulas in a sentence and for ordinals like 1st.

LaTeX
Water is H\textsubscript{2}O and this is the
1\textsuperscript{st} draft.
OutputThe sentence: Water is H2O and this is the 1st draft, with a lowered 2 and a raised st.
Full document you can compile
example.tex
\documentclass{article}
\begin{document}
Water is H\textsubscript{2}O and this is the
1\textsuperscript{st} draft.
\end{document}

Can you nest a LaTeX subscript inside another?

Yes. A script can have its own script, as in a double exponent 2^{2^n} or an index of an index x_{i_k}. Each level is set smaller, down to a minimum size.

LaTeX
$2^{2^n}$, \quad $x_{i_k}$, \quad $e^{-x^2/2}$
OutputTwo to the two to the n, x sub i sub k, and e to the minus x squared over 2.
Full document you can compile
example.tex
\documentclass{article}
\begin{document}
$2^{2^n}$, \quad $x_{i_k}$, \quad $e^{-x^2/2}$
\end{document}

Why do limits on a sum move to the side?

Inside a paragraph, LaTeX places the limits of \sum, \prod and \lim to the right so the line spacing stays even. In a displayed equation they go above and below. To force the stacked form inline, write \sum\limits_{i=1}^{n}. The sum sign and ∞ have their own pages: the sigma symbol and the infinity symbol.

LaTeX
Inline: $\sum_{i=1}^{n} i$ \quad Displayed:
\[ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} \]
OutputAn inline sum from i equals 1 to n with limits at the side, then a displayed sum with limits above and below equal to n times n plus 1 over 2.
Full document you can compile
example.tex
\documentclass{article}
\begin{document}
Inline: $\sum_{i=1}^{n} i$ \quad Displayed:
\[ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} \]
\end{document}

How do you write a subscript before a symbol?

For isotopes and tensor notation, load mathtools and use \prescript{sup}{sub}{base}. It right-aligns the two left scripts against the base, which an empty group like {}^{14}_{6}\mathrm{C} doesn't do.

LaTeX
Carbon-14: $\prescript{14}{6}{\mathrm{C}}$
OutputCarbon-14 written with 14 above and 6 below on the left of C.

Needs \usepackage{mathtools} in the preamble.

Full document you can compile
example.tex
\documentclass{article}
\usepackage{mathtools}
\begin{document}
Carbon-14: $\prescript{14}{6}{\mathrm{C}}$
\end{document}

How do you write chemical formulas with subscripts?

For more than the odd H₂O, the mhchem package is easier: inside \ce{…}, numbers after an element become subscripts and charges after ^ become superscripts, all in upright type.

LaTeX
\ce{H2SO4}, \quad \ce{SO4^2-}, \quad \ce{^{14}_{6}C}
OutputSulfuric acid H2SO4, the sulfate ion SO4 2 minus, and carbon-14 with mass and atomic numbers.

Needs \usepackage{mhchem} in the preamble.

Full document you can compile
example.tex
\documentclass{article}
\usepackage{mhchem}
\begin{document}
\ce{H2SO4}, \quad \ce{SO4^2-}, \quad \ce{^{14}_{6}C}
\end{document}

How do you get subscripts on a web page?

The LaTeX to HTML and MathML converter turns x_1 into MathML that browsers render, and the equation editor lets you build the formula with a preview. HTML's own <sub> and <sup> tags are fine for text such as H₂O, as the symbol table notes.

Text drafted with AI from the cited documentation; every example compiled with TeX Live 2026; checked by Cem Demir. See the editorial policy.