# Formulae with charge and number of atoms (e.g. sulfate ion) aren't displayed properly

I just noticed that there is a problem when using mhchem to display structures such as sulfate's. According to its manual, they should appear as

But using $\ce{SO4^2-}$ results in

$\ce{SO4^2-}$

which isn't that bad, but is not the IUPAC recommended display.

A workaround is $\ce{SO4{}^{2-}}$:

$\ce{SO4{}^{2-}}$

Which works but has a funny spacing between the $^2$ and the $^-$ (which also looks too big).

I've seen at least one other bug report with mhchem recently. Any chance we get them fixed? Also, is there a better alternative than the one I showed?

• Since MathJax is not LaTeX, you might only get it fixed by issuing a bug report there: sourceforge.net/p/mathjax/bugs I would recommend ignoring it for the time being. While it is not IUPAC recommended, it does not automatically make it wrong, and it is still easy enough to understand. – Martin - マーチン Jun 14 '15 at 8:30

## 2 Answers

The documentation you linked is for mhchem v 4.01 (dated 23 April 2015). It is likely that Chemistry.SE uses an older version of the package that renders charge differently. Also note that Chemistry.SE uses the MathJax filter to process math mode $\LaTeX$ (including mhchem) and the problem could be in MathJax. For example, MathJax converts $\ce{SO4^2-}$ into something like

<math xmlns="http://www.w3.org/1998/Math/MathML">
<msubsup>
<mtext>SO</mtext>
<mrow class="MJX-TeXAtom-ORD">
<mn>4</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
<mo>&#x2212;<!-- − --></mo>
</mrow>
</msubsup>
[/itex]


so that internet browsers can display $\ce{SO4^2-}$.

If necessary, a workaround that avoids the wrong spacing between ‘$2$’ and ‘$-$’ is $\ce{SO4{}^{$2-$}}$:

$\ce{SO4{}^{$2-$}}$

Such notation is used in the current version of Nomenclature of Inorganic Chemistry – IUPAC Recommendations 2005 (Red Book) and the ACS Style Guide.

However, international and various national standards (e.g. ISO 80000, DIN 1338) still use $\mathrm{SO_4^{2-}}$. (International standards do not always agree with IUPAC recommendations.)

Remark:

With the current version of the mhchem extension of MathJax, the described workaround is no longer necessary. However, now the opposite workaround might become necessary in order to write a conforming formula such as $\mathrm{SO_4^{2-}}$ instead of the nonconforming version $\mathrm{SO_4{}^{2-}}$.

• The upcoming MathJax/mhchem update will switch to the IUPAC recommendation. What "international standards" are you talking about? – mhchem Mar 16 '16 at 1:11
• @mhchem Arguably, the most important international standard is ISO 80000 Quantities and units – Part 9 Physical chemistry and molecular physics (which replaced ISO 31-8) as well as its derivatives (e.g. the European standard EN ISO 80000-9, the German standard DIN EN ISO 80000-9). Furthermore, there are independent standards such as DIN 1338 Writing and typesetting of formulae. – user7951 Mar 16 '16 at 11:37
• And all of those really specify the stacked notation? I asked a chemist of look up recently published books and they all adhere to the IUPAC staggered notation. (I am not a chemist.) Therefore, I would change the MathJax/mhchem rendering to staggered. But I am open to hear your arguments. Should I open a meta discussion? – mhchem Mar 16 '16 at 18:15
• @mhchem Yes, ISO and DIN specify the aligned notation; DIN also explicitly mentions that the staggered notation shall not be used. – user7951 Mar 16 '16 at 18:38
• @mhchem Following your remark concerning publications, I checked the ACS Style Guide, which is probably the most important reference for publications. And indeed, you are right, according to this style guide, the subscript and superscript shall be staggered, not aligned. – user7951 Mar 16 '16 at 18:38