Daily Shaarli

All links of one day in a single page.

June 6, 2025

Typeset redox sum reactions in LaTeX building on `chemmacros`

Reduction-oxidation sum reactions are typically written as two lines (red/ox) with a sum reaction underneath. Here is an example of how to typeset this building on the reactions environment from the awesome chemmacros package.

My goals with this custom environment was to retain chemical reaction numbering (with sub-numbering for the redox reactions) and horizontally align everything on the reaction arrow.

The solution is not automated all the way so may require some fiddling of horizontal or vertical distances to make it look great.

Load chemmacros in the preamble:

\usepackage[
   % *minimal* specifies the following set of always loaded modules:
   % acid-base, charges, nomenclature, particles, phases, symbols
   minimal=true,%
   modules={reactions}%
]{chemmacros}

and define the custom environment I like to call subreactions:

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

I did not come up with that on my own, I got a lot of help and found inspiration in the work of others.

Here is the end result (screenshot from my thesis), the well-known water splitting reaction expressed as hydrogen reduction and water oxidation:

which was created with this code:

\begin{subreactions}\begin{reactions}%
4 \proton{} + 4 \electron{} &-> 2 \hydrogen{} && $\qquad\qquad\qquad\qquad$ \AddRxnDesc{Hydrogen~evolution} \"\label{rxn:hydrogen-evolution}\" \\%
2 \water{} + 4 \hole{} &-> \oxygen{} + 4 \proton{} && $\qquad\qquad\qquad\qquad$ \AddRxnDesc{Oxygen~evolution} \"\label{rxn:oxygen-evolution}\"%
\end{reactions}\end{subreactions}%
\addtocounter{reaction}{-1}%
\vspace{-\baselineskip}%
% note that the following lengths must be adjusted if
% the horizontal extent of any reactions are changed!
\hspace{13mm}%
\begin{minipage}{59mm}%
  \vspace{-\baselineskip}%
  \hrulefill%
\end{minipage}%
\begin{reaction}%
\qquad{}\qquad{}\quad{} 2 \water\lqd{} -> 2 \hydrogen\gas{} + \oxygen\gas{} $\quad\enspace\enspace E^0=\qty{1.23}{\voltNHE}$ \AddRxnDesc{Overall~water~splitting} \"\label{rxn:water-splitting}\"%
\end{reaction}%