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.







\ce{CO2 + C -> 2CO}

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



For more information, see the mhchem package documentation.

Related posts:

For daily tips on LaTeX and typography, follow @TeXtip on Twitter.

TeXtip logo


8 thoughts on “Typesetting chemistry in LaTeX

  1. 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.

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

  3. Hi,

    I have to write represent a ring C10 to C15 in LaTeX.
    How to write. Chemfig (\ce) subscripts the number.

    Please help.

Leave a Reply

Your email address will not be published. Required fields are marked *