> 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/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)

此示例中有一些变化：

* 选项 `方括号` 和 `数字` 在 `\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}. ({德文})
        [{关于}运动物体的电动力学]",
    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     = "\LaTeX\ 伴侣",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "美国马萨诸塞州雷丁"
}

@misc{knuthwebsite,
    author    = "Donald Knuth",
    title     = "Knuth：计算机与排版",
    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}

%在目录中包含“参考文献”
\usepackage[nottoc]{tocbibind}

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

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

\begin{document}

\maketitle

\tableofcontents

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

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

## 参考指南

**natbib 宏包选项**

* `圆括号` 用于圆括号
* `方括号` 使用方括号
* `花括号` 花括号
* `尖括号` 尖括号或 V 形符号
* `分号` 用分号分隔多个引用
* `冒号` 与……相同 `分号`
* `逗号` 用逗号分隔多个引用
* `作者-年份` 用于作者-年份引用
* `数字` 用于数字引用
* `上标` 数字引用使用上标，例如 *Nature*
* `排序` 按照参考文献列表对多个引用进行排序
* `排序并压缩` 与……相同 `排序` 但如果可能，多重数字引用会被压缩
* `压缩` 不排序直接压缩
* `先显示全名` 任何参考文献的第一次引用中都会显示作者全名
* `sectionbib` 应与宏包 **chapterbib** 一起使用，以便将参考文献作为未编号的节而不是未编号的章添加到目录中
* `nonamebreak` 防止作者姓名断词
* `省略` 用于省略合并引用中的共同元素

**标准条目类型**

**article**

来自杂志或期刊的文章

**book**

已出版的书籍

**booklet**

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

**conference**

会议论文集中的文章

**inbook**

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

**incollection**

书籍中有自己标题的部分

**inproceedings**

会议论文集中的文章

**manual**

技术文档

**硕士论文**

硕士论文

**misc**

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

**phdthesis**

博士论文

**proceedings**

与 conference 相同

**techreport**

由某机构出版的报告

**unpublished**

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

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

|           |           |              |
| --------- | --------- | ------------ |
| 地址        | 注释        | author       |
| booktitle | 章节        | 交叉引用         |
| edition   | editor    | institution  |
| 期刊        | 键         | month        |
| note      | number    | organization |
| pages     | publisher | 学校           |
| 系列        | title     | type         |
| volume    | year      | URL          |
| ISBN      | ISSN      | LCCN         |
| abstract  | keywords  | 价格           |
| 版权        | 语言        | 目录           |

## 进一步阅读

更多信息请参见

* [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://overleaf-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.
