blob: 93f27d989bc3fc14343457fc7f6520bc2f7a0e2d (
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
%
% topiclongtable v1.3.2 - Renders autocollapsing cells in longtables
%
% Copyright (c) 2017-2020 Paolo Brasolin (<paolo.brasolin@gmail.com>)
%
% This work is sponsored by Human Predictions, LLC (<http://www.humanpredictions.com>).
% This work is maintained by Paolo Brasolin (<paolo.brasolin@gmail.com>).
% This work is available under the terms of the MIT License.
%
\documentclass[full,kernel]{l3doc}
\usepackage{topiclongtable}
\begin{document}
\title{%
The \pkg{topiclongtable} package%
\thanks{Development of this package was sponsored by Human Predictions,
LLC (\href{http://www.humanpredictions.com}{www.humanpredictions.com}).}\\
Autocollapsing cells in longtables
}
\author{
Paolo Brasolin\\
\href{mailto:paolo.brasolin@gmail.com}{paolo.brasolin@gmail.com}
}
\date{2020/04/12 v1.3.2}
\maketitle
\begin{documentation}
This \LaTeX\ package extends \env{longtable}s implementing
\env{topiclongtable}s, in which vertically adjacent cells merge if
and only if they have the same content and the cells on their left
are merged. Furthermore the merging is well behaved, in that it
does not happen after page breaks and correct separation lines are
drawn automatically.
The typical use case is a table that spans multiple pages and
contains a list of hierarchically organized topics (hence the package
name).
\section*{Usage}
To use the package install it in your tree (or put \file{topiclongtable.sty} in your work folder) and require it in your preamble:
\begin{verbatim}
\usepackage{topiclongtable}
\end{verbatim}
\subsection*{Environment}
\begin{function}[updated=2019-07-08]{topiclongtable}
\begin{syntax}
\tn[no-index]{begin}\{\env{topiclongtable}\}\marg{column specification}
\ \ \meta{cells specification}
\tn[no-index]{end}\{\env{topiclongtable}\}
\end{syntax}
The \env{topiclongtable} environment extends \env{longtable}.
They share the same syntax and all features of the latter are
available in the former.
To use \pkg{topiclongtable} macros you must \emph{prepend} \enquote{\texttt{F}}
to the first column specification and \enquote{\texttt{T}} to all others:
\begin{verbatim}
\begin{topiclongtable}{|Fl|Tl|Tl|Tr|Tl|Tr}
% ...
\end{topiclongtable}
\end{verbatim}
\end{function}\smallskip
\subsection*{Macros}
\begin{function}{\Topic}
\begin{syntax}
\tn{Topic}\oarg{content}
\end{syntax}
This is the main macro of the package; you can use it to wrap the
optional \meta{content} of a cell in order to allow it to merge with
adjacent cells.
\end{function}\smallskip
The behaviour of \tn{Topic} can be observed in the following complete example:
\begin{verbatim}
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|}
\Topic[Topic 1] & \Topic[Subtopic 1] & \Topic[Subsubtopic 1] & Foo \\
\Topic & \Topic & \Topic[Subsubtopic 2] & Bar \\
\Topic & \Topic[Subtopic 1] & \Topic[Subsubtopic 2] & Baz \\
\Topic[Topic 2] & \Topic[Subtopic 1] & \Topic[Subsubtopic 3] & Qux \\
\Topic & \Topic[Subtopic 2] & \Topic[Subsubtopic 4] & Zod \\
\Topic & \Topic & \Topic & Bop \\
\end{topiclongtable}
\end{verbatim}
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|}
\Topic[Topic 1] & \Topic[Subtopic 1] & \Topic[Subsubtopic 1] & Foo \\
\Topic & \Topic & \Topic[Subsubtopic 2] & Bar \\
\Topic & \Topic[Subtopic 1] & \Topic[Subsubtopic 2] & Baz \\
\Topic[Topic 2] & \Topic[Subtopic 1] & \Topic[Subsubtopic 3] & Qux \\
\Topic & \Topic[Subtopic 2] & \Topic[Subsubtopic 4] & Zod \\
\Topic & \Topic & \Topic & Bop \\
\end{topiclongtable}
Here is a breakdown of the manifested behaviour:
\begin{itemize}[nosep]
\item the parameter is optional;
\item merging happens when it is omitted (rows 1--3 on column 1);
\item merging happens when its value is equal to the one above
(rows 2--3 on columns 2 and 3);
\item merging does not happen (rows 3--4 on column 2) when the
cells on the left are not merged (rows 3--4 on column 1).
\end{itemize}
\begin{function}{\TopicLine}
\begin{syntax}
\tn{TopicLine}
\end{syntax}
\tn{TopicLine} can be used at the start of a row to automatically
draw the horizontal lines that separates it from the row above
and correctly accounts for merged cells.
By default no horizontal lines are drawn on top and bottom of
table chunks to allow for maximal flexibility. You can use longtable
footer and headers to easily draw them (or whichever footer/header
you may desire) as shown in the next example.
\end{function}\smallskip
Here is the previous example with lines added:
\begin{verbatim}
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|}
\hline\endhead
\hline\endfoot
\TopicLine \Topic[T1] & \Topic[ST1] & \Topic[SST1] & Foo \\
\TopicLine \Topic & \Topic & \Topic[SST2] & Bar \\
\TopicLine \Topic & \Topic[ST1] & \Topic[SST2] & Baz \\
\TopicLine \Topic[T2] & \Topic[ST1] & \Topic[SST3] & Qux \\
\TopicLine \Topic & \Topic[ST2] & \Topic[SST4] & Zod \\
\TopicLine \Topic & \Topic & \Topic & Bop \\
\end{topiclongtable}
\end{verbatim}
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|}
\hline\endhead
\hline\endfoot
\TopicLine \Topic[T1] & \Topic[ST1] & \Topic[SST1] & Foo \\
\TopicLine \Topic & \Topic & \Topic[SST2] & Bar \\
\TopicLine \Topic & \Topic[ST1] & \Topic[SST2] & Baz \\
\TopicLine \Topic[T2] & \Topic[ST1] & \Topic[SST3] & Qux \\
\TopicLine \Topic & \Topic[ST2] & \Topic[SST4] & Zod \\
\TopicLine \Topic & \Topic & \Topic & Bop \\
\end{topiclongtable}
\subsection*{Settings}
All settings described in this section are global and can be changed between tables.
\begin{function}{\TopicSetContinuationCode}
\begin{syntax}
\tn{TopicSetContinuationCode}\marg{\TeX\ code}
\end{syntax}
Cells \emph{continuing} from the previous page can be explicitly
marked. You can set a code fragment to append to such cells using
\tn{TopicSetContinuationCode}:
\begin{verbatim}
\TopicSetContinuationCode{\ (cont.)}
\end{verbatim}
By default no mark is appended and you can reset to the default
using
\begin{verbatim}
\TopicSetContinuationCode{}
\end{verbatim}
\end{function}\smallskip
Consider this example across two pages:
\begin{verbatim}
\TopicSetContinuationCode{\ (cont.)}
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|}
\hline\endhead
\hline\endfoot
\TopicLine \Topic[A] & \Topic[B] & 1 \\
\TopicLine \Topic & \Topic & 2 \\
% ...
\TopicLine \Topic & \Topic[C] & 10 \\
\TopicLine \Topic & \Topic & 11 \\
% ...
\TopicLine \Topic & \Topic & 20 \\
\end{topiclongtable}
\end{verbatim}
\TopicSetContinuationCode{\ (cont.)}
\begin{topiclongtable}{|Fl|Tl|Tl|}
\hline\endhead
\hline\endfoot
\TopicLine \Topic[A] & \Topic[B] & 1 \\
\TopicLine \Topic & \Topic & 2 \\
\TopicLine \Topic & \Topic & 3 \\
\TopicLine \Topic & \Topic & 4 \\
\TopicLine \Topic & \Topic & 5 \\
\TopicLine \Topic & \Topic & 6 \\
\TopicLine \Topic & \Topic & 7 \\
\TopicLine \Topic & \Topic & 8 \\
\TopicLine \Topic & \Topic & 9 \\
\TopicLine \Topic & \Topic[C] & 10 \\
\TopicLine \Topic & \Topic & 11 \\
\TopicLine \Topic & \Topic & 12 \\
\TopicLine \Topic & \Topic & 13 \\
\TopicLine \Topic & \Topic & 14 \\
\TopicLine \Topic & \Topic & 15 \\
\TopicLine \Topic & \Topic & 16 \\
\TopicLine \Topic & \Topic & 17 \\
\TopicLine \Topic & \Topic & 18 \\
\TopicLine \Topic & \Topic & 19 \\
\TopicLine \Topic & \Topic & 20 \\
\end{topiclongtable}
\TopicSetContinuationCode{}
\begin{function}{\TopicSetVPos}
\begin{syntax}
\tn{TopicSetVPos}\marg{vertical position specification}
\end{syntax}
You can set the vertical position for \tn{Topic} cells by using
\tn{TopicSetVPos}. Allowed \meta{vertical position specification}s
are \enquote{\texttt{b}} (bottom), \enquote{\texttt{c}} (center)
and the default \enquote{\texttt{t}} (top). All \tn{Topic} cells
will align in the same way:
\end{function}\smallskip
Here is an example of \emph{bottom} alignment:
\begin{verbatim}
\TopicSetVPos{b}
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|}
\hline\endhead
\hline\endfoot
\TopicLine \Topic[T1] & \Topic[ST1] & Foo \\
\TopicLine \Topic & \Topic[ST2] & Bar \\
\TopicLine \Topic & \Topic & Baz \\
\end{topiclongtable}
\end{verbatim}
\TopicSetVPos{b}
\begin{topiclongtable}{|Fl|Tl|Tl|Tl|}
\hline\endhead
\hline\endfoot
\TopicLine \Topic[T1] & \Topic[ST1] & \Topic[SST1] & Foo \\
\TopicLine \Topic & \Topic & \Topic[SST2] & Bar \\
\TopicLine \Topic & \Topic[ST1] & \Topic[SST2] & Baz \\
\end{topiclongtable}
\TopicSetVPos{t}
\begin{function}{\TopicSetWidth}
\begin{syntax}
\tn{TopicSetVPos}\marg{cell width specification}
\end{syntax}
You can set the width of the \tn{Topic} cells by using
\tn{TopicSetWidth}. Allowed \meta{cell width specification}s are
\enquote{\texttt{=}} (fit column width) and the default
\enquote{\texttt{*}} (fit natural content width).
\end{function}\smallskip
Note \enquote{\texttt{=}} will be useful mostly when coupled with
column specifiers like \texttt{p}\Arg{width} to force the overflowing
content inside the column width:
\begin{verbatim}
\TopicSetWidth{=}
\begin{topiclongtable}{|Fp{.5in}|Tl|}
\hline\endhead
\hline\endfoot
\TopicLine \Topic[Fits column width] & A \\
\TopicLine \Topic & B \\
\TopicLine \Topic & C \\
\end{topiclongtable}
\end{verbatim}
\TopicSetWidth{=}
\begin{topiclongtable}{|Fp{.5in}|Tl|}
\hline\endhead
\hline\endfoot
\TopicLine \Topic[Fits column width] & A \\
\TopicLine \Topic & B \\
\TopicLine \Topic & C \\
\end{topiclongtable}
\TopicSetWidth{*}
\end{documentation}
\PrintIndex
\end{document}
|