使用最近的包脚注返回参考可以反向引用footnotes
,然后可以直接从正文跳转到并footnote
返回。指向正文的链接footnote
可以设置为文本内的符号footnote
,或者像我更喜欢的那样,直接设置为footnote
中的数字footnote
。该hyperref
包将正文中的脚注编号链接到文本,而不是脚注的编号。
当以更高的缩放级别查看文档时,页面宽度不再适合 pdf 查看器的窗口,这会导致不想要的结果。单击正文中的脚注编号后,脚注编号和反向引用几乎不显示或根本不显示。所以我想知道是否可以将hyperref
脚注引用的位置直接更改为脚注编号。
可视化示例
在这里您可以明白我的意思,以防我无法正确解释或者有人想阅读我的描述。
平均能量损失
\documentclass{article}
\usepackage{footnotebackref}
\textheight=3cm
\begin{document}
Text\footnote{The first footnote.} Text\\
\end{document}
答案1
诀窍是将用于hyperref
将脚注锚点/目标设置为脚注文本的一部分的代码(因此在脚注标记被“绘制”之后)移动到用于定义脚注标记的“脚注”部分的代码中!(每个脚注使用两次脚注标记,一次在文本中,一次在脚注本身中;我在这里指的是后者。)
默认的 LaTeX 对这两个脚注标记不作区分,这可能就是为什么hyperref
最初会这样做的原因。footnotebackref
在某种意义上确实做出了区分,但我们无法干净地修补它,因此我们撤消他们的更改并使用我们的方法将它们修补回来(我从当前版本的中复制了此代码footnotebackref
,因此这可能会不同步)。
无论是否使用 ,以下代码都应该可以工作footnotebackref
(但如果使用 ,则必须在修补此补丁之前加载)。hyperref
也必须在修补此补丁之前加载。 的原始定义\@makefnmark
将保留,除非footnotebackref
使用 ,否则无论如何都会破坏它们。
\documentclass{article}
% comment/uncomment various combinations of these for testing
%\PassOptionsToPackage{symbol=$\wedge$}{footnotebackref}
%\PassOptionsToPackage{numberlinked=false}{footnotebackref}
\usepackage{footnotebackref}
\usepackage{hyperref}
\makeatletter
% distinguish between footnote marks in the text and in the footnotes themselves!
\let\hyperfoot@oldmakefntext\@makefntext
\renewcommand*{\@makefntext}{%
\let\hyperfoot@base@makefnmark\@makefnmark
\let\@makefnmark\hyperfoot@infootnote@makefnmark
\hyperfoot@oldmakefntext}
% set the hypertarget (through \hyper@@anchor) before placing \@thefnmark
\newcommand*{\hyperfoot@infootnote@makefnmark}{%
\fn@settarget
\hyperfoot@base@makefnmark
}
\@ifpackageloaded{footnotebackref}{%
\ifFootnoteBackref@numberlinked
\let\hyperfoot@oldmakefntext\BHFN@OldMakefntext% undo their patch
\renewcommand\hyperfoot@infootnote@makefnmark{%... and merge with ours
\fn@settarget
\mbox{\textsuperscript{\normalfont%
\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}\,}%
\fi
}{}
% reset hyperref's overriding of \@footnotetext, which basically just adds the \hyper@@anchor as part of the footnote text
\long\def\@footnotetext#1{%
\H@@footnotetext{#1}}
% and put the hyperref magic into \fn@settarget instead
% note that we set the anchor text to be \relax. previously, it was sometimes (=when allowing links to be nested) the footnote text. I don't actually know what the effect is of having anchor text... but apparently no drivers support nesting at the moment anyway.
\newcommand\fn@settarget{% a form of this was previously part of hyperref's \@footnotetext
%\message{^^J^^J**setting target!**^^J^^J}% we should only see as many 'setting target' messages in the log as there are footnotes!
\ifHy@nesting
\expandafter\ltx@firstoftwo
\else
\expandafter\ltx@secondoftwo
\fi
{%
\expandafter\hyper@@anchor\expandafter{%
\Hy@footnote@currentHref
}{\relax}%
}{%
\Hy@raisedlink{%
\expandafter\hyper@@anchor\expandafter{%
\Hy@footnote@currentHref
}{\relax}%
}%
\let\@currentHref\Hy@footnote@currentHref
\let\@currentlabelname\@empty
}%
}
% following makes testing slightly easier on my monitor
\hypersetup{pdfstartview={XYZ null null 4}}
\textheight=3cm
\begin{document}
Text\footnote{The first footnote.} Text.
Let's have more than one footnote!\footnote{For better testing!}
\end{document}