Chemical Equations in LaTeX Without the Font Trouble

Maths mode was designed for variables and operators, not for element symbols. Type H2O inside $ $ and LaTeX renders it as the product of H, 2 and O…

Maths mode was designed for variables and operators, not for element symbols. Type H2O inside $ $ and LaTeX renders it as the product of H, 2 and O — italic, with the 2 as a subscript-shaped variable. Chemistry packages exist to stop that.

mhchem

The standard answer. Load \usepackage{mhchem} and write formulas with \ce:

\ce{2H2 + O2 -> 2H2O}\n\ce{[Cu(NH3)4]^2+}\n\ce{CaCO3(s) <=> CaO(s) + CO2(g)}

Subscripts, charges, oxidation states, equilibrium arrows and phase labels all come out right, and the markup stays readable.

If you cannot load packages

In MathJax or KaTeX, \ce is available as an extension, but you have to enable it explicitly. Otherwise the fallback is manual: \mathrm{H}_{2}\mathrm{O}, which is correct and tedious.

Units

Pair mhchem with siunitx for quantities — \SI{25}{\degreeCelsius} keeps unit spacing and formatting consistent across a document, which is exactly the thing hand-rolled ^\circ\text{C} gets wrong.

chemistrylatexsiunitx

Keep reading

Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.