Subscript Count in LaTeX (\text{H}_2\text{O})

H2O\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.

2H2+O2→2H2O2\text{H}_2 + \text{O}_2 \to 2\text{H}_2\text{O}
\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

All 화학 →

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.
Math poweredAI로 LaTeX 작성

최고의 AI LaTeX 편집기, Overleaf 대안

Octree는 15개 이상의 대학의 연구자들이 AI를 사용하여 논문을 더 빠르게 작성하도록 도움

  • AI로 아름다운 TikZ 다이어그램 생성
  • 이미지를 업로드하고 LaTeX로 원활하게 변환
  • 논문 작성 및 서식에 대한 즉각적인 지원 받기