[Tex/LaTex] authblk footnote marks before/atop commas

authblkfootnotespunctuationtitles

The authblk package, in footnoted mode, puts footnote marks inside commas ("Alice1,") which is bad typography. Is there any way to persuade it to put the footnote marks outside the commas ("Alice,1"), or even better, on top of them?

Example:

\documentclass{article}
\usepackage{authblk}
\begin{document}
\title{A Demonstration of Bad Punctuation Placement}
\author[1]{Alice}
\author[2]{Bob}
\author[3]{Peggy}
\author[4]{Trent}
\affil[1]{}\affil[2]{}\affil[3]{}\affil[4]{}
\date{}
\maketitle

Better: $\mbox{Alice,}^1$ $\mbox{Bob,}^2$ $\mbox{Peggy,}^3$
and $\mbox{Trent}^4$

Even better: $\mbox{Alice\rlap{,}}^1$ $\mbox{Bob\rlap{,}}^2$
$\mbox{Peggy\rlap{,}}^3$ and $\mbox{Trent}^4$

\end{document}

(Ignore everything but the "Alice, Bob, Peggy, Trent" lines.)

Best Answer

It is actually easier to obtain the "even better" output, if you're willing to accept some spacing adjustments:

enter image description here

\documentclass{article}
\usepackage{authblk}% http://ctan.org/pkg/authblk
\makeatletter
\renewcommand\AB@authnote[1]{\rlap{\textsuperscript{\normalfont#1}}}
\renewcommand\Authsep{,~\,}
\renewcommand\Authands{,~\,and }
\makeatother
\begin{document}
\title{A Demonstration of Bad Punctuation Placement}
\author[1]{Alice}
\author[2]{Bob}
\author[3]{Peggy}
\author[4]{Trent}
\affil[1]{}\affil[2]{}\affil[3]{}\affil[4]{}
\date{}
\maketitle

Better: $\mbox{Alice,}^1$ $\mbox{Bob,}^2$ $\mbox{Peggy,}^3$
and $\mbox{Trent}^4$

Even better: $\mbox{Alice\rlap{,}}^1$ $\mbox{Bob\rlap{,}}^2$
$\mbox{Peggy\rlap{,}}^3$ and $\mbox{Trent}^4$

\end{document}

The \AB@authnote is first set, followed by \Authsep or \Authands, depending on whether you're the last author or not. The renewal of \AB@authnote to now have a right overlap (\rlap) causes the authors to be a little too condensed, which is corrected using a ,~\, and/or ,~\,and spacing.