Every LaTeX reference list has the same three moving parts: a set of records
(usually a .bib file), a program that formats them (BibTeX or Biber), and a
command in the document that prints the result. Almost every broken bibliography
is a mismatch between those three rather than a mistake inside any one of them.
Here are the two setups that work with a .bib file, how to choose between them,
and the compile order that makes the list actually appear — plus a third route,
at the end, for when you do not want a .bib file at all.
The two routes, and how to pick
| Route 1: BibTeX | Route 2: biblatex + Biber | |
|---|---|---|
| Load the records | \bibliography{refs} (no extension) |
\addbibresource{refs.bib} (with extension) |
| Print the list | same command | \printbibliography |
| Choose the style | \bibliographystyle{plain} — a .bst file |
a package option: style=authoryear |
| Formatting program | bibtex |
biber |
Pick Route 1 if a publisher handed you a class or a .bst file — IEEEtran,
acmart, elsarticle, most journal templates. IEEEtran and elsarticle ship BibTeX
styles only; acmart ships biblatex styles as well, but its own manual calls that
support experimental and says ACM’s TAPS production system does not accept it.
Arguing with the template costs more than it saves.
Pick Route 2 if the choice is yours. Styles are package options instead of files you have to hunt for, sorting handles non-ASCII names properly, and you can print several bibliographies from one source (per chapter, or primary sources separately).
One .bib file feeds either route, but do not mix the commands.
\bibliographystyle belongs to Route 1 and \printbibliography to Route 2.
Route 1 — BibTeX, in four commands
Two files. refs.bib:
@inproceedings{vaswani2017attention,
author = {Vaswani, Ashish and Shazeer, Noam and Parmar, Niki},
title = {Attention Is All You Need},
booktitle = {Advances in Neural Information Processing Systems},
year = {2017}
}
main.tex:
\documentclass{article}
\begin{document}
Attention-based models replaced recurrence for sequence transduction
\cite{vaswani2017attention}.
\bibliographystyle{plain}
\bibliography{refs} % refs.bib, written without the extension
\end{document}
Then run, in this order:
pdflatex main # writes main.aux: \citation{...}, \bibdata{refs}, \bibstyle{plain}
bibtex main # reads main.aux, pulls the cited entries from refs.bib, writes main.bbl
pdflatex main # pulls in main.bbl — the list appears, in-text numbers are still [?]
pdflatex main # the numbers resolve
Two details do most of the damage. The second command takes the job name
(main), not main.tex and not refs — BibTeX is a separate program that runs
against the .aux file, not against your source. And LaTeX has to run twice
afterwards: once to pull in the list BibTeX generated, once to number the
citations that the list just defined.
latexmk -pdf main.tex runs the whole chain and repeats until the output stops
changing; Overleaf and most editor build buttons do the same thing. Run the four
commands by hand once anyway. When the build button fails, the log you need is
BibTeX’s own (main.blg), and knowing which pass produced it saves an hour.
Why the list is empty
| What you see | What went wrong |
|---|---|
[?] where the citation should be |
LaTeX has not run twice since BibTeX |
| No bibliography at all | BibTeX never ran, or ran on the wrong name |
I found no \citation commands |
the .aux holds no \citation — the LaTeX pass aborted before writing them, or nothing cites anything (with no .aux at all the message is I couldn't open file name `main.aux') |
I couldn't open database file refs.bib |
BibTeX searched and did not find it — wrong path or wrong name |
An entry sits in refs.bib but never prints |
nothing cites it |
Citation undefined after a full clean run |
the key in \cite does not match the key in the entry |
The fifth row is worth stating on its own: BibTeX prints only what you cite.
A 200-entry .bib in a paper that cites twelve of them produces a list of
twelve. When you want the whole file printed — a reading list, an annotated
bibliography — put \nocite{*} before \bibliography{refs}.
The cite commands: natbib in practice
Plain LaTeX gives you one command, \cite{key}, and it prints whatever the style
dictates. That is not enough for author-year writing, where the citation is part
of the sentence in one place and inside parentheses in another. natbib adds the
distinction:
\usepackage[authoryear]{natbib} % use [numbers] instead for [1]
\bibliographystyle{plainnat} % must be a natbib-aware .bst
| Command | Prints |
|---|---|
\citet{vaswani2017attention} |
Vaswani et al. (2017) |
\citep{vaswani2017attention} |
(Vaswani et al., 2017) |
\citep[see][p. 5]{key} |
(see Vaswani et al., 2017, p. 5) |
\citeauthor{key} and \citeyear{key} |
Vaswani et al. / 2017 |
\cite{key} |
style-dependent — be explicit instead |
The trap: in author-year mode, a style that is not natbib-aware (plain,
abbrv, unsrt) raises Bibliography not compatible with author-year citations on the following run and drops the whole document back to numeric
citations. natbib needs a .bst that emits author-year data — plainnat,
abbrvnat, unsrtnat, or whichever natbib-aware style your venue ships.
Numeric citations compress if you ask them to:
\usepackage[numbers,sort&compress]{natbib} turns \cite{a,b,c,d} into [1–4]
rather than [1, 2, 3, 4].
Choosing a style
.bst |
In-text | List order |
|---|---|---|
plain |
[1] |
alphabetical by author |
unsrt |
[1] |
order of first citation |
abbrv |
[1] |
alphabetical, initials for given names |
alpha |
[Vas17] for a lone author, [VSP17] for the three-author entry above |
alphabetical |
ieeetr |
[1] |
order of first citation |
plainnat |
numeric or author-year, via natbib | alphabetical |
abbrvnat |
the same, with initials for given names | alphabetical |
If the journal supplies a .bst, use it and ignore the table. If it only names a
style in prose (“APA 7th”), biblatex with style=apa — the biblatex-apa
package, which follows the 7th edition and requires Biber — is usually less
painful than hunting for a BibTeX style that matches.
Route 2 — biblatex and Biber
\documentclass{article}
\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{refs.bib} % with the extension, unlike \bibliography
\begin{document}
\textcite{vaswani2017attention} replaced recurrence with attention, and the
result has been reproduced widely \parencite{vaswani2017attention}.
\printbibliography
\end{document}
pdflatex main
biber main # not bibtex
pdflatex main
pdflatex main
Same shape, different second command. The citation commands rename cleanly:
\textcite is natbib’s \citet, \parencite is \citep, and \footcite puts
the citation in a footnote. Switching the whole document from numeric to
author-year is one option — style=numeric becomes style=authoryear, then
recompile. Under Route 1 that is a different .bst, and often a different
package as well.
Two options you will want quickly:
\printbibliography[title={References}, heading=bibintoc] renames the section
and lists it in the table of contents, and \printbibliography[keyword=primary]
prints a filtered subset. Filtered bibliographies have no BibTeX equivalent worth
the effort.
Route 3 — no .bib file at all
For a five-reference course report, the whole apparatus is optional:
\begin{thebibliography}{9}
\bibitem{vaswani2017attention}
A. Vaswani, N. Shazeer, and N. Parmar.
\newblock Attention Is All You Need.
\newblock In {\em Advances in Neural Information Processing Systems}, 2017.
\end{thebibliography}
\cite{vaswani2017attention} works exactly as before and there is no second
program to run — two LaTeX passes and you are done. In exchange you format every
entry yourself, nothing sorts, and changing style means rewriting the list. It is
worth knowing that this is precisely what BibTeX generates into main.bbl:
routes 1 and 3 produce the same construct, one by program and one by hand.
Doing this without a local TeX install
The part that stays tedious in all three routes is the .bib file itself. Every
entry is a record somebody typed: publisher pages export them with the venue in
the wrong field, booktitle missing, names mangled. No style file repairs a
wrong record.
Litlas works on that end. Its editor compiles LaTeX in the
browser — a WebAssembly build of pdfTeX, so there is no local TeX installation to
maintain — and citations come out of your saved library instead of being typed.
Picking a paper from the library inserts \cite{key} at the cursor and merges
that paper’s BibTeX entry into the document in the same action, so a citation and
its entry cannot drift apart. The bibliography block does not have to exist
first — the first citation creates one (the IEEE and ACM starters ship an
empty one already). If you would rather have a real .bib, add one to the
project and use \bibliography{refs}: the bundled engine runs classic BibTeX
after each pass and repeats LaTeX (up to four passes) until references resolve,
so the four-step chain above happens behind one Compile button. An existing
.bib can be pasted or uploaded, and entries already present are skipped rather
than duplicated.
The limitation to know before moving a manuscript there: the in-browser engine
cannot run Biber. A Route 2 document compiles, but the bibliography does not
resolve. The editor detects the combination and offers a one-click conversion to
a thebibliography block that does compile — useful, but if your venue mandates
biblatex, keep that document on a full local or server-side TeX. The free plan
needs no card and covers this workflow, with caps (3 boards, 100 saved items, 5
searches a day); sharing a document by link is free, while inviting a co-author
by email address is a paid feature.
Before you submit
- Delete
main.aux,main.bblandmain.blg, then run the full chain from clean. A stale.bblhides problems until the deadline. - Search the output PDF for
[?]and for the word undefined. - Read
main.blg. Missing required fields are warnings there, not errors, so nothing stops you from submitting a reference with no year in it. - Confirm the style is the one the venue asked for, not the one that came with the template you copied.
