Subscript and superscript syntax in LaTeX

In LaTeX, you create a subscript (text or numbers below the baseline) by placing an underscore _ before the character or group of characters you want to lower. You create a superscript (text or numbers above the baseline) by placing a caret ^ before the character or group. Both work the same way: single character goes directly after the symbol, multiple characters go in curly braces.

For a single subscript character, type H_2O to get H with a 2 below it. For multiple characters or when you want to be explicit, use braces: H_{2}O produces the same result. The braces tell LaTeX where the subscript ends, which matters when you have text when ready after. Without braces, x_2y makes only the 2 subscript, but x_{2}y makes the 2 subscript and keeps the y at normal height.

Superscripts follow the same rule. x^2 produces x squared. E=mc^2 produces Einstein's equation with the 2 as a superscript. For multiple characters, use braces: 2^{10} gives you 2 to the power of 10, not 2 to the power of 1 with a 0 after it.

Key Takeaways

  • Use underscore _ for subscripts and caret ^ for superscripts, followed when ready by the character or a group in curly braces.
  • Single characters work without braces: x_2 or x^2, but multiple characters need braces: x_{12} or x^{12}.
  • Subscripts and superscripts can be nested or combined in the same expression, such as x_1^2 for x subscript 1, superscript 2.
  • In text mode (outside math), subscripts and superscripts do not work; you must be inside a math environment like $...$ or \[...\].

Subscripts and superscripts together on the same character

You can place both a subscript and a superscript on the same base character. The order does not matter to LaTeX — x_2^3 and x^3_2 both produce x with a 2 below and a 3 above. Most people write subscript first, then superscript, because that reads more naturally when you are typing.

This is useful for chemical notation like ^{235}U_{92} (uranium-235 with atomic number 92) or mathematical expressions like a_i^2 (the square of the i-th element of a). If you have multiple subscripts or superscripts on different parts of an expression, each base character gets its own underscore or caret.

Math mode: where subscripts and superscripts actually work

Subscripts and superscripts only work inside a math environment. The most common math environments are inline math (between dollar signs: $x_2$) and display math (between \[ and \] or between double dollar signs). If you try to use underscore or caret outside math mode, LaTeX will either produce an error or treat them as regular characters.

Inline math keeps the expression on the same line as your text: "The formula $E=mc^2$ changed physics." Display math puts the expression on its own line, centered. For a subscript in running text, use inline math: "The element $H_2O$ is water." For a longer equation or when you want it to stand out, use display math.

Some LaTeX editors and document classes have shortcuts. In Overleaf, you can type math directly without worrying about which environment you are in for straightforward expressions. In a standard .tex file, you must be explicit about entering math mode first.

Subscripts with letters and words

Subscripts do not have to be numbers. You can use letters: x_i, a_n, or T_{max}. When the subscript is a word or multiple letters, always use braces to make clear where it ends. x_max might be read by LaTeX as x subscript m, then a, then x — use x_{max} instead.

By default, subscript letters appear in italic (math italic), the same as the base variable. If you want a subscript in roman (upright) text — common for labels like T_{room} or P_{atm} — use \mathrm inside the braces: T_{\mathrm{room}}. This makes the subscript upright and easier to read as a label rather than a variable name.

Nested subscripts and superscripts

You can nest subscripts and superscripts, though this gets complicated quickly and can be hard to read. x^{2^n} produces x to the power of (2 to the power of n). The inner superscript is smaller and raised higher. a_{b_c} produces a with a subscript of b, where b itself has a subscript of c — the c appears even smaller and lower.

Nesting works because anything inside braces is treated as a single unit. The outer braces group the content for the first subscript or superscript, and if that content has its own subscript or superscript, it gets applied to that grouped content. In practice, nested subscripts and superscripts are rare outside of advanced mathematics or computer science notation.

Common mistakes and how to fix them

The most common mistake is forgetting braces when you have multiple characters. x_12 produces x with only the 1 as a subscript, leaving the 2 at normal height. Use x_{12} instead. Another mistake is trying to use subscripts outside math mode — if you type H_2O in regular text without dollar signs, LaTeX will error or ignore the underscore.

A third mistake is using the wrong symbol. The hyphen - is not the same as underscore _, and the backtick ` is not the same as caret ^. On most keyboards, underscore is Shift+hyphen, and caret is Shift+6. If your subscript or superscript is not appearing, check that you used the correct symbol.

If you have a subscript that should be in text (like a label) but it appears in italic, wrap it in \mathrm{} or \text{}. The \text command requires the amsmath package, which most LaTeX documents load by default. \mathrm works without any package.

Subscripts in different contexts: fractions, integrals, and sums

In fractions, subscripts and superscripts work the same way. \frac{x_1}{x_2} puts x subscript 1 in the numerator and x subscript 2 in the denominator. In integrals and sums, subscripts and superscripts have special meaning: the subscript becomes the lower limit and the superscript becomes the upper limit. \sum_{i=1}^{n} x_i produces a sum from i equals 1 to n of x subscript i.

In display mode, these limits appear directly below and above the symbol. In inline mode, they appear as subscripts and superscripts to the right of the symbol, to save vertical space. This is automatic — you do not need to do anything different. Just use underscore for the lower limit and caret for the upper limit.

Frequently Asked Questions

Can I use subscripts and superscripts in the document title or section headings?

Yes, but you must put them in math mode even inside a heading. Use $x_2$ or \(x_2\) inside the heading text. Some document classes handle this automatically, but it is safest to be explicit. If the heading is in a special font or color, the math mode text may look different, so test it in your document.

What is the difference between underscore and hyphen for subscripts?

Underscore _ is the LaTeX command for subscript and only works in math mode. Hyphen - is a regular character and produces a dash. They are not interchangeable. If you type x-2, you get x dash 2, not x subscript 2.

How do I make a subscript or superscript in a table or text box?

Use math mode inside the table cell or text box, just as you would in regular text. \$x_2\$ works in a table cell. If the table or box is already in math mode, you do not need the dollar signs. Check your specific environment — some table packages have their own rules.

Can I change the size of subscripts and superscripts?

LaTeX automatically scales subscripts and superscripts smaller than the base text. You can override this with commands like \scriptstyle or \scriptscriptstyle, but this is rarely necessary and usually makes the document harder to read. Stick with the default sizing unless you have a specific reason to change it.