General\autoref does not link correctly

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
kart672
Posts: 2
Joined: Mon Jul 23, 2007 11:59 am

\autoref does not link correctly

Post by kart672 »

hi there.

I have problems with the use of the autoref command and linking to a figure.
In the header file I include

Code: Select all

\usepackage[colorlinks=true, linkcolor=black]{hyperref}
When I create a figure like this:

Code: Select all

\begin{figure}
\centering
\includegraphics[viewport = 112 707 468 738, width=\textwidth]{images/01/blabla.pdf}
\label{fig:blabla}
\caption{Bla Bla}
\end{figure}
and try to link to this figure with

Code: Select all

\autoref{fig:blabla}
I will be linked to the chapter headline that includes the figure, but not to the actual figure. It works with figures from other files, though.

Has anybody an idea?

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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

\autoref does not link correctly

Post by localghost »

Pay attention to the right sequence of the caption and label command.

Code: Select all

\begin{figure}[!ht]
  \centering
  \includegraphics[viewport = 112 707 468 738, width=\textwidth]{images/01/blabla.pdf}
  \caption{Bla Bla}\label{fig:blabla}
\end{figure}
In your example the label fig:blabla has the value of the last command which can be marked. In your case this seems to be a chapter.
kart672
Posts: 2
Joined: Mon Jul 23, 2007 11:59 am

Re: \autoref does not link correctly

Post by kart672 »

hey,

yes, of course the \label must come after the \caption.
now that has become clear to me.
thanks a lot.
Post Reply