# I get double question marks when referring to labels inside figures

I have some charts embedded in figures, and I want to be able to refer to them easily using the "Figure x" notation. I'm doing it like this (in this order):

\documentclass[12pt,letterpaper]{article}

...

\section*{Results}
...we performed a linear regression to obtain a standard curve
(Figure~\ref{0:stdcurve})....

\pagebreak
\section*{Results (Graphs)}
\subsection*{Construction of Standard Graph for PNP}
\begin{figure}[h]   % Figure 1
\centering
\includegraphics[scale=1]{kinematics-res/graph0-1}
\caption{The standard curve for PNP.}
\label{0:stdcurve}
\end{figure}


However, instead of getting the output "...to obtain a standard curve (Figure 1)...", I just get "...to obtain a standard curve (Figure ??)..."

I also noticed that the PDFLaTeX compiler is generating warnings saying that it couldn't find the reference of the name 0:stdcurve. Why am I getting these warnings?

You need to run LaTeX twice. The first time it figures out the reference numbers. On the second pass it fills in the reference numbers.

The following generates ...standard curve (Figure {??}) upon the first pass, but generates ...standard curve (Figure 1)... upon the second pass:

\documentclass[12pt,letterpaper]{article}
\usepackage[demo]{graphicx}

\begin{document}
\section*{Results}
...we performed a linear regression to obtain a standard curve
(Figure~\ref{0:stdcurve})....

\pagebreak
\section*{Results (Graphs)}
\subsection*{Construction of Standard Graph for PNP}
\begin{figure}[h]   % Figure 1
\centering
\includegraphics[scale=1]{kinematics-res/graph0-1}
\caption{The standard curve for PNP.}
\label{0:stdcurve}
\end{figure}
\end{document}

• I am using PDFLaTeX. Am I supposed to run that twice? I just did that, and it's not changing anything. If it's of any help, I am using Texmaker as my TeX IDE. – kibibyte Oct 17 '11 at 4:22
• Run it twice, and don't delete the temporary files that get generated upon the first run. – Peter Grill Oct 17 '11 at 4:23
• Oooh...thanks for that. The "temporary files" bit was the important part. I have a stray \nofiles command stuck at the beginning of my file. Now I know that the .aux files that PDFLaTeX are actually very important for cross-references. – kibibyte Oct 17 '11 at 4:26
• @GiantMarshmallow: That's why we always ask for a minimal example that you've actually tried. It's amazing what people miss out and then assume we'll all guess! – Joseph Wright Oct 17 '11 at 7:25