本文的主要内容:
- 最基础的引用方式
- 如何使用BibTeX
- 如何方便地使用BibTeX
论文写作的过程中免不了引用文献。在Microsoft Word下我们可以通过像EndNote一样的工具来完成方便快捷地引用(但这两个工具都是收费的),那么在免费开源的LaTeX中,我们该如何实现引用呢?
最基础的引用方法
在LaTeX中,最为原始而基础的引用方式需要在.tex
文件最后输入一个thebibliography
环境,将我们要引用的文献信息硬编码在.tex
文件中。
下面是一个例子:
1 | \documentclass{ctexart} |
这是上面那个例子的输出:
这种方式如果不自定义标签,引用的形式就都是嵌在正文里,被方括号包裹的数字。这样明显达不到“方便”的程度。还好我们现在已经拥有了更加简便的工具。
BibTeX的基础用法
BibTeX是一个和LaTeX联用的管理文献和引用样式的工具。这时候我们会接触到一个新的文件格式,.bib
格式。
如何新建一个.bib
文件呢?非常简单。首先,打开记事本(Windows下的话,其他系统打开任意文本编辑器即可),随后输入以下代码:
1 | @article{patterson1917system, |
单击“保存”,随后将文件名字改为ref.bib
即可(前面的文件名可以随便取)。
我们刚刚干了什么呢?我们刚刚已将一堆文献的信息用一定的格式手动地集体存储至一个独立于.tex
文件的文本文档里。
每一段花括号内最开头的一段文字,如rigaudy1979nomenclature
就是我们刚刚接触过的“citekey”,在正文内我们只需要使用形似\cite{powell1984treatment}
的代码就可以引用啦!
而每一个文件中需要输入的内容大致有这些:
关键词 | 描述 |
---|---|
address | Usually the address of the publisher. At least for small publishers, this |
information | might be useful. |
annote | An annotation, not used by the standard bibliography styles. Other styles or |
macros | might use this. |
author | The name(s) of the author(s). |
booktitle | The title of a book, if you cite a part of that. For a book, use the title field instead. |
chapter | A chapter number. |
crossref | The key of the database entry being cross referenced. |
edition | The edition (First, Second, and alike) of a book. Commonly it's capitalized. |
editor | The name(s) of the editor(s). |
howpublished | The way of publishing, especially if it's unusual. Capitalize the first word. |
institution | Could be a sponsoring institution. |
journal | A journal name; you may use common abbreviations. |
key | Used for alphabetizing, cross-referencing, and labeling if the author information is missing. Don't confuse it with the key used in the \cite command which corresponds to the beginning of the entry. |
month | The month in which the work was published or written if it's not yet published. Usually a three letter abbreviation is used. |
note | Any additional useful information. Capitalize the first word. |
number | The number of a journal or another kind of work in a series. |
organization | Might be a sponsoring organization. |
pages | A page number or range of page numbers, like 12-18 or 22+. |
publisher | The name of the publisher. |
school | Could be the name of the school where the document was written. |
series | The name of a series of books or its number of a multi-volume set. |
title | The title of the work. |
type | The type of the publication. |
volume | The volume of a journal or multi-volume book. |
year | The year of the publication or the year when it was written if it hasn't been published yet. Commonly four numerals are used, such as 2010. |
但是你会发现,很多时候你根本不需要怎么多信息啊!一般来说BibTeX所需的信息和文献的类型有关,就是每一个开头@
后面的那个单词。
BibTeX里的文档类型有:
文档类型 | 需要的关键词 | 可选的关键词 |
---|---|---|
article | author, title, journal, year | volume, number, pages, month, note |
book | author or editor, title, publisher, year | volume or number, series, address, edition, month, note |
booklet | title | author, howpublished, address, month, year, note |
conference | author, title, booktitle, year | editor, volume or number, series, pages, address, month, organization, publisher, note |
manual | title | author, organization, address, edition, month, year, note |
mastersthesis | author, title, school, year | type, address, month, note |
misc | none | author, title, howpublished, month, year, note |
phdthesis | author, title, school, year | type, address, month, note |
proceedings | title, year | editor, volume or number, series, address, month, organization, publisher, note |
techreport | author, title, institution, year | type, number, address, month, note |
unpublished | author, title, note | month, year |
下面是一个例子(需要将刚刚生成的ref.bib
和下面这个.tex
文件放在同一目录下):
1 | \documentclass{ctexart} |
如果你没有使用TeXstudio这样的工具,而是手动编译.tex
文件的话,你需要先运行一遍XeLaTeX,再运行一遍BibTeX,再运行两边XeLaTeX。
我们可以通过改变\bibliographystyle{·}
中花括号内的内容来改变引用文献的样式。大家可以到这个网站寻找自己需要的样式:http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html
使用natbib
natbib
让我们引用的样式更多并且更加方便了。我们首先需要在导言区加载natbib
宏包。随后同样在导言区输入\bibliographystyle{apalike}
(只是个例子,花括号内的内容可以改),最后在正文的最后,输入\bibliography{·}
就能引用啦!
使用natbib
可以明显提升BibTeX的鲁棒性,对于非英语文献的支持性更好,一般来说是非常推荐使用natbib
的。