summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tablefootnote/tablefootnote.sty
blob: 2b4b06f36f2b9719c11de9758c66328ac6e8c022 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
%%
%% This is file `tablefootnote.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tablefootnote.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Project: tablefootnote
%% Version: 2014/01/26 v1.1c
%% 
%% Copyright (C) 2011 - 2014 by
%%     H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
%% 
%% The usual disclaimer applies:
%% If it doesn't work right that's your problem.
%% (Nevertheless, send an e-mail to the maintainer
%%  when you find an error in this package.)
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainer of this work is H.-Martin Muench.
%% 
%% This work consists of the main source file tablefootnote.dtx,
%% the README, and the derived files
%%    tablefootnote.sty, tablefootnote.pdf,
%%    tablefootnote.ins, tablefootnote.drv,
%%    tablefootnote-example.tex, tablefootnote-example.pdf.
%% 
%% In memoriam Tommy Muench + 2014/01/02.
%% 
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\ProvidesPackage{tablefootnote}[2014/01/26 v1.1c
              Table foot notes (HMM)]
%% Provides the \tablefootnote[...]{...} command
%% for footnotes in (sideways)tables.

\RequirePackage{ltxcmds}[2011/11/09]%     v1.22
\RequirePackage{letltxmacro}[2010/09/02]% v1.4
\RequirePackage{xifthen}[2009/04/17]%     v1.3
%% tablefootnote may work with earlier versions of LaTeX and those
%% packages, but this was not tested. Please consider updating
%% your LaTeX and packages to the most recent version
%% (if they are not already the most recent version).

\@ifpackageloaded{rotating}{%
  \gdef\tfn@rotating{1}
  \@ifpackagelater{rotating}{2009/03/28}% v2.16a
   {% >= 2009/03/28, OK
   }{% else
     \PackageWarningNoLine{tablefootnote}{%
       It is required version\MessageBreak%
       2009/03/28 v2.16a (or later) of package rotating,\MessageBreak%
       but only version\MessageBreak%
      `\csname ver@rotating.sty\endcsname'\MessageBreak%
      is available}%
   }%
 }{% else
   \gdef\tfn@rotating{0}%
 }

\def\tfn@footnotetablecount{0}
\def\tfn@footnotetableprint{0}
\def\tfn@footnotezero{0}
\def\tfn@fnt{0}
\def\tfn@swt{0}%       _s_ide_w_ays_t_able
\def\tfn@fmpw{\relax}% f_oot_m_isc_p_ara_w_arn-switch
\def\tfn@fnbr{0}%      f_oot_n_ote_b_ack_r_ef(erence package)

\DeclareRobustCommand{\tfn@hyperfootnotes}[2]{%
  \ifHy@hyperfootnotes%
    #1%
  \else%
    #2%
  \fi%
  }

\ltx@ifpackageloaded{footnotebackref}{%
  \gdef\tfn@fnbr{1}%
  \ifx\FootnoteBackref@symbol\empty%
    \ifFootnoteBackref@numberlinked%
      \newcommand\tablemakefntext[1]{%
        \noindent\makebox[1.634em][r]{%
         \mbox{\textsuperscript{\normalfont%
           \hyperlink{tfn:m\theHfootnote}{\@thefnmark}%
        }}}%
        \ #1%
      }
    \else
      \newcommand\tablemakefntext[1]{%
        \noindent\makebox[1.8em][r]{%
          \mbox{\textsuperscript{\normalfont%
            \@thefnmark%
        }}}%
        #1%
      }
    \fi
  \else
    \newcommand\tablemakefntext[1]{%
      \noindent\makebox[1.8em][r]{%
        \mbox{\textsuperscript{\normalfont%
          \ifFootnoteBackref@numberlinked%
            \hyperlink{tfn:m\theHfootnote}{\@thefnmark}\ %
          \else%
            \@thefnmark%
          \fi%
      }}}%
      \hyperlink{tfn:m\theHfootnote}{\FootnoteBackref@symbol}%
      #1%
    }
  \fi
}{%
  \newcommand\tablemakefntext[1]{%
    \noindent\makebox[1.8em][r]{%
      \mbox{\textsuperscript{\normalfont%
        \@thefnmark%
    }}}%
    #1%
  }
}

