如何使用 bibunits 在文档末尾添加全局参考书目?

如何使用 bibunits 在文档末尾添加全局参考书目?

我有这个代码:

\documentclass[10pt]{article}

\usepackage[globalcitecopy]{bibunits}
\usepackage{filecontents}
\usepackage[round]{natbib}

\begin{filecontents*}{mwecitations.bib}
@book{goossens93,
    author = "Frank Mittelbach and Michel Goossens  and Johannes Braams and David Carlisle  and Chris Rowley",
    title = "The {LaTeX} Companion",
    year = "1993",
    publisher = "Addison-Wesley",
    address = "Reading, Massachusetts"
}
@article{fujita2010economic,
    title={Economic effects of the unemployment insurance benefit},
    author={Fujita, Shigeru},
    journal={FRB Phil. Business Review},
    volume={4},
    year={2010}
}
@article{rothstein2011unemployment,
    title={Unemployment insurance and job search in the {Great Recession}},
    author={Rothstein, Jesse},
    journal={NBER},
    volume={w17534},
    year={2011}
}
\end{filecontents*}


\defaultbibliography{mwecitations}
\defaultbibliographystyle{plainnat}

\begin{document}

\begin{bibunit}
\section{something}
First discuss \cite*{goossens93}.
\putbib
\end{bibunit}

\begin{bibunit}
\section{something else}
Now discuss \cite*{rothstein2011unemployment} and \cite*{fujita2010economic}.
\putbib
\end{bibunit}

\renewcommand{\refname}{Global bibliography}
\bibliography[mwecitations]

\end{document}

输出如下内容:

![在此处输入图片描述

没有全局书目,引用文件的名称包含错误。我正在尝试获取包含以下内容的全局书目每一个引自每一个文档末尾的 bibunit。根据bibunits 文档

\bibliography[〈BibTeX files〉]您可以使用命令和照常创建全局书目\bibliographystyle[〈style〉]。使用\cite\nocite生成出现在本地书目中的引文。在单元中使用\cite*\nocite*为本地和全局书目生成引文。

据我所知,我正确地应用了这一点。如果我使用\bibliography而不是\bibliography[mwecitations](因为我希望使用默认.bib 文件,而不必通过名称来调用它),我收到错误

!段落在\bibliography完成之前结束。

我做错了什么?我用以下方式编译文档

xelatex mwe
bibtex bu1.aux
bibtex bu2.aux
xelatex mwe
xelatex mwe

我使用natbib它来引用作者年份。

答案1

有三个错误:您有一个拼写错误(括号而不是大括号),缺少全局 \bibliographystyle,并且您没有在主文件上运行 bibtex。

\documentclass[10pt]{article}

\usepackage[globalcitecopy]{bibunits}
\usepackage{filecontents}
\usepackage[round]{natbib}

\begin{filecontents*}{mwecitations.bib}
@book{goossens93,
    author = "Frank Mittelbach and Michel Goossens  and Johannes Braams and David Carlisle  and Chris Rowley",
    title = "The {LaTeX} Companion",
    year = "1993",
    publisher = "Addison-Wesley",
    address = "Reading, Massachusetts"
}
@article{fujita2010economic,
    title={Economic effects of the unemployment insurance benefit},
    author={Fujita, Shigeru},
    journal={FRB Phil. Business Review},
    volume={4},
    year={2010}
}
@article{rothstein2011unemployment,
    title={Unemployment insurance and job search in the {Great Recession}},
    author={Rothstein, Jesse},
    journal={NBER},
    volume={w17534},
    year={2011}
}
\end{filecontents*}


\defaultbibliography{mwecitations}
\defaultbibliographystyle{plainnat}

\begin{document}

\begin{bibunit}
\section{something}
First discuss \cite*{goossens93}.
\putbib
\end{bibunit}

\begin{bibunit}
\section{something else}
Now discuss \cite*{rothstein2011unemployment} and \cite*{fujita2010economic}.
\putbib
\end{bibunit}

\renewcommand{\refname}{Global bibliography}
\bibliographystyle{plainnat}
\bibliography{mwecitations}

\end{document}

在此处输入图片描述

相关内容