summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/xtables/xtables-mkiv.tex
blob: 1b878e5cbae7794e7cd9ba2ee153d513e1e91ea7 (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
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
% language=uk

% author    : Hans Hagen
% copyright : PRAGMA ADE & ConTeXt Development Team
% license   : Creative Commons Attribution ShareAlike 4.0 International
% reference : pragma-ade.nl | contextgarden.net | texlive (related) distributions
% origin    : the ConTeXt distribution
%
% comment   : Because this manual is distributed with TeX distributions it comes with a rather
%             liberal license. We try to adapt these documents to upgrades in the (sub)systems
%             that they describe. Using parts of the content otherwise can therefore conflict
%             with existing functionality and we cannot be held responsible for that. Many of
%             the manuals contain characteristic graphics and personal notes or examples that
%             make no sense when used out-of-context.
%
% comment   : Some chapters might have been published in TugBoat, the NTG Maps, the ConTeXt
%             Group journal or otherwise. Thanks to the editors for corrections. Also thanks
%             to users for testing, feedback and corrections.

\usemodule[art-01,abr-02]

\definecolor[red]    [darkred]
\definecolor[green]  [darkgreen]
\definecolor[blue]   [darkblue]
\definecolor[yellow] [darkyellow]
\definecolor[magenta][darkmagenta]
\definecolor[cyan]   [darkcyan]

\setupexternalfigures
  [location={local,default}]

\setupbodyfont
  [10pt]

\setuptyping
  [color=darkyellow]

\setuptype
  [color=darkcyan]

% \setupnumbering
%   [alternative=doublesided]

\setuphead
  [section]
  [color=darkmagenta]

\setupinteraction
  [hidden]

\startdocument
  [metadata:author=Hans Hagen,
   metadata:title=Extreme Tables,
   author=Hans Hagen,
   affiliation=PRAGMA ADE,
   location=Hasselt NL,
   title=Extreme Tables,
   extra=ConTeXt MkIV,
   support=www.contextgarden.net,
   website=www.pragma-ade.nl]

\startMPpage

    StartPage ;
        fill Page enlarged 2mm withcolor magenta/4 ;
        pickup pencircle scaled 2mm ;
        numeric n ; n := bbheight Page ;
        forever :
            n := n / 1.5 ;
            draw bottomboundary Page shifted (0, n) withcolor 2yellow/3 withtransparency (1,0.5) ;
            draw topboundary    Page shifted (0,-n) withcolor 2yellow/3 withtransparency (1,0.5) ;
            exitif n < 2cm ;
        endfor ;
        numeric n ; n := bbheight Page ;
        forever :
            n := n / 1.5 ;
            draw leftboundary  Page shifted ( n,0) withcolor 2cyan/3 withtransparency (1,0.5) ;
            draw rightboundary Page shifted (-n,0) withcolor 2cyan/3 withtransparency (1,0.5) ;
            exitif n < 2cm ;
        endfor ;
        picture p, q, r ;
        p := textext("\ssbf\WORD{\documentvariable{title}}") xsized (bbheight Page - 2cm) rotated 90 ;
        q := textext("\ssbf\WORD{\documentvariable{author}}") ysized 1cm ;
        r := textext("\ssbf\WORD{\documentvariable{extra}}") xsized bbwidth q ;
        draw anchored.rt (p, center rightboundary  Page shifted (-1cm,0cm)) withcolor white ;
        draw anchored.bot(q, center bottomboundary Page shifted ( 1cm,4.4cm)) withcolor white ;
        draw anchored.bot(r, center bottomboundary Page shifted ( 1cm,2.8cm)) withcolor white ;
    StopPage ;

\stopMPpage

% \page[empty] \setuppagenumber[start=1]

\startsubject[title={Contents}]

\placelist[section][criterium=all,interaction=all]

\stopsubject

\startsection[title={Introduction}]

This is a short introduction to yet another table mechanism built in \CONTEXT. It
is a variant of the so called natural tables but it has a different
configuration. Also, the implementation is completely different. The reason for
writing it is that in one of our projects we had to write styles for documents
that had tables spanning 30 or more pages and apart from memory constraints this
is quite a challenge for the other mechanisms, if only because splitting them
into successive floats is not possible due to limitations of \TEX. The extreme
table mechanism can handle pretty large tables and split them too. As each cell
is basically a \type {\framed} and as we need to do two passes over the table,
this mechanism is not the fastest but it is some two times faster than the
natural tables mechanism, and in most cases can be used instead.

\stopsection

\startsection[title={The structure}]

The structure of the tables is summarized here. There can be the usual head, body
and foot specifications and we also support the optional header in following
pages.

\starttyping
\definextable [tag] | [tag][parent]
\setupxtable [settings] | [tag][settings]

\startxtable[tag|settings]
  \startxtablehead|next|body|foot[tag|settings]
    \startxrowgroup[tag|settings]
      \startxrow[settings]
        \startxcellgroup[tag|settings]
          \startxcell[settings] ... \stopxcell
        \stopxcellgroup
      \stopxrow
    \startxrowgroup
  \stopxtablehead|next|body|foot
\stopxtable
\stoptyping

Contrary to what you might expect, the definition command defines a new set of
command. You don't need to use this in order to set up a new settings
environment. Settings and definitions can inherit so you can build a chain of
parent|-|child settings. The grouping is nothing more than a switch to a new set
of settings.

\stopsection

\startsection[title={Direct control}]

A simple table with just frames is defined as follows:

\startbuffer
\startxtable
  \startxrow
    \startxcell one   \stopxcell
    \startxcell two   \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

\startlinecorrection[blank] \getbuffer \stoplinecorrection

You can pass parameters for tuning the table:

\startbuffer
\startxtable[offset=1cm]
  \startxrow
    \startxcell one   \stopxcell
    \startxcell two   \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

\startlinecorrection[blank] \getbuffer \stoplinecorrection

You can (for as much as they make sense) use the same settings as the \type
{\framed} command, as long as you keep in mind that messing with the frame
related offsets can have side effects.

\stopsection

\startsection[title={Sets of settings}]

Instead of directly passing settings you can use a predefined set. Of course you
can also combine these methods.

\startbuffer
\definextable
  [myxtable]

\definextable
  [myxtable:important]
  [myxtable]

\setupxtable
  [myxtable]
  [width=4cm,
   foregroundcolor=red]

\setupxtable
  [myxtable:important]
  [background=color,
   backgroundcolor=red,
   foregroundcolor=white]
\stopbuffer

\typebuffer \getbuffer

We can use these settings in table. Although it is not really needed to define a
set beforehand (i.e.\ you can just use the setup command) it is cleaner and more
efficient too.

\startbuffer
\startxtable[myxtable]
  \startxrow[foregroundcolor=green]
    \startxcell one \stopxcell
    \startxcell two \stopxcell
    \startxcellgroup[foregroundcolor=blue]
      \startxcell tree  \stopxcell
      \startxcell four  \stopxcell
    \stopxcellgroup
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
    \startxcellgroup[myxtable:important]
      \startxcell gamma \stopxcell
      \startxcell delta \stopxcell
    \stopxcellgroup
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

\startlinecorrection[blank] \getbuffer \stoplinecorrection

The overhead of (chained) settings is quite acceptable and it helps to keep the
source of the table uncluttered from specific settings.

\stopsection

\startsection[title={Defining}]

If needed you can define your own encapsulating commands. The following example
demonstrates this:

\startbuffer
\definextable[mytable]
\stopbuffer

\getbuffer \typebuffer

We now can use the \type{mytable} wrapper:

\startbuffer
\startmytable[height=4cm,width=8cm,align={middle,lohi}]
  \startxrow
    \startxcell test \stopxcell
  \stopxrow
\stopmytable
\stopbuffer

\typebuffer

\startlinecorrection[blank] \getbuffer \stoplinecorrection

One drawback of using buffers is that they don't play well in macro definitions.
In that case you need to use the following wrapper:

\startbuffer
\starttexdefinition MyTable #1#2#3#4
  \startembeddedxtable
    \startxrow
      \startxcell #1 \stopxcell
      \startxcell #2 \stopxcell
    \stopxrow
    \startxrow
      \startxcell #3 \stopxcell
      \startxcell #4 \stopxcell
    \stopxrow
  \stopembeddedxtable
\stoptexdefinition
\stopbuffer

\typebuffer \getbuffer

This macro is used as any other macro with arguments:

\startbuffer
\MyTable{one}{two}{three}{four}
\stopbuffer

\typebuffer

\startlinecorrection[blank] \getbuffer \stoplinecorrection

\stopsection

\startsection[title={Stretching}]

If you don't give the width of a cell, the widest natural size will be taken.
Otherwise the given width applies to the whole column.

\startbuffer
\startxtable
  \startxrow
    \startxcell[width=1cm] one  \stopxcell
    \startxcell[width=2cm] two  \stopxcell
    \startxcell[width=3cm] tree \stopxcell
    \startxcell[width=4cm] four \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
    \startxcell gamma \stopxcell
    \startxcell delta \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

\startlinecorrection[blank] \getbuffer \stoplinecorrection

You can let the cells stretch so that the whole width of the text area is taken.

\startbuffer[one]
\startxtable[option=stretch]
  \startxrow
    \startxcell[width=1cm] one  \stopxcell
    \startxcell[width=2cm] two  \stopxcell
    \startxcell[width=3cm] tree \stopxcell
    \startxcell[width=4cm] four \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
    \startxcell gamma \stopxcell
    \startxcell delta \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer[one]

The available left over space is equally distributed among the cells.

\startlinecorrection[blank] \getbuffer[one] \stoplinecorrection

\startbuffer[two]
\startxtable[option={stretch,width}]
  \startxrow
    \startxcell[width=1cm] one  \stopxcell
    \startxcell[width=2cm] two  \stopxcell
    \startxcell[width=3cm] tree \stopxcell
    \startxcell[width=4cm] four \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
    \startxcell gamma \stopxcell
    \startxcell delta \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

An alternative is to distribute the space proportionally:

\typebuffer[two]

\startlinecorrection[blank] \getbuffer[two] \stoplinecorrection

Just to stress the difference we show both alongside now:

\startlinecorrection[blank]
    \getbuffer[one]
    \blank
    \getbuffer[two]
\stoplinecorrection

You can specify the width of a cell with each cell but need to keep into mind
that that value is then used for the whole column:

\startbuffer
\startxtable
  \startxrow
    \startxcell[width=1em] one  \stopxcell
    \startxcell[width=2em] two  \stopxcell
    \startxcell[width=3em] tree \stopxcell
    \startxcell[width=4em] four \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
    \startxcell gamma \stopxcell
    \startxcell delta \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

\startlinecorrection[blank] \getbuffer \stoplinecorrection

You can enforce that larger columns win via the \type {option} parameter:

\startbuffer
\startxtable[option=max]
  \startxrow
    \startxcell[width=1em] one  \stopxcell
    \startxcell[width=2em] two  \stopxcell
    \startxcell[width=3em] tree \stopxcell
    \startxcell[width=4em] four \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
    \startxcell gamma \stopxcell
    \startxcell delta \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

\startlinecorrection[blank] \getbuffer \stoplinecorrection

\stopsection

\startsection[title={Spacing}]

It is possible to separate the cells by horizontal and/or vertical space. As an
example we create a setup.

\startbuffer
\setupxtable
  [myztable]
  [option=stretch,
   foregroundcolor=blue,
   columndistance=10pt,
   leftmargindistance=20pt,
   rightmargindistance=30pt]
\stopbuffer

\typebuffer \getbuffer

You can use the \type {textwidth} parameter to set a specific maximum width. We
now apply the previous settings to an extreme table:

\startbuffer
\startxtable[myztable]
  \startxrow
    \startxcell[width=1cm] one              \stopxcell
    \startxcell[width=2cm,distance=5pt] two \stopxcell
    \startxcell[width=3cm] tree             \stopxcell
    \startxcell[width=4cm] four             \stopxcell
  \stopxrow
  \startxrow
    \startxcell[width=1cm] alpha \stopxcell
    \startxcell[width=2cm] beta  \stopxcell
    \startxcell[width=3cm] gamma \stopxcell
    \startxcell[width=4cm] delta \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

As you can see here, we can still locally overload the settings but keep in mind
that these apply to the whole column then, not to the specific cell.

\startlinecorrection[blank] \getbuffer \stoplinecorrection

Vertical spacing is (currently) setup differently, i.e.\ as an argument to the
\type {\blank} command.

\startbuffer
\startxtable[spaceinbetween=medium]
  \startxrow
    \startxcell one  \stopxcell
    \startxcell two  \stopxcell
    \startxcell tree \stopxcell
    \startxcell four \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
    \startxcell gamma \stopxcell
    \startxcell delta \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

Specifying spacing this way improves consistency with the rest of the document
spacing.

\startlinecorrection[blank] \getbuffer \stoplinecorrection

\stopsection

\startsection[title={Spanning}]

Of course we can span cells horizontally as well as vertically. Future versions
might provide more advanced options but the basics work okay.

\startbuffer
\startxtable
  \startxrow
    \startxcell one \stopxcell
    \startxcell[nx=2] two + three \stopxcell
    \startxcell four \stopxcell
    \startxcell five \stopxcell
  \stopxrow
  \startxrow
    \startxcell[nx=3] alpha + beta + gamma \stopxcell
    \startxcell[nx=2] delta + epsilon \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

This spans a few cells horizontally:

\startlinecorrection[blank] \getbuffer \stoplinecorrection

The next example gives a span in two directions:

\startbuffer
\startxtable
  \startxrow
    \startxcell alpha 1 \stopxcell
    \startxcell beta  1 \stopxcell
    \startxcell gamma 1 \stopxcell
    \startxcell delta 1 \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha 2 \stopxcell
    \startxcell[nx=2,ny=2] whatever \stopxcell
    \startxcell delta 2 \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha 3 \stopxcell
    \startxcell delta 3 \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha 4 \stopxcell
    \startxcell beta  4 \stopxcell
    \startxcell gamma 4 \stopxcell
    \startxcell delta 4 \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

Of course, spanning is always a compromise but the best fit found by this
mechanism takes natural width, given width and available space into account.

\startlinecorrection[blank] \getbuffer \stoplinecorrection

\stopsection

\startsection[title={Partitioning}]

You can partition a table as follows:

\startbuffer
\startxtable
  \startxtablehead
    \startxrow
      \startxcell head one  \stopxcell
      \startxcell head two  \stopxcell
      \startxcell head tree \stopxcell
      \startxcell head four \stopxcell
    \stopxrow
  \stopxtablehead
  \startxtablenext
    \startxrow
      \startxcell next one  \stopxcell
      \startxcell next two  \stopxcell
      \startxcell next tree \stopxcell
      \startxcell next four \stopxcell
    \stopxrow
  \stopxtablenext
  \startxtablebody
    \startxrow
      \startxcell body one  \stopxcell
      \startxcell body two  \stopxcell
      \startxcell body tree \stopxcell
      \startxcell body four \stopxcell
    \stopxrow
  \stopxtablebody
  \startxtablefoot
    \startxrow
      \startxcell foot one  \stopxcell
      \startxcell foot two  \stopxcell
      \startxcell foot tree \stopxcell
      \startxcell foot four \stopxcell
    \stopxrow
  \stopxtablefoot
\stopxtable
\stopbuffer

\typebuffer

There can be multiple such partitions and they are collected in head, next, body
and foot groups. Normally the header ends up at the beginning and the footer at
the end. When a table is split, the first page gets the header and the following
pages the next one.

You can let headers and footers be repeated by setting the \type {header}
and|/|or \type {footer} parameters to \type {repeat}.

\starttyping
\setupxtable
  [split=yes,
   header=repeat,
   footer=repeat]
\stoptyping

The table can be flushed in the running text but also in successive
floats. Given that the table is in a buffer:

\starttyping
\placetable[here,split]{A big table.}{\getbuffer}
\stoptyping

When you specify \type {split} as \type {yes} the caption is taken into account
when calculating the available space.

There are actually three different split methods. The \type {yes} option works in
text mode as well as in floats, but in text mode no headers and footers get
repeated. If you want that feature in a text flush you have to set \type {split}
to \type {repeat} as well.

You can keep rows together by passing a \type {samepage} directive. This
parameter can get the values \type {before}, \type {after} and \type {both}.

\starttyping
\startxtable[split=yes]
  \startxrow                \startxcell \tttf      .01. \stopxcell \stopxrow
  \startxrow                \startxcell \tttf      .... \stopxcell \stopxrow
  \startxrow                \startxcell \tttf \red .21. \stopxcell \stopxrow
  \startxrow[samepage=both] \startxcell \tttf \red .22. \stopxcell \stopxrow
  \startxrow[samepage=both] \startxcell \tttf \red .23. \stopxcell \stopxrow
  \startxrow                \startxcell \tttf      .... \stopxcell \stopxrow
  \startxrow                \startxcell \tttf      .99. \stopxcell \stopxrow
\stopxtable
\stoptyping

\stopsection

\startsection[title={Options}]

On the average a table will come out okay but you need to keep in mind that when
(complex) spans are used the results can be less that optimal. However, as
normally one pays attention to creating tables, the amount of control provided
often makes it possible to get what you want.

In the following situations, the first cell width is determined by the span. It
is possible to make a more clever analyzer but we need to keep in mind that in
the same column there can be entries that span a different amount of columns. Not
only would that be inefficient but it would also be rather unpredictable unless
you know exactly what happens deep down. The following two examples demonstrate
default behaviour.

\startbuffer
\startxtable
  \startxrow
    \startxcell[nx=3]
        1/2/3
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell 1 \stopxcell
    \startxcell 2 \stopxcell
    \startxcell 3 \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startxtable
  \startxrow
    \startxcell[nx=3]
        1 / 2 / 3
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell 1 \stopxcell
    \startxcell 2 \stopxcell
    \startxcell 3 \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

In practice you will set the width of the columns, as in:

\startbuffer
\startxtable
  \startxrow
    \startxcell[nx=3]
        1/2/3
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell[width=\dimexpr\textwidth/3] 1 \stopxcell
    \startxcell[width=\dimexpr\textwidth/3] 2 \stopxcell
    \startxcell[width=\dimexpr\textwidth/3] 3 \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

But, if you want you can control the enforced width by setting an option:

\startbuffer
\startxtable
  \startxrow
    \startxcell[nx=3,option=tight]
        1/2/3
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell 1 \stopxcell
    \startxcell 2 \stopxcell
    \startxcell 3 \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startxtable
  \startxrow
    \startxcell[nx=3,option=tight]
        1 / 2 / 3
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell 1 \stopxcell
    \startxcell 2 \stopxcell
    \startxcell 3 \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

There is also a global setting:

\startbuffer
\startxtable[option=tight]
  \startxrow
    \startxcell[nx=3]
      1/2/3
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell 1 \stopxcell
    \startxcell 2 \stopxcell
    \startxcell 3 \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\stopsection

\startsection[title={Nesting}]

Extreme tables can be nested but you need to keep an eye on inheritance here as
the inner table uses the settings from the encapsulating cell. The widths and
heights of the inner table default to \type {fit}. We could cook up a more
complex nesting model but this one is easy to follow.

\startbuffer
\startxtable
  \startxrow
    \startxcell[offset=0pt]
      \startxtable[background=color,backgroundcolor=green,
            foregroundcolor=white,offset=1ex]
        \startxrow
          \startxcell[width=1cm] one \stopxcell
          \startxcell[width=2cm] two \stopxcell
        \stopxrow
        \startxrow
          \startxcell[width=3cm] alpha \stopxcell
          \startxcell[width=4cm] beta  \stopxcell
        \stopxrow
      \stopxtable
    \stopxcell
    \startxcell two   \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell
      \startxtable[background=color,backgroundcolor=red,
            foregroundcolor=white]
        \startxrow
          \startxcell one \stopxcell
          \startxcell two \stopxcell
        \stopxrow
        \startxrow
          \startxcell alpha \stopxcell
          \startxcell beta  \stopxcell
        \stopxrow
      \stopxtable
    \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer

Here we just manipulate the offset a bit.

\startlinecorrection[blank] \getbuffer \stoplinecorrection

\stopsection

\startsection[title={Buffers}]

When you don't want to clutter your document source too much buffers can be if
help:

\startbuffer
\startbuffer[test]
\startxtable
  \startxrow
    \startxcell[width=1cm] one \stopxcell
    \startxcell[width=2cm] two \stopxcell
  \stopxrow
  \startxrow
    \startxcell alpha \stopxcell
    \startxcell beta  \stopxcell
  \stopxrow
\stopxtable
\stopbuffer
\stopbuffer

\typebuffer \getbuffer

One way of getting this table typeset is to say:

\starttyping
\getbuffer[test]
\stoptyping

Normally this is quite okay. However, internally extreme tables become also
buffers. If you don't like the overhead of this double buffering you can use the
following command:

\starttyping
\processxtablebuffer[test]
\stoptyping

This can save you some memory and runtime, but don't expect miracles. Also, this
way of processing does not support nested tables (unless \type {{}} is used).

\stopsection

\startsection[title={XML}]

The following example demonstrates that we can use this mechanism in \XML\ too.
The example was provided by Thomas Schmitz. First we show how a table looks like
in \XML:

\startbuffer[test]
<table>
  <tablerow>
      <tablecell>
        One
      </tablecell>
      <tablecell>
        Two
      </tablecell>
  </tablerow>
  <tablerow>
    <tablecell>
      <b>Three</b>
    </tablecell>
    <tablecell>
      Four
    </tablecell>
  </tablerow>
</table>
\stopbuffer

\typebuffer[test]

We need to map these elements to setups:

\startbuffer
\startxmlsetups xml:testsetups
    \xmlsetsetup{main}{b|table|tablerow|tablecell}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:testsetups}
