由于某些奇怪的原因,我有一个\ifcase
开始抱怨“额外 \or”但因为\ifcase
可以有许多\or
s,它怎么会有一个“额外”的呢?
它是一个大包的一部分,相关部分已经工作多年,如下所示。它不再像第二个了\or
:
\ifcase\value{uniquename}%
\ifuseprefix
{\usebibmacro{name:family}{#1}{#3}{#5}{}}
{\usebibmacro{name:family}{#1}{#3}{}{}}%
\or
\ifuseprefix
{\usebibmacro{name:given-family}{#1}{#4}{#5}{}}
{\usebibmacro{name:given-family}{#1}{#4}{}{}}%
\or
\ifuseprefix
{\usebibmacro{name:given-family}{#1}{#3}{#5}{}}
{\usebibmacro{name:given-family}{#1}{#3}{}{}}%
\fi
如果我将第二个更改\or
为\else
,则会收到“Extra \else”错误。
答案1
问题在于:
\ifdefvoid #1->\ifundef {#1} {\@firstoftwo } {\ifdefmacro {#1} {\ifdefparam {#1} {\@secondoftwo } {\etb@ifdefempty {#1}}} {\@secondoftwo }}
#1<-
\ifundef #1->\ifdefined #1\ifx #1\relax \expandafter \expandafter \expandafter \@firstoftwo \else \expandafter \expandafter \expandafter \@secondoftwo \fi \else \expandafter \@firstoftwo \fi
#1<-
{\ifdefined: (level 3) entered on line 13}
{true}
{\relax}
{\expandafter}
{\expandafter}
{\else: \ifdefined (level 3) entered on line 13}
{\fi: \ifdefined (level 3) entered on line 13}
{\expandafter}
{\else: \ifcase (level 2) entered on line 13}
{\fi: \ifcase (level 2) entered on line 13}
当\ifdefvoid
被调用时,它会被传递一个空参数,因此下一条指令变成
\ifdefined \ifx\relax \expandafter \expandafter \expandafter \@firstoftwo \else \expandafter \expandafter \expandafter \@secondoftwo \fi \else \expandafter \@firstoftwo \fi
并\ifdefined
看着\ifx
,是已定义,但它也从输入流中移除,因此\fi
原本要匹配它的 匹配了外部的\ifcase
,如
{\else: \ifcase (level 2) entered on line 13}
{\fi: \ifcase (level 2) entered on line 13}
下一个\or
放错了位置。