Subscripts and superscripts in LaTeX use the underscore and caret symbols
In LaTeX, you write a subscript (a number or letter below the baseline) by placing an underscore _ before the character. You write a superscript (a number or letter above the baseline) by placing a caret ^ before the character. Both work only in math mode, which means they must appear between dollar signs or inside a math environment.
For a single character, the syntax is straightforward: $x_2$ produces x with a subscript 2, and $x^2$ produces x with a superscript 2. If you need more than one character in the subscript or superscript, you must wrap them in curly braces: $x_{12}$ or $x^{n+1}$. Without the braces, LaTeX will only apply the subscript or superscript to the first character that follows.
Key Takeaways
- Use underscore _ for subscripts and caret ^ for superscripts, always inside math mode (between dollar signs).
- Single characters need no braces: $x_2$ works, but multiple characters require braces: $x_{12}$.
- You can combine subscripts and superscripts on the same base: $x_2^3$ or $x^3_2$ both work.
- For text (not math) subscripts and superscripts, use the \textsubscript{} and \textsuperscript{} commands outside math mode.
- Nested subscripts and superscripts work but can become hard to read; use braces to control grouping.
Single versus multiple characters
LaTeX treats a single character after _ or ^ as the subscript or superscript. If you type $x_23$, LaTeX reads it as x with subscript 2, followed by the number 3 outside the subscript. The result looks wrong. To make both 2 and 3 part of the subscript, you must write $x_{23}$.
The same rule applies to superscripts. $2^10$ produces 2 to the power of 1, followed by 0. You need $2^{10}$ to get 2 to the power of 10. This is one of the most common mistakes when learning LaTeX subscripts and superscripts.
Combining subscripts and superscripts
You can place both a subscript and a superscript on the same base character. The order does not matter: $x_2^3$ and $x^3_2$ produce the same output, with 2 below and 3 above the x. LaTeX handles the positioning automatically.
If your subscript or superscript itself contains a subscript or superscript, use nested braces. For example, $x^{2^3}$ produces x to the power of 2 to the power of 3. The inner braces keep the second superscript grouped correctly. Without them, LaTeX will misinterpret the structure.
Math mode requirements
Subscripts and superscripts only work inside math mode. Math mode begins with a single dollar sign $ for inline math (within a line of text) or $$ for display math (on its own line). You can also use the \( \) pair for inline math or \[ \] for display math, or environments like equation* or align*.
If you try to use _ or ^ outside math mode, LaTeX will produce an error. The underscore in particular is reserved for math mode, so you cannot type it in regular text without escaping it as \_.
Text subscripts and superscripts outside math mode
Sometimes you need a subscript or superscript in regular text, not in a mathematical expression. LaTeX provides \textsubscript{} and \textsuperscript{} for this purpose. For example, H\textsubscript{2}O produces the chemical formula for water with the 2 as a subscript in text mode.
These commands work outside math mode and do not require dollar signs. They are useful for chemical formulas, footnote markers, or ordinal numbers like 1st, 2nd, 3rd. However, they produce smaller text than subscripts and superscripts in math mode, so use them only when you are writing prose rather than equations.
Common mistakes and how to fix them
The most frequent error is forgetting braces around multi-character subscripts or superscripts. If your output looks wrong, check whether you have wrapped multi-character groups in curly braces. Another common mistake is trying to use subscripts or superscripts outside math mode without the text commands.
Spacing can also cause confusion. LaTeX ignores spaces inside math mode, so $x _ 2$ and $x_2$ produce identical output. If you want readable source code, you can add spaces for clarity without affecting the result. However, if you need actual spacing in the subscript or superscript, use \, or \: inside the braces.
Subscripts and superscripts in different environments
Subscripts and superscripts behave the same way in inline math, display math, and math environments like equation or align. The syntax never changes. However, the size and positioning may differ slightly depending on the environment. In display mode, subscripts and superscripts are often larger and positioned farther from the base character than in inline mode.
If you are writing a long equation with many subscripts and superscripts, consider using display math to make it more readable. Inline math with complex subscripts can become cramped and hard to parse. Breaking it into a separate equation often improves clarity for both you and your readers.
Frequently Asked Questions
What is the difference between $x_2$ and $x_{2}$?
There is no difference in the output. Both produce x with a subscript 2. The braces are optional for single characters but required for multiple characters. Using braces for single characters is a matter of style and does not affect the result.
Can I use subscripts and superscripts in section titles or headings?
Yes, but you must still use math mode. Write \section{The formula $E=mc^2$} to include a superscript in a section title. If you need a subscript or superscript in text mode only (no math), use \textsubscript{} or \textsuperscript{} instead.
How do I make a subscript or superscript larger or smaller?
LaTeX automatically scales subscripts and superscripts to be smaller than the base text. To override this, use size commands like \large or \small inside the braces: $x^{\large 2}$. However, this is rarely necessary and can make your equations look inconsistent.
What if I need both a subscript and superscript on the same side of a character?
LaTeX places subscripts below and superscripts above by default. If you need both on the same side (for example, both above), you must use special commands like \sideset{}{} or manually adjust positioning with \phantom{}. This is an advanced technique used mainly in specialized mathematical notation.
Do subscripts and superscripts work with Greek letters?
Yes. Greek letters in math mode work exactly like regular letters: $\alpha_2$ produces alpha with a subscript 2, and $\beta^{n+1}$ produces beta to the power of n+1. The underscore and caret syntax is identical regardless of the base character.