> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/latex/zh-cn/can-kao-wen-xian-he-yin-yong/03-bibliography-management-with-biblatex.md).

# 使用 biblatex 管理参考文献

对于文献管理宏包，LaTeX 中主要有三个选项：bibtex、natbib 和 biblatex。Biblatex 是一个用于处理文献信息的现代程序，提供了比另外两个选项更简单、更灵活的接口，以及更好的语言本地化支持。本文将介绍如何使用 **biblatex** 来管理并格式化 LaTeX 文档中的参考文献。

## 引言

一个最小工作示例的 **biblatex** 宏包如下所示：

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{biblatex}
\addbibresource{sample.bib}

\begin{document}
来引用吧！爱因斯坦的期刊论文 \cite{einstein} 和狄拉克的
著作 \cite{dirac} 都是与物理学相关的条目。

\printbibliography

\end{document}
```

![BiblatexEx1.png](/files/78ca532fd19cece6fdca720290374f7aaee8f4bf)

本例中有四个与参考文献相关的命令：

**\usepackage{biblatex}**

导入 biblatex 宏包。

**\addbibresource{sample.bib}**

导入 bibtex 数据文件 sample.bib；该文件包含每本被引用的书籍、文章等的信息。更多信息请参见参考文献文件部分。

**\cite{einstein}**

此命令会在文档中插入一个引用，在此例中是 \[1]，它对应于参考文献中的一个条目；“einstein” 是 sample.bib 中某个条目的关键词。

**\printbibliography**

输出被引用参考文献的列表，article 文档类的默认标题是“参考文献”，而书籍和报告的默认标题是“书目”。

***Overleaf 提供了若干带有预定义样式的模板来管理参考文献。请参见*** [***这些示例。***](https://www.overleaf.com/latex/templates/tagged/bibliography)

[在 Overleaf 上打开一个 biblatex 宏包示例](https://www.overleaf.com/project/new/template/19715?id=66713383\&templateName=Example+using+BiBLaTeX\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## 基本用法

在包导入语句中可以传入若干参数，下面来看

```latex
\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

使用 \texttt{biblatex}，你可以将参考文献按章节分组显示，
这取决于引文类型。
来引用吧！爱因斯坦的期刊论文 \cite{einstein} 和狄拉克的
著作 \cite{dirac} 都是与物理学相关的条目。
接下来，\textit{The \LaTeX\ Companion} 一书 \cite{latexcompanion}，唐纳德
克努特的网站 \cite{knuthwebsite}，\textit{The Comprehensive Tex Archive
Network}（CTAN）\cite{ctan} 是与 \LaTeX\ 相关的条目；但其他唐纳德
克努特的条目 \cite{knuth-fa,knuth-acp} 专门用于编程。

\medskip

\printbibliography

\end{document}
```

![BiblatexEx2.png](/files/965d2ab519469c1933eea7bd077e215ec6be8519)

在导入时，会添加一些额外选项，写在方括号中并以逗号分隔， **biblatex**:

**backend=biber**

设置用于排序参考文献的后端，biber 是默认后端并且推荐使用，因为它为多个命令提供了完整的本地化支持，而且 biber 的样式更容易修改，因为它们使用标准 LaTeX 宏。另一个支持的后端是 bibtex，它是一种更传统的程序；如果将其设为后端，它将只用于对参考文献排序，因此这里不能使用 bibtex 样式。

**style=alphabetic**

定义参考文献样式和引文样式，在本例中为 alphabetic。根据样式不同，可能还会提供更多引文命令。更多信息请参见参考文献样式和引文样式。

**sorting=ynt**

确定对参考文献来源进行排序的准则。在本例中，它们按年份、姓名和标题排序。排序选项列表请参见参考手册。

其余命令已经在 [引言](#introduction).

[在 Overleaf 上打开一个 biblatex 宏包示例](https://www.overleaf.com/project/new/template/19715?id=66713383\&templateName=Example+using+BiBLaTeX\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## 参考文献文件

参考文献文件必须采用标准 BibTeX 语法

```latex
@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{...}**

这是记录条目的第一行，@article 告诉 BibTeX 这里存储的信息是关于一篇文章的。有关该条目的信息被括在花括号中。除了示例中显示的条目类型（article、book、online 和 inbook）之外，还有许多其他类型，详见参考手册。

**einstein**

标签 einstein 被分配给了此条目，它是一个标识符，可用于在文档中引用这篇文章。

**author = "Albert Einstein",**

这是参考文献条目的第一个字段，表示这篇文章的作者是 Albert Einstein。还可以使用相同的语法 key = value 添加多个以逗号分隔的字段，例如：title、pages、year、URL 等。可用字段列表请参见参考手册。

该文件中的信息随后可以像前几节所示那样，在 LaTeX 文档中通过命令打印并引用 `\addbibresource{sample.bib}`。.bib 文件中的并非所有信息都会显示，这取决于文档中设置的参考文献样式。

