# How to put chemical formula into subscript with mhchem

I would like to put chemical formulas into subscripts/superscripts. For example, $M_\ce{H}$ should denote mass of H atom. However, this fails in recent version of mhchem (4.02)

\documentclass{report}
\usepackage{mhchem}

\begin{document}
$$M_\ce{H}$$

\end{document}


Saying

! Missing { inserted.
\tex_let:D
l.6     M_\ce{H}

? q


I know that it used to work in previous version of mhchem (3.07), but adding \usepackage[version=3]{mhchem} doesn't help. Is there some other way how to do it?

• This wasn't true for all versions 3 of mhchem. If this ever worked I guess it was by chance tex.stackexchange.com/questions/239301/… – clemens Nov 2 '15 at 17:00
• @clemens A dupe of the older question perhaps? – Joseph Wright Nov 2 '15 at 17:06
• @Joseph maybe. Although the error is different both cause and solution are the same... – clemens Nov 2 '15 at 18:39

Sub- and superscripts should be given in braces if they are not a single token. Whilst some cases do work without this (for example $M_\mathrm{n}$) this is not generally true. Here, the document will work correctly with eh official LaTeX syntax
\documentclass{report}
$$M_{\ce{H}}$$