# Properly reference figure? [duplicate]

Possible Duplicate:
Figure numbers using the section number

I have a figure inside a section, like:

\subsection{Something}
\begin{figure}[htbp]
\centering
\includegraphics[height=2in]{pictures/mathematic/vn_vicinity.pdf}
\hspace{1.5in}\parbox{5in}{\caption{Representación gráfica Vecindad de Von Neumann}}
\end{figure}


When I want to reference the figure:

This is my all awesome figure \ref{fig:VecindadVonNeumann}


I get the reference number from the section, not from the figure itself.

This is my section number

This is my Figure, shows 2.1 as number

This is the number that I'm getting in my \ref

Is this normal ? Shouldn't I get 2.1 in my reference ?

-

## marked as duplicate by David Carlisle, lockstep, cmhughes, Werner, diabonasSep 25 '12 at 21:40

You should put the \label command inside the \parbox; however, customizing the appearance of the caption is best done with the caption package. – egreg Sep 25 '12 at 16:53

As soon as you you put the \label inside the \parbox argument, it works fine:

\documentclass{article}
\begin{document}
\subsection{Something}
\begin{figure}[htbp]
\centering
dummy graphics

It looks like the \parbox separates the \label from the counter. As @egreg alread pointed out in his comment above, shaping the caption with such \hspace and \parbox things isn't quite good style. Better take the caption package or -- if you use one of them -- the built-in means of the KOMAscript classes.