Graphics, Figures & TablesHyperref shows section number instead of table number.

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
pgeezer
Posts: 7
Joined: Wed Dec 08, 2010 4:57 pm

Hyperref shows section number instead of table number.

Post by pgeezer »

This is strange.

I've set up references to show \section.\table for all figures and tables with:

Code: Select all

\numberwithin{table}{section}%for tables
I've got Table 1.1, 1.2, 1.3, 2.1, 2.2, 2.3 ... 17.1, 17.2 etc. All tables are numbered correctly and all \ref{t-name} in the body text work (shows 2.1, 3.1, 16.4, etc).

Then out of the blue one text reference returns the section number (17.4.1) instead of the table number (17.2). The misnumbered hyperlink (17.4.1) goes to the correctly numbered (17.2) table. Why is it returning the section number? \label is correct and matching, hence the working link.

I have no idea how to make this show in a MWE as it is working except for the one table. Bug in Hyperref?
Last edited by pgeezer on Wed Feb 16, 2011 8:38 pm, edited 1 time in total.

Recommended reading 2024:

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

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

Hyperref shows section number instead of table number.

Post by localghost »

Make sure that you inserted the \label command right behind the \caption command. If not, swap them.


Thorsten
pgeezer
Posts: 7
Joined: Wed Dec 08, 2010 4:57 pm

Hyperref shows section number instead of table number.

Post by pgeezer »

Bingo and thanks! My centering command had displaced the label from the caption.

Before (wrong):

Code: Select all

\begin{table}[htbp]
\begin{center}
\includegraphics[width=5in]{t-name.pdf}
\linespread{1}
\caption{This is the caption}
\end{center}
\label{t-name}
\end{table}
After (fixed!):

Code: Select all

\begin{table}[htbp]
\begin{center}
\includegraphics[width=5in]{t-name.pdf}
\linespread{1}
\caption{This is the caption}
\label{t-name}
\end{center}
\end{table}
I'll mark the thread as solved. Thanks again!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Hyperref shows section number instead of table number.

Post by localghost »

It's preferable to use the \centering command instead of the center environment in order to avoid additional vertical space (which is mostly unwanted in cases like this). This would also evade the problem you described here.
pgeezer
Posts: 7
Joined: Wed Dec 08, 2010 4:57 pm

Hyperref shows section number instead of table number.

Post by pgeezer »

localghost wrote:It's preferable to use the \centering command instead of the center environment in order to avoid additional vertical space (which is mostly unwanted in cases like this). This would also evade the problem you described here.
Thanks for advice. I'll give it a try and compare.
Post Reply