Bibliography Management with BibTeX: .bib Files, \cite and Styles
Quick answer
- References: entries in
refs.bib, one per source, each with a key. - Cite:
\cite{key}in the text. - Print the list:
\bibliographystyle{plain}and\bibliography{refs}(no.bib). - Compile: pdfLaTeX → BibTeX → pdfLaTeX → pdfLaTeX. Octree and Overleaf do this automatically.
\documentclass{article}
\begin{document}
Knuth designed \TeX{} for high-quality typesetting \cite{knuth1984}.
\bibliographystyle{plain}
\bibliography{refs} % reads refs.bib
\end{document}BibTeX keeps your references in a separate database file and formats only the ones you cite, in whatever style the journal asks for. You write each source once, cite it by a short key, and switch citation styles by changing one line. This guide covers the .bib file and its entry types, citing, choosing a style, the compile order, natbib and biblatex, and the errors that leave you with [?] in the text. Ready-made entries for APA, MLA, Chicago and IEEE are in the bibliography examples.
The .bib File
A .bib file is plain text. Each entry starts with @type, then a citation key you choose, then field = {value} pairs separated by commas. Save this next to your .tex file as refs.bib:
% refs.bib
@book{knuth1984,
author = {Knuth, Donald E.},
title = {The {\TeX}book},
publisher = {Addison-Wesley},
address = {Reading, MA},
year = {1984}
}
@article{lamport1987,
author = {Lamport, Leslie},
title = {Document Production: Visual or Logical?},
journal = {Notices of the American Mathematical Society},
volume = {34},
pages = {621--624},
year = {1987}
}
@inproceedings{vaswani2017,
author = {Vaswani, Ashish and Shazeer, Noam and Parmar, Niki and others},
title = {Attention Is All You Need},
booktitle = {Advances in Neural Information Processing Systems},
volume = {30},
year = {2017}
}
@misc{who2023,
author = {{World Health Organization}},
title = {World Health Statistics 2023},
howpublished = {\url{https://www.who.int/data/gho}},
note = {Accessed 9 November 2026},
year = {2023}
}Write authors as Last, First joined by and, never by commas. Wrap a company name in a second pair of braces so BibTeX does not split it into first and last names. Page ranges use -- for an en dash.
| Entry type | For | Required fields |
|---|---|---|
@article | Journal article | author, title, journal, year |
@book | Book | author or editor, title, publisher, year |
@inproceedings | Conference paper | author, title, booktitle, year |
@incollection | Chapter in an edited book | author, title, booktitle, publisher, year |
@phdthesis / @mastersthesis | Thesis | author, title, school, year |
@techreport | Report | author, title, institution, year |
@misc | Websites, software, anything else | none; use title, howpublished, note, year |
Classic BibTeX styles have no @online type; use @misc with the URL in howpublished (and load url or hyperref for \url). biblatex does support @online with a url field.
Citing and Printing the Bibliography
\documentclass{article}
\usepackage{url}
\begin{document}
\section{Introduction}
\TeX{} was designed by Knuth \cite{knuth1984}, and \LaTeX{} added logical
markup on top of it \cite{lamport1987}. Several sources at once
\cite{knuth1984,vaswani2017}, and a page number \cite[p.~12]{knuth1984}.
\nocite{who2023} % listed without being cited
\bibliographystyle{plain}
\bibliography{refs}
\end{document}\nocite{*} lists every entry in the file. The heading is “References” in article and “Bibliography” in report and book; rename it with \renewcommand{\refname}{Sources} (or \bibname). To list it in the table of contents, add \usepackage[nottoc]{tocbibind}.
Bibliography Styles
\bibliographystyle picks a .bst file that controls the order and look of entries. Journals usually supply their own; these ship with every TeX distribution:
| Style | Labels | Order |
|---|---|---|
plain | [1], [2] | Alphabetical by author |
unsrt | [1], [2] | Order of first citation |
abbrv | [1], [2] | Alphabetical, first names abbreviated |
alpha | [Knu84] | Alphabetical |
ieeetr | [1], [2] | Order of citation, IEEE layout |
plainnat, abbrvnat, unsrtnat | Author-year or numbers | Need natbib |
The Compile Order: LaTeX, BibTeX, LaTeX, LaTeX
BibTeX is a separate program, and each pass hands information to the next:
- pdflatex writes every
\citekey, the style and the database name to the.auxfile. Citations print as[?]. - bibtex reads the
.aux, looks up the keys inrefs.biband writes the formatted list to a.bblfile. - pdflatex reads the
.bbland prints the bibliography; the labels are now known but not yet used in the text. - pdflatex once more puts the right labels in place of
[?].
On the command line, latexmk -pdf main.tex runs exactly as many passes as needed. In Octree and Overleaf, one click of Compile does the same. The labels and .aux file work the same way as for \ref; see cross-referencing.
natbib and biblatex
natbib keeps BibTeX but adds author-year citation commands: \citet for “Knuth (1984)” and \citep for “(Knuth, 1984)”:
\documentclass{article}
\usepackage[round]{natbib}
\usepackage{url}
\begin{document}
\citet{knuth1984} designed \TeX{}; transformers came later \citep{vaswani2017}.
\bibliographystyle{plainnat}
\bibliography{refs}
\end{document}biblatex replaces BibTeX entirely. It uses the biber program, takes the file name with its extension, and sets the style as a package option:
\documentclass{article}
\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{refs.bib}
\begin{document}
\textcite{knuth1984} designed \TeX{} \parencite[see][12]{knuth1984}.
\printbibliography
\end{document}| BibTeX (+ natbib) | biblatex | |
|---|---|---|
| Program | bibtex | biber |
| Style | \bibliographystyle{...} with a .bst file | style= option, customised in LaTeX |
| Database | \bibliography{refs} | \addbibresource{refs.bib} |
| Unicode, URLs, dates | Limited | Full support, @online type |
| Best for | Journal and conference templates | Theses, books, APA and MLA |
Do not load both, and do not mix their commands. The usual APA and MLA styles (biblatex-apa, biblatex-mla) are biblatex styles; see MLA in-text citations and the AMA citation format.
Common Errors and Fixes
| Message or symptom | Cause | Fix |
|---|---|---|
LaTeX Warning: Citation ‘knuth1984’ on page 1 undefined, and [?] in the PDF | BibTeX not run yet, or the key is not in the .bib file | Run the full sequence; check the key's spelling and case |
| LaTeX Warning: Empty ‘thebibliography’ environment | No citations reached BibTeX, or BibTeX failed | Add a \cite or \nocite{*}; read the .blg log |
| I couldn't open database file refs.bib | The name in \bibliography is misspelled, or the file is in another folder | Match the file name exactly (case included) and give a relative path, e.g. \bibliography{bib/refs} |
| I found no \bibdata command / no \bibstyle command | \bibliography or \bibliographystyle missing | Add both before \end{document} |
| I was expecting a ‘,’ or a ‘}’ | A missing comma between fields, or an unbalanced brace | Check the entry on the line the .blg names |
| Acronyms print in lower case, such as “dna” | The style lower-cases titles | Protect them: {DNA}, {\LaTeX} |
The bibliography does not update after editing refs.bib | The old .bbl is still used | Run BibTeX again, or delete the auxiliary files |
Frequently Asked Questions
How do I use BibTeX in LaTeX?
Put your references in a .bib file, cite them in the text with \cite{key}, and at the point where the list should appear write \bibliographystyle{plain} and \bibliography{refs} (the file name without .bib). Then compile with LaTeX, BibTeX, LaTeX and LaTeX again, or let latexmk, Octree or Overleaf run the sequence for you.
Why are my citations showing as question marks?
A [?] means LaTeX has no entry for that key yet. Either BibTeX has not been run since you added the citation, the key is misspelled, or the entry is missing from the .bib file. Run the full LaTeX, BibTeX, LaTeX, LaTeX sequence and check the .blg log for warnings such as “I didn't find a database entry”.
Why is my bibliography empty?
BibTeX only lists entries that are cited. An empty list, or the warning “Empty thebibliography environment”, means no \cite or \nocite reached BibTeX, BibTeX was not run, or it could not open the .bib file. Add \nocite{*} to list every entry in the file without citing it.
Should I use BibTeX, natbib or biblatex?
Use the plain BibTeX setup or natbib when a journal or conference template asks for a .bst style, which most do. natbib adds \citet and \citep for author-year citations on top of BibTeX. Use biblatex with the biber program for theses and your own documents: styles are set with package options and it handles Unicode, URLs and dates better.
How do I keep capital letters in BibTeX titles?
Many styles lower-case titles, so protect the letters that must stay capital with braces: title = {A Study of {DNA} Repair in {E}scherichia coli}. Wrap whole words or acronyms, not the entire title, so the style can still format the rest.
Next Steps
- Bibliography Examples – APA, MLA, Chicago and IEEE entries with their BibTeX source
- MLA In-Text Citation – Author-page citations and biblatex-mla
- AMA Citation Format – Superscript numbered citations in LaTeX
- Cross-Referencing – \label, \ref and the same two-pass rule
- Table of Contents – Adding the bibliography to the contents
Free LaTeX Tools
- LaTeX Preview – Compile any example above and see the result instantly
- AI LaTeX Generator – Describe a document and get the LaTeX
Citations without the compile dance
Octree runs BibTeX or biber for you on every compile. Paste a DOI or a messy reference and its AI writes the .bib entry, then fixes undefined citations with the PDF next to your code.