When I reference a table in a posterior chapter in my thesis, instead of the correct table number it puts ??. However, the link works correctly, and the table appears in the List of Tables fine.

I reference it as:


The table is:

\begin{table}[h] \label{tab:datasets} ...

The log shows

Reference 'tab:datasets' on page 16 undefined

How can I make Latex show the proper table number?

  • 3
    Put the label behind the caption. – Ulrike Fischer Jun 24 '15 at 14:26
  • And you need to compile at least twice. The label number is written to the .aux file and read at the beginning (\begin{document}) of the next LaTeX run. – Heiko Oberdiek Jun 24 '15 at 14:31
  • @HeikoOberdiek: As the table appears in the list of table and links work I think one can assume that the document has been compiled twice. – Ulrike Fischer Jun 24 '15 at 14:54
  • @UlrikeFischer That does not explain the question marks. The \label could be added at a later time, the the auxiliary files already contain the caption, but not yet the label. – Heiko Oberdiek Jun 24 '15 at 15:01
  • @UlrikeFischer gave the correct answer. – CrystalCalculator Jun 24 '15 at 15:33

You need to run the program twice, one after another. And before that, be sure you have used the standard \label-\ref system: \label{labelname} and \ref{labelname}. In your case \label{tab:datasets} and \ref{tab:datasets}. Try to avoid using the same "label name" more times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.