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
General ⇒ Error: References point to sections instead of figures
-
- Posts: 3
- Joined: Sat Jan 10, 2009 11:55 am
NEW: TikZ book now 40% off at Amazon.com for a short time.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Error: References point to sections instead of figures
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.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? [...]
Best regards and welcome to the board
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 3
- Joined: Sat Jan 10, 2009 11:55 am
Re: Error: References point to sections instead of figures
That seems to be the solution! Thanks!
Error: References point to sections instead of figures
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.