这些重新定义有什么区别?

这些重新定义有什么区别?

在尝试实现自己的titlepage风格时我遇到了一些问题。

具体来说,我试图以不同的风格展示作者(下面的展示案例不限于此,但可以作为示例)。这个想法是通过重复使用宏来提供( )\author的替代品。我让它工作了,但只适用于一些用例,我不明白区别在哪里。titlepage\maketitle\author

案例 A、B、C 的值适用于案例 1-3,但我无法让案例 4 与案例 C 一起使用(A 和 B 有效)。虽然说案例 3 和案例 4 似乎相同似乎是合理的。

我看不到的神奇差别是什么?

\documentclass{article}

\usepackage{Tabbing}
\usepackage{ifthen}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter

\def\tst@au#1\and#2\nil{%
    \edef\test{#2}%
    \ifx\test\@empty One \else More\fi%
}%

\newcommand{\@testAuthor}{%
    \expandafter\tst@au\@author\and\nil%
}

\newcommand{\@prettyPrintAuthor}{%
    \ifthenelse{\equal{\@author}{}}%
    {}%
    {%
        \@printAuthor%
    }%
}%

\newcommand{\@printAuthor}[0]{%
    \protected\def\and{\\ \> \>}%
    \begin{tabbing}%
        XXXX \= XXXX:XX \= XXXXXXXXXXXXXXX \= \kill%
        \> \@testAuthor: \> \@author%
    \end{tabbing}%
}%

\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% case A
%\author{Title First Name}

% case B
%\author{Title First Name \and Title2 First2 Name2}

% case C
\author{\emph{Title} First Name \and \emph{Title2} First2 Name2}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter

% case 1
\begin{tabbing}%
    XXXX \= XXXX:XX \= XXXXXXXXXXXXXXX \= \kill%
    \> More: \> \emph{Title} First Name \\ \> \> \emph{Title2} First2 Name2%
\end{tabbing}%

% case 2
\let\@temp@and\and
\renewcommand\and{\\ \> \>}
\begin{tabbing}%
    XXXX \= XXXX:XX \= XXXXXXXXXXXXXXX \= \kill%
    \> More: \> \emph{Title} First Name \and \emph{Title2} First2 Name2%
\end{tabbing}%
\let\and\@temp@and

% case 3
\protected\def\and{\\ \> \>}%
\begin{tabbing}%
    XXXX \= XXXX:XX \= XXXXXXXXXXXXXXX \= \kill%
    \> More: \> \emph{Title} First Name \and \emph{Title2} First2 Name2%
\end{tabbing}%

% case 4 - this does not work
%\@printAuthor

\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

答案1

\edef在 LaTeX 中使用未知标记永远是不安全的

\def\tst@au#1\and#2\nil{%
    \protected@edef\test{#2}%
    \ifx\test\@empty One \else More\fi%
}%

相关内容