使用 natbib 进行参考文献管理

142 篇文章 4 订阅

原  文:Bibliography management with natbib
译  者:Xovee
翻译时间:2020年11月16日

使用 natbib 进行参考文献管理

在 LaTeX 的参考文献管理中,natbib 包是一个用来自定义引用(特别是作者-年份引用格式)的工具。这篇文章将介绍如何在 BibTeX 中使用 natbib 来管理参考文献的格式和参考文献的源文件。

注意:如果你是一个新手的话,我们建议你使用biblatex,这个包支持多种语言,非常的简单和灵活。不过,现如今大多数期刊依旧在使用 bibtex 和 natbib。

介绍

下面介绍一个简单的例子:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{natbib}
\bibliographystyle{unsrtnat}

\title{Bibliography management: \texttt{natbib} package}
\author{Share\LaTeX}
\date { }

\begin{document}

\maketitle

This document is an example of \texttt{natbib} package using in bibliography
management. Three items are cited: \textit{The \LaTeX\ Companion} book 
\cite{latexcompanion}, the Einstein journal paper \cite{einstein}, and the 
Donald Knuth's website \cite{knuthwebsite}. The \LaTeX\ related items are 
\cite{latexcompanion,knuthwebsite}. 

\medskip

\bibliography{sample}

\end{document}

在这里插入图片描述
这个例子介绍了四种基础的参考文献管理命令:

usepackage{natbib}
引入 natbib 包

\bibliographystyle{unsrtnat}
将参考文献的格式设置为unsrtnat参考文献样式这篇文章介绍了更多信息。

\cite{labelcompanion}
在文档中打印出一个参考文献,其样式取决于引用的样式。大括号中的参数对应于参考文献源文件中一个特定的记录。

bibliography{sample}
引入sample.bib文件,其中包含了参考文献的所有信息。

基础用法

下面的代码中包含了更多命令:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage[square,numbers]{natbib}
\bibliographystyle{abbrvnat}

\title{Bibliography management: \texttt{natbib} package}
\author{Share\LaTeX}
\date { }

\begin{document}

\maketitle

This document is an example of \texttt{natbib} package using in bibliography 
management. Three items are cited: \textit{The \LaTeX\ Companion} book \cite{latexcompanion}, the Einstein journal paper \citet{einstein}, and the 
Donald Knuth's website \cite{knuthwebsite}. The \LaTeX\ related items are
\cite{latexcompanion,knuthwebsite}. 

\medskip

\bibliography{sample}

\end{document}

在这里插入图片描述
几个变化:

  • 命令\usepackage[square,numbers]{natbib}中的选项squarenumber代表着引用的格式将是中括号和数字。文末介绍了其他可用的选项。
  • 使用了样式abbrvnat,见参考文献样式一文。
  • 命令\citet将会在引用中添加作者的名字,无论你使用哪种参考文献的样式

参考文献文件

参考文献文件必须服从标准的 bibtex 语法,其文件后缀为 .bib。文件中包含一系列参考文献的信息。

@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   = "Reading, Massachusetts"
}

@misc{knuthwebsite,
    author    = "Donald Knuth",
    title     = "Knuth: Computers and Typesetting",
    url       = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}

文件中包含了参考文献记录,记录有一种特殊的格式。例如,第一个参考文献又下面的命令定义:

@article{…}
这是参考文献条目的第一行,它告诉 BibTeX 这个条目的类型是 article。条目的信息包含在大括号之中。除了例子中的三种条目(article, book, misc),更多条目类型见文末。

einstein
这是条目的标签,是某个特定参考文献唯一的标识符。我们使用这个标签来在文档中引用这个参考文献。

author = “albert Einstein”,
这是参考文献条目的第一个字段,即该参考文献的作者是 Albert Einstein。你可以添加更多的字段,由逗号分割,语法是key = value,,例如:标题、页码、年份、URL等。更多例子见文末。

该参考文献中的内容可以随后在文档中进行引用和展示(命令为\bibliography{sample}。需要注意的是,.bib 文件中的信息并不是都会展示出来,展示哪些信息取决于你所使用的参考文献格式。例如,某些格式不会展示(打印)文献的出版商。

在文档目录中添加参考文献章

如果你向在文档的目录中添加参考文献的章节,引入tocbibind包:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage[nottoc]{tocbibind}

\begin{document}

\tableofcontents

\section{First Section}
This document ...

\bibliographystyle{unsrt}
\bibliography{sample}

\end{document}

在这里插入图片描述

目录中参考文献章的标题的具体内容取决于文档的类型,例如,\usepackage[nottoc]{tocbibind}可能会在表格中显示References,或者Bibliography。请小心使用这个包,它有时候会添加其他类型的元素,例如索引、术语表、图片和表格的列表等。更多信息请见其官方文档

参考指南

natbib 包的选项

  • round:圆括号
  • square:方括号
  • curly:大括号
  • angle:尖括号
  • semicolon:用分号来分割多个引用
  • colon:与semicolon相同
  • comma:用逗号来分割多个引用
  • authoryear:作者-年份 引用格式
  • number:数字 引用格式
  • super:位于上标的数字 引用格式,例如在 Nature 期刊中
  • sort:根据参考文献的列表来对多个引用排序
  • sort&compress:与sort相同,不过会尽可能地压缩多个数字引用
  • compress:压缩引用,不排序
  • longnamefirst:任何参考文献的第一个引用将会打印作者的全名
  • sectionbib:与chapterbib包配合使用,把参考文献添加在目录中,当作一个不编号的节(section),而不是一个不编号的章(chapter)。
  • nonamebreak:避免作者名字用连字号连接
  • elide:忽略合并参考文献的共同部分

标准条目类型

article
杂志或者期刊的文章

book
书籍

booklet
没有出版的或者没有赞助机构的书籍

conference
会议文章

inbook
书籍的一部分内容(例如章节)

incollection
书籍的某个拥有自己标题的内容

inproceedings
会议文章

manual
技术文档

masterthesis
硕士论文

misc
其他类型的文档

phdthesis
博士论文

proceedings
会议论文

techreport
一个机构出版的报告

unpublished
没有正式出版的文档,拥有作者和标题

BibTeX 中最常用的字段

  • address
  • annote
  • author
  • booktitle
  • chapter
  • crossref
  • edition
  • editor
  • institution
  • journal
  • key
  • month
  • note
  • number
  • organization
  • pages
  • publisher
  • school
  • series
  • title
  • type
  • volume
  • year
  • URL
  • ISBN
  • ISSN
  • LCCN
  • abstract
  • keywords
  • price
  • copyright
  • language
  • contents

延伸阅读

更多信息请见:

  • 22
    点赞
  • 66
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值