Tx · LaTeX & TikZ

How to Fix “There Were Undefined References” in LaTeX

Published By the 9to5Science editorial team

At a glance

  1. 1. Find the unresolved key

    Read the .log file and identify the label or citation key LaTeX could not resolve.

  2. 2. Check the source

    Verify spelling, matching labels and citations, and that labels follow the relevant numbered object.

  3. 3. Run the needed tools

    Compile again for cross-references; run BibTeX or Biber as well when using a bibliography.

  4. 4. Check the final build

    Compile LaTeX or XeLaTeX again and confirm that the warning and question marks are gone.

LaTeX prints “There were undefined references” when it cannot match at least one reference in your document to the information recorded during compilation. The usual fix is to compile again, but repeated runs will not fix a misspelled label or a bibliography that has not been processed.

The warning is general: the log file gives the useful detail. Look there for a line such as Reference 'sec:results' ... undefined or Citation 'smith2020' ... undefined. That tells you whether you need to fix a \ref label, a citation key, or the build sequence.

Why LaTeX needs more than one run

Commands such as \label and \ref rely on data written to auxiliary files. On an initial run, LaTeX may encounter \ref{sec:results} before it has created or read the corresponding reference data. It writes information to files such as .aux; a later run reads that information and replaces ?? with the section number, page number, or other value.

A reference can therefore be unresolved on the first run and correct on the next. Changes to numbering or document structure can also require another run. Most LaTeX editors and online services automate these passes, but a one-pass build may leave the warning behind.

Check a basic cross-reference

This complete example creates a section label and refers to it. Save it as example.tex and compile it twice with LaTeX or XeLaTeX. The first run may show ??; the next should show the section number.

\documentclass{article}

\begin{document}

See Section~\ref{sec:method} for the method.

\section{Method}
\label{sec:method}
This section describes the method.

\end{document}

Put the \label after the command that establishes the number you want to reference. For a section, put it after \section. For a figure or table, put it after \caption, which updates the figure or table counter. If the label is misspelled, absent, or duplicated, another compile will not fix the problem.

Use the right bibliography build sequence

Citations need a bibliography processor in addition to LaTeX. Choose the sequence that matches your setup; use the document’s filename without its extension when invoking BibTeX or Biber.

SetupTypical sequence
biblatex with BiberXeLaTeX → Biber → XeLaTeX → XeLaTeX
Traditional BibTeXXeLaTeX → BibTeX → XeLaTeX → XeLaTeX

For example, if the file is paper.tex, run XeLaTeX on paper.tex, run biber paper for a Biber setup, and then run XeLaTeX again—often twice. In a biblatex document, the backend is commonly selected with an option such as backend=biber; follow the setting in your preamble rather than switching processors at random.

If you use an editor’s build command, check that it is configured to run Biber or BibTeX when needed. A bibliography may appear empty or citations may remain unresolved if LaTeX runs but the bibliography processor does not.

Diagnose a warning that persists

Use the .log file to find the exact unresolved name, then check the matching source:

  • Unresolved \ref or \pageref: Confirm that the label exists and that its spelling, capitalization, and punctuation match exactly. Check that it is defined by a numbered section, caption, equation, or other referenceable object.
  • Unresolved citation: Check that the citation key matches an entry in the .bib file, and confirm that the bibliography processor ran successfully. Also check that the bibliography file is available at the path specified in the document.
  • Cross-reference to a changed object: Compile again after editing section order, captions, or labels. LaTeX may need another pass to update stored numbering.
  • Build stops early: Fix any earlier errors first. If compilation fails before reaching the relevant labels or bibliography commands, the auxiliary information may be incomplete.

The warning is not, by itself, evidence of a XeTeX or TikZ-Feynman problem. Those packages can appear in the same document, but first follow the unresolved label or citation named in the log. If the log reports no specific unresolved key, run the full build again and inspect the messages immediately before the general warning.

Common mistakes

  • Compiling repeatedly without checking the key: More passes help only when the reference data is expected to become available. A typo or nonexistent label needs a source edit.
  • Running Biber on the wrong name: Use the main document’s basename, such as biber paper, not biber paper.tex.
  • Using the wrong bibliography tool: biblatex commonly uses Biber, while traditional BibTeX workflows use BibTeX. Use the backend configured for the document.
  • Placing a figure label before its caption: The label may capture an earlier counter value. Place it immediately after \caption.
  • Treating every warning as a fatal error: Undefined references are warnings, but the output may contain ?? or missing citations. Resolve them before relying on the final document.

References

  1. LaTeX2e unofficial reference manual: Cross references
  2. The biblatex Package: Programmable Bibliographies and Citations

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.