LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Figure references all wrong Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
theo moore
Posts: 72
Joined: Thu Jan 15, 2009 3:16 pm

Figure references all wrong

Can anybody figure out what's going on? Typically, you would create a figure like so,

\begin{figure}\label{blah}\end{figure}

Then call it afterwards, like,

See \ref{blah}

That's fine. I've never had a problem with that. Until now, that is. In my current (set of) documents, whenever I reference a figure label, instead of printing out the correct label, it's printing out the section number for which the figure is in!

I can't figure out what's wrong. Everything compiles well. The references to sections, subsections and equations work fine!

Any help?

Tags:

Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm
The problem there is that you must put the label after a caption, so the label can reference to the figure (it references to the caption, actually). See also here: http://www.latex-community.org/forum/viewtopic.php?t=3659

See if the following works:
\begin{figure}Text, images\dots inside the figure\caption{the caption}\label{blah}\end{figure}

theo moore
Posts: 72
Joined: Thu Jan 15, 2009 3:16 pm
Keta wrote:The problem there is that you must put the label after a caption, so the label can reference to the figure (it references to the caption, actually).

I've been using LaTeX for something like 5 years now, but never knew that. That simply blows my mind. I always thought it was arbitrary -- how I ever avoided the problem until now is a mystery.

moameen
Posts: 2
Joined: Fri Jul 13, 2012 8:17 pm
I had the same problem and would have never figured that out!!!

thanh1985
Posts: 1
Joined: Sun Jan 20, 2013 4:22 am
I have some problem when I'm writing my thesis and paper. I try to arrange \label{} right after \caption{}, that means they are in a sequence. It worked for me. Try!
Last edited by cgnieder on Sun Jan 20, 2013 3:01 pm, edited 1 time in total.