Here's an option using the eforms package.
It randomises the authors at document opening time using JavaScript and puts the result in a form field where the author is normally inserted in the title page.
There are some limitations though:
- It's not really easy to use a non-standard font in PDF form text fields, so I've use Times everywhere.
- You have to specify the height of the text field, so if your number of authors exceeds one line you'll need to adjust it manually. This could probably be automated if you were really keen.
- And of course, it requires Adobe Reader.
MWE
\documentclass{article}
\usepackage{newtxtext,newtxmath}
\usepackage[useui]{eforms}
\newcommand{\randauthorformat}{%
border={invisible},
textsize={11.5},
textfont={Times-Roman},
align={centered},
fieldflags={readonly,multiline,noscrolling},
% Default value for readers that don't support JavaScript
value={Author One, Author Two, Author Three, and Author Four},
pageopen={%
% Add authors to array
var array = ["Author One", "Author Two", "Author Three", "Author Four"];
% Shuffling algorithm from https://stackoverflow.com/a/2450976/12652399
var currentIndex = array.length, temporaryValue, randomIndex;
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
var i = array.length;
currentIndex = 0;
var authors = "";
while (currentIndex < array.length) {
authors += array[currentIndex];
if (currentIndex < array.length - 1) {
authors += ", ";
}
if (currentIndex == array.length - 2) {
authors += "and ";
}
currentIndex += 1;
}
var f = this.getField("author");
f.value = authors;
}
}
\newcommand{\randauthor}{%
\textField[\ui{presets=\randauthorformat}]{author}{\linewidth}{11.5pt}}
\title{Randomised Authors}
\author{\randauthor}
\begin{document}
\maketitle
\end{document}
