> 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-tw/can-kao-wen-xian-yu-yin-wen/02-bibliography-management-with-natbib.md).

# 使用 natbib 管理參考書目

在 LaTeX 中進行參考文獻管理時，套件 **natbib** 是在使用 [BibTeX](/latex/zh-tw/can-kao-wen-xian-yu-yin-wen/01-bibliography-management-with-bibtex.md)時，用來自訂引用格式（特別是作者－年份引用格式）的套件 `natbib` 來格式化並引用參考文獻來源。

**注意**：如果你是從頭開始，建議使用 [biblatex](/latex/zh-tw/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/fdf547c27fdf716c4f87c1f0df687e17b13ebd82)

在這個範例中，有四個用來管理參考文獻的基本指令：

**\usepackage{natbib}**

載入 natbib 套件。

**\bibliographystyle{unsrtnat}**

設定參考文獻樣式為 unsrtnat。更多資訊請參閱關於參考文獻樣式的文章。

**\cite{labelcompanion}**

列印一個對引用條目的參照，實際列印內容取決於引用樣式。大括號中的詞語對應於參考文獻檔案中的特定條目。

**bibliography{sample}**

載入包含參考文獻來源的 sample.bib 檔案。請參閱參考文獻檔案章節。

[在 Overleaf 中開啟一個 `natbib` 套件範例](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/2532f6ede703ac1d6e07cfb568a55a61cf4ca7c3)

這個範例有幾個變更：

* 選項 `square` 以及 `numbers` 在 `\usepackage[square,numbers]{natbib}` 分別啟用方括號與數字型引用。請參閱 [參考指南](#reference-guide) 以取得套件選項清單
* 樣式 *abbrvnat* 在此使用，請參閱 [書目樣式](/latex/zh-tw/can-kao-wen-xian-yu-yin-wen/05-natbib-bibliography-styles.md)
* 指令 `\citet` 會將作者姓名加入引用標記中，不論 [引用樣式](/latex/zh-tw/can-kao-wen-xian-yu-yin-wen/06-natbib-citation-styles.md).

[再開啟另一個 `natbib` 套件範例](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   = "麻薩諸塞州雷丁"
}

@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 等。請參閱參考指南以查看可用欄位清單。

這個檔案中的資訊之後可以如前面章節所示，透過命令 `\bibliography{sample}`在 LaTeX 文件中列印並引用。並非 .bib 檔案中的所有資訊都會顯示，這取決於文件中設定的書目樣式。

## 將書目加入目錄

如果你希望將參考文獻包含在目錄中，載入套件 **tocbibind** 並放在前言區即可：

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

%在目錄中加入「References」
\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/420b89a15ac9e6be44cc11bbe50265d7fb6517bd)

[在 Overleaf 中開啟一個 `natbib` 與目錄的範例](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` 使用方括號
* `curly` 大括號
* `angle` 角括號或 chevron
* `分號` 以分號分隔多個引用
* `冒號` 與 `分號`
* `逗號` 以逗號分隔多個引用
* `authoryear` 用於作者－年份引用
* `numbers` 用於數字型引用
* `上標` 數字型引用的上標，例如 *Nature*
* `排序` 依照參考文獻清單排列多個引用
* `排序並壓縮` 與 `排序` 但若可能，多個數字型引用會被壓縮
* `壓縮` 在不排序的情況下壓縮
* `longnamefirst` 作者的全名將出現在任何參考文獻的第一次引用中
* `sectionbib` 要與套件 **chapterbib** 搭配使用，將參考文獻加入目錄中，作為無編號節，而不是無編號章節
* `nonamebreak` 避免作者姓名斷字
* `elide` 用來省略合併引用中的共同元素

**標準條目類型**

**article**

來自雜誌或期刊的文章

**book**

已出版的書籍

**booklet**

已印製但沒有出版社或贊助機構的作品

**conference**

會議論文集中的文章

**inbook**

書籍的一部分（節、章等等）

**incollection**

具有自己標題的書籍部分

**inproceedings**

會議論文集中的文章

**manual**

技術文件

**mastersthesis**

碩士論文

**misc**

不屬於其他任何類型的內容

**phdthesis**

博士論文

**proceedings**

與 conference 相同

**techreport**

由某機構出版的報告

**unpublished**

未正式出版的文件，含作者與標題

**BibTeX 中最常用的欄位**

|           |           |              |
| --------- | --------- | ------------ |
| 地址        | 註記        | author       |
| booktitle | 章節        | crossref     |
| edition   | editor    | institution  |
| 期刊        | 鍵         | month        |
| 注意        | number    | organization |
| pages     | publisher | 學校           |
| series    | title     | type         |
| volume    | year      | URL          |
| ISBN      | ISSN      | LCCN         |
| abstract  | 關鍵字       | 價格           |
| 版權        | language  | 內容           |

## 延伸閱讀

更多資訊請參見

* [Natbib 參考文獻樣式](/latex/zh-tw/can-kao-wen-xian-yu-yin-wen/05-natbib-bibliography-styles.md)
* [Natbib 引用樣式](/latex/zh-tw/can-kao-wen-xian-yu-yin-wen/06-natbib-citation-styles.md)
* [使用 biblatex 進行參考書目管理](/latex/zh-tw/can-kao-wen-xian-yu-yin-wen/03-bibliography-management-with-biblatex.md)
* [使用 bibtex 進行參考書目管理](/latex/zh-tw/can-kao-wen-xian-yu-yin-wen/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-tw/yu-yan/03-international-language-support.md)
* [目錄](/latex/zh-tw/wen-jian-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-tw/can-kao-wen-xian-yu-yin-wen/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.
