elog2labfolder/_build/latex/footnotehyper-sphinx.sty
author weiher
Mon, 04 Jun 2018 16:38:36 +0200
changeset 18 57431f642e82
parent 3 b71be85a294c
permissions -rw-r--r--
Minor additions for comprehension and changes in the document structure
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
     1
\NeedsTeXFormat{LaTeX2e}
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
     2
\ProvidesPackage{footnotehyper-sphinx}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
     3
 [2017/03/07 v1.6 hyperref aware footnote.sty for sphinx (JFB)]
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
     4
%%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
     5
%% Package: footnotehyper-sphinx
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
     6
%% Version: based on footnotehyper.sty 2017/03/07 v1.0
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
     7
%% as available at http://www.ctan.org/pkg/footnotehyper
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
     8
%% License: the one applying to Sphinx
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
     9
%%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    10
%% Refer to the PDF documentation  at http://www.ctan.org/pkg/footnotehyper for
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    11
%% the code comments.
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    12
%%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    13
%% Differences:
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    14
%% 1. a partial tabulary compatibility layer added (enough for Sphinx mark-up),
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    15
%% 2. use of \spx@opt@BeforeFootnote from sphinx.sty,
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    16
%% 3. use of \sphinxunactivateextrasandspace from sphinx.sty,
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    17
%% 4. macro definition \sphinxfootnotemark,
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    18
%% 5. macro definition \sphinxlongtablepatch
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    19
\DeclareOption*{\PackageWarning{footnotehyper-sphinx}{Option `\CurrentOption' is unknown}}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    20
\ProcessOptions\relax
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    21
\newbox\FNH@notes
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    22
\newdimen\FNH@width
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    23
\let\FNH@colwidth\columnwidth
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    24
\newif\ifFNH@savingnotes
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    25
\AtBeginDocument {%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    26
    \let\FNH@latex@footnote    \footnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    27
    \let\FNH@latex@footnotetext\footnotetext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    28
    \let\FNH@H@@footnotetext   \@footnotetext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    29
    \newenvironment{savenotes}
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    30
        {\FNH@savenotes\ignorespaces}{\FNH@spewnotes\ignorespacesafterend}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    31
    \let\spewnotes      \FNH@spewnotes
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    32
    \let\footnote       \FNH@footnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    33
    \let\footnotetext   \FNH@footnotetext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    34
    \let\endfootnote    \FNH@endfntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    35
    \let\endfootnotetext\FNH@endfntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    36
    \@ifpackageloaded{hyperref}
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    37
     {\ifHy@hyperfootnotes
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    38
         \let\FNH@H@@footnotetext\H@@footnotetext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    39
      \else
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    40
         \let\FNH@hyper@fntext\FNH@nohyp@fntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    41
      \fi}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    42
     {\let\FNH@hyper@fntext\FNH@nohyp@fntext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    43
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    44
\def\FNH@hyper@fntext{\FNH@fntext\FNH@hyper@fntext@i}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    45
\def\FNH@nohyp@fntext{\FNH@fntext\FNH@nohyp@fntext@i}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    46
\def\FNH@fntext #1{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    47
  \ifx\ifmeasuring@\@undefined
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    48
    \expandafter\@secondoftwo\else\expandafter\@firstofone\fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    49
% these two lines modified for Sphinx (tabulary compatibility):
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    50
    {\ifmeasuring@\expandafter\@gobbletwo\else\expandafter\@firstofone\fi}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    51
    {\ifx\equation$\expandafter\@gobbletwo\fi #1}%$
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    52
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    53
\long\def\FNH@hyper@fntext@i#1{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    54
  \global\setbox\FNH@notes\vbox
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    55
  {\unvbox\FNH@notes
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    56
   \FNH@startnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    57
   \@makefntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    58
    {\rule\z@\footnotesep\ignorespaces
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    59
     \ifHy@nesting\expandafter\ltx@firstoftwo
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    60
             \else\expandafter\ltx@secondoftwo
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    61
     \fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    62
     {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}{#1}}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    63
     {\Hy@raisedlink
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    64
       {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    65
       {\relax}}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    66
      \let\@currentHref\Hy@footnote@currentHref
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    67
      \let\@currentlabelname\@empty
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    68
      #1}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    69
     \@finalstrut\strutbox
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    70
    }%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    71
   \FNH@endnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    72
  }%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    73
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    74
\long\def\FNH@nohyp@fntext@i#1{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    75
  \global\setbox\FNH@notes\vbox
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    76
  {\unvbox\FNH@notes
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    77
   \FNH@startnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    78
   \@makefntext{\rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    79
   \FNH@endnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    80
  }%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    81
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    82
\def\FNH@startnote{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    83
  \hsize\FNH@colwidth
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    84
  \interlinepenalty\interfootnotelinepenalty
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    85
  \reset@font\footnotesize
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    86
  \floatingpenalty\@MM
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    87
  \@parboxrestore
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    88
  \protected@edef\@currentlabel{\csname p@\@mpfn\endcsname\@thefnmark}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    89
  \color@begingroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    90
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    91
\def\FNH@endnote{\color@endgroup}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    92
\def\FNH@savenotes{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    93
  \begingroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    94
  \ifFNH@savingnotes\else
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    95
    \FNH@savingnotestrue
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    96
    \let\@footnotetext    \FNH@hyper@fntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    97
    \let\@mpfootnotetext  \FNH@hyper@fntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    98
    \let\H@@mpfootnotetext\FNH@nohyp@fntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
    99
    \FNH@width\columnwidth
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   100
    \let\FNH@colwidth\FNH@width
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   101
    \global\setbox\FNH@notes\box\voidb@x
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   102
    \let\FNH@thempfn\thempfn
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   103
    \let\FNH@mpfn\@mpfn
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   104
    \ifx\@minipagerestore\relax\let\@minipagerestore\@empty\fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   105
    \expandafter\def\expandafter\@minipagerestore\expandafter{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   106
      \@minipagerestore
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   107
      \let\thempfn\FNH@thempfn
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   108
      \let\@mpfn\FNH@mpfn
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   109
    }%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   110
  \fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   111
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   112
\def\FNH@spewnotes {%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   113
  \endgroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   114
  \ifFNH@savingnotes\else
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   115
   \ifvoid\FNH@notes\else
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   116
    \begingroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   117
     \let\@makefntext\@empty
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   118
     \let\@finalstrut\@gobble
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   119
     \let\rule\@gobbletwo
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   120
     \FNH@H@@footnotetext{\unvbox\FNH@notes}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   121
    \endgroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   122
   \fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   123
  \fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   124
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   125
\def\FNH@footnote@envname    {footnote}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   126
\def\FNH@footnotetext@envname{footnotetext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   127
\def\FNH@footnote{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   128
% this line added for Sphinx:
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   129
    \spx@opt@BeforeFootnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   130
    \ifx\@currenvir\FNH@footnote@envname
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   131
        \expandafter\FNH@footnoteenv
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   132
    \else
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   133
        \expandafter\FNH@latex@footnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   134
    \fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   135
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   136
\def\FNH@footnoteenv{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   137
% this line added for Sphinx (footnotes in parsed literal blocks):
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   138
    \catcode13=5 \sphinxunactivateextrasandspace
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   139
    \@ifnextchar[%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   140
      \FNH@footnoteenv@i %]
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   141
      {\stepcounter\@mpfn
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   142
       \protected@xdef\@thefnmark{\thempfn}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   143
       \@footnotemark
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   144
       \def\FNH@endfntext@fntext{\@footnotetext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   145
       \FNH@startfntext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   146
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   147
\def\FNH@footnoteenv@i[#1]{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   148
    \begingroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   149
     \csname c@\@mpfn\endcsname #1\relax
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   150
     \unrestored@protected@xdef\@thefnmark{\thempfn}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   151
    \endgroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   152
    \@footnotemark
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   153
    \def\FNH@endfntext@fntext{\@footnotetext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   154
    \FNH@startfntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   155
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   156
\def\FNH@footnotetext{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   157
    \ifx\@currenvir\FNH@footnotetext@envname
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   158
        \expandafter\FNH@footnotetextenv
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   159
    \else
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   160
        \expandafter\FNH@latex@footnotetext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   161
    \fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   162
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   163
\def\FNH@footnotetextenv{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   164
    \@ifnextchar[%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   165
      \FNH@footnotetextenv@i %]
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   166
      {\protected@xdef\@thefnmark{\thempfn}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   167
       \def\FNH@endfntext@fntext{\@footnotetext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   168
       \FNH@startfntext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   169
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   170
\def\FNH@footnotetextenv@i[#1]{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   171
    \begingroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   172
     \csname c@\@mpfn\endcsname #1\relax
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   173
     \unrestored@protected@xdef\@thefnmark{\thempfn}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   174
    \endgroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   175
    \ifFNH@savingnotes
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   176
      \def\FNH@endfntext@fntext{\FNH@nohyp@fntext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   177
    \else
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   178
      \def\FNH@endfntext@fntext{\FNH@H@@footnotetext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   179
    \fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   180
    \FNH@startfntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   181
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   182
\def\FNH@startfntext{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   183
  \setbox\z@\vbox\bgroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   184
    \FNH@startnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   185
    \FNH@prefntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   186
    \rule\z@\footnotesep\ignorespaces
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   187
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   188
\def\FNH@endfntext {%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   189
    \@finalstrut\strutbox
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   190
    \FNH@postfntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   191
    \FNH@endnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   192
    \egroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   193
  \begingroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   194
    \let\@makefntext\@empty\let\@finalstrut\@gobble\let\rule\@gobbletwo
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   195
    \FNH@endfntext@fntext {\unvbox\z@}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   196
  \endgroup
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   197
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   198
\AtBeginDocument{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   199
   \let\FNH@@makefntext\@makefntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   200
   \ifx\@makefntextFB\undefined
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   201
   \expandafter\@gobble\else\expandafter\@firstofone\fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   202
   {\ifFBFrenchFootnotes \let\FNH@@makefntext\@makefntextFB \else
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   203
                         \let\FNH@@makefntext\@makefntextORI\fi}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   204
   \expandafter\FNH@check@a\FNH@@makefntext{1.2!3?4,}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   205
               \FNH@@@1.2!3?4,\FNH@@@\relax
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   206
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   207
\long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   208
    \ifx\relax#3\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   209
    \FNH@bad@makefntext@alert
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   210
    {\def\FNH@prefntext{#1}\def\FNH@postfntext{#2}\FNH@check@b}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   211
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   212
\def\FNH@check@b #1\relax{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   213
    \expandafter\expandafter\expandafter\FNH@check@c
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   214
    \expandafter\meaning\expandafter\FNH@prefntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   215
    \meaning\FNH@postfntext1.2!3?4,\FNH@check@c\relax
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   216
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   217
\def\FNH@check@c #11.2!3?4,#2#3\relax{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   218
    \ifx\FNH@check@c#2\expandafter\@gobble\fi\FNH@bad@makefntext@alert
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   219
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   220
% slight reformulation for Sphinx
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   221
\def\FNH@bad@makefntext@alert{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   222
  \PackageWarningNoLine{footnotehyper-sphinx}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   223
    {Footnotes will be sub-optimal, sorry. This is due to the document class or^^J
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   224
  some package modifying macro \string\@makefntext.^^J
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   225
  You can try to report this incompatibility at^^J
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   226
  https://github.com/sphinx-doc/sphinx with this info:}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   227
    \typeout{\meaning\@makefntext}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   228
    \let\FNH@prefntext\@empty\let\FNH@postfntext\@empty
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   229
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   230
% this macro from original footnote.sty is not used anymore by Sphinx
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   231
% but for simplicity sake let's just keep it as is
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   232
\def\makesavenoteenv{\@ifnextchar[\FNH@msne@ii\FNH@msne@i}%]
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   233
\def\FNH@msne@i #1{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   234
  \expandafter\let\csname FNH$#1\expandafter\endcsname %$
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   235
                  \csname #1\endcsname
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   236
  \expandafter\let\csname endFNH$#1\expandafter\endcsname %$
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   237
                  \csname end#1\endcsname
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   238
  \FNH@msne@ii[#1]{FNH$#1}%$
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   239
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   240
\def\FNH@msne@ii[#1]#2{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   241
  \expandafter\edef\csname#1\endcsname{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   242
    \noexpand\savenotes
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   243
    \expandafter\noexpand\csname#2\endcsname
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   244
  }%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   245
  \expandafter\edef\csname end#1\endcsname{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   246
    \expandafter\noexpand\csname end#2\endcsname
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   247
    \noexpand\expandafter
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   248
    \noexpand\spewnotes
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   249
    \noexpand\if@endpe\noexpand\@endpetrue\noexpand\fi
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   250
  }%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   251
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   252
% end of footnotehyper 2017/02/16 v0.99
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   253
% some extras for Sphinx :
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   254
% \sphinxfootnotemark: usable in section titles and silently removed from TOCs.
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   255
\def\sphinxfootnotemark [#1]%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   256
   {\ifx\thepage\relax\else\protect\spx@opt@BeforeFootnote
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   257
                             \protect\footnotemark[#1]\fi}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   258
\AtBeginDocument{%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   259
   % let hyperref less complain
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   260
   \pdfstringdefDisableCommands{\def\sphinxfootnotemark [#1]{}}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   261
   % to obtain hyperlinked footnotes in longtable environment we must replace
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   262
   % hyperref's patch of longtable's patch of \@footnotetext by our own
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   263
   \let\LT@p@ftntext\FNH@hyper@fntext
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   264
   % this *requires* longtable to be used always wrapped in savenotes environment
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   265
}%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   266
\endinput
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   267
%%
b71be85a294c Initial commit of labfolder at FHI documentation
weiher
parents:
diff changeset
   268
%% End of file `footnotehyper-sphinx.sty'.