revtex4-1
我基本上是在尝试使用文档datatool
中的包重建作者环境scrartcl
。这样做的目的是最终能够从 .csv 文件中读取大量作者列表,然后在我的scrartcl
文档中自动正确格式化它,该文档出于各种其他原因使用 KOMA 脚本。
到目前为止,这就是我所得到的:
\documentclass{scrartcl}
\usepackage{datatool}
%% DEFINE THE AUTHOR DATABASE
\DTLnewdb{longauthors}
\newcommand*{\longauthor}[3]{%
\DTLnewrow{longauthors}%
\DTLnewdbentry{longauthors}{name}{#1}%
\DTLnewdbentry{longauthors}{affiliation}{#2}%
\DTLnewdbentry{longauthors}{email}{#3}%
}
%% ADD THE AUTHORS
\longauthor{A.N. AUTHOR}{Organization}{Email: [email protected]}
\longauthor{A.N. OTHER-AUTHOR}{Other-Organization}{}
\longauthor{A. THIRD-AUTHOR}{Other-Organization}{}
%% GET UNIQUE AFFILIATIONS
\newcommand*{\uniqueaffils}{}
\DTLforeach*{longauthors}{\name=name,\affil=affiliation,\email=email}{%
\DTLifSubString{\uniqueaffils}{\affil}%
{}% do nothing, already in list
{% add to list
\ifdefempty{\uniqueaffils}%
{% first element of list
\eappto\uniqueaffils{\affil}%
}%
{% append to list
\eappto\uniqueaffils{, \affil}%
}%
}%
}
%% MAKE AUTHOR LIST
\newcommand*{\authorlist}{}
\DTLforeach*{longauthors}{\name=name, \affil=affiliation, \email=email}{%
\DTLifSubString{\authorlist}{\name} % make sure author is unique
{}% do nothing, already in list
{% add to list
\ifdefempty{\authorlist}%
{% first element of list
\eappto\authorlist{\name}%
}%
{% append to list
\eappto\authorlist{, \name}%
}%
}%
}
\begin{document}
\authorlist
List of unique affiliations: \uniqueaffils.
\end{document}
其输出如下:
我如何转换上述代码以将此列表更改为所需的格式:
也就是我最关心的变化:
- 我如何在最后两位作者之间添加“和”?
- 我如何从编号的唯一隶属关系列表中跟踪和分配每个作者的隶属关系?
在此先感谢您的帮助!