GeneralError: References point to sections instead of figures

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
spiderman2
Posts: 3
Joined: Sat Jan 10, 2009 11:55 am

Error: References point to sections instead of figures

Post by spiderman2 »

When I try to make a reference to a figure or table with the \ref command, the output is just the number of the section that the figure or table is aligned under. Anyone knows how to correct this?

I've been using latex for the latest months, and this problem hasn't occurred until just recently. At first I thought it might be because of some new packages I've loaded in a document, but it happens to old .tex files as well in which I don't use those packages, so it seems to be some kind of system setting behind all this. I'm using the texlive installation on Ubuntu Linux.

Thankful for help,
Henrik

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Error: References point to sections instead of figures

Post by localghost »

spiderman2 wrote:When I try to make a reference to a figure or table with the \ref command, the output is just the number of the section that the figure or table is aligned under. Anyone knows how to correct this? [...]
Presumably you used the \label command before \caption. This can't work because the anchor for references is always set to the last command which creates one (mostly structuring commands like \chapter). If not, provide a complete and compilable code example.


Best regards and welcome to the board
Thorsten¹
spiderman2
Posts: 3
Joined: Sat Jan 10, 2009 11:55 am

Re: Error: References point to sections instead of figures

Post by spiderman2 »

That seems to be the solution! Thanks!
Gecko17k
Posts: 1
Joined: Tue May 06, 2014 6:00 pm

Error: References point to sections instead of figures

Post by Gecko17k »

Turns out that centering destroys the figure referencing. So with that it doesn't help to put the label after the caption.

Code: Select all

\begin{figure}
\begin{center}
\includegraphics[width=90mm,height=90mm]{somefigure.jpg}
\caption{\footnotesize{Caption text here. \cite{somepaper}}}
\end{center}
\label{afigure}
\end{figure}
Last edited by Stefan Kottwitz on Tue May 06, 2014 7:25 pm, edited 1 time in total.
Post Reply