footnotebackref 软件包与 memoir 冲突

footnotebackref 软件包与 memoir 冲突

我正在使用footnotebackrefmemoir脚注已生成,并且文本中的链接有效(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}

相关内容