Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question led to a new package:
footnotebackref

I'm using hyperref to have footnote marks link to the footnote proper and I'd like to have some sort of "backreferences" from the footnote proper back to where they're called (à la Wikipedia). For example:

This[1] is the text[2] that serves[3] as an example[1] to
the footnote[2] backrefence thing[4].
-------
[1] The first footnote. [a, d]
[2] The second footnote. [b, e]
[3] The third footnote. [c]
[4] The fourth footnote. [f]

Where a, b, c, d, e and f are links to the first, second, third, fourth, fifth and sixth places where footnotemarks are respectively.

I hope I managed to communicate what I'd like, I'm not that good at it :P

A MWE follows.

\documentclass{book}
\usepackage{hyperref}
\begin{document}
  This\footnote{The first footnote. [a, d]} is the text\footnote{The second footnote. [b, e]}
  that serves\footnote{The third footnote. [c]} as an example\footnotemark[1] to
  the footnote\footnotemark[2] backrefence thing\footnote{The fourth footnote. [f]}.
\end{document}
share|improve this question
3  
I think you have communicated it very well. But, even though it may seem trivial it would be better to compose a MWE that illustrates the problem including the \documentclass so that those trying to help don't have to recreate it. –  Peter Grill Oct 23 '11 at 1:15
1  
In your real application, are these going to be "free-text footnotes", i.e. do you specify the content of the footnote explicitly, or are they bibliographic footnotes generated using something like biblatex? –  Jake Oct 23 '11 at 2:05
    
For the foreseeable future at least, these are supposed to be normal footnotes. –  mpr Oct 23 '11 at 2:20
    
The mechanism will probably involve \hypertarget{linkname}{link text} and \hyperlink{linkname}{a or b or c etc}. This is quite a tricky problem to automate, it's almost like you're creating a little toc in the footnote. –  cmhughes Oct 23 '11 at 15:49
1  
It's quite easy to get working if there is at most one footnote mark per footnote... I got stuck when I typeset the first double mark one :S –  mpr Oct 23 '11 at 17:53

1 Answer 1

up vote 34 down vote accepted

Edit: Using the new package footnotebackref

Just include the package in the preamble and use the \footnote-command as usual. There are two options which are described in the package documentation.

\documentclass{article}
\usepackage{footnotebackref}
%\usepackage[symbol=$\wedge$]{footnotebackref}
%\usepackage[numberlinked=false]{footnotebackref}

\textheight=3cm
\begin{document}\noindent
Text\footnote{The first footnote.} Text\\
Text\footnote[4]{The second footnote.} Text\\
Text\footnote{The third footnote.} Text
\end{document}

footnotebackref


The original answer:

Here is a non tricky approach for the backreferences. I used the hyperref[target]{text} command from the hyperref package and created an new footnote to expand the standard footnote command. Before I set the standard footnote I place a label with an unambiguous(!) tag (myFootnoteTag) for the label-ref-mechanism using an independent counter. To reference the label from the footnote the hyperref[]{} command is used. This is set to the footnotetext and create a clickable reference in it. Here one can choose between different styles for the clickable item.

\documentclass{article}
\usepackage{hyperref}

\newcounter{myHyperFootnoteCounter}

\newcommand{\myHyperFootnote}[1]{%
    \refstepcounter{myHyperFootnoteCounter}%
    \def\myFootnoteTag{hfn:\themyHyperFootnoteCounter}%
    \label{\myFootnoteTag}%
    %\footnote{\hyperref[\myFootnoteTag]{#1}}% clickable footnotetext
    \footnote{\hyperref[\myFootnoteTag]{$\wedge$}#1}% Wikipedia style
}

\makeatletter
%clickable footnote number
\renewcommand\@makefntext[1]{%
    \noindent\makebox[1.8em][r]{%
    \mbox{\textsuperscript{\normalfont\hyperref[\myFootnoteTag]{\@thefnmark}}}\,}#1%
}

\makeatother

\begin{document}
Text\myHyperFootnote{The first footnote.} Text\\
Text\myHyperFootnote{The second footnote.} Text\\
Text\myHyperFootnote{The third footnote.} Text\\
Text\myHyperFootnote{The fourth footnote.} Text\\
Text\myHyperFootnote{The fifth footnote.} Text\\
Text\myHyperFootnote{The sixth footnote.} Text
\end{document}

Edit: After the question of Stephen I give an extended version. I use the TeX-command \@ifnextchar to branch between the footnotes with or without optional argument. If the next char after \myHyperFootnote is [ the macro \my@OptHyperFootnote will be executed. If there is no [ the macro \my@HyperFootnote will be executed. Keep in mind that all macros are in the \makeatletter environment now because I used the @ in the 'submacros'.

\documentclass{article}
\usepackage{hyperref}

%a new counter to create an unambiguous label-tag
\newcounter{myHyperFootnoteCounter}

\makeatletter

% branch between the footnote with/without opt. argument
\def\myHyperFootnote{\@ifnextchar[\my@OptHyperFootnote\my@HyperFootnote}

%define an new footnote without optional argument
\def\my@HyperFootnote#1{%
    \refstepcounter{myHyperFootnoteCounter}%
    \def\myFootnoteTag{hfn:\themyHyperFootnoteCounter}%
    \label{\myFootnoteTag}%
    \footnote{\hyperref[\myFootnoteTag]{$\wedge$}#1}%
}

%define an new footnote with optional argument
\def\my@OptHyperFootnote[#1]#2{%
    \refstepcounter{myHyperFootnoteCounter}%
    \def\myFootnoteTag{hfn:\themyHyperFootnoteCounter}%
    \label{\myFootnoteTag}%
    % put the optional argument to the original `footnote`
    \footnote[#1]{\hyperref[\myFootnoteTag]{$\wedge$}#2}% 
}

%if the footnote number should be the reference than redefine the footnote macro
\renewcommand\@makefntext[1]{%
    \noindent\makebox[1.8em][r]{%
    \mbox{\textsuperscript{\normalfont\hyperref[\myFootnoteTag]{\@thefnmark}}}\,}#1%
}
\makeatother


\begin{document}
Text\myHyperFootnote{The first footnote.} Text\\
Text\myHyperFootnote[4]{The second footnote.} Text\\
Text\myHyperFootnote{The third footnote.} Text\\
Text\myHyperFootnote{The fourth footnote.} Text\\
Text\myHyperFootnote[8]{The fifth footnote.} Text\\
Text\myHyperFootnote{The sixth footnote.} Text
\end{document}
share|improve this answer
    
That is really nice. Do you have an idea how to handle conditional footnote-numbers, i.e. \footnote[7]{The third footnote.}? –  Stephen May 2 '12 at 15:22
    
@Stephen: I extend the hyperFootnote with an optional argument. –  Holle May 2 '12 at 17:43
    
That is great!!! If I had not upvoted it before, I would have done so now. Thanks! (I just removed an empty line, which introduced a line-break in the text whenever an optional argument was used with \footnote.) –  Stephen May 3 '12 at 15:16
    
Please see my comment, given as "answer" because of the limited length of comments. Thanks! –  Stephen Jun 8 '12 at 17:14
    
@Holle I use your package with numberlinked=true. At a higher zoom level after clicking on the footnote number inside the text I jump to the footnote. Then I am not able to see the footnote number in the footer since the link points directly to the text. When I want to go back to the main text, I have to go the left of the footnote to see the footnote number and click on it. This scrolling is a bit annoying though. May be you can change this, so that the link from the main text points to number in the footer and not the text in the footer. –  maetra Jul 4 '12 at 16:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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