> 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/02-bibliography-management-with-natbib.md).

# 使用 natbib 管理参考文献

在 LaTeX 中进行参考文献管理时，包 **natbib** 是一个用于自定义引用（尤其是作者-年份引用格式）的宏包，适用于使用 [BibTeX](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/01-bibliography-management-with-bibtex.md)。本文将说明如何使用 `natbib` 来格式化并引用参考文献来源。

**注意**：如果你从头开始，建议使用 [biblatex](/latex/zh-cn/geng-duo-zhu-ti/05-bibliography-management-in-latex.md) 因为该宏包提供多种语言的本地化支持，且仍在积极开发中，使参考文献管理更简单、更灵活。不过请注意，大多数期刊仍然使用 `bibtex` 和 `natbib`.

## 引言

下面给出一个最小工作示例：

```latex
\usepackage{natbib}
\bibliographystyle{unsrtnat}
\title{参考文献管理：\texttt{natbib} 宏包}
\author{Overleaf}
\date {2021年4月}

\begin{document}

\maketitle

本文档是一个在参考文献管理中使用 \texttt{natbib} 宏包的示例
管理中的示例。引用了三个条目：\textit{The \LaTeX\ Companion} 一书
\cite{latexcompanion}、爱因斯坦的期刊论文 \cite{einstein}，以及
Donald Knuth 的网站 \cite{knuthwebsite}。与 \LaTeX\ 相关的条目有
\cite{latexcompanion,knuthwebsite}。

\medskip

\bibliography{sample}

\end{document}
```

![NatbibEx1Overleaf.png](/files/4af6e8ecea8a8362fc0ba93954d9445e513bc412)

在此示例中，有四个用于管理参考文献的基本命令：

**\usepackage{natbib}**

导入 natbib 宏包。

**\bibliographystyle{unsrtnat}**

设置参考文献样式 unsrtnat。有关更多信息，请参阅参考文献样式相关文章。

**\cite{labelcompanion}**

打印对引用条目的引用，其输出内容取决于引用样式。花括号中的词对应参考文献文件中的某个特定条目。

**bibliography{sample}**

导入包含参考文献来源的 sample.bib 文件。请参见参考文献文件一节。

