TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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:
Figure numbers using the section number

I have a figure inside a section, like:

    \hspace{1.5in}\parbox{5in}{\caption{Representación gráfica Vecindad de Von Neumann}}

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


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

share|improve this question

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

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.

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
up vote 4 down vote accepted

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

dummy graphics
\hspace{1.5in}\parbox{5in}{\caption{Representación gráfica Vecindad de Von Neumann}\label{fig:VecindadVonNeumann}}
This is my all awesome figure \ref{fig:VecindadVonNeumann}

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.

share|improve this answer

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