如何修复超目标将链接指向目标后的行?这看起来像是一个错误

如何修复超目标将链接指向目标后的行?这看起来像是一个错误

如果超目标处于文本模式位置,则指向它的链接可以正常工作(它们会在页面顶部显示目标行)。但是,如果超目标处于数学模式(任何类型:内联、显示数学或方程数组),则它将直接指向目标后的行。

平均能量损失

\documentclass{minimal}
\usepackage{amsmath}
\usepackage{hyperref}

\begin{document}
\hypertarget{test1}{target1 in text mode}

Filler text.

$3 + 4 = 7 \hypertarget{test2}{}$ More filler text.

Link 2 actually directs to this line, rather than the above line, where we would expect it to do the latter.

\begin{eqnarray}
x * y = z \hypertarget{test3}{} \\
a + b = c % Link 3 actually directs to this line, rather than the above line, where we would expect it to do the latter. \\
\end{eqnarray}

\hyperlink{test1}{Clicking on this link shows target1 at the top of the page, as expected.}

\hyperlink{test2}{Link 2.}

\hyperlink{test3}{Link 3.}

\end{document}

对我来说这似乎是一个错误,但是有没有更好的方法来做到这一点?

答案1

您可以执行以下操作:

\documentclass{minimal}
\usepackage{amsmath}
\usepackage{hyperref}

\makeatletter
 \newcommand{\linkdest}[1]{\Hy@raisedlink{\hypertarget{#1}{}}}
\makeatother

\begin{document}
\linkdest{test1}target1 in text mode.

Filler text.

$3 + 4 = 7 \linkdest{test2}{}$ More filler text.

Link 2 actually directs to this line, rather than the above line, where we would expect it to do the latter.

\begin{eqnarray}
x * y = z \linkdest{test3}{} \\
a + b = c % Link 3 actually directs to this line, rather than the above line, where we would expect it to do the latter. \\
\end{eqnarray}

\hyperlink{test1}{Clicking on this link shows target1 at the top of the page, as expected.}

\hyperlink{test2}{Link 2.}

\hyperlink{test3}{Link 3.}

\end{document}

测试宏来修改超目标以正确显示

相关内容