\stopbuffer

\typebuffer \getbuffer

The setups themselves are rather simple as we don't capture any attributes.

\startbuffer
\startxmlsetups xml:b
  \bold{\xmlflush{#1}}
\stopxmlsetups

\startxmlsetups xml:table
  \startembeddedxtable
    \xmlflush{#1}
  \stopembeddedxtable
\stopxmlsetups

\startxmlsetups xml:tablerow
  \startxrow
    \xmlflush{#1}
  \stopxrow
\stopxmlsetups

\startxmlsetups xml:tablecell
  \startxcell
    \xmlflush{#1}
  \stopxcell
\stopxmlsetups
\stopbuffer

\typebuffer \getbuffer

We now process the example. Of course it will also work for files.

\startbuffer
  \xmlprocessbuffer{main}{test}{}
\stopbuffer

\typebuffer

The result is:

\startlinecorrection[blank] \getbuffer \stoplinecorrection

\stopsection

\startsection[title={Natural tables}]

For the impatient a small additional module is provided that remaps the natural
table commands onto extreme tables:

\startbuffer
\usemodule[ntb-to-xtb]
\stopbuffer

\typebuffer \getbuffer

After that:

\startbuffer
\bTABLE
  \bTR
    \bTD[background=color,backgroundcolor=red] one \eTD
    \bTD[width=2cm] two \eTD
  \eTR
  \bTR
    \bTD[width=5cm] alpha \eTD
    \bTD[background=color,backgroundcolor=yellow] beta \eTD
  \eTR
\eTABLE
\stopbuffer
\stopbuffer

\typebuffer

Will come out as:

\startlinecorrection[blank]
\getbuffer
\stoplinecorrection

You can restore and remap the commands with the following helpers:

\starttyping
\restoreTABLEfromxtable
\mapTABLEtoxtable
\stoptyping

Of course not all functionality of the natural tables maps onto similar
functionality of extreme tables, but on the average the result will look rather
similar.

\stopsection

\startsection[title={Alignment}]

\enabletrackers[typesetters.characteralign]

There is limited support for aligning numbers in columns. When you flush right
and have a fixed number of digits it's not a problem, but otherwise it might come
in handy. In any case, you might want to use the following as part of your style:

\starttyping
\addfeature[tabularnumbers]
\stoptyping

\start \addfeature[tabularnumbers]

The basic alignment mechanism can be demonstrated with the following examples:

\startbuffer
\startcharacteralign[,] % or [character={,}]
    \checkcharacteralign{123.456,78} \par
    \checkcharacteralign    {456}    \par
    \checkcharacteralign {23.456}    \par
    \checkcharacteralign     {78,9}  \par
    \checkcharacteralign     {78}    \par
\stopcharacteralign
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startcharacteralign[leftsample=123.456,rightsample=00,character={,}]
    \checkcharacteralign{123.456,78} \par
    \checkcharacteralign    {456}    \par
    \checkcharacteralign {23.456}    \par
    \checkcharacteralign     {78,9}  \par
    \checkcharacteralign     {78}    \par
\stopcharacteralign
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startcharacteralign[leftwidth=100pt,rightwidth=30pt]
    \checkcharacteralign{123.456,78} \par
    \checkcharacteralign    {456}    \par
    \checkcharacteralign {23.456}    \par
    \checkcharacteralign     {78,9}  \par
    \checkcharacteralign     {78}    \par
\stopcharacteralign
\stopbuffer

\typebuffer \getbuffer

Samples win over width settings. When no sample or width is given a two pass
analyzer kicks in. This is not the case in the following examples.

\startbuffer
\startxtable
    [align={flushright,lohi},
     aligncharacter=yes,
     alignmentleftsample=100,
     alignmentrightsample=00,
     alignmentcharacter={.}]
  \startxrow \startxcell 1     \stopxcell \stopxrow
  \startxrow \startxcell 1.1   \stopxcell \stopxrow
  \startxrow \startxcell 11.11 \stopxcell \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startxtable
    [align={flushright,lohi},
     aligncharacter=yes,
     alignmentleftsample=000.000,
     alignmentrightsample=00,
     alignmentcharacter={,}]
  \startxrow \startxcell 123.456,78 x \stopxcell \stopxrow
  \startxrow \startxcell     456    x \stopxcell \stopxrow
  \startxrow \startxcell 23.456     x \stopxcell \stopxrow
  \startxrow \startxcell     78,9   x \stopxcell \stopxrow
  \startxrow \startxcell     78     x \stopxcell \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startxtable[align={flushright,lohi}]
  \startxrow
    \startxcell
        [aligncharacter=yes,
         alignmentcharacter={,},
         alignmentleftsample=000.000,
         alignmentrightsample=00]
        123.456,78
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell
        [aligncharacter=yes]
        456
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell
        [aligncharacter=yes]
        23.456
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell
        [aligncharacter=yes]
        78,9
    \stopxcell
  \stopxrow
  \startxrow
    \startxcell
        [aligncharacter=yes]
        78
    \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\setupxtable
  [aligned]
  [aligncharacter=yes,
   alignmentleftsample=000.000,
   alignmentrightsample=00,
   alignmentcharacter={,}]

\startxtable[align={flushright,lohi}]
  \startxrow \startxcell[aligned] 123.456,78 \stopxcell \stopxrow
  \startxrow \startxcell[aligned]     456    \stopxcell \stopxrow
  \startxrow \startxcell[aligned] 23.456     \stopxcell \stopxrow
  \startxrow \startxcell[aligned]     78,9   \stopxcell \stopxrow
  \startxrow \startxcell[aligned]     78     \stopxcell \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\stop

\disabletrackers[typesetters.characteralign]

\stopsection

\startsection[title={Depth}]

Take the following example. Here we have some text that, when typeset narrow,
will have a last line with no (or, depending on the font, hardly) depth.

\startbuffer
\startxtable[frame=on]

    \startxrow
        \startxcell[width=3cm]
            here filled with some words to force a rather long line
        \stopxcell
    \stopxrow

    \startxrow
        \startxcell
            here filled with some words to force a rather long line
        \stopxcell
    \stopxrow

    \startxrow
        \startxcell
            here filled with some words to force a rather long line

        \stopxcell
    \stopxrow

\stopxtable
\stopbuffer

\typebuffer

The problem is that \TEX\ doesn't add depth that that last line and adding it
automatically can be done in grid mode but one doesn't always want that. Some mechanisms
add so called struts automatically. As the table cells are framed boxes indeed that
happens here, unless you add an empty line (as in the last row). When you embed

\startlinecorrection[blank] {\showstruts \showboxes \getbuffer} \stoplinecorrection

\startbuffer
\startxtable[frame=on]

    \startxrow
        \startxcell[width=3cm]
            \startitemize[packed]
                \startitem
                    here filled with some words to force a rather long line
                \stopitem
            \stopitemize
        \stopxcell
    \stopxrow

    \startxrow
        \startxcell
            \startitemize[packed]
                \startitem
                    here filled with some words to force a rather long line
                \stopitem
            \stopitemize
        \stopxcell
    \stopxrow

    \startxrow
        \startxcell
            \startitemize[packed]
                \startitem
                    here filled with some words to force a rather long line

                \stopitem
            \stopitemize
        \stopxcell
    \stopxrow

\stopxtable
\stopbuffer

\typebuffer

Don't count on all mechanisms used inside a cell to provide this but with itemize
you're lucky.

\startlinecorrection[blank] {\showstruts \showboxes \getbuffer} \stoplinecorrection

\stopsection

\startsection[title={Swapping}]

The next two examples demonstrate a feature added for Taco, who wanted to input
vertical instead of horizontal. It's a bit of a hack but it works okay for
simple cases. We assume these settings:

\startbuffer[settings]
\setupxtable[one]  [foregroundcolor=darkred]
\setupxtable[two]  [foregroundcolor=darkgreen]
\setupxtable[three][foregroundcolor=darkblue]
\setupxtable[four] [foregroundcolor=darkorange]
\stopbuffer

\startbuffer[demo-1]
\startxtable[frame=on]
    \startxcolumn[one]
        \startxcell A1 \stopxcell
        \startxcell B1 \stopxcell
        \startxcell C1 \stopxcell
        \startxcell D1 \stopxcell
        \startxcell E1 \stopxcell
    \stopxcolumn
    \startxcolumn[two]
        \startxcell A2 \stopxcell
        \startxcell B2 \stopxcell
        \startxcell C2 \stopxcell
        \startxcell D2 \stopxcell
        \startxcell E2 \stopxcell
    \stopxcolumn
    \startxcolumn[three]
        \startxcell A3 \stopxcell
        \startxcell B3 \stopxcell
        \startxcell C3 \stopxcell
        \startxcell D3 \stopxcell
        \startxcell E3 \stopxcell
    \stopxcolumn
    \startxcolumn[four]
        \startxcell A4 \stopxcell
        \startxcell B4 \stopxcell
        \startxcell C4 \stopxcell
        \startxcell D4 \stopxcell
        \startxcell E4 \stopxcell
    \stopxcolumn
\stopxtable
\stopbuffer

\startbuffer[demo-2]
\startxtable[frame=on]
    \startxcolumn[one]
        \startxcell A \stopxcell
        \startxcell B \stopxcell
        \startxcell C \stopxcell
        \startxcell D \stopxcell
        \startxcell E \stopxcell
    \stopxcolumn
    \startxcolumn[two]
        \startxcell       A  \stopxcell
        \startxcell[ny=2] BC \stopxcell
        \startxcell[ny=2] DE \stopxcell
    \stopxcolumn
    \startxcolumn[three]
        \startxcell       A    \stopxcell
        \startxcell[ny=4] BCDE \stopxcell
    \stopxcolumn
    \startxcolumn[four]
        \startxcell       A \stopxcell
        \startxcell       B \stopxcell
        \startxcell[ny=2] CD \stopxcell
        \startxcell       E  \stopxcell
    \stopxcolumn
\stopxtable
\stopbuffer

\typebuffer[settings]

The first example has no spans:

\typebuffer[demo-1]

while the second one has:

\typebuffer[demo-2]

The results are shown in \in {figure} [fig:swapped].

\startplacefigure[title={Entering columns instead of rows.},reference=fig:swapped]
    \getbuffer[settings]
    \startcombination
        {\getbuffer[demo-1]} {no spans}
        {\getbuffer[demo-2]} {some spans}
    \stopcombination
\stopplacefigure

\stopsection

\startsection[title={Examples}]

On the following pages we show some examples of (experimental) features. For this
we will use the usual quotes from Ward, Tufte and Davis etc.\ that you can find
in the distribution.

\page

\startbuffer
\startxtable[bodyfont=6pt]
    \startxrow
        \startxcell \input ward  \stopxcell
        \startxcell \input tufte \stopxcell
        \startxcell \input davis \stopxcell
    \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startxtable[bodyfont=6pt,option=width]
    \startxrow
        \startxcell \input ward  \stopxcell
        \startxcell \input tufte \stopxcell
        \startxcell \input davis \stopxcell
    \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\page

\startbuffer
\startxtable[bodyfont=6pt]
    \startxrow
        \startxcell \externalfigure[cow.pdf][width=3cm] \stopxcell
        \startxcell \input tufte \stopxcell
        \startxcell \input davis \stopxcell
    \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startxtable[bodyfont=6pt,option=width]
    \startxrow
        \startxcell \externalfigure[cow.pdf][width=3cm] \stopxcell
        \startxcell \input tufte \stopxcell
        \startxcell \input davis \stopxcell
    \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\page

\startbuffer
\startxtable[option=stretch]
    \startxrow
        \startxcell bla \stopxcell
        \startxcell bla bla \stopxcell
        \startxcell bla bla bla \stopxcell
    \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startxtable[option={stretch,width}]
    \startxrow
        \startxcell bla \stopxcell
        \startxcell bla bla \stopxcell
        \startxcell bla bla bla \stopxcell
    \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\page

\startbuffer
\setupxtable[suffix][align=middle,foregroundcolor=red]
\setupxtable[blabla][foregroundstyle=slanted]
\setupxtable[crap]  [foregroundcolor=blue]
\setupxtable[bold]  [crap][foregroundstyle=bold]

\startxtable % [frame=off]
    \startxtablehead
        \startxrow[bold]
            \startxcell[suffix]       head a \stopxcell
            \startxcell[blabla]       head b \stopxcell
            \startxcell               head c \stopxcell
        \stopxrow
    \stopxtablehead
    \startxtablebody
        \startxrow
            \startxcell[suffix][ny=2] cell a 1 \stopxcell
            \startxcell               cell b 1 \stopxcell
            \startxcell               cell c 1 \stopxcell
        \stopxrow
        \startxrow
            \startxcell               cell b 2 \stopxcell
            \startxcell               cell c 2 \stopxcell
        \stopxrow
        \startxrow
            \startxcell[suffix]       cell a 3 \stopxcell
            \startxcell               cell b 3 \stopxcell
            \startxcell               cell c 3 \stopxcell
        \stopxrow
        \startxrow
            \startxcell[suffix]       cell a 4 \stopxcell
            \startxcell               cell b 4 \stopxcell
            \startxcell               cell c 4 \stopxcell
        \stopxrow
        \startxrow
            \startxcell[suffix]       cell a 5 \stopxcell
            \startxcell               cell b 5 \stopxcell
            \startxcell               cell c 5 \stopxcell
        \stopxrow
    \stopxtablebody
\stopxtable
\stopbuffer

\typebuffer \start \getbuffer \stop

\page

\startbuffer
\startxtable[option=stretch]
    \startxrow
        \startxcell[option=fixed] first cell \stopxcell
        \startxcell 101 \stopxcell
        \startxcell 102 \stopxcell
        \startxcell 103 \stopxcell
    \stopxrow
    \startxrow
        \startxcell 2\high{nd} cell \stopxcell
        \startxcell a \stopxcell
        \startxcell b \stopxcell
        \startxcell c \stopxcell
    \stopxrow
\stopxtable
\stopbuffer

\typebuffer \start \getbuffer \stop

\page

\startbuffer[demo]
\startxtable
\startxrow
    \startxcell[demo][nx=4] 1 / 2 / 3 / 4 \stopxcell
\stopxrow
\startxrow
    \startxcell[demo][nx=3] 1 / 2 / 3 \stopxcell
    \startxcell 4 \stopxcell
\stopxrow
\startxrow
    \startxcell 1 \stopxcell
    \startxcell[demo][nx=3] 2 / 3 / 4 \stopxcell
\stopxrow
\startxrow
    \startxcell[demo][nx=2] 1 / 2 \stopxcell
    \startxcell 3 \stopxcell
    \startxcell 4 \stopxcell
\stopxrow
\startxrow
    \startxcell 1 \stopxcell
    \startxcell[demo][nx=2] 2 / 3 \stopxcell
    \startxcell 4 \stopxcell
\stopxrow
\startxrow
    \startxcell 1 \stopxcell
    \startxcell 2 \stopxcell
    \startxcell[demo][nx=2] 3 / 4 \stopxcell
\stopxrow
\startxrow
    \startxcell[demo][nx=2] 1 / 2 \stopxcell
    \startxcell[demo][nx=2] 3 / 4 \stopxcell
\stopxrow
\startxrow
    \startxcell 1 \stopxcell
    \startxcell 2 \stopxcell
    \startxcell 3 \stopxcell
    \startxcell 4 \stopxcell
\stopxrow
\stopxtable
\stopbuffer

\startbuffer[tight]
\setupxtable[demo][option=tight]
\stopbuffer

\startbuffer[normal]
\setupxtable[demo][option=]
\stopbuffer

\typebuffer[demo]

\page

\typebuffer[tight]  \start \getbuffer[tight,demo]  \stop
\typebuffer[normal] \start \getbuffer[normal,demo] \stop

\page

\startbuffer
\startxtable[align={middle,lohi}]
  \startxrow
    \startxcell[ny=3] (1,3) \stopxcell
    \startxcell       (1,1) \stopxcell
    \startxcell       (1,1) \stopxcell
  \stopxrow
  \startxrow
    \startxcell       (1,1) \stopxcell
    \startxcell       (1,1) \stopxcell
  \stopxrow
  \startxrow
    \startxcell[nx=2] (2,1) \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startxtable[align={middle,lohi}]
  \startxrow
    \startxcell[ny=2] (1,2) \stopxcell
    \startxcell       (1,1) \stopxcell
    \startxcell       (1,1) \stopxcell
  \stopxrow
  \startxrow
    \startxcell       (1,1) \stopxcell
    \startxcell       (1,1) \stopxcell
  \stopxrow
  \startxrow
    \startxcell[nx=2] (2,1) \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startxtable[align={middle,lohi}]
  \startxrow
    \startxcell[ny=2] (1,2) \stopxcell
    \startxcell       (1,1) \stopxcell
    \startxcell       (1,1) \stopxcell
    \startxcell       (1,1) \stopxcell
  \stopxrow
  \startxrow
    \startxcell[nx=3] (3,1) \stopxcell
  \stopxrow
  \startxrow
    \startxcell[nx=4] (4,1) \stopxcell
  \stopxrow
\stopxtable
\stopbuffer

\typebuffer \getbuffer

\page

% \ruledhbox{\getbuffer[normal,demo]}

\startsection[title={Colofon}]

\starttabulate[|B|p|]
\NC author    \NC \getvariable{document}{author}, \getvariable{document}{affiliation}, \getvariable{document}{location} \NC \NR
\NC version   \NC \currentdate \NC \NR
\NC website   \NC \getvariable{document}{website} \endash\ \getvariable{document}{support} \NC \NR
\NC copyright \NC \symbol[cc][cc-by-sa-nc] \NC \NR
\stoptabulate

\stopsection

\stopdocument