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:
Where to put the \label on a figure environment?

I'm having a problem with referencing figures in LaTeX. I have the following text:

\caption{ENN unbalanced 10\%}

The figure \ref{fig:enn1015} (...)

For some reason, the figure caption is:

Figure 3.5 Enn unbalanced 10%

But the text is:

The figure 3.2.1 (...)

Instead of:

The figure 3.5

It is printing the chapter.section.subsection the figure is in, and not the figure. Can anybody help me?

share|improve this question

migrated from stackoverflow.com Dec 7 '11 at 15:08

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Werner, Torbjørn T., lockstep, Joseph Wright Dec 9 '11 at 10:08

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.

up vote 33 down vote accepted

Try putting your \label{} statement immediately after your \caption{} statement.

Edit: I'm not a total expert on how the \label command works, but I think it assigns a label to the last-seen "labelable" thing, so you want it right after your caption, which is "labelable" (my terminology). Currently, it is labeling whatever the last "labelable" thing was before your figure, probably a section heading or something (hence the 3.2.1).

2nd Edit: In other words, and maybe this is kind of counter-intuitive, you can't label figures; you must label captions.

share|improve this answer
It works, thank u! – Dayvid Victor Dec 7 '11 at 14:58

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