blob: 9f2a7be5f9168dd19d8daba9d12822f03b5b1b07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
%File: footnotebackref.sty
% Copyright (C) 2012 Holger Lange
%
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\ProvidesPackage{footnotebackref}%
[2012/07/01 v1.0 Backreferences for footnotes (Holger Lange)]
% This package was inspired by http://tex.stackexchange.com/a/40282
\RequirePackage{letltxmacro}
\RequirePackage{hyperref}
\RequirePackage{kvoptions}[2010/12/23]% v3.10
\SetupKeyvalOptions{family=FootnoteBackref, prefix=FootnoteBackref@}
% The symbol between the footnotenumber and the footnotetext
% If empty no symbol will be printed
\DeclareStringOption{symbol}
% Option to hyperlink the footnotenumber
\DeclareBoolOption[true]{numberlinked}
\ProcessKeyvalOptions*
% A new counter to create an unambiguous label-tag for all hyperfootnotes
\newcounter{BackrefHyperFootnoteCounter}
% Store the original LaTeX footnote macros to separate macros
\LetLtxMacro{\BHFN@OldFootnote}{\footnote}
\LetLtxMacro{\BHFN@OldMakefntext}{\@makefntext}
% Redefine the original footnote macro to
% branch between the footnote with/without optional argument
\renewcommand*\footnote{%
\refstepcounter{BackrefHyperFootnoteCounter}%
\edef\BackrefFootnoteTag{bhfn:\theBackrefHyperFootnoteCounter}%
\label{\BackrefFootnoteTag}%
\@ifnextchar[\Backref@OptHyperFootnote\Backref@HyperFootnote}
% Define an new footnote without optional argument
\newcommand\Backref@HyperFootnote[1]{%
\BHFN@OldFootnote{\Backref@HyperSymbol#1}}
% Define an new footnote with optional argument
\newcommand\Backref@OptHyperFootnote[2][\empty]{%
\BHFN@OldFootnote[#1]{\Backref@HyperSymbol#2}}
% Definition of the hyperlinked symbol ...
\newcommand\Backref@HyperSymbol{%
\hyperref[\BackrefFootnoteTag]{\FootnoteBackref@symbol}}
% ...but if the symbol is empty it is deleted straightaway
\ifx\FootnoteBackref@symbol\empty
\renewcommand\Backref@HyperSymbol\relax\fi
% If the footnote number should be the reference
% than redefine the \@makefntext and \@makefnmark
% The \@makefnmark macro is redefined in the space of
% the \@makefntext macro
% So the footnote numbers in the main text are not influenced
\ifFootnoteBackref@numberlinked
\renewcommand\@makefntext[1]{%
\renewcommand\@makefnmark{%
\mbox{\textsuperscript{\normalfont%
\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}\,}%
\BHFN@OldMakefntext{#1}}%
\fi
\endinput
|