[在 Overleaf 上打开一个 biblatex 宏包示例](https://www.overleaf.com/project/new/template/19715?id=66713383\&templateName=Example+using+BiBLaTeX\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## 自定义参考文献

Biblatex 只需很少的工作就能对参考文献部分进行高度自定义。前面提到过有多种 [引文样式](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/08-biblatex-citation-styles.md) 和 [参考文献样式](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/07-biblatex-bibliography-styles.md) 可供使用，而且你也可以创建新的样式。另一种自定义选项是更改参考文献部分的默认标题。

```latex
\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

使用 \texttt{biblatex}，你可以将参考文献按章节分组显示，
这取决于引文类型。
来引用吧！爱因斯坦的期刊论文 \cite{einstein} 和狄拉克的
著作 \cite{dirac} 都是与物理学相关的条目。
接下来，\textit{The \LaTeX\ Companion} 一书 \cite{latexcompanion}，唐纳德
克努特的网站 \cite{knuthwebsite}，\textit{The Comprehensive Tex Archive
Network}（CTAN）\cite{ctan} 是与 \LaTeX\ 相关的条目；但其他唐纳德
克努特的条目 \cite{knuth-fa,knuth-acp} 专门用于编程。

\medskip

\printbibliography[title={Whole bibliography}]

\end{document}
```

![BiblatexEx3.png](/files/3520566a50dee5ca3ce4f972aa7edfdf3b2e1a86)

附加参数 `title={Whole bibliography}` 以方括号形式传递给命令 `\printbibliography` 的是用于更改标题的那个参数。

参考文献也可以根据不同过滤条件划分为若干部分，例如：只打印来自同一作者、同一期刊或标题相似的参考文献。下面是一个示例。

```latex
\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}]
```

![BiblatexEx4.png](/files/ecf3ae10fc8f7927131863e678574a68e151207f)

这里，参考文献被分为 4 个部分。这里所用命令的语法如下所述：

**\printbibliography\[type=article,title={Articles only}]**

只打印类型为 "article" 的条目，并将本部分标题设为 "Articles only"。同样的语法也适用于其他任何条目类型。

**\printbibliography\[keyword={physics},title={Physics-related only}]**

筛选在任一字段中包含单词 "physics" 的参考文献条目。将该部分标题设为 "Physics-related only"。

[在 Overleaf 上打开一个 biblatex 宏包示例](https://www.overleaf.com/project/new/template/19715?id=66713383\&templateName=Example+using+BiBLaTeX\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## 将参考文献添加到目录中

要让参考文献出现在目录中，必须向 `\printbibliography`

```latex
\printbibliography[
heading=bibintoc,
title={Whole bibliography}
]

\printbibliography[heading=subbibintoc,type=article,title={Articles only}]
```

![BiblatexEx5.png](/files/9125f6cce23be447fcc1d7a0ce8562ab614313a1)

目录中会添加一个节和一个小节：

* 在第一种情况下，添加 `heading=bibintoc` 会将标题作为无编号章添加到目录中；如果不可能，则作为无编号节添加。
* 第二种情况是 `heading=subbibintoc` 会将标题作为目录中的第二级条目添加，在本例中是嵌套在 "Whole bibliography" 下的小节。

[在 Overleaf 上打开一个 biblatex 宏包示例](https://www.overleaf.com/project/new/template/19715?id=66713383\&templateName=Example+using+BiBLaTeX\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## 参考指南

**支持的条目类型**

|               |                |              |
| ------------- | -------------- | ------------ |
| article       | book           | mvbook       |
| inbook        | bookinbook     | suppbook     |
| booklet       | collection     | mvcollection |
| incollection  | suppcollection | manual       |
| misc          | 在线             | patent       |
| periodical    | suppperiodical | proceedings  |
| mvproceedings | inproceedings  | 参考           |
| mvreference   | inreference    | report       |
| set           | thesis         | unpublished  |
| custom        | conference     | electronic   |
| mastersthesis | phdthesis      | techreport   |
| datatype      |                |              |

**支持的条目字段** （打印出的信息取决于参考文献样式）

|               |              |               |                 |
| ------------- | ------------ | ------------- | --------------- |
| 摘要            | afterword    | annotation    | annotator       |
| 作者            | authortype   | bookauthor    | bookpagination  |
| booksubtitle  | booktitle    | chapter       | commentator     |
| date          | doi          | edition       | editor          |
| editortype    | eid          | entrysubtype  | eprint          |
| eprinttype    | eprintclass  | eventdate     | eventtitle      |
| 文件            | foreword     | holder        | howpublished    |
| indextitle    | institution  | 引言            | isan            |
| isbn          | ismn         | isrn          | issue           |
| issuesubtitle | issuetitle   | iswc          | journalsubtitle |
| journaltitle  | label        | 语言            | 库               |
| location      | mainsubtitle | maintitle     | month           |
| note          | number       | organization  | origdate        |
| origlanguage  | origlocation | origpublisher | origtitle       |
| pages         | pagetotal    | pagination    | part            |
| publisher     | pubstate     | reprinttitle  | 系列              |
| shortauthor   | shortedition | shorthand     | shorthandintro  |
| shortjournal  | shortseries  | shorttitle    | subtitle        |
| 标题            | translator   | type          | url             |
| venue         | version      | volume        | year            |

**参考文献排序选项**

| 选项      | 说明                 |
| ------- | ------------------ |
| `nty`   | 按姓名、标题、年份排序        |
| `nyt`   | 按姓名、年份、标题排序        |
| `nyvt`  | 按姓名、年份、卷、标题排序      |
| `anyt`  | 按字母标签、姓名、年份、标题排序   |
| `anyvt` | 按字母标签、姓名、年份、卷、标题排序 |
| `ydnt`  | 按年份（降序）、姓名、标题排序    |
| `none`  | 条目将按引用顺序处理         |

## 进一步阅读

更多信息请参见

* [参考文献样式](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/04-bibtex-bibliography-styles.md)
* [Biblatex 引文样式](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/08-biblatex-citation-styles.md)
* [基本参考文献管理](/latex/zh-cn/geng-duo-zhu-ti/05-bibliography-management-in-latex.md)
* [使用 natbib 管理参考文献](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/02-bibliography-management-with-natbib.md)
* [biblatex 文档](http://linorg.usp.br/CTAN/macros/latex/contrib/biblatex/doc/biblatex.pdf)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ayakaleaf-pro.ayaka.space/latex/zh-cn/can-kao-wen-xian-he-yin-yong/03-bibliography-management-with-biblatex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
