ムウェ

ムウェ

経済学では、著者の順序は伝統的にアルファベット順です。この順序によって生じる既知のバイアスにより、論文の著者をランダムに順序付ける動きが少しあります()。

コンパイル時に を使って文書の著者を順序付けすることはできますpgfmathrandomが、これではランダム性が不十分です。著者をビュー時に動的に順序付けしたいのです。LaTeX/PDF で JavaScript 機能を実装する例を見つけることはできませんが、それらは文書の内容を直接調整する処理をしていないため、適用できません ()。

望ましい MWE (\maketitle上書きする必要はありません。その部分は単純です):

 \documentclass{article}

 \usepackage{[magic-package]}

 \addauthor{Aaron}
 \addauthor{Zhang}

 \begin{document}
 \maketitle

 \end{document}

結果は次のようになります:

 +--------------+               +--------------+
 | Aaron, Zhang |               | Zhang, Aaron |
 |              |               |              |
 | Lorem ipsum  | w.p. 1/2,     | Lorem ipsum  | w.p. 1/2.

答え1

ここでは、eformsパッケージ。

これは、ドキュメントを開くときに JavaScript を使用して著者をランダム化し、その結果を、タイトル ページに著者が挿入されるフォーム フィールドに入力します。

ただし、いくつか制限があります:

  • PDF フォームのテキスト フィールドで非標準フォントを使用するのは簡単ではないため、私はどこでも Times を使用しています。
  • テキスト フィールドの高さを指定する必要があるため、著者の数が 1 行を超える場合は手動で調整する必要があります。本当に熱心であれば、これを自動化できる可能性があります。
  • もちろん、Adobe Reader も必要です。

ムウェ

\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}

MWE出力

関連情報