summaryrefslogtreecommitdiff
path: root/info/laan/pwt/pwt.tab
blob: 43a535c135f08b7ecbf98781e838416346204d3a (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
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
\input blue.tex \loadindexmacros \report \hfuzz15pt

\bluechapter Tabular Material

\beginsummary
BLUe's format provides btable for the class of (simple) bordered tables.
It will be shown that this model can be used to format a wide variety 
of tables. 
Difference in representation can be obtained via attributes, i.e.,
without changing the markup.
Customization of the macro can be done by modification of the separators
for the caption, the columns, and the like.
The diversity of tabular material in general has been illustrated by
a kaleidoscope of tables borrowed from literature. 
For the latter group the markup is not necessarily restricted to 
btable or halign.
The example of how Knuth marked up real-life tables is illustrated by
his font charts.
\endsummary

The backbone of \bluetex's tables is |\btable|, to format a bordered table.
Other \TeX niques for formatting tables will be dealt with too.
The formatting of tables with simultaneous row and column spans
is a subject for the `educated layman,' not for the faint-hearted.

\bluehead Bordered table

A bordered table consists of 
a caption, 
a header, 
row stubs, 
a table proper, and
a footer, all with parameterized separators. 
Special cases occur when some of the elements are absent.

Abstraction from a ruled and a non-ruled table is realized at
the user level.
Ruled can be specified either as horizontal, vertical or both.
Dotted rules, also the partial ones, can be specified.
No variation in the line thicknesss has been coded.
Framing has been treated just as if a general document element 
has to be framed.
I chose to leave the caption and the footer outside the frame.\ftn{However,
   we can frame  any document element, can't we?}
The positioning of the elements can be specified as
centered, flushed left, or flushed right.
A ^{template} is provided by default.
Caption, border (first, header, row stubs), and footer can be specified;
all mutual orthogonal and independent of \cs{data}.
^^{bordered table model}

\bluesubhead Model

{\def\btablecaption{$\leftarrow$\hfill C a p t i o n\hfill$\rightarrow$}
\def\first{\hbox to6ex{\hss First\hss}}
\def\header{\hbox to18ex{\hss Header\hss}}
\def\rowstblst{{\hfil$\vcenter to20ex{\vss\offinterlineskip
                \fifo rowstblst\ofif\vss}$}}
\def\data{$\vcenter{\offinterlineskip\hbox{Table}\kern1ex\hbox{Proper}}$}
\def\footer{$\leftarrow$\hfill{\small F o o t e r}\hfill\hfill\hfill$\rightarrow$}
\def\fifo#1{\ifx\ofif#1\ofif\fi\process{#1}\fifo}\def\ofif#1\fifo{\fi}
\def\process#1{\hbox to0pt{\hss#1\hss}\kern.5ex}
\nonframed
$$\vcenter{\btable\data}$$
}%end scope
\TeX nically caption and footer are \cs{hbox}-es and table proper is an \cs{vbox}.
The separators of caption and footer are default \cs{medskip} and \cs{smallskip}.

\bluesubhead Markup tags

\bitem tags ^|\beginbtable| and |\endbtable|, or the shortcut |\btable|,
       and the column and row separator ^|\cs|, and ^|\rs|
\bitem defs to be redefined ^|\btablecaption|, ^|\first|,  
       ^|\header|, ^|\footer|, ^|\rowstblst|,
       (all defined empty by default)
\bitem table markup tags, ^|\logms|, ^{logical multispan} to
       span a number of {\em logical\/} columns
\bitem attributes
\itemitem{--} ^|\ruled|, ^|\hruled|, ^|\vruled|,   ^|\dotruled| \hfill
   Default:\hbox to13ex{\hfil^|\nonruled|}
\itemitem- ^|\framed|, ^|\dotframed| \hfill
   Default:\hbox to13ex{\hfil^|\nonframed|}
\itemitem- ^|\fll| (flushed left), ^|\flr| (flushed right) \hfill
   Default:\hbox to13ex{\hfil^|\ctr|}
\bitem token variables ^|\prebtable|, ^|\postbtable| for positioning
the table within the context.{\parindent0pt\ftn{In practice the math display is used
   most of the time.}}
\smallbreak

By the way the above model is an example of the markup
of a bordered table.\ftn{Admittedly a little complicated. Simpler
   examples will follow.} 
The markup reads as follows.

\beginverbatim
\def\btablecaption{$\leftarrow$\hfill C a p t i o n\hfill$\rightarrow$}
\def\first{\hbox to6ex{\hss First\hss}}
\def\header{\hbox to18ex{\hss Header\hss}}
\def\rowstblst{{\hfil$\vcenter to20ex{\vss\offinterlineskip
                \fifo rowstblst\ofif\vss}$}}
\def\process#1{\hbox to0pt{\hss#1\hss}\kern.5ex}
\def\data{$\vcenter{\offinterlineskip\hbox{Table}\kern1ex\hbox{Proper}}$}
\def\footer{$\leftarrow$\hfill{\small F o o t e r}\hfill\hfill\hfill
            $\rightarrow$}
$$\vcenter{\btable\data}$$
!endverbatim

\thissubhead{\runintrue}
\bluesubhead Customization\par
\cs{$\langle X\rangle$sep} are parameters,
which govern the kind of ^{separators}. 
The following are defaults to be customized.

\beginverbatim
\def\cellsize{\cvsize=4ex\tsht=.775\cvsize\tsdp=.225\cvsize}
\def\colsepsurround{\kern.5em}\def\captionsep{\medskip}\def\rowstbsep{\vrule}
\def\headersep{\hrule}\def\footersep{\smallskip}\def\template{}
!endverbatim

The positioning of the elements in the cells is parameterized
by \cs{lft} and \cs{rgt}. They are equal to \cs{hfil} by default.
A nice application is to make these equal to \$ in such a way that data
can be processed in math mode.

The empty template looks curious. 
The explanation is: when empty\Dash i.e., a user did not provide one\Dash
a standard template will be used.

\vfill\eject
\bluehead Use of btable macro

There are some pitfalls that I know of and that
a user might like to be aware of. ^^{btable, pitfalls}
\bitem When \cs{header}, \cs{footer} and the like are defined 
       they keep their value.
       So when you don't have a header in the next table, be sure that
       this definition is empty.
\bitem Most of the time I used  definitions with \cs{btable} instead of
       token variables. Beware.
\bitem To specify the row stub list separately from the data might yield
       a first column and a data part of unequal size. 
\bitem The ^|\cs| is ambiguous. In \bluetex{} it has the function to
       yield the argument as control sequence, while within btable
       the meaning is the column separator.
\bitem When verbatims are also part of the data process the table on the
       fly via \cs{beginbtable} \dots\thinspace \cs{endbtable}. However,
       there is a problem when the header and footer have to be processed
       on the fly too.
\bitem In the markup of the table in the  appendix `History of
       Changes,' the problems are the right line distances in a \cs{vtop}.
       The latter as element in the table.  
       It is caused by the \cs{tstrut}, table strut, 
       which is inserted at the end of each table row.
       See the script how to circumvent this problem.
\bitem The attribute \cs{dotruled} is not so general as \cs{ruled}
       or \cs{vruled}, because we lack the primitive \cs{vdotfill} 
       as a dotted alternative for \cs{vrule}. 
       For horizontal rules \TeX{} provides the primitives
       \cs{hrule} with the dotted variant \cs{dotfill}.
\smallbreak

In the examples of use below the invocation of \cs{data} could have been
hidden. 
However, in order to remain compatible with the situation where a user
wishes to forget about \cs{data} and provide the table entries directly
as argument to \cs{btable},  I refrained from that.
 
\blueexample Just data, magic squares

$$\def\data{2\cs7\cs6\rs 
            9\cs5\cs1\rs  
            4\cs3\cs8}
\vcenter{\framed\ruled\btable\data}\qquad\qquad\qquad
  \def\data{16\cs    3\cs    2\cs13\rs
             5\cs   10\cs   11\cs 8\rs
             9\cs    6\cs    7\cs12\rs
             4\cs   15\cs   14\cs 1}
 \def\template{\colsepsurround\lft{\oldstyle##}\rgt
               &&\lft##\rgt&\lft{\oldstyle##}\rgt\cr}
 \ruled\framed\setbox0=\btable\data%for measuring sizes
 \vcenter{\dotruled\dotframed\btable\data}\qquad$$
via
\begincenterverbatim
$$\def\data{2\cs7\cs6\rs 
            9\cs5\cs1\rs  
            4\cs3\cs8}
\vcenter{\framed\ruled\btable\data}\qquad\qquad\qquad
  \def\data{16\cs    3\cs    2\cs13\rs
             5\cs   10\cs   11\cs 8\rs
             9\cs    6\cs    7\cs12\rs
             4\cs   15\cs   14\cs 1}
 \def\template{\colsepsurround\lft{\oldstyle##}\rgt
               &&\lft##\rgt&\lft{\oldstyle##}\rgt\cr}
 \ruled\framed\setbox0=\btable\data%for measuring sizes
 \vcenter{\dotruled\dotframed\btable\data}\qquad$$
!endcenterverbatim
Remark. To introduce the ^|\oldstyle| elegantly I added
a template for the ^|\halign|. For doing this, awareness of
the physical columns is needed. Logically we are talking about
a {\oldstyle3}${*}${\oldstyle3} and {\oldstyle4}${*}${\oldstyle4} table.
Note that for dotted variants much more work has to be done.

\blueexample Data plus header, \TB{} {\oldstyle246}

^^{data with header}
$$\def\header{\hfill Year\hfill\cs
    \hfill World Population\hfill}
\def\data{8000 B.C.\cs  5,000,000\rs
            50 A.D.\cs200,000,000}
\flr\nonframed\vruled\vcenter{\btable\data}\qquad
              \ruled\vcenter{\framed\btable\data}$$
via the nearly descriptive markup

\beginverbatim
\def\header{\hfill Year\hfill\cs \hfill World Population\hfill}
\def\data{8000 B.C.\cs  5,000,000\rs 50 A.D.\cs200,000,000}
$$\flr\vruled\vcenter{\btable\data}\qquad\ruled\framed\vcenter{\btable\data}$$
!endverbatim 

\exercise How come that the left table contains a \cs{hrule}?
\answer The header separator is not influenced by the ruled
        attributes.

\blueexample Data with row stubs, \TB{} {\oldstyle232}

^^{data with row stubs}
\nonruled\nonframed\ctr%defaults
\begindemo
\def\rowstblst{{Horizontal lists}
     {Vertical lists}{Math lists}}
\def\rowstbsep{}%Customization 
\def\data{Chapter 14\rs
          Chapter 15\rs 
          Chapter 17}
$$\btable\data$$
!yields
\def\rowstblst{{Horizontal lists}
                 {Vertical lists}
                 {Math lists}}
  \def\rowstbsep{}
  \def\data{Chapter 14\rs 
            Chapter 15\rs 
            Chapter 17}
\btable\data
\enddemo

\exercise How can we obtain the same table without the use of \cs{rowstblst}?
\answer Just consider all as data.
\beginverbatim
Alternative
\def\data{Horizontal lists    \cs Chapter 14\rs
          Vertical lists\hfill\cs Chapter 15\rs
          Math lists\hfill    \cs Chapter 16}
$$\btable\data$$
!endverbatim

%end exercise

\blueexample Data, row stubs, header, caption and footer

^^{data with header, row stubs, caption and footer}
\nonruled\nonframed
$$\def\data{11\cs12\rs
            21\cs22}
  \vcenter{\framed\btable\data}      \qquad
  \def\header{\logms2\hfill Header\hfill}
  \def\rowstblst{{$1^{st}$ row}
                 {$2^{nd}$ row}}
  \vcenter{\btable\data}             \qquad
  \def\btablecaption{Caption}
  \def\footer{Footer}
  \vcenter{\dotruled\btable\data}    \qquad
  \vcenter{\ruled\framed\btable\data}
$$
after data definition, |\def\data| |{11\cs12\rs| |21\cs22}|,
via\ftn{Note the invariance of the
   {\tt\char92data} specification.}
\begincenterverbatim
$$\vcenter{\framed\btable\data}        \qquad
     \def\header{\logms2\hfill Header\hfill}
     \def\rowstblst{{$1^{st}$ row}
                    {$2^{nd}$ row}}
  \vcenter{\btable\data}               \qquad
    \def\btablecaption{Caption}
    \def\footer{Footer}
  \vcenter{\dotruled\btable\data}      \qquad
  \vcenter{\ruled\framed\btable\data}$$
!endcenterverbatim   
The above example shows in a nutshell the essential possibilities of
the \cs{btable} macro. It is my favorite, although other nice
and powerful examples are still to come.

\blueexample Walter's spreadsheet, \TB{} {\oldstyle244}

No preamble has to be defined. ^^{spreadsheet}
$$
\def\data{1\cs\logms2Adjusted gross income     \dotfill\cs \$4,000\rs
          2\cs Zero bracket amount for                            \rs
           \cs a single individual \dotfill\cs\hfill\$2,300\cs    \rs
          3\cs Earned income       \dotfill\cs
                                    \hfill\underbar{ 1,500}\cs    \rs
          4\cs\logms2Substract line 3 from line 2
                                  \dotfill\cs\hfill\underbar{ 800}\rs
          5\cs Add lines 1 and 4. Enter here                      \rs
           \cs\logms2and on Form 1040, line 35 \dotfill\cs\$4,800}
\def\colsepsurround{\kern.5ex}\cvsize=3ex
\fll\btable\data
$$
The above is marked up, as a 4-column table, via
\beginverbatim
\def\data{1\cs\logms2Adjusted gross income     \dotfill\cs \$4,000\rs
          2\cs Zero bracket amount for                            \rs
           \cs a single individual \dotfill\cs\hfill\$2,300\cs    \rs
          3\cs Earned income       \dotfill\cs
                                    \hfill\underbar{ 1,500}\cs    \rs
          4\cs\logms2Substract line 3 from line 2
                                  \dotfill\cs\hfill\underbar{ 800}\rs
          5\cs Add lines 1 and 4. Enter here                      \rs
           \cs\logms2and on Form 1040, line 35 \dotfill\cs\$4,800}
\def\colsepsurround{\kern.5ex}\cvsize=3ex
$$\fll\btable\data$$
!endverbatim 

\blueexample Spreadsheet digression

It happens that tables\Dash read budgets\Dash set by \AllTeX{} suffer from 
a simple addition flaw. 
Can't we add a {\em little\/} spreadsheet functionality to \TeX, i.e.,
let \TeX{} do the additions?\ftn{Courtesy
   Phil Taylor's Trigonometry \TeX, for the idea to use dimen vars and 
   how to remove the pt.
   Remember that \TeX{} allows {\oldstyle16} bit fixed-point arithmetic.
   It is limited to absolute values $<$ {\oldstyle16384}.}
\begingroup
\newdimen\a\newdimen\b\newdimen\c
\begindemo
\def\data{r1\cs     \ass\a{1.23} \rs
          r2\cs\ubp{\ass\b{4.56}}\rs
 \cs\cs\sumup{\a\b}\global\c\dimen0\rs
 \cs\cs\ubm{\ass\a{3.14}}\rs            
              \cs\cs\minus\c\a}
$$\btable\data$$ 
!yields
\def\ass#1#2{\global#1=#2pt#2}
\def\sumup#1{\global\dimen0=0pt
   \let\process\processsum\fifo#1\ofif}
\def\processsum#1{\global\advance\dimen0#1\relax}
\def\ofif#1\fifo{\fi\nodim\the\dimen0}
\def\minus#1#2{\global
\dimen0#1\global\advance\dimen0-#2
\nodim\the\dimen0}
%\nodim, i.e. \xs, strips pt from 
%        dimension quantity
{\catcode`\p=12 \catcode`\t=12 
 \gdef\xs#1pt{#1}}
\def\nodim{\expandafter\xs} 
%\underbar extended by + and -
\def\ubp#1{\underbar{#1}\rlap
 {\lower.8ex\hbox{\thinspace\small$+$}}}
\def\ubm#1{\underbar{#1}\rlap
 {\lower.8ex\hbox{\thinspace\small$-$}}}
%
\def\data{r1  \cs     \ass\a{1.23} \rs
          r2  \cs\ubp{\ass\b{4.56}}\rs
 \cs\cs\sumup{\a\b}\global\c\dimen0\rs
 \cs\cs\ubm{\ass\a{3.14}}\rs  
              \cs\cs\minus\c\a}
$$\btable\data$$ 
\enddemo
\endgroup
with auxiliaries
\beginverbatim
\newdimen\a\newdimen\b\newdimen\c
\def\ass#1#2{\global#1=#2pt#2}
\def\sumup#1{\global\dimen0=0pt\let\process\processsum\fifo#1\ofif}
\def\processsum#1{\global\advance\dimen0#1\relax}
\def\ofif#1\fifo{\fi\nodim\the\dimen0}
\def\minus#1#2{\global\dimen0#1\global\advance\dimen0-#2\nodim\the\dimen0}
%\nodim, i.e. \xs, strips pt from 
%        dimension quantity
{\catcode`\p=12 \catcode`\t=12 \gdef\xs#1pt{#1}}
\def\nodim{\expandafter\xs} 
%\underbar extended by + and -
\def\ubp#1{\underbar{#1}\rlap{\lower.8ex\hbox{\thinspace\small$+$}}}
\def\ubm#1{\underbar{#1}\rlap{\lower.8ex\hbox{\thinspace\small$-$}}}
!endverbatim

\blueexample Part of AAP's table, AAP {\oldstyle1989}

Subtle is the header part and the alignments on the signs. ^^{AAP table}
\def\nl{\hfil\strut\break\strut}
{%
\catcode`?=\active \def?{\kern1.1ex}
%
\def\btablecaption{AAP's table:\qquad Job Changes 
                                1973--1980\hfill}
\def\rowstblst{{Texas}{Maryland}}
\def\header{\copy1\cs\copy2\cs\copy3}
 \setbox1=\vtop{\noindent\hsize14ex
    Gain/Loss of\nl hospitals \nl since 1973}
 \setbox2=\vtop{\noindent\hsize13ex
    Total No\nl 
    of CEO Job\nl 
    Changes\nl 
    1973--90\strut}
 \setbox3=\vtop{\noindent\hsize10ex
    Survival\nl Rate of\nl CEO's}
\def\data{$+20$\cs---\cs22\%\rs
          $+?5$\cs 42\cs24\%}
\def\footer{Source: David Kinzer, `Turnover etc.}
$$\btable\data$$ 
}obtained via
\beginverbatim
\def\btablecaption{AAP's table:\qquad Job Changes 1973--1980\hfill}
\def\rowstblst{{Texas}{Maryland}}
\def\header{\copy1\cs\copy2\cs\copy3}
\def\data{$+20$\cs---\cs22\%\rs
          $+?5$\cs 42\cs24\%}
\def\footer{Source: David Kinzer, `Turnover etc.}
$$\btable\data$$
!endverbatim 
with auxiliaries
\beginverbatim
\def\nl{\hfil\strut\break\strut}
\catcode`?=\active \def?{\kern1.1ex}
\setbox1=\vtop{\noindent\hsize14ex Gain/Loss of\nl hospitals \nl since 1973}
\setbox2=\vtop{\noindent\hsize13ex Total No\nl of CEO Job\nl Changes\nl 1973--90}
\setbox3=\vtop{\noindent\hsize10ex Survival\nl Rate of\nl CEO's}
!endverbatim 
Remark. With longer footnotes put the text in a \cs{vtop},
with \cs{hsize} set to \cs{thsize}.\ftn{The table proper is first set
   in a box, and this box is measured yielding \cs{thsize} and \cs{tvsize}.
   After this the \cs{header} and \cs{footer} are set using the
   \cs{thsize}.}

\blueexample AT\&T table diversions, \TB{} {\oldstyle247}

Subtle is the alignment on the dot via the use of `?', \`a la Knuth,
and the |\llap\$|, and |\rlap*|.
^^{ATT table}
\def\rowstblst{}
{\def\btablecaption{AT\&T Common Stock\hfill}
\def\header{Year\cs Price\cs Dividend}
\catcode`?=\active \def?{\kern1.1ex}
\def\data{1971\cs41--54\cs\llap\$2.60\rs
             2\cs41--54\cs       2.70\rs
             3\cs46--55\cs       2.87\rs
             4\cs40--53\cs       3.24\rs
             5\cs45--52\cs       3.40\rs
             6\cs51--59\cs       ?.95\rlap*}
\def\footer{* (first quarter only)}
$$\framed\vcenter{\vbox{\small\btable\data}}\qquad\qquad
  \def\btablecaption{}
  \def\header{\logms3 \hfil AT\&T Common Stock\hfil\rs
    \hfill Year\hfill\cs\hfill Price\hfill\cs \hfill Dividend\hfill}
  \vcenter{\flr\ruled\btable\data}$$
}
via
\begincenterverbatim
\def\btablecaption{AT\&T Common Stock}
\def\header{Year\cs Price\cs Dividend}
\catcode`?=\active \def?{\kern1.1ex}
\def\data{1971\cs41--54\cs\llap\$2.60\rs
             2\cs41--54\cs       2.70\rs
             3\cs46--55\cs       2.87\rs
             4\cs40--53\cs       3.24\rs
             5\cs45--52\cs       3.40\rs
             6\cs51--59\cs       ?.95\rlap*}
\def\footer{* (first quarter only)}
$$\framed\vcenter{\vbox{\small
  \btable\data}}\qquad\qquad
%
\def\btablecaption{}
\def\header{\logms3 
   \hfil AT\&T Common Stock\hfil\rs
   \hfill Year\hfill\cs
   \hfill Price\hfill\cs 
   \hfill Dividend\hfill}
\vcenter{\flr\ruled\btable\data}$$
!endcenterverbatim      

\blueexample Pittman's deterministic multiplication table

Typographically and in other programming languages a trifle. 
In \TeX\ the coding matters. ^^{multiplication table}

\def\header{}
\def\rowstblst{}
\def\btablecaption{}\def\first{}\def\footer{}
\newcount\rcnt \newcount\ccnt \newcount\tnum
\newcount\mrow \newcount\mcol
\rcnt1 \ccnt1 
\def\rows{\global\ccnt1 \cols \global\advance\rcnt1
   \ifnum\rcnt>\mrow\swor\fi\rs\rows}
\def\swor#1\rows{\global\rcnt1 \global\ccnt1 \fi}
\def\cols{\tnum\rcnt \multiply\tnum\ccnt \the\tnum
   \global\advance\ccnt1 \ifnum\ccnt>\mcol\sloc\fi\cs\cols}
\def\sloc#1\cols{\fi}
%
\mrow2 \mcol3 $$\nonruled\nonframed
\vcenter{\btable\rows}\qquad\qquad
\def\first{$\times$}  \def\header{\row}
\def\row{\the\ccnt\global\advance\ccnt1
   \ifnum\ccnt>\mcol\wor\fi\cs\row}
\def\wor#1\row{\fi}
\def\rowstblst{{Anything, non-empty}}
\def\nxtrs{\the\rcnt\rss}
\vcenter{\btable\rows}\qquad\qquad
%
\mrow3 \mcol4 \def\rowstblst{{Anything, non-empty}}
\framed\vcenter{\btable\rows}
$$
via
\beginverbatim
\newcount\rcnt\newcount\ccnt\newcount\tnum\newcount\mrow\newcount\mcol
\rcnt1 \ccnt1 \mrow2 \mcol3
\def\rows{\global\ccnt1 \cols \global\advance\rcnt1
   \ifnum\rcnt>\mrow\swor\fi\rs\rows}
\def\swor#1\rows{\global\rcnt1 \global\ccnt1 \fi}
\def\cols{\tnum\rcnt\multiply\tnum\ccnt\the\tnum\global\advance\ccnt1 
   \ifnum\ccnt>\mcol\sloc\fi\cs\cols}           \def\sloc#1\cols{\fi}
$$\mrow2 \mcol3 \vcenter{\btable\rows}\qquad\qquad
%
\def\first{$\times$}  \def\header{\row}
\def\row{\the\ccnt\global\advance\ccnt1 \ifnum\ccnt>\mcol\wor\fi\cs\row}
\def\wor#1\row{\fi} %\def\rowstblst{{1}{2}}%Fully automated via the two defs
   \def\rowstblst{{Anything, non-empty}}    \def\nxtrs{\the\rcnt\rss}
\vcenter{\btable\rows}\qquad\qquad
%
\mrow3 \mcol4 %\def\rowstblst{{1}{2}{3}}%Fully automated via the two defs
   \def\rowstblst{{Anything, non-empty}}     \def\nxtrs{\the\rcnt\rss}
\framed\vcenter{\btable\rows}$$
!endverbatim

%Back to defaults
\def\header{}\def\rowstblst{}\def\btablecaption{}\def\first{}\def\footer{}

\vfill\eject
\bluehead Kaleidoscope

Some examples of special tables are given in order to illustrate the
diversity. The markup is not restricted to the use of \cs{btable}. 
With respect to programming, the deterministic tables and
the tables which update the computer memory, deserve special attention.
The latter category is induced by {\em computer\/} typography.

\blueexample Young tableaux, irregular shape, Knuth {\oldstyle1973}
 
^^{Young tableaux}
\begindemo
\newdimen\csize\csize=3ex
\newcount\cnt
\def\young#1{\hbox{\vrule\vtop{\hrule
   \offinterlineskip\halign{&\vbox
   {\hbox to\csize{\strut\hss##\hss
   \vrule}\hrule}\cr%template
#1\crcr}}}}%end \young
\catcode`'=13\relax 
\def'{\global\advance\cnt1 \the\cnt}
\def\data{'&'&'&'\cr'&'&'\cr'}
\young\data
\def\data{7&8&9&10\cr9&11\cr16\cr}
\young\data
!yields
\newdimen\csize\csize=3ex
\newcount\cnt
\def\young#1{\hbox{\vrule\vtop{\hrule
   \offinterlineskip\halign{&\vbox
   {\hbox to\csize{\strut\hss##\hss
   \vrule}\hrule}\cr%template
#1\crcr}}}}%end \young
\catcode`'=13\relax 
\def'{\global\advance\cnt1 \the\cnt}
\def\data{'&'&'&'\cr'&'&'\cr'}
\leavevmode\qquad\young\data\qquad
\def\data{7&8&9&10\cr9&11\cr16\cr}
\young\data
\enddemo

\blueexample Pascal triangle, a deterministic table

^^{Pascal triangle}
\begindemo
$$\displaylines{1\cr
  1\quad1\cr
  1\quad2\quad1\cr
  1\quad3\quad3\quad1\cr}$$
!yields\hsize=10em
$$\displaylines{1\cr
  1\quad1\cr
  1\quad2\quad1\cr
  1\quad3\quad3\quad1\cr}$$
\enddemo
\exercise The Pascal triangle is deterministic. Write a macro 
          |\def\pascal#1{...}| which provides the table with the
          order as argument.
\answer The macro and auxiliaries read as follows.
\thisverbatim{\unmc}
\beginverbatim
\newcount\n
\newcount\rcnt  \newcount\ccnt 
\newcount\tentry\newcount\prev
%
\def\pascal#1{\n#1 \def\0{1} \ccnt1
   \loop\ea\xdef\csname\the\ccnt\endcsname{0}
     \ifnum\ccnt<\n \advance\ccnt1
   \repeat\rcnt0 \ccnt0
   \displaylines{\rows}}
%
\def\rows{\global\advance\rcnt1 
 \ifnum\rcnt>\n \swor\fi
 \nxtrow\rows}
%
\def\swor#1\rows{\fi}
%
\def\nxtrow{1 \ccnt1 \prev1
 \loop\ifnum\ccnt<\rcnt
  \tentry\prev
  \prev\csname\the\ccnt\endcsname
  \advance\tentry\prev
  \ea\xdef\csname\the\ccnt\endcsname{\the\tentry}
  \quad\the\tentry
  \advance\ccnt1
 \repeat\cr}
!endverbatim

%above blank line terminates answer.
           
\blueexample Tower of Hanoi,  deterministic

The process of replacement of the disks will be printed
by the invocation of |\hanoi<n>|, $n$ an integer.
No user markup is needed. ^^{tower\ of\ Hanoi}
\begindemo
\hanoi2 
%or
\beginhanoi2\endhanoi
!yields
\hanoi2
\enddemo

\blueexample Chart, \TB{} ex{\oldstyle22}.{\oldstyle14} {\oldstyle248} 

^^{chart}%but elaborated differently.
{\small
\newdimen\dist \dist=2\baselineskip
\def\ent#1{\hbox{\vbox to 0pt
{\vss\hbox to10ex{\quad\strut#1\hss}
                           \hrule}}}
\def\vl#1{\hbox{\vrule height#1\dist
depth0pt}}%Vertical Line of prop. size
\def\bl#1{\kern#1\dist}%BLank of prop. size
%Balanced
$$\offinterlineskip
 \vcenter{\ent{abc}}
 \vcenter{\ent{de}
          \vl2
          \ent{fg}}
 \vcenter{\ent{hij}
          \vl1
          \ent{klm}
          \bl1
          \ent{nop}
          \vl1
          \ent{qrs}}
\quad%Nearly balanced tree; pruning a branch
 \vcenter{\ent{abc}}
 \vcenter{\ent{de}
          \vl2
          \ent{fg}}
 \vcenter{\ent{hij}
          \vl{.5} %\bl{.5}<-|
 %        \ent{klm}         |
          \bl{1.5}%       <-|
          \ent{nop}
          \vl1
          \ent{qrs}}$$   }%end scope

via the following alternative code without \cs{halign}

\begincenterverbatim
\newdimen\dist \dist=2\baselineskip
\def\ent#1{\hbox{\vbox to0pt{\vss\hbox to10ex{\quad
                             \strut#1\hss}\hrule}}}
\def\vl#1{\hbox{\vrule height#1\dist depth0pt}}
\def\bl#1{\kern#1\dist}%BLank of proper size
%Balanced
$$\offinterlineskip
 \vcenter{\ent{abc}}
 \vcenter{\ent{de} \vl2\ent{fg}}
 \vcenter{\ent{hij}\vl1\ent{klm}\bl1\ent{nop}\vl1\ent{qrs}}
\quad%Nearly balanced tree; pruning a branch
 \vcenter{\ent{abc}}
 \vcenter{\ent{de} \vl2\ent{fg}}
 \vcenter{\ent{hij}\vl{.5}%\bl{.5}\ent{klm}
                         \bl{1.5}\ent{nop}\vl1\ent{qrs}}$$
!endcenterverbatim    

\blueexample Binary tree

The nodes are identified via Dewey's decimal notation, similar to
a ToC in a book. 
For example, node {\oldstyle11} is the left most node at the first level.
The user must supply within the environment ^|\beginbintree|   \cs{endbintree} 
the pairs of node numbers and node contents, with at the end the
level of the tree.
A node which is not specified will not show. 

The syntax of the invocation reads
\begincenterverbatim
\beginbintree<nodeno><nodevalue>
              ...
             <nodeno><nodevalue>
<levelno>\endbintree
!endcenterverbatim
$$\thisbintree{\tophns13ex} 
  \beginbintree{00}1{11}6{12}7{21}2{22}3{23}4
  2\endbintree
  \raise13ex\hbox{$\buildrel heap\over \longrightarrow$}
  \thisbintree{\tophns13ex} 
  \beginbintree{00}7{11}6{12}4{21}3{22}2{23}1
  2\endbintree
$$
\begincenterverbatim
$$\thisbintree{\tophns13ex} 
  \beginbintree{00}1{11}6{12}7{21}2{22}3{23}4
  2\endbintree
  \raise13ex\hbox{$\buildrel heap\over \longrightarrow$}
  \thisbintree{\tophns13ex} 
  \beginbintree{00}7{11}6{12}4{21}3{22}2{23}1
  2\endbintree
$$
!endcenterverbatim

\blueexample Dewey's decimal notation

$$\beginbintree{00}{$root$}
      {11}{$n_{11}$}
      {12}{$n_{12}$}
      {21}{$n_{21}$}
      {22}{$n_{22}$}
      {23}{$n_{23}$}
      {24}{$n_{24}$}
      {35}{$n_{35}$}
      {36}{$n_{36}$}
      {49}{$n_{49}$}
      {410}{$n_{410}$}
4\endbintree$$
\vskip-2.5\bigskipamount
\begincenterverbatim
$$\beginbintree{00}{$root$}
   {11}{$n_{11}$}{12}{$n_{12}$}
   {21}{$n_{21}$}{22}{$n_{22}$}{23}{$n_{23}$}{24}{$n_{24}$}
     {35}{$n_{35}$}{36}{$n_{36}$}
       {49}{$n_{49}$}{410}{$n_{410}$}
4\endbintree$$  
!endcenterverbatim

\blueexample Bitstreams as names of nodes

^^|\beginbt|\thisbt{\xoffset{-400}}%Interactive binary tree traversal
\beginbt 1 NTG member?
10 Plain TeX ie?
100 Honoured?
1000 cgl
1001 HH
101 On board?
1010 Chair?
10100 Erik
10101 Secretary?
101010 Gerard
101011 Treasurer?
1010110 Wietse
1010111 Dark?
10101110 JLB
10101111 FG
1011 Anonymous
11 Just a friend
8 \endbt
The above b(inary)t(ree)\ftn{Courtesy Bernd Raichle.} is not foolproof and suffers from 
overprinting of the leaves with a tree of depth {\oldstyle10} or so. 
Note that the specification of the nodes is on a line by line basis\Dash
   \cs{obeylines} is on\Dash and 
that each node and its contents is separated by a space. 
The last line must contain the number of levels\Dash
    used to create the niche for the tree\Dash
and the closing tag \cs{endbt}, again separated by a space.
By adopting these conventions no curly braces were needed.\ftn{The above ideas 
   emerged from an interactive traversal of a  binary tree in a guess
   who-is-who game. The programming is such that it can be extended easily to
   a trinary or higher-order tree. The overprinting drawback remains, however.
   Alexander Calder might have appreciated these `mobiles,' \winksmiley.}
\begincenterverbatim
\thisbt{\xoffset{-400}}
\beginbt 1 NTG member?
10 Plain TeX ie?
100 Honoured?
1000 Kees
1001 HH
101 On board?
1010 Chair?
10100 Erik
10101 Secretary?
101010 Gerard
101011 Treasurer?
1010110 Wietse
1010111 Dark?
10101110 JLB
10101111 FG
1011 Anonymous
11 Just a friend
8 \endbt
\bye
!endcenterverbatim
There are some special tree packages. Gurari is strong with respect to
diagrams in general and trees in particular.

\blueexample Maze
 
%Labyrinth via TeX, just an experiment  feb 92.
%Assumed is a closed rule on top and to the right
%| and _ denote the rules to mark the labyrinth
%Labyrinth proper
\thisverbatim{\catcode`\|=12 } ^^{maze}
\begindemo
\catcode`|=13 \def|{\vrule}
\catcode`_=13 \def_{\hrulefill}
$$\vcenter{\hbox{\vtop{\hrule
\offinterlineskip
\halign{&\hbox to\csize{\vrule 
  height\csize width0pt#\hfil}\cr
          |&_&|_& \cr
           &|&_&  \cr
          |&|_&_&|\cr
          |_& &_&_\cr}%end \halign
 }\vrule%end \vbox
 }%end \hbox
!yields
\newdimen\csize \csize=3ex
\catcode`|=13 \def|{\vrule}
\catcode`_=13 \def_{\hrulefill}
\qquad\hbox{\vtop{\offinterlineskip
   \hrule\halign{&\hbox to\csize
   {\vrule height\csize width0pt
    #\hfil}\cr
        |&_&|_& \cr
         &|&_&  \cr
        |&|_&_&|\cr
        |_& &_&_\cr}%end \halign
 }\vrule%end \vbox
 }%end \hbox
\enddemo

\blueexample Crosswords: puzzle, clues and solution

^^{crosswords}
\begincrosswords
$$\bdata%
P*On
DEk*
*n*S
Edit
\edata
\vcenter{\sevenrm\csize=3ex\crw}
\vcenter{\parindent=5ex
\vtop{\hsize=21ex\obeylines Across
2 Switch mode
3 Knuth
6 Prior to \TeX}}
\vcenter{\parindent=3ex
\vtop{\hsize=25ex\obeylines Down
1 Public domain
2 All right
4 All comes to it
5 Atari type}}
\vcenter{\fiverm\csize=3ex\sol}$$
\endcrosswords
The above is obtained essentially via
\begincenterverbatim
\begincrosswords
$$\bdata%
P*On
DEk*
*n*S
Edit
\edata
\vcenter{\sevenrm\csize=3ex\crw}
<Clues>
\vcenter{\fiverm\csize=3ex\sol}$$
\endcrosswords
!endcenterverbatim

\blueexample Much alignment occurs in typesetting mathematics
 
Aligned equations in display, matrices, and 
the complex commutative diagrams. 
This has been dealt with elsewhere, 
for example Knuth {\oldstyle1984}, and Spivak {\oldstyle1989}. 
Also typesetting of program texts requires vertical alignment.

\blueexample Chess boards
 
The first board has been marked up via ^|\leaders|,\ftn{Courtesy
          David Salomon.} 
horizontally and vertically. ^^{chess}
The second is obtained via (a degenerate use of \winksmiley ) 
the crossword macro.
{\newdimen\unitlength \unitlength3ex
\begindemo
\unitlength3ex
\boxit{\vbox{\leaders
 \vbox{\offinterlineskip
  \hbox{\leaders\hbox{%
   \kern\unitlength
   \vrule width\unitlength 
          height\unitlength
  }\hskip8\unitlength
  }\hbox{\leaders\hbox{\vrule 
    width\unitlength 
    height\unitlength
    \kern\unitlength
  }\hskip8\unitlength
  }}\vskip8\unitlength}}
!yields
\boxit{\vbox{\leaders
 \vbox{\offinterlineskip
  \hbox{\leaders\hbox{%
   \kern\unitlength
   \vrule width\unitlength 
          height\unitlength
  }\hskip8\unitlength
  }\hbox{\leaders\hbox{\vrule 
    width\unitlength 
    height\unitlength
    \kern\unitlength
  }\hskip8\unitlength
  }}\vskip8\unitlength}}
\enddemo}

\begindemo
\begincrosswords
\obeyspaces\let =\space
\csize=3ex
\bdata%
8 * * * *
7* * * * 
6 * * * *
5* * * * 
4 * * * *
3* * * * 
2 * * * *
1* * * * 
*ABCDEFGH
\edata
\sol
\endcrosswords
!yields
\begincrosswords
\obeyspaces\let =\space
\csize=3ex
\bdata%
8 * * * *
7* * * * 
6 * * * *
5* * * * 
4 * * * *
3* * * * 
2 * * * *
1* * * * 
*ABCDEFGH
\edata
\sol
\endcrosswords
\enddemo
\exercise How can we add field indicators on top and to the right?
\answer Extend the data by the numbers at the end of each row, and
        copy the last row also on top.
\beginverbatim
\bdata%
*ABCDEFGH*
8 * * * *8
7* * * * 7
6 * * * *6
5* * * * 5
4 * * * *4
3* * * * 3
2 * * * *2
1* * * * 1
*ABCDEFGH*
\edata
!endverbatim

\exercise How can we diminish the ^{optical illusion}
          of the border?
\answer Make the border thicker. For example via
        |\boxit{\boxit{\sol}}|. Why don't you develop a nice border macro?

\exercise How can we add pieces to the board?
\answer Chess pieces are available in a font. Similar to the letters in the
        solution of the crosswords we can put in pieces. For example let us
        assume for simplicity's sake that K denotes the white king then 
        the following yields the requested result.
\beginverbatim
\begincrosswords
\obeyspaces\let =\space
\csize=3ex
\bdata%
8 * * * *
7* * * * 
6 * * * *
5* * * * 
4 *K* * *
3* * * * 
2 * * * *
1* * * * 
*ABCDEFGH
\edata
\boxit{\boxit{\sol}}
\endcrosswords
!endverbatim

%blank line is needed, to close answer.
The above entails that we are on the way to generate any board and 
just add the pieces, all based on the crosswords macro approach.

\blueexample Optical illusion

Again a nice application of the use of ^|\leaders|,\ftn{For \cs{soto} and
    and \cs{sot} see the script file.}
horizontally and vertically. When I submitted my crosswords macro to \TUB{}
it was refused because of the wiggling of the frame!?! There the similar
effect is on with neighbouring black and white squares.
The black squares look smaller than the white squares, 
yielding a ^{wiggling illusion}.

\newdimen\unitlength \unitlength5ex
\newbox\soto\setbox\soto\vbox{\hrule height1exwidth5ex\relax
        \hbox to5ex{\vrule width1exdepth0pt\relax
         \hss\vrule height3exwidth1exdepth0pt}%
        \hrule height1exwidth5ex\relax}
{\newdimen\unitlength \unitlength5ex
\newbox\sot
\setbox\sot\vbox to\unitlength{\vss
        \hbox to\unitlength{\hss
         \vrule height.6\unitlength
                width.6\unitlength 
                depth0pt\hss}%
        \vss}

\smallskip
\begindemo
\boxit{\vbox{\leaders\vbox{%
  \offinterlineskip\hbox{\leaders
   \hbox{\copy\soto\copy\sot}%
   \hskip30ex}%
  \hbox{\leaders
   \hbox{\copy\sot\copy\soto}%
   \hskip30ex}}%
  \vskip30ex}}
!yields
\boxit{\vbox{\leaders\vbox{\offinterlineskip
   \hbox{\leaders\hbox{\copy\soto\copy\sot}\hskip30ex}%
   \hbox{\leaders\hbox{\copy\sot\copy\soto}\hskip30ex}}%
   \vskip30ex}}
\enddemo

\blueexample Soto's kinetic art

\begindemo
\leavevmode
%background
\hbox{\xleaders\hbox to.5ex{\hss
   \vrule height6\unitlength\hss
   }\hskip6\unitlength
   }\kern-6\unitlength
%the squares
\boxit{\vbox{\offinterlineskip
   \leaders\hbox{\leaders\copy\sot
      \hskip6\unitlength
   }\vskip6\unitlength}}
!yields
\leavevmode
\hbox{\xleaders\hbox to.5ex{\hss
   \vrule height6\unitlength\relax\hss
   }\hskip6\unitlength}\kern-6\unitlength
%the squares
\boxit{\vbox{\offinterlineskip
   \leaders\hbox{\leaders\copy\sot
      \hskip6\unitlength}\vskip6\unitlength}}
\enddemo
}

\blueexample Row and/or column spans, partial horizontal rules

^^{row\ and\ column\ spans}
%Fill-in form bridge
\nonruled\ctr\framed \def\rowstblst{}
{\small%\defaults
\newcount\bcnt
\def\lines{\global\advance\bcnt by1 \ifnum\bcnt=3 et cetera\hidewidth
   \senil\fi\the\bcnt.\cs\cs\cs\cs\cs\cs\rs\lines}
\def\senil#1\lines{\fi}
\thisbtable{
\def\ghostrow{\omit\colsepsurround%
  \vbox to0pt{\vss\hbox to5ex{\hss Pair\hss}\vskip.5ex
          \hbox to5ex{\hss No\hss}\vss}\prs\logms2\lineglue\srp
  \vbox to0pt{\vss\hbox to5ex{\hss Re-\hss}\vskip.5ex
          \hbox to5ex{\hss sults\hss}\vss}\prs\logms2\lineglue\srp
  \vbox to0pt{\vss\hbox to15ex{\hss Game \dots\hss}\vskip1.5ex
           \hbox to15ex{\hss MP$\,$s\hss}\vss}\colsepsurround\cr}
\def\header{\cs\logms2\hfil Contract\hfil\cs
                          \cs\logms2\hfil Scores\hfil\cs\grs
            \cs N--S\cs E--W\cs\cs N--S\cs E--W\cs}
}
$$ \framed\ruled\btable\lines$$
}%end scope
\beginverbatim
\newcount\bcnt
\def\lines{\global\advance\bcnt by1 \ifnum\bcnt=3 et cetera\hidewidth
   \senil\fi\the\bcnt.\cs\cs\cs\cs\cs\cs\rs\lines}
\def\senil#1\lines{\fi}
\thisbtable{
\def\ghostrow{\omit\colsepsurround%
  \vbox to0pt{\vss\hbox to5ex{\hss Pair\hss}\vskip.5ex
          \hbox to5ex{\hss No\hss}\vss}\prs\logms2\lineglue\srp
  \vbox to0pt{\vss\hbox to5ex{\hss Re-\hss}\vskip.5ex
          \hbox to5ex{\hss sults\hss}\vss}\prs\logms2\lineglue\srp
  \vbox to0pt{\vss\hbox to15ex{\hss Game \dots\hss}\vskip1.5ex
           \hbox to15ex{\hss MP$\,$s\hss}\vss}\colsepsurround\cr}
\def\header{\cs\logms2\hfil Contract\hfil\cs
                          \cs\logms2\hfil Scores\hfil\cs\grs
            \cs N--S\cs E--W\cs\cs N--S\cs E--W\cs}
}
$$ \framed\ruled\btable\lines$$
!endverbatim
\exercise How many rows does the header have? 
\answer Descriptive {\oldstyle1}, visual {\oldstyle2}, and for
        plain \TeX\ formatting {\oldstyle3}. 
        It is all a matter of point of view.

\exercise The above ^{recursive markup} of the data is elegant, especially
   when the table is large.
   Simplify the markup by abandoning the independence of size,
   i.e., provide the data explicitly instead of recursively.
\answer The `data' can be defined as follows.
\beginverbatim 
\def\data{1.\cs\cs\cs\cs\cs\cs\rs
          2.\cs\cs\cs\cs\cs\cs\rs
          et cetera\hidewidth}
!endverbatim

\blueexample Bridge pair match scheme, with special `first' element

$$\def\first{\thispicture{\unitlength=6ex \xdim{1.4}\ydim{1}}%
  \lower1.5ex\hbox\beginpicture%(1.4, 1)(0,-.1)
  \put( 0.0, 0.0){\small \strut Round}%
  \put( 1.4, 0.575){\llap{\small Game}}%
  \put( 1.4, 0.1){\line(-2, 1){1.4}}%
\endpicture\lower2ex\null}
\def\header{%
  1--3 \cs 4--6 \cs 7--9 \cs 10--12\cs13--15\cs 16--18 \cs 19--21} 
\def\rowstblst{{1.}{2.}{et cetera}}
\def\data{%
1--2   \cs       \cs     \cs2: 3--4\cs        \cs3: 5--6 \cs4: 7--8\rs 
4: 8--3\cs1: 1--6\cs     \cs       \cs2: 5--7 \cs        \cs3: 2--4\rs 
       %\cs       \cs     \cs       \cs        \cs        \cs      \rs 
}
\framed\ruled\btable\data
$$via
\beginverbatim
\def\first{\thispicture{\unitlength=6ex\xdim{1.4}\ydim{1}}%   
  \lower1.5ex\hbox\beginpicture%(1.5, 1)(0,-.1)
  \put( 0.0, 0.0){\small \strut Round}%
  \put( 1.4, 0.575){\llap{\small Game}}%
  \put( 1.4, 0.1){\line(-2, 1){1.4}}%
\endpicture
\lower2ex\null
}
\def\header{%
  1--3 \cs 4--6 \cs 7--9 \cs 10--12\cs13--15\cs 16--18 \cs 19--21} 
\def\rowstblst{{1.}{2.}{et cetera}}
\def\data{%
1--2   \cs       \cs     \cs2: 3--4\cs        \cs3: 5--6 \cs4: 7--8\rs 
4: 8--3\cs1: 1--6\cs     \cs       \cs2: 5--7 \cs        \cs3: 2--4\rs 
       %\cs       \cs     \cs       \cs        \cs        \cs      \rs    
}
\framed\ruled\btable\data
!endverbatim
Remark. The need for centering the first row is induced by
\cs{first}. It is elegant to solve the problem for that in ^|\first|.

\exercise How can we center the numbers in the first column?
\answer Add \cs{hfil} in the \cs{rowstblst} via
   \beginverbatim
   \def\rowstblst{{\hfil1.}{\hfil2.}{et cetera}}
   !endverbatim
   Another solution is the following template
   \beginverbatim
   \def\template{\colsepsurround\hfil##\hfil&&\lft##\rgt\cr}
   !endverbatim

\blueexample Alignment at decimal points

Generally this is done by introducing an extra column for the dot, 
and flushing right the digits left and
flushing left the digits right of it.  
It comes from the wish not to print
non-significant leading zeroes, and to suppress
zeroes behind the point for exact numbers. 
{\oldstyle3}.{\oldstyle5} means exactly  3${1\over2}$.
{\oldstyle3}.{\oldstyle500} means accurate to three digits. 
I would mark up the numbers separately and 
insert Knuth's `?', \TB{} {\oldstyle240}\dash{\oldstyle241},
for non-signicant zeroes, automatically. 
The latter can also be done by programming the editor by a template 
consisting of sufficient ?-s followed by the decimal point. 
The numbers required can be brought in by overtyping
the template. 
Related to ^{alignment at decimal point}s is 
           ^{alignment at number sign}s,\ftn{Another column for the signs
       offends the structure.
       At a lower level one could think of {\tt\char92scs},
       a Sign Column Separator, but that is not nice either.} 
see the AAP table.

\blueexample Nested table

A ruled table with unruled tables as data is incorporated in the chapter
`Creating an index,' to illustrate the ordering choices. See the script.

^^{nested table}
\blueexample Nested, and interrupted table with updating of memory

From the user level one would say:
aligned material connected by text, where the latter
in the case at hand is the status of the play.
For the markup see the script.

\beginbridge
{\small 
%bridge data
\def\LFTINF{Puzzle}
\def\RGTINF{\vtop{\hbox{6NT,}
             \hbox{by East}}}
%
\Ns={KQ76}\Es={T9}\Ss={8542}\Ws={AJ3}
\Nh={J98} \Eh={A2}\Sh={QT74}\Wh={K653}
\Nd={J942}\Ed={T5}\Sd={Q876}\Wd={AK3}
\Nc={65}\Ec={KJ9xxxx}\Sc={2}\Wc={AQT}
\showgame
\LEADS\bplay
h4! & hK & h8 & h2 & --& 1\LEADW\cr
cA  & c5 & cx & c2 & --& 2\cr
cQ  & c6 & cx & s2 & --& 3\cr
cT  & h9 & cK & s4 & --& 4\LEADE\cr
cJ  & s5 & s3 & s6 & --& 5\cr
c9  & s8 & h5 & s7 & --& 6\cr
cx  & d6 & sJ & d2 & --& 7\cr
\bintermezzo
\def\RGTINF{\vtop{\hbox to 0pt{NS squeezed on\hss}
             \hbox to 0pt{\cl\ continuation?\hss}
             \hbox to 7ex{\hss}}} %phantom for alignment
\Ec={{\ooalign{\hfil\raise.07ex%
    \hbox{x}\hfil\crcr\mathhexbox20D}}}
\showgame  \Ec={x}
\eintermezzo
cx & h7 & h6 & hJ & --& 8\cr
\omit et cetera \hidewidth \cr
\eplay
}%end of scope
\endbridge

Tables which also require updating of memory
occur with typesetting of chess,
for example Tutelaers {\oldstyle1992}, or 
GO, Ko{\l}odziejska {\oldstyle1991}.

\blueexample Fill-in forms
 
The registration forms for the various \TeX{} conferences are captivating. 
Now and then I ponder about the
e-mail equivalents of the traditional snail forms, especially what
(and how they) should be filled in.  
Redefine a list of empty definitions?

\blueexample Time tables

Railway, bus, \dots\thinspace, and the use of rotated fonts.
This is a \PS{} issue.

\blueexample No markup

For simple tables the data can be  specified {\em without\/}
\cs{cs}-s, and \cs{rs}-s,
i.e., without explicit markers for column and row separators. 
These can be inserted by \TeX, see \TB{} {\oldstyle249}.
For special cases, for example  centering texts\ftn{See the implementation
    of \cs{center} in the file.}
and crosswords, this is handy. ^^{no markup}

\thissubhead{\runintrue}
\bluesubhead Pondering about lists\par makes you realize that the table proper data forms
a nested list with \cs{rs} and \cs{cs}, respectively first level
and second level separators. One could also adopt |<cr>|
and {\tt\char32} for that, in other words allow natural data provision.

\blueexample Simultaneous row spans

Simultaneous column spans can be marked up in \cs{btable} by
\cs{logms}---for logical columns,
as an extension to \cs{multispan} for \cs{halign}. ^^{row\ spans}
For row spans start from \cs{valign}, the transposition of \cs{halign}.
A little more than the analogy of transposition is needed.
From the \TeX-nl list the following example of spans over rows.
\begindemo
\hbox{\vrule\valign{&\hrule\vfil
  \noindent\hsize15ex\strut
  \xsp#\xsp\vfil\hrule\cr
\multispan3{\hrule\vfil
  \vbox{\noindent\hsize15ex\strut
   \xsp This\\
   \xsp looks\\
   \xsp problematic}}\vfil
   \hrule&
   Doesn't it?\cr
\noalign{\vrule}
\hfill22 &%space needed
\hfill12 &
\hfill1943 &
\hfill190 \cr}\vrule}
%with auxiliary
\def\xsp{\hbox{ }}
!yields
\def\xsp{\hbox{ }}
\hbox{\vrule\valign{&\hrule\vfil
  \noindent\hsize15ex\strut
  \xsp#\xsp\vfil\hrule\cr
\multispan3{\hrule\vfil
  \vbox{\noindent\hsize15ex\strut
   \xsp This\\
   \xsp looks\\
   \xsp problematic}}\vfil
   \hrule&
   Doesn't it?\cr
\noalign{\vrule}
\hfill22 &%space needed
\hfill12 &
\hfill1943 &
\hfill190 \cr}\vrule}
\enddemo
As can be seen from this difficult example, we have to fall back
on lower level details now and then.
\exercise Modify the above towards a ^|\vtable| macro, such that we can use
          the attributes \cs{ruled}, \cs{vruled}, \cs{hruled}, with
          default \cs{nonruled}, and \cs{framed} and \cs{nonframed}.^^|\valign|
\answer  As a parameter I provided the \cs{hsize} of the table entries. 
         For row spans the \cs{logms}, logical multispan, has been used, 
         similar as for \cs{btable}.
\beginverbatim
\def\xsp{\hbox{ }}
\def\vruled{\def\colsep{\vrule}\def\rowsep{}}
\def\hruled{\def\colsep{}\def\rowsep{\hrule}}
\def\ruled{\def\colsep{\vrule}\def\rowsep{\hrule}}
\def\nonruled{\def\colsep{}\def\rowsep{}}
\def\framed{\let\frameit\boxit}
\def\nonframed{\def\frameit##1{##1}}
\def\rs{&\null\rowsepsurround\rowsep\rowsepsurround&}
\def\cs{\lcs\noalign{\colsep}}
\def\lcs{\rowsepsurround\cr}
\def\top{\null\vskip.5em}
\def\bot{\vskip.5em}
\def\ctr{\def\lft{\hfil}}
\def\fll{\def\lft{}}
\def\flr{\def\lft{\hfill}}
%Macro
\def\vtable#1{\frameit{\hbox{\valign{\top\noindent
   \hsize#1\lft##\bot
   &&##&\hsize#1\top\noindent\lft##\bot\cr
  \data}}}}
%Defaults
\nonframed\nonruled\ctr
\def\rowsepsurround{\vskip.1ex}
%Examples
\def\data{1 \rs  2\rs 3\cs
          4 \rs  5\rs 6\cs
         314\rs271\rs  \lcs}
\vtable{7ex}
\smallskip
\def\data{\logms3{\hsize7ex\null
\vfil\noindent\hfil1\hfil\vfil}\cs
          C\rs G\rs L\cs
         22\rs12\rs1943\lcs}
\ruled\vtable{7ex}
\smallskip
\def\data{\logms3{\hsize15ex\null
\vfil\noindent\xsp This\\
              \xsp looks\\
              \xsp problematik\vfil}\cs
                       O\rs  A\rs G\cs
                      16\rs11\rs1954\lcs}
\framed\ruled\vtable{5ex}
!endverbatim

%end answer
\blueexample Macroscopic markup vtable, based on valign

{%Example with macroscopic \vtable markup
\def\xsp{\hbox{ }}
\def\vruled{\def\colsep{\vrule}\def\rowsep{}}
\def\hruled{\def\colsep{}\def\rowsep{\hrule}}
\def\ruled{\def\colsep{\vrule}\def\rowsep{\hrule}}
\def\nonruled{\def\colsep{}\def\rowsep{}}
\def\framed{\let\frameit\boxit}
\def\nonframed{\def\frameit##1{##1}}
\def\rs{&\null\rowsepsurround\rowsep\rowsepsurround&}
\def\cs{\lcs\noalign{\colsep}}
\def\lcs{\rowsepsurround\cr}
\def\top{\null\vskip.5em}
\def\bot{\vskip.5em}
\def\ctr{\def\lft{\hfil}}
\def\fll{\def\lft{}}
\def\flr{\def\lft{\hfill}}
%Macro
\def\vtable#1{\frameit{\hbox{\valign{\top\noindent
   \hsize#1\lft##\bot
   &&##&\hsize#1\top\noindent\lft##\bot\cr
  \data}}}}
%Defaults
\nonframed\nonruled\ctr
\def\rowsepsurround{\vskip.1ex}
\begindemo
\def\data{\logms3{\hsize15ex
   \vfil\noindent\xsp This\\
                 \xsp looks\\
                 \xsp problematic
   \vfil}\rs\omit\hsize15ex
   \vfil\noindent
         \xsp Doesn't it?\vfil\cs
          O\rs  A\rs G\rs 189\cs
           \rs 16\rs11\rs1954\lcs}
\framed\ruled\vtable{5ex}
!yields
\def\data{\logms3{\hsize15ex
   \vfil\noindent\xsp This\\
                 \xsp looks\\
                 \xsp problematic
\vfil}\rs
\omit\hsize15ex\vfil\noindent
         \xsp Doesn't it?\vfil\cs
          O\rs  A\rs G\rs   \cs
           \rs16\rs11\rs1954\lcs}
\framed\ruled\vtable{5ex}
\enddemo}

\blueexample Regular use vtable based on valign

{\begindemo
\def\vtable#1{\frameit{\hbox
  {\valign{\top\noindent
   \hsize#1\lft##\bot
   &&##&\hsize#1\top
                \noindent\lft
                ##\bot\cr
  \data}}}}
\def\data{anatoly\rs
          andre\rs
          alex
          \cs       
          beatrici\rs
          bernd\lcs}
\nonframed\vtable{20ex}
!yields
\def\vruled{\def\colsep{\vrule}\def\rowsep{}}
\def\hruled{\def\colsep{}\def\rowsep{\hrule}}
\def\ruled{\def\colsep{\vrule}\def\rowsep{\hrule}}
\def\nonruled{\def\colsep{}\def\rowsep{}}
\def\framed{\let\frameit\boxit}
\def\nonframed{\def\frameit##1{##1}}
\def\rs{&\null\rowsepsurround\rowsep\rowsepsurround&}
\def\cs{\lcs\noalign{\colsep}}
\def\lcs{\rowsepsurround\cr}
\def\top{\null\vskip.1em}
\def\bot{\vskip.1em}
\def\ctr{\def\lft{\hfil}}
\def\fll{\def\lft{}}
\def\flr{\def\lft{\hfill}}
%
\def\rowsepsurround{\vskip.1ex}
%
\def\vtable#1{\frameit{\hbox
  {\valign{\top\noindent
   \hsize#1\lft##\bot
   &&##&\hsize#1\top
                \noindent\lft
                ##\bot\cr
  \data}}}}
\def\data{anatoly\rs
          andre\rs
          alex
          \cs       
          beatrici\rs
          bernd\lcs}
\nonframed\vtable{20ex}
\enddemo}
The advantage of \cs{valign} for this case is that when a name is
inserted in a column that column can grow without 
adaptation of the markup for the other cells.

\blueexample Simultaneous row and column spans

These require more work. ^^{row\ and\ column\ spans}
\newbox\block
\setbox\block=\hbox{$2*3$}
\def\data{\logms3\cs14\grs
          \logms3\cs24\rs
         31\cs32\cs33\cs34}
\def\btablecaption{Caption}
\def\rowstblst{{row 1}{row 2}{\hfil
     $\Rightarrow$}}
\def\header{\logms4 Header\hfil$\Downarrow$}
\def\footer{Footer}
\thisbtable{\def\ghostrow{\ifx\empty\rowstblst
  \else\omit\lineglue\ea\srp\fi
  \logms3\hfil\vbox to0pt{\vss
  \copy\block\vss}\hfil\prs\lineglue\cr\nxtrs}
}
$$\vcenter{\framed\ruled\btable\data}
\qquad\qquad
%\setbox\block=\hbox{$3*3$}
\def\data{\logms3\hfil\cs14\grs
\logms3\hfil$3*3$\hfil\cs24\grs
          \logms3\hfil\cs34\rs
              41\cs42\cs43\cs44}
\thisbtable{\def\ghostrow{\ifx\empty\rowstblst
   \else\omit\lineglue\ea\srp\fi
   \logms3\hfil\prs\lineglue\cr
   \ifx\empty\rowstblst\else\ea\nxtrs\fi}}
\def\btablecaption{Caption}
\def\header{\logms4 Header\hfil$\Downarrow$\ }
\def\rowstblst{{row 1}{row 2}{row 3}{\hfil$\Rightarrow$}}
\def\footer{Footer}
\vcenter{\ruled\framed\btable\data} 
$$
\exercise How to markup the above with simultaneous row and column spans?
\answer Because of the separation of concerns we only have to concentrate
        on the data. My approach is to look at a block\Dash here $2{*}3$\Dash
        as a ghost to be overprinted. 
        A natural way is to introduce the concept of a ghostrow, 
        which will be invoked by the ghostrow separator \cs{grs}.
        So first mark up for the data with the hole in the table and
        include the \cs{grs}. Then provide \cs{ghostrow}. 
        In order to do the latter gracefully, 
        we also need the concept of partial row separator, \cs{prs},
        and its mirror, \cs{srp}, to handle partial lines.
   \beginverbatim
   \setbox\block=\hbox{$2*3$}
   \def\data{\logms3\cs14\grs
             \logms3\cs24\rs
             31\cs32\cs33\cs34}
   \def\btablecaption{Caption}
   \def\rowstblst{{row 1}{row 2}{\hfil
     $\Rightarrow$}}
   \def\header{\logms4 Header\hfil$\Downarrow$}
   \def\footer{Footer}
   \thisbtable{\def\ghostrow{\ifx\empty\rowstblst
     \else\omit\lineglue\ea\srp\fi
     \logms3\hfil\vbox to0pt{\vss
     \copy\block\vss}\hfil\prs\lineglue\cr\nxtrs}
   }\vcenter{\framed\ruled\btable\data}$$
   %
   %and the 3*3 block can be obtained via
   %
   %\setbox\block=\hbox{$3*3$}
   \def\data{\logms3\hfil\cs14\grs
   \logms3\hfil$3*3$\hfil\cs24\grs
          \logms3\hfil\cs34\rs
              41\cs42\cs43\cs44}
   \thisbtable{\def\ghostrow{\ifx\empty\rowstblst
     \else\omit\lineglue\ea\srp\fi
     \logms3\hfil\prs\lineglue\cr
     \ifx\empty\rowstblst\else\ea\nxtrs\fi}}
   \def\btablecaption{Caption}
   \def\header{\logms4 Header\hfil$\Downarrow$\ }
   \def\rowstblst{{row 1}{row 2}{row 3}{\hfil$\Rightarrow$}}
   \def\footer{Footer}
   $$\vcenter{\ruled\framed\btable\data}$$ 
   !endverbatim

\begingroup
\blueexample Gnonoms

In \TUB{} a discussion about the following kind of
rules within tables\Dash so-called ^{gnonoms}\Dash emerged. 
\newcount\rowno \rowno1
\thisverbatim{\unmc}
\begindemo
\newcount\columnno \columnno1
\def\data{1\cs3\cs5\rs
          1\cs4\cs7\rs
          1\cs5\cs9\lrs}
\def\cs{\hss\vrule\ifnum
   \columnno<\rowno width0pt\fi\relax 
         &\global\advance\columnno1 }
\def\rs{\hss\vrule\relax\cr
        \global\advance\rowno1 
        \global\columnno1 }
\def\lrs{\hss\vrule\relax\cr}
\halign{&\vbox to12pt{\hbox to12pt
  {\hss\strut#}\vss\hrule\ifnum
 \rowno<\columnno width0pt\fi}\cr
        \data}
!yields\offinterlineskip
\newcount\columnno \columnno1
\def\data{1\cs3\cs5\rs
          1\cs4\cs7\rs
          1\cs5\cs9\lrs}
\def\cs{\hss\vrule\ifnum
   \columnno<\rowno width0pt\fi\relax 
         &\global\advance\columnno1 }
\def\rs{\hss\vrule\relax\cr
        \global\advance\rowno1 
        \global\columnno1 }
\def\lrs{\hss\vrule\relax\cr}
$$\vbox{\halign{&\vbox to12pt{\hbox to12pt{\hss\strut#}\vss\hrule
         \ifnum\rowno<\columnno width0pt\fi\relax}\cr
        \data}}\qquad\qquad$$
\enddemo
%
%Coding with the deterministic behaviour absorbed, reads as follows.
\newcount\rowno \rowno1
\newcount\columnno \columnno1
\newcount\tnum
\newcount\diff \diff1
\newcount\n 
\def\rows{\global\tnum1 
     \global\advance\diff1
   \cols
   \ifnum\rowno=\n\lrs\swor\fi
   \rs\rows}
\def\swor#1\rows{\fi}
\def\cols{\the\tnum 
   \global\advance\tnum\diff
   \ifnum\columnno=\n\sloc\fi
   \cs\cols}
\def\sloc#1\cols{\fi}
\def\cs{\hss\vertrule \ifnum
   \columnno<\rowno width0pt\fi\relax 
         &\global\advance\columnno1 }
\def\rs{\hss\vertrule\relax\cr
     \global\advance\rowno1 
     \global\columnno1 }
\def\lrs{\hss\vertrule\relax
     \global\columnno1
     \global\rowno1 
     \global\diff1 \cr}
%
\def\gnonoms#1{\n#1 \offinterlineskip
\halign{&\vbox to12pt{\hbox to15pt
           {\hss\strut\oldstyle##}\vss\horrule
            \ifnum\rowno<\columnno 
             width0pt\fi\relax}\cr
          \rows}}
\let\vertrule\vrule
\let\horrule\hrule
\exercise Each entry of the table obeys the formula 
          $$entry_{i,j}=2j-1+(i-1)(j-1).$$
          A little backside of the envelope calculation-\Dash or just
          look closer at the table\Dash shows
          that elements in neighbouring columns differ by $i+1$.
          Format this table as function of the size, i.e.,
          with the elements generated automatically. 
\answer A solution reads as follows (Similar approach as to Pittman's
        multiplication tables.)
\thisverbatim{\unmc}
\beginverbatim
\newcount\rowno \rowno1
\newcount\columnno \columnno1
\newcount\tnum
\newcount\diff \diff1
\newcount\n 
\def\rows{\global\tnum1 
     \global\advance\diff1
   \cols
   \ifnum\rowno=\n\lrs\swor\fi
   \rs\rows}
\def\swor#1\rows{\fi}
\def\cols{\the\tnum 
   \global\advance\tnum\diff
   \ifnum\columnno=\n\sloc\fi
   \cs\cols}
\def\sloc#1\cols{\fi}
\def\cs{\hss\vertrule \ifnum
   \columnno<\rowno width0pt\fi\relax 
         &\global\advance\columnno1 }
\def\rs{\hss\vertrule\relax\cr
     \global\advance\rowno1 
     \global\columnno1 }
\def\lrs{\hss\vertrule\relax
     \global\columnno1
     \global\rowno1 
     \global\diff1 \cr}
%
\def\gnonoms#1{\n#1 \offinterlineskip
\halign{&\vbox to12pt{\hbox to15pt
           {\hss\strut\oldstyle##}\vss\horrule
            \ifnum\rowno<\columnno 
             width0pt\fi\relax}\cr
          \rows}}
\let\vertrule\vrule
\let\horrule\hrule
$$\vtop{\gnonoms2}\qquad
  \vtop{\gnonoms5}\qquad
  \vtop{\gnonoms{10}}$$
\bye
!endverbatim

\exercise Playing longer with the gnonoms can yield the following
          graphical results. Modify the above in order to obtain this
          graph.
\def\vertrule{\vrule width1ex}
\def\horrule{\hrule height 1ex}
\def\cols{\ifnum\columnno=\n\sloc\fi
   \cs\cols}
$$\vtop{\gnonoms3}\qquad
  \vtop{\gnonoms5}\qquad
  \vtop{\gnonoms{7}}$$
\answer  The following redefinitions yield the results.
\beginverbatim
\def\vertrule{\vrule width1ex}
\def\horrule{\hrule height 1ex}
\def\cols{\ifnum\columnno=\n\sloc\fi
   \cs\cols}
$$\vtop{\gnonoms3}\qquad
  \vtop{\gnonoms5}\qquad
  \vtop{\gnonoms7}$$
!endverbatim 

\endgroup   

\bluesubhead Font charts

Font tables can be formatted via
^|\beginchart| and |\endchart|. 
This markup is used in \TB{} {\oldstyle468}--{\oldstyle526},
for the font tables of the Appendices C and F, and  
in {\tt testfont.tex}, which comes along with \MF.

\blueexample ASCII table, \TB{} {\oldstyle367}

\beginverbatim
\beginchart{\global\count@='41\tentt
 \def\chartstrut{\lower4.3pt\vbox to13.6pt{}}}
&\oct{00x}&&NUL&&SOH&&STX&&ETX&&EOT&&ENQ&&ACK&&BEL&&\oddline0
&\oct{03x}&&CAN&&EM&&SUB&&ESC&&FS&&GS&&RS&&US&\evenline
&\oct{04x}&&SP&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline2
&\oct{05x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline
\noalign{\vskip2ex\line{\hfil et cetera\hfil}
         \vskip2.5ex\hrule
         \global\advance\count@ 64 }
&\oct{16x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline7
&\oct{17x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&DEL&\evenline
\endchart
!endverbatim
resulting in the partial ASCII table
{\catcode`\@=11
\beginchart{\global\count@='41\postdisplaypenalty=0 \tentt
  \def\chartstrut{\lower4.3pt\vbox to13.6pt{}}}
&\oct{00x}&&NUL&&SOH&&STX&&ETX&&EOT&&ENQ&&ACK&&BEL&&\oddline0
&\oct{03x}&&CAN&&EM&&SUB&&ESC&&FS&&GS&&RS&&US&\evenline
&\oct{04x}&&SP&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline2
&\oct{05x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&\evenline
\noalign{\vskip2ex\line{\hfil et cetera\hfil}
         \vskip2.5ex\hrule\global\advance\count@ 64 }
&\oct{16x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\oddline7
&\oct{17x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&DEL&\evenline
\endchart
}

%Blank line is needed
\bluesubsubhead Why bother about font charts?

Well, \dots\thinspace a lot can be learned from \cs{beginchart} 
for the markup of classes of tables. 

\bitem Font charts belong to the class of bordered tables
\bitem the template is hidden from the user
\bitem the data can be provided separately and processed on the fly
\bitem the default value of \cs{displaypenalty} can be redefined
       via \cs{displaypenalty} |<number>| as argument of 
       \cs{beginchart}
\bitem \cs{beginchart} is parameterized over the fonts
\bitem ^|\normalchart| keeps automatically track of the positions
       in the font chart.
\smallbreak
In short, the macros show how 
\bitem to mark up classes of tables
\bitem to hide an \cs{halign} template
\bitem to use two-part macros 
\bitem to cope with options and defaults 
\bitem to parameterize over fonts, and
\bitem to minimize markup.
\smallbreak

\blueexample Markup for Appendix F {\oldstyle427}\dash{\oldstyle432}

\beginverbatim
\beginchart{\postdisplaypenalty=0 \tenrm}
                              %or \tenit, \tentt, \tenit, \tensy, \tenex
      \normalchart
\endchart
!endverbatim
resulting in, for the ^{font chart} \cs{tenrm}
\beginchart{\postdisplaypenalty=0 \tenrm}
      \normalchart
\endchart
\noindent The default value of \cs{postdisplaypenalty} is -{\oldstyle10000},
to enforce a page break. 

\exercise How can we get a print of \LaTeX's ^{line\ font}s?
          Why don't you print ^|\oldstyle| too, just for the fun of it?
\answer Similarly, as follows.
\beginverbatim
\font\tenln=line10
\font\tenlnw=linew10
\beginchart{\postdisplaypenalty=0 
            \tenln}
   \normalchart
\endchart
\beginchart\tenlnw
   \normalchart
\endchart
!endverbatim

%end of answer

The argument of \cs{beginchart} is used among other things to control
the kind of table: \cs{tenrm}, \cs{tenit}, \cs{tentt},
          \cs{teni}, \cs{tensy}, or \cs{tenex}.
The data for normal font tables is provided via |\def\normalchart{...}|.
As a consequence the markup for the
other tables in \TB{} Appendix F is surprisingly simple.
\exercise How come that Knuth decided to implement an ordinary argument 
          after \cs{beginchart}? If you look at \cs{begindisplay}
          nearly the same coding structure is used, but there the argument is
          optional. Subtle, very subtle these coding schemes.
\answer There is no much use in providing an optional one. 
        The font is needed and {\sl must\/} be specified.
 
%end answer
\bluesubhead Ordering table for indexing

The most curious of all tables is not a table but generated
each time. ^^{ordering table}
\thisverbatim{\catcode`\|=12 \catcode`\!=12 \catcode`\~=0 }
\begincenterverbatim
\def\otindex{%Parameters: Ordering `table'
\ea\chardef\csname ot \endcsname=0 
%Bulk according to ASCII
\def\process##1{\ea\chardef
   \csname ot##1\endcsname=`##1 }
%
\fifo abcdefghijklmnopqrstuvwxyz\ofif
\chardef\otij=`y \chardef\otIJ=`y
%
\fifo!"##$&'()*+,-./0123456789:;<=>?@
      []_`\ofif
%
\def\process##1{\ea\chardef
  \csname ot##1\endcsname=\lccode`##1 }
\uppercase{\fifo 
  abcdefghijklmnopqrstuvwxyz\ofif}}
~endcenterverbatim
%Back to defaults
\def\header{}\def\rowstblst{}\def\btablecaption{}\def\first{}\def\footer{}
\endinput