> 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/shen-ru-wen-zhang/13-getting-started-with-biblatex.md).

# BibLaTeX 入門

**作者：Josh Cassidy（2013 年 7 月）**

多年來 LaTeX 使用者一直使用 BibTeX 以及多個額外套件，例如 `natbib` 來撰寫參考文獻。不過現在有了新的選擇：BibLaTeX。它的設計讓你能用更多選項輕鬆設定參考文獻／引用。很方便的是，現有的 `.bib` 檔案若要與 BibLaTeX 搭配使用，通常不需要大幅修改。除了 300 多頁的 [BibLaTeX 文件](http://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf)，CTAN 還有一份實用的 [BibLaTeX「速查表」](http://tug.ctan.org/info/biblatex-cheatsheet/biblatex-cheatsheet.pdf)。為了補充這些資源，以下提供一段影片教學，並附上一些筆記／範例，幫助你開始上手。

{% embed url="<https://www.youtube.com/embed/nH9If8c5VCs>" %}

### 基本指令與樣式

首先，你在 tex 檔中用來將參考文獻加入文件的指令與以往相當不同。在導言區你需要使用以下程式碼：

```latex
\usepackage{biblatex}
\addbibresource{}
```

第一個指令只是載入 `biblatex` 套件。第二個則用來指定你要使用哪些 bib 檔。你只要在大括號中輸入檔名，包括 `.bib` 副檔名。接著在文件正文中，不再使用 `\bibliography` 指令來建立參考文獻，而是使用 `\printbibliography` 指令。使用 BibTeX 時，你會透過 `\bibliographystyle` \bibliographystyle 指令。在 `biblatex` BibLaTeX 中，我們不再使用這個指令，而是透過將更多參數傳入 `\usepackage` \usepackage 指令。為此，我們輸入 `樣式=` 後面接上樣式名稱，並把它放在緊接著大括號之前的方括號中。例如：

```latex
\usepackage[style=numeric]{biblatex}
```

或者，如果你想為引用宣告一種樣式、為參考文獻宣告另一種樣式，則可使用 `citestyle` 和 `bibstyle`這兩個字。以下是一個範例：

```latex
\usepackage[citestyle=alphabetic,bibstyle=authortitle]{biblatex}
```

在往下看之前，我先快速示範這些樣式在引用與實際參考文獻項目中的效果。不過，你可以 [查閱文件](http://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf) 以取得完整樣式清單。

* 該 `數字` 樣式： ![BiBLaTeXnumeric.png](/files/6ce41393cb2eea9b26ea2d0438cb3aaaf2def482)－ `字母順序` 樣式： ![BiBLaTeXalphabetic.png](/files/842d68f7a5d4cec9e77e0500fb796436be1a3e2f)－ `閱讀` 樣式： ![BiBLaTeXreading.png](/files/a61dc53064caccdb972f7623ba2ad3c1f1afccbc)－ `作者年份` 樣式： ![BiBLaTeXauthoryear.png](/files/e913a2160c2fd22d1c345a57209628cd82f1756f)

你還可以給 `\usepackage` 指令的另一個參數是排序選項。例如：

```latex
\usepackage[style=authoryear,sorting=ynt]{biblatex}
```

這會使用作者－年份樣式，然後依年份、名稱、標題來排序參考文獻項目。以下列出一些可用的排序選項：

* `nty`—依名稱、標題、年份排序項目；
* `nyt`—依名稱、年份、標題排序項目；
* `nyvt`—依名稱、年份、卷期、標題排序項目；
* `anyt`—依字母標籤、名稱、年份、標題排序項目；
* `anyvt`—依字母標籤、名稱、年份、卷期、標題排序項目；
* `ynt`—依年份、名稱、標題排序項目；
* `ydnt`—依年份（遞減順序）、名稱、標題排序項目；
* `無`—不排序。項目會依照它們在正文中出現的順序呈現。

如果你沒有指定順序，預設值是 `nty`.

### 引用指令

在 `biblatex`中，引用指令也已經全面改寫。 `前註` 和 `後註` 作為參數加入：

* a `前註` 是一個像「see」這樣的字詞或片語，會插入在引用開頭；
* a `後註` 是你想插入在引用結尾的文字。

要加入這些註記，你可以在引用指令中使用兩組方括號。以下是一個範例：

```latex
\cite[see][page 12]{latexcompanion}
```

在這個範例中，我們已經載入了 `字母順序` 樣式和 `latexcompanion` 只是引用鍵。這就是引用在正文中的樣子：

![BiBLaTeXprepost.png](/files/da1afce72e716eaaf1f63970384cbcfe0d888dcc)

如果你只打開一組方括號，系統會假設括號中的內容是 `後註`前註， `前註` 所以如果你只想要一個後註，請確保你還是打開第二組方括號，然後把它留空。

你還可以使用多種不同的引用指令。以下是一些標準的指令：

* `\cite`—最基本的一個。除非使用 `字母順序` 或 `數字` 樣式時會使用方括號；
* `\parencite`—引用會以括號形式輸出，除非使用 `字母順序` 或 `數字` 樣式時會使用方括號；
* `\footcite`—將引用放在註腳中。

### 將參考文獻分組

其中一個很棒的地方是 `biblatex` 就是你可以依來源類型將參考文獻分組。以下是依來源類型分組的範例：

```latex
\printbibheading
\printbibliography[type=book,heading=subbibliography,title={Book Sources}]
\printbibliography[nottype=book,heading=subbibliography,title={Other Sources}]
```

在這個範例中，我們把參考文獻分成兩個區塊，一個是書籍來源，另一個則是非書籍來源。以下是輸出範例：

![BiBLaTeXtypes.png](/files/baad3a4ae31cb4930fc311de78375bab40ad8d4b)

另一種將參考文獻分組的方法是使用關鍵字篩選器。要做到這點，你需要在你的 `keywords` 中的條目加入一個 `.bib` 檔案中的參考條目。範例如下：

```latex
@article{key,
	keywords = {keywordA,keywordB,keywordC}
```

以下是之後如何依關鍵字分組的範例：

```latex
\printbibheading
\printbibliography[keyword=major,heading=subbibliography,title={Major Sources}]
\printbibliography[keyword=minor,heading=subbibliography,title={Minor Sources}]
```

對應的輸出如下：

![BiBLaTeXmajor.png](/files/5be4a375d67a84c6f3e8c21699719b6906b409f4)

看來不久的將來 BibTeX 只會成為 LaTeX 歷史中的一小段了！希望這對你開始使用 `biblatex`.


---

# 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/shen-ru-wen-zhang/13-getting-started-with-biblatex.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.
