使用 biblatex 进行参考文献管理
原 文:Bibliography management with natbib
译 者:Xovee
翻译时间:2020年11月21日
使用 biblatex 进行参考文献管理
当你使用 LaTeX 进行参考文献管理时,一般来说你有三种选择:bibtex
、natbib
、biblatex
。Biblatex
是一个非常现代化的处理参考文献信息的程序,它提供了简单、灵活、易于操作的界面,在语言支持上也比其他两个工具更好。本篇文章介绍如何使用biblatex
来在 LaTeX 文档中进行参考文献管理。
介绍
下面介绍了一个简单的例子:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{biblatex}
\addbibresource{sample.bib}
\begin{document}
Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's
book \cite{dirac} are physics related items.
\printbibliography
\end{document}
这个例子中介绍了四种与参考文献有关的命令:
\usepackage{biblatex}
引入biblatex
包
\addbibresource{sample.bib}
从sample.bib
文件中引入bibtex
数据。这个文件中包含了你所需要的各种参考文献的信息。
\cite{einstein}
这个命令会在文档中插入一个参考文献,在这个例子中,它会在文档中显示 [1]
,einstein
是该参考文献在文件中某个条目的关键字。
\printbibliography
打印所有引用的参考文献,其默认的标题为Reference
(article
类型的文档),或者Bibliography
(books
或reports
类型的文档)。
Overleaf 提供了许多预定义的参考文献管理格式。
基础用法
在引入包的时候,你可以传递许多参数,例如:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{comment}
\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt
]{biblatex}
\addbibresource{sample.bib}
\title{Bibliography management: \texttt{biblatex} package}
\author{Overleaf}
\date{ }
\begin{document}
\maketitle
Using \texttt{biblatex} you can display bibliography divided into sections,
depending of citation type.
Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's
book \cite{dirac} are physics related items.
Next, \textit{The \LaTeX\ Companion} book \cite{latexcompanion}, the Donald
Knuth's website \cite{knuthwebsite}, \textit{The Comprehensive Tex Archive
Network} (CTAN) \cite{ctan} are \LaTeX\ related items; but the others Donald
Knuth's items \cite{knuth-fa,knuth-acp} are dedicated to programming.
\medskip
\printbibliography
\end{document}
在引入biblatex
包的时候,额外的选项定义在大括号之中,用逗号分割。
backend=biber
设置对参考文献进行排序的后端处理。biber
是默认的,也是我们推荐的排序方式。它对许多命令提供了完整的本地化实现,并且biber
的样式非常容易编辑,因为它使用了标准的 LaTeX 宏指令。另外一个支持的后端处理是bibtex
,它是一个比较传统的程序,它只被用来对参考文献进行排序,不可以用来设置bibtex
的样式。
style=alphabetic
定义参考文献的样式以及引用的样式,在这个例子里被设置为alphabetic
。取决于所使用的样式,你有可能使用更多的引用命令。请见参考文献样式和引用样式。
sorting=ynt
定义了参考文献排序的规则。在这个例子里,它们会以年份、姓名、标题来进行排序。更多选项见文末。
参考文献文件
参考文献文件必须使用标准的bibtex
语法:
@article{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"
}
@book{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}
}
@online{knuthwebsite,
author = "Donald Knuth",
title = "Knuth: Computers and Typesetting",
url = "http://www-cs-faculty.stanford.edu/~uno/abcde.html",
keywords = "latex,knuth"
}
@inbook{knuth-fa,
author = "Donald E. Knuth",
title = "Fundamental Algorithms",
publisher = "Addison-Wesley",
year = "1973",
chapter = "1.2",
keywords = "knuth,programming"
}
...
文件中包含了参考文献记录,记录有一种特殊的格式。例如,第一个参考文献又下面的命令定义:
@article{…}
这是参考文献条目的第一行,它告诉 BibTeX 这个条目的类型是 article。条目的信息包含在大括号之中。除了例子中的三种条目(article, book, misc),更多条目类型见文末。
einstein
这是条目的标签,是某个特定参考文献唯一的标识符。我们使用这个标签来在文档中引用这个参考文献。
author = “albert Einstein”,
这是参考文献条目的第一个字段,即该参考文献的作者是 Albert Einstein。你可以添加更多的字段,由逗号分割,语法是key = value,
,例如:标题、页码、年份、URL等。更多例子见文末。
该参考文献中的内容可以随后在文档中进行引用和展示(命令为\bibliography{sample}
。需要注意的是,.bib 文件中的信息并不是都会展示出来,展示哪些信息取决于你所使用的参考文献格式。例如,某些格式不会展示(打印)文献的出版商。
自定义参考文献
biblatex
提供了许多高阶的、容易使用的参考文献自定义命令。它支持许多参考文献样式和引用样式,你也可以创建自己的样式。另外一个支持的自定义选项是改变默认的参考文献章的标题。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{comment}
\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt
]{biblatex}
\addbibresource{sample.bib}
\title{Bibliography management: \texttt{biblatex} package}
\author{Overleaf}
\date{ }
\begin{document}
\maketitle
Using \texttt{biblatex} you can display bibliography divided into sections,
depending of citation type.
Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's
book \cite{dirac} are physics related items.
Next, \textit{The \LaTeX\ Companion} book \cite{latexcompanion}, the Donald
Knuth's website \cite{knuthwebsite}, \textit{The Comprehensive Tex Archive
Network} (CTAN) \cite{ctan} are \LaTeX\ related items; but the others Donald
Knuth's items \cite{knuth-fa,knuth-acp} are dedicated to programming.
\medskip
\printbibliography[title={Whole bibliography}]
\end{document}
大括号中的参数title={Whole bibliography}
会改变参考文献章的标题。
参考文献也可以被划分为多个章节,例如:只打印某个作者的参考文献,只打印某个期刊的参考文献等。下面是一个例子:
\printbibliography[type=article,title={Articles only}]
\printbibliography[type=book,title={Books only}]
\printbibliography[keyword={physics},title={Physics-related only}]
\printbibliography[keyword={latex},title={\LaTeX-related only}]
在这里,参考文献被分为四个章。命令的语法解释如下:
\printbibliography[type=article,title={Articles only}]
只打印条目类型为article
的条目,并且将该章节的标题设置为Articles only
。其他条目类型的设置方式类似。
\printbibliography[keyword={physics},title={Physics-related only}]
只打印条目信息中出现过关键词physics
的条目,并将该章节的标题设置为Physics-related only
。
在目录中添加参考文献章
为了在文档的目录中添加参考文献的章节,你需要给\printbibliography
传递参数:
\printbibliography[
heading=bibintoc,
title={Whole bibliography}
]
\printbibliography[heading=subbibintoc,type=article,title={Articles only}]
章(section)和子章(subsection)被添加到文档的目录之中:
- 在第一种情况下,参数
heading=bibintoc
会把参考文献当作一个不编号的章(chapter,其他情况也有可能是section)添加到目录之中。 - 第二种情况下,命令
heading=subbibintoc
会将标题当作第二级的记录添加到目录之中。
参考指南
支持的条目类型
- article
- book
- mvbook
- inbook
- bookinbook
- suppbook
- booklet
- collection
- mvcollection
- incollection
- suppcollection
- manual
- misc
- online
- patent
- periodical
- suppperiodical
- proceedigns
- mvproceedings
- inproceedigns
- reference
- mvreference
- inreference
- report
- set
- thesis
- unpublished
- custom
- conference
- electronic
- masterthesis
- phdthesis
- techreport
支持的条目字段
- abstract
- afterword
- annotation
- annotator
- author
- authortype
- bookauthor
- bookpagination
- boosubtitle
- booktitle
- chapter
- commentator
- date
- doi
- edition
- editor
- editortype
- eid
- entrysubtype
- eprint
- epritntype
- eprintclass
- eventdate
- eventtitle
- file
- foreword
- holder
- howpublished
- indextitle
- institution
- introduction
- isan
- isbn
- ismn
- isrn
- issue
- issuesubtitle
- issuetitle
- iswc
- journalsubtitle
- journaltitle
- label
- language
- library
- location
- mainsubtitle
- maintitle
- month
- note
- number
- organization
- origdate
- origlanguage
- origlocation
- origpublisher
- origtitle
- pages
- pagetotal
- pagination
- part
- publisher
- pubstate
- reprinttitle
- series
- shortauthor
- shortedition
- shorthand
- shorthandintro
- shortjournal
- shortseries
- shorttitle
- subtitle
- title
- translator
- type
- url
- venue
- version
- volume
- year
参考文献排序选项
选项 | 描述 |
---|---|
nty | 姓名、标题、年份 |
nyt | 姓名、年份、标题 |
nyvt | 姓名、年份、volume、标题 |
anyt | 字母顺序的标签label、姓名、年份、标题 |
anyvt | 字母顺序的标签label、姓名、年份、volume、标题 |
ydnt | 年份(降序)、姓名、标题 |
none | 按照引用的顺序来排序 |
延伸阅读
更多信息请见: