My google-fu has finally failed me...
I'm trying to write a package that will allow you say \addauthor{name, email} several times and have the title page properly formatted. Here is a minimal example of my troubles:
% FILE: sd.sty
\ProvidesPackage{sd}
\newcounter{authors}
\newcommand{\@authors}{\@empty}
\newcommand{\@authorsnoemail}{\@empty}
\def\addauthor#1{\@addauthor#1\@nil}
\def\@addauthor#1,#2\@nil{%
\expandafter\def\expandafter\@authorsnoemail\expandafter{%
\@authorsnoemail%
\ifnum\value{authors}>0, \fi%
#1}
\expandafter\def\expandafter\@authors\expandafter{\@authors%
\ifnum\value{authors}=0 \else ; \fi%
#1 - #2}
\stepcounter{authors}}
\newcommand{\ane}{\@authorsnoemail}
\newcommand{\auth}{\@authors}
and then I try
% FILE: main.tex
\documentclass{article}
\usepackage{sd}
\addauthor{1, 1@1}
\addauthor{2, 2@2}
\addauthor{3, 3@3}
\begin{document}
\begin{tabular}{ll}
Expected: & 1, 2, 3 \\
Got: & \ane\\
Expected: & 1 - 1@1; 2 - 2@2; 3 - 3@3 \\
Got: & \auth \\
\end{tabular}
\end{document}
And the output is
Expected: 1, 2, 3
Got: , 1, 2, 3
Expected: 1 - 1@1; 2 - 2@2; 3 - 3@3
Got: ; 1 - 1@1; 2 - 2@2; 3 - 3@3
My question is "How can I do the counter comparison properly, so that the divider will only be inserted at the second author and above?"
(I included both lists since for some reason removing one makes it work... I suspect I'm doing something wrong with the \expandafters)



