What is the 'best' package for typesetting chemical formulas? (I don't need anything but the chemical formulas.)

Assume I want to typeset

The dissociation of a AgBr molecure requires an energy of $E = \SI{123456789}{\J}$.

I am using the siunitx package for the physical quantity but what about AgBr?

  • 5
    Take a look at chemmacros by @cgnieder. It would be something like \ch{AgBr}or \ch{Fe2O3}. – Johannes_B Nov 19 '13 at 17:11
  • If you really only want the names, I think just typing directly is easiest :-) – Joseph Wright Nov 19 '13 at 17:12
  • @JosephWright I have a feeling my code will be easier to read when typing the names using macros. – Svend Tveskæg Nov 19 '13 at 17:13
  • 1
    Maybe have a look at tex.stackexchange.com/questions/87253/cursive-text-after/… for some alternatives – cgnieder Nov 19 '13 at 17:53
  • One advantage to using a package like chemmacros over direct typing is that you can make a strong penalty for hyphenating formulas. That is, you can prevent situations where you end up with Ag- <newline> Br – pdanese Oct 15 '19 at 14:16

The answer depends a bit on what you actually need. If all your formulae are as simple as AgBr or FeO there is no need for any package and you can just type them as they are. If you want some macro for marking the formulae in your source something like


would suffice. Or - if you plan to use it in math mode, too -


The second version would even allow you to typeset formulae like AlBr3 and even simple reaction equations:



$\chem{H_2} + (1/2)\,\chem{O_2} = \chem{H_2O}$

$2\,\chem{H_2} + \chem{O_2} \to 2\,\chem{H_2O}$


Output 1

Only if you need more complicated features or if you have to type a lot of those formulae and not just some ten or twenty then one of the chemistry packages will start to bring you benefits. There are two packages to consider:

  1. mhchem
  2. chemformula

The differences between both of them are

  • subtle differences in the syntax,
  • differences in the layout of the equations, e.g., regarding spacing,
  • a different set of options for customization,
  • probably more I have forgotten right now.


\ce{H2 + (1/2) O2 = H2O}

\ce{2H2 +  O2 -> 2H2O}


Output 2



\ch{H2 + (1/2) O2 == H2O}

\ch{2 H2 +  O2 -> 2 H2O}


Output 3

| improve this answer | |
  • 5
    I'd avoid using any kind of "hack" if there is a good package to do something in a simple manner. I would recommend something like mchem (which I use) right away. – DetlevCM Nov 19 '13 at 19:03
  • Thank you, Clement. Great answer. (Of course you mean \newcommand*\chem[1]{\ensuremath{\mathrm{#1}}}; you forgot \chem.) – Svend Tveskæg Nov 19 '13 at 19:06
  • 8
    @DetlevCM I wouldn't consider a small macro a “hack” but rather good LaTeX practice... Although I actually wrote the chemmacros bundle I rather wanted to give an overview over the various possibilities (and my answer isn't even complete!) to present a choice to the OP any anyone interested. Of course mhchem is a great package if you have some more serious chemistry in your documents :) – cgnieder Nov 19 '13 at 19:14
  • 1
    @cgnieder in a loose definition, any modification is a hack - which includes a small macro. My key worry with doing these things is, that in the end you start defining more and more as you go along and end up with a mess or several months later have forgotten what you did. I use mchem because it is what I found when I searched for a package one or two years ago - I had a look at the chemmacros manual and it looks very good. – DetlevCM Nov 20 '13 at 6:42
  • 8
    @DetlevCM However you call it: writing own macros is the very heart of LaTeX's philosophy IMHO. Regarding »in the end you start defining more and more as you go along and end up with a mess« - that's how most of my packages were born :) – cgnieder Nov 20 '13 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.