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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
--- grid-headers ---
#set page(width: auto, height: 12em)
#table(
columns: 5,
align: center + horizon,
table.header(
table.cell(colspan: 5)[*Cool Zone*],
table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*],
table.hline(start: 2, end: 3, stroke: yellow)
),
..range(0, 6).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten()
)
--- grid-headers-no-repeat ---
// Disable repetition
#set page(width: auto, height: 12em)
#table(
columns: 5,
align: center + horizon,
table.header(
table.cell(colspan: 5)[*Cool Zone*],
table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*],
table.hline(start: 2, end: 3, stroke: yellow),
repeat: false
),
..range(0, 6).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten()
)
--- grid-headers-gutter ---
#set page(width: auto, height: 12em)
#table(
columns: 5,
align: center + horizon,
gutter: 3pt,
table.header(
table.cell(colspan: 5)[*Cool Zone*],
table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*],
table.hline(start: 2, end: 3, stroke: yellow),
),
..range(0, 6).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten()
)
--- grid-header-relative-row-sizes ---
// Relative lengths
#set page(height: 10em)
#table(
rows: (30%, 30%, auto),
table.header(
[*A*],
[*B*]
),
[C],
[C]
)
--- grid-header-cell-with-y ---
#grid(
grid.cell(y: 1)[a],
grid.header(grid.cell(y: 0)[b]),
grid.cell(y: 2)[c]
)
--- grid-header-last-child ---
// When the header is the last grid child, it shouldn't include the gutter row
// after it, because there is none.
#grid(
columns: 2,
gutter: 3pt,
grid.header(
[a], [b],
[c], [d]
)
)
--- grid-header-nested ---
#set page(height: 14em)
#let t(n) = table(
columns: 3,
align: center + horizon,
gutter: 3pt,
table.header(
table.cell(colspan: 3)[*Cool Zone #n*],
[*Name*], [*Num*], [*Data*]
),
..range(0, 5).map(i => ([\##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456])).flatten()
)
#grid(
gutter: 3pt,
t(0),
t(1)
)
--- grid-header-hline-and-vline ---
// Test line positioning in header
#table(
columns: 3,
stroke: none,
table.hline(stroke: red, end: 2),
table.vline(stroke: red, end: 3),
table.header(
table.hline(stroke: aqua, start: 2),
table.vline(stroke: aqua, start: 3), [*A*], table.hline(stroke: orange), table.vline(stroke: orange), [*B*],
[*C*], [*D*]
),
[a], [b],
[c], [d],
[e], [f]
)
--- grid-header-not-at-first-row ---
// Error: 3:3-3:19 header must start at the first row
// Hint: 3:3-3:19 remove any rows before the header
#grid(
[a],
grid.header([b])
)
--- grid-header-not-at-first-row-two-columns ---
// Error: 4:3-4:19 header must start at the first row
// Hint: 4:3-4:19 remove any rows before the header
#grid(
columns: 2,
[a],
grid.header([b])
)
--- grow-header-multiple ---
// Error: 3:3-3:19 cannot have more than one header
#grid(
grid.header([a]),
grid.header([b]),
[a],
)
--- table-header-in-grid ---
// Error: 2:3-2:20 cannot use `table.header` as a grid header
// Hint: 2:3-2:20 use `grid.header` instead
#grid(
table.header([a]),
[a],
)
--- grid-header-in-table ---
// Error: 2:3-2:19 cannot use `grid.header` as a table header
// Hint: 2:3-2:19 use `table.header` instead
#table(
grid.header([a]),
[a],
)
--- grid-header-in-grid-header ---
// Error: 14-28 cannot place a grid header within another header or footer
#grid.header(grid.header[a])
--- table-header-in-grid-header ---
// Error: 14-29 cannot place a table header within another header or footer
#grid.header(table.header[a])
--- grid-header-in-table-header ---
// Error: 15-29 cannot place a grid header within another header or footer
#table.header(grid.header[a])
--- table-header-in-table-header ---
// Error: 15-30 cannot place a table header within another header or footer
#table.header(table.header[a])
--- grid-header-block-with-fixed-height ---
#set page(height: 15em)
#table(
rows: (auto, 2.5em, auto),
table.header(
[*Hello*],
[*World*]
),
block(width: 2em, height: 20em, fill: red)
)
--- grid-header-and-rowspan-non-contiguous-1 ---
// Rowspan sizing algorithm doesn't do the best job at non-contiguous content
// ATM.
#set page(height: 15em)
#table(
rows: (auto, 2.5em, 2em, auto, 5em),
table.header(
[*Hello*],
[*World*]
),
table.cell(rowspan: 3, lines(15))
)
--- grid-header-and-rowspan-non-contiguous-2 ---
// Rowspan sizing algorithm doesn't do the best job at non-contiguous content
// ATM.
#set page(height: 15em)
#table(
rows: (auto, 2.5em, 2em, auto, 5em),
gutter: 3pt,
table.header(
[*Hello*],
[*World*]
),
table.cell(rowspan: 3, lines(15))
)
--- grid-header-and-rowspan-non-contiguous-3 ---
// This should look right
#set page(height: 15em)
#table(
rows: (auto, 2.5em, 2em, auto),
gutter: 3pt,
table.header(
[*Hello*],
[*World*]
),
table.cell(rowspan: 3, lines(15))
)
--- grid-header-lack-of-space ---
// Test lack of space for header + text.
#set page(height: 8em)
#table(
rows: (auto, 2.5em, auto, auto, 10em),
gutter: 3pt,
table.header(
[*Hello*],
[*World*]
),
table.cell(rowspan: 3, lorem(80))
)
--- grid-header-orphan-prevention ---
// Orphan header prevention test
#set page(height: 12em)
#v(8em)
#grid(
columns: 3,
grid.header(
[*Mui*], [*A*], grid.cell(rowspan: 2, fill: orange)[*B*],
[*Header*], [*Header* #v(0.1em)]
),
..([Test], [Test], [Test]) * 20
)
--- grid-header-empty ---
// Empty header should just be a repeated blank row
#set page(height: 12em)
#table(
columns: 4,
align: center + horizon,
table.header(),
..range(0, 4).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789])).flatten()
)
--- grid-header-containing-rowspan ---
// When a header has a rowspan with an empty row, it should be displayed
// properly
#set page(height: 10em)
#let count = counter("g")
#table(
rows: (auto, 2em, auto, auto),
table.header(
[eeec],
table.cell(rowspan: 2, count.step() + context count.display()),
),
[d],
block(width: 5em, fill: yellow, lorem(15)),
[d]
)
#context count.display()
--- grid-header-expand ---
// Ensure header expands to fit cell placed in it after its declaration
#set page(height: 10em)
#table(
columns: 2,
table.header(
[a], [b],
[c],
),
table.cell(x: 1, y: 1, rowspan: 2, lorem(80))
)
--- grid-nested-with-headers ---
// Nested table with header should repeat both headers
#set page(height: 10em)
#table(
table.header(
[a]
),
table(
table.header(
[b]
),
[a\ b\ c\ d]
)
)
--- grid-nested-headers ---
#set page(height: 12em)
#table(
table.header(
table(
table.header(
[b]
),
[c],
[d]
)
),
[a\ b]
)
--- grid-header-stroke-edge-cases ---
// Test header stroke priority edge case (last header row removed)
#set page(height: 8em)
#table(
columns: 2,
stroke: black,
gutter: (auto, 3pt),
table.header(
[c], [d],
),
..(table.cell(stroke: aqua)[d],) * 8,
)
--- grid-header-hline-bottom ---
// Yellow line should be kept here
#set text(6pt)
#table(
column-gutter: 3pt,
inset: 1pt,
table.header(
[a],
table.hline(stroke: yellow),
),
table.cell(rowspan: 2)[b]
)
--- grid-header-hline-bottom-manually ---
// Red line should be kept here
#set page(height: 6em)
#set text(6pt)
#table(
column-gutter: 3pt,
inset: 1pt,
table.header(
table.hline(stroke: red, position: bottom),
[a],
),
[a],
table.cell(stroke: aqua)[b]
)
--- grid-header-rowspan-base ---
#set page(height: 7em)
#set text(6pt)
#let full-block = block(width: 2em, height: 100%, fill: red)
#table(
columns: 3,
inset: 1.5pt,
table.header(
[a], full-block, table.cell(rowspan: 2, full-block),
[b]
)
)
|