summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tablefootnote/tablefootnote.sty
blob: 470650c6c2c01da16bd74e5905580445d0886266 (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
%%
%% 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: 2011/11/06 v1.0c
%% 
%% Copyright (C) 2011 by
%%     H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
%% 
%% The usual disclaimer applys:
%% 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.
%% 
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\ProvidesPackage{tablefootnote}[2011/11/06 v1.0c
              Table foot notes (HMM)]

%% Provides the \tablefootnoteote{...} command
%% for footnotes in (sideways)tables.

\RequirePackage{ltxcmds}[2011/04/18]%      v1.20

\@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}%
   }%
  \RequirePackage{amstext}[2000/06/29]%    v2.01
  \RequirePackage{setspace}[2000/12/01]%   v6.7
  \RequirePackage{subcaption}[2011/09/12]% v1.1b
 }{% else
  \gdef\tfn@rotating{0}%
 }

%% 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).

\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

\newcommand{\tfn@footnotemarks}{%
  \footnotemark%
  \count255=\tfn@footnotetablecount \relax%
  \count255=\numexpr \count255 - 1 \relax%
  \xdef\tfn@footnotetablecount{\the\count255}%
}

\newcommand{\tfn@footnotetext}[1]{%
  \ifx\tfn@footnotetableprint\tfn@footnotezero%
    % This is the first footnotetext after the (sideways)table.
    \addtocounter{footnote}{\tfn@footnotetablecount}%
    \ltx@ifpackageloaded{hyperref}{%
      \addtocounter{Hfootnote}{\tfn@footnotetablecount}%
     }{}%
    \gdef\tfn@footnotetableprint{1}%
  \fi%
  \addtocounter{footnote}{+1}%
  \ltx@ifpackageloaded{hyperref}{%
    \addtocounter{Hfootnote}{+1}%
    % Code form the hyperref package, 2011/10/01, v6.82j,
    % by Heiko Oberdiek
    \global\let\Hy@saved@currentHref\@currentHref%
    \hyper@makecurrent{Hfootnote}%
    \global\let\Hy@footnote@currentHref\@currentHref%
    \global\let\@currentHref\Hy@saved@currentHref%
    % End of code form the hyperref package
   }{}%
  \ifx\tfn@swt\tfn@footnotezero%
    \footnotetext{#1}%
  \else%
    \footnotetext{${}^{\text{\textup{\thefootnote}}}$\thinspace #1}%
  \fi%
  \count255=\tfn@footnotetablecount \relax%
  \count255=\numexpr \count255 + 1 \relax%
  \xdef\tfn@footnotetablecount{\the\count255}%
  \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}[1]{%
\tfn@footnotemarks%
\ltx@GlobalAppendToMacro{%
\tfn@tablefootnoteprintout}{\tfn@footnotetext{#1}}%
\gdef\tfn@fnt{1}%
}

\newcommand{\tfn@swtbox}{%
\vspace{0.8cm}%
\begin{spacing}{0.1}%
\subcaptionbox*{}[\linewidth][l]{\tfn@tablefootnoteprintout}%
\end{spacing}%
}

\IfFileExists{etoolbox.sty}{%
  \RequirePackage{etoolbox}[2011/01/03]%   v2.1
  \AfterEndEnvironment{table}{%
    \tfn@tablefootnoteprintout%
    \gdef\tfn@fnt{0}%
   }
  \ltx@ifpackageloaded{rotating}{%
    \AtBeginEnvironment{sidewaystable}{%
      \gdef\tfn@swt{1}%
    }
    \AtEndEnvironment{sidewaystable}{%
      \ifx\tfn@fnt\tfn@footnotezero% \relax
      \else%
        \tfn@swtbox%
      \fi%
      \gdef\tfn@swt{0}%
      \gdef\tfn@fnt{0}%
     }%
   }{}%
}{%
  \PackageWarning{tablefootnote}{%
    Package etoolbox not available, therefore\MessageBreak%
    substituting commands \string\AtEndEnvironment\space %
    and\MessageBreak%
    \string\AfterEndEnvironment\space for tablefootnotes%
    \MessageBreak%
   }%
  \RequirePackage{letltxmacro}[2010/09/02]% v1.4
  \@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}{%
        \tfn@tablefootnoteprintout%
        \gdef\tfn@fnt{0}%
       }%
     }{\relax}
    \tfnorigtable%
   }{%
     \tfnendorigtable%
     \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%
        \tfn@swtbox%
      \fi%
      \gdef\tfn@swt{0}%
      \gdef\tfn@fnt{0}%
      \tfnendorigsidewaystable%
     }%
   }{}%
}

\AtBeginDocument{%
  \ltx@ifpackageloaded{rotating}{%
    \ifx\tfn@rotating\tfn@footnotezero%
      \PackageError{tablefootnote}{%
        Package rotating loaded after package tablefootnote}{%
        When using both the rotating and the tablefootnote package,%
        \MessageBreak%
        the rotating package must be loaded before the tablefootnote%
        package!%
       }%
    \fi%
   }{}
  }

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