1

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}}
    \label{fig:VecindadVonNeumann}
\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

Section Number

This is my Figure, shows 2.1 as number Figure Number

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

2.1.4

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

Mr.Gando
  • 725
  • 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

1 Answers1

4

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
\hspace{1.5in}\parbox{5in}{\caption{Representación gráfica Vecindad de Von Neumann}\label{fig:VecindadVonNeumann}}
\end{figure}
This is my all awesome figure \ref{fig:VecindadVonNeumann}
\end{document}

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.

Benedikt Bauer
  • 6,590
  • 2
  • 34
  • 60