3

I'm using footnotebackref with memoir. The footnote is generated and the link from the text works (from hyperref presumably), but no link is created from the footnote back to the text. This appears to be a confict with memoir (though it compiles fine and I don't see any errors in the output). If in the following MWE you substitute book for memoir then it works as expected. I've run it in both pdfLaTeX and LuaTeX and the results are the same.

\documentclass{memoir}
\usepackage{hyperref}
\usepackage{footnotebackref}
\begin{document}
This is text.\footnote{This is a footnote.}
\end{document}
2
  • Wild guess, but could it be because of your pdf viewer? Have you tried with two different ones? May 27, 2013 at 15:01
  • Yep, I've tried multiple viewers.
    – bfootdav
    May 27, 2013 at 15:07

2 Answers 2

2
+50

The footnotebackref package works by patching \@makefnmark, but memoir does not use this. Patching \@thefnmark as below seems to work at least on this example, but I can't promise that there aren't other unwanted effects:

\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}
3
  • Yep, that does it. Both my MWE and my real world version. The only thing I noticed in the output, which might be related, is the line: Package fmtcount Warning: \ordinal already defined use \FCordinal instead. on input line 344. I don't know what that means but it compiled fine and I don't see any problems in my main text. I've marked it answered for now but if anyone sees a potential problem and has a fix that's be great.
    – bfootdav
    May 27, 2013 at 19:03
  • The warning you are getting is due to both memoir and the fmtcount package trying to define \ordinal for similar purposes. However, from what I can tell, these are not interface compatible as one works on a counter name and the other on a literal number, hence it depends if you are using the fmtcount version anywhere. The footnotebackref code does not load fmtcount so this is caused by something unrelated to this question and you would be advised to create a further question with an appropriate MWE if you want help investigating. May 27, 2013 at 19:42
  • Thanks for the additional information. Turns out that the warning did not occur from my MWE but my real world example. I've got lots of stuff going on with that one so whenever I get around to isolating that problem I'll bring it up here. But for now it looks like the footnotebackref problem is solved. Thanks for figuring it out.
    – bfootdav
    May 27, 2013 at 23:13
0

memoir has many interfaces, thus seems that footnotebackref is not needed.

I use this patch without loading 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

The patch from @cyberSingularity will destroy \multfootsep, as it inserts the \label directly into \footnote.

MWE:

\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}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .