![footnotebackref 软件包与 memoir 冲突](https://linux22.com/image/269061/footnotebackref%20%E8%BD%AF%E4%BB%B6%E5%8C%85%E4%B8%8E%20memoir%20%E5%86%B2%E7%AA%81.png)
我正在使用footnotebackref
。memoir
脚注已生成,并且文本中的链接有效(hyperref
大概来自),但没有从脚注创建回文本的链接。这似乎与 memoir 发生冲突(尽管它编译得很好,而且我在输出中没有看到任何错误)。如果在以下 MWE 中替换 ,book
那么memoir
它会按预期工作。我在 pdfLaTeX 和 LuaTeX 中都运行过它,结果是一样的。
\documentclass{memoir}
\usepackage{hyperref}
\usepackage{footnotebackref}
\begin{document}
This is text.\footnote{This is a footnote.}
\end{document}
答案1
该footnotebackref
软件包通过修补 起作用\@makefnmark
,但memoir
不使用此功能。\@thefnmark
至少在这个例子中,下面的修补似乎有效,但我不能保证没有其他不良影响:
\documentclass{memoir}
\usepackage{hyperref}
\usepackage{footnotebackref}
\makeatletter
\renewcommand\@makefntext[1]{%
\let\BHFN@thefnmark\@thefnmark
\renewcommand\@thefnmark{\hyperref[\BackrefFootnoteTag]{\BHFN@thefnmark}}%
\BHFN@OldMakefntext{#1}}%
\makeatother
\begin{document}
This is text.\footnote{This is a footnote.}
\end{document}
答案2
memoir
有很多接口,因此看起来footnotebackref
没有必要。
我用这个补丁没有加载中footnotebackref
:
\newcounter{BackrefHyperFootnoteCounter}
\makeatletter
\LetLtxMacro{\mfnbr@old@footnote}{\footnote} % `letltxmacro' already required by `hyperref'
\let\mfnbr@old@makefnmark=\@makefnmark
\let\mfnbr@old@makefootmark=\makefootmark
\def\footnote{% must not insert any visible things: space, label etc.
\stepcounter{BackrefHyperFootnoteCounter}% must not be `\refstepcounter', which include a `\ref'.
\edef\BackrefFootnoteTag{mfnbr:\theBackrefHyperFootnoteCounter}%
\mfnbr@old@footnote
}
\def\@makefnmark{%
\mfnbr@old@makefnmark%
\label{\BackrefFootnoteTag}% must not be in `\footnote', as this is "visible" to TeX.
}
\def\makefootmark{\hyperref[\BackrefFootnoteTag]{\mfnbr@old@makefootmark}}
\makeatother
@cyberSingularity 的补丁将会破坏\multfootsep
,因为它将\label
直接插入\footnote
。
梅威瑟:
\documentclass{memoir}
\usepackage{lipsum}
\usepackage[colorlinks, allcolors=blue]{hyperref}
\newcounter{BackrefHyperFootnoteCounter}
\makeatletter
\LetLtxMacro{\mfnbr@old@footnote}{\footnote} % `letltxmacro' already required by `hyperref'
\let\mfnbr@old@makefnmark=\@makefnmark
\let\mfnbr@old@makefootmark=\makefootmark
\def\footnote{% must not insert any visible things: space, label etc.
\stepcounter{BackrefHyperFootnoteCounter}% must not be `\refstepcounter', which include a `\ref'.
\edef\BackrefFootnoteTag{mfnbr:\theBackrefHyperFootnoteCounter}%
\mfnbr@old@footnote
}
\def\@makefnmark{%
\mfnbr@old@makefnmark%
\label{\BackrefFootnoteTag}% must not be in `\footnote', as this is "visible" to TeX.
}
\def\makefootmark{\hyperref[\BackrefFootnoteTag]{\mfnbr@old@makefootmark}}
\makeatother
\begin{document}
\lipsum[3]\footnote{fn1}\footnote{fn2}\lipsum
\end{document}