Comma in chemical formula

I am using the \usepackage[version=3]{mhchem} package, and would like to write the formula for Dolomite in my report: (Ca,Mg)CO3

So far I haven't found a way to get that comma right in my formula using the mhchem package, and haven't found anyone having had troubles doing that so far. Anyone could help me doing so?

Cheers!

• Dolomite is CaMg(CO3)2. What you write, (Ca,Mg)CO3 is Mg-rich calcite that is a different mineral to dolomite and has different crystal structure and properties. – Gimelist 17 hours ago

The OP's formula (Ca,Mg)CO3 is completely fine and meets IUPAC recommendations [1, p. 21], section IR-2.2.3.1:

(d) In solid-state chemistry, to enclose symbols of atoms occupying the same type of site in a random fashion. The symbols themselves are separated by a comma, with no space.

Example:

1. K(Br,Cl)

To achieve this with mhchem, the sane way would be to use braces around the comma (as mentioned in the comments): {,}. Note that chemformula doesn't require the comma to be escaped and renders the formula correctly "as is":

\documentclass{article}
\usepackage[version=3]{mhchem}
\usepackage{chemmacros}
\chemsetup{
modules = all
}

\begin{document}

\ce{(Ca{,}Mg)CO3} (\texttt{mhchem})

\ch{(Ca,Mg)CO3} (\texttt{chemformula})

\end{document}


References

1. IUPAC “Red Book” Nomenclature of Inorganic Chemistry, 1st ed.; Connelly, N. G., Damhus, T., Hartshorn, R. M., Hutton, A. T., Eds.; IUPAC Recommendations; Royal Society of Chemistry: Cambridge, UK, 2005. ISBN 978-0-85404-438-2. PDF
• Thank you very much ! so easy, and yet haven't found any answer anywhere. Thanks again :) – TheEpok Jan 30 at 16:28