Subscript Count in LaTeX (\text{H}_2\text{O})
- LaTeX command
\text{H}_2\text{O}- Package
- Add to your preamble:
\usepackage{amsmath} - Mode
- Math mode only
Where it is used
Molecular formula for water, with the subscript 2 counting hydrogen atoms in each molecule.
Element symbols must be upright, which is why each letter group is wrapped in \text; italic H_2O would look like variables. A shorter equivalent is \mathrm{H_2O}, which keeps everything upright including the subscript and is immune to surrounding italics. Subscripts count atoms only and should never be confused with superscript charges. Formulas with parentheses follow the same pattern, \mathrm{Ca(OH)_2}. For extensive chemistry, a dedicated chemistry package saves effort, but for a few formulas this manual approach is perfectly adequate.
Minimal compilable example
Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Subscript Count: $\text{H}_2\text{O}$
\[ 2\text{H}_2 + \text{O}_2 \to 2\text{H}_2\text{O} \]
\end{document}Related symbols
- Delta (Upper)
\Delta - Superscript Charge
\text{Na}^{+} - Degree symbol
^{\circ} - Isotope
{}^{14}_{6}\text{C} - Degrees Celsius
^{\circ}\text{C} - Down Arrow
\downarrow
Frequently asked questions
- How do I write Subscript Count in LaTeX?
- Type \text{H}_2\text{O} in math mode, for example $2\text{H}_2 + \text{O}_2 \to 2\text{H}_2\text{O}$. Load amsmath first with \usepackage{amsmath}.
- Which package do I need for \text{H}_2\text{O}?
- \text{H}_2\text{O} needs amsmath: add \usepackage{amsmath} to your preamble before the document starts.
- Can I use \text{H}_2\text{O} in text mode, or only in math mode?
- Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\text{H}_2\text{O}$ in running text.
Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf
Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI
- Gumawa ng magagandang TikZ diagrams gamit ang AI
- Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
- Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers