
在類別中使用\iupac
inside時出現錯誤:\title
achemso
\documentclass{achemso}
\usepackage{chemmacros}
\title{Study of \iupac{1,2-di|methyl|benzene}}
\begin{document}
\maketitle
\end{document}
這是錯誤:
ABD: EveryShipout initializing macros
! Undefined control sequence.
\l__chemmacros_tmpa_tl ->1,2-
di|methyl|benzene
l.7 \begin{document}
一切看起來都很好article
,或者\iupac
在正文中使用相同的命令而不是在標題中。
答案1
chemmacros
此問題已在v5.11 (2020/03/07)中修復。
achemso
/存在輕微的計時問題chemmacros
。首先achemso
重新定義\begin{document}
添加\maketitle
在最後。然後chemmacros
加載etoolbox
,然後附加\@afterendpreamblehook
到\document
(所以現在\begin{document}
相當於\begin{document}\maketitle\@afterendpreamblehook
)。
問題是\iupac
使多個字元處於活動狀態,這最好不要在序言中完成,因此chemmacros
使用 延遲此活動\AfterEndPreamble
,因此事物只能在 中定義\@afterendpreamblehook
,這樣您就可以看到這是怎麼回事。在使用標題時\maketitle
,使用 有點為時過早\iupac
,儘管可能不應該如此。
透過(可能太)快速查看程式碼,在我看來應該在定義中chemmacros
進行,以便在需要時所有定義都在那裡。\bool_set_true:N \l__chemmacros_in_document_bool
\chemmacros_iupac:nn
有幾種方法可以解決這個問題,但最簡單的方法似乎是交換添加內容的順序\begin{document}
,以便序言在之前「結束」\maketitle
(這可能是一個好主意)。為此,只需etoolbox
在之前加載\documentclass{achemso}
:
\RequirePackage{etoolbox}
\documentclass{achemso}
\usepackage{chemmacros}
\title{Study of \iupac{1,2-di|methyl|benzene}}
\begin{document}
\maketitle
\end{document}