On Mathematica 13 or later version, the ChemicalFormula
and ChemicalReaction
functions helpe a lot to deal with chemical formula in Mathematica, but there are still a lot limits as compared to the Chemmacros
of LaTeX.
For example, if there is need to make plot label to as it is in LaTeX:
$$\ch{H2O}=\ch{H2}+\ch{O2}$$
How should I do? I tried to do this in Mathematica:
Plot[Sin[x], {x, 1, 5},
PlotLabel ->
ChemicalFormula["H2O"]["Formula"] <> "=" <>
ChemicalFormula["H2"]["Formula"] <> "+" <>
ChemicalFormula["O2"]["Formula"]]
But the output is
Deleting the <>
will cause this wrong output:
Of course, they are all wrong.
\usepackage{chemmacros}
it gives errors. So I usedmhchem
$\endgroup$\ce
should be\ch
, and I changed them now. $\endgroup$