在这个答案,@UlrichDiez 创建了一个宏\InnerCreateTheorem
,如下:
\NewDocumentCommand{\InnerCreateTheorem}{mmmod<>}{%
% #1 = star or no star
% #2 = name of environment
% #3 = emptiness or star to append to name of environment
% #4 = numbered like
% #5 = numbered within
\IfBooleanTF{#1}{%
\IfValueTF{#4}{\@firstoftwo}{\IfValueTF{#5}{\@firstoftwo}{\@secondoftwo}}%
}{\IfValueTF{#4}{\IfValueTF{#5}{\@firstoftwo}{\@secondoftwo}}{\@secondoftwo}}%
{%
\GenericError{}%
{\string\CreateTheorem\space syntax error\on@line}%
{You cannot call the starred variant with optional arguments.\MessageBreak
You cannot call the unstarred variant with several optional arguments.}%
{%
Allowed usage:\MessageBreak\MessageBreak
\CreateTheorem*{(name of environment)}\MessageBreak
\CreateTheorem{(name of environment)}[(numbered like)]\MessageBreak
\CreateTheorem{(name of environment)}<(numbered within)>\MessageBreak
\CreateTheorem{(name of environment)}\MessageBreak
Captions come from macros \string\(name of environment)nameEN\MessageBreak
respective \string\(name of environment)nameFR.\MessageBreak
These macros must be defined separately.%
}%
}{%
%% ...
}%
}%
然而,我对此感到困惑。据我了解(根据这个问题),\@firstoftwo
对应于{\GenericError ...}
并且\@secondoftwo
对应于{%%...}
。但\GenericError
似乎有四种情况,那么每种情况会在什么情况下出现?
答案1
GenericError
确实需要四个参数,但它们并没有确定发出错误的四种不同情况。相反,四个参数表示(部分ltxerror.dtx
;参见LaTeX2e 源文档):
- 延续,
- 错误消息,
- 在哪里可以获取更多信息,以及
- 帮助信息。
因此,使用\@firstoftwo
,您将看到由 生成的错误\GenericError
。