| 1 |
\documentclass[a4paper,article]{memoir} |
| 2 |
\usepackage[T1]{fontenc} |
| 3 |
%\usepackage[garamond]{mathdesign} |
| 4 |
|
| 5 |
\usepackage{bera} |
| 6 |
|
| 7 |
\setsecnumdepth{part} |
| 8 |
\pagestyle{plain} |
| 9 |
|
| 10 |
\usepackage{xspace,listings,xcolor} |
| 11 |
\newcommand\pkg{\jobname\xspace} |
| 12 |
|
| 13 |
\newcommand\env[1]{\texttt{#1}} |
| 14 |
|
| 15 |
\newcommand\tpt{threeparttable\xspace} |
| 16 |
|
| 17 |
\definecolor{felinesrcbgcolor}{rgb}{1,1,0.85} |
| 18 |
\definecolor{austdblue}{cmyk}{1,0.8,0,0.15} |
| 19 |
\definecolor{nicered}{rgb}{.647,.129,.149} |
| 20 |
\lstset{ |
| 21 |
basicstyle=\ttfamily\footnotesize, |
| 22 |
columns=fixed, |
| 23 |
backgroundcolor=\color{felinesrcbgcolor}, |
| 24 |
frame=single, |
| 25 |
extendedchars=true, |
| 26 |
framexleftmargin=3pt, |
| 27 |
numbers=none, |
| 28 |
numberstyle=\tiny\ttfamily, |
| 29 |
escapeinside={X}{X}, |
| 30 |
} |
| 31 |
|
| 32 |
\usepackage[referable]{threeparttablex} |
| 33 |
\usepackage{longtable} |
| 34 |
|
| 35 |
\usepackage{hyperref} |
| 36 |
|
| 37 |
\begin{document} |
| 38 |
|
| 39 |
\title{A small extension to threeparttable \\ -- or bringing |
| 40 |
threeparttable to longtable} |
| 41 |
|
| 42 |
\author{Lars Madsen\thanks{Email: [email protected]}} |
| 43 |
|
| 44 |
\date{Corresponding to version 0.3, manual updated \today} |
| 45 |
|
| 46 |
\maketitle |
| 47 |
|
| 48 |
\section{Introduction} |
| 49 |
\label{sec:introduction} |
| 50 |
|
| 51 |
Because of the measuring nature of the original \tpt |
| 52 |
environment, one cannot use it in combination with the longtable |
| 53 |
environment. This package makes up for this and brings \tpt |
| 54 |
to longtable, at the small cost of having to do things a little |
| 55 |
different when adding table notes to longtable. |
| 56 |
|
| 57 |
If asked for it, the pacakge will also enable the user to label and |
| 58 |
refer to table notes. |
| 59 |
|
| 60 |
|
| 61 |
\section{Prerequisites} |
| 62 |
\label{sec:prerequisites} |
| 63 |
|
| 64 |
The \pkg package requires the \tpt and environ packages to |
| 65 |
be available on your system. |
| 66 |
|
| 67 |
\section{Basic usage} |
| 68 |
\label{sec:basic-usage} |
| 69 |
|
| 70 |
The interface for the regular \tpt system has not changed. We add the |
| 71 |
following: |
| 72 |
\begin{description} |
| 73 |
\item[ThreePartTable] a very simple wrapper environment that should |
| 74 |
wrap around the entire longtable. (It actually does nothing else but |
| 75 |
enable the \cs{tnote} command). |
| 76 |
\item[TableNotes] an environment taking the same options as the normal |
| 77 |
table\-notes environment, write the table notes in this environment. |
| 78 |
It needs to be placed \emph{before} the longtable. It \emph{cannot} |
| 79 |
be added inside longtable. |
| 80 |
\item[\cs{insertTableNotes}] use this macro to insert the table notes |
| 81 |
inside the longtable. It is inserted via a special |
| 82 |
\cs{multicolumn}. If you add stuff after the table notes, e.g.\ a |
| 83 |
caption, you should remember to use \verb+\insertTableNotes\\+. |
| 84 |
\end{description} |
| 85 |
|
| 86 |
\noindent A longtable example could look like this: |
| 87 |
\begin{lstlisting} |
| 88 |
\begin{ThreePartTable} |
| 89 |
\begin{TableNotes} |
| 90 |
\item[a] A note |
| 91 |
\item[b] Another note |
| 92 |
\end{TableNotes} |
| 93 |
\begin{longtable}{l l} |
| 94 |
\toprule |
| 95 |
Column 1 & Column 2 \\ |
| 96 |
\midrule |
| 97 |
\endhead |
| 98 |
\cmidrule{2-2} |
| 99 |
\multicolumn{2}{r}{\textit{continued}} |
| 100 |
\endfoot |
| 101 |
\bottomrule |
| 102 |
\insertTableNotes |
| 103 |
\endlastfoot |
| 104 |
|
| 105 |
% the contents of the table |
| 106 |
A & B\tnote{a} \\ |
| 107 |
C\tnote{b} & D \\ |
| 108 |
\end{longtable} |
| 109 |
\end{ThreePartTable} |
| 110 |
\end{lstlisting} |
| 111 |
|
| 112 |
\paragraph{Caveat:} As mentioned on |
| 113 |
\url{http://tex.stackexchange.com/q/149032/3929}, if you use \cs{fill} |
| 114 |
to spread out the columns in the table, the width \env{longtable} |
| 115 |
reports back (which we use to specify the width of the notes) will be |
| 116 |
wrong. It will be the natural width of the table not the actual |
| 117 |
width. The result is that the area for the notes will have the wrong |
| 118 |
width. A remedy is to tell it to use the full width, something similar |
| 119 |
to |
| 120 |
\begin{lstlisting} |
| 121 |
\begin{ThreePartTable} |
| 122 |
\renewcommand\TPTminimum{\textwidth} %%% we want full width |
| 123 |
... |
| 124 |
\end{lstlisting} |
| 125 |
will do. |
| 126 |
|
| 127 |
|
| 128 |
\section{Extending \tpt} |
| 129 |
\label{sec:extending-tpt} |
| 130 |
|
| 131 |
One thing missing in \tpt is the ability to refer to |
| 132 |
individual table notes. And even let \cs{tnote} pickup the note |
| 133 |
marker via a label (reducing the error-40 factor). |
| 134 |
|
| 135 |
By using the package option >>\texttt{referable}<< we will change a |
| 136 |
few \tpt internals such that |
| 137 |
\begin{enumerate}[(a)] |
| 138 |
\item The manually specified note markers issued by \verb+\item[...]+ |
| 139 |
is referable, and |
| 140 |
\item \cs{tnotex}\marg{label} will refer to the table note identified |
| 141 |
by \meta{label}. (We do not want to change \cs{tnote}). In case you |
| 142 |
are using hyperref, there is also a \cs{tnotex*} that does not make |
| 143 |
the tnote into a hyperlink. |
| 144 |
\item \cs{setTableNoteFont}\marg{font commands} can be used to set the |
| 145 |
font inside tables notes. (default is empty) |
| 146 |
\item inside the \emph{tablenotes} environment, the macros \cs{note} |
| 147 |
and \cs{source} can be used to specify general notes and a source |
| 148 |
reference for the table data. These are commonly used within the |
| 149 |
examples in The Chicago Manual of Style. |
| 150 |
\item The macros \cs{TPTLnotename} \cs{TPTLsourcename} holds the title |
| 151 |
names for \cs{note} and \cs{source} (default: >>Note<< and |
| 152 |
>>Source<<). Both are typeset using \cs{TPTLnotesnamefontcommand} |
| 153 |
which deaults to \cs{textit}. |
| 154 |
\end{enumerate} |
| 155 |
|
| 156 |
\section{Example} |
| 157 |
\label{sec:example} |
| 158 |
|
| 159 |
\begin{lstlisting} |
| 160 |
\begin{ThreePartTable} |
| 161 |
\begin{TableNotes} |
| 162 |
\item[a] \label{tn:a} test test test test test test test test |
| 163 |
\item[b] \label{tn:b} test2 |
| 164 |
\source Made up by daleif |
| 165 |
\end{TableNotes} |
| 166 |
|
| 167 |
\begin{longtable}{l l l} |
| 168 |
\caption{A long table}\\ |
| 169 |
\toprule |
| 170 |
Coloum 1 & & Column 2 \\ |
| 171 |
\midrule |
| 172 |
\endhead |
| 173 |
\cmidrule{3-3} |
| 174 |
\multicolumn{3}{r}{\textit{continued}} |
| 175 |
\endfoot |
| 176 |
\bottomrule |
| 177 |
\insertTableNotes\\ |
| 178 |
\endlastfoot |
| 179 |
AAAA\tnotex{tn:a} & XXXXXXXX & BBBB \\ |
| 180 |
% \newpage |
| 181 |
CC & & DD\tnotex{tn:b} \\ |
| 182 |
\end{longtable} |
| 183 |
\end{ThreePartTable} |
| 184 |
|
| 185 |
|
| 186 |
\begin{center} |
| 187 |
\begin{threeparttable} |
| 188 |
\caption{A regular tabular} |
| 189 |
\begin{tabular}{l l l} |
| 190 |
\toprule |
| 191 |
Coloum 1 & & Column 2 \\ |
| 192 |
\midrule |
| 193 |
AAAA\tnote{c} & XXXXXXXX & BBBB \\ |
| 194 |
CC & & DD\tnotex*{tn:c} \\ |
| 195 |
\bottomrule |
| 196 |
\end{tabular} |
| 197 |
\begin{tablenotes} |
| 198 |
\footnotesize |
| 199 |
\item[c] test test test test test test test test |
| 200 |
\item[d] \label{tn:c} the reference to this is not a link |
| 201 |
\note Some general note |
| 202 |
\end{tablenotes} |
| 203 |
\end{threeparttable} |
| 204 |
\end{center} |
| 205 |
\end{lstlisting} |
| 206 |
|
| 207 |
\newpage |
| 208 |
|
| 209 |
\noindent Resulting in: |
| 210 |
|
| 211 |
\begin{ThreePartTable} |
| 212 |
\begin{TableNotes} |
| 213 |
\item[a] \label{tn:a} test test test test test test test test |
| 214 |
\item[b] \label{tn:b} test2 |
| 215 |
\source Made up by daleif |
| 216 |
\end{TableNotes} |
| 217 |
|
| 218 |
\begin{longtable}{l l l} |
| 219 |
\caption{A long table}\\ |
| 220 |
\toprule |
| 221 |
Coloum 1 & & Column 2 \\ |
| 222 |
\midrule |
| 223 |
\endhead |
| 224 |
\cmidrule{3-3} |
| 225 |
\multicolumn{3}{r}{\textit{continued}} |
| 226 |
\endfoot |
| 227 |
\bottomrule |
| 228 |
\insertTableNotes\\ |
| 229 |
\endlastfoot |
| 230 |
AAAA\tnotex{tn:a} & XXXXXXXX & BBBB \\ |
| 231 |
% \newpage |
| 232 |
CC & & DD\tnotex{tn:b} \\ |
| 233 |
\end{longtable} |
| 234 |
\end{ThreePartTable} |
| 235 |
|
| 236 |
|
| 237 |
\begin{center} |
| 238 |
\begin{threeparttable} |
| 239 |
\caption{A regular tabular} |
| 240 |
\begin{tabular}{l l l} |
| 241 |
\toprule |
| 242 |
Coloum 1 & & Column 2 \\ |
| 243 |
\midrule |
| 244 |
AAAA\tnote{c} & XXXXXXXX & BBBB \\ |
| 245 |
CC & & DD\tnotex*{tn:c} \\ |
| 246 |
\bottomrule |
| 247 |
\end{tabular} |
| 248 |
\begin{tablenotes} |
| 249 |
\footnotesize |
| 250 |
\item[c] test test test test test test test test |
| 251 |
\item[d] \label{tn:c} the reference to this is not a link |
| 252 |
\note Some general note |
| 253 |
\end{tablenotes} |
| 254 |
\end{threeparttable} |
| 255 |
\end{center} |
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
\end{document} |
| 261 |
|
| 262 |
%%% Local Variables: |
| 263 |
%%% mode: latex |
| 264 |
%%% TeX-master: t |
| 265 |
%%% End: |