> 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/wen-da/07-creating-multiple-bibliographies-in-the-same-document.md).

# 在同一文档中创建多个参考文献列表

## 简介

本文将讨论如何使用适当的宏包在同一个 LaTeX 文档中创建多个参考文献表。默认情况下，每个 LaTeX 文档只能包含一个参考文献表或参考文献列表，无论是使用 `\begin{thebibliography}\bibitem...\end{thebibliography}` 列表，还是使用 `\bibligraphystyle{...}\bibliography{...}`，或 `\printbibliography`。但在某些情况下，你可能需要创建 *多个参考文献表*。你可能希望为每一章单独设置参考文献表，而不是为整个文档设置一个。或者，你可能希望为不同的类别和主题分别设置参考文献表。

如果你试图通过在 LaTeX 文档的不同位置放置多个 `\bibliography` 调用来满足这些情况，你会发现它们都包含同一份条目列表，涵盖了 *整个* 文档中的所有引用。相反，你必须使用合适的 LaTeX 宏包来正确生成独立的参考文献表。

你首先需要确定你使用的是 [BibTeX](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/01-bibliography-management-with-bibtex.md) 或 [biblatex](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/03-bibliography-management-with-biblatex.md)：它们需要不同的宏包，且不能混用。如果你使用的是出版商或大学提供的模板，请检查示例模板 `.tex` 文件是否包含 `\printbibliography` 或 `\addbibresource`。如果是这样，那么你使用的是 `biblatex`，请直接跳到这一节 [这里](#with-biblatex)。否则，你很可能使用的是 BibTeX，请继续阅读 [这里](#packages-for-bibtex).

## BibTeX 的宏包

### chapterbib 宏包

如果你只需要在你的书/论文的每一章末尾都有一个参考文献表，那么 `chapterbib` 宏包可能就足够了。

1. *每一章都应该放在各自独立的 `.tex` 文件中。* 编写

   ```latex
   \bibliographystyle{...}
   \bibliography{...}
   ```

   在每个 `.tex` 文件的每一章末尾。你可以为每一章指定不同的 `.bib` 文件。 `\bibliography`.
2. 在你的“主文档” `.tex` 文件中，加载 `chapterbib` 宏包。 `sectionbib` 宏包选项很有用，如果你希望每一章的参考文献表在实际章节之后以无编号节的形式出现，而不是无编号章。

   ```latex
   \usepackage[sectionbib]{chapterbib}
   ```
3. 使用 `\include` 在主文档文件中引入你的每个章节 `.tex` 文件。 *`\input` 将会 **不** 配合 `chapterbib` 一起工作，从而生成按章的参考文献表！*
4. 如果在本地机器上编译：编译你的主文档 `.tex` 将会生成多个 `.aux` 文件，每一章一个 `.tex` 文件。你现在必须在编译主文档 `bibtex` 文件之前，先对所有这些 `.aux` 文件运行 `.tex` 文件再次编译。 [Overleaf 的构建工具 `latexmk`,](/latex/zh-cn/zhi-shi-ku/064-how-does-overleaf-compile-my-project.md) 会自动处理所有这些步骤，所以你只需要点击一次 **“Recompile”** 按钮。

请注意，你 *绝不能* 在使用 `\bibliobraphy{...}` 时，在你的主文档 `.tex` 文件中写入 `chapterbib`。否则你可能会得到大量关于 *“Illegal; another \bibdata command”*&#x7684; BibTeX 错误消息。如果你还需要一个“全局”参考文献表来收集整个文档中的所有引用，那么 `bibunits` 宏包可能是更好的选择。

[在 Overleaf 中打开示例](https://www.overleaf.com/project/new/template/5694?id=8827885\&mainFile=main.tex\&templateName=Per-chapter+bibliographies+with+chapterbib)

### bibunits 宏包

该 `bibunits` 宏包也可用于创建按章参考文献表，而且各章不需要放在独立的 `.tex` 文件。

1. 先写入 `\usepackage[sectionbib]{bibunits}` 时，在你的主文档 `.tex`的导言区。
2. 要为文档中的所有引用使用相同的 `.bib` 文件和参考文献样式，请在加载 `\defaultbibliographystyle{...}` 和 `\defaultbibliography{...}` 命令之后使用 `bibunits`例如：

   ```latex
   \defaultbibliographystyle{unsrt}
   \defaultbibliography{references} % 不带扩展名的 .bib 文件名
   ```
3. 添加 `\bibliographyunit[\chapter]` 在 `\begin{document}`.
4. 在每一章的末尾，添加 `\putbib`。这将打印自上一个 `\cite` 以来出现的所有 `\chapter`的引用对应的参考文献表。 （你可以在文档后面的某处写 `\bibliographyunit` 而不带任何参数，以关闭章节的自动 `bibunit`化。）
5. 如果在本地机器上编译：编译你的主文档 `.tex` 将会生成多个 `.aux` 文件，每一章一个 `.tex` 文件。你现在必须在编译主文档 `bibtex` 文件之前，先对所有这些 `.aux` 文件运行 `.tex` 文件再次编译。 [Overleaf 的构建工具 `latexmk`,](/latex/zh-cn/zhi-shi-ku/064-how-does-overleaf-compile-my-project.md) 会自动处理所有这些步骤，所以你只需要点击一次 **“Recompile”** 按钮。

[在 Overleaf 中打开示例](https://www.overleaf.com/project/new/template/5695?id=8828133\&mainFile=main.tex\&templateName=Per-chapter+bibliographies+with+bibunits)

一些额外提示：

* 如果你为每一章/单元使用不同的 `.bib` 文件，你可以将其作为可选参数提供给 `\putbib`，例如 `\putbib[chap1refs]`——注意，没有 `.bib` 扩展名。
* 如果你需要将文档划分为任意的“参考文献单元”（即不局限于 `\chapter` 或其他节标题命令），并且每个单元都带有独立的引用和参考文献表，你可以使用 `bibunit` 环境，并在其中使用一个 `\putbib` ，在其中：

  ```latex
  \begin{bibunit}
  ...\cite{smith2012} 和 \cite{wilkins2008}...
  \putbib
  \end{bibunit}
  ```

  如果你需要为某个特定的 `bibunit` 即不同于你所指定的 `\defaultbibliographystyle{...}` 样式，你可以将其作为可选参数传给 `bibunit`: `\begin{bibunit}**[plain]**`
* 如果你还需要一个包含所有章节或 bibunit 中所有引用的“全局”参考文献表，请添加 `globalcitecopy` 选项，在加载 `bibunits` 宏包的示例代码： `\usepackage[sectionbib,**globalcitecopy**]{bibunits}`

### multibib 宏包

有时你可能希望为不同类别设置单独的参考文献表。实现这一点的一种方法是使用 `multibib` 宏包。例如，要为化学相关参考文献创建一个列表，为物理相关参考文献创建另一个列表，所需步骤如下：

1. 加载该 `multibib` 宏包，并使用 `\newcites` 命令来创建“`Math`”和“`Phys`”参考文献类型。它们将以“Math Readings”和“Physics Readings”作为参考文献标题。

   ```latex
   \usepackage[resetlabels,labeled]{multibib}

   \newcites{Math}{Math Readings}
   \newcites{Phys}{Physics Readings}
   ```

   你可以使用逗号分隔的值，在同一个 `\newcites{}` 命令中创建多个参考文献类型；只要确保你也指定了正确数量的参考文献标题：

   ```latex
   \newcites{Math,Phys}{Math Readings,Physics Readings}
   ```
2. 对于每个新的参考文献 `X`，你现在会有新的命令 `\citeX`, `\bibliographystyleX`, `\bibliographyX`。因此你现在将有

   * `\citeMath`, `\bibliographystyleMath`, `\bibliographyMath`
   * `\citePhys`, `\bibliographystylePhys`, `\bibliographyPhys`

   ，除了默认的 `\cite`, `\bibliographystyle`, `\bibliography`

   现在你可以使用 `\bibliographystyle`, `\bibliographystyleMath`, `\bibliographystylePhys` 来为每个参考文献指定样式；并指定 `.bib` 每个对应的文件 `\bibliography`, `\bibliographyMath`, `\bibliographyPhys`（参考文献样式通常在所有参考文献表中保持一致，但你也可能使用不同的 `.bib` 文件。）

   ```latex
   \cite{paper1} 和 \cite{paper2} 的发表时间晚于 \citeMath{paper3}。另见 \citePhys{paper4}。
   \bibliographystyle{unsrt}

   \bibliography{references}
   \bibliographystyleMath{unsrt}

   \bibliographyMath{refs-etc}
   \bibliographystylePhys{unsrt}

   \bibliographyPhys{refs-etc}
   在这个例子中，
   ```

   paper1 `paper2` 和 `在` 中定义，并且会列在 `references.bib` 默认参考文献表中。 `paper3` 会列在“Math Readings”参考文献表中； `paper4` 会列在“Physics Readings”参考文献表中；这两个 `paper3` 和 `paper4` 中定义，并且会列在 `refs-etc.bib` 文件中完全相同的大小写或拼写。
3. 如果在本地机器上编译：编译你的主文档 `.tex` 将会生成多个 `.aux` 文件中。你现在必须运行 `bibtex` 文件之前，先对所有这些 `.aux` 文件运行 `.tex` 文件再次编译。在 Overleaf 上，你只需点击 **重新编译** 按钮，它会自动处理所有这些步骤。

[在 Overleaf 中打开示例](https://www.overleaf.com/project/new/template/18645?id=3104751\&latexEngine=pdflatex\&mainFile=main.tex\&templateName=Multiple+Bibliographies+with+multibib)

## 使用 biblatex

如果你使用的是 biblatex 宏包，那么你 **不应** 加载前面各节提到的任何宏包：其中包括 `natbib`, `chapterbib`, `bibunits`, `multibib`.

### 按章参考文献

该 `biblatex` 宏包具有一个 `refsection` 机制，类似于一个“`bibunit`".

1. 你可以让 `biblatex` 自动开始一个新的 `refsection` 当它遇到 `\chapter`，只需添加 **`refsection=chapter`** 选项来加载 `biblatex`:

   ```latex
   \usepackage[natbib,style=authoryear,refsection=chapter]{biblatex}
   \addbibresource{refs.bib}
   ```
2. 然后你可以在 `\printbibliography` 每个……的末尾放置一个 `\chapter`，以仅列出自上一个 `\chapter`。 `heading=subbibintoc` 选项，用于 `\printbibliography`，这样参考文献会在章末以无编号节（`subbib`）而不是无编号章；并且它会被包含在目录中（`intoc`).

   ```latex
   \chapter{第一章}

   \section{Section Heading}
   这里有一个引用！ \citep{latex:companion}
   \printbibliography[heading=subbibintoc]


   \chapter{Second Chapter}

   \section{Section Heading}
   这里还有另一个引用！ \citep{lshort}
   \printbibliography[heading=subbibintoc]
   ```
3. 或者，你可以放置 `\begin{refsection}...\end{refsection}` 在每一章周围，或围绕任意文本块。此时不要使用 `refsection=chapter` 选项：

   ```latex
   \usepackage[natbib,style=authoryear]{biblatex}
   \addbibresource{refs.bib}
   ...
   \begin{refsection}
   \chapter{第一章}
   \section{Section Heading}
   这里有一个引用！ \citep{latex:companion}
   \printbibliography[heading=subbibintoc]
   \end{refsection}

   \begin{refsection}
   \chapter{Second Chapter}
   \section{Section Heading}
   这里还有另一个引用！ \citep{lshort}
   \printbibliography[heading=subbibintoc]
   \end{refsection}

   %% 可以使用这种方法创建一份出版物列表
   \begin{refsection}
   \nocite{paper1,paper2}
   %% 这里我们想要一个无编号章，但标题不同
   \printbibliography[title={List of Publications}]
   \end{refsection}
   ```

[在 Overleaf 中打开一个示例。](https://www.overleaf.com/docs?snip_uri=https://assets.ctfassets.net/nrgyaltdicpt/3mfINcJWZRlegHyXND3SEQ/7843cab4a5d022161a43bea6662bc00b/biblatex-perchapter.zip) paper1 `main.tex` 使用 `[refsection=chapter]` 宏包选项，而 `alt.tex` 使用手动插入的 `refsection` 这些环境。

### 不同类别的参考文献

你可以使用关键词或类别，根据不同主题创建独立的参考文献。

#### 使用关键词

1. 在这种方法中，你需要添加一个 **`关键词`** 字段到你在 `.bib` 文件中的参考文献条目中。例如：

   ```bibtex
   @article{paper4,
     title={High energy colliders as black hole factories...},
     ...
     keywords={phys}
   }
   ```
2. 像往常一样引用你的参考文献。
3. 然后发出几个 `\printbibliography` 命令，同时指定要包含哪些 `关键词` 以纳入其中。你可以为每个 `标题`设置不同的 `\printbibliography` 命令设置为特定值：

   ```latex
   % “主”参考文献表
   \printbibliography[notkeyword={math},notkeyword={phys}]

   % 数学参考文献表
   \printbibliography[keyword={math},title={Math Readings}]

   % 物理参考文献表
   \printbibliography[keyword={phys},title={Physics Readings}]
   ```

[在 Overleaf 中打开示例](https://www.overleaf.com/docs?snip_uri=https://assets.ctfassets.net/nrgyaltdicpt/3Bt5Tf9eSCtcXQrGshjQJT/7c64c3820a4adc4e20468aee752dc1e9/biblatex-keywords.zip)

#### 使用类别

1. 在这种方法中，你无需向你的 `.bib` 文件添加任何额外字段。相反，你会声明类别类型，并将参考文献添加到每个类别中，在你的 `.tex` 文件的导言区：

   ```latex
   \addbibresource{refs-nokeywords.bib}
   \DeclareBibliographyCategory{math}
   \DeclareBibliographyCategory{phys}
   \addtocategory{math}{paper3}
   \addtocategory{phys}{paper4}
   ```
2. 像往常一样引用你的参考文献。
3. 然后发出几个 `\printbibliography` 命令，每个都指定要打印哪个 `类别` 进行打印。

   ```latex
   % “主”参考文献表
   \printbibliography[notcategory={math},notcategory={phys}]

   % 数学参考文献表
   \printbibliography[category={math},title={Math Readings}]

   % 物理参考文献表
   \printbibliography[category={phys},title={Physics Readings}]
   ```

[在 Overleaf 中打开示例](https://www.overleaf.com/docs?snip_uri=https://assets.ctfassets.net/nrgyaltdicpt/6l5HYYfby0AscSXwLsWKPM/71b6fb3e848f473fc9d2735847af7ec1/biblatex-categories.zip)


---

# 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/wen-da/07-creating-multiple-bibliographies-in-the-same-document.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.
