Use this file to discover all available pages before exploring further.
To write a subscript in LaTeX, use _ in math mode: x_1. To write a superscript, use ^: x^2. When the subscript or superscript contains more than one character, wrap it in braces, as in x_{12} or x^{2n}. This guide starts with the basic subscript syntax most people search for, then covers superscripts, chemistry notation, tensors, and the errors that usually break equations.
Quick start: Use _ for subscripts and ^ for superscripts. For multiple characters, enclose in braces: x_{12} and x^{2n}.Prerequisites: Basic LaTeX knowledge. For math mode basics, see Mathematical Expressions.Last updated: April 2026 | Reading time: 12 min | Difficulty: Beginner to Intermediate
What is the difference between subscripts and superscripts in LaTeX?
In LaTeX, subscripts are notations placed below the baseline using the underscore character (_), commonly used for indices and chemical formulas. Superscripts are placed above the baseline using the caret character (^), typically for exponents and powers. Both are essential for mathematical and scientific notation in professional documents.Quick Example:
Subscript: x_1 renders as x₁
Superscript: x^2 renders as x²
How do I write multiple character subscripts in LaTeX?
Always use braces {} to group multiple characters in a LaTeX subscript or superscript. Without braces, only the first character becomes a subscript.Correct subscript syntax:
x_{12} % Both 1 and 2 are subscriptx_{n+1} % Entire expression is subscript
Wrong syntax:
x_12 % Only 1 is subscript (renders as x₁2)
This is one of the most common subscript errors in LaTeX.
Why do I get a 'Double subscript' error in LaTeX?
The “Double subscript” error occurs when you try to apply two subscripts to the same variable without proper grouping:
x_a_b % ERROR: Double subscript
Solutions:
Use nested braces if one subscript depends on another:
x_{a_b} % Correct: a has subscript b, all subscript to x
Or separate them with an empty group:
x_a{}_{b} % Correct: separate subscripts
How do I use subscripts in chemical formulas?
For chemical formula subscript notation, enclose the formula in \mathrm{} and use subscripts for atom counts:
\documentclass{article}\usepackage{amsmath}\begin{document}% Single character subscript$x_1$, $x_2$, $x_n$% Multiple character subscript (requires braces)$x_{12}$, $x_{n+1}$, $x_{max}$% Variables with subscripts$a_i$, $b_j$, $c_{ij}$% Greek letters with subscripts$\alpha_1$, $\beta_{n}$, $\gamma_{i,j}$\end{document}
\documentclass{article}\usepackage{amsmath}\begin{document}% Single character superscript$x^2$, $x^n$, $x^*$% Multiple character superscript (requires braces)$x^{10}$, $x^{2n}$, $x^{n+1}$% Common exponents$e^x$, $2^n$, $10^{-3}$% Special notations$x^{\prime}$, $x^{\dagger}$, $x^{\ast}$\end{document}
\documentclass{article}\usepackage{amsmath}\begin{document}% Both subscript and superscript$x_1^2$, $a_n^m$, $x_i^{j+1}$% Order doesn't matter$x_1^2 = x^2_1$% Complex combinations$x_{n+1}^{2m}$, $a_{ij}^{kl}$% With operators$\sum_{i=1}^n$, $\int_0^{\infty}$% Tensor notation$T_{\mu\nu}^{\rho\sigma}$\end{document}
Rendered Output
Both subscript and superscript:x12, anm, xij+1Order doesn’t matter:x12=x12Complex combinations:xn+12m, aijklWith operators:i=1∑n, ∫0∞Tensor notation:Tμνρσ
\documentclass{article}\usepackage{amsmath}\begin{document}% Single prime$f'(x)$, $y'$% Multiple primes$f''(x)$, $f'''(x)$% Alternative notation$f^{\prime}(x)$, $f^{\prime\prime}(x)$% With subscripts$x'_1$, $x''_n$% Prime on subscript$x_{n'}$, $x_{n''}$\end{document}
Rendered Output
Single prime:f′(x), y′Multiple primes:f′′(x), f′′′(x)Alternative notation:f′(x), f′′(x)With subscripts:x1′, xn′′Prime on subscript:xn′, xn′′
\documentclass{article}\usepackage{fixltx2e} % For \textsubscript\begin{document}% In text modeH\textsubscript{2}O is water.E = mc\textsuperscript{2} is Einstein's equation.% Or use math modeH$_2$O is water.E = mc$^2$ is Einstein's equation.% Ordinals1\textsuperscript{st}, 2\textsuperscript{nd}, 3\textsuperscript{rd}% Footnote markersText\textsuperscript{a}, Reference\textsuperscript{1}\end{document}
Rendered Output
In text mode: H2O is water. E = mc2 is Einstein’s equation.Ordinals: 1st, 2nd, 3rdFootnote markers: Texta, Reference1