[Tex/LaTex] Formatting redox reactions with chemmacros and mhchem; arrows aren’t drawn correctly

chemistrychemmacrosmhchem

I'm using the chemmacros package to format redox reactions using its redox module to get the nice arrows that indicate which atoms are changing oxidation state as illustrated in the package manual. I am trying to do something that the manual says is nonstandard and may not work, which is using the mhchem package to format reactions. Nonetheless it works in one simple instance but not another and I'd appreciate any tips to get it working better.

It appears if you have chemmacros draw an arrow with the \redox(a,b) command where a and b are in the same compound, it works fine. But if a and b are in different compounds in the reaction (two formulas separated by a + or an arrow) in the \ce{ a + b -> c + d} reaction, then the chemmacros arrow doesn't quite know where to start.

Here's an example.

\documentclass{article} 
\usepackage[version=4]{mhchem}
\usepackage{chemmacros}
\usechemmodule{redox}
\begin{document}

\ce{\OX{a,Pt}(CH2CH=CH\OX{b,C}(CH2)2) + \OX{c,Fe} + \OX{d,Zn}}\redox(a,b)[draw=red,->]{\small oxidation}
%that above command produces good output

\bigskip

\ce{\OX{a,Pt}(CH2CH=CH\OX{b,C}(CH2)2) + \OX{c,Fe} + \OX{d,Zn}}\redox(a,c)[draw=red,->]{\small oxidation}
%that above command produces bad output

\end{document}

enter image description here

Best Answer

It works if you place \ce inside \OX instead of the other way around:

\documentclass{article} 
\usepackage{chemmacros}
\chemsetup{
  formula = mhchem ,
  modules = redox
}
\begin{document}

\OX{a,\ce{Pt}}\ce{(CH2CH=CH\OX{b,C}(CH2)2) + }\OX{c,\ce{Fe}}\ce{ +}\OX{d,\ce{Zn}}
\redox(a,c)[draw=red,->]{\small oxidation}

\end{document}

This is one of the cases where the “natural” support package chemformula is easier to work with:

\documentclass{article} 
\usepackage{chemmacros}
\chemsetup{
  formula = chemformula ,
  modules = redox
}
\begin{document}

\ch{"\OX{a,Pt}" (CH2CH=CH\OX{b,C}(CH2)2) + "\OX{c,Fe}" + "\OX{d,Zn}"}
\redox(a,c)[draw=red,->]{\small oxidation}

\end{document}