Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Trying to implement an own titlepage style I am encountering a few problems.

Specifically I am trying to show the authors in a different style (the show case below is not restricted to \author but works as an example). The idea is to provide a drop in replacement for the titlepage (\maketitle) by reusing the \author macro. I have it working but only for some use cases and I don't understand where the difference is.

The values from the cases A, B, C work with cases 1-3, but I can't get case 4 to work with case C (A & B work). Although it seems reasonable to say the case 3 and case 4 seem to be the same..

What is the magic difference I can't see?

\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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
share|improve this question
2  
Using \edef\test{#2} when #2 contains \emph is surely bound to give problems. Since you're redefining \author anyway, why not using it multiple times, each time adding to a container? Say \def\author#1{\g@addto@macro\@authors{\@doauthor{#1}}}, so that you can execute \@authors giving \@doauthor the meaning you prefer. –  egreg Mar 29 '13 at 11:04
    
Welcome to TeX.SX. –  Claudio Fiandrino Mar 29 '13 at 11:14

1 Answer 1

up vote 7 down vote accepted

It is never safe to use \edef on unknown tokens in LaTeX use

\def\tst@au#1\and#2\nil{%
    \protected@edef\test{#2}%
    \ifx\test\@empty One \else More\fi%
}%
share|improve this answer
    
Great! I've been spnding hours to find the problem and got the answer within minutes. Thanks a lot! P.S.: The code with edef origins from: How to count the number of authors of a document? –  kromo Mar 29 '13 at 11:53
    
@kromo it happens: xkcd.com/386 –  David Carlisle Mar 29 '13 at 11:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.