2

What is the best way of implementing Certified Random coauthors in LaTeX. There is one potential implementation from the comp.text.tex usenet group that uses perltex and can be modified as follows:

\usepackage{perltex}

\perlnewcommand{\shuffleauthors}[1]{
@authlist = split /\\.*?\{c\}/, $_[0];
foreach (1 .. 3) {
foreach $i (0 .. $#authlist) {
$r = int(rand(@authlist));
($authlist[$i], $authlist[$r]) = ($authlist[$r], $authlist[$i]);
}
}
return join(" \\textcircled{r} ", @authlist);
}

\title{Test of Random Authors}
\author{\shuffleauthors{Arthur Won \and Ardur Tu \and Auzer Trea}}

\begin{document}
\maketitle

\end{document}

Unfortunately \thanks footnotes do not work in this implementation and I'm not enough of a latex coder to get it to work. Moreover, the ideal implementation would not require perltex.

5
  • 1
    isn't it better to do this in your editor to arrange a fixed but random order in the source? If the order changed every time you process the source file citing the paper from elsewhere would be almost impossible. Commented Mar 31, 2019 at 13:22
  • Yes, I hadn't completely thought this through. Although, would it be the worst thing in the world if citations were also at random? It bears some further thought.
    – zoof
    Commented Mar 31, 2019 at 16:58
  • You need a stable list of authors post publication so that citation indices etc can work. Commented Mar 31, 2019 at 17:05
  • Yes, of course upon publication, it would have to be fixed.
    – zoof
    Commented Mar 31, 2019 at 17:23
  • but it is often useful to re-create the document after you submit so you would need a way to fix the random seed so that you got the same list. Commented Mar 31, 2019 at 17:48

1 Answer 1

2

You can use expl3:

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\shuffleauthors}{m}
 {
  \seq_set_split:Nnn \l_tedto_shuffle_authors_seq { \and } { #1 }
  \seq_shuffle:N \l_tedto_shuffle_authors_seq
  \seq_use:Nn \l_tedto_shuffle_authors_seq { \and }
 }
\seq_new:N \l_tedto_shuffle_authors_seq
\ExplSyntaxOff

\begin{document}

\title{Test of Random Authors}
\author{\shuffleauthors{%
  Arthur Won\thanks{Supported by somebody} \and Ardur Tu \and Auzer Trea%
}}

\maketitle

\end{document}

enter image description here

If you want to add \textcirled{r} after every author, you have to modify the behavior of \thanks that typesets the mark in a zero width box.

\documentclass{article}
\usepackage{xparse,etoolbox}

\patchcmd{\maketitle}{\rlap}{\mbox}{}{} % we want \thanks not to occupy zero width

\ExplSyntaxOn

\NewDocumentCommand{\shuffleauthors}{m}
 {
  \seq_set_split:Nnn \l_tedto_shuffle_authors_seq { \and } { #1 }
  \seq_shuffle:N \l_tedto_shuffle_authors_seq
  \seq_use:Nn \l_tedto_shuffle_authors_seq { \,\textcircled{r}\and }
  \,\textcircled{r}
 }
\seq_new:N \l_tedto_shuffle_authors_seq

% fix the seed
\sys_gset_rand_seed:n { 42 }

\ExplSyntaxOff

\begin{document}

\title{Test of Random Authors}
\author{\shuffleauthors{%
  Arthur Won\thanks{Supported by somebody} \and Ardur Tu \and Auzer Trea%
}}

\maketitle

\end{document}

I also added how to ensure constant typesetting, by setting a seed.

enter image description here

10
  • I suppose to have the \and use ` \textcircled{r} ` means rewriting the \author command.
    – zoof
    Commented Mar 31, 2019 at 17:02
  • I'm not sure what the problem is but a direct copy of your code is giving me Undefined control sequence. \maketitle. I'm using texlive/pdflatex on a Debian Stretch system.
    – zoof
    Commented Mar 31, 2019 at 17:21
  • @TedTo Quite likely, your TeX distribution is not up-to-date.
    – egreg
    Commented Mar 31, 2019 at 19:08
  • texlive 2016.20170123-5.
    – zoof
    Commented Mar 31, 2019 at 20:26
  • @TedTo Definitely outdated.
    – egreg
    Commented Mar 31, 2019 at 20:27

You must log in to answer this question.

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