summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/threeparttablex/threeparttablex.tex
blob: 1d7a713b65265aaa4ff13d0493ecf77144e55ed4 (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
\documentclass[a4paper,article]{memoir}
\usepackage[T1]{fontenc}
%\usepackage[garamond]{mathdesign}

\usepackage{bera}

\setsecnumdepth{part}
\pagestyle{plain}

\usepackage{xspace,listings,xcolor}
\newcommand\pkg{\jobname\xspace}

\newcommand\tpt{threeparttable\xspace}

\definecolor{felinesrcbgcolor}{rgb}{1,1,0.85}
\definecolor{austdblue}{cmyk}{1,0.8,0,0.15}
\definecolor{nicered}{rgb}{.647,.129,.149}
\lstset{
  basicstyle=\ttfamily\footnotesize,
  columns=fixed,
  backgroundcolor=\color{felinesrcbgcolor},
  frame=single,
  extendedchars=true,
  framexleftmargin=3pt,
  numbers=none,
  numberstyle=\tiny\ttfamily,
  escapeinside={X}{X},
}

\usepackage[referable]{threeparttablex}
\usepackage{longtable}

\usepackage{hyperref}

\begin{document}

\title{A small extension to threeparttable \\ -- or bringing
  threeparttable to longtable}

\author{Lars Madsen\thanks{Email: daleif@imf.au.dk}}

\maketitle

\section{Introduction}
\label{sec:introduction}

Because of the measuring nature of the original \tpt
environment, one cannot use it in combination with the longtable
environment. This package makes up for this and brings \tpt
to longtable, at the small cost of having to do things a little
different when adding table notes to longtable.

If asked for it, the pacakge will also enable the user to label and
refer to table notes.


\section{Prerequisites}
\label{sec:prerequisites}

The \pkg package requires the \tpt and environ packages to
be available on your system.

\section{Basic usage}
\label{sec:basic-usage}

The interface for the regular \tpt system has not changed. We add the
following:
\begin{description}
\item[ThreePartTable] a very simple wrapper environment that should
  wrap around the entire longtable. (It actually does nothing else but
  enable the \cs{tnote} command).
\item[TableNotes] an environment taking the same options as the normal
  table\-notes environment, write the table notes in this environment.
  It needs to be placed \emph{before} the longtable. It \emph{cannot}
  be added inside longtable.
\item[\cs{insertTableNotes}] use this macro to insert the table notes
  inside the longtable. It is inserted via a special
  \cs{multicolumn}. If you add stuff after the table notes, e.g.\ a
  caption, you should remember to use \verb+\insertTableNotes\\+.
\end{description}

\noindent A longtable example could look like this:
\begin{lstlisting}
\begin{ThreePartTable}
  \begin{TableNotes}
    \item[a] A note
    \item[b] Another note
  \end{TableNotes}
  \begin{longtable}{l l}
    \toprule
    Column 1 & Column 2 \\
    \midrule
    \endhead
    \cmidrule{2-2}
    \multicolumn{2}{r}{\textit{continued}}
    \endfoot
    \bottomrule
    \insertTableNotes
    \endlastfoot

    % the contents of the table
    A          & B\tnote{a} \\
    C\tnote{b} & D          \\ 
  \end{longtable}
\end{ThreePartTable}
\end{lstlisting}


\section{Extending \tpt}
\label{sec:extending-tpt}

One thing missing in \tpt is the ability to refer to
individual table notes. And even let \cs{tnote} pickup the note
marker via a label (reducing the error-40 factor).

By using the package option >>\texttt{referable}<< we will change a
few \tpt internals such that
\begin{enumerate}[(a)]
\item The manually specified note markers issued by \verb+\item[...]+
  is referable, and
\item \cs{tnotex}\marg{label} will refer to the table note identified
  by \meta{label}. (We do not want to change \cs{tnote}). In case you
  are using hyperref, there is also a \cs{tnotex*} that does not make
  the tnote into a hyperlink.
\item \cs{setTableNoteFont}\marg{font commands} can be used to set the
  font inside tables notes. (default is empty)
\end{enumerate}

\section{Example}
\label{sec:example}

\begin{lstlisting}
\begin{ThreePartTable}
  \begin{TableNotes}
  \item[a] \label{tn:a} test test test test test test test test
  \item[b] \label{tn:b} test2
  \end{TableNotes}

\begin{longtable}{l l l}
  \caption{A long table}\\
  \toprule
  Coloum 1 & & Column 2 \\
  \midrule
  \endhead
  \cmidrule{3-3}
  \multicolumn{3}{r}{\textit{continued}}
  \endfoot
  \bottomrule
  \insertTableNotes\\
  \endlastfoot
  AAAA\tnotex{tn:a} & XXXXXXXX & BBBB \\
%  \newpage
  CC   &          & DD\tnotex{tn:b}   \\
\end{longtable}
\end{ThreePartTable}


\begin{center}
  \begin{threeparttable}
    \caption{A regular tabular}
    \begin{tabular}{l l l}
      \toprule
      Coloum 1 & & Column 2 \\
      \midrule
      AAAA\tnote{c} & XXXXXXXX & BBBB \\
      CC   &          & DD\tnotex*{tn:c}   \\
      \bottomrule
    \end{tabular}
    \begin{tablenotes}
      \footnotesize
    \item[c] test test test test test test test test 
    \item[d] \label{tn:c} the reference to this is not a link
    \end{tablenotes}
  \end{threeparttable}
\end{center}
\end{lstlisting}

\noindent Resulting in:

\begin{ThreePartTable}
  \begin{TableNotes}
  \item[a] \label{tn:a} test test test test test test test test
  \item[b] \label{tn:b} test2
  \end{TableNotes}

\begin{longtable}{l l l}
  \caption{A long table}\\
  \toprule
  Coloum 1 & & Column 2 \\
  \midrule
  \endhead
  \cmidrule{3-3}
  \multicolumn{3}{r}{\textit{continued}}
  \endfoot
  \bottomrule
  \insertTableNotes\\
  \endlastfoot
  AAAA\tnotex{tn:a} & XXXXXXXX & BBBB \\
%  \newpage
  CC   &          & DD\tnotex{tn:b}   \\
\end{longtable}
\end{ThreePartTable}


\begin{center}
  \begin{threeparttable}
    \caption{A regular tabular}
    \begin{tabular}{l l l}
      \toprule
      Coloum 1 & & Column 2 \\
      \midrule
      AAAA\tnote{c} & XXXXXXXX & BBBB \\
      CC   &          & DD\tnotex*{tn:c}   \\
      \bottomrule
    \end{tabular}
    \begin{tablenotes}
      \footnotesize
    \item[c] test test test test test test test test 
    \item[d] \label{tn:c} the reference to this is not a link
    \end{tablenotes}
  \end{threeparttable}
\end{center}




\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: