帮助理解使用 \GenericError 与 \@firstoftwo 和 \@secondoftwo 的宏

帮助理解使用 \GenericError 与 \@firstoftwo 和 \@secondoftwo 的宏

这个答案,@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 源文档):

  1. 延续,
  2. 错误消息,
  3. 在哪里可以获取更多信息,以及
  4. 帮助信息。

因此,使用\@firstoftwo,您将看到由 生成的错误\GenericError

相关内容