LaTeX warning · Warnings: references, floats and boxes
LaTeX Warning: Citation `vaswani2017' on page 1 undefined
Quick answer
LaTeX resolves \cite{key} from the .aux file written by the previous run and the bibliography produced by BibTeX or Biber. Until a matching entry exists, the citation prints as [?] or bold key and the log warns. Check that the key is spelled exactly as in the .bib file or \bibitem, that the .bib file is found and the entry is valid, then run LaTeX, BibTeX/Biber, LaTeX, LaTeX (an online editor or latexmk does this sequence for you).
The warning in the log
This is how the message appears in the .log file (and in the compile output). The line starting with l. is the line number where TeX noticed the problem; the real mistake is there or just before it.
LaTeX Warning: Citation `vaswani2017' on page 1 undefined on input line 3.
LaTeX Warning: There were undefined references.Why it happens
- The key in
\citedoes not match the key in the.bibfile or\bibitemexactly (keys are case-sensitive):vaswani2017versusvaswani2017attention. - BibTeX or Biber has not been run, or failed: look in the
.blgfile for "I couldn't open database file" or syntax errors in the entry. - The bibliography is never printed:
\bibliography{refs}or\printbibliographyis missing, or the.bibfile name is wrong. - Mixing systems:
\addbibresource(biblatex) with BibTeX, or\bibliographystyletogether with biblatex.
How to fix it
Copy the key from the warning and search for it in your bibliography. If it is not there, add the entry or correct the key in \cite. If it is there, compile the full sequence (LaTeX, BibTeX or Biber, LaTeX twice) and read the .blg log for problems with the .bib file.
The example below uses thebibliography so it is self-contained; with a .bib file the fix is the same: the key in \cite must match the key on the first line of the entry.
Broken: reproduces the warning
\documentclass{article}
\begin{document}
Transformers were introduced by Vaswani et al.~\cite{vaswani2017}.
\begin{thebibliography}{9}
\bibitem{vaswani2017attention} A. Vaswani et al.
Attention is all you need. NeurIPS, 2017.
\end{thebibliography}
\end{document}Try this in Octree — free LaTeX editor with AI, compiles in your browser
Fixed: compiles cleanly
\documentclass{article}
\begin{document}
Transformers were introduced by Vaswani et al.~\cite{vaswani2017attention}.
\begin{thebibliography}{9}
\bibitem{vaswani2017attention} A. Vaswani et al.
Attention is all you need. NeurIPS, 2017.
\end{thebibliography}
\end{document}Related errors
- Reference undefined – A
\refor\eqrefhas no matching\label, so the PDF shows ??. - File not found – A package or class named in
\usepackageor\documentclassis misspelled or not installed. - Too many unprocessed floats – Figures or tables pile up behind one that LaTeX cannot place, until it runs out of float slots.
- All LaTeX errors and warnings – The full list, grouped by cause
Frequently Asked Questions
Why does my citation show as [?] in the PDF?
[?] is how LaTeX prints a citation it cannot resolve. Either the key does not match any bibliography entry, or BibTeX/Biber has not run since you added it. Fix the key, then compile LaTeX, BibTeX or Biber, and LaTeX twice.
How do I run BibTeX in the right order?
pdflatex main, bibtex main (or biber main for biblatex), pdflatex main, pdflatex main. latexmk -pdf main does this automatically, and online editors like Octree run it on every compile.
The key is correct but the citation is still undefined. Why?
Usually the .bib file is not being read: check the file name in \bibliography{} or \addbibresource{} (biblatex needs the .bib extension), and open the .blg file, which reports missing files and broken entries such as an unescaped & or a missing comma.
What does "There were undefined references" mean?
It is the summary at the end of the run. It appears whenever at least one \cite or \ref could not be resolved; scroll up for the individual "Citation ... undefined" or "Reference ... undefined" warnings.
Paste your document into Octree — compile errors get a Fix with AI button
When a compile fails, Octree shows the error next to the line that caused it and offers a one-click fix that you can review before applying. Free, nothing to install.
Fix it in Octree →