2

I try to make my own macro for a typesetting an authors block instead of using package authblk. How can I suppress separator near the fist author of the article. Main condition is to use only LaTeX kernel, no additional packages. enter image description here

\documentclass[a4paper,12pt]{article}
\makeatletter
\let\@authortofile\@empty
\def\@separator{, }
\def\addauthor#1#2{%
\g@addto@macro\@author{\@separator#1\textsuperscript{#2}}
\g@addto@macro\@authortofile{\@separator#1}
}
\makeatother
\date{}
\title{Title}
\addauthor{One}{1}
\addauthor{Two}{1,2}
\addauthor{Three}{1,2}
\begin{document}
\maketitle
\end{document}
sergiokapone
  • 5,578
  • 1
  • 16
  • 39

2 Answers2

4

The first time you use \addauthor the command redefines itself so in the following it adds \@separator

\def\addauthor#1#2{%
  \g@addto@macro\@author{#1\textsuperscript{#2}}%
  \g@addto@macro\@authortofile{#1}%
  \def\addauthor##1##2{%
    \g@addto@macro\@author{\@separator##1\textsuperscript{##2}}%
    \g@addto@macro\@authortofile{\@separator##1}%
  }
}
Manuel
  • 27,118
3

Delay the use of , once by embedding the definition inside itself:

enter image description here

\documentclass{article}
\makeatletter
\let\@authortofile\@empty
\def\@separator{\def\@separator{, }}% Delay comma once
\def\addauthor#1#2{%
  \g@addto@macro\@author{\@separator#1\textsuperscript{#2}}
  \g@addto@macro\@authortofile{\@separator#1}
}
\makeatother

\date{}
\title{Title}
\addauthor{One}{1}
\addauthor{Two}{1,2}
\addauthor{Three}{1,2}

\begin{document}

\maketitle

\end{document}
Werner
  • 603,163