|
1 | 1 | %% authblk.sty - minimal local stub providing \author, \affil, \Authfont, \Affilfont |
2 | | -%% Based on the authblk package by Patrick W. Daly |
| 2 | +%% Based on the authblk package by Patrick W. Daly. |
| 3 | +%% Honors explicit optional-argument affiliation marks, e.g. \author[2]{Name} |
| 4 | +%% and \affil[2]{Address}; falls back to sequential auto-numbering when the |
| 5 | +%% optional argument is omitted. Each mark is expanded at storage time (via |
| 6 | +%% \xdef) so it is fixed per author/affil; multiple \affil entries accumulate |
| 7 | +%% (each on its own line) rather than overwriting one another. |
3 | 8 | \NeedsTeXFormat{LaTeX2e} |
4 | 9 | \ProvidesPackage{authblk}[2001/02/27 1.3 (PWD)] |
5 | 10 | \newcommand\Authfont{\normalfont} |
|
10 | 15 | \newcounter{auth} |
11 | 16 | \newcounter{affil} |
12 | 17 | \newlength{\affilsep}\setlength{\affilsep}{1.5em} |
13 | | -\newif\ifnewaffil \newaffiltrue |
14 | | -\let\AB@authold\author |
| 18 | +\gdef\AB@authors{} |
| 19 | +\gdef\AB@affillist{} |
15 | 20 | \renewcommand\author[2][]{% |
16 | | - \ifnewaffil\addtocounter{affil}{1}% |
17 | | - \edef\AB@affilnote{\theaffil}\newaffilfalse |
18 | | - \fi |
19 | | - \addtocounter{auth}{1}% |
| 21 | + \stepcounter{auth}% |
| 22 | + \edef\AB@mark{#1}% |
| 23 | + \ifx\AB@mark\@empty\edef\AB@mark{\arabic{auth}}\fi |
20 | 24 | \ifnum\theauth=1\relax |
21 | | - \gdef\AB@authors{{\Authfont #2}\textsuperscript{\AB@affilnote}}% |
| 25 | + \xdef\AB@authors{\unexpanded{{\Authfont #2}}\noexpand\textsuperscript{\AB@mark}}% |
22 | 26 | \else |
23 | | - \g@addto@macro\AB@authors{, {\Authfont #2}\textsuperscript{\AB@affilnote}}% |
| 27 | + \xdef\AB@authors{\unexpanded\expandafter{\AB@authors}, \unexpanded{{\Authfont #2}}\noexpand\textsuperscript{\AB@mark}}% |
24 | 28 | \fi |
25 | 29 | } |
26 | 30 | \newcommand\affil[2][]{% |
27 | | - \newaffiltrue |
28 | | - \ifx\\#1\\% |
29 | | - \addtocounter{affil}{1}% |
30 | | - \edef\AB@note{\theaffil}% |
31 | | - \else |
32 | | - \def\AB@note{#1}% |
33 | | - \fi |
| 31 | + \stepcounter{affil}% |
| 32 | + \edef\AB@note{#1}% |
| 33 | + \ifx\AB@note\@empty\edef\AB@note{\arabic{affil}}\fi |
34 | 34 | \ifnum\theaffil=1\relax |
35 | | - \gdef\AB@affillist{\textsuperscript{\AB@note}{\Affilfont #2}}% |
| 35 | + \xdef\AB@affillist{\noexpand\textsuperscript{\AB@note}\unexpanded{{\Affilfont #2}}}% |
36 | 36 | \else |
37 | | - \g@addto@macro\AB@affillist{\\[0.3ex]\textsuperscript{\AB@note}{\Affilfont #2}}% |
| 37 | + \xdef\AB@affillist{\unexpanded\expandafter{\AB@affillist}\unexpanded{\\[0.3ex]}\noexpand\textsuperscript{\AB@note}\unexpanded{{\Affilfont #2}}}% |
38 | 38 | \fi |
39 | 39 | } |
40 | | -\gdef\AB@authors{} |
41 | | -\gdef\AB@affillist{} |
42 | 40 | \renewcommand\@author{% |
43 | 41 | \AB@authors\\[1ex]\AB@affillist |
44 | 42 | } |
0 commit comments