![是](https://linux22.com/image/301598/%E6%98%AF.png)
在大量使用文本链接的文档中,我遇到一个问题,即当跳转到那里时,目标总是超出 pdf 查看器的视图,我找不到合适的解决方案。
最好是,跳跃应该以这样的方式着陆,即视图受目标所在行的顶行限制,左边框应与左文本边框匹配(甚至留下一点空白)。参见下图。此行为应该与查看器所处的当前缩放状态无关(同时承认如果缩放值较低,则无法实现左边框匹配)。
有可能吗?
例如采用这个 MWE
\documentclass[a4paper]{report}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[hidelinks]{hyperref}
\begin{document}
\chapter{First chapter}
Get to know more about what is a \hyperlink{frog}{frog}.
\chapter{Second chapter}
Did you know, that a \hypertarget{frog}{frog} is an animal?
\end{document}
是
应该
答案1
试试这个。这是使用 的\phantomsection
旧式格式,并且有效。ref/label
hyperref
\documentclass[a4paper]{report}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[hidelinks]{hyperref}
\begin{document}
\chapter{First chapter}
Get to know more about what is a \hyperref[frog]{frog}.
\chapter{Second chapter}
Did you know, that a frog\phantomsection\label{frog} is an animal?
\end{document}
然后你也可以将所有内容包装到命令中。
\newcommand{\myref}[1]{\hyperref[#1]{#1}}
\newcommand{\mylabel}[1]{\phantomsection\label{#1}}
从而变成:
\documentclass[a4paper]{report}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[hidelinks]{hyperref}
\newcommand{\myref}[1]{\hyperref[#1]{#1}}
\newcommand{\mylabel}[1]{\phantomsection\label{#1}}
\begin{document}
\chapter{First chapter}
Get to know more about what is a \myref{frog}.
\chapter{Second chapter}
Did you know, that a frog\mylabel{frog} is an animal?
\end{document}