0

While I'm aware that hyperref doesn't suport footnotes and I quote:

hyperfootnotes boolean true
Makes the footnote marks into hyperlinks to the footnote text. Easily broken …

I'm wondering if anyone's found a workaround for something like:

\documentclass{article}

\usepackage[stable,perpage,multiple,bottom]{footmisc} 
\usepackage[hyperfootnotes=true]{hyperref}
\usepackage{footnotebackref} % connect note back to table
\usepackage{longtable}
\usepackage{blindtext} 

\begin{document}

\blindtext
\newpage
\blindtext

\begin{longtable}{c c p{3cm} c}
  & centered \footnote{Here's a note from a
    centered column} & \\
  &  & paragraph \footnote{This note is } & \\

\end{longtable}

\end{document}

Which givesenter image description here

Here we can see that the note from a centered column works as expected (i.e. clicking on the footnote label brings the user to the footnote' they can then click on this label and be brought back to the table) while that from a paragraph-formatted column is rather recalcitrant (it brings the user back to the top of the document). I'm using footnotebackref to get back to the table, but this behavior is not essential...

(I'm using the \usepackage{}s as above after numerous attempts to solve this - this seems to be the closest I can come).

I'm asking as I have a table spanning multiple pages which would be better if a paragraph-formatted column could hyperlink to a footnote on the same page.

Or is this currently not possible?

  • 1
    recalcitrant: (Adjective) Marked by stubborn resistance to and defiance of authority or guidance. Darn those paragraph footnotes...! – Werner Oct 13 '13 at 5:02
  • 1
    As posted I get an error ! Undefined control sequence.<argument> \BackrefFootnoteTag you (or someone:-) should fix that before looking at the output. You don't say what is wrong with the output you show but I assume it is just the missing backlink on the second footnote, which is I assume related. – David Carlisle Oct 13 '13 at 9:53
  • Thanks to you both. @David Carlisle I think the \BackrefFootnoteTag error is due to the second footnote not being properly defined and having no tag, so that footnotebackref can't find it. It can be removed by commenting out \usepackage{footnotebackref} – dardisco Oct 13 '13 at 22:06
  • 1
    @dardisco yes you can comment out footnotebackref but then everything works and there is no issue, it is only that the backref doesn't work on the second footnot isn't it? If there are no footnote backrefs everythuing is as expected. – David Carlisle Oct 13 '13 at 22:37
  • @David Carlisle Yes, I wish. It does compile without error. However the backref is not the primary issue here. I'm afraid it still causes the same problem i.e. the footnote reference from the paragraph-formatted column still doesn't work. – dardisco Oct 14 '13 at 5:08
3

Some extra work is needed so that the corresponding tag used by footnotebackref is still available when it gets recalled. The following seems to work:

\documentclass{article}

\usepackage{longtable}
\usepackage{array}

\usepackage{hyperref}
\usepackage{footnotebackref}
\usepackage{etoolbox}
\patchcmd{\footnote}{\edef}{\xdef}{}{\errmessage{failed to patch}}

\makeatletter
\renewcommand\@makefntext[1]{%
    \edef\@makefnmark{%
        \noexpand\mbox{\noexpand\textsuperscript{\noexpand\normalfont%
        \noexpand\hyperref[\BackrefFootnoteTag]{\noexpand\@thefnmark}}}\noexpand\,}%
    \BHFN@OldMakefntext{#1}}%
\makeatother


\begin{document}

\begin{longtable}{
    c
    >{\raggedright}p{3cm}
  }
  % start of table cells:
  centered \footnote{Here's a note from a
    centered column} \tabularnewline
  & paragraph \footnote{This note is from paragraph } \tabularnewline
\end{longtable}

\end{document}
  • Yes, works like a charm, thanks! Will need to dig a little to see how... – dardisco Oct 21 '13 at 18:20
  • 1
    @dardisco: Sorry, didn't put much explanation in! The tag is what hyperref uses as an anchor. The first patch converts footnotebackref's setting of \BackrefFootnoteTag within \footnote to be global instead of lasting only for current group (\xdef instead of \edef), and the second part ensures that \BackrefFootnoteTag is expanded when \@makefntext is called rather than deferring it to when \@makefnmark is called (footnotes don't get created straight away when in a table but are saved for recalling later, but by then, multiple footnotes will cause earlier tags to get lost). – cyberSingularity Oct 21 '13 at 18:57
  • Thanks for the explanation! I'm still learning how to find function definitions.. I'm guessing you looked at source for footnotebackref, hyperref and functions footnote and @makefnmark to come up with this... – dardisco Oct 21 '13 at 23:28
  • 1
    @dardisco: Yes, exactly. source2e/latex.ltx has the original forms of \footnote and \@makefnmark if needed. And also longtable changes footnote handling. footnotebackref is a very small package so I'd start with that. Just open up the sty file (either on your own machine or from CTAN if easier) and inspect! For specific commands, latexdef can be useful (and there's lots of questions and answers involving it on this site). – cyberSingularity Oct 22 '13 at 8:57
0

@David Carlisle was bang on (as usual), it seems footnotebackref and longtable don't play well together. Here's a minimal example which produces the behavior I was originally hoping for.

\documentclass{article}

\usepackage{longtable}
\usepackage{array}

%\usepackage{footnotebackref}
\usepackage{hyperref}

\begin{document}

\begin{longtable}{
    c
    >{\raggedright}p{3cm}
  }
  % start of table cells:
  centered \footnote{Here's a note from a
    centered column} \tabularnewline
  & paragraph \footnote{This note is from paragraph } \tabularnewline
\end{longtable}

\end{document}

giving (sorry for quality) enter image description here

Would be nice to have the footnote link back to the longtable so will keep this one open for now in case there's a way to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.