Superscript and subscript in LaTeX use the caret (^) and underscore (_) symbols
In LaTeX, you write superscript by placing a caret (^) before the character or group you want raised. You write subscript by placing an underscore (_) before the character or group you want lowered. Both symbols work inside math mode, which you enter with dollar signs ($...$) for inline math or \[...\] for display math.
The key rule: if your superscript or subscript is more than one character, wrap it in curly braces. Without braces, LaTeX will only raise or lower the first character and leave the rest at normal height or depth. This is the most common mistake when starting out with mathematical typesetting in LaTeX.
Key Takeaways
- Use the caret symbol (^) for superscript and underscore (_) for subscript, always inside math mode.
- Wrap multi-character superscripts and subscripts in curly braces: x^{2n} not x^2n.
- Single characters do not need braces, but adding them never hurts and prevents errors when you edit later.
- You can nest superscripts and subscripts: x^{2^3} produces x to the power of 2 to the power of 3.
- Superscript and subscript only work inside math mode; outside math mode, use \textsuperscript{} and \textsubscript{} instead.
Single characters: no braces needed
For a single character superscript or subscript, you can omit the braces. Write $x^2$ to get x squared, or $H_2O$ to get H with subscript 2 and O. LaTeX will correctly raise or lower just that one character and leave the rest of the text at normal position.
However, many writers add braces anyway—$x^{2}$ and $H_{2}O$—because it makes the code clearer to read and prevents mistakes if you later add more characters. This is a matter of style, not correctness, but the habit can save you debugging time.
Multiple characters: always use braces
If your superscript or subscript contains more than one character, you must wrap it in curly braces. Write $x^{2n}$, not $x^2n$. Without braces, LaTeX raises only the 2 and leaves the n at normal height, which looks wrong and breaks the mathematical meaning.
The same rule applies to subscripts. Write $a_{ij}$ to get a with subscript ij, or $E_{kinetic}$ to get E with subscript kinetic. The braces tell LaTeX to treat everything inside as a single unit to be raised or lowered together as one block.
Stacking superscripts and subscripts
You can place both a superscript and a subscript on the same base character. Write $x_i^2$ or $x^2_i$—the order does not matter, and LaTeX will position them correctly on opposite sides. If either the superscript or subscript has multiple characters, wrap it in braces: $x_{ij}^{2n}$.
You can also nest superscripts and subscripts inside each other. Write $x^{2^3}$ to get x to the power of (2 to the power of 3). The inner superscript 3 will be smaller and positioned above the 2. Nesting works the same way for subscripts: $a_{b_{c}}$ produces a with subscript b with subscript c, with each level getting progressively smaller.
Common symbols that need math mode
Superscript and subscript only work inside math mode. If you write x^2 in regular text without dollar signs, LaTeX will either produce an error or ignore the caret entirely. You must write $x^2$ with the dollar signs to enter math mode first.
For inline math (text that appears in a sentence), use single dollar signs: $E = mc^2$. For display math (a separate line or equation block), use \[E = mc^2\] or the equation* environment. Both work with superscript and subscript the same way, though display mode may position subscripts differently for certain operators.
Spacing and readability in your source code
LaTeX ignores spaces inside math mode, so $x ^ 2$ and $x^2$ produce identical output. You can add spaces around the caret or underscore if it makes your source code easier to read, or omit them—the choice is yours and does not affect the final result.
For complex expressions, many writers break the code across multiple lines or add comments to stay organized. For example, you might write a chemical formula like this:
$\text{H}_{2}\text{O}$ for water, or $\text{CO}_{2}$ for carbon dioxide
The \text{} command lets you write letters in regular font inside math mode, which is useful for chemical symbols and variable names that should not be italicized. This keeps your formulas readable and properly formatted.
Frequently Asked Questions
What if I want superscript or subscript outside of math mode?
You must enter math mode first. Use dollar signs for inline: The formula is $E = mc^2$. If you need superscript in regular text (like for footnotes or ordinals), use the \textsuperscript{} command instead: 1\textsuperscript{st} produces 1st. For subscript in text, use \textsubscript{}.
Why does my superscript look too small?
LaTeX automatically makes superscripts and subscripts smaller than the base text. This is correct behavior and matches standard mathematical typesetting. If you want them larger, you are probably using the wrong tool for your document type—check whether you should be using a different document class or font size.
Can I use superscript and subscript in section headings or titles?
Yes, but wrap the math mode in braces to prevent LaTeX from breaking the heading. Write \section{The formula $E = mc^2$ explained} rather than leaving the math mode unbraced. This ensures the heading processes correctly in the table of contents.
How do I write a limit with subscript, like "limit as n approaches infinity"?
Use the \lim command with an underscore subscript: $\lim_{n \to \infty}$. The \to command produces the arrow symbol. In display mode, LaTeX automatically positions the subscript below the lim symbol; in inline mode, it appears to the right. You can force display-style positioning with \limits: $\lim\limits_{n \to \infty}$.