考虑一个旨在容纳与作者相关的各种内容的环境。内容可能包括姓名、所属机构、一段简短的传记以及一系列精选出版物。然后考虑一份旨在总结一组作者的文档,因此,总结了“作者环境”的多个实例。
我最初尝试解决这个问题,涉及几个文件。
- 描述作者描述环境的.cls 文件。
- 一个 .tex 文件,是作者摘要,这里调用环境
- 一些定义了作者属性的 .tex 文件
- 一些 .bib 文件,其中定义了作者出版物
.cls 文件显示为:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{authou}[2015/11/11 an author description]
\LoadClass[12pt]{article}
\RequirePackage[numbers]{natbib}
\RequirePackage{cite}
\bibliographystyle{plainnat}
% define an author description environment
\newenvironment{author_description}[2]{%
\input{#1}%
\begin{center}%
\textbf{Name}: \authorname\\%
\textbf{Affiliation}: \authoraffiliation\\%
\nocite{*}%
\bibliography{#2}%
\end{center}%
}%
{%
% environment end definition
\newpage%
}%
\AtBeginDocument{%
}%
\AtEndDocument{%
}%
作者总结文档如下:
\NeedsTeXFormat{LaTeX2e}
\documentclass{author}
\begin{document}
\begin{author_description}%
{author.tex}%
{author}%
\end{author_description}%
\begin{author_description}%
{anotherauthor.tex}%
{anotherauthor}%
\end{author_description}%
\end{document}
作者属性存储在以下文件中:
\newcommand\authorname{Author}
\newcommand\authoraffiliation{The author's most relevant affiliation}
标准 .bib 文件如下所示:
@ARTICLE{Author2015b,
author={Author},
journal={Journal},
title={The author's most recent work},
year={2015},
volume={40},
number={3},
pages={683-700},
keywords={reading, writing, arithmetic},
doi={},
ISSN={},
month={July},}
@ARTICLE{Author2015a,
author={Author},
journal={Journal},
title={The author's second most recent work},
year={2015},
volume={12},
number={1},
pages={56-74},
keywords={reading, writing, arithmetic},
doi={},
ISSN={},
month={May},}
我需要指出的是,作者属性文件和相应的 .bib 文件都以作者姓名命名,在本例中author
为。anotherauthor
编译时,出现明显错误(见附件)。与作者描述环境的第一个实例相关的 .bib 条目出现在所有后续实例中。
当我第一次发现这个问题时,我立即将注意力转向了 multibib,然而,经过更深入的研究,我发现 multibib 似乎并不存在这个问题。
所以问题是:我如何定义一个包含参考书目的环境(以 .bib 文件名作为参数)并允许在单个文档中显示不确定数量的参考书目?
答案1
一种可能性是使用 Biblatex/Biber 和refsection
。请注意,您不需要具有两个参数的环境 - 一个就足够了。如果您想在开始和结束之间添加内容,您只需要一个环境(而不是命令)。这不在您的示例中,但我认为您确实想要它。
\begin{filecontents}{author.tex}
\renewcommand\authorname{Author}
\renewcommand\authoraffiliation{The author's most relevant affiliation}
\end{filecontents}
\begin{filecontents}{author.bib}
@ARTICLE{Author2015b,
author={Author},
journal={Journal},
title={The author's most recent work},
year={2015},
volume={40},
number={3},
pages={683-700},
keywords={reading, writing, arithmetic},
doi={},
ISSN={},
month={July},}
@ARTICLE{Author2015a,
author={Author},
journal={Journal},
title={The author's second most recent work},
year={2015},
volume={12},
number={1},
pages={56-74},
keywords={reading, writing, arithmetic},
doi={},
ISSN={},
month={May},}
\end{filecontents}
\begin{filecontents}{otherauthor.tex}
\renewcommand\authorname{Other Author}
\renewcommand\authoraffiliation{The otherauthor's most relevant affiliation}
\end{filecontents}
\begin{filecontents}{otherauthor.bib}
@ARTICLE{OtherAuthor2015b,
otherauthor={Other Author},
journal={Journal},
title={The otherauthor's most recent work},
year={2015},
volume={40},
number={3},
pages={683-700},
keywords={reading, writing, arithmetic},
doi={},
ISSN={},
month={July},}
@ARTICLE{OtherAuthor2015a,
otherauthor={Other Author},
journal={Journal},
title={The otherauthor's second most recent work},
year={2015},
volume={12},
number={1},
pages={56-74},
keywords={reading, writing, arithmetic},
doi={},
ISSN={},
month={May},}
\end{filecontents}
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\newcommand\authorname{}
\newcommand\authoraffiliation{}
\newenvironment{author_description}[1]{%
\begin{refsection}[#1.bib]
\input{#1}%
\begin{center}
\textbf{Name}: \authorname\\%
\textbf{Affiliation}: \authoraffiliation\\%
\nocite{*}%
\printbibliography
\end{center}
}{% environment end definition
\end{refsection}%
\newpage}
\begin{document}
\begin{author_description}{author}
here is some stuff about Author
\end{author_description}
\begin{author_description}{otherauthor}
here is some stuff about Other Author
\end{author_description}
\end{document}