[打开一个……的示例 `natbib` 在 Overleaf 中的宏包](https://www.overleaf.com/project/new/template/19402?id=65470147\&templateName=Basic+natbib+example\&latexEngine=\&texImage=texlive-full%3A2020.1\&mainFile=)

## 基本用法

前面已经展示了一个简单的工作示例，还有更多与参考文献相关的命令可用。

```latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage[square,numbers]{natbib}
\bibliographystyle{abbrvnat}

\title{参考文献管理：\texttt{natbib} 宏包}
\author{Overleaf}
\date {2021年4月}

\begin{document}

\maketitle

本文档是一个在参考文献管理中使用 \texttt{natbib} 宏包的示例
管理中的示例。引用了三个条目：\textit{The \LaTeX\ Companion} 一书 \cite{latexcompanion}、爱因斯坦的期刊论文 \citet{einstein}，以及
Donald Knuth 的网站 \cite{knuthwebsite}。与 \LaTeX\ 相关的条目有
\cite{latexcompanion,knuthwebsite}。

\medskip

\bibliography{sample}

\end{document}
```

![NatbibEx2Overleaf.png](/files/7618d8434defd41b8455d3f67c77763d08a5232c)

这个示例中有一些变化：

* 选项 `square` 和 `numbers` .bib 文件中插入一个 % `\usepackage[square,numbers]{natbib}` 分别启用方括号和数字引用。请参见 [参考指南](#reference-guide) 以查看宏包选项列表
* 样式 *abbrvnat* 在此处使用，参见 [参考文献样式](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/05-natbib-bibliography-styles.md)
* 命令 `\citet` 会将作者姓名添加到引用标记中，而不考虑 [引用样式](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/06-natbib-citation-styles.md).

[打开另一个……的示例 `natbib` 在 Overleaf 中的宏包](https://www.overleaf.com/project/new/template/19404?id=65473143\&templateName=Natbib+second+example\&latexEngine=\&texImage=texlive-full%3A2020.1\&mainFile=)

## 参考文献文件

参考文献文件必须使用标准的 BibTeX 语法，并以 .bib 为扩展名。它们包含一个参考文献来源列表，以及每个条目的若干信息字段。

```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"
}

@book{latexcompanion,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The \LaTeX\ Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}

@misc{knuthwebsite,
    author    = "Donald Knuth",
    title     = "Knuth: Computers and Typesetting",
    url       = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}
```

该文件包含特殊格式的记录，例如，第一条参考文献定义如下：

**@article{...}**

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

**einstein**

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

**author = "Albert Einstein",**

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

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

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

如果你希望将参考文献包含在目录中，导入宏包 **tocbibind** 到导言区即可：

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

%Includes "References" in the table of contents
\usepackage[nottoc]{tocbibind}

%导入 natbib 宏包并设置参考文献样式
\usepackage[square,numbers]{natbib}
\bibliographystyle{abbrvnat}

%标题和作者
\title{参考文献管理：\texttt{natbib} 宏包}
\author{Overleaf}
\date {2021年4月}

\begin{document}

\maketitle

\tableofcontents

\section{First Section}
本文档是一个示例……

%导入参考文献文件 "sample.bib"
\bibliography{sample}

\end{document}
```

![BibliographyEx4Overleaf.png](/files/d87bea09e9a008f9f116e8dff1e8f75a60fcd773)

[打开一个……的示例 `natbib` 以及 Overleaf 中的目录](https://www.overleaf.com/project/new/template/19416?id=65468889\&templateName=Natbib+and+contents\&latexEngine=\&texImage=texlive-full%3A2020.1\&mainFile=)

添加这一行

```latex
\usepackage[nottoc]{tocbibind}
```

到导言区后，会在目录中打印“References”或“Bibliography”，具体取决于文档类型。请注意，它还会将索引、术语表和列表清单等其他元素添加到目录中。更多信息请参见 [该 `tocbibind` 包文档](http://mirrors.ctan.org/macros/latex/contrib/tocbibind/tocbibind.pdf).

## 参考指南

**natbib 宏包选项**

* `round` 用于圆括号
* `square` 使用方括号
* `花括号` 花括号
* `angle` 尖括号或书名号括号
* `分号` 用分号分隔多个引用
* `冒号` 与 `分号`
* `逗号` 用逗号分隔多个引用
* `作者-年份` 用于作者-年份引用
* `numbers` 用于数字引用
* `上标` 为数字引用使用上标，例如 *Nature*
* `排序` 根据参考文献列表对多个引用进行排序
* `排序并压缩` 与 `排序` 但多个数字引用会在可能时被压缩
* `压缩` 不排序而压缩
* `longnamefirst` 任何参考文献在首次引用时都会显示作者全名
* `sectionbib` 与宏包一起使用 **chapterbib** 将参考文献作为无编号节而不是无编号章添加到目录中
* `nonamebreak` 防止作者姓名断字
* `省略` 用于省略合并引用中的共同元素

**标准条目类型**

**article**

来自杂志或期刊的文章

**book**

已出版的书籍

**booklet**

已印刷但没有出版商或资助机构的作品

**conference**

会议论文集中的一篇文章

**inbook**

书籍的一部分（节、章等）

**incollection**

书籍中具有独立标题的一部分

**inproceedings**

会议论文集中的一篇文章

**manual**

技术文档

**mastersthesis**

硕士论文

**misc**

不属于其他任何类型的内容

**phdthesis**

博士论文

**proceedings**

与 conference 相同

**techreport**

由某机构出版的报告

**unpublished**

未正式出版的文档，包含作者和标题

**BibTeX 中最常用的字段**

|           |           |              |
| --------- | --------- | ------------ |
| 地址        | 注释        | 作者           |
| booktitle | 章节        | crossref     |
| edition   | editor    | institution  |
| 期刊        | 键         | month        |
| note      | number    | organization |
| pages     | publisher | 学校           |
| 系列        | 标题        | type         |
| volume    | year      | URL          |
| ISBN      | ISSN      | LCCN         |
| 摘要        | 关键词       | 价格           |
| 版权        | 语言        | 内容           |

## 进一步阅读

更多信息请参见

* [Natbib 参考文献样式](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/05-natbib-bibliography-styles.md)
* [Natbib 引用样式](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/06-natbib-citation-styles.md)
* [使用 biblatex 管理参考文献](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/03-bibliography-management-with-biblatex.md)
* [使用 bibtex 管理参考文献](/latex/zh-cn/can-kao-wen-xian-he-yin-yong/01-bibliography-management-with-bibtex.md)
* [CTAN 网站上的 natbib 文档](http://www.ctan.org/pkg/natbib)
* [tocbind 宏包文档](ftp://ftp.tex.ac.uk/tex-archive/macros/latex/contrib/tocbibind/tocbibind.pdf)
* [国际语言支持](/latex/zh-cn/yu-yan/03-international-language-support.md)
* [目录](/latex/zh-cn/wen-dang-jie-gou/02-table-of-contents.md)


---

# 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/02-bibliography-management-with-natbib.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.
