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}
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}
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}%
  }
}

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.