blob: e5d6ba4b07b4c8b399477043bd1ae330729846c9 (
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
|
\ProvidesPackage{threeparttablex}[2010/02/12 v0.1 by daleif]
%%
%% This package can 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 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% The Current Maintainer of this work is Lars Madsen (daleif@imf.au.dk).
%%
\newif\ifTPTL@referable
\DeclareOption{referable}{\TPTL@referabletrue}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{threeparttable}}
\ProcessOptions\relax
\RequirePackage{threeparttable}
\RequirePackage{environ}
\newcommand\TPTL@font{}
\newcommand\setTableNoteFont[1]{\renewcommand\TPTL@font{#1}}
% length to store the longtable width in
\newlength\TPTL@width
% macro to store the optional argument for tablenotes
\def\TPTL@optarg{}
% wrapper env used to collect the tablenotes for later use
\newenvironment{TableNotes}[1][]{
\gdef\TPTL@optarg{#1}%
\Collect@Body\TPTL@collector}{}
\newcommand\TPTL@collector[1]{%
\long\gdef\TPTL@body{#1}}
% the macro used to store the tablenotes contents
\gdef\TPTL@body{}
\newcommand\insertTableNotes{%
% first we need to know the width of the longtable, remember that it
% will only settle after a few compilations
\noalign{\begingroup
\setlength\TPTL@width{0pt}
\renewcommand\LT@entry[2]{\global\advance\TPTL@width by ##2}
\@nameuse{LT@\roman{LT@tables}}
\ifdim\TPTL@width<\TPTminimum\relax\global\TPTL@width=\TPTminimum\fi
\endgroup}
% then add the table notes inside a \parbox of the required width
\multicolumn{\LT@cols}{c}{%
\makebox[0pt][c]{\parbox{\TPTL@width}{%
\let\TPT@hsize\@empty% otherwise the width is not reset
% correctly as \TPT@hsize messes with \@parboxrestore
\begin{tablenotes}[\TPTL@optarg]%
\TPTL@font%
\TPTL@body
\end{tablenotes}
}}}}
% the alternative threeparttable env, it only enables \TPToverlap
\newenvironment{ThreePartTable}{\let\TPToverlap\TPTrlap}{}
\ifTPTL@referable\else\endinput\fi
% we only come here if we need to make tablenotes referable
% define an extra \tnote command that table a label instead of a string
\DeclareRobustCommand\tnotex{\@ifstar{\TPTL@tnotex{01}}{\TPTL@tnotex{00}}}
\newcommand\TPTL@tnotex[2]{\tnote{\ref{#2}}}
% if hyperref is loaded we activate a starred version
\AtBeginDocument{%
\@ifpackageloaded{hyperref}{%
\renewcommand\TPTL@tnotex[2]{%
\if#1\relax%
\tnote{\ref{#2}}%
\else%
\tnote{\ref*{#2}}
\fi}}{}}
\newcommand\TPTL@generator[2]{%
\providecommand{#1}{}% just to make it exist
\renewcommand#1[1][#2]{%
\let\TPTL@oldmakelabel=\makelabel
\renewcommand\makelabel[1]{\TPTLnotesnamefontcommand{##1:}}
\item
\let\makelabel=\TPTL@oldmakelabel}}
\providecommand\TPTLnotename{Note}
\providecommand\TPTLsourcename{Source}
\providecommand\TPTLnotesnamefontcommand{\textit}
\let\TPTL@tablenotes=\tablenotes
% \makelabel (i.e. \item) hides its argument inside a group, making it
% difficult to set \@currentlabel, so we locally overload \item to get
% the argument and set \@currentlabel AFTER \item[...]
\renewcommand\tablenotes{%
\let\TPTL@item=\item
\renewcommand\item[1][]{\TPTL@item[##1]%
\phantomsection\protected@edef\@currentlabel{##1}}
\TPTL@generator\note{\TPTLnotename}
\TPTL@generator\source{\TPTLsourcename}
\TPTL@font\TPTL@tablenotes}
% just in case it is not already there
\providecommand\phantomsection{}
\endinput
The End
|