[Tex/LaTex] Trouble with commas in subscript of chemical formula (using mhchem)

mhchemsubscripts

I'm writing a thesis on clay materials which have rather unusual chemical formulas with commas in the subscript. For intance I try to write the following chemical formula in LaTeX:

\begin{document}
\usepackage[version=3]{mhchem}

The chemical formula of beidelite is: \ce{Na0,5Al2(Si3,5Al0,5)O10(OH)2.n(H2O)}

\end{document}

It ignores the commas and gives the following output:

chemical formula of beidelite

To be clear, I want the subscript after Na to say 0,5, the subscript after Si say 3,5 and the subscript after Al say 0,5.

How do i fix this?

Best Answer

Place the non-integers inside curly bracket groups:

\documentclass[border=5pt]{standalone}
\usepackage[version=3]{mhchem}
\begin{document}

The chemical formula of beidelite is: \ce{Na_{0,5}Al2(Si_{3,5}Al_{0,5})O10(OH)2.$n$(H2O)}

\end{document}

Output with <code>version=3</code>

Related Question