Possible Duplicate:
Why does an environment's label have to appear after the caption?

I am using tikz with its externalize library. I create figures with the following coding style:

  code code code..
\caption{Blah blah blah text.}

when I use \ref{fig:label} it does not display the correct number. Another notable and bizarre behavior is that the number is in the format, e.g 5.2.1 and not 5.2; has anyone encountered this?

Also by trying to create a MWE I could not make the thing to even appear. I am not trying to do complex stuff, just to say "in the figure x.x ...". Anyway, here is the not working MWE:

\usepackage{tikz} %pgf-tikz pakcage




\draw[fill = blue,fill opacity = 0.3](0,2) rectangle (1.5,3.5);
\draw[fill = yellow,fill opacity = 0.3](0.5,2.5) rectangle (1,3);

\draw[->] (0.75,0.75) -- (0.75,2.75);

Hello \ref{fig:stuff} world
  • 2
    Put \label after \caption.
    – lockstep
    Commented Aug 31, 2012 at 21:20
  • That's it. I switched positions and it worked like a charm. Thanks a lot. Commented Aug 31, 2012 at 21:36

1 Answer 1


you should put figure label after caption

Not the answer you're looking for? Browse other questions tagged .