TransWikia.com

Reaction annotation with math using chemformula and chemmacros packages

TeX - LaTeX Asked on February 21, 2021

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

One Answer

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}

Answered by leandriis on February 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP