# Typesetting chemistry in LaTeX

Yesterday I gave the following tip on TeXtip:

Set chemical formulas with math Roman. Example: sulfate is $mathrm{SO_4^{2-}}$

TorbjoernT and scmbradley let me know there’s a better way: use Martin Hansel’s package mhchem. The package is simpler to use and it correctly handles subtle typographical details.

Using the mhchem package, sulfate would be written ce{SO4^2-}. In addition to chemical compounds, mhchem has support for bonds, arrows, and related chemical notation.

Example:

Source:

\documentclass{article}
\usepackage[version=3]{mhchem}
\parskip=0.1in
\begin{document}

\ce{SO4^2-}

\ce{^{227}_{90}Th+}

\ce{A\bond{-}B\bond{=}C\bond{#}D}

\ce{CO2 + C -> 2CO}

\ce{SO4^2- + Ba^2+ -> BaSO4 v}

\end{document}

Related posts:

## 7 thoughts on “Typesetting chemistry in LaTeX”

1. Those supposed right angles are showing HTML entities instead.

2. Michael: Thanks for letting me know. I’ve fixed it.

My plug-in for displaying code nicely failed me. So I reverted to putting the code in <pre> tags. Now it’s not as fancy, but it’s at least correct.

3. Chris Smith

Thanks for your notes. Very useful and work perfectly with MacTeX out of the box.

4. Thanks, John, for posting this! I was having trouble finding any documentation on the mhchem package. Now my nuclear reaction notation looks just right.

5. mhchem is very useful, but one thing it won’t do is properly typeset IUPAC names like 3-ethyl-2,2,5-trimethylhexane. For IUPAC names, use bpchem along with mhchem.