Take the 2-minute tour ×

I include a figure like this

\caption{ Recalls of test query MB002-MB049}
\label{ recall_details}

And then I refer it using \ref{recall_details}. Instead of getting numbers like 1, 2, I get ??. Literally I mean ??. What is wrong with my codes? How to make the references show correctly?

share|improve this question
You might want to post this in TeX instead. –  fgb May 6 '13 at 22:29
add comment

closed as off topic by David Z, andersoj, hammar, Minko Gechev, Tikhon Jelvis May 7 '13 at 7:28


2 Answers

up vote 0 down vote accepted

You should "compile" your latex code twice to get numbers instead of question marks

share|improve this answer
Cool, I think I find my problem. Two things, first is I leave some whitespaces in the \label{}, and second is even after correcting them, I need to run compile twice. –  Yitong Zhou May 6 '13 at 22:55
@YitongZhou: you should look into latexmk or the like, so that multiple compilations are done automagically. –  fgb May 6 '13 at 22:57
add comment

The issue is that you're referencing \ref{recalls_details}, but you've defined \label{ recalls_details}. That extra space before recalls_details is what gets you ?? instead of the figure number. You should either change the \ref to \ref{ recalls_details} or the \label to \label{recalls_details}.

On another note, I suggest you add a modifier at the start of the label, such as fig: in this case: \label{fig:recalls_details}. This is useful when you have different types of labels (e.g. to sections, sec:, and to equations, eqn:).

The bottom line is to always use the exact string you give within the \label{} in the relevant \ref{}.

share|improve this answer
I tried use \label to refer the labels, then I get a blank, not a number. Do you know what is going wrong? –  Yitong Zhou May 6 '13 at 22:52
@YitongZhou: If you define a label for something (i.e. \label{name}), you insert a reference to it using \ref (i.e. \ref{name}). –  fgb May 6 '13 at 22:55
add comment
