4

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}
\begin{equation}
    M_\ce{H}
\end{equation}

\end{document}

Saying

! Missing { inserted.
<to be read again> 
                   \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?

  • 1
    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
5

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}
\usepackage[version=4]{mhchem}

\begin{document}
\begin{equation}
    M_{\ce{H}}
\end{equation}

\end{document}

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.