4

I'm getting an error when using \iupac inside \title with the achemso class:

\documentclass{achemso}
\usepackage{chemmacros}

\title{Study of \iupac{1,2-di|methyl|benzene}}

\begin{document}
\maketitle
\end{document}

This is the error:

ABD: EveryShipout initializing macros
! Undefined control sequence.
\l__chemmacros_tmpa_tl ->1,2-
                             di|methyl|benzene
l.7 \begin{document}

Everything looks good with article, or with the same \iupac command in the body and not in the title.

1
4
+50

This is fixed in chemmacros v5.11 (2020/03/07).


There is a slight timing issue with achemso/chemmacros. First achemso redefines \begin{document} to add \maketitle at the end. Then chemmacros loads etoolbox, which then appends \@afterendpreamblehook to \document (so now \begin{document} is equivalent to \begin{document}\maketitle\@afterendpreamblehook).

The problem is that \iupac makes several characters active, and this is best not done in the preamble, so chemmacros delays this making-active with \AfterEndPreamble, so things only get their definition in \@afterendpreamblehook, so you can see where this is going. At the time the title is used, in \maketitle, it is a bit too early to use \iupac, though it probably shouldn't be.

With a (probably too) quick view of the code, it seems to me that chemmacros should do \bool_set_true:N \l__chemmacros_in_document_bool in the definition of \chemmacros_iupac:nn so that all definitions are there when needed.

There are a few ways you can work around this, but the easiest one seems to swap the order that things get added to \begin{document}, so that the preamble "ends" before \maketitle (which is probably a good idea). To do that, just load etoolbox before \documentclass{achemso}:

\RequirePackage{etoolbox}
\documentclass{achemso}
\usepackage{chemmacros}

\title{Study of \iupac{1,2-di|methyl|benzene}}

\begin{document}
\maketitle
\end{document}

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.