When it comes to bibliography management in LaTeX the program natbib is an alternative used in several journals. The program is not actively developed, but is very stable and widely used. This article explains how to use natbib to format and cite bibliographic sources.
Note: If you are starting from scratch it's recommended to use biblatex since that package provides localization in several languages, it's actively developed and makes bibliography management easier and more flexible.
Contents |
A minimal working example is presented below:
\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}
In this example there are four basic commands to manage the bibliography:
usepackage{natbib}
\bibliographystyle{unsrtnat}
\cite{labelcompanion}
bibliography{sample}
Open an example of the natbib package in ShareLaTeX
A simple working example was shown at the introduction, there are more bibliography-related commands available.
\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}
There are a few changes in this example:
square
and numbers
in \usepackage[square,numbers]{natbib}
enable squared brackets and numeric citations respectively. See the reference guide for a list of package options
\citet
adds the name of the author to the citation mark, regardless of the citation style.
Open an example of the natbib package in ShareLaTeX
The bibliography files must have the standard bibtex syntax and the extension .bib. They contain a list of bibliography sources and several fields with information about each entry.
@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" }
This file contains records in a special format, for instance, the first bibliographic reference is defined by:
@article{...}
@article
tells BibTeX that the information stored here is about an article. The information about this entry is enclosed within braces. Besides the entry types shown in the example (article
, book
and misc
there are a lot more, see the reference guide.
einstein
einstein
is assigned to this entry, is a unique identifier that can be used to refer this article within the document.
author = "Albert Einstein",
key = value
, for instance: title, pages, year, URL, etc. See the reference guide for a list of possible fields.
The information in this file can later be printed and referenced within a LaTeX document, as shown in the previous sections, with the command \bibliography{sample
. Not all the information in the .bib file will be displayed, it depends on the bibliography style set in the document.
Open an example of the natbib package in ShareLaTeX
If you want the bibliography to be included in the table of contents, importing the package tocbibind in the preamble will do the trick:
\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}
Adding the line
\usepackage[nottoc]{tocbibind}
to the preamble will print the "References" or "Bibliography" in the table of contents, depending on the document type. Be careful, it will also add other elements like the Index, Glossary and list of Listings to the table of contents. For more information see the tocbibind package documentation.
Open an example of the natbib package in ShareLaTeX
natbib package options
round
for round parentheses
square
uses square brackets
curly
curly braces
angle
angle braces or chevrons
semicolon
separates multiple citations with semicolons
colon
same as semicolon
comma
separate multiple citations with commas
authoryear
for author-year citations
numbers
for numerical citations
super
superscripts for numerical citations, as in Nature
sort
orders multiple citations according to the list of references
sort&compress
same as sort
but multiple numerical citations are compressed if possible
compress
compress without sorting
longnamefirst
the full name of the author will appear in the first citation of any reference
sectionbib
To be used with the package chapterbib to add the bibliography to the table of contents as a unnumbered section instead of an unnumbered chapter
nonamebreak
prevents hyphenation of author names
elide
to omit common elements of merged references
Standard entry types
article
book
booklet
conference
inbook
incollection
inproceedings
manual
mastersthesis
misc
phdthesis
proceedings
conference
techreport
unpublished
Most common fields used in BibTeX
address | annote | author |
booktitle | chaper | 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 |
For more information see