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

# 在同一份文件中建立多個參考書目

## 簡介

本文將討論如何使用適當的套件，在同一份 LaTeX 文件中建立多個參考文獻列表。預設情況下，每份 LaTeX 文件只能包含一個參考文獻或參考列表，不論是使用 `\begin{thebibliography}\bibitem...\end{thebibliography}` 清單，或使用 `\bibligraphystyle{...}\bibliography{...}`、或 `\printbibliography`。但在某些情況下，您可能需要建立 *多個參考文獻列表*。您可能希望每個章節各自有一份參考文獻列表，而不是整份文件共用一份。或者，您也可能希望針對不同的類別與主題分別建立參考文獻列表。

如果您試圖透過在文件中放入多個 `\bibliography` 呼叫來因應這些情況，您會發現它們都包含相同的項目清單，涵蓋 *整份* 您整個文件中的所有引文。相反地，您必須使用適當的 LaTeX 套件才能正確產生分開的參考文獻列表。

您首先需要確認您是否使用 [BibTeX](/latex/zh-tw/can-kao-wen-xian-yu-yin-wen/01-bibliography-management-with-bibtex.md) 或 [biblatex](/latex/zh-tw/can-kao-wen-xian-yu-yin-wen/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` .bib 檔案。 *`\input` 將會 **不** 搭配 `chapterbib` 產生各章節的參考文獻列表！*
4. 如果是在本機編譯：編譯您的主文件 `.tex` 將會產生多個 `.aux` 檔案，每個章節各一個 `.tex` 您先前包含的檔案。您現在必須對所有這些 `bibtex` 執行 `.aux` 檔案，然後再編譯主文件 `.tex` 檔案一次。 [Overleaf 的建置工具 `latexmk`,](/latex/zh-tw/zhi-shi-ku/064-how-does-overleaf-compile-my-project.md) 將會自動處理所有這些步驟，因此您只需要點擊 **「重新編譯」** 按鈕一次。

請注意，您 *絕對不要* 寫入 `\bibliobraphy{...}` 在主文件 `.tex` 檔案中使用 `chapterbib`。否則您可能會收到許多關於 BibTeX 的錯誤訊息，內容涉及 *「Illegal；另一個 \bibdata 指令」*。如果您也需要一份「全域」參考文獻列表，用來彙整整份文件中的所有引文， `bibunits` 套件可能是更好的選擇。

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

### bibunits 套件

該 `bibunits` 套件也可以用來建立每章的參考文獻列表，而且章節不需要分開放在不同的 `.tex` .bib 檔案。

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-tw/zhi-shi-ku/064-how-does-overleaf-compile-my-project.md) 將會自動處理所有這些步驟，因此您只需要點擊 **「重新編譯」** 按鈕一次。

[在 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} and \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} and \cite{paper2} were published later than
   \citeMath{paper3}. See also \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{First Chapter}

   \section{Section Heading}
   Here's a citation! \citep{latex:companion}
   \printbibliography[heading=subbibintoc]


   \chapter{Second Chapter}

   \section{Section Heading}
   Here's another citation! \citep{lshort}
   \printbibliography[heading=subbibintoc]
   ```
3. 或者，您也可以把 `\begin{refsection}...\end{refsection}` 包住每個章節，或包住任意的文字區塊。此時不要使用 `refsection=chapter` 這個選項：

   ```latex
   \usepackage[natbib,style=authoryear]{biblatex}
   \addbibresource{refs.bib}
   ...
   \begin{refsection}
   \chapter{First Chapter}
   \section{Section Heading}
   Here's a citation! \citep{latex:companion}
   \printbibliography[heading=subbibintoc]
   \end{refsection}

   \begin{refsection}
   \chapter{Second Chapter}
   \section{Section Heading}
   Here's another citation! \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) 在此範例中， `main.tex` 使用 `[refsection=chapter]` 套件選項，而 `alt.tex` 則使用手動插入的 `refsection` 這些環境。

### 不同類別的參考文獻列表

您可以使用關鍵字或類別，根據不同主題建立分開的參考文獻列表。

#### 使用關鍵字

1. 在這種方法中，您需要在 **`keywords`** 欄位加入 `.bib` 檔案中的參考條目。範例如下：

   ```bibtex
   @article{paper4,
     title={High energy colliders as black hole factories...},
     ...
     keywords={phys}
   }
   ```
2. 如常引用您的參考文獻。
3. 接著使用多個 `\printbibliography` 指令，並指定要包含哪些 `關鍵字` 要納入。您可以為每個 `title`設定不同的 `\printbibliography` 命令：

   ```latex
   % 「主」參考文獻列表
   \printbibliography[notkeyword={math},notkeyword={phys}]

   % Math 參考文獻列表
   \printbibliography[keyword={math},title={Math Readings}]

   % Physics 參考文獻列表
   \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}]

   % Math 參考文獻列表
   \printbibliography[category={math},title={Math Readings}]

   % Physics 參考文獻列表
   \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-tw/wen-yu-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.
