24

我正在尝试创建对不使用标题的浮动的引用。如果我在浮点数中包含 \label{foo} 并使用 \pageref{foo} 引用它,正确的页码会显示在我的 pdf 文档中,但 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}
4

3 回答 3

22

\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}没有意义。

于 2010-04-30T23:55:51.560 回答
17

在标签之前,使用 \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}

:)

于 2016-04-19T00:29:21.840 回答
0

加载caption包应该抑制空字幕的字幕输出。浮点数的标签始终由标签命令之前的标题命令确定。

于 2010-04-30T17:07:07.450 回答