BibTeX

BibTeX is the classic way to manage references: you record each work once in a .bib database, and the bibliography is generated from it automatically. In the document you only ever call a key with \cite. Swap the style file (.bst) and the same data is recast to match any journal’s format. This page covers how to write a .bib file, what \bibliographystyle and \bibliography do, and the distinctive “latex → bibtex → latex → latex” build sequence.

What is BibTeX

You can list references by hand at the end of a document (the thebibliography environment), but that breaks down as the count grows and as you reuse the same works across several papers. BibTeX is a separate program, written by Oren Patashnik around 1985, that runs alongside — but apart from — TeX/LaTeX itself. Its job is to pull from a bibliography database only the works you actually cited, format them in a chosen style, and write them out in a form the document can splice in.

The mechanism has three parts: the **.bib file (the raw reference data), the \cite** calls plus two commands in the document (\bibliographystyle and \bibliography), and the **.bst file** (the style) that fixes the appearance. Because data and appearance are separate, switching venues never touches the data — you change a single style word. This is exactly the “separate structure from appearance” idea that runs through all of LaTeX.

Writing the .bib database

A .bib file is a list of entries. Each entry declares a type such as @article, then in braces gives a citation key followed by fields. The citation key is an identifier you choose (e.g. knuth1984) that must match \cite{...} in the document exactly. Fields take the form fieldname = {value}, separated by commas.

references.bib
@book{knuth1984,
  author    = {Donald E. Knuth},
  title     = {The {TeX}book},
  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}
}

@inproceedings{lamport1987,
  author    = {Leslie Lamport},
  title     = {Document Production: Visual or Logical?},
  booktitle = {Proceedings of TUG},
  year      = {1987},
  pages     = {19--24}
}

It pays to learn the common types and their required fields. @article is a journal paper (author, title, journal, year); @book is a book (author or editor, title, publisher, year); @inproceedings is a paper in conference proceedings (author, title, booktitle, year). Others include @phdthesis/@mastersthesis for dissertations, @incollection for a chapter in a book, and @misc for odds and ends such as web pages. Which fields are required for each type is decided by the style.

The braces around a value carry practical meaning. Nesting an extra pair inside, as in title = {The {TeX}book}, shields that span from the style’s upper/lower-casing (so TeX is not lowered to Tex). For multiple authors, separate them with **and** — author = {A. Smith and B. Jones} — and let BibTeX and the style handle name order and abbreviation.

The two commands in the document

In the document you place two commands where the bibliography should appear (usually at the end of the body). \bibliographystyle{plain} selects the style — which .bst to use — and \bibliography{references} both tells BibTeX which database to read and prints the reference list at that spot. Note that the latter takes no .bib extension: even though the file is references.bib, you write references.

document.tex
\documentclass{article}
\begin{document}

TeX was created by Knuth~\cite{knuth1984}, building on
Shannon's information theory~\cite{shannon1948}.

\bibliographystyle{plain}
\bibliography{references}

\end{document}

In the body, \cite{knuth1984} points at the citation key knuth1984 in the .bib. If the keys do not match, the work will not appear (you get an undefined-reference warning). Only cited works show up in the list; anything in the .bib that you did not cite is ignored (use \nocite{*} to force the whole database in). The variations of \cite itself — multiple citations, page locators, the cite package — are covered on the “Citing basics” page.

The build sequence (four runs)

This is where BibTeX first trips people up. To produce the list correctly, the classic recipe runs the tools four times in the order latex → bibtex → latex → latex. Why several passes? Because BibTeX is a separate program from LaTeX itself, and the two exchange information through auxiliary files (.aux and .bbl).

  • 1st latex — processes the body and writes the cited keys plus the \bibliographystyle/\bibliography settings into the .aux file. At this point the reference list is still blank.
  • bibtex — reads the .aux to learn which keys were cited, which style, and which .bib; pulls the matching entries from the .bib; formats them by the rules in the .bst; and writes the **.bbl file**.
  • 2nd latex — pulls in the .bbl and sets the reference list, but the cross-references (such as each entry’s number) are not yet resolved.
  • 3rd latex — the numbers and \cite markers settle, so the in-text citations and the reference list line up exactly.
