4

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}

\begin{equation}
1 + 3 = 4
\end{equation}

\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.

  • 1
    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 \begin{equation} \ch{A + B -> C + D} \end{equation}. – clemens Sep 16 '15 at 10:03
  • The whole purpose of the reaction environment is to have independent numbering. – clemens 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! – Schewerle Sep 16 '15 at 10:18
  • This is (roughly speaking) what the reaction environment is: an equation with the contents wrapped in \ch. – clemens Sep 16 '15 at 10:29
2

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

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

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

\documentclass{scrartcl}
\usepackage{chemmacros}

\begin{document}

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

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

\begin{equation}
  1 + 3 = 4
\end{equation}

\end{document}

enter image description here

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}
  {\begin{equation}\expandafter\ch\expandafter{\BODY}\end{equation}}
\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}

\begin{equation}
  1 + 3 = 4
\end{equation}

\end{document}

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.