With xparse it's pretty easy to split a list at each occurrence of a token. In my MWE I set up a new command \mylist in which I passes two names separated by \and. The xparse script splits the list at the \and token and outputs the two names under each other.
Is there a possibility to use this script with the \@author macro. I'd like to print the authors passed to \author{} one after the other in the \maketitle command. To make sure that LaTeX can normally use the author-command where I used to, I don't want to use the example code (underneath the MWE).
MWE
\documentclass{article}
\usepackage{xparse}
\NewDocumentCommand\mylist{>{\SplitList{\and}}m}
{
\ProcessList{#1}{\insertitem}
}
\newcommand\insertitem[1]{#1\\}
\begin{document}
\noindent \emph{Authors:}\\
\mylist{John Doe \and Jane Doe}
\end{document}
Author Example
...
\RenewDocumentCommand\author{>{\SplitList{\and}}m}
...
\author{John Doe \and Jane Doe}
...
Count
I have set up a counter and add 1 for every item, so at the end I know how many authors were passed to the list. I then check with a conditional if the value of the counter is greater than 1. With this I could decide if Author or Authors should be output before the names. This does not work at the moment because I need the result before the array is defined. If I could use the default LaTeX \author command, this problem would not occur, because the \author command is populated in the preamble. Then the \maketitle shoulr prints out the authors as shown in the MWE.
\documentclass{article}
\usepackage{xparse}
\RenewDocumentCommand\author{>{\SplitList{\and}}m}
{
\ProcessList{#1}{\insertitem}
}
\newcounter{numberOfAuthors}
\newcommand\insertitem[1]{%
#1%
\newline%
\addtocounter{numberOfAuthors}{1}
}
\makeatletter
\newcommand\checkIfGreatherThan{%
\ifnum\c@numberOfAuthors>1
\noindent There are \thenumberOfAuthors\ authors given. The output should be \emph{Authors:}
\else
\noindent There is only one author given. The output should be \emph{Author:}
\fi}
\makeatother
\begin{document}
\noindent \emph{Authors:}\\
% uncomment one of the two commands to test
% \author{John Doe \and Jane Doe}
% \author{John Doe}
\checkIfGreatherThan
\end{document}



\begin{flushright}and with a right-alignedtabularxenvironment, but neither of them worked. Thank you very much in advance! PS: I need your code for the\authorcommand and for a self defined\supervisorcommand. The authors should be left aligned and the supervisors right aligned, so the alignment shouldn't be hard coded to the script. It would be better if the output would respect theflushrightenvironment. – Sam Sep 17 '17 at 20:13\NewDocumentCommand{\displayauthorhead},\NewDocumentCommand{\displayauthorshead}and\newcommand\insertitemand replaced it by\newline. I now reverted it back to the empty line and it works fine. Is there a more clean solution than an empty line? I tried with\\which resulted in over 100 errors in my case... – Sam Sep 19 '17 at 14:44\linebreakdid the job. – Sam Sep 19 '17 at 15:01\newlineand\linebreakare means of last resort only. An empty line is the correct trigger for TeX to ship out a new paragraph – Sep 20 '17 at 20:39