Latest news 2021-06-05: New blog post: Dickimaw Books Site Account.

5.2 BibTeX

Now that we've created a .bib file (as described above) we next need to look at how to incorporate the information in the database into a LaTeX document. As mentioned in Volume 1, entries are cited in the document using:

\cite[<text>]{<key list>}

where <key list> is a comma-separated list of keys. Each key uniquely identifies an entry in the database. If you used JabRef (§5.1.1. JabRef), this is the key you entered in the “Bibtexkey” field. If you wrote the .bib file in a text editor (§5.1.2. Writing the .bib File Manually) it's the <keyword> bit at the start of the list of fields for the entry.

Next you need to specify what type of bibliography style you want to use. There are many available, but the basic ones are:[Choosing a bibliography style]

Entries sorted alphabetically with abbreviated first names, months and journal names.

Entries sorted alphabetically with the citation represented by abbreviated author surname and year instead of a number.

Entries sorted alphabetically, with the citation represented by a number.

Entries sorted according to citation with the citation represented by a number.

The style is specified in your LaTeX document with the command:


where <style> is the name of the style. Some people put this command in the document's preamble and some people put it near their bibliography, but wherever you choose to put it, this command should only be used once.

The actual bibliography itself is input into the document using


where <database> is the name of the database without the .bib extension. In fact, this argument can be a comma-separated list of databases if your entries are stored across multiple files.

Recall the example thesis in Listing 1 ended with:

% The bibliography will go here


If my references are stored in the file thesis-ref.bib, then I can replace the above comment as follows:

Listing 15:

Elsewhere in my document I need some citations. For example:

See Turabian~\cite{turabian96} for a comprehensive guide on preparing a thesis.

If you are using arara (see §1.1.2. Arara) you need the following lines in your source code:

% arara: pdflatex: { synctex: on }
% arara: bibtex
% arara: pdflatex: { synctex: on }
% arara: pdflatex: { synctex: on }

If you are using latexmk (see §1.1.1. LaTeXmk) make sure you are using the -bibtex argument (Figure 1.5).

If you are not using either latexmk or arara, you will need to run PDFLaTeX, then run BibTeX, then run PDFLaTeX twice more (see §1.1. Building Your Document).

If your citations appear as two question marks ?? in your PDF, then the citation key you used hasn't been recognised. This could be that you've forgotten the BibTeX and subsequent two PDFLaTeX calls, or it could be that the key hasn't been defined, or you have misspelt it.

Recall from Volume 1 that the bibliography doesn't usually get added to the table of contents for most class files, but the KOMA-Script classes provide the options bibliography=totocnumbered and bibliography=totoc, that add a numbered or unnumbered bibliography to the table of contents.

You can add backlinks from your bibliography back to the section or page where the entries were cited using the backref option of the hyperref package. (The hyperref package should usually be loaded last.) For example, to have backreferences to the pages on which the citation occurs:


The hyperref package is covered in more detail in Creating a PDF Document using PDFLaTeX [14].

This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-02-9).

© 2013 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs