I have a command \by{ }
that lets me list authors of an article like this:
\by{
{author 1}{tagline} \\
{author 2}{tagline} \\
{author 3}{tagline} \\
<etc.>
}
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 \\
<etc.>
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.
MWE:
\RequirePackage{fix-cm}
\documentclass[fontsize=13pt,paper=a4,openany,parskip=half,DIV=calc]{scrbook}
\usepackage[T1]{fontenc}
\usepackage{DejaVuSans} % Sans-serif
\usepackage{lipsum}
% mytextbox environment:
\RequirePackage{eso-pic}
\newcommand{\overlaytextbox}[3]{% \placetextbox{<horizontal pos>}{<vertical pos>}{<stuff>}
\AddToShipoutPictureFG*{%
\put(\LenToUnit{#1\paperwidth},%
\LenToUnit{#2\paperheight}){\vtop{{\null}\parbox{0.3\textwidth}{#3}}}
}%
}%
\newcommand{\mytextbox}[2][black]{%
\overlaytextbox{0.05}{0.94}{% 0.65 og 0.94 for plassering til høyre
\color{#1}
\subsubsection*{Authors}%
%\vspace{3mm}%
\linespread{1.6}\selectfont
{\itshape
#2
}%
}%
}%
% \by command:
\def\by#1{\vspace{1mm}{\centering\fontsize{7}{10}\sffamily Written by \\}\vspace{5pt}\setbox1=\box0 \setbox1=\box3 \byA\\#1\end}
\def\byA#1{\ifx\end#1\expandafter\byC
\else
\expandafter\byB
\fi
}
\def\byB#1#2{%
\ifvoid3
\setbox1=\hbox{\makebox{\vtop{\halign{\hfil##\hfil\cr{\fontsize{9}{11}\sffamily\MakeUppercase{#1}}\vspace{-5pt}\cr{\fontsize{7}{10}\sffamily#2}\cr}}}}%
\ifvoid0\setbox0=\box1
\else
\setbox2=\hbox{\unhcopy0 \ \hspace{2mm}{\fontsize{7}{10}\sffamily and} \hspace{2mm} \unhcopy1 \ \hspace{2mm} {\fontsize{7}{10}\sffamily et al.}}
\ifdim\wd2>\hsize
\setbox3=\hbox{ \unhbox0 \ \hspace{2mm}{\fontsize{7}{10}\sffamily et al.}\hspace{2mm}}
\else
\setbox0=\hbox{\unhbox0 \ \hspace{2mm}{\fontsize{7}{10}\sffamily and}\hspace{2mm} \unhbox1}
\fi
\fi
\fi
\byA
}
\def\byC{\ifvoid3 \setbox3=\box0 \fi \hbox to\hsize{\hss\box3\hss}\bigskip}
\begin{document}
\hfill
\begin{minipage}[t]{0.6\textwidth}
\begin{center}
\lipsum[1-2]
\end{center}
\end{minipage}
\mytextbox[red]{
% some command to list authors here:
% for exaple \authorlist
Someone \\
Firstname Lastname \\
Myname is Bond \\
Paul \\
Jane \\
}
\clearpage
{\centering \sffamily\textbf{First Article}\\}
\by{
{Someone}{Tagline}
}
\lipsum[1]
{\centering \sffamily\textbf{Second Article}\\}
\by{
{Firstname Lastname}{Hey ho matey yo ho} \\
{Someone}{New tagline}\\
{Myname is Bond}{Secret Service} \\
{Paul}{Physicist}
}
\lipsum[1]
{\centering \sffamily\textbf{Third Article}\\}
\by{
{Paul}{Still a physicist}
}
\lipsum[1]
{\centering \sffamily\textbf{Poem}\\}
\begin{center}
foo \\
baz \\
baa foo!
\end{center}
Thank you Jane for creating this poem!
\end{document}
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.