2

I found this question: Authblk for chapters? - Author and affiliations per chapter which defines a very nice framework for including author affiliations in chapters in a TeX document. I want to tweak it slightly, to allow the optional inclusion of more than one affiliation per author.

I managed to do it by defining \chapterauthormulti like so:

\makeatletter
\def\chapterauthormulti[#1][#2]#3{\ifnewauthor\sffamily\else, \fi
       #3\textsuperscript{\hyperref[authaffil\the\value{chapter}.#1]{#1},}%
         \textsuperscript{\hyperref[authaffil\the\value{chapter}.#2]{#2}}%
       \ifnewauthor\newauthorfalse\gdef\chapterauthors{#2}\else
               \g@addto@macro\chapterauthors{, #2}\fi
       \ifnewauthor\newauthorfalse\gdef\chapterauthors{#2}\else
               \g@addto@macro\chapterauthors{, #3}\fi
       \ignorespaces % to remove end of line spaces from
                     % \chapterauthor[foo]{bar} input lines
}
\makeatother

which allows me to add up to 2 affiliations and can be generalized in a straightforward is bulky way to more. This works, but seems very inelegant. Is there a cleaner way to modify that example to allow an arbitrary (within reason) number of affiliations to be added to each author in a single definition?

KBriggs
  • 527

1 Answers1

1

I'm not sure I'm 100% sure what you're looking for. But if I understand correctly, you can use a comma separated list.

First

\usepackage{etoolbox}

Next, taking the code from your linked answer, modify the definition of \chapterauthor

\makeatletter
\def\chapterauthor[#1]#2{\ifnewauthor\else, \fi
   #2\affilscripts{#1}%<- Change is here
   \ifnewauthor\newauthorfalse\gdef\chapterauthors{#2}\else
           \g@addto@macro\chapterauthors{, #2}\fi
   \ignorespaces
}
\makeatother

Then write a separate macro \affilscripts to print the superscripts

\newcommand{\affilscripts}[1]{%
  \let\supsep\relax
  \ifundef{\do}{\newcommand{\do}[1]{}}{}%
  \renewcommand*{\do}[1]{%
    \textsuperscript{\supsep%
     \hyperref[authaffil\the\value{chapter}.##1]
      {##1}}\def\supsep{,~}}%
  \docsvlist{#1}%
}

(Incidentally -- there's something odd here. It shouldn't need the \ifundef{}{}{}, but for some reason that I couldn't be bothered to track down, I was receiving "complaints" about \do being undefined, which I had to silence. It does no harm, but it's ugly. I'm probably messing up groups or something, as I often do.)

Then, say

\chapterauthor[1,2]{Jane Doe}

Will produce "Jane Doe" with superscript "1, 2", hyperlinked to the list of affiliations. You can have as many as you want.

KBriggs
  • 527
Paul Stanley
  • 18,151