1

I would like to use something like subequations within the reactions environment provided by chemmacros. Something like this:

A -> B {1a}

B -> C {1b}

C -> D {1c}

This doesn't work:

\documentclass{article}

\usepackage{chemmacros}

\chemsetup{modules=reactions}
\chemsetup{formula=mhchem}

\begin{document}

\begin{subequations}
\begin{reactions}
A &-> B \\
B &-> C \\
C &-> D
\end{reactions}
\end{subequations}

\end{document}

Is there any way to do this with chemmacro? Thanks

  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – TonioElGringo Mar 1 '17 at 14:10
  • What do you mean when you say "This doesn't work" ? It seems to do exactly what you want. – TonioElGringo Mar 1 '17 at 14:11
  • Sorry, I edited it to make it a MWE. This example labels the reactions {1}, {2}, {3}. Not {1a}, {1b}, {1c} – Craig Mar 1 '17 at 14:21
1

I managed to figure it out. You have to create a new environment subreactions based on the subequations environment that uses reaction instead of equation as the counter and thereaction instead of theequation as the tag:

\documentclass{article}

\usepackage{chemmacros}
\usepackage{amsmath}


\chemsetup{modules=reactions}
\chemsetup{formula=mhchem}

\makeatletter
\@ifundefined{ignorespacesafterend}{\def\ignorespacesafterend{\global\@ignoretrue}}{}
\newenvironment{subreactions}{%
  \refstepcounter{reaction}%
  \protected@edef\theparentequation{\thereaction}%
  \setcounter{parentequation}{\value{reaction}}%
  \setcounter{reaction}{0}%
  \def\thereaction{\theparentequation\alph{reaction}}%
  \ignorespaces
}{%
  \setcounter{reaction}{\value{parentequation}}%
  \ignorespacesafterend
}
\makeatother


\begin{document}

\begin{subequations}
\begin{align}
A &= B \\
B &= C \\
C &= D
\end{align}
\end{subequations}

\begin{subreactions}
\begin{reactions}
A &-> B \\
B &-> C \\
C &-> D
\end{reactions}
\end{subreactions}

\begin{subequations}
\begin{align}
A &= B \\
B &= C \\
C &= D
\end{align}
\end{subequations}

\begin{subreactions}
\begin{reactions}
A &-> B \\
B &-> C \\
C &-> D
\end{reactions}
\end{subreactions}

\end{document}
  • You can safely remove the \@ifundefined{ignorespacesafterend} line. – egreg Mar 1 '17 at 21:22

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.