带有 hyperref 的多个脚注标记被错误引用

带有 hyperref 的多个脚注标记被错误引用

我需要在标题中放置脚注 - 不仅一个,而且多个。我搜索了几种方法,最终找到了以下解决方案 - 作为 MWE:

\documentclass[a4paper,11pt]{article}
\usepackage[margin=2.5cm]{geometry} 
\usepackage{float}
\usepackage[pdfa, unicode]{hyperref}
\usepackage{kantlipsum}
\begin{document}
\kant[1-6]
\begin{figure}[H]
Test of a caption with two footnote 
\caption[figure]{%
\protect\footnotemark{} first footnote. 
\protect\footnotemark{}second footnote.}
\end{figure}
%\kant[1]
\addtocounter{footnote}{-1}
\footnotetext{first reference footnote}
\addtocounter{footnote}{1}
\footnotetext{second footnote }
\kant
\end{document}

此解决方案与lualatex 1.17.0和编译良好Hyperref v7.00v。我看到的主要问题是单击第一个脚注引用。页面滚动到“无处”。当我单击第二个脚注计数器时,页面正确滚动并正确显示脚注。

它能按预期工作吗?还是我需要做更多调整?

答案1

我首先尝试使用\refstepcounter,但里面已经太迟了,之前会链接到创建的\footnotetext位置。所以我创建了以正确定义。\footnotetext\footlabel\hypertarget

\documentclass[a4paper,11pt]{article}
\usepackage[margin=2.5cm]{geometry} 
\usepackage{float}
\usepackage[pdfa, unicode]{hyperref}
\usepackage{kantlipsum}
\makeatletter
\def\footlabel{%
  %\edef\@currentlabel{\thefootnote}%
  \edef\@currentHref{footnote.\the\c@footnote}%
  \raisebox{\baselineskip}[0pt]{\hypertarget{\@currentHref}{}}% adjust aim up
  \label}
\makeatother
\begin{document}
\kant[1-6]
Note that aim point does not include number\footnote{test}
\begin{figure}[H]
Test of a caption with two footnote 
\caption[figure]{% no \protect needed with short caption [figure] in use
\footref{A} first footnote. 
\footref{B} second footnote.}
\end{figure}
%\kant[1]
\stepcounter{footnote}%
\footnotetext{\footlabel{A}first reference footnote}
\stepcounter{footnote}%
\footnotetext{\footlabel{B}second footnote }
\kant
\end{document}

相关内容