TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

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
share|improve this question

marked as duplicate by lockstep, Torbjørn T., Gonzalo Medina, cmhughes, Stephan Lehmke Aug 31 '12 at 21:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Put \label after \caption. – lockstep Aug 31 '12 at 21:20
That's it. I switched positions and it worked like a charm. Thanks a lot. – msmechanized Aug 31 '12 at 21:36
up vote 3 down vote accepted

you should put figure label after caption

share|improve this answer

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