> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-pro.ayaka.space/latex/zh-cn/shen-ru-wen-zhang/13-getting-started-with-biblatex.md).

# BibLaTeX 入门

**作者：Josh Cassidy（2013年7月）**

多年来，LaTeX 用户一直在使用 BibTeX 以及多个额外的宏包，例如 `natbib` 来编写参考文献。然而，现在有了一个新的选项：BibLaTeX。它旨在为你提供更多选项，方便地配置参考文献/引文。方便的是，现有的 `.bib` 文件为了与 BibLaTeX 配合使用，可能无需太多修改。除了 300 多页的 [BibLaTeX 文档](http://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf)，CTAN 还有一个有用的 [BibLaTeX “速查表”](http://tug.ctan.org/info/biblatex-cheatsheet/biblatex-cheatsheet.pdf)。为补充这些资源，这里还有一个视频教程，随后附上一些笔记/示例，帮助你入门。

{% embed url="<https://www.youtube.com/embed/nH9If8c5VCs>" %}

### 基本命令和样式

首先，在 tex 文件中将参考文献加入文档时所使用的命令有很大不同。在导言区你需要使用以下代码：

```latex
\usepackage{biblatex}
\addbibresource{}
```

第一个命令只是加载 `biblatex` 宏包。第二个用于指定你想使用哪些 bib 文件。你只需在花括号中输入文件名，包括 `.bib` 扩展名。然后在文档正文中，不再使用 `\bibliography` 命令来生成参考文献，而是使用 `\printbibliography` 命令。使用 BibTeX 时，你通过使用 `\bibliographystyle` 命令来指定参考文献样式。在 `biblatex` 中，我们不再使用这个命令，而是通过向 `\usepackage` 命令传入更多参数来指定样式选项。为此我们输入 `style=` ，然后在花括号前紧挨着的方括号中跟上样式名称。例如：

```latex
\usepackage[style=numeric]{biblatex}
```

或者，如果你想为引文和参考文献分别声明不同的样式，你可以使用 `citestyle` 和 `bibstyle`。例如：

```latex
\usepackage[citestyle=alphabetic,bibstyle=authortitle]{biblatex}
```

在继续之前，我先快速展示一下这些样式在引文和实际参考文献条目中的效果。不过，你也可以 [查阅文档](http://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf) 以获取完整的样式列表。

* 该 `数字` 样式： ![BiBLaTeXnumeric.png](/files/e40df73fff1a28567865e8c3cb73cc20112e2080)- 这是一种 `字母式` 样式： ![BiBLaTeXalphabetic.png](/files/05c1bcb468bb7b5664e3de0de9a7cfcb735c6044)- 这是一种 `阅读` 样式： ![BiBLaTeXreading.png](/files/c35a922388f605dd4aeec0fa5f725e267d354e3f)- 这是一种 `作者-年份` 样式： ![BiBLaTeXauthoryear.png](/files/8dcc0b7d82a4cb45f95b5c17cf39ceeb49e1a9b5)

你还可以向……命令传入的另一个参数是 `\usepackage` 排序选项。例如：

```latex
\usepackage[style=authoryear,sorting=ynt]{biblatex}
```

这将使用作者-年份样式，并按年份、姓名、标题对参考文献条目排序。下面列出一些可用的不同排序选项：

* `nty`—按姓名、标题、年份排序条目；
* `nyt`—按姓名、年份、标题排序条目；
* `nyvt`—按姓名、年份、卷号、标题排序条目；
* `anyt`—按字母标签、姓名、年份、标题排序条目；
* `anyvt`—按字母标签、姓名、年份、卷号、标题排序条目；
* `ynt`—按年份、姓名、标题排序条目；
* `ydnt`—按年份（降序）、姓名、标题排序条目；
* `none`—不排序。条目按它们在正文中出现的顺序显示。

如果你不指定顺序，默认是 `nty`.

### 引文命令

引文命令也在其中进行了全面改版 `biblatex`。这些更智能的命令允许你添加一个 `前注` 和 `后注` 作为参数：

* a `前注` 是一个词或短语，例如“see”，会插入在引文开头；
* a `后注` 是你想插入在引文末尾的文本。

要添加这些注释，你需要在引文命令中使用两组方括号。下面是一个例子：

```latex
\cite[see][page 12]{latexcompanion}
```

在这个例子中，我们已经加载了 `字母式` 样式和 `latexcompanion` 只是引文键。引文在正文中的效果如下：

![BiBLaTeXprepost.png](/files/46313168568f091cc8173879e01d7c40ecd2b6e2)

如果你只打开一组方括号，它会假定方括号中的内容是一个 `后注`，所以如果你只想要一个 `前注` 请确保你仍然打开第二组方括号，然后保持为空。

还有许多不同的引文命令可供你使用。下面是一些标准命令：

* `\cite`—最基本的一种。默认不带任何括号输出，除非使用 `字母式` 或 `数字` 样式时，它会使用方括号；
* `\parencite`—以圆括号形式输出引文，除非使用 `字母式` 或 `数字` 样式时，它会使用方括号；
* `\footcite`—将引文放在脚注中。

### 参考文献分组

BibLaTeX 的一个优点是 `biblatex` 你可以根据来源类型将参考文献拆分。下面是按来源类型拆分的示例：

```latex
\printbibheading
\printbibliography[type=book,heading=subbibliography,title={Book Sources}]
\printbibliography[nottype=book,heading=subbibliography,title={Other Sources}]
```

在这个例子中，我们将参考文献分成两个部分，一个是图书类来源，另一个是非图书类来源。下面是示例输出：

![BiBLaTeXtypes.png](/files/b5b5336807a5f1a72f154e56cb4d8d4704d77105)

另一种拆分参考文献的方法是使用关键词筛选器。为此你需要在 `keywords` 字段添加到你 `.bib` 文件中的条目里。例如：

```latex
@article{key,
	keywords = {keywordA,keywordB,keywordC}
```

下面是按关键词拆分的示例：

```latex
\printbibheading
\printbibliography[keyword=major,heading=subbibliography,title={Major Sources}]
\printbibliography[keyword=minor,heading=subbibliography,title={Minor Sources}]
```

对应的输出如下：

![BiBLaTeXmajor.png](/files/5633dac2efb89b2d4a5bc80f2b329f15b045b93a)

看起来不久之后，BibTeX 将只会成为 LaTeX 历史中的一段往事！希望这能帮助你开始使用 `biblatex`.


---

# 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://overleaf-pro.ayaka.space/latex/zh-cn/shen-ru-wen-zhang/13-getting-started-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.
