# Where to put the \label on a figure environment? [duplicate]

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

I noticed that when I put the \label command before the \caption command in a figure environment, I get wrong \ref results for this figure. When I put the label in or after the \caption, the \ref will work fine. In the first case, I will get a \ref to the enclosing section (or subsection). Why is that so? And is there some documentation which tells me how to label a figure correctly?

-