BibTeX’s version number is still 0.99d. That is the number TeX Live 2024 ships, and the official documentation, btxdoc.tex, still carries the date 8 February 1988 and still promises to be expanded “when BibTeX version 1.00 comes out.” Version 1.00 has not come out. And yet BibTeX remains the reference point for handling a bibliography in LaTeX, for a simple reason: from the start it separated what a work is (the .bib database) from how it is printed (the .bst style). This page covers writing a .bib file, what \cite, \bibliographystyle and \bibliography each do, the four-run latex → bibtex → latex → latex build, and why LaTeX Warning: Citation ... undefined sometimes refuses to go away.
Why BibTeX is a separate program from LaTeX
BibTeX is not part of LaTeX; it is a separate executable. More than that, it never reads your .tex file at all. It reads only the .aux that LaTeX produced, picks up three things from it — which keys were cited, which style was requested, which .bib to open — and writes its answer back into a .bbl. That strict division of labour is precisely why the build takes four runs, as we will see. The copyright line still sitting at the top of the standard style files reads “Copyright (C) 1984, 1985, 1988 Howard Trickey and Oren Patashnik” — years when LaTeX itself was still taking shape. BibTeX was not bolted on afterwards; it was designed as a near-contemporary companion.
The mechanism has three parts: the .bib file holding the raw reference data; the \cite calls plus two commands in the document (\bibliographystyle and \bibliography); and the .bst file that fixes the appearance. Listing references by hand at the end of a document with the thebibliography environment is fine for something small, but the moment you start reusing the same works across several papers you lose track of which version is correct. That is the problem BibTeX solved: keep the data in one place, and changing venues costs you one style word instead of an afternoon. The “separate structure from appearance” idea that runs through all of LaTeX is simply applied to citations here.
How to write a .bib entry: type, citation key, fields
A .bib file is plain text listing entries. Each entry declares an entry type such as @article, then inside braces gives the citation key first and the fields after it, written as fieldname = {value} and separated by commas. The citation key is an identifier that must match \cite{...} in the document character for character; naming is up to you. The usual convention, surname plus year as in knuth1984, rarely collides and stays memorable in a co-authored paper. The order of the fields makes no difference to the output — sorting and formatting are the style’s job, not yours.
@string{bstj = "Bell System Technical Journal"}
@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 = bstj, % @string abbreviation, no braces
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}
}What counts as a required field is decided by the style, not by BibTeX itself. Run the standard plain and any gap is named for you: Warning--empty journal in shannon1948. These are warnings, not errors, so processing continues — the information simply vanishes from the output without comment, which is exactly why the warnings are worth reading. Defining an abbreviation with @string{bstj = "..."} lets you reference the value as a bare name with no braces. And the crossref field lets a chapter inherit from a parent @proceedings entry, so the conference name and publisher need not be retyped for every paper in the volume.
| Entry type | What it covers | Required by plain |
|---|---|---|
@article | A paper in a journal | author, title, journal, year |
@book | A book from a publisher | author or editor, title, publisher, year |
@inproceedings | A paper in conference proceedings | author, title, booktitle, year |
@incollection | A chapter of a book with its own title | author, title, booktitle, publisher, year |
@phdthesis | A doctoral thesis (@mastersthesis for a master’s) | author, title, school, year |
@techreport | A report issued by an institution | author, title, institution, year |
@unpublished | An unpublished draft or communication | author, title, note |
@misc | Anything that fits nowhere else, e.g. a web page | None; howpublished and note do the work |
Why plain turns TeX into tex: brace-protecting capitals
The plain and abbrv styles lowercase a paper’s title except for the first letter. So an @article whose title reads title = {A Note on TeX and NASA Systems} comes out as “A note on tex and nasa systems”. Proper nouns and acronyms are flattened without mercy. There is exactly one defence: wrap the part you want to keep in another pair of braces. Written as {TeX} and {NASA}, those spans are left alone. Note that the lowercasing applies to article titles (title), not to book titles or booktitle — so bracing {TeX} inside an @book does no harm but also no work, and knowing that saves some confusion.
% unprotected: plain.bst prints "A note on tex and nasa systems"
@article{bad,
author = {A. One},
title = {A Note on TeX and NASA Systems},
journal = {J. Test},
year = {2000}
}
% protected: prints "A note on {TeX} and {NASA} systems"
@article{good,
author = {B. Two},
title = {A Note on {TeX} and {NASA} Systems},
journal = {J. Test},
year = {2000}
}
% names: separate with "and"; brace a corporate author whole
@misc{org,
author = {{World Health Organization}},
title = {Annual Report},
year = {2024}
}Author names follow the same logic. Separate several authors with and (author = {A. Smith and B. Jones}); the comma is reserved for splitting surname from given name, so author = {Smith, Alice} means surname Smith, given name Alice. End the list with and others and the style substitutes “et al.”. Corporate authors are the awkward case: unless you wrap the whole name in another pair of braces, as in {World Health Organization}, BibTeX dissects it into surname and initials. It parses names as syntax, so when you want something exempted from that parsing you silence it with braces — the same single tool as before.
What \bibliographystyle and \bibliography actually do
Both commands are less about printing than about leaving a message in the .aux. \bibliographystyle{plain} writes \bibstyle{plain} there and \bibliography{references} writes \bibdata{references}; BibTeX reads those and acts on them. \bibliography has a second job as well: it prints the reference list at the point where you put it, which is why it normally sits at the end of the body, just before \end{document}. Its argument takes no extension — even though the file is references.bib, you write references — and several databases are given as a comma-separated list, \bibliography{books,papers}.
\documentclass{article}
\begin{document}
TeX was created by Knuth~\cite{knuth1984}, building on
Shannon's information theory~\cite{shannon1948,lamport1987}.
% \nocite{*} % force every entry of the database into the list
\bibliographystyle{plain}
\bibliography{references}
\end{document}In the body, \cite{knuth1984} points straight at the citation key in the .bib. Only cited works reach the list: an entry that sits in the .bib but is never \cited is ignored. To force the whole database in, add \nocite{*} — \nocite registers a work as cited without printing any mark in the text. Keys can be combined in one call, \cite{shannon1948,lamport1987}. The variations on \cite itself — a page locator with \cite[p.~42]{knuth1984}, or author–year forms such as natbib’s \citet and \citep — belong to the citing page.
Why the build runs latex → bibtex → latex → latex
Four runs are needed because information only flows one way at a time. BibTeX cannot know what you cited without the .aux, and LaTeX cannot know what to print without the .bbl. The numbers “[1]”, “[2]” are only settled once the reference list has actually been typeset, so getting those numbers back into the \cite marks in the body costs another lap. BibTeX’s own documentation, btxdoc.tex, spells out this recipe — and adds that in very rare circumstances you may need an extra BibTeX and LaTeX run on top.
- 1st latex — processes the body and writes the cited keys as
\citation{...}, plus the style and database as\bibstyle{...}and\bibdata{...}, into the.aux. No reference list exists yet. - bibtex — reads only the
.aux, learns which keys, which style and which.bib; pulls the matching entries from the database; formats them by the rules in the.bst; and writes a wholethebibliographyenvironment out as the.bblfile. - 2nd latex — reads the
.bbland typesets the reference list. The\citemarks in the body, however, are still working from the old.aux, so theCitation ... undefinedwarnings do not disappear on this pass. - 3rd latex — the numbers settle and the in-text citations finally match the list. Only now do the warnings stop.
$ pdflatex document.tex # writes document.aux (\citation, \bibstyle, \bibdata)
$ bibtex document # note: job name, not document.tex -> writes .bbl and .blg
$ pdflatex document.tex # pulls in .bbl; citations still undefined here
$ pdflatex document.tex # numbers settle; warnings clearThe one spelling trap is that bibtex takes the job name, without extension, not the .tex. Typing bibtex document.tex sends it looking for document.tex.aux and it fails. Alongside its output, BibTeX writes a log named .blg, which is where to look when you want to re-read the full text of a warning afterwards. And in practice nobody types the four commands: latexmk inspects the .aux, decides whether BibTeX needs to run and how many passes are required, so latexmk -pdf document.tex is the whole recipe.
Citation ... undefined, and a bibliography that comes out empty
You see LaTeX Warning: Citation ... undefined and LaTeX Warning: There were undefined references., the citations in the text render as [?], and the bibliography is missing along with its heading. Nine times out of ten the cause is simply that you have not run enough passes. With no .bbl yet, LaTeX prints not one line of the list — and the heading is missing too because the thebibliography environment itself lives inside the .bbl. So first, calmly run latex → bibtex → latex → latex all the way through. If the warning survives that, BibTeX will have printed a different message of its own.
| Message | Where it appears | Cause and fix |
|---|---|---|
Citation ... undefined | LaTeX | No .bbl yet, or a stale one. Run the full latex → bibtex → latex → latex |
There were undefined references. | LaTeX | Some \cite or \ref is still unresolved; run latex once more |
I found no \citation commands | BibTeX | Neither \cite nor \nocite is present; cite something, or add \nocite{*} |
I found no \bibstyle command | BibTeX | \bibliographystyle{...} is missing from the document |
I found no database files | BibTeX | \bibliography{...} is absent, or the named .bib cannot be found |
I found no style file | BibTeX | No .bst of that name exists; check the spelling or install the venue’s .bst |
Warning--I didn't find a database entry | BibTeX | A key you cited is not in the .bib — a typo, or an entry never added |
If the problem still will not go, suspect stale auxiliary files. After you rename a key, move the .bib to another directory, or swap the style, the .aux, .bbl and .blg may still be carrying last run’s information. latexmk -C deletes the generated files in one go, and rebuilding from scratch after that is the shortest route. Remember too that citation keys are case-sensitive: Knuth1984 and knuth1984 are two different works as far as BibTeX is concerned.
plain vs unsrt vs alpha vs abbrv
The four standard styles differ in only three respects — sort order, the shape of the label, and how far names and journal titles are abbreviated — while the fields they include are identical. That is no accident: plain.bst, unsrt.bst, alpha.bst and abbrv.bst are all built from a single file. A template called btxbst.doc is fed to the C preprocessor with -DPLAIN, -DUNSRT, -DALPHA or -DABBRV, as the file itself explains at the top. The four styles look subtly different because they are conditional compilations of one text.
| Style | Sort order | Label and character |
|---|---|---|
plain | Alphabetical by author | Running numbers [1]; the safest default |
unsrt | Order of first citation in the text | Running numbers [1]; formatting identical to plain |
alpha | By label, which is effectively author then year | Alphanumeric labels like [Knu84]; readable in maths-heavy fields |
abbrv | Alphabetical by author | Same numbering as plain, but abbreviates given names, months and journal titles to save space |
The BibTeX distribution also carries four more styles that its own README calls “semi-standard”: acm (ACM Transactions), apalike (APA-like author–year, used together with apalike.sty), ieeetr (IEEE Transactions, numbered in citation order) and siam (SIAM). Engineering usually starts from ieeetr, computer science from acm, and psychology or the social sciences from apalike when author–year is required. Beyond that, societies and publishers distribute .bst files matching their submission rules, so if the venue is already decided, look for theirs first. Whichever style you move to, not one line of the .bib or of the \cite calls has to change.
Why nobody writes .bst by hand: makebst and custom-bib
The reason .bst files are avoided is that they are written in a postfix stack language. The official guide for style designers, btxhak.tex (Oren Patashnik, 8 February 1988), says so outright in its opening lines: you write bibliography styles in a postfix stack language, and the style file is a program written in an unnamed language. The language does not even have a name. It has only ten commands, but every value is pushed onto and popped off a stack, so merely formatting an author field runs on as a long stretch of reverse Polish notation. Copying an existing .bst and adapting it is feasible; designing one from nothing rarely pays.
$ latex makebst # answer the questions; choose "merlin" as the master file
# -> writes a .dbj batch job
$ latex mystyle.dbj # runs docstrip -> mystyle.bstWhat people actually use is the custom-bib package, whose front door is makebst. Type latex makebst and an interactive questionnaire begins: should the surname come first, should the year sit in parentheses, should titles be italic — you answer, and a .bst comes out the other end. Its author is Patrick W. Daly, the same person who wrote natbib and brought author–year citations to the LaTeX side; the styles makebst produces are designed to work together with natbib. When a journal’s rules are almost, but not quite, one of the existing styles, this is the most realistic way out.
Handling Japanese references: pbibtex and upbibtex
Plain bibtex assumes Western text, so a .bib containing Japanese author names or titles breaks both its sorting and its string handling. TeX Live therefore ships pbibtex (for pLaTeX, sorting by EUC-JP code points) and upbibtex (for upLaTeX, sorting by Unicode code points). What matters is that these do more than swap encodings: the style language itself is extended. A new built-in, is.kanji.str$, reports whether a string contains any non-ASCII character; substring$ was modified so it never cuts a multi-byte character in half; and add.period$ was taught not to append a full stop after Japanese punctuation such as 。 and ?. The lineage runs back to Shouichi Matsui’s JBibTeX, and the distribution still ships that history in its documentation.
$ 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 -> PDFJapanese counterparts of the styles ship as well: jplain for plain, junsrt for unsrt, jalpha for alpha, jabbrv for abbrv, and jname, which leads with the surname. For societies there are jipsj (Information Processing Society of Japan), tipsj, tieice (IEICE) and jorsj — and these too are cut from a single template, jbtxbst.doc, by the C preprocessor, exactly as on the Western side. The build changes only in its names: latex becomes platex or uplatex, bibtex becomes pbibtex or upbibtex. Because the route goes through DVI, you finish by converting with dvipdfmx. latexmk can be told in its configuration file to call these, so Japanese work automates just as well.
Stay with BibTeX, or move to biblatex and biber?
The dividing line is clear. If the venue prescribes a .bst, use BibTeX; if you control the format yourself, use biblatex and biber. BibTeX’s design assumes 8-bit encodings, so multilingual author names and accented characters need patching, and the sorting rules are out of reach. Changing the format in any detail means touching a .bst, which is the unnamed stack language from the previous section. In short, every weakness of BibTeX traces back to one thing: a design frozen in 1988.
Waiting on the other side are biblatex (a LaTeX package) and its default backend, biber. They take Unicode as it comes, expose sorting and formatting as options on the LaTeX side, and spare you from writing a single line of .bst. The commands change too — \cite gives way to \autocite and \printbibliography — and the build calls biber instead of bibtex. The .bib file itself, however, is common to both, so switching costs less than it looks. That is where the decision made forty years ago — separating what a work is from how it is printed — pays off most.