6

An argument error is thrown when I attempt to use thermodynamic states (as well as custom state variables via \DeclareChemState) in chemmacros's reactions environment.

The MWE provided at the end of the question will reproduce the following error upon (at the time of this question) typesetting with the most updated version of TeX Live 2012.

The error:

[...] Argument of \chemformula_superscript:n has an extra }.
<inserted text>
                \par
l.8 \end{reactions}

The MWE:

\documentclass[12pt]{article}
\usepackage{chemmacros}
\DeclareChemState[delta=false]{StdElPot}{E}{\volt}
\begin{document}
\begin{reactions}
Pd\pch[2]\aq{} + 2 \el{} &<=> Pd\sld{} &&\StdElPot{0.83} \\
PdCl4\mch[2]\aq{} + 2 \el{} &<=> Pd\sld{} + 4 Cl\mch\aq{} &&\StdElPot{0.64}
\end{reactions}
\end{document}
4

The \ch{} command treats numbers in its input as subscripts before a command expands. Quoting the chemformula manual:

Commands are allowed in a compound [...] However, if the commands demand numbers as argument, e.g., [...][\hspace{}] the direct use will fail. This is because the numbers are treated as subscripts before the command expands.

This also holds for \StdElPot. chemmacros - or rather the chemformula package that does the parsing of the formulae - has a way out: input can be escaped by putting it between '...' or "...".

If you put something between " " or ' ' then the input will be treated as normal text [...]

The preferred syntax for your example would look as follows:

\documentclass[12pt]{article}
\usepackage{chemmacros}
\chemsetup{
  modules={reactions,thermodynamics}
}

\NewChemState\StdElPot{
  symbol=E , subscript-pos=right , pre = , unit=\volt
}

\begin{document}

\begin{reactions}
 Pd^2+ \aq{}    + 2 e- &<=> Pd\sld{}               && "\StdElPot{0.83}" \\
 PdCl4^2- \aq{} + 2 e- &<=> Pd\sld{} + 4 Cl- \aq{} && "\StdElPot{0.64}"
\end{reactions}

\end{document}

enter image description here

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.