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

Craig
  • 21

1 Answers1

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}
Craig
  • 21