\newcommand\swtablemakefntext[1]{\noindent\ #1}

\newcommand{\tfn@footnotemarks}[1][]{%
  \hbox{%
    \ifthenelse{\isempty{#1}}%
      {\footnotemark%
       \ltx@ifpackageloaded{footnotebackref}%
         {\raisebox{\ht\strutbox}{\hypertarget{tfn:m\theHfootnote}{}}}%
         {% footnotebackref not loaded
         }%
      }%
      {\ltx@ifpackageloaded{hyperref}%
        {\tfn@hyperfootnotes{%
            \hyperlink{tfn:#1}{\footnotemark[#1]}%
          }{\footnotemark[#1]}}%
        {\footnotemark[#1]}%
       \ltx@ifpackageloaded{footnotebackref}%
        {\raisebox{\ht\strutbox}{\hypertarget{tfn:m#1}{}}}{}%
      }%
   }%
  \@tempcnta=\tfn@footnotetablecount\relax%
  \advance\@tempcnta by -1\relax%
  \xdef\tfn@footnotetablecount{\the\@tempcnta}%
}

\newcommand{\tfn@footmiscparawarn}{%
  \ifFN@para%
    \PackageWarning{tablefootnote}{%
      Package footmisc with option para used.\MessageBreak%
      Unfortunately package tablefootnote is not yet\MessageBreak%
      able to regard this in sidewaystables.\MessageBreak%
      Here the footnotes are printed one below\MessageBreak%
      the other. Sorry!\MessageBreak%
     }%
  \fi%
  }

\newcommand{\tfn@updateHyper}{%
  % The code of this command is partly from the
  % hyperref package by Heiko Oberdiek, 2011/10/01, v6.82j.
  % Newer versions of that package are available at CTAN.org.
  \global\let\Hy@saved@currentHref\@currentHref%
  \tfn@hyperfootnotes{\hyper@makecurrent{Hfootnote}}{}%
  \global\let\Hy@footnote@currentHref\@currentHref%
  \global\let\@currentHref\Hy@saved@currentHref%
  }

\newcommand{\tfn@footnotetext}[2][]{%
  \ifx\tfn@footnotetableprint\tfn@footnotezero%
    % This is the first footnotetext after the (sideways)table.
    \addtocounter{footnote}{\tfn@footnotetablecount}%
    \ltx@ifpackageloaded{hyperref}{%
      \tfn@hyperfootnotes{%
        \addtocounter{Hfootnote}{\tfn@footnotetablecount}}{}%
      \tfn@updateHyper%
     }{}%
  \fi%
  \addtocounter{footnote}{+1}%
  \ltx@ifpackageloaded{hyperref}{%
    \tfn@hyperfootnotes{\addtocounter{Hfootnote}{+1}}{}%
    \tfn@updateHyper%
   }{}%
  \ifx\tfn@swt\tfn@footnotezero%
    \ifthenelse{\isempty{#1}}%
      {\footnotetext{#2}}%
      {\ltx@ifpackageloaded{hyperref}%
         {\tfn@hyperfootnotes{%
             \footnotetext[#1]{%
               \raisebox{\ht\strutbox}{\hypertarget{tfn:#1}{}}#2}%
           }{\footnotetext[#1]{#2}%
           }%
         }{\footnotetext[#1]{#2}}%
      }%
  \else%
    \ifx\tfn@footnotetableprint\tfn@footnotezero%
      \gdef\tfn@fmpw{\tfn@footmiscparawarn}%
    \else%
      \ltx@ifpackageloaded{footmisc}{\tfn@fmpw}{\relax}%
      \gdef\tfn@fmpw{\relax}%
    \fi%
    \ltx@ifpackageloaded{footnotebackref}{%
      \LetLtxMacro{\tfncurrentmft}{\@makefntext}%
      \LetLtxMacro{\@makefntext}{\swtablemakefntext}%
      \ifthenelse{\isempty{#1}}%
        {\footnotetext{%
           \raisebox{\ht\strutbox}{\hypertarget{tfn:\theHfootnote}{}}%
           \hbox{\@textsuperscript{\normalfont%
              \hyperlink{tfn:m\theHfootnote}{\thefootnote}}}\thinspace%
         \ifx\FootnoteBackref@symbol\empty%
         \else\hyperlink{tfn:m\theHfootnote}{\FootnoteBackref@symbol}%
         \fi%
         #2}%
       }{\edef\tfn@tfn{\arabic{footnote}}%
         \edef\tfn@thn{\arabic{Hfootnote}}%
         \setcounter{footnote}{#1}%
         \setcounter{Hfootnote}{#1}%
         \tfn@updateHyper%
         \footnotetext{%
           \raisebox{\ht\strutbox}{\hypertarget{tfn:#1}{}}%
           \hbox{\@textsuperscript{\normalfont%
                  \hyperlink{tfn:m#1}{#1}}}%
           \thinspace%
           \ifx\FootnoteBackref@symbol\empty%
           \else%
             \raisebox{\ht\strutbox}{%
               \hyperlink{tfn:m#1}{\FootnoteBackref@symbol}}%
           \fi%
           #2%
          }%
         \setcounter{footnote}{\tfn@tfn}%
         \setcounter{Hfootnote}{\tfn@thn}%
         \tfn@updateHyper%
       }%
      \LetLtxMacro{\@makefntext}{\tfncurrentmft}%
     }{% footnotebackref not loaded
       \ifthenelse{\isempty{#1}}%
         {\footnotetext{%
            \hbox{\@textsuperscript{\normalfont\thefootnote}}%
            \ltx@ifpackageloaded{hyperref}%
              {\tfn@hyperfootnotes{%
                 \raisebox{\ht\strutbox}{%
                   \hypertarget{tfn:\theHfootnote}{}}}{}%
              }{}%
            \thinspace%
            #2}%
        }{%
          \edef\tfn@tfn{\arabic{footnote}}%
          \ltx@ifpackageloaded{hyperref}{%
            \tfn@hyperfootnotes{\xdef\tfn@thn{\arabic{Hfootnote}}}{}%
           }{}%
          \setcounter{footnote}{#1}
          \ltx@ifpackageloaded{hyperref}{%
            \tfn@hyperfootnotes{\setcounter{Hfootnote}{#1}}{}%
            \tfn@updateHyper%
           }{}%
          \footnotetext{%
            \hbox{\@textsuperscript{\normalfont #1}}%
            \ltx@ifpackageloaded{hyperref}{%
              \tfn@hyperfootnotes{\raisebox{\ht\strutbox}{%
                                         \hypertarget{tfn:#1}{}}}{}%
             }{}%
            \thinspace%
            #2}%
          \setcounter{footnote}{\tfn@tfn}%
          \ltx@ifpackageloaded{hyperref}{%
            \tfn@hyperfootnotes{\setcounter{Hfootnote}{\tfn@thn}}{}%
            \tfn@updateHyper%
           }{}%
        }%
     }%
  \fi%
  \gdef\tfn@footnotetableprint{1}%
  \@tempcnta=\tfn@footnotetablecount\relax%
  \advance\@tempcnta by +1\relax%
  \xdef\tfn@footnotetablecount{\the\@tempcnta}%
  \ifx\tfn@footnotetablecount\tfn@footnotezero% all footnotes placed
    \gdef\tfn@footnotetableprint{0}%
    \global\let\tfn@tablefootnoteprintout\relax% brute force
 %\else there is at least one \footnotemark which needs \footnotetext
  \fi
}

\newcommand{\tfn@tablefootnoteprintout}{\relax}

\newcommand{\tablefootnote}[2][]{%
  \tfn@footnotemarks[#1]%
  \ifthenelse{\isempty{#1}}{\relax}{%
    \ltx@GlobalPrependToMacro{\tfn@tablefootnoteprintout}{%
      \addtocounter{footnote}{+1}%
      \ltx@ifpackageloaded{hyperref}{%
        \tfn@hyperfootnotes{\addtocounter{Hfootnote}{+1}}{}%
        \tfn@updateHyper%
       }{}%
     }%
   }%
  \ltx@GlobalAppendToMacro{\tfn@tablefootnoteprintout}{%
    \tfn@footnotetext[#1]{#2}%
    \ifthenelse{\isempty{#1}}{\relax}{%
      \addtocounter{footnote}{-1}%
      \ltx@ifpackageloaded{hyperref}{%
        \tfn@hyperfootnotes{\addtocounter{Hfootnote}{-1}}{}%
        \tfn@updateHyper%
       }{}%
     }%
   }%
  \gdef\tfn@fnt{1}%
  }

\newcommand{\tfn@swtbox}{%
\ifvoid \footins%
\vskip 2\baselineskip%
\else%
\vskip \skip\footins%
\fi%
\parbox[b][][t]{\linewidth}{\raggedright\tfn@tablefootnoteprintout}%
}

\IfFileExists{etoolbox.sty}{%
  \RequirePackage{etoolbox}[2011/01/03]%   v2.1
  \AfterEndEnvironment{table}{%
    \ltx@ifpackageloaded{footnotebackref}{%
      \LetLtxMacro{\tfncurrentmft}{\@makefntext}%
      \LetLtxMacro{\@makefntext}{\tablemakefntext}%
       \tfn@tablefootnoteprintout%
      \LetLtxMacro{\@makefntext}{\tfncurrentmft}%
     }{% footnotebackref not loaded
      \tfn@tablefootnoteprintout%
     }%
      \gdef\tfn@fnt{0}%
   }%
  \ltx@ifpackageloaded{rotating}{%
    \AtBeginEnvironment{sidewaystable}{%
      \gdef\tfn@swt{1}%
    }
    \AtEndEnvironment{sidewaystable}{%
      \ifx\tfn@fnt\tfn@footnotezero% \relax
      \else%
        \ltx@ifpackageloaded{footnotebackref}{%
          \LetLtxMacro{\tfncurrentmft}{\@makefntext}%
          \LetLtxMacro{\@makefntext}{\tablemakefntext}%
           \tfn@swtbox%
          \LetLtxMacro{\@makefntext}{\tfncurrentmft}%
         }{% footnotebackref not loaded
          \tfn@swtbox%
          }%
      \fi%
      \gdef\tfn@swt{0}%
      \gdef\tfn@fnt{0}%
     }%
   }{}% else \relax
}{%
  \PackageWarning{tablefootnote}{%
    Package etoolbox not available, therefore\MessageBreak%
    substituting commands \string\AtEndEnvironment\space %
    and\MessageBreak%
    \string\AfterEndEnvironment\space for tablefootnotes%
    \MessageBreak%
   }%
  \@ifpackagelater{letltxmacro}{2010/09/02}%
   {% >= 2010/09/02, OK
    \GlobalLetLtxMacro{\tfnorigtable}{\table}
    \GlobalLetLtxMacro{\tfnendorigtable}{\endtable}
   }{% else
     \PackageError{tablefootnote}{%
       Outdated version of letltxmacro package used%
      }{Version 2010/09/02 v1.4 or newer needed but not found!%
        \MessageBreak%
        Update the used letltxmacro package.}
        \LetLtxMacro{\tfnorigtable}{\table}
        \LetLtxMacro{\tfnendorigtable}{\endtable}
    }%
  \ltx@ifpackageloaded{float}{%
    \@ifpackagelater{float}{2001/11/08}%   v1.3d
     {% >= 2001/11/08, OK
     }{% else
       \PackageWarningNoLine{tablefootnote}{%
         It is required version\MessageBreak
         2001/11/08 v1.3d (or later) of package float,\MessageBreak
         but only version\MessageBreak
        `\csname ver@float.sty\endcsname'\MessageBreak
        is available}%
     }%
   }{\relax}
  \renewenvironment{table}{%
    \ltx@ifpackageloaded{float}{%
      \ltx@LocalAppendToMacro{\float@endH}{%
        \ltx@ifpackageloaded{footnotebackref}{%
          \LetLtxMacro{\tfncurrentmft}{\@makefntext}%
          \LetLtxMacro{\@makefntext}{\tablemakefntext}%
           \tfn@tablefootnoteprintout%
          \LetLtxMacro{\@makefntext}{\tfncurrentmft}%
         }{% footnotebackref not loaded
          \tfn@tablefootnoteprintout%
         }%
          \gdef\tfn@fnt{0}%
       }%
     }{\relax}
    \tfnorigtable%
   }{%
     \tfnendorigtable%
     \ltx@ifpackageloaded{footnotebackref}{%
       \LetLtxMacro{\tfncurrentmft}{\@makefntext}%
       \LetLtxMacro{\@makefntext}{\tablemakefntext}%
        \tfn@tablefootnoteprintout%
       \LetLtxMacro{\@makefntext}{\tfncurrentmft}%
      }{% footnotebackref not loaded
       \tfn@tablefootnoteprintout%
      }%
     \gdef\tfn@fnt{0}%
    }%
  \ltx@ifpackageloaded{rotating}{%
    \let\tfnorigsidewaystable\sidewaystable
    \let\tfnendorigsidewaystable\endsidewaystable
    \renewenvironment{sidewaystable}{%
      \gdef\tfn@swt{1}%
      \tfnorigsidewaystable%
    }{%
      \ifx\tfn@fnt\tfn@footnotezero% \relax
      \else%
        \ltx@ifpackageloaded{footnotebackref}{%
          \LetLtxMacro{\tfncurrentmft}{\@makefntext}%
          \LetLtxMacro{\@makefntext}{\tablemakefntext}%
           \tfn@swtbox%
          \LetLtxMacro{\@makefntext}{\tfncurrentmft}%
         }{% footnotebackref not loaded
          \tfn@swtbox%
         }%
      \fi%
      \gdef\tfn@swt{0}%
      \gdef\tfn@fnt{0}%
      \tfnendorigsidewaystable%
     }%
   }{}%
}

\AtBeginDocument{%
  \ltx@ifpackageloaded{footnotebackref}{%
    \ifx\tfn@fnbr\tfn@footnotezero%
      \PackageError{tablefootnote}{%
        Package footnotebackref loaded after tablefootnote}{%
        When using both the footnotebackref and the tablefootnote %
        package,\MessageBreak%
        the footnotebackref package MUST be loaded before the %
        tablefootnote package!\MessageBreak%
       }%
    \fi%
   }{% else \relax
   }
  \ltx@ifpackageloaded{rotating}{%
    \ifx\tfn@rotating\tfn@footnotezero%
      \PackageError{tablefootnote}{%
        Package rotating loaded after tablefootnote}{%
        When using both the rotating and the tablefootnote package,%
        \MessageBreak%
        the rotating package MUST be loaded before the tablefootnote%
        \space package!\MessageBreak%
       }%
    \fi%
   }{% else \relax
   }
  \ltx@ifpackageloaded{hyperref}{%
    \tfn@hyperfootnotes{
      \ifluatex%
        \PackageWarningNoLine{tablefootnote}{%
          LuaTeX and hyperref package used:\MessageBreak%
          Hyperreferences in rotated content\MessageBreak%
          will be misplaced\MessageBreak%
          regardless of tablefootnote package.\MessageBreak%
          The text to be printed will be OK%
         }%
      \fi%
     }{% else \relax
     }%
   }{% else \relax
   }%
  \ltx@ifpackageloaded{footnotebackref}{%
     \ltx@ifpackageloaded{hyperref}{%
        \tfn@hyperfootnotes{\relax}{% else
          \PackageError{tablefootnote}{%
             footnotebackref but not hyperfootnotes}{%
             The footnotebackref package is used\MessageBreak%
             but the hyperfootnotes option of the hyperref package%
             \MessageBreak%
             was set to false.\MessageBreak%
             Either enable hyperfootnotes or do not use footnotebackref.%
             \MessageBreak%
             Loading of the tablefootnote package will be aborted.%
           }%
          \endinput%
      }%
    }{\PackageError{tablefootnote}{footnotebackref but not hyperref}{%
        The footnotebackref package is used\MessageBreak%
        but not the hyperref package.\MessageBreak%
        Either load hyperref or do not use footnotebackref.%
        \MessageBreak%
        Loading of the tablefootnote package will be aborted.%
        }%
      \endinput%
    }%
  }{}
}

\endinput
%%
%% End of file `tablefootnote.sty'.