terminal
$ latex document.tex     # writes document.aux (cite keys)
$ bibtex document        # reads .aux + .bib + .bst, writes .bbl
$ latex document.tex     # pulls in .bbl
$ latex document.tex     # resolves all references

Note that you hand bibtex the auxiliary name (the job name, without extension), not the .tex. The recipe is identical with pdflatex — just replace latex with pdflatex. Because typing four commands every time is tedious, in practice you delegate to **latexmk**, which inspects the .aux to decide whether BibTeX needs to run and how many passes are required, usually finishing in a single invocation.

terminal
$ latexmk -pdf document.tex   # runs latex/bibtex/latex as many times as needed

Standard styles (.bst)

A style fixes the sort order, the label (a number or an abbreviation), and how author names and journal titles are shortened. BibTeX ships four standard styles, and knowing these covers most needs. You switch simply by passing the name to \bibliographystyle{...}.

StyleOrderLabel / trait
plainAlphabetical by authorNumbered [1]; the usual default
unsrtOrder of first citationNumbered [1] (same format as plain)
alphaBy label (roughly author, year)Alphanumeric labels like [Knu84]
abbrvAlphabetical by authorAbbreviates first names and journal titles

Beyond these, several field-specific staples ship as standard too: **ieeetr (IEEE Transactions look, numbered in citation order), widely used in engineering; acm (ACM style) in computer science; and siam** (SIAM style) in applied mathematics. Societies and publishers also distribute their own .bst files, which you swap in to match a venue’s requirements. The BibTeX payoff is that changing the style requires no change at all to the .bib or to the \cite calls in the body.

Japanese: pbibtex / upbibtex

Plain bibtex targets Western text and does not sort or process fields containing Japanese author names or titles well. So pLaTeX/upLaTeX provide Japanese-aware commands. **pbibtex is for pLaTeX and sorts by EUC-JP code points; upbibtex** is for upLaTeX and sorts by Unicode code points. Both descend from JBibTeX (developed by Shouichi Matsui) and extend the built-in functions so that Japanese fields are handled without being split mid-character.

Usage mirrors the Western case: in the build sequence you simply replace **latex with platex (or uplatex) and bibtex with pbibtex (or upbibtex). Japanese counterparts of the styles exist too — jplain** for plain, **junsrt** for unsrt, jalpha for alpha, and jname, which puts the surname at the head as in “[Kin80] Kinoshita: …” (society styles such as jipsj are available as well).

terminal
$ uplatex  document.tex   # 1st pass: writes .aux
$ upbibtex document       # Japanese-aware: writes .bbl
$ uplatex  document.tex   # pulls in .bbl
$ uplatex  document.tex   # resolves references
$ dvipdfmx document.dvi   # DVI -> PDF

Because upLaTeX goes through DVI, you finish by converting to PDF with dvipdfmx (this pipeline is detailed on the Japanese and DVI-converter pages). latexmk can be configured to call pbibtex/upbibtex, so the four manual passes are automated for Japanese too.

Limits of BibTeX, and biber/biblatex

BibTeX is mature and widely used, but its design is old and carries several limitations: it assumes 8-bit encodings and does not handle Unicode cleanly (multilingual author names and accents are awkward), its sorting is inflexible, and crafting a complex format means writing .bst — an idiosyncratic, stack-oriented little language.

To lift these limits came biblatex (a LaTeX package) and its default backend, biber. They handle Unicode natively, let you control sorting and formatting through options on the LaTeX side, and spare you from writing .bst. For new projects, biblatex/biber is a strong choice — covered on its own page.