0

In trying to answer another question, I would like to split the \author command by author (that is, at each \and) and then for each author give author and affiliation separate fonts---without using the authblk package. I'm trying to wrap my head around an answer to an old question, but can't quite seem to bend it to my will.

The old answer redefines both \author and \@author, which I would like to avoid as I suspect it might be a bad idea. I have managed to avoid redefining \@author by replacing its role with \FPA@author, but I cannot seem to get out of redefining \author. I would have thought that I could just replace (2) below with (1), but to no avail.

Also, I don't understand why \FPA@FormatAuthor doesn't work as intended. I would have thought that the entire affiliation would be in italics and not just the first character... Any hints as to why this is would be much appreciated.

\documentclass{article}
\makeatletter
\usepackage{xpatch}
\renewcommand{\@maketitle}{
  \newpage
  \let \footnote \thanks
  % \let\FPA@tmp\noexpand\split@and\@author\and\@nil  % (1)
  {\flushleft\@title \par}%
  \vskip 1.5em%
  {\flushleft
   \lineskip .5em%
   \FPA@author}
  \vskip 1em%
  {\flushleft \@date}%
  \par
  \vskip 1.5em}
\def\FPA@author{}
\def\split@and#1\and#2{%
  \g@addto@macro\FPA@author{\FPA@FormatAuthor#1\\}%
  \ifx#2\@nil\else
    \expandafter\split@and\expandafter#2\fi
}
\def\author#1{\split@and#1\and\@nil}  % (2)
\def\FPA@FormatAuthor#1\\#2{{\bfseries#1} \\ {\itshape#2}}
\makeatother

\title{On the Origins of the Philosopher's Stone}
\author{Albus Dumbledore\thanks{A footnote} \\ Hogwarts School of Witchcraft and Wizardry, International Confederation of Wizards, and the Wizengamot \and Nicholas Flamel\\Beauxbatons Academy of Magic}
\date{\today}
\begin{document}
  \maketitle
\end{document}

Results thus far

0
1

The following seems to work:

\documentclass{article}
\makeatletter
% \usepackage{xpatch}  % Not actually needed
\renewcommand{\@maketitle}{
  \newpage
  \let \footnote \thanks
  \expandafter\split@and\@author\and\@nil  % (1)
  {\flushleft\@title \par}%
  \vskip 1.5em%
  {\flushleft
   \lineskip .5em%
   \FPA@author}
  \vskip 1em%
  {\flushleft \@date}%
  \par
  \vskip 1.5em}
\def\FPA@author{}
\def\split@and#1\and#2{%
  \g@addto@macro\FPA@author{\FPA@FormatAuthor#1\\}%
  \ifx#2\@nil\else
    \expandafter\split@and\expandafter#2\fi
}
%\def\author#1{\split@and#1\and\@nil}  % (2)
\def\FPA@FormatAuthor#1\\#2\\{{\bfseries#1} \\ {\itshape#2} \\}
\makeatother

\title{On the Origins of the Philosopher's Stone}
\author{Albus Dumbledore\thanks{A footnote} \\ Hogwarts School of Witchcraft and Wizardry, International Confederation of Wizards, and the Wizengamot \and Nicholas Flamel\\ Beauxbatons Academy of Magic}
\date{\today}
\begin{document}
  \maketitle
\end{document}

Not-quite explanations:

  1. The way \split@and is defined if you don't expand \@author first it will never do the recursion. What you want it to do is see ARG1\and ARG2\and ARG3\and @nil and run the recursion to first parse ARG1 and save ARG2\and ARG3\and @nil to pass into the next run. With \@author unexpanded it just sees the entire \@author as ARG1.
    So all you really need is pre-expand \@author using an \expandafter to set it going. (I also removed the \let\FPA@tmp\noexpand since I don't see it anywhere else used; but you can restore it if you need.)

  2. The reason that your italics didn't work is the same reason that if you type \frac{1}12 you will see "1/1" followed by "2" and not "1/12". The way you defined \FPA@FormatAuthor, when you feed it the first author string, it sees it as asking it to process everything up to the \\ as the first argument, and the first token after as the second argument. And the first token after is the first letter of the address. You can force it to read further along by correctly delimiting the second argument too. I used \\ since you seem to only be using single line addresses, and are already using a line break when you called \FPA@FormatAuthor#1\\, but if you want to use line breaks in your addresses, you should probably change the second delimiter to something else and change the call to \FPA@FormatAuthor appropriately.

2
  • Might \empty be a good choice to use as the second delimiter of \FPA@FormatAuthor? – Fredrik P Apr 9 at 7:49
  • 1
    @FredrikP pretty much anything you do not expect to come up in the middle of the \author would work. – Willie Wong Apr 9 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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