How to Write Subscript in LaTeX: A Complete Guide
Subscript notation is one of the most frequently used formatting tools in LaTeX — whether you're writing chemical formulas, mathematical expressions, or technical documentation. LaTeX handles subscript through a clean, consistent syntax, but the specifics shift depending on your environment, nesting needs, and document type.
What Is Subscript in LaTeX?
In LaTeX, subscript refers to text or characters positioned slightly below the baseline of the main text — like the "2" in H₂O or the "n" in xₙ. LaTeX was designed with scientific and mathematical typesetting at its core, so subscript support is built directly into the language rather than bolted on as an afterthought.
The Core Subscript Syntax
The fundamental operator for subscript in LaTeX is the underscore character_.
x_n This renders "x" with "n" as a subscript. That's the entire foundation — but context matters significantly.
Using Subscript in Math Mode
LaTeX subscripts only work inside math mode. If you try to use _ in regular text, you'll either get an error or unexpected output depending on your compiler.
There are three common ways to enter math mode:
- Inline math: Wrap with single dollar signs —
$x_n$ - Display math: Use
[ x_n ]or theequationenvironment for centered, block-level equations - Inside environments:
align,gather,equation*, and similar environments from theamsmathpackage
The variable $x_n$ represents the nth element. [ x_{n+1} = x_n + delta ] Subscripts With More Than One Character 🔢
This is one of the most common sources of errors for new LaTeX users. When your subscript contains more than a single character, you must wrap it in curly braces {}.
x_n % correct — single character subscript x_{n+1} % correct — multi-character subscript x_n+1 % wrong — only "n" becomes subscript; "+1" stays on baseline The curly braces tell LaTeX exactly where the subscript begins and ends. Forgetting them produces output that looks subtly wrong and can be hard to debug.
Combining Subscript and Superscript
LaTeX allows simultaneous subscript and superscript on the same base element. Order doesn't matter — both x_i^2 and x^2_i produce the same output.
$x_i^2$ % subscript i, superscript 2 $a_{ij}^{kl}$ % multi-character subscript and superscript together This combination is common in tensor notation, summation limits, and indexed variables across physics, engineering, and mathematics documents.
Subscripts Outside Math Mode
Sometimes you need subscript-style formatting in regular body text — not inside an equation. There are two practical approaches:
Option 1: Use extsubscript{}
Available in standard LaTeX (no extra package required in most distributions):
H extsubscript{2}O This renders chemical-style subscript within a sentence without switching to math mode. The result is typographically slightly different from math-mode subscript — it uses the current text font rather than math italics.
Option 2: Use the fixltx2e or subscript Package
Older LaTeX documents sometimes relied on the fixltx2e package to get extsubscript working reliably. In modern LaTeX distributions (2015 onward), this is unnecessary — extsubscript is available natively.
Subscripts in Chemical Formulas ⚗️
If your document involves chemistry, the mhchem package (usepackage{mhchem}) offers a dedicated syntax designed for chemical notation:
ce{H2O} ce{CO2} ce{Fe2O3} The ce{} command automatically handles subscript placement, charge notation, and reaction arrows — far cleaner than manually placing _{} throughout a chemistry-heavy document.
Nested Subscripts
LaTeX supports nested subscripts — a subscript that itself has a subscript. The syntax layers naturally:
$x_{i_{j}}$ Be aware that each level of nesting reduces font size by default. Deep nesting (three or more levels) can produce output that's difficult to read. The scriptstyle and scriptscriptstyle commands give you manual control over sizing if needed.
Common Variables That Affect Your Approach
| Factor | Impact on Subscript Method |
|---|---|
| Document type (math vs. text-heavy) | Determines whether math mode is natural or disruptive |
| Chemistry vs. mathematics content | mhchem vs. standard _{} syntax |
| LaTeX distribution version | Affects extsubscript availability |
| Single vs. multi-character subscripts | Requires {} grouping for anything beyond one character |
| Nesting depth | May need manual font-size control |
| Font package in use | Affects how math-mode subscript visually compares to text-mode subscript |
Subscripts in Specific Environments
Summation and Integral Limits
In display math, subscripts on operators like sum and int appear below the operator — functioning as lower limits:
[ sum_{i=1}^{n} x_i ] In inline math ($...$), those same subscripts appear to the side of the operator to preserve line height. This behavior is automatic but can be overridden with limits and olimits.
Matrix and Array Environments
Inside matrix, pmatrix, bmatrix, and similar environments, subscripts work identically to standard math mode — the same _{} syntax applies without modification.
Quick Reference: Subscript Syntax Summary
% Single character subscript $x_n$ % Multi-character subscript (braces required) $x_{n+1}$ % Subscript + superscript together $x_{i}^{2}$ % Text-mode subscript (no math mode) H extsubscript{2}O % Chemistry package ce{H2SO4} % Nested subscript $x_{i_{j}}$ The Factor That Determines Everything Else 📄
The syntax itself is simple — _{} covers the vast majority of cases. Where it gets nuanced is in how your specific document is structured: whether you're in a math-heavy paper, a chemistry lab report, a technical manual with mixed text and notation, or something else entirely. The right method in a journal article template may be unnecessarily heavy for a simple inline reference in a README, and the clean output of mhchem is irrelevant if your subscripts are purely algebraic. Those distinctions come down to what you're building and how your document class and packages are already configured.