summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/blkarray/blkarray.sty
blob: a4b988c1327a3144454de4651347311e1b4df06f (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
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
%%%     blkarray.sty
%%%
%%% Copyright David Carlisle 1992 1999
%%%           david@dcarlisle.demon.co.uk
%%%
%%% This file may be distributed under the terms of the LPPL.
%%% See 00readme.txt for details.
%%%
%%% Version 0.01 - 0.03  November 1992
%%% Version 0.04         03 December 1992
%%% Version 0.05         24 March 1999  (email update only)
%%%
%%%
%%%
%%%     A LaTeX style option extending array and tabular
%%%     HIGHLY VOLATILE, use at your own risk!!!!!!!!
%%%
%%%
%%% 
%%% ====================================================================
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%<*x>
% This file may be used without modification as a style (.sty) file.
%
% If you have Mittelbach's doc.sty, this file may be formatted with a
% command like:
%                latex blkarray.sty
%
% If you have the Mittelbach/Duchier/Braams docstrip utility, you may
% produce a faster loading .sty file. Rename this file to: blkarray.doc
% Then run this file through *plain* TeX:
%                tex blkarray.doc
% This should produce the file blkarray.sty.
% If you do not have plain TeX on your system, you can trick LaTeX into
% doing the work as follows:
%                latex \def\fmtname{plain} \input blkarray.doc
% Note that you may need to quote the arguments here to stop your
% operating system treating the \ characters incorrectly.
%
%                latex blkarray.doc
% Will produce a typeset version of the documentation, as above.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\plain{plain}\ifx\fmtname\plain\csname fi\endcsname
     \def\batchfile{blkarray.doc}
     \input docstrip
     \preamble

     Do not distribute the stripped version of this file.
     The checksum in the header refers to the documented version.

     \endpreamble
     \generateFile{blkarray.sty}{t}{\from{blkarray.doc}{}}
     \endinput
\fi
%
\ifcat a\noexpand @\let\next\relax\else\def\next{%
    \documentclass{article}\usepackage{blkarray,doc}\MakePercentIgnore}\fi\next
%
%\def\eatmodule<#1>{}\eatmodule
%</x>
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \let\osmall\small\def\small{\osmall\tt}
% \textwidth=355pt   ^^A Allow macrocode text with 72 columns.
% \CodelineIndex     ^^A Code lines numbered.
% \DisableCrossrefs  ^^A No Cross references.
% \MakeShortVerb{\"} ^^A "\foo" works like \verb+\foo+
%
% \title{blkarray.sty}
% \author{D. P. Carlisle}
% \begin{document}
% \maketitle
%
% \begin{center}
% \huge\bf Warning\,!
% \end{center}
% \begin{quote}
% This style option is in the early stages of development. If you want
% to use an extended {\tt array} or {\tt tabular} in a document,
% consider using one of the options in the ARRAY package, available from
% most \TeX-servers.
%
% The commands defined in this style are quite likely to have both their
% user-interface, and their internal definitions changed in later
% versions.
% \end{quote}
%
%\BAextrarowheight=1pt
%\BAextraheightafterhline=2pt
%
% \section{Introduction}
% This style option implements an environment, {\tt blockarray}, that
% may be used in the same way as the {\tt array} or {\tt tabular}
% environments of standard \LaTeX, or their extended versions defined in
% {\tt array.sty}. If used in math-mode, {\tt blockarray} acts like
% {\tt array}, otherwise it acts like {\tt tabular}.
%
% The main feature of this style is that it uses a new method of
% defining column types. In the simplest form, this has been given a
% syntax matching the "\newcolumntype" command of {\tt array.sty}.\\
% "\BAnewcolumntype{C}{>{\large}c}"\\
% defines a column of large centred text.
%
% In {\tt array.sty} column specifiers defined via "\newcolumntype" are
% re-written in a preliminary stage to the primitive types, which are
% then treated by a completely different mechanism (basically a nested
% "\if" testing each token against one of the predefined column types,
% "c", "l", ">", \ldots
%
% In {\tt blockarray.sty}, {\em all\/} column specifiers have equal
% standing, most of the specifiers of Lamport's original are defined
% using "\BAnewcolumntype", e.g.\\
% "\BAnewcolumntype{c}   {>{\hfil}<{\hfil}}"
%
% There are one or two other features built into {\tt blockarray}, these
% will be introduced in no particular order.
%
% \subsection{Explicit Column Separators in the Preamble}
%
% As described in the \LaTeX\ book, originally specifiers like "|" and
% "@"-expressions were always considered to be part of the {\em
% preceding\/} column (except for expressions before the first column).
% This can be inconvenient if that column type is going to be over
% ridden by a "\multicolumn" specification, consider:
%
% \begin{minipage}{3in}
% \begin{verbatim}
% \begin{tabular}{c|c|c}
%  11 & 22                    & 33 \\
%  1  &\multicolumn{1}{l|}{2} &  3 \\
%  11 & 22                    & 33
% \end{tabular}
% \end{verbatim}
% \end{minipage}
% \begin{tabular}{c|c|c}
%  11 & 22                    & 33 \\
%  1  &\multicolumn{1}{l|}{2} &  3 \\
%  11 & 22                    & 33
% \end{tabular}
%
% The rule needs to be specified again in the "\multicolumn" argument as
% "{l|}", {\tt blockarray} lets you move the rule into the third column,
% by specifying "&" in the preamble like so:
%
% \begin{minipage}{3in}
% \begin{verbatim}
% \begin{blockarray}{c|c&|c}
%  11 & 22                     & 33 \\
%  1  &\BAmulticolumn{1}{l}{2} &  3 \\
%  11 & 22                     & 33
% \end{blockarray}
% \end{verbatim}
% \end{minipage}
% \begin{blockarray}{c|c&|c}
%  11 & 22                     & 33 \\
%  1  &\BAmulticolumn{1}{l}{2} &  3 \\
%  11 & 22                     & 33
% \end{blockarray}
%
% I first came across the idea of having such a feature in an array
% preamble when  Rainer Sch\"opf gave a brief introduction to various
% enhanced array styles. An implementation by Denys Duchier had a
% feature like this, however I have not seen that style so I do not know
% the details.
%
% \subsection{Blocks}
% Sometimes you want whole blocks of the table to have a different
% format, this is often the case with headings for instance. This can be
% accomplished using lots of "\multicolumn" commands, but this style
% lets you specify the format for such a block in the usual syntax for
% column specifiers:
%
% \begin{minipage}{3in}
% \begin{verbatim}
% \begin{blockarray}{*{3}{c}}
%  11 & 22 & 33 \\
%  1  & 2  &  3 \\
% \begin{block}{*{3}{>{\bf}l}}
%  11 & 22 & 33 \\
%  1  & 2  & 3  \\
% \end{block}
%  1  & 2  &  3
% \end{blockarray}
% \end{verbatim}
% \end{minipage}
% \begin{blockarray}{*{3}{c}}
%  11 & 22 & 33 \\
%  1  & 2  &  3 \\
% \begin{block}{*{3}{>{\bf}l}}
%  11 & 22 & 33 \\
%  1  & 2  & 3  \\
% \end{block}
%  1  & 2  &  3
% \end{blockarray}
%
% \subsection{Delimiters}
%
% People often want to put delimiters around sub-arrays of a larger
% array, delimiters can now be specified in the preamble argument:
%
% \begin{minipage}{3in}
% \begin{verbatim}
% \begin{blockarray}{[cc]c\}}
%  11 & 22  & 33 \\
%  1  & 2   &  3 \\
% \begin{block}{(ll)l\}}
%  11 & 22 & 33 \\
%  1  & 2  & 3  \\
% \end{block}
%  1  & 2   &  3
% \end{blockarray}
% \end{verbatim}
% \end{minipage}
% \begin{blockarray}{[cc]c\}}
%  11 & 22  & 33 \\
%  1  & 2   &  3 \\
% \begin{block}{(ll)l\}}
%  11 & 22 & 33 \\
%  1  & 2  & 3  \\
% \end{block}
%  1  & 2   &  3
% \end{blockarray}
%
% Note how in the previous example the nested {\tt block} was not
% spanned by the $[\ ]$. each section of the `outer' block was
% separately bracketed. If instead of the {\tt block} environment we use
% {\tt block*}, then the outer brackets will span the inner block,
% however it is not possible to specify any delimiters in the argument
% of {\tt block*}.
%
% \begin{minipage}{3in}
% \begin{verbatim}
% \begin{blockarray}{[cc]c\}}
%  11 & 22  & 33 \\
%  1  & 2   &  3 \\
% \begin{block*}{lll}
%  11 & 22 & 33 \\
%  1  & 2  & 3  \\
% \end{block*}
%  1  & 2   &  3
% \end{blockarray}
% \end{verbatim}
% \end{minipage}
% \begin{blockarray}{[cc]c\}}
%  11 & 22  & 33 \\
%  1  & 2   &  3 \\
% \begin{block*}{lll}
%  11 & 22 & 33 \\
%  1  & 2  & 3  \\
% \end{block*}
%  1  & 2   &  3
% \end{blockarray}
%
% The delimiters, "( ) [ ] \{ \}" have been pre-defined as column
% specifiers,
% however any delimiter, including these ones can be specified using the
% specifiers "\Left" and "\Right"\\
% "\Left{"\meta{text}"}{"\meta{delimiter}"}"\\
% specifies a delimiter together with a `label' which will be vertically
% centred with respect to the block. Note that the delimiter and the
% label take up no horizontal space, and so extra space must be left
% with a "!"- or "@"-expression or the text will over-print adjacent
% columns.
%
% \subsection{Automatic Numbering}
% A column specifier "\BAenum" specifies that the row number is to be
% printed (in a "!"-expression) at that point in each row, this number
% may be accessed with "\label" in the usual way. The number is a
% standard \LaTeX\ counter, "BAenumi", and so the appearence may be
% changed by altering the default definition of "\theBAenumi".
%
% \subsection{Footnotes}
% The "\footnote" command may be used inside {\tt blockarray}.
% Two styles are supported. If the test "BAtablenotes" is true (by
% default, or after "\BAtablenotestrue") then footnotes will appear at
% the end of the table, with lines set to the width of the table. If
% "BAtablenotes" is false, footnotes within the table will be treated as
% standard footnotes, with the text (usually) appearing at the foot of
% the page.
%
% If table notes are being set, the footnote counter is reset at the
% start of the table. Also an extended version of "\footnotetext" can be
% used. As described in the book, "\footnotetext[2]{xxx}" will produce a
% text marked with the footnote symbol for `2'. However for tablenotes,
% the optional argument may also be any non-numeric text, in which case
% it is set directly at the start of the footnote text. So you can  go
% "\footnotetext[\sc source:]{xxx}" or "\footnotetext[\sc note:]{xxx}"
% anywhere in the table body, before the first numbered footnote.
%
% If "BAtablenotes" is false the footnote text will not appear at the
% foot of the page if the whole {\tt blockarray} environment is in an
% environment which treats footnotes in a special way (eg another {\tt
% blockarray}). So if you have a complicated table which requires
% tablenotes, but for \TeX{}nical reasons you wish to enter it in the
% {\tt .tex} file as nested {\tt blockarray} environments, you may set
% "\BAtablenotestrue" for the outer environment, and then locally set it
% to false before each of the nested environments. This will ensure that
% footnotes from all parts of the table will be collected together at
% the end.
%
% This table is set with "\BAtablenotestrue".
%
% \begin{center}
% \begin{blockarray}{||c||c|||}
%   ONE\footnotetext[\sc source:]{Chicago Manual of Style.}
% &
%   TWO\footnote{Note on TWO. This is a reasonably long footnote, to
%   show the line breaking.}
% \\
%   \begin{blockarray}{|ll|}
%     \footnotetext[\sc source:]{Chicago Manual of Style.}^^A
%     \footnotetext[\sc note:]{The above attribution is incorrect.}^^A
%     l-one & l-two \\
%     l-three\footnote{Footnote to l-three.} & l-four \\
%   \end{blockarray}
% &
%   \begin{blockarray}{|ll|}
%     \footnotetext[\sc source:]{Chicago Manual of Style.}^^A
%     \footnotetext[\sc note:]{The above attribution is incorrect.}^^A
%     r-one & r-two \\
%     r-three\footnote{Footnote to r-three} & r-four \\
%   \end{blockarray}
% \\
% THREE\footnote{Note on THREE.} & FOUR \\
% \end{blockarray}
% \end{center}
%
% In this example, the outer table is set with "\BAtablenotestrue", but
% each of the inner tables is set with a local setting
% "\BAtablenotesfalse".
%
% Also the footnotes have been set in a single paragraph. Tablenotes
% will be set `run in' a paragraph, after a "\BAparfootnotes"
% declaration.
% \begin{center}
%
% \BAparfootnotes
% \begin{blockarray}{||c||c|||}%
%   \footnotetext[\sc source:]{Chicago Manual of Style.}^^A
%   \footnotetext[\sc note:]{The above attribution is incorrect.}^^A
%   ONE
% &
%   TWO\footnote{Note on TWO. This is a reasonably long footnote, to
%   show the line breaking.}
% \\\BAtablenotesfalse
%   \begin{blockarray}{|ll|}
%     l-one & l-two \\
%     l-three\footnote{Footnote to l-three.} & l-four \\
%   \end{blockarray}
% &
%   \BAtablenotesfalse
%   \begin{blockarray}{|ll|}
%     r-one & r-two \\
%     r-three\footnote{Footnote to r-three} & r-four \\
%   \end{blockarray}
% \\
% THREE\footnote{Note on THREE.} & FOUR\\
% \end{blockarray}
% \end{center}
%
% \subsection{Non Aligned Material}
%
% The primitive "\noalign" command may be used with standard \LaTeX\
% arrays, but paragraphs inside "\noalign" are broken into lines that
% are the width of the page, (or at least the current value of "\hsize")
% not to the final width of the table. Within a {\tt blockarray}
% "\BAnoalign" specifies material to be packaged into a parbox the same
% width as the table. This makes a `hole' in the current block.
% "\BAnoalign*" is similar, but any delimiters in the current block span
% across the non-aligned paragraphs.
%
% \begingroup
% \catcode`\Z=0
% \begin{verbatim}
% \begin{blockarray}{\BAenum!{.\quad}cc\Right{\}}{\tt block 1}}
% \BAnoalign*{Zldots The paragraphs Zldots}
% \begin{block}{\BAenum!{.\quad}(rr\Right{\}}{{\tt block 2} Zdots}}
% \begin{block*}{\BAenum!{.\quad}(ll)}
% \begin{block}{\BAenum!{.\quad}>{\bf}l\{c\Right{\}}{\tt block 3}}
% \BAmultirow{50pt}{Zldots Spanning Zldots}
% \begin{block}{\BAenum!{.\quad}\{l\}l\Right{\}}{\tt block 4}}
% \BAnoalign{\centering Unlike  Zldots}
% \end{verbatim}
% \endgroup
%
% \begin{blockarray}{\BAenum!{.\quad}cc\Right{\}}{\tt block 1}}
% ccc &cc\\
% c &ccccccccc \\
% \BAnoalign*{\raggedright
% The paragraphs in a {\tt\bslash BAnoalign*} are set to the final width
% of the table.}
% \begin{block}{\BAenum!{.\quad}(rr\Right
%               {\}}{{\tt block 2}, with a nested \tt block*}}
% rrr&rr \\
% rrr&r \\
% \begin{block*}{\BAenum!{.\quad}ll}
% lll&ll \\
% l&lll \\
% \end{block*}
% r&r \\
% \end{block}
% ccc \\
% \begin{block}{\BAenum!{.\quad}>{\bf}l\{c\Right{\}}{\tt block 3}}
% LLL&
% \BAmultirow{50pt}{\centering
% Spanning all the rows in a block.}
%  \\
% LL&  \\
% L&  \\
% \end{block}
% \begin{block}{\BAenum!{.\quad}\{l\}l\Right{\}}{\tt block 4}}
% ll &l\\
% \BAnoalign{\centering
% Unlike {\tt\bslash BAnoalign*}, {\tt\bslash BAnoalign} breaks  any
% delimiters in the current block.}
% l&lll \\
% \end{block}
% c&c
% \end{blockarray}
%
%
% \bigskip
%
% \subsection{Spanning Rows and Columns}
%
% The previous table had an example of the use of a "\BAmultirow"
% command. If an entry contains\\
% "\BAmultirow{"\meta{dimen}"}{"\meta{par-mode material}"}"\\
% then the \meta{par-mode material} will appear in a box at least
% \meta{dimen} wide, spanning all the rows in the current block. If the
% other entries in that column of the current block are not empty, they
% will be over printed by the spanning text.
%
% There is a column specification corresponding to "\BAmultirow". if\\
% "\BAmultirow{"\meta{dimen}"}"\\
% appears in the preamble, then each entry in that column will be
% packaged as a paragraph, in a box at least \meta{dimen} wide, spanning
% all the rows in the current block. If this is the last column in the
% block, you can not use the optional argument to "\\", and no entry in
% the column must be empty, it must at least have "{}" in it. (If you
% need to ask why, you don't want to know!)
%
% Similarly there is a column specification corresponding to
% "\BAmulticolumn".  if\\
% "\BAmulticolumn{"\meta{number}"}{"\meta{column specification}"}"\\
% appears in the preamble to a {\tt block}, then the rows in the block
% should have less entries than the outer block, the  columns
% will line up as expected.
%
% \begin{verbatim}
% \begin{blockarray}{r|lccr|c}
% aaa&bbb&ccc&ddd&eee&fff\\
% \begin{block}{(r|\BAmulticolumn{4}{>{\bf}l}|c)}
% 111&The second entry in each &333\\
% \end{block}
% a&b&c&d&e&f\\
% \begin{block}{[r|lccr\{\BAmultirow{1in}]}
% 111&222&333&444&555&Each entry\\
% 1&2&3&4&5&in this column is packaged as a paragraph.\\
% 1&2&3&4&5&\relax\\
% \end{block}
% a&b&c&d&e&f
% \end{blockarray}
% \end{verbatim}
%
% \begin{blockarray}{r|lccr|c}
% aaa&bbb&ccc&ddd&eee&fff\\
% a&b&c&d&e&f\\
% \begin{block}{(r|\BAmulticolumn{4}{>{\bf}l}|c)}
% 111&The second entry in each &333\\
% 1&row of this block spans 4 &3\\
% 1&columns of the {\tt blockarray}.&3\\
% \end{block}
% a&b&c&d&e&f\\
% a&b&c&d&e&f\\
% \begin{block}{[r|lccr\{\BAmultirow{1in}]}
% 111&222&333&444&555&Each entry\\
% 1&2&3&4&5&\hbadness10000 in this column is packaged as a paragraph.\\
% 1&2&3&4&5&\relax\\
% 1&2&3&4&5&\relax\\
% 1&2&3&4&5&\relax\\
% \end{block}
% a&b&c&d&e&f
% \end{blockarray}
%
% \subsection{Horzontal Lines}
% For  technical reasons (explained in the code section) the
% standard "\hline" does not work with "blockarray". "\BAhline" may be
% used in just the same way, although currently it is implemented
% using\ldots\\
% "\BAhhline". The "\hhline" from "hhline.sty", would work, but this is
% a new implementation, more in the spirit of this style.
%
% \begin{minipage}{3in}
% \begin{verbatim}
% \begin{blockarray}{||c||c&|cc||cc||}
% \BAhhline{|t:=:t:=&|==#==:t|}
% 0&  1  & 2   &  3 &4&5\\
% \BAhline
% 0&  1  & 2   &  3&4&5\\
% \BAhline\BAhline
% 0&  1  & 2   &  3&4&5\\
% \BAhhline{||-||-..||.-}
% 0&  1  & 2   &  3&4&5\\
% \BAhhline{=::=""::"=}
% 0&  1  & 2   &  3&4&5\\
% \BAhhline{|b:=:b:=""::"=:b|}
% \end{blockarray}
% \end{verbatim}
% \end{minipage}
% \begin{blockarray}{||c||c&|cc||cc||}
% \BAhhline{|t:=:t:=&|==#==:t|}
% 0&  1  & 2   &  3 &4&5\\
% \BAhline
% 0&  1  & 2   &  3&4&5\\
% \BAhline\BAhline
% 0&  1  & 2   &  3&4&5\\
% \BAhhline{||-||-..||.-}
% 0&  1  & 2   &  3&4&5\\
% \BAhhline{=::=""::"=}
% 0&  1  & 2   &  3&4&5\\
% \BAhhline{|b:=:b:=""::"=:b|}
% \end{blockarray}
%
% Both "\hline" and "\hhline" increase the (minimum) height of the
% following row by "\BAextraheightafterhline", which defaults to 0pt.
% {\tt array.sty} introduced a parameter, known in this style as
% "\BAextrarowheight", which is a length added to the default height of
% {\em all\/} the rows. One of the stated reasons for introducing this
% was to stop horizontal lines touching large entries like accented
% capitals, however increasing all the row heights has an effect rather
% similar to setting "\arraystretch". This style allows the the extra
% height just to be added after the horizontal rule.
%
% \subsection{Further Thoughts}
% \begin{itemize}
% \item
% The main point of any environment based on "\halign" is to make
% entries line up. Using this style as currently implemented, it is easy
% to spoil this alignment by putting different "@" expressions or rules
% in the same column in different blocks. In practice, if you want
% different "@" expressions, you need to do boxing tricks to make sure
% that they all have the same width. This could be done automatically by
% the "\halign", if the "@"-expressions and rules were put in a separate
% column. (This fact could be hidden from the user, by a method similar
% to the multicolumn column specification).
%
% \item
% The "[tcb]" optional argument does not really work at present, I have
% not done a proper implementation, as I do not know what to do about
% horizontal rules.
%
% Standard \LaTeX\ lines "[t]" and "[b]" up like this:
% xx
% \setbox0=\hbox{\begin{tabular}[t]{|c|}1\\2\\3\end{tabular}}\copy0\
% xx
% \setbox2=\hbox{\begin{tabular}[b]{|c|}1\\2\\3\end{tabular}}\copy2\
% xx
%
% However if there are horizontal lines, it looks like:
% xx
% \setbox4=\hbox{\begin{tabular}[t]{|c|}\hline1\\2\\3\end{tabular}}^^A
% \copy4\
% xx
% \setbox6=\hbox
%  {\begin{tabular}[b]{|c|}1\\2\\3\\\hline\end{tabular}}\copy6\
% xx
%
% I {\em think\/} I want it to look like this:
% xx
% \dimen0\dp4
% \advance\dimen0-\dp0
% \raise\dimen0 \box4\
% xx
% \dimen0\ht6
% \advance\dimen0-\ht2
% \lower\dimen0 \box6\
% xx
%
% This would be reasonably easy to achieve in a `full' {\tt blockarray},
% as each row is taken off and inspected, however I would like an array
% that only uses the features of the original implementation to be
% processed by the `quick' system. Any ideas?
%
% \item
% Many user-level commands and parameters defined in this style are
% named "\BA"\ldots\ This is to avoid clashes with the standard
% environments, especially if these are nested inside {\tt blockarray}.
% If {\tt array} and {\tt tabular} were re-defined in terms of {\tt
% blockarray}, many commands could be renamed, for example,
% "\BAextrarowheight", "\BAmulticolumn", "\BAhline".
%
% \item
% This style uses a lot of macros, and every use of the {\tt blockarray}
% uses a lot more. Does it work at all on a PC?
%
% \end{itemize}
%
%
% \typeout{End of the Introduction and Examples.}
% \typein[\answer]%
%   {Do you want an annotated listing of the macro definitions (y/n) ?}
% \def\next{y}\ifx\answer\next\else\expandafter\stop\fi
%

% \clearpage
% \section{The Macros}
%
% \subsection{Some General Control Macros}
% The macros in this section do not have the "BA" prefix, but rather the
% "GC" prefix, other style files can repeat these definitions without
% using up \TeX's memory.
%
%
% \LaTeX\ provides "\z@", "\@ne", "\tw@", "\thr@@", but I needed some
% more\ldots
%    \begin{macrocode}
\chardef\GC@four=4
\chardef\GC@five=5
\chardef\GC@six=6
%    \end{macrocode}
%
% \subsubsection{Tests}
%
% Tests are like "\ifs" except that instead of the\\
% "\if"\ldots\meta{true-text}"\else"\meta{false-text}"\fi"\\
% notation, they have\\
% "\test"\ldots"{"\meta{true-text}"}{"\meta{false-text}"}"\\
% They are constructed such that they expand directly to either the
% \meta{true-text} or \meta{false-text}, without leaving a trailing
% "\fi".
%
%    \begin{macrocode}
\def\GC@newtest#1{%
  \@namedef{#1true}%
    {\expandafter\let\csname test#1\endcsname\GC@true}%
  \@namedef{#1false}%
    {\expandafter\let\csname test#1\endcsname\GC@false}%
  \@nameuse{#1false}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\GC@def@testfromif#1#2\fi{%
  \def#1##1##{#2##1\expandafter\GC@true\else\expandafter\GC@false\fi}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\GC@true#1#2{#1}
\def\GC@false#1#2{#2}
%    \end{macrocode}
%
% This "\testGC@num" is not very good as it does not delimit the
% \meta{number}s correctly.
%    \begin{macrocode}
\GC@def@testfromif\testGC@x\ifx\fi
\GC@def@testfromif\testGC@num\ifnum\fi
%    \end{macrocode}
%
% \subsubsection{List Macros}
%
% If "\X" is "abc" then "\GC@add@to@front\X{xyz}" is "xyzabc";
%    \begin{macrocode}
\long\def\GC@add@to@front#1#2{%
  \def\@tempa##1{\gdef#1{#2##1}}%
  \expandafter\@tempa\expandafter{#1}}
%    \end{macrocode}
%
% and "\GC@add@to@end\X{xyz}" is "abcxyz".
%    \begin{macrocode}
\long\def\GC@add@to@end#1#2{%
  \expandafter\gdef\expandafter#1\expandafter{#1#2}}
%    \end{macrocode}
%
% \subsection{Allocations}
%
% I have given `meaningful names' to plain-\TeX's scratch registers, I
% am not sure this was a good idea, but it should be OK as long as I
% always access by name, and do not use, say, "\count4" as a scratch
% register. I do not like using numbered registers in the code, and can
% not afford to allocate registers just to get nice names, they are in
% too short supply already!
%
% Only allocate another register if {\tt blockarray} is going to lose
% control at a point where the register value needs to be saved. (eg
% inside a "\BAnoalign" anything can happen.
%
% "\BAtracing" can be set to any integer, the higher the number, the
% more gets printed.
%    \begin{macrocode}
%<*tracing>
\chardef\BAtracing=0
%</tracing>
%    \end{macrocode}
%
%    \begin{macrocode}
\newcounter{BAenumi}\let\BA@row\c@BAenumi
\countdef\BA@row@shadow=6
%    \end{macrocode}
%
%    \begin{macrocode}
\countdef\BA@ftn@shadow=0
%    \end{macrocode}
%
%    \begin{macrocode}
\newcount\BA@col
\countdef\BA@col@shadow=2
%    \end{macrocode}
%
%    \begin{macrocode}
\newcount\BA@block@cnt
\countdef\BA@block@cnt@shadow=4
%    \end{macrocode}
%
%    \begin{macrocode}
\countdef\BA@col@max=8
%    \end{macrocode}
%
%    \begin{macrocode}
\newbox\BA@final@box
\chardef\BA@final@box@shadow=8
%    \end{macrocode}
%
%    \begin{macrocode}
\chardef\BA@first@box=0
%    \end{macrocode}
%
%    \begin{macrocode}
\chardef\BA@tempbox@a=2
%    \end{macrocode}
%
%    \begin{macrocode}
\chardef\BA@tempbox@b=4
%    \end{macrocode}
%
%    \begin{macrocode}
\chardef\BA@block@box=6
%    \end{macrocode}
%
%    \begin{macrocode}
\newdimen\BA@colsep
\BA@colsep=\tabcolsep
%    \end{macrocode}
%
%    \begin{macrocode}
\newtoks\BA@ftn
\toksdef\BA@ftnx@shadow=0
%    \end{macrocode}

% \subsection{`Local' Variables}
%
% Most of {\tt blockarray} happens inside a "\halign" which means that
% the different parts have to make global assignments if they need to
% communicate. However many of these assignments are logically local to
% {\tt blockarray}, or a sub-environment like {\tt block}. This means
% that I have to manage the saving and restoring of local values `by
% hand'.
%
% Three different mechanisms occured to me, I have used all of them in
% this style, mainly just to try them out!
%
% \begin{itemize}
% \item `shadowing' If  "\X" is to be assigned globally, but it is to
% be considered local to a block of code that corresponds to a \TeX\
% group, then it may be shadowed by a local variable "\Y"\\
% "\begingroup\Y=\X"\\
% "\begingroup"\\
% \meta{arbitrary code making global assignments to {\tt X}}\\
% "\endgroup"\\
% "\global\X=\Y\endgroup".\\
% The inner group is needed to protect "\Y" from being changed.
%
% This is effectively the situation in the {\tt blockarray} environment,
% where the outer group is provided by "\begin"\ldots"\end", and the
% inner group is provided by an assignment to a box register.
% \item Generating new command names, according to nesting depth.
% Instead of directly using "\X", the variable can always be indirectly
% accessed by "\csname\nesting X\endcsname". Here "\nesting" should
% expand to a different sequence of tokens for each nested scope in
% which "\X" is  used. "\nesting" might be altered by a local
% assignment, or sometimes  need to be globally incremented at the start
% of the scope, and globally decremented at the end.
% \item Maintaining a stack of previous values. Corresponding to  a
% macro, "\X", is a macro"\Xstack" which consists of a list of the
% values of "\X" in all outer environments. When the local scope ends,
% this stack is popped, and the top value (which was the value of "\X"
% before the environment) is globally assigned to "\X".
% \end{itemize}
%
% The first method has the advantage that the variable is normally
% accessed within the environment, and the code to restore previos
% values is trivial. The main memory usage is in the save-stack, \TeX's
% normal place for saving local vaues.
%
% Shadowing can only be used when the environment corresonds to a \TeX\
% group. The {\tt block} environment does not!, "\end{block}" is not in
% the scope of any local assignments made by "\begin{block}".
%
% The second method, has the advantage that, once the access functions
% are defined, it is easy to declare new local variables, however unless
% you keep track of what has been produced, these variables will
% continue to take up memory space, even after the environment has
% ended. {\tt blockarray} at the moment does not do much clearing up, so
% after a {\tt blockarray} there are typically five macros per column
% per block (u-part, v-part, left right and `mid' delimiters) left
% taking up space. Not to mention macros containing the texts of any
% non-aligned entries.
%
%
% An extra `"."' will locally be added to "\BA@nesting" as each {\tt
% blockarray} is entered, this is used as described above.
%    \begin{macrocode}
\def\BA@nesting{}
%    \end{macrocode}
%
% These two macros help in accessing macros that are `local' to the
% current value of "\BA@nesting".
%    \begin{macrocode}
\def\BA@expafter#1#2{%
  \expandafter#1\csname BA@\BA@nesting#2\endcsname}
\def\BA@use#1{\csname BA@\BA@nesting#1\endcsname}
%    \end{macrocode}
%
% These are similar, but for macros which depend on the column and block
% involved, not just the outer {\tt blockarray} environment.
%    \begin{macrocode}
\def\BA@col@expafter#1#2{%
  \expandafter#1%
    \csname BA@\BA@nesting[\BA@use{blocktype},\the\BA@col]#2\endcsname}
\def\BA@col@use#1{%
  \csname BA@\BA@nesting[\BA@use{blocktype},\the\BA@col]#1\endcsname}
%    \end{macrocode}
%
% The following macros manage a stack as described in the third method
% above.
%    \begin{macrocode}
\def\BA@push@blocktype{%
\edef\@tempa{{{\BA@use{blocktype}}}}%
  \BA@expafter\GC@add@to@front{BTstack\expandafter}\@tempa}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@pop@blocktype{%
\BA@expafter\BA@pop@{BTstack}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@pop@#1{\expandafter\BA@pop@@#1\@@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@pop@@#1#2\@@{%
  \BA@expafter\gdef{blocktype}{#1}%
  \BA@expafter\gdef{BTstack}{#2}}
%    \end{macrocode}
%
% \subsection{The Block Environment}
%
%    \begin{macrocode}
\def\BA@beginblock#1{%
  \noalign{%
    \BA@push@blocktype
    \global\advance\BA@block@cnt\@ne
    \penalty\the\BA@block@cnt
    \BA@expafter\xdef{blocktype\expandafter}\expandafter
      {\the\BA@block@cnt}%
    \penalty\@ne
    \global\BA@col=1
    \global\BA@expafter\def{blank@row}{\crcr}%
    \BA@clear@entry
    \global\let\BA@l@expr\@empty\global\let\BA@r@expr\@empty
    \BA@colseptrue
    \BA@parse#1\BA@parseend
    \ifnum\BA@col@max=\BA@col\else
       \@latexerr{wrong number of columns in block}\@ehc\fi
    \global\BA@col\z@}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@endblock{%\crcr
  \noalign{%
  \BA@pop@blocktype
  \penalty\BA@use{blocktype}%
  \penalty\tw@}}
%    \end{macrocode}
%
%    \begin{macrocode}
\@namedef{BA@beginblock*}#1{%
  \noalign{%
    \BA@push@blocktype
    \global\advance\BA@block@cnt\@ne
    \BA@expafter\xdef{blocktype\expandafter}\expandafter
      {\the\BA@block@cnt}%
    \global\BA@col=\@ne
    \global\BA@expafter\def{blank@row}{\crcr}%
    \BA@stringafter\let\Left\BA@left@warn
    \BA@stringafter\let\Right\BA@right@warn
    \BA@clear@entry
    \global\let\BA@l@expr\@empty\global\let\BA@r@expr\@empty
    \BA@colseptrue
    \BA@parse#1\BA@parseend
    \ifnum\BA@col@max=\BA@col\else
       \@latexerr{wrong number of columns in block*}\@ehc\fi
    \global\BA@col\z@}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@left@warn#1#2{%
  \@warning{Left delimiter, \string#2, ignored}\BA@parse}
\def\BA@right@warn#1#2{%
  \@warning{Right delimiter, \string#1, ignored}\BA@parse}
%    \end{macrocode}
%
%    \begin{macrocode}
\@namedef{BA@endblock*}{%\crcr
  \noalign{%
  \BA@pop@blocktype}}
%    \end{macrocode}
%
% \subsection{Multicolumn}
%
% First we have the "\multicolumn" command to be used as in original
% \LaTeX.
%
%    \begin{macrocode}
\def\BAmulticolumn#1#2#3{%
  \multispan{#1}%
  \global\advance\BA@col#1\relax
  \edef\BA@nesting{\BA@nesting,}%
  \BA@expafter\def{blocktype}{0}%
  {\BA@defcolumntype{&}##1\BA@parseend{%
     \@latexerr{\string& in multicolumn!}\@ehc\BA@parse\BA@parseend}%
  \global\BA@expafter\def{blank@row}{\crcr}%
  \BA@clear@entry
  \global\let\BA@l@expr\@empty\global\let\BA@r@expr\@empty
  \BA@colseptrue
  \BA@parse#2\BA@parseend}%
  \BA@strut\BA@col@use{u}\ignorespaces#3\BA@vpart}
%    \end{macrocode}
%
% Now something more interesting, a "\BAmulticolumn" column
% specification!
%
%    \begin{macrocode}
\def\BA@make@mc#1{%
  \count@#1\relax
  \BA@make@mcX
  \edef\BA@mc@hash{%
    \noexpand\BA@parse
     >{\BA@mc@spans}\noexpand\BA@MC@restore@hash
     \BA@mc@amps\noexpand\BA@MC@switch@amp}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@make@mcX{%
  \ifnum\count@=\@ne
    \def\BA@mc@spans{\null}%
    \let\BA@mc@amps\@empty
  \else
   \advance\count@\m@ne
    \BA@make@mcX
    \GC@add@to@end\BA@mc@spans{\span}%
    \GC@add@to@end\BA@mc@amps{&@{}}%
  \fi}
%    \end{macrocode}
%
% \subsection{\tt\bslash BAmultirow}
%
% First as a command.
%
%    \begin{macrocode}
\long\def\BAmultirow#1{\kern#1\relax
  \global\BA@quickfalse
  \BA@col@expafter\gdef{mid}}
%    \end{macrocode}
%
% Then as a column specification. (The actual "\BAnewcolumn" comes
% later)
%
%    \begin{macrocode}
\def\BA@mrow@bslash#1{%
  \kern#1\relax
  \global\BA@quickfalse
  \iffalse{\else\let\\\cr\fi\iffalse}\fi
  \BA@mrow}
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\BA@mrow#1\BA@vpart{%
  \BA@col@expafter\GC@add@to@end{mid}{\endgraf#1}
  \BA@vpart}
%    \end{macrocode}
%
% \subsection{\tt\bslash BAnoalign}
%
%    \begin{macrocode}
\def\BAnoalign{%\crcr
  \noalign{\ifnum0=`}\fi
     \global\BA@quickfalse
     \penalty\the\BA@row
  \@ifstar
      {\penalty\GC@four\BA@noalign}%
      {\penalty\BA@use{blocktype}\penalty\thr@@\BA@noalign}}
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\BA@noalign#1{%
  \long\BA@expafter\gdef{noalign\the\BA@row}{#1}%
  \ifnum0=`{\fi}}
%    \end{macrocode}
%
% \subsection{\tt\bslash\bslash}
%
% The following code is taken directly from "array.sty", apart from some
% name changes. It is very similar to the version in {\tt latex.tex}.
% Making "\\" into a macro causes problems when you want the entry to be
% taken as a macro argument. One possibility is to "\let" "\\" be
% "\span", and then have the \meta{u-part} of a final column parse the
% optional argument. There is still a problem with "\end{...}". Note
% that at the moment this style assumes that "\\" is used at the end of
% all lines except the last, even before "\begin{block}" or
% "\end{block}", this allows spacing to be specified, and also
% approximates to the truth about what is actually happening. The idea
% of making it easier to allow entries to be taken as arguments may be a
% non-starter if "&" is allowed to become a `short-ref' (ie "\active")
% character.
%
%    \begin{macrocode}
\def\BA@cr{{\ifnum 0=`}\fi
  \@ifstar \BA@xcr \BA@xcr}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@xcr{\@ifnextchar [%
  \BA@argcr {\ifnum 0=`{\fi}\cr}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@argcr[#1]{\ifnum0=`{\fi}\ifdim #1>\z@
  \BA@xargcr{#1}\else \BA@yargcr{#1}\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@xargcr#1{\unskip
  \@tempdima #1\advance\@tempdima \dp\@arstrutbox
  \vrule \@depth\@tempdima \@width\z@ \cr}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@yargcr#1{\cr\noalign{%
     \vskip #1}}
%    \end{macrocode}
%
%    \begin{macrocode}
\newdimen\BAextrarowheight
\newdimen\BAextraheightafterhline
\newdimen\BAarrayrulewidth
   \BAarrayrulewidth\arrayrulewidth
%    \end{macrocode}
%
%    \begin{macrocode}
\newdimen\BAdoublerulesep
   \BAdoublerulesep\doublerulesep
%    \end{macrocode}
%
% The B form of the strut is an extra high strut to use after a
% horizontal rule.
%    \begin{macrocode}
\def\BA@strut{\unhcopy\@arstrutbox}
\let\BA@strutA\BA@strut
\def\BA@strutB{\dimen@\ht\@arstrutbox
  \advance\dimen@\BAextraheightafterhline
  \vrule \@height\dimen@ \@depth \dp\@arstrutbox \@width\z@
  \global\let\BA@strut\BA@strutA}
%    \end{macrocode}
%
% \subsection{Begin and End}
%
% "\begin{block}" is supposed to expand to "\noalign{...", but the code
% for "\begin" would place non-expandable tokens before the "\noalign".
% Within the {\tt blockarray} environment, redefine "\begin" so that if
% its argument corresponds to a command "\BA@begin"\meta{argument}, then
% directly directly expand that command, otherwise do a normal "\begin".
% A matching change is made to "\end".
%    \begin{macrocode}
\let\BA@@begin\begin
\let\BA@@end\end
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@begin#1{%
  \expandafter\testGC@x\csname BA@begin#1\endcsname\relax
    {\BA@@begin{#1}}%
    {\csname BA@begin#1\endcsname}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@end#1{%
  \expandafter\testGC@x\csname BA@end#1\endcsname\relax
    {\BA@@end{#1}}%
    {\csname BA@end#1\endcsname}}
%    \end{macrocode}
%
% \subsection{The {\tt blockarray} Environment}
%
%    \begin{macrocode}
\def\blockarray{\relax
  \@ifnextchar[{\BA@blockarray}{\BA@blockarray[c]}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@blockarray[#1]#2{%
  \expandafter\let\expandafter\BA@finalposition
    \csname BA@position@#1\endcsname
  \let\begin\BA@begin
  \let\end\BA@end
  \ifmmode
    \def\BA@bdollar{$}\let\BA@edollar\BA@bdollar
  \else
    \def\BA@bdollar{\bgroup}\def\BA@edollar{\egroup}%
    \let\BA@bdollar\bgroup\let\BA@edollar\egroup
  \fi
  \let\\\BA@cr
%    \end{macrocode}
% Currently I use "\everycr" this means that every macro that uses
% "\halign" that might be used inside a {\tt blockarray} must locally
% clear "\everycr". The version of {\tt array} in {\tt array.sty} does
% this, but not the one in {\tt latex.tex}.
%    \begin{macrocode}
  \everycr{\noalign{%
     \global\advance\BA@row\@ne
     \global\BA@col\z@}}%
%    \end{macrocode}
% The "\extrarowheight" code from {\tt array.sty}.
%    \begin{macrocode}
  \@tempdima \ht \strutbox
  \advance \@tempdima by\BAextrarowheight
  \setbox\@arstrutbox \hbox{\vrule
             \@height \arraystretch \@tempdima
             \@depth \arraystretch \dp \strutbox
             \@width \z@}%
%    \end{macrocode}
% As explained above various registers which are `local' to {\tt
% blockarray} are always accessed globally, and so must be shadowed by
% local copies, so that the values can be restored at the end.
%    \begin{macrocode}
  \BA@col@shadow=\BA@col
    \global\BA@col=\@ne
  \BA@block@cnt@shadow=\BA@block@cnt
    \global\BA@block@cnt\@M
  \BA@row@shadow\BA@row
    \global\BA@row\z@
  \setbox\BA@final@box@shadow=\box\BA@final@box
    \global\setbox\BA@final@box=\box\voidb@x
  \let\BA@delrow@shadow=\BA@delrow
  \let\testBA@quick@shadow\testBA@quick
    \global\BA@quicktrue
%    \end{macrocode}
% If we are using tablenotes, shadow the footnote counter (or possibly
% mpfootnote), and set up the print style for the table notes.
%    \begin{macrocode}
  \testBAtablenotes
    {\edef\BA@mpftn{\csname c@\@mpfn\endcsname}%
     \@namedef{the\@mpfn}{\BA@fnsymbol{\@nameuse{c@\@mpfn}}}%
     \BA@ftn@shadow=\BA@mpftn\global\BA@mpftn\z@
     \BA@ftnx@shadow=\expandafter{\the\BA@ftn}\global\BA@ftn{}%
      }{}%
%    \end{macrocode}
% Locally increase "\BA@nesting" so that macros accessed by `the second
% method' will be local to this environment.
%    \begin{macrocode}
  \edef\BA@nesting{\BA@nesting.}%
%    \end{macrocode}
% Now start up the code for this block
%    \begin{macrocode}
  \BA@expafter\xdef{blocktype}{10000}%
  \BA@expafter\xdef{BTstack}{\relax}%
  \global\BA@expafter\def{blank@row}{\crcr}%
  \setbox\BA@first@box=\vbox{\ifnum0=`}\fi
    \let\@footnotetext\BA@ftntext\let\@xfootnotenext\BA@xftntext
    \lineskip\z@\baselineskip\z@
    \BA@clear@entry
    \global\let\BA@l@expr\BA@bdollar\global\let\BA@r@expr\BA@edollar
    \global\let\BA@l@expr\@empty\global\let\BA@r@expr\@empty
    \BA@colseptrue
    \BA@parse#2\BA@parseend
    \BA@col@max=\BA@col
%    \end{macrocode}
% There had to be a "\halign" somewhere, and here it is!
%
% Currently I am using a `repeating preamble' because it was easier, but
% I think that I should modify the columntypes for {\tt blockarray} (not
% {\tt block}) so that they construct a preamble with the right number
% of columns. this would give better error checking, and would give the
% possibility of modifying the tabskip glue.
%    \begin{macrocode}
    \tabskip\z@
    \halign\bgroup\BA@strut%\global\BA@col=\z@
       \BA@upart##\BA@vpart&&\BA@upart##\BA@vpart\cr
       \noalign{\penalty\GC@five}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@upart{\global\advance\BA@col\@ne\BA@col@use{u}\ignorespaces}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@vpart{\unskip\BA@col@use{v}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@clear@entry{%
  \global\BA@col@expafter\let{u}\@empty
  \global\BA@col@expafter\let{v}\@empty
  \global\BA@col@expafter\let{left}\relax
  \global\BA@col@expafter\let{mid}\@empty
  \global\BA@col@expafter\let{right}\relax
  \BA@uparttrue}
%    \end{macrocode}
%
%    \begin{macrocode}
\let\BA@fnsymbol=\@fnsymbol
%    \end{macrocode}
%
% The code to place the footnote texts at the foot of the table, each
% footnote starting on a new line. This will only be activated if
% "\BAtablenotestrue".
%    \begin{macrocode}
\def\BA@expft[#1]#2{%
  \noindent\strut\ifodd0#11{%
  \edef\@thefnmark
     {\BA@fnsymbol{#1}}\@makefnmark}\else{#1}\fi\ #2\unskip\strut\par}
%    \end{macrocode}
%
% After a "\BAparfootnotes" declaration, the table notes will be set in
% a single paragraph, with a good chance of line breaks occuring at the
% start of a footnote.
%    \begin{macrocode}
\def\BAparfootnotes{%
  \def\BA@expft[##1]##2{%
   \noindent\strut\ifodd0##11{%
     \edef\@thefnmark{\BA@fnsymbol{##1}}\@makefnmark}\else{##1~}\fi
   ##2\unskip\strut\nobreak
  \hskip \z@ plus 3em \penalty\z@\hskip 2em plus -2.5em minus .5em}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\endblockarray{%
%    \end{macrocode}
% At this point, if no delimiters, "\BAnoalign", or "\BAmultirow" have
% been used, just finish here, this makes {\tt blockarray} was just
% about as efficient as {\tt array} If no fancy tricks have been used.
%    \begin{macrocode}
  \testBA@quick\BA@quick@end\BA@work@back@up
%    \end{macrocode}
% Now we restore the values  that have been `shadowed' by versions that
% are local to this environment.
%    \begin{macrocode}
  \global\BA@block@cnt=\BA@block@cnt@shadow
  \global\BA@col=\BA@col@shadow
  \global\BA@row=\BA@row@shadow
  \global\setbox\BA@final@box=\box\BA@final@box@shadow
  \global\let\BA@delrow=\BA@delrow@shadow
  \global\let\BA@delrow=\BA@delrow@shadow
  \global\let\testBA@quick\testBA@quick@shadow
%    \end{macrocode}
% If tablenotes are being used, reset the shadowed list of footnotes.
% Otherwise execute the list now, to pass the footnotes on to the outer
% environment, or the current page.
%    \begin{macrocode}
  \testBAtablenotes
    {\global\BA@mpftn=\BA@ftn@shadow
     \global\BA@ftn=\expandafter{\the\BA@ftnx@shadow}}
    {\global\BA@ftn\expandafter{\expandafter}\the\BA@ftn}}
%    \end{macrocode}
%
% Here is the `quick ending': just position the box as specified by
% "[tcb]", possibly adding footnotes.
%    \begin{macrocode}
\def\BA@quick@end{%
  \crcr
  \egroup% end of halign
  \ifnum0=`{\fi}% end of \BA@first@box
%<*tracing>
     \ifnum\BAtracing>\z@\typeout{Quick blockarray ends \on@line}\fi
%</tracing>
   \leavevmode\BA@finalposition\BA@first@box}
%    \end{macrocode}
%
% If any delimiters or noaligns have been used, we must take apart the
% table built in "\BA@first@box", and reassemble it. This is done by
% removing the rows one by one, starting with the last row, using
% "\lastbox".
%    \begin{macrocode}
\def\BA@work@back@up{%
  \BA@use{blank@row}%
  \egroup% end of halign
  \setbox\@tempboxa=\lastbox
  \unskip
  \BA@getwidths
%<*tracing>
     \ifnum\BAtracing>\z@\typeout{Full blockarray ends \on@line}\fi
%</tracing>
%<*tracing>
   \ifnum\BAtracing>\thr@@
     \egroup\showbox\BA@first@box
     \setbox\BA@first@box=\vbox\bgroup\unvbox\BA@first@box
   \fi
%</tracing>
  \setbox\BA@block@box=\box\voidb@x
  \BA@check@pen
  \ifnum0=`{\fi}% end of \BA@first@box
%<*check>
  \dimen@=\ht\BA@first@box\advance\dimen@\dp\BA@first@box
  \ifdim\dimen@>\z@\showthe\dimen@\fi
%</check>
     \leavevmode\BA@finalposition\BA@final@box}
%    \end{macrocode}
%
% These macros position the final box, they are just first attempts. In
% particular "[t]" does not work properly because the guard penalty used
% to terminate the main loop means that "\BA@first@box" always has zero
% height. Also if the box has been taken apart, "[t]" and "[b]" will
% cause the position to be based on the {\em centre\/} of the
% corresponding block.
%
% If tablenotes are being used, package the table in a box with the
% notes.
%    \begin{macrocode}
\newdimen\BAfootskip
\BAfootskip=1em
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@position@c#1{\hbox{%
     \testBAtablenotes
      {\let\footnotetext\BA@expft
       \hsize\wd#1\@parboxrestore\footnotesize}%
      {}%
     $\vcenter{%
      \unvbox#1%
      \testBAtablenotes
        {\vskip\BAfootskip
         \the\BA@ftn}{}%
      }$}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@position@t#1{\vtop{%
     \testBAtablenotes
      {\let\footnotetext\BA@expft
       \hsize\wd#1\@parboxrestore\footnotesize}%
      {}%
      \unvbox#1%
      \testBAtablenotes
        {\vskip\BAfootskip
         \the\BA@ftn}{}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@position@b#1{%
    \testBAtablenotes
      {\vbox{%
        \let\footnotetext\BA@expft
        \hsize\wd#1\@parboxrestore\footnotesize
        \unvbox#1%
        \vskip\BAfootskip
        \the\BA@ftn}}%
      {\box#1}}
%    \end{macrocode}
%
%
% \subsection{Fitting the Parts Together}
%
% Get the widths of each column. It also faithfully copies the tabskip
% glue, even though currently this is always 0pt. The width of the
% column is put into "\BA@delrow" as the argument to the (unexpanded)
% call to "\BA@lr".
%    \begin{macrocode}
\def\BA@getwidths{%
  \setbox\@tempboxa=\hbox{\unhbox\@tempboxa
    \xdef\BA@delrow{\hskip\the\lastskip}\unskip
    \let\BA@lr\relax
    \loop
    \setbox\BA@tempbox@a=\lastbox
    \skip\z@=\lastskip\unskip
    \ifhbox\BA@tempbox@a
    \xdef\BA@delrow{%
      \hskip\the\skip\z@\BA@lr{\the\wd\BA@tempbox@a}\BA@delrow}%
    \repeat}}
%    \end{macrocode}
%
% The main mechanism by which {\tt blkarray} leaves information to be
% used `on the way back' is to leave groups of penalties in the main
% box.
% The last penalty in each group (the first to be seen on the way back)
% is a code penalty, it has the following meanings:\\
% "\penalty 1" --- "\begin{block}"\\
% "\penalty 2" --- "\end{block}"\\
% "\penalty 3" --- "\BAnoalign"\\
% "\penalty 4" --- "\BAnoalign*"\\
% "\penalty 5" --- "\begin{blockarray}"\\
% Note that the {\tt block*} environment does not produce any penalties,
% this environment is just as efficient as "\multicolumn", and does not
% require the second phase, coming back via "\lastbox".
%
% Above the code penalty may be other penalties, depending on the code,
% typically these have the values of the blocktype for the block, or the
% row number.
%    \begin{macrocode}
\def\BA@check@pen{%
  \count@=\lastpenalty\unpenalty
  \ifcase\count@
%    \end{macrocode}
% Grumble Grumble. "\lastpenalty" should be {\tt void} if the previous
% thing was not a penalty, and there should be an "\ifvoid\lastpenalty"
% or something equivalent to test for this. If the user manages to get a
% "\penalty0" into the main box, it will just have to be discarded.
% Actually that is not disastrous, but if a rule, mark, special, insert
% or write gets into that box {\tt blockarray} will go into an infinite
% loop. Every class of \TeX\ object should have a "\last"\ldots\
% so that boxes may be taken apart and reconstructed by special styles
% like this. \TeX\ of course is frozen, so these missing features will
% never be added (while the system is called \TeX).
%
%    \begin{macrocode}
%<*tracing>
     \ifnum\BAtracing>\tw@\typeout{0-???}\fi
%</tracing>
     \BA@get@row
  \or
%<*tracing>
     \ifnum\BAtracing>\tw@\typeout{1-block}\fi
%</tracing>
     \BA@expafter\xdef{blocktype}{\the\lastpenalty}\unpenalty
     \ifnum\lastpenalty=\tw@
%<*tracing>
       \ifnum\BAtracing>\tw@\typeout{discarding 2-endblock}\fi
%</tracing>
       \unpenalty\unpenalty\fi
     \BA@place
  \or
%<*tracing>
     \ifnum\BAtracing>\tw@\typeout{2-endblock}\fi
%</tracing>
     \BA@expafter\xdef{blocktype}{\the\lastpenalty}\unpenalty
     \BA@place
  \or
%<*tracing>
     \ifnum\BAtracing>\tw@\typeout{3-BAnoalign}\fi
%</tracing>
     \BA@expafter\xdef{blocktype}{\the\lastpenalty}\unpenalty
     \BA@place
     \count@=\lastpenalty\unpenalty
     \global\setbox\BA@final@box=\vbox{%
       \hsize=\wd\BA@final@box\@parboxrestore
       \vrule \@height \ht\@arstrutbox \@width \z@
       \BA@use{noalign\the\count@}
       \vrule \@width \z@ \@depth \dp \@arstrutbox
       \endgraf\unvbox\BA@final@box}%
  \or
%<*tracing>
     \ifnum\BAtracing>\tw@\typeout{4-BAnoalign*}\fi
%</tracing>
     \count@=\lastpenalty\unpenalty
     \setbox\BA@block@box=\vbox{%
       \hsize=\wd\BA@final@box \@parboxrestore
       \vrule \@height \ht\@arstrutbox \@width \z@
       \BA@use{noalign\the\count@}
       \vrule \@width \z@ \@depth \dp \@arstrutbox
       \endgraf\unvbox\BA@block@box}%
  \or
%<*tracing>
     \ifnum\BAtracing>\tw@\typeout{5-blockarray}\fi
%</tracing>
     \BA@expafter\xdef{blocktype}{10000}
     \BA@place
     \let\BA@check@pen\relax
  \fi
  \BA@check@pen}
%    \end{macrocode}
%
% Move a row of the table from the "\BA@first@box" into the block that
% is being constructed in "\BA@block@box".
%    \begin{macrocode}
\def\BA@get@row{%
  \skip@=\lastskip\unskip
  \advance\skip@\lastskip\unskip
  \setbox\@tempboxa=\lastbox
  \setbox\BA@block@box=\vbox{%
     \box\@tempboxa
     \vskip\skip@
     \unvbox\BA@block@box}}
%    \end{macrocode}
%
% Place the block that has been constructed in "\BA@block@box", together
% with any delimiters, or spanning entries which have been assembled
% into "\BA@delrow", into the final table, which is being constructed in
% "\BA@final@box".
%    \begin{macrocode}
\def\BA@place{%
  \global\setbox\BA@final@box=\vbox{\hbox{%
    \m@th\nulldelimiterspace=\z@
    \dimen\z@=\ht\BA@block@box
    \advance\dimen\z@ by \dp\BA@block@box
    \divide\dimen\z@\tw@
    \dimen\tw@=\dimen\z@
    \advance\dimen\z@ by\fontdimen22 \textfont\tw@
    \advance\dimen2 by-\fontdimen22 \textfont\tw@
    \global\BA@col=\z@
    \delimitershortfall=10pt
    \delimiterfactor=800
    \BA@delrow
    \kern-\wd\BA@block@box
    \ht\BA@block@box=\dimen\z@ \dp\BA@block@box=\dimen\tw@
    \box\BA@block@box}
  \unvbox\BA@final@box}}
%    \end{macrocode}
%
%
% Place the delimiters or spanning entries in position for one column of
% the current block.
%    \begin{macrocode}
\def\BA@lr#1{%
 \global\advance\BA@col\@ne\relax
 \BA@col@use{left}%
 \BA@col@expafter\ifx{mid}\@empty
   \kern#1
 \else
   \hbox to #1{%
      \setbox\BA@tempbox@a
        \hbox{\let\BA@mrow@bslash\@gobble\BA@col@use{u}\BA@edollar}%
      \setbox\BA@tempbox@b
        \hbox{\BA@bdollar\BA@col@use{v}}%
     \kern\wd\BA@tempbox@a
     $\vcenter{%
      \hsize=#1
      \advance\hsize-\wd\BA@tempbox@a
      \advance\hsize-\wd\BA@tempbox@b
      \@parboxrestore\BA@col@use{mid}}$%
     \kern\wd\BA@tempbox@b}%
 \fi
 \BA@col@use{right}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@leftdel#1#2#3{%
  \llap{%
    {#1}$\left#2\vrule height \dimen\z@ width\z@ \right.$\kern-#3}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@rightdel#1#2#3{%
  \rlap{%
    \kern-#3$\left.\vrule height \dimen\z@ width\z@ \right#1${#2}}}%
%    \end{macrocode}
%
% \subsection{Parsing the Column Specifications}
%
% A token "x" in the column specification, is interpreted by "\BA@parse"
% as "\BA@<x>". This command is then expanded, which may take further
% tokens as arguments.
% The expansion of "\BA@<x>" is supposed to end with a call to
% "\BA@parse" which will convert the token following any arguments to a
% control sequence name. The process is terminated by the token
% "\BA@parseend" as the coresponding command "\BA@<\BA@parseend>" does
% some `finishing off', but does not call "\BA@parse".
%
% There are two commands to help in defining column types.\\
% "\BA@defcolumntype" This takes its parameter specification in the
% primitive "\def" syntax, and allows the replacement text to be
% anything.\\
% "\BAnewcolumntype" This takes its parameter specification in \LaTeX's
% "\newcommand" syntax, and applies "\BA@parse" to the {\em front\/} of
% the replacement text. This is intended for users to define their own
% column types in terms of primitive column types, rather than in terms
% of arbitrary \TeX\ expressions.
%
% The preamble argument build up various macros as as follows:
%
% Each entry in the "\halign" preamble is of the form\\
% "\BA@upart#\BA@vpart"\\
% "\BA@upart" increments "\BA@col", and then expands
% "\BA@col@use{u}", similarly "\BA@vpart" expands
% "\BA@col@use{v}".
%
% "\BA@col@use{u}" is a macro considered local to the current block
% and column, it is always accessed via "\BA@col@use" or
% "\BA@col@expafter". So the preamble entries must result in
% "\BA@col@use{u}" and "\BA@col@use{v}" being defined to enter
% any text specified in "@"-expressions, the inter-column space (in the
% \LaTeX\ tradition, not "\tabskip"), and any declarations in ">" and
% "<" expressions. Delimiters are not added to these macros as they
% correspond to the whole block, they are left in the macros
% "\BA@col@use{left}" and "\BA@col@use{right}" spanning entries from
% "\BAmultirow" are considered like delimiters, and left in
% "\BA@col@use{mid}".
%
% If the test "\testBA@upart" is true, then the \meta{u-part} is being
% built. This consists of three different sections.\\
% 1) The left inter-column text, declared in "!"- and "@"-expressions\\
% 2) The left inter-column skip.\\
% 3) Any declarations specified in ">" expressions.
%
% Suppose "X" is a column type, which may itself be defined in terms of
% other column types, then the (equivalent) specifications:\\
% "@{aaa}>{\foo}X" and ">{\foo}@{aaa}X"\\
% must result in "aaa", surrounded by
% {\tt\protect\bslash bgroup}\ldots{\tt\protect\bslash egroup} or
% {\tt\$}\ldots{\tt\$},  being prepended to the
% {\em front\/} of the u-part, and "\foo" being appended to the end, so
% that it is the innermost declaration to be applied to the entries in
% that column.
%
% In order to achieve this, ">" expressions are directly added to the
% u-part, using "\GC@add@to@front", "@"- and "!"- expressions (and rules
% from "|") are added to a scratch macro, "\BA@l@expr", using
% "\GC@add@to@end".
%
% When the next "#" column specifier is reached, the "\BA@l@expr" is
% added to the front of the u-part, It is separated from the
% ">"-expressions by a \meta{hskip} unless an "@"-expression has
% occured, either while building the current u-part, or the previous
% v-part.
%
%  Building the v-part is similar.
%
% This procedure has certain consequences,
% \begin{itemize}
%  \item "@{a}@{b}" is equivalent to "@{ab}", or more correctly
%  "@{{a}{b}}".
%  \item ">{\a}>{\b}" is equivalent to ">{\b\a}".
% \item If any "@"-expression occurs between two columns, all
% "!"-expressions between those columns will be treated identically to
% "@"-expressions. This differs from {\tt array.sty} where two
% "!"-expressions are separated by the same skip as the rules specified
%   by "||".
%  \item If any rule "|" occurs, then a following rule will be preceded
%  by the doubleruleskip, unless a "@" or "!"-expression comes between
%  them. In particular "|&|" specifies a double rule, which looks the
%  same as "||", but "\multicolumn" commands can be used to remove one
%  or other of the rules for certain entries.
% \end{itemize}
%
% Create a macro name from a column specifier.
%    \begin{macrocode}
\def\BA@stringafter#1#2{\expandafter#1\csname BA@<\string#2>\endcsname}
%    \end{macrocode}
%
% Execute the specifier, or discard an unknown one, and try the next
% token.
%    \begin{macrocode}
\def\BA@parse#1{%
  \BA@stringafter\testGC@x{#1}\relax
    {\@latexerr {Unknown column type, \string#1}\@ehc\BA@parse}%
    {\csname BA@<\string#1>\endcsname}}
%    \end{macrocode}
%
% "\def" for column types.
%    \begin{macrocode}
\def\BA@defcolumntype#1{%
  \BA@stringafter\def{#1}}
%    \end{macrocode}
%
% "\newcommand" for column types.\footnote{Currently does not check that
% the type is new.}
%    \begin{macrocode}
\def\BAnewcolumntype{\@ifnextchar[{\BA@nct}{\BA@nct[0]}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@nct[#1]#2#3{%
  \BA@stringafter\@reargdef{#2}[#1]{\BA@parse#3}}
%    \end{macrocode}
%
% These "\if"s will be true if their associated skips are to be added in
% the current column.
%    \begin{macrocode}
\newif\ifBA@colsep
\newif\ifBA@rulesep
%    \end{macrocode}
%
% This is true if we do not need to come back up the array.
%    \begin{macrocode}
\GC@newtest{BA@quick}
%    \end{macrocode}
%

% This will be true if building the \meta{u-part}, and false if building
% the \meta{v-part}.
%    \begin{macrocode}
\GC@newtest{BA@upart}
%    \end{macrocode}
%
%
% \subsection{`Internal' Column-Type Definitions}
%
% ">" expressions:\\
%  If we are building the v-part, add a "&", and try
% again, so that "c<{\a}>{\b}c" is equivalent to "c<{\a}&>{\b}c".\\
% Otherwise add the expression to the front of the u-part, i.e., the
% list being built in "\BA@col@use{u}". Note that no grouping is added
% so that the scope of any declaration includes the column entry.
%    \begin{macrocode}
\BA@defcolumntype{>}#1{%
  \testBA@upart
   {\BA@col@expafter\GC@add@to@front{u}{#1}%
    \BA@parse}%
   {\BA@parse &>{#1}}}
%    \end{macrocode}
%
% Left delimiters:\\
% Again add a "&" if required, otherwise just save the delimiter and
% label as the first two arguments of "\BA@left@del" in the macro
% "\BA@col@use{left}".
%    \begin{macrocode}
\BA@defcolumntype{\Left}#1#2{%
  \testBA@upart
   {\global\BA@quickfalse
    \BA@col@expafter\gdef{left}{\BA@leftdel{#1}{#2}}\BA@parse}%
   {\BA@parse &\Left{#1}{#2}}}
%    \end{macrocode}
%
% Right delimiters: As for Left.
%    \begin{macrocode}
\BA@defcolumntype{\Right}#1#2{%
  \testBA@upart
   {\BA@parse ##\Right{#1}{#2}}
   {\global\BA@quickfalse
    \BA@col@expafter\gdef{right}{\BA@rightdel{#1}{#2}}\BA@parse}}%
%    \end{macrocode}
%
% "&" The end of each column specification is terminated by "&", either
% by the user explicitly entering "&", or one being added by one of the
% other rewrites.\\
% If we are still in the u-part, finish it off with "#".\\
% Otherwise add another column to the blank row, advance the column
% counter by one. Finally reset the variables
% $"\BA@use{u"|"v"|"left"|"mid"|"right}"$
%    \begin{macrocode}
\BA@defcolumntype{&}{%
  \testBA@upart
   {\BA@parse ##&}%
   {%
    \BA@expafter\xdef{blank@row}{\BA@use{blank@row}\omit&}%
    \global\advance\BA@col\@ne
    \BA@clear@entry
    \BA@parse}}
%    \end{macrocode}
%
% "#" Add a "&" if required.\\
% Otherwise make the u-part of the current column, and the v-part of the
% previous one.
%
%    \begin{macrocode}
\BA@defcolumntype{#}{%
  \testBA@upart
   {%
%    \end{macrocode}
% Add the intercolumn skips unless a "@" expression has occured since
% the last "#" entry.
%    \begin{macrocode}
    \ifBA@colsep
       \GC@add@to@front\BA@r@expr{\BA@edollar\hskip\BA@colsep}%
       \GC@add@to@end\BA@l@expr{\hskip\BA@colsep\BA@bdollar}%
    \else
       \GC@add@to@front\BA@r@expr{\BA@edollar}%
       \GC@add@to@end\BA@l@expr{\BA@bdollar}%
    \fi
%    \end{macrocode}
% Go back to the previous column. Add "\BA@r@expr" to the end of
% "\BA@col@use{v}".
%    \begin{macrocode}
    \global\advance\BA@col\m@ne
    \BA@col@expafter\GC@add@to@end{v\expandafter}\expandafter
           {\BA@r@expr}%
%    \end{macrocode}
% Add the total width of any "@" expressions as the third argument in
% the right delimiter macro, this will be used to move the delimiters
% past any inter-column material.
%    \begin{macrocode}
    \BA@add@rskip
%    \end{macrocode}
% Repeat for the u-part, and left delimiter of the current column.
%    \begin{macrocode}
    \global\advance\BA@col\@ne
    \BA@col@expafter\GC@add@to@front{u\expandafter}\expandafter
           {\BA@l@expr}%
     \BA@add@lskip
%    \end{macrocode}
% Clear these scratch macros ready for the next column.
%    \begin{macrocode}
    \global\let\BA@l@expr\@empty\global\let\BA@r@expr\@empty
%    \end{macrocode}
% Reset these tests and ifs, ready for the next inter-column material.
%    \begin{macrocode}
    \BA@upartfalse
    \BA@rulesepfalse
    \BA@colseptrue
%    \end{macrocode}
% Finally look at the next specifier.
%    \begin{macrocode}
    \BA@parse}%
   {\BA@parse &##}}
%    \end{macrocode}
%
% "<" Just like ">".
%    \begin{macrocode}
\BA@defcolumntype{<}#1{%
  \testBA@upart
   {\BA@parse ##<{#1}}%
   {\BA@col@expafter\GC@add@to@front{v}{#1}\BA@parse}}
%    \end{macrocode}
%
% "BA" version of "\vline".
%    \begin{macrocode}
\def\BA@vline{\vrule \@width \BAarrayrulewidth}
%    \end{macrocode}
%
% "|" like "!", except that a "\hskip\BAdoublerulesep" is added for
% consecutive pairs.
%    \begin{macrocode}
\BA@defcolumntype{|}{%
  \testBA@upart
   {\ifBA@rulesep
      \GC@add@to@end\BA@l@expr{\hskip\BAdoublerulesep\BA@vline}%
    \else
      \GC@add@to@end\BA@l@expr{\BA@vline}%
    \fi}%
   {\ifBA@rulesep
      \GC@add@to@end\BA@r@expr{\hskip\BAdoublerulesep\BA@vline}%
    \else
      \GC@add@to@end\BA@r@expr{\BA@vline}%
    \fi}%
  \BA@ruleseptrue
  \BA@parse}
%    \end{macrocode}
%
% "@" identical to "!", but set "\BA@colsepfalse".
%    \begin{macrocode}
\BA@defcolumntype{@}#1{%
  \testBA@upart
   {\GC@add@to@end\BA@l@expr{\BA@bdollar#1\BA@edollar}}%
   {\GC@add@to@end\BA@r@expr{\BA@bdollar#1\BA@edollar}}%
  \BA@colsepfalse
  \BA@rulesepfalse
  \BA@parse}
%    \end{macrocode}
%
% "!" Just save the expression, and make "\BA@rulesepfalse" so that the
% next "|" is not preceded by a skip.
%    \begin{macrocode}
\BA@defcolumntype{!}#1{%
  \testBA@upart
   {\GC@add@to@end\BA@l@expr{\BA@bdollar#1\BA@edollar}}%
   {\GC@add@to@end\BA@r@expr{\BA@bdollar#1\BA@edollar}}%
  \BA@rulesepfalse
  \BA@parse}
%    \end{macrocode}
%
% "*": "*{3}{xyz}" just produces "xyz*{2}{xyz}" which is then re-parsed.
%    \begin{macrocode}
\BA@defcolumntype{*}#1#2{%
 \count@=#1\relax
 \ifnum\count@>\z@
    \advance\count@\m@ne
    \edef\@tempa##1{\noexpand\BA@parse##1*{\the\count@}{##1}}%
 \else
    \def\@tempa##1{\BA@parse}%
 \fi
 \@tempa{#2}}
%    \end{macrocode}
%
% "\BA@parseend" this is added to the end of the users preamble, it acts
% like a cross between "#" and "&". It terminates the preamble building
% as it does not call "\BA@parse".
%    \begin{macrocode}
\BA@defcolumntype{\BA@parseend}{%
  \testBA@upart
   {\BA@parse ##\BA@parseend}%
   {%
    \ifBA@colsep
       \GC@add@to@front\BA@r@expr{\BA@edollar\hskip\BA@colsep}%
    \else
       \GC@add@to@front\BA@r@expr{\BA@edollar}%
    \fi
    \BA@expafter\xdef{blank@row}{\BA@use{blank@row}\omit\cr}%
    \BA@add@rskip
    \BA@col@expafter\GC@add@to@end{v\expandafter}\expandafter
           {\BA@r@expr}}}
%    \end{macrocode}
%
% Like {\tt array.sty}
%    \begin{macrocode}
\def\BA@startpbox#1{\bgroup
  \hsize #1 \@arrayparboxrestore
   \vrule \@height \ht\@arstrutbox \@width \z@}

\def\BA@endpbox{\vrule \@width \z@ \@depth \dp \@arstrutbox \egroup}
%    \end{macrocode}
%
% Save the "&" and "#" macros, so they can be restored after a
% multicolumn, which redefines them.
%    \begin{macrocode}
\BA@stringafter{\let\expandafter\BA@save@amp}{&}
\BA@stringafter{\let\expandafter\BA@save@hash}{#}
%    \end{macrocode}
%
% A column specification of "\BAmulticolumn{3}{c}" is re-written to:\\
% "c\BA@MC@end", except that the definition of "#" has been changed so
% that it expands to:\\
% ">{\null\span\span}\BA@MC@restore@hash&@{}&@{}\BA@MC@switch@amp"\\
% The 2 "\span"s in the u-part make the entry span 3 columns, the 2
% "&@{}" increment "\BA@col" without adding any intercolumn skips.
% The "\BA@MC@restore@hash" specifier just restores "#" to its normal
% meaning. "\BA@MC@switch@amp" then causes a specifier "&" to generate
% an error, as the argument to multicolumn may only specify one column.
% Finally when "\BA@MC@end" is reached, "&" is restored.
%
% "\BA@MC@restore@hash" restore the meaning of "#".
%    \begin{macrocode}
\BA@defcolumntype{\BA@MC@restore@hash}{%
  \BA@stringafter\let{##}\BA@save@hash
  \BA@parse}
%    \end{macrocode}
%
% Switch the meaning of "&" so it generates an error, and skips all
% specifiers up to "\BA@MC@end"
%    \begin{macrocode}
\BA@defcolumntype{\BA@MC@switch@amp}{%
  \BA@stringafter\let{&}\BA@extra@amp
  \BA@parse}
%    \end{macrocode}
%
% Restore "&".
%    \begin{macrocode}
\BA@defcolumntype{\BA@MC@end}{%
  \BA@stringafter\let{&}\BA@save@amp
  \BA@parse}
%    \end{macrocode}
%
% The special definition of "&" while parsing the multicolumn argument.
%    \begin{macrocode}
\def\BA@mc@extra@amp#1\BA@MC@end{%
     \@latexerr{\string& in multicolumn!}\@ehc\BA@parse\BA@MC@end}%
%    \end{macrocode}
%
% Putting it all together!
%    \begin{macrocode}
\BA@defcolumntype{\BAmulticolumn}#1#2{%
  \BA@make@mc{#1}%
  \BA@stringafter\let{##}\BA@mc@hash
  \BA@parse#2\BA@MC@end}
%    \end{macrocode}
%
% As explained above, in order to position the delimiters on the way
% back we need the widths of the inter-column texts.
%    \begin{macrocode}
\def\BA@add@rskip{%
  \BA@col@expafter\ifx{right}\relax\else
    \setbox\BA@tempbox@a\hbox{\BA@bdollar\BA@r@expr}%
    \BA@col@expafter\GC@add@to@end{right\expandafter}\expandafter
       {\expandafter{\the\wd\BA@tempbox@a}}\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@add@lskip{%
  \BA@col@expafter\ifx{left}\relax\else
    \setbox\BA@tempbox@a\hbox{\BA@l@expr\BA@edollar}%
    \BA@col@expafter\GC@add@to@end{left\expandafter}\expandafter
      {\expandafter{\the\wd\BA@tempbox@a}}\fi}
%    \end{macrocode}
%
% \subsection{User Level Column-Type Definitions}
%
%    \begin{macrocode}
\BAnewcolumntype{c}   {>{\hfil}<{\hfil}}
\BAnewcolumntype{l}   {>{}<{\hfil}}
\BAnewcolumntype{r}   {>{\hfil}<{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\BAnewcolumntype[1]{p}{>{\vtop\BA@startpbox{#1}}c<{\BA@endpbox}}
\BAnewcolumntype[1]{m}{>{$\vcenter\BA@startpbox{#1}}c<{\BA@endpbox$}}
\BAnewcolumntype[1]{b}{>{\vbox\BA@startpbox{#1}}c<{\BA@endpbox}}
%    \end{macrocode}
%
%    \begin{macrocode}
\BAnewcolumntype{(}  {\Left{}{(}}
\BAnewcolumntype{)}  {\Right{)}{}}
\BAnewcolumntype{\{} {\Left{}{\{}}
\BAnewcolumntype{\}} {\Right{\}}{}}
\BAnewcolumntype{[}  {\Left{}{[}}
\BAnewcolumntype{]}  {\Right{]}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\BAnewcolumntype{\BAenum}  {%
  !{%
    {\def\protect{\noexpand\protect\noexpand}%
     \xdef\@currentlabel{\p@BAenumi\theBAenumi}}
    \hbox to 2em{%
    \hfil\theBAenumi}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\BAnewcolumntype[1]{\BAmultirow}{>{\BA@mrow@bslash{#1}}##}
%    \end{macrocode}
%
% \subsection{Footnotes}
%
% This test is true if footnote texts are to be displayed at the end of
% the table.
%    \begin{macrocode}
\GC@newtest{BAtablenotes}
\BAtablenotestrue
%    \end{macrocode}
%
% Inside the alignment just save up the footnote text in a token
% register.
%    \begin{macrocode}
\long\def\BA@ftntext#1{%
  \edef\@tempa{\the\BA@ftn\noexpand\footnotetext
                    [\the\csname c@\@mpfn\endcsname]}%
  \global\BA@ftn\expandafter{\@tempa{#1}}}%
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\BA@xftntext[#1]#2{%
  \global\BA@ftn\expandafter{\the\BA@ftn\footnotetext[#1]{#2}}}
%    \end{macrocode}

% \subsection{Hline and Hhline}
% The standard "\hline" command would work fine `on the way down' but on
% the way back it throws me into an infinite loop as there is no
% "\lastrule" to move the rule into the final box. I could just make
% "\hline" leave a code penalty, and put in the rule on the way back,
% but this would mean that every array with an "\hline" needs to be
% taken apart. I hope to make `most' arrays be possible without comming
% back up the array via "\lastbox". I could do something with
% "\leaders" which are removable, but for now, I just make "\hline" and
% "\hline\hline" just call "\hhline" with the appropriate argument.
% The "\hhline" from {\tt hhline.sty} does work, but needs extra options
% to deal with "&" etc, but here is a re-implementation, more in the
% spirit of this style.
%
%    \begin{macrocode}
\def\BAhline{%
  \noalign{\ifnum0=`}\fi
   \futurelet\@tempa\BA@hline}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@hline{%
  \ifx\@tempa\BAhline
    \gdef\BA@hline@@##1{\BAhhline{*{\BA@col@max}{=}}}%
  \else
    \gdef\BA@hline@@{\BAhhline{*{\BA@col@max}{-}}}%
  \fi
  \ifnum0=`{\fi}%
  \BA@hline@@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BAhhline#1{%
  \omit
%    \end{macrocode}
% First set up the boxes used in "\leaders".
%    \begin{macrocode}
\global\setbox\BA@ddashbox=\BA@HHbox\BAarrayrulewidth\BAarrayrulewidth
\global\setbox\BA@dashbox=\hbox to \GC@six\BAarrayrulewidth{%
  \hss
  \vrule\@height\BAarrayrulewidth \@width\BAarrayrulewidth \@depth\z@
  \hss}%
%    \end{macrocode}
%
%    \begin{macrocode}
  \global\let\BA@strut\BA@strutB
  \global\BA@rulesepfalse
  \global\BA@uparttrue
  \BA@HHparse#1\BA@HHend}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@HHexp#1#2{\expandafter#1\csname aa\string#2\endcsname}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@HHparse{{\ifnum0=`}\fi\BA@HHparsex}
\def\BA@HHparsex#1{\BA@HHexp\aftergroup{#1}\ifnum0=`{\fi}}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def\BA@HHend{%
  \cr}
%    \end{macrocode}
%
%    \begin{macrocode}
\newbox\BA@dashbox
\newbox\BA@ddashbox
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def|{%
  \ifBA@rulesep\hskip\BAdoublerulesep\fi
  \global\BA@ruleseptrue
  \vrule\@width\BAarrayrulewidth
  \BA@HHparse}
%    \end{macrocode}
%
% ":" denotes a broken vertical rule, as in "hhline.sty". If the double
% dots \hbox{\leaders\hbox {\,:\,}\hskip3em} currently produced by
% \verb|"| turn out to be useful, it might be better to use ":" for
% them, and something else, perhaps "!" for this feature.
%    \begin{macrocode}
\BA@HHexp\def:{%
  \ifBA@rulesep\hskip\BAdoublerulesep\fi
  \global\BA@ruleseptrue
  \copy\BA@ddashbox
  \BA@HHparse}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def-{%
  \testBA@upart{}{&\omit\global\BA@uparttrue}%
  \leaders\hrule\@height\BAarrayrulewidth\hfil
  \global\BA@upartfalse
  \global\BA@rulesepfalse
  \BA@HHparse}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def.{%
  \testBA@upart{}{&\omit\global\BA@uparttrue}%
  \copy\BA@dashbox\xleaders\copy\BA@dashbox\hfil\copy\BA@dashbox
  \global\BA@rulesepfalse
  \global\BA@upartfalse
  \BA@HHparse}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def"{%
  \testBA@upart{}{&\omit\global\BA@uparttrue}%
  \setbox\z@\hbox to \GC@six\BAarrayrulewidth
       {\hss\copy\BA@ddashbox\hss}%
  \copy\z@\xleaders\copy\z@\hfil\copy\z@
  \global\BA@rulesepfalse
  \global\BA@upartfalse
  \BA@HHparse}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def={%
  \testBA@upart{}{&\omit\global\BA@uparttrue}%
  \copy\BA@ddashbox\xleaders\copy\BA@ddashbox\hfil\copy\BA@ddashbox
  \global\BA@rulesepfalse
  \global\BA@upartfalse
  \BA@HHparse}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def~{%
  \testBA@upart{}{&\omit\global\BA@uparttrue}%
  \hfill
  \global\BA@rulesepfalse
  \global\BA@upartfalse
  \BA@HHparse}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def#{%
  \ifBA@rulesep\hskip\BAdoublerulesep\fi
  \global\BA@ruleseptrue
  \vrule\@width\BAarrayrulewidth
  \BA@HHbox\BAdoublerulesep\BAdoublerulesep
  \vrule\@width\BAarrayrulewidth
  \BA@HHparse}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def{t}{%
  \rlap{\BA@HHbox\BAdoublerulesep\z@}%
  \BA@HHparse}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def{b}{%
  \rlap{\BA@HHbox\z@\BAdoublerulesep}%
  \BA@HHparse}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\BA@HHbox#1#2{\vbox{%
  \hrule \@height \BAarrayrulewidth \@width #1
  \vskip \BAdoublerulesep
  \hrule \@height \BAarrayrulewidth \@width #2}}
%    \end{macrocode}
%
%    \begin{macrocode}
\BA@HHexp\def&{&\omit\global\BA@uparttrue\BA@HHparse}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\BA@HHexp\def{*}#1#2{%
 \count@=#1\relax
 \ifnum\count@>\z@
    \advance\count@\m@ne
    \edef\next##1{\noexpand\BA@HHparse##1*{\the\count@}{##1}}%
 \else
    \def\next##1{\BA@HHparse}%
 \fi
 \next{#2}}
%    \end{macrocode}
%
% \end{document}
\endinput