Chemical formulae

Chemical formulae and equations have a different style compared to mathematical formulae and equations. For example:

  • Letters mean atomic symbols and are written upright, unlike italic math variables.
  • Numbers are commonly used in subscripts, indicating the number of atoms.
  • We use a lot of subscripts and superscripts, they should be aligned properly.
  • We need also left subscripts and superscripts.
  • We need special symbols such as for bonds and arrows for chemical equations.

With basic LaTeX, it’s hard to achieve all of this. There’s a better way with the chemformula package. Here, we will boldly go ahead and type some chemical stuff, to see how it works.

The code is fully explained in the LaTeX Cookbook, Chapter 11, Science and Technology, Writing chemical formulae.

% Chemical formulae
% Author: Stefan Kottwitz
% https://www.packtpub.com/hardware-and-creative/latex-cookbook
\documentclass{scrartcl}
\usepackage{chemformula}
\pagestyle{empty}
\begin{document}
\section*{About \ch{Na2SO4}}
\ch{Na2SO4} is sodium sulfate.
It contains \ch{Na+} and \ch{SO4^2-}.
\ch{Na2SO4 * 10 H2O} is a decahydrate.
\[
\ch{Na2SO4 + 2 C -> Na2S + 2 CO2}
\]
\begin{equation}
\ch{Na2SO4 + H2SO4 <=> 2 NaHSO4}
\end{equation}
\section*{Isotopes}
\ch{^{232}_{92}U140} is uranium-232.
\section*{Hydrocarbons}
\begin{itemize}
  \item \ch{H3C-CH3} is ethane,
  \item \ch{H2C=CH2} is ethylene,
  \item \ch{H2C+CH2} is ethyne.
\end{itemize}
\end{document}
Click to download: chemistry.texchemistry.pdf
Open in Overleaf: chemistry.tex