背页/乳胶:
如何在一个 Latex 项目中引用多个并行的 *.bib 文件,并在最后创建一个通用文献目录,而无需合并这两个文件?
非常感谢您的帮助!
我已经看到了使用不同的包(例如)从多个参考文献文件创建多个(主要是1:1)参考书目的方法,但我还没有找到上述问题的方法或解决方案。如果已经有合适的条目,那么我只是还没有找到它并为此道歉...... 我希望我已经足够清楚地定义了要求。如果有遗漏的信息,请再询问,我会立即补充。
如果您可以使用biblatex,则不必合并您的库。只需将所有单独的文件放在一个文件夹中即可。然后,在代码中,加载引用时只需指向文件夹即可,主要是在文件名前加上文件夹名
\addbibresournce{<folder>/<file>}
。对包含您的参考文献的所有必需文件重复相同的命令。
考虑下面的代码。假设所有文件都集中在当前项目文件夹中的
bib/
中。运行下面的示例,所有参考文献都应出现在 PDF 中,全部从单独的文件加载。确保 bin/
文件夹存在。
注意egin{filecontents*}... nd{filecontents}` 的块,这些块只需要在编译期间创建文件时使示例自包含即可。在实际情况下,这些文件已经存在。
代码
%%% --- THIS BLOCK CREATES files ---
\begin{filecontents*}[overwrite]{bib/sample1.bib}
@article{ref:einstein,
author = "Albert Einstein",
title = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
[{On} the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
}
\end{filecontents*}
\begin{filecontents*}[overwrite]{bib/sample2.bib}
@book{ref:dirac,
title = {The Principles of Quantum Mechanics},
author = {Paul Adrien Maurice Dirac},
isbn = {9780198520115},
series = {International series of monographs on physics},
year = {1981},
publisher = {Clarendon Press},
keywords = {physics}
}
\end{filecontents*}
\begin{filecontents*}[overwrite]{bib/sample3.bib}
@online{ref:knuthwebsite,
author = "Donald Knuth",
title = "Knuth: Computers and Typesetting",
url = "http://www-cs-faculty.stanford.edu/~uno/abcde.html",
addendum = "(accessed on 20/09/2023)",
keywords = "latex,knuth"
}
\end{filecontents*}
\begin{filecontents*}[overwrite]{bib/sample4.bib}
@inbook{ref:knuth-fa,
author = "Donald E. Knuth",
title = "Fundamental Algorithms",
publisher = "Addison-Wesley",
year = "1973",
chapter = "1.2",
keywords = "knuth,programming"
}
\end{filecontents*}
%%% --- END --- %%%
%%% REGULAR LATEX DOCUMENT STARTS HERE
\documentclass{article}
\usepackage[
backend=biber,
style=apa,
]{biblatex}
\usepackage[colorlinks]{hyperref}
\usepackage[nopar]{kantlipsum}
\addbibresource{bib/sample1.bib}
\addbibresource{bib/sample2.bib}
\addbibresource{bib/sample3.bib}
\addbibresource{bib/sample4.bib}
\begin{document}
\section{Introduction}\label{sec:intro}
\kant[1][1] \autocite{ref:einstein}.
\section{Main section}\label{sec:main}
\kant[1][2] \autocite{ref:dirac}.
\section{Simple implementation}\label{sec:implementation}
\kant[1][3] \autocite{ref:knuthwebsite}.
\section{Conclusion}\label{sec:conclusion}
\kant[1][4] \autocite{ref:knuth-fa}.
\printbibliography
\end{document}