In a document with many sources, a hand-made bibliography is a constant source of errors: a citation added and never listed, an author written two different ways, numbering to redo after every change. LaTeX solves the problem by separating data from presentation: the sources live in a separate file, the document calls them by a label, and the style decides how to display them.
The .bib file
Sources are collected in a text file with the .bib extension. Each entry has a type, a label and a set of fields:
@book{knuth1984,
author = {Knuth, Donald E.},
title = {The {TeXbook}},
publisher = {Addison-Wesley},
year = {1984}
}
@manual{pandoc-manual,
author = {MacFarlane, John},
title = {Pandoc User's Guide},
note = {Official documentation}
}
- The type (
@book,@article,@manual,@online,@incollection,@thesis…) determines which fields are expected and how the entry will be formatted. - The label (
knuth1984) is the name you will cite the source by. A fixed convention helps, for example surname plus year. - Multiple authors are separated with
and, not with commas:author = {Rossi, Anna and Bianchi, Luca}. - Inner braces, as in
{TeXbook}, protect capital letters that some styles would otherwise turn lowercase.
biblatex or BibTeX?
There are two systems. BibTeX is the older one, very widespread and required by several journals with their own style files. biblatex, used together with the Biber program, is more modern: it handles UTF-8 and accented letters well, has more entry types and lets you customise styles with LaTeX commands rather than with BibTeX's dedicated language.
If you do not have to follow a template imposed by a publisher, biblatex with Biber is the more convenient choice.
The document
\documentclass{article}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{sources.bib}
\begin{document}
The system is described in detail by \textcite{knuth1984}.
For the conversion options see the guide \parencite{pandoc-manual}.
\printbibliography
\end{document}
\addbibresourcepoints to the sources file, including the extension.csquotesis recommended by biblatex to handle quotation marks according to the language.\printbibliographyprints the list wherever you place it. Only the sources actually cited appear, unless you use\nocite{*}.
Citation commands
| Command | Typical use | Example output (author-year style) |
|---|---|---|
\textcite{key} |
Author as subject of the sentence | Knuth (1984) |
\parencite{key} |
Citation in brackets | (Knuth 1984) |
\parencite[45]{key} |
With page number | (Knuth 1984, p. 45) |
\cite{key} |
Basic form, no brackets | Knuth 1984 |
\footcite{key} |
Citation in a note | footnote |
Using the right command makes the text independent of the style: if you switch from author-year to numeric, \parencite automatically becomes «[1]».
Styles
The style is chosen with the style option. The most used among those included:
numeric: citations numbered in bibliography order.authoryear: author and year, common in the social sciences.alphabetic: labels such as [Knu84].verbose: full citation in a note at first occurrence, typical of the humanities.
There are also external styles that follow widespread conventions such as APA, installable as additional packages.
Compiling with Biber
Compilation needs several passes: LaTeX records the citations, Biber processes the .bib file, LaTeX inserts the results.
pdflatex thesis
biber thesis
pdflatex thesis
If question marks or bold labels appear instead of citations, Biber usually has not been run, or the wrong backend is set in the editor. latexmk runs the whole sequence on its own.
Do not write the .bib by hand
For a large bibliography a reference manager such as Zotero or JabRef is worth it. You import sources from catalogues, DOI identifiers or web pages, and export the .bib file automatically. With Zotero, the Better BibTeX extension keeps labels stable and updates the file on every change.
Still check the imported entries: titles in all capitals, inverted author names and missing fields are frequent.
In short
- Sources live in a
.bibfile, separate from the text, and are called by a label. - biblatex with Biber handles UTF-8 and customisation better; BibTeX is still required by some publishers.
\textcite,\parenciteand\footcitemake the text independent of the style.- Compilation requires a Biber pass, which
latexmkautomates. - A manager such as Zotero or JabRef saves writing entries by hand, but needs checking.