I have a command \by{ } that lets me list authors of an article like this:

{author 1}{tagline} \\
{author 2}{tagline} \\
{author 3}{tagline} \\

enter image description here

I would like to store author 1, author 2, author 3, etc. in some sort of list and print that list like this:

author 1 \\
author 2 \\
author 3 \\

I also want to be able to add names manually (i.e. names that are not used in \by). An exaple of this is the name Jane in the MWE.

One important thing is that each name only appears once in the list. If author 1 has written two articles, their name should still only appear once in the printed list of authors.

I also have an environment \mytextbox for displaying this list. However, I do not want to modify this environment to automaticually print authors, because I still want to be able to manually input authors in this environment as a "failsafe" if, for some reason, there should be an error with the automatic list (for example because of a new imported package in the future or another new pice of code). I chose to include this environment in the MWE to ensure that solutions will be compatible with it.


\usepackage{DejaVuSans} % Sans-serif

% mytextbox environment:
\newcommand{\overlaytextbox}[3]{% \placetextbox{<horizontal pos>}{<vertical pos>}{<stuff>}
    \overlaytextbox{0.05}{0.94}{% 0.65 og 0.94 for plassering til høyre

% \by command:
\def\by#1{\vspace{1mm}{\centering\fontsize{7}{10}\sffamily Written by \\}\vspace{5pt}\setbox1=\box0 \setbox1=\box3 \byA\\#1\end}
         \setbox2=\hbox{\unhcopy0 \ \hspace{2mm}{\fontsize{7}{10}\sffamily and} \hspace{2mm} \unhcopy1 \ \hspace{2mm} {\fontsize{7}{10}\sffamily et al.}}
            \setbox3=\hbox{ \unhbox0 \ \hspace{2mm}{\fontsize{7}{10}\sffamily et al.}\hspace{2mm}}
            \setbox0=\hbox{\unhbox0 \ \hspace{2mm}{\fontsize{7}{10}\sffamily and}\hspace{2mm} \unhbox1}
\def\byC{\ifvoid3 \setbox3=\box0 \fi \hbox to\hsize{\hss\box3\hss}\bigskip}


% some command to list authors here:
% for exaple \authorlist
Someone \\
Firstname Lastname \\
Myname is Bond \\
Paul \\
Jane \\

{\centering \sffamily\textbf{First Article}\\}


{\centering \sffamily\textbf{Second Article}\\}
{Firstname Lastname}{Hey ho matey yo ho} \\
{Someone}{New tagline}\\
{Myname is Bond}{Secret Service} \\


{\centering \sffamily\textbf{Third Article}\\}
{Paul}{Still a physicist}


{\centering \sffamily\textbf{Poem}\\}

    foo \\
    baz \\
    baa foo!

Thank you Jane for creating this poem!


How can I do this? Where can I find more information on how to make lists like this in LaTeX? I guess I have to have some sort of if case to check if the author already is on the list?

The only solution I can currently think of would be an expl3 token list and \str_case:nnF{ author }{ {<compare to list element>}{} }{ <add to list> }. However, I think it may not be a good idea to combine expl3 and plain TeX. Also, I'm not entierly sure on how to implement this approach.

1 Answer 1


You can add \addauthor{#1} into the \byB macro (on the top of this macro):


and you can define the macro \addauthor:

\def\addauthor#1{\immediate\write\csname @mainaux\endcsname{\string\xauthor{#1}}}
   \unless \ifcsname xa:#1\endcsname
      \expandafter\gdef\csname xa:#1\endcsname{}
      \expandafter\gdef\expandafter\authorlist\expandafter{\authorlist #1\\}

Finally, you can use \authorlist in your red box because this list includes


after the second run of TeX. We used the .aux file because you want to know \authorlist before authors are read by \by.

If you want to add Jane to the list, you can do this manually in your red box or you can write \addauthor{Jane} after the "foo baz baa foo" poem in the "Thanks" text.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .