# Numbering of chemmacros reaction change to same numbering as equation

Is there an option of chemmacros to change the numbering of the reaction environment to the same numbering as the equation environment?

It looks a bit confusing if an equation follows a reaction directly and the numbering of the first is higher than the numbering of the last.

\documentclass{scrartcl}
\usepackage{chemmacros}

\begin{document}

\begin{reaction}
A + B -> C + D
\end{reaction}

\begin{reaction}
A + B -> C + D
\end{reaction}

$$1 + 3 = 4$$

\end{document}


I already managed to solve this by changing the chemmacros.sty, but I think this is a really dirty solution.

I would prefer a solution directly in the document.

• Welcome to TeX - LaTeX! Do you want equations and reactions to share the same counter? If yes then just don't use the reaction environment and use $$\ch{A + B -> C + D}$$. Sep 16 '15 at 10:03
• The whole purpose of the reaction environment is to have independent numbering. Sep 16 '15 at 10:04
• Ok, thanks a lot! Much trouble easy solved! I was not aware that I can put a whole reaction in \ch! Sep 16 '15 at 10:18
• This is (roughly speaking) what the reaction environment is: an equation with the contents wrapped in \ch. Sep 16 '15 at 10:29

The whole purpose of the reaction environment is to have independent numbering for displayed reactions. If you want the same numbering for displayed reactions and equations you can simply use

$$\ch{ A + B -> C + D }$$


Under the hood this is what the reaction environment does after all.

\documentclass{scrartcl}
\usepackage{chemmacros}

\begin{document}

$$\ch{ A + B -> C + D }$$

$$\ch{ A + B -> C + D }$$

$$1 + 3 = 4$$

\end{document}


If you want to use a reaction environment the easiest solution would be to redefine it to just do the above (the following example contains code to make the example works with older and newer versions of chemmacros):

\documentclass{scrartcl}
\usepackage{chemmacros,environ}

% in older versions there is no \IfChemCompatibilityT
\providecommand\IfChemCompatibilityT[3]{}

% load the reactions' module in newer versions:
\IfChemCompatibilityT{>=}{5.0}{
\usechemmodule{reactions}
}

% redefine the environments:
\RenewEnviron{reaction}
{$$\expandafter\ch\expandafter{\BODY}$$}
\RenewEnviron{reaction*}
{\begin{equation*}$$\expandafter\ch\expandafter{\BODY}$$\end{equation*}}
\RenewEnviron{reactions}
{\begin{align}$$\expandafter\ch\expandafter{\BODY}$$\end{align}}
\RenewEnviron{reactions*}
{\begin{align*}$$\expandafter\ch\expandafter{\BODY}$$\end{align*}}

\begin{document}

\begin{reaction}
A + B -> C + D
\end{reaction}

\begin{reactions}
A + B &-> C + D \\
E + F &<=> G
\end{reactions}

$$1 + 3 = 4$$

\end{document}
`