| 1 |
% |
| 2 |
% topiclongtable v1.3.2 - Renders autocollapsing cells in longtables |
| 3 |
% |
| 4 |
% Copyright (c) 2017-2020 Paolo Brasolin (<[email protected]>) |
| 5 |
% |
| 6 |
% This work is sponsored by Human Predictions, LLC (<http://www.humanpredictions.com>). |
| 7 |
% This work is maintained by Paolo Brasolin (<[email protected]>). |
| 8 |
% This work is available under the terms of the MIT License. |
| 9 |
% |
| 10 |
|
| 11 |
\documentclass[full,kernel]{l3doc} |
| 12 |
|
| 13 |
\usepackage{topiclongtable} |
| 14 |
|
| 15 |
\begin{document} |
| 16 |
|
| 17 |
\title{% |
| 18 |
The \pkg{topiclongtable} package% |
| 19 |
\thanks{Development of this package was sponsored by Human Predictions, |
| 20 |
LLC (\href{http://www.humanpredictions.com}{www.humanpredictions.com}).}\\ |
| 21 |
Autocollapsing cells in longtables |
| 22 |
} |
| 23 |
|
| 24 |
\author{ |
| 25 |
Paolo Brasolin\\ |
| 26 |
\href{mailto:[email protected]}{[email protected]} |
| 27 |
} |
| 28 |
|
| 29 |
\date{2020/04/12 v1.3.2} |
| 30 |
|
| 31 |
\maketitle |
| 32 |
|
| 33 |
\begin{documentation} |
| 34 |
|
| 35 |
|
| 36 |
This \LaTeX\ package extends \env{longtable}s implementing |
| 37 |
\env{topiclongtable}s, in which vertically adjacent cells merge if |
| 38 |
and only if they have the same content and the cells on their left |
| 39 |
are merged. Furthermore the merging is well behaved, in that it |
| 40 |
does not happen after page breaks and correct separation lines are |
| 41 |
drawn automatically. |
| 42 |
|
| 43 |
The typical use case is a table that spans multiple pages and |
| 44 |
contains a list of hierarchically organized topics (hence the package |
| 45 |
name). |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
\section*{Usage} |
| 51 |
|
| 52 |
To use the package install it in your tree (or put \file{topiclongtable.sty} in your work folder) and require it in your preamble: |
| 53 |
|
| 54 |
\begin{verbatim} |
| 55 |
\usepackage{topiclongtable} |
| 56 |
\end{verbatim} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
\subsection*{Environment} |
| 62 |
|
| 63 |
\begin{function}[updated=2019-07-08]{topiclongtable} |
| 64 |
\begin{syntax} |
| 65 |
\tn[no-index]{begin}\{\env{topiclongtable}\}\marg{column specification} |
| 66 |
\ \ \meta{cells specification} |
| 67 |
\tn[no-index]{end}\{\env{topiclongtable}\} |
| 68 |
\end{syntax} |
| 69 |
The \env{topiclongtable} environment extends \env{longtable}. |
| 70 |
They share the same syntax and all features of the latter are |
| 71 |
available in the former. |
| 72 |
|
| 73 |
To use \pkg{topiclongtable} macros you must \emph{prepend} \enquote{\texttt{F}} |
| 74 |
to the first column specification and \enquote{\texttt{T}} to all others: |
| 75 |
\begin{verbatim} |
| 76 |
\begin{topiclongtable}{|Fl|Tl|Tl|Tr|Tl|Tr} |
| 77 |
% ... |
| 78 |
\end{topiclongtable} |
| 79 |
\end{verbatim} |
| 80 |
\end{function}\smallskip |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
\subsection*{Macros} |
| 86 |
|
| 87 |
\begin{function}{\Topic} |
| 88 |
\begin{syntax} |
| 89 |
\tn{Topic}\oarg{content} |
| 90 |
\end{syntax} |
| 91 |
This is the main macro of the package; you can use it to wrap the |
| 92 |
optional \meta{content} of a cell in order to allow it to merge with |
| 93 |
adjacent cells. |
| 94 |
\end{function}\smallskip |
| 95 |
|
| 96 |
The behaviour of \tn{Topic} can be observed in the following complete example: |
| 97 |
\begin{verbatim} |
| 98 |
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|} |
| 99 |
\Topic[Topic 1] & \Topic[Subtopic 1] & \Topic[Subsubtopic 1] & Foo \\ |
| 100 |
\Topic & \Topic & \Topic[Subsubtopic 2] & Bar \\ |
| 101 |
\Topic & \Topic[Subtopic 1] & \Topic[Subsubtopic 2] & Baz \\ |
| 102 |
\Topic[Topic 2] & \Topic[Subtopic 1] & \Topic[Subsubtopic 3] & Qux \\ |
| 103 |
\Topic & \Topic[Subtopic 2] & \Topic[Subsubtopic 4] & Zod \\ |
| 104 |
\Topic & \Topic & \Topic & Bop \\ |
| 105 |
\end{topiclongtable} |
| 106 |
\end{verbatim} |
| 107 |
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|} |
| 108 |
\Topic[Topic 1] & \Topic[Subtopic 1] & \Topic[Subsubtopic 1] & Foo \\ |
| 109 |
\Topic & \Topic & \Topic[Subsubtopic 2] & Bar \\ |
| 110 |
\Topic & \Topic[Subtopic 1] & \Topic[Subsubtopic 2] & Baz \\ |
| 111 |
\Topic[Topic 2] & \Topic[Subtopic 1] & \Topic[Subsubtopic 3] & Qux \\ |
| 112 |
\Topic & \Topic[Subtopic 2] & \Topic[Subsubtopic 4] & Zod \\ |
| 113 |
\Topic & \Topic & \Topic & Bop \\ |
| 114 |
\end{topiclongtable} |
| 115 |
|
| 116 |
Here is a breakdown of the manifested behaviour: |
| 117 |
\begin{itemize}[nosep] |
| 118 |
\item the parameter is optional; |
| 119 |
\item merging happens when it is omitted (rows 1--3 on column 1); |
| 120 |
\item merging happens when its value is equal to the one above |
| 121 |
(rows 2--3 on columns 2 and 3); |
| 122 |
\item merging does not happen (rows 3--4 on column 2) when the |
| 123 |
cells on the left are not merged (rows 3--4 on column 1). |
| 124 |
\end{itemize} |
| 125 |
|
| 126 |
|
| 127 |
\begin{function}{\TopicLine} |
| 128 |
\begin{syntax} |
| 129 |
\tn{TopicLine} |
| 130 |
\end{syntax} |
| 131 |
\tn{TopicLine} can be used at the start of a row to automatically |
| 132 |
draw the horizontal lines that separates it from the row above |
| 133 |
and correctly accounts for merged cells. |
| 134 |
|
| 135 |
By default no horizontal lines are drawn on top and bottom of |
| 136 |
table chunks to allow for maximal flexibility. You can use longtable |
| 137 |
footer and headers to easily draw them (or whichever footer/header |
| 138 |
you may desire) as shown in the next example. |
| 139 |
\end{function}\smallskip |
| 140 |
|
| 141 |
Here is the previous example with lines added: |
| 142 |
\begin{verbatim} |
| 143 |
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|} |
| 144 |
\hline\endhead |
| 145 |
\hline\endfoot |
| 146 |
\TopicLine \Topic[T1] & \Topic[ST1] & \Topic[SST1] & Foo \\ |
| 147 |
\TopicLine \Topic & \Topic & \Topic[SST2] & Bar \\ |
| 148 |
\TopicLine \Topic & \Topic[ST1] & \Topic[SST2] & Baz \\ |
| 149 |
\TopicLine \Topic[T2] & \Topic[ST1] & \Topic[SST3] & Qux \\ |
| 150 |
\TopicLine \Topic & \Topic[ST2] & \Topic[SST4] & Zod \\ |
| 151 |
\TopicLine \Topic & \Topic & \Topic & Bop \\ |
| 152 |
\end{topiclongtable} |
| 153 |
\end{verbatim} |
| 154 |
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|} |
| 155 |
\hline\endhead |
| 156 |
\hline\endfoot |
| 157 |
\TopicLine \Topic[T1] & \Topic[ST1] & \Topic[SST1] & Foo \\ |
| 158 |
\TopicLine \Topic & \Topic & \Topic[SST2] & Bar \\ |
| 159 |
\TopicLine \Topic & \Topic[ST1] & \Topic[SST2] & Baz \\ |
| 160 |
\TopicLine \Topic[T2] & \Topic[ST1] & \Topic[SST3] & Qux \\ |
| 161 |
\TopicLine \Topic & \Topic[ST2] & \Topic[SST4] & Zod \\ |
| 162 |
\TopicLine \Topic & \Topic & \Topic & Bop \\ |
| 163 |
\end{topiclongtable} |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
\subsection*{Settings} |
| 169 |
|
| 170 |
All settings described in this section are global and can be changed between tables. |
| 171 |
|
| 172 |
\begin{function}{\TopicSetContinuationCode} |
| 173 |
\begin{syntax} |
| 174 |
\tn{TopicSetContinuationCode}\marg{\TeX\ code} |
| 175 |
\end{syntax} |
| 176 |
Cells \emph{continuing} from the previous page can be explicitly |
| 177 |
marked. You can set a code fragment to append to such cells using |
| 178 |
\tn{TopicSetContinuationCode}: |
| 179 |
\begin{verbatim} |
| 180 |
\TopicSetContinuationCode{\ (cont.)} |
| 181 |
\end{verbatim} |
| 182 |
By default no mark is appended and you can reset to the default |
| 183 |
using |
| 184 |
\begin{verbatim} |
| 185 |
\TopicSetContinuationCode{} |
| 186 |
\end{verbatim} |
| 187 |
\end{function}\smallskip |
| 188 |
|
| 189 |
Consider this example across two pages: |
| 190 |
\begin{verbatim} |
| 191 |
\TopicSetContinuationCode{\ (cont.)} |
| 192 |
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|} |
| 193 |
\hline\endhead |
| 194 |
\hline\endfoot |
| 195 |
\TopicLine \Topic[A] & \Topic[B] & 1 \\ |
| 196 |
\TopicLine \Topic & \Topic & 2 \\ |
| 197 |
% ... |
| 198 |
\TopicLine \Topic & \Topic[C] & 10 \\ |
| 199 |
\TopicLine \Topic & \Topic & 11 \\ |
| 200 |
% ... |
| 201 |
\TopicLine \Topic & \Topic & 20 \\ |
| 202 |
\end{topiclongtable} |
| 203 |
\end{verbatim} |
| 204 |
\TopicSetContinuationCode{\ (cont.)} |
| 205 |
\begin{topiclongtable}{|Fl|Tl|Tl|} |
| 206 |
\hline\endhead |
| 207 |
\hline\endfoot |
| 208 |
\TopicLine \Topic[A] & \Topic[B] & 1 \\ |
| 209 |
\TopicLine \Topic & \Topic & 2 \\ |
| 210 |
\TopicLine \Topic & \Topic & 3 \\ |
| 211 |
\TopicLine \Topic & \Topic & 4 \\ |
| 212 |
\TopicLine \Topic & \Topic & 5 \\ |
| 213 |
\TopicLine \Topic & \Topic & 6 \\ |
| 214 |
\TopicLine \Topic & \Topic & 7 \\ |
| 215 |
\TopicLine \Topic & \Topic & 8 \\ |
| 216 |
\TopicLine \Topic & \Topic & 9 \\ |
| 217 |
\TopicLine \Topic & \Topic[C] & 10 \\ |
| 218 |
\TopicLine \Topic & \Topic & 11 \\ |
| 219 |
\TopicLine \Topic & \Topic & 12 \\ |
| 220 |
\TopicLine \Topic & \Topic & 13 \\ |
| 221 |
\TopicLine \Topic & \Topic & 14 \\ |
| 222 |
\TopicLine \Topic & \Topic & 15 \\ |
| 223 |
\TopicLine \Topic & \Topic & 16 \\ |
| 224 |
\TopicLine \Topic & \Topic & 17 \\ |
| 225 |
\TopicLine \Topic & \Topic & 18 \\ |
| 226 |
\TopicLine \Topic & \Topic & 19 \\ |
| 227 |
\TopicLine \Topic & \Topic & 20 \\ |
| 228 |
\end{topiclongtable} |
| 229 |
\TopicSetContinuationCode{} |
| 230 |
|
| 231 |
\begin{function}{\TopicSetVPos} |
| 232 |
\begin{syntax} |
| 233 |
\tn{TopicSetVPos}\marg{vertical position specification} |
| 234 |
\end{syntax} |
| 235 |
You can set the vertical position for \tn{Topic} cells by using |
| 236 |
\tn{TopicSetVPos}. Allowed \meta{vertical position specification}s |
| 237 |
are \enquote{\texttt{b}} (bottom), \enquote{\texttt{c}} (center) |
| 238 |
and the default \enquote{\texttt{t}} (top). All \tn{Topic} cells |
| 239 |
will align in the same way: |
| 240 |
\end{function}\smallskip |
| 241 |
|
| 242 |
Here is an example of \emph{bottom} alignment: |
| 243 |
\begin{verbatim} |
| 244 |
\TopicSetVPos{b} |
| 245 |
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|} |
| 246 |
\hline\endhead |
| 247 |
\hline\endfoot |
| 248 |
\TopicLine \Topic[T1] & \Topic[ST1] & Foo \\ |
| 249 |
\TopicLine \Topic & \Topic[ST2] & Bar \\ |
| 250 |
\TopicLine \Topic & \Topic & Baz \\ |
| 251 |
\end{topiclongtable} |
| 252 |
\end{verbatim} |
| 253 |
\TopicSetVPos{b} |
| 254 |
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|} |
| 255 |
\hline\endhead |
| 256 |
\hline\endfoot |
| 257 |
\TopicLine \Topic[T1] & \Topic[ST1] & \Topic[SST1] & Foo \\ |
| 258 |
\TopicLine \Topic & \Topic & \Topic[SST2] & Bar \\ |
| 259 |
\TopicLine \Topic & \Topic[ST1] & \Topic[SST2] & Baz \\ |
| 260 |
\end{topiclongtable} |
| 261 |
\TopicSetVPos{t} |
| 262 |
|
| 263 |
\begin{function}{\TopicSetWidth} |
| 264 |
\begin{syntax} |
| 265 |
\tn{TopicSetVPos}\marg{cell width specification} |
| 266 |
\end{syntax} |
| 267 |
You can set the width of the \tn{Topic} cells by using |
| 268 |
\tn{TopicSetWidth}. Allowed \meta{cell width specification}s are |
| 269 |
\enquote{\texttt{=}} (fit column width) and the default |
| 270 |
\enquote{\texttt{*}} (fit natural content width). |
| 271 |
\end{function}\smallskip |
| 272 |
|
| 273 |
Note \enquote{\texttt{=}} will be useful mostly when coupled with |
| 274 |
column specifiers like \texttt{p}\Arg{width} to force the overflowing |
| 275 |
content inside the column width: |
| 276 |
\begin{verbatim} |
| 277 |
\TopicSetWidth{=} |
| 278 |
\begin{topiclongtable}{|Fp{.5in}|Tl|} |
| 279 |
\hline\endhead |
| 280 |
\hline\endfoot |
| 281 |
\TopicLine \Topic[Fits column width] & A \\ |
| 282 |
\TopicLine \Topic & B \\ |
| 283 |
\TopicLine \Topic & C \\ |
| 284 |
\end{topiclongtable} |
| 285 |
\end{verbatim} |
| 286 |
\TopicSetWidth{=} |
| 287 |
\begin{topiclongtable}{|Fp{.5in}|Tl|} |
| 288 |
\hline\endhead |
| 289 |
\hline\endfoot |
| 290 |
\TopicLine \Topic[Fits column width] & A \\ |
| 291 |
\TopicLine \Topic & B \\ |
| 292 |
\TopicLine \Topic & C \\ |
| 293 |
\end{topiclongtable} |
| 294 |
\TopicSetWidth{*} |
| 295 |
|
| 296 |
\end{documentation} |
| 297 |
|
| 298 |
\PrintIndex |
| 299 |
|
| 300 |
\end{document} |