Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 38 ยท Cross-references and Bibliographies

BibTeX Basics: Citations and .bib Files

Keep your references in a .bib file, cite them with \cite, pick a bibliography style and run BibTeX to produce a formatted reference list.

A research paper, report or thesis needs a list of sources, and the citations in the text must match that list exactly. BibTeX is the classic way to manage this in LaTeX. You store every source once in a plain-text database (a .bib file), cite entries by key, and BibTeX builds the formatted reference list for you.

The big advantage is separation: the data about a book lives in one place, and the style (author-year, numbered, abbreviated names) lives in a separate style file. Change the style and the whole list reformats.

The workflow in four parts

  1. A .bib file holding entries.
  2. \cite{key} commands in the text.
  3. \bibliographystyle{...} and \bibliography{...} at the end of the document.
  4. A build sequence: LaTeX, then BibTeX, then LaTeX twice.
LATEX
\documentclass{article}
\begin{document}

Knuth describes the idea in detail \cite{knuth1984}.
Several studies agree \cite{lamport1994,goossens1993}.

\bibliographystyle{plain}
\bibliography{references}   % reads references.bib

\end{document}

Only entries that are cited appear in the list. To include an entry without citing it, use \nocite{key}; \nocite{*} includes everything in the .bib file.

Anatomy of a .bib entry

BIBTEX
@book{knuth1984,
  author    = {Donald E. Knuth},
  title     = {The {TeXbook}},
  publisher = {Addison-Wesley},
  year      = {1984},
}

@article{shannon1948,
  author  = {Claude E. Shannon},
  title   = {A Mathematical Theory of Communication},
  journal = {Bell System Technical Journal},
  volume  = {27},
  number  = {3},
  pages   = {379--423},
  year    = {1948},
}

An entry starts with @type{key, followed by field = {value}, pairs. The key must be unique and has no spaces. Common types and their required fields:

Type Use for Required fields
@article Journal paper author, title, journal, year
@book Book author or editor, title, publisher, year
@inproceedings Conference paper author, title, booktitle, year
@phdthesis, @mastersthesis Theses author, title, school, year
@techreport Report author, title, institution, year
@misc Websites and anything else none

Writing author names

Separate several authors with the word and, never a comma. Either Last, First or First Last works, but with commas BibTeX is never confused by prefixes and suffixes:

BIBTEX
author = {Lamport, Leslie and Goossens, Michel and Mittelbach, Frank},

Protecting capitals with braces

Most styles lowercase titles. Wrap words that must keep their capitals in braces: , , . Write a page range with a double hyphen 379--423 so it prints as an en dash.

The stand-in below parses .bib text into objects and builds an author-year citation, which is what a style file does in miniature.

JS Parse a .bib file and format citations

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Built-in bibliography styles

\bibliographystyle{...} chooses the look. The standard styles are:

  • plain: numbered [1], sorted alphabetically by author.
  • unsrt: numbered in order of first citation.
  • alpha: labels like [Knu84].
  • abbrv: like plain but with abbreviated first names and months.

For author-year citations such as "(Knuth, 1984)" the standard styles are not enough. Use natbib with a style such as plainnat or abbrvnat:

LATEX
\usepackage[round]{natbib}
...
\citet{knuth1984}   % Knuth (1984)
\citep{knuth1984}   % (Knuth, 1984)
\citep[p.~12]{knuth1984}   % (Knuth, 1984, p. 12)
\bibliographystyle{plainnat}
\bibliography{references}

Many journals and universities supply their own .bst style file; you place it in the project folder and name it without the extension.

Building the document

BibTeX is a separate program from LaTeX, so the build order is:

  1. pdflatex main: writes citation keys to main.aux.
  2. bibtex main: reads main.aux and references.bib, writes main.bbl.
  3. pdflatex main: reads main.bbl, inserts the list, but numbers may still be [?].
  4. pdflatex main: final run, all citations resolved.

Editors and latexmk automate this. A diagram of the data flow:

flowchart LR
  A["main.tex"] -->|"pdflatex"| B["main.aux"]
  B -->|"bibtex"| C["main.bbl"]
  D["references.bib"] --> C
  E["style.bst"] --> C
  C -->|"pdflatex x2"| F["main.pdf"]

The .aux file tells BibTeX which keys are cited; the .bbl file carries the formatted list back to LaTeX.

Common mistakes

  • Missing comma after a field. BibTeX stops with a confusing error about the next line.
  • Unbalanced braces in a title or author field.
  • Using & or % unescaped in a field; write \& and \%.
  • Duplicate keys in the .bib file: only the first is used.
  • Forgetting to run BibTeX: citations display as [?] and a warning "Citation undefined" appears.
  • Mixed-up editor and author for edited books.

Reference managers such as Zotero, JabRef or Mendeley can export .bib files and keep keys consistent, saving you from typing every entry by hand. Always skim exported entries, since automatic exports often lose capital-letter protection.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How do you separate multiple authors in a .bib author field?

    BibTeX splits names on the word and. Commas are reserved for the Last, First form.
  2. 2. What does the .bbl file contain?

    BibTeX writes the formatted thebibliography environment to the .bbl file, which LaTeX then reads.
  3. 3. Which style gives numbered references in order of first citation?

    unsrt numbers in citation order, while plain sorts the list alphabetically.
  4. 4. Why wrap a word such as {TeXbook} in braces inside a title?

    Braces protect capitalisation from the style's automatic case changes.

Summary

  • Keep sources in a .bib file, cite with \cite{key}, and add \bibliographystyle and \bibliography at the end.
  • Entry types such as @article and @book require specific fields; authors are joined with and.
  • natbib provides \citet and \citep for author-year styles.
  • Build order is LaTeX, BibTeX, LaTeX, LaTeX; missing citations show [?].
  • Protect capitals with braces and escape special characters.

Next: biblatex and Biber