Usually I use the package mhchem for writing chemical formulas, but until now I was not able to find a solution for writing crystals such as Nd^{3+}:YAG properly with this package. When simply writing


it results in an error. My current alternative solution is to write it as


Is there a more elegant way to do that?

  • Why place the YAG part into a \ce in the first place? YAG is not a chemical formula but an abbreviation for yttrium aluminum garnet.
    – leandriis
    Mar 1, 2020 at 10:39
  • If you want to stick with putting the whole expression into a \ce command, you can add an extra pair of {} around the : as in \ce{Nd^{3+}{:}YAG}.
    – leandriis
    Mar 1, 2020 at 10:41

1 Answer 1


The error message reads

./test.tex:6: Package mhchem Error: Assertion failed: Unexpected input character. In case
(mhchem)                you think this is a bug, please contact the package
(mhchem)                author.

which gives a hidden hint to the solution. As this is a parsing error for mhchem escaping might help. The manual says

If you want to escape parsing, for instance for a simple hyphen (that should not become a bond), use {...}.

And indeed:




enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .