我用它bibtex
来创建出版物列表。每年我都有一个.bib
包含该年出版物的文件。我尝试做的是:
\documentclass{article}
\usepackage{filecontents, pgffor}
\title{\Large\bfseries
Selected Publications
}
\author{
{\scshape Dr MWE}\\
Department of Minimum Working,\\
University of Examples
}
\begin{filecontents}{publications_2000.bib}
@article{MWE1,
author = {MWE, Dr},
title = {How to produce an {MWE}},
journal = {Journal of MWEs},
year = {2000},
volume = {1},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications_2001.bib}
@article{MWE2,
author = {MWE, Dr},
title = {How to produce yet another an {MWE}},
journal = {Journal of MWEs},
year = {2001},
volume = {2},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications_2002.bib}
@article{MWE2,
author = {MWE, Dr},
title = {How to produce yet another {MWE}, again},
journal = {Journal of MWEs},
year = {2002},
volume = {3},
pages = {1--10}
}
\end{filecontents}
\begin{document}
\maketitle
\nocite{*}
\bibliographystyle{unsrt}
\foreach \yr in {2000,...,2002}{
\renewcommand\refname{\large \yr}
\bibliography{publications_\yr}
}
\end{document}
我希望它能输出每个文件的参考书目(publications_20xx.bib
)。但我得到的输出如下:
换句话说,同一年不断重复。我尝试查看该包multibib
,但似乎无法让它在本例中发挥作用。非常感谢任何帮助。
答案1
我会使用bibtopic
它来轻松地对不同的 bib 进行分组。您只需对每个生成的 .aux 文件运行 bibtex,然后就可以继续或重置编号。
\documentclass{article}
\usepackage{filecontents, pgffor}
\usepackage{bibtopic}
%\usepackage[sectcntreset]{bibtopic} %use to reset numbering in each section
\title{\Large\bfseries
Selected Publications
}
\author{
{\scshape Dr MWE}\\
Department of Minimum Working,\\
University of Examples
}
\begin{filecontents}{publications_2000.bib}
@article{MWE1,
author = {MWE, Dr},
title = {How to produce an {MWE}},
journal = {Journal of MWEs},
year = {2000},
volume = {1},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications_2001.bib}
@article{MWE2,
author = {MWE, Dr},
title = {How to produce yet another an {MWE}},
journal = {Journal of MWEs},
year = {2001},
volume = {2},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications_2002.bib}
@article{MWE3,
author = {MWE, Dr},
title = {How to produce yet another {MWE}, again},
journal = {Journal of MWEs},
year = {2002},
volume = {3},
pages = {1--10}
}
\end{filecontents}
\begin{document}
\maketitle
\nocite{*}
\bibliographystyle{unsrt}
\foreach \yr in {2000,...,2002}{
\subsection*{\large \yr}
\begin{btSect}{publications_\yr}
\btPrintNotCited
\end{btSect}
}
\end{document}
答案2
这里有一种方法multibib
:
\documentclass{article}
\usepackage{filecontents,multibib,etoolbox}
\title{\Large\bfseries
Selected Publications
}
\author{
{\scshape Dr MWE}\\
Department of Minimum Working,\\
University of Examples
}
\begin{filecontents}{publications-2000.bib}
@article{MWE1,
author = {MWE, Dr},
title = {How to produce an {MWE}},
journal = {Journal of MWEs},
year = {2000},
volume = {1},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications-2001.bib}
@article{MWE2,
author = {MWE, Dr},
title = {How to produce yet another an {MWE}},
journal = {Journal of MWEs},
year = {2001},
volume = {2},
pages = {1--10}
}
\end{filecontents}
\begin{filecontents}{publications-2002.bib}
@article{MWE2,
author = {MWE, Dr},
title = {How to produce yet another {MWE}, again},
journal = {Journal of MWEs},
year = {2002},
volume = {3},
pages = {1--10}
}
\end{filecontents}
\newcommand{\yearlist}{}
\forcsvlist{\listadd\yearlist}{2000,2001,2002}
\renewcommand{\do}[1]{\newcites{year\romannumeral #1}{#1}}
\dolistloop{\yearlist}
\begin{document}
\maketitle
\renewcommand{\do}[1]{\csuse{nociteyear\romannumeral #1}{*}%
\csuse{bibliographystyleyear\romannumeral #1}{unsrt}%
\csuse{bibliographyyear\romannumeral #1}{publications-#1}}%
\dolistloop{\yearlist}
\end{document}
这样multibib
做的目的是引入一个新命令\newcites
。写作
\newcites{papers}{My papers}
准备创建带有标题的参考书目My papers
。它创建新的命令
\citepapers
\nocitepapers
\bibliographystylepapers
\bibliographypapers
然后将其用作常用命令的替代品。
现在,对于您的情况,还有几个其他问题。我们不能使用带有\newcites
inside 的循环命令,因为它会创建一个组,而新命令只存在于该组内。相反,我们可以使用该etoolbox
包中的循环构造。我在上面已经通过构建一个\yearlist
然后\dolistloop
在重新定义\do
以实现我需要的效果后调用此列表来完成此操作。
第二个问题是我们不能使用数字作为新命令名称的一部分(至少不容易)。解决这个问题的标准 LaTeX 方法是用罗马数字替换数字。所以我叫
\newcites{year\romannumeral 2000}{2000}
而\newcites{year2000}
不是 等
现在,当您使用 编译上述示例文件时,将写入latex
文件yearmm.aux
、 、...。然后依次运行每个文件,然后再运行。yearmmi.aux
bibtex
latex
最后要说的是,标题的样式不应该在内部完成\refname
。参见如何更改参考书目标题?针对此问题的一些方法。