微量元素

微量元素

在經濟學中,作者順序傳統上是按字母順序排列的。由於這種排序引起的已知偏差,隨機排序論文作者的變動很小(例子)。

我可以在編譯時使用 來對文檔作者進行排序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。
  • 您必須指定文字欄位的高度,因此如果您的作者數量超過一行,您需要手動調整它。如果你真的熱衷的話,這可能會自動化。
  • 當然,它需要 Adob​​e 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}

微波能量輸出

相關內容