1

In the following MWE, I attempt to use the chemformula and chemmacros packages to typeset a reaction annotated with some math. Why does Reaction 1 compile but Reaction 2 does not?

\documentclass[oneside,11pt]{book}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
  final
]{microtype}
\usepackage[font={sf,small},labelsep=quad,labelfont=sc]{caption}
\usepackage{siunitx}
\usepackage{mathtools}
\usepackage{chemmacros}
\usechemmodule{reactions}
\chemsetup[reactions]{
  before-tag = R,
  tag-open = [,
  tag-close = ]
}
\usepackage{cleveref}

\begin{document}

% Reaction 1
\begin{reactions}
  2 H2O + 2 e- &<=> H2 + 2 OH-&{$E^{\circ}$}
\end{reactions}

% Reaction 2
\begin{reactions}
  2 H2O + 2 e- &<=> H2 + 2 OH-&{$E^{\circ} \approx \SI{-0.83}{\volt}$}
\end{reactions}

\end{document}

mwe

2

Removing the space between E^{\circ} and \approx is sufficient to make the code compilable.

For an in-depth explanation on the role of spaces inside of chemformula's \ch, which is what the reaction environment's body is parsed with unless instructed otherwise, take a look at cgnieder's answer to a related question

enter image description here

\documentclass[oneside,11pt]{book}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
  final
]{microtype}
\usepackage[font={sf,small},labelsep=quad,labelfont=sc]{caption}
\usepackage{siunitx}
\usepackage{mathtools}
\usepackage{chemmacros}
\usechemmodule{reactions}
\chemsetup[reactions]{
  before-tag = R,
  tag-open = [,
  tag-close = ]
}
\usepackage{cleveref}

\begin{document}

\begin{reactions}
  2 H2O + 2 e- &<=> H2 + 2 OH-& $E^{\circ}\approx \SI{-0.83}{\volt}$
\end{reactions}

\end{document}

chemmacros by default loads the chemformula package in order to typeset chemical formulae but also offers the possibility to use other packages such as mhchem (\chemsetup{formula= mhchem}). Since mhchem uses a different parsing mechanism, the space inside the equation is not an issue:

\documentclass[oneside,11pt]{book}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
  final
]{microtype}
\usepackage[font={sf,small},labelsep=quad,labelfont=sc]{caption}
\usepackage{siunitx}
\usepackage{mathtools}
\usepackage{chemmacros}
\usechemmodule{reactions}
\chemsetup[reactions]{
  before-tag = R,
  tag-open = [,
  tag-close = ]
}
\chemsetup{formula= mhchem}
\usepackage{cleveref}

\begin{document}

\begin{reactions}
  2 H2O + 2 e- &<=> H2 + 2 OH-& $E^{\circ} \approx \SI{-0.83}{\volt}$
\end{reactions}

\end{document}
2
  • There is also math escaping (which inserts a small amount of space after the math per default, though). The real problem is the space between {\circ} and \approx. It is hidden in your solution by the outer pair of braces… Without it `"..." also fails unless the space is removed. See here for example: tex.stackexchange.com/a/392693
    – cgnieder
    Dec 30 '20 at 9:35
  • @cgnieder: I've updated my answer accordingly.
    – leandriis
    Dec 31 '20 at 17:12

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.