TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following lines:

\begin{tikzpicture}[level distance=1.5cm, grow=down,
    every node/.style={minimum size=1cm,circle,thin,draw},
    edge from parent/.style={-latex, thin, draw}
\node {$A$}
    child {
        node {$CO_{1}$}
        child {node[rectangle,draw] {$CL_{1}$}}
    child {
        node[circle,dotted,draw] {$\cdots$}
        child {node[rectangle,dotted,draw] {$\cdots$}}
    child {
        node {$CO_{n}$}
        child {node[rectangle,draw] {$CL_{n}$}}
\caption{Sample configuration}

In Figure ~\ref{fig:sampleconfig}, the node labelled $A$ is the root APPLICATION node.

No matter how many times I recompile the LaTeX file, I still get two question marks in place of "Figure 1," like so: "Figure ??."

Am I doing something incorrectly?

Thanks in advance for your help.


In case it would help to solve the problem: I'm using MikTex 2.9 on Windows 7.

share|improve this question
The \label command must go after the \caption (or inside its argument). Besides you shouldn't be using the center environment, but rather the simple command \centering in place of \begin{center} – egreg Nov 21 '11 at 14:54
related question: tex.stackexchange.com/questions/20816/… – matth Nov 21 '11 at 15:04
Thanks for the suggestion about \centering. I've updated my LaTeX file accordingly. – Shredderroy Nov 21 '11 at 16:11
up vote 18 down vote accepted

Put your label in the caption itself. i.e.

\caption{Sample configuration\label{fig:sampleconfig}}

It should work then. You can also place it after the caption as long as it is still in the figure environment. Figure labels do not behave correctly if they are placed before the caption.

share|improve this answer
Unfortunately, the problem persists even after following your suggestion. I have a feeling it might have something to do with MikTex. I think if I transfer the LaTex file to my Fedora workstation, download all the TeX packages and compile there, everything will show up correctly. But someone here must know better than me about this problem. – Shredderroy Nov 21 '11 at 14:28
It is extremely unlikely that this is a MikTeX problem. Are you sure? Delete the aux file and try a couple more times if you didn't delete it before. You also need to upgrade the example above to a MWE that demonstrates your problem. Inserting your code in a shell article with just the TikZ package included shows your problem until I perform the change detailed in the answer. – qubyte Nov 21 '11 at 14:32
Never mind! Four more compilations, and your suggestion has worked! Thanks. – Shredderroy Nov 21 '11 at 14:32
Oops! Excellent. You are quite welcome. :) – qubyte Nov 21 '11 at 14:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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