LaTeX hyperref链接转到了错误的页面

时间:2010-04-30 15:37:58

标签: latex hyperref

我正在尝试创建一个不使用标题的浮点数的引用。如果我在float中包含\ label {foo}并使用\ pageref {foo}引用它,则在我的pdf文档中显示正确的页码,但是由hyperref包创建的超链接链接到不同的页面(第一页)部分)。如果我在浮点数中的标签之前加上一个标题,则hyperref链接会转到正确的页面。

有没有办法让hyperref链接正常工作而不在浮点数中包含标题?或者有没有办法抑制标题的显示,所以我可以包括一个没有显示的标题?

以下是一个最小的例子。如果我使用pdflatex处理它,我会得到三页。 “图”显示在第二页上,第三页正确显示“见第2页上的图”。但是'2'上的超链接显示“转到第1页”,如果我点击它,则会转到第1页。

如果我在\ label {foo}之前添加一个空\ caption {},那么超链接可以正常工作,但我不想为我的浮点显示一个标题。

\documentclass[11pt]{memoir}

\usepackage{hyperref}

\begin{document}

some text
\clearpage


\begin{figure}
  a figure
  \label{foo}
\end{figure}

more text
\clearpage


See figure on page \pageref{foo}.

\end{document}

3 个答案:

答案 0 :(得分:14)

\label命令引用\refstepcounter的最后一次调用。 \caption认识到它位于数字环境中并调用\refstepcounter{figure}。您可以自己致电\refstepcounter

为避免跳过一系列数字中的数字,您可以使用\newcounter{dummy}创建一个自己的,无意义的计数器。结果:

\documentclass{scrreprt}
\usepackage{hyperref}
\newcounter{dummy}
\begin{document}

\chapter{First}

\newpage
\begin{figure}
{\Huge FIGURE}
\refstepcounter{dummy}
\label{fig:figure}
\end{figure}

\chapter{Second}

Goto \pageref{fig:figure}

\end{document}

创建指向图末尾的超链接。 (适用于我的机器:-) 注意比\ref{fig:figure}没有意义。

答案 1 :(得分:7)

在标签之前,使用\ phantomsection,如下所示:

\documentclass{memoir}
\usepackage{hyperref}
\begin{document}
some text
\clearpage
\begin{figure}
a figure
\phantomsection
\label{foo}
\end{figure}
more text
\clearpage
See figure on page \pageref{foo}.
\end{document}

:)

答案 2 :(得分:0)

加载caption包应该禁止显示空标题的标题输出。浮点数的标签始终由label命令前面的caption命令确定。