For a beamer presentation I want to apply the nice chemformula package. I now wish to have only the coefficients colored individually, for example marking the first coefficient in blue:

\ch{\color{blue}106 CO2 + 122 H2O + 16 HNO3 + H3PO4 -> (CH2O)106 + (NH3)16(H3PO4) + 138 O2}

As soon as I include the \color command (as explained in the chemformula manual), the coefficient becomes a subscript. I also tried

\ch{ \textcolor{blue}{106} CO2 + 122 H2O + ...,

which generates the same result. The equation looks fine when I omit any attempt coloring the coefficients. What am I missing here? I assume that there is a very simple solution to this problem. Any advice is much appreciated, thanks. Markus


A stoichiometric factor may only contain numbers and the signs . ,_ /().

As alternative you might prevent chemformula from parsing the input, for example using \ch{"⟨escaped text⟩"}

Compounds are more straightforward. (Third formula)




        \ch{106 CO2 + 122 H2O + 16 HNO3 + H3PO4 -> (CH2O)106 + (NH3)16(H3PO4) + 138 O2}\bigskip     
        \ch{"\color{blue}" 106}\ch{CO2 + 122 H2O + 16 HNO3 + H3PO4 -> (CH2O)106 + (NH3)16(H3PO4) + 138 O2}\bigskip
        \ch{106 \color{red}CO2 + 122 H2O + 16 HNO3 + H3PO4 -> (CH2O)106 + (NH3)16(H3PO4) + 138 O2}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.