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
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
|
% \iffalse meta-comment balanced on line 107
% ltxutil.dtx: utilities package
% Copyright (c) 2009 Arthur Ogawa
%
% Disclaimer
% This file is distributed WITHOUT ANY WARRANTY;
% without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% License
% You may distribute this file under the conditions of the
% LaTeX Project Public License 1.3c or later
% (http://www.latex-project.org/lppl.txt).
% ReadMe
% For the documentation and more detailed instructions for
% installation, typeset this document with \LaTeX.
% Maintenance Status
% This work has the LPPL maintenance status "maintained";
% Current Maintainer of this work is Arthur Ogawa.
%
% This work consists of the main source file ltxutil.dtx
% and the derived files
% ltxutil.sty, ltxutil.pdf
% Distribution:
% CTAN:macros/latex/contrib/revtex/
%
% Unpacking:
% tex ltxutil.dtx
%
% Documentation:
% latex ltxutil.dtx; ...
%
% Program calls to get the documentation (example):
% pdflatex ltxutil.dtx
% makeindex -s gind.ist ltxutil.idx
% makeindex -s gglo.ist -o ltxutil.gls ltxutil.glo
% pdflatex ltxutil.dtx
% makeindex -s gind.ist ltxutil.idx
% pdflatex ltxutil.dtx
%
% Installation:
% TDS:doc/latex/revtex/
% TDS:source/latex/revtex/
% TDS:tex/latex/revtex/
%
% Thanks, Heiko!
% This method of letting a single .dtx file serve as both
% documentation (via latex) and installer (via tex) follows
% the example of Heiko Oberdiek. Thanks!
%<*ignore>
\begingroup
\def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase
0\expandafter\ifx\csname processbatchFile\endcsname\relax\else1\fi\ifx\fmtname\x\else 1\fi
\relax
\else
\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip
\preamble
This is a generated file;
altering it directly is inadvisable;
instead, modify the original source file.
See the URL in the file README-LTXUTIL.tex.
License
You may distribute this file under the conditions of the
LaTeX Project Public License 1.3c or later
(http://www.latex-project.org/lppl.txt).
This file is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
\endpreamble
\askforoverwritefalse
\keepsilent
\generate{%
%{ignore}
\file{ltxutil.sty}{%
\from{ltxutil.dtx}{package,kernel}%
}%
\file{ltxutil.krn}{%
\from{ltxutil.dtx}{kernel}%
}%
}%
\ifToplevel{
\Msg{***********************************************************}
\Msg{*}
\Msg{* To finish the installation, please move}
\Msg{* ltxutil.sty}
\Msg{* into a directory searched by TeX;}
\Msg{* in a TDS-compliant installation:}
\Msg{* texmf/tex/macros/latex/revtex/.}
\Msg{*}
\Msg{* To produce the documentation,
run ltxutil.dtx through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing}
\Msg{***********************************************************}
}
\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
% \fi
%
% \GetFileInfo{ltxutil.dtx}\CheckSum{4291}
%
% \iffalse ltxdoc klootch
%<*package>
%%% @LaTeX-file{
%%% filename = "ltxutil.dtx",
%%% version = "4.2c",
%%% date = "2019/01/18",
%%% time = "14:29:48 UT-5",
%%% checksum = "4291",
%%% author = "Arthur Ogawa (mailto:arthur_ogawa at sbcglobal.net),
%%% commissioned by the American Physical Society. Minor changes by Mark Doyle for version 4.2a-c.
%%% ",
%%% copyright = "Copyright (C) 1999, 2009 Arthur Ogawa,
%%% distributed under the terms of the
%%% LaTeX Project Public License 1.3c, see
%%% ftp://ctan.tug.org/macros/latex/base/lppl.txt
%%% ",
%%% address = "Arthur Ogawa,
%%% USA",
%%% telephone = "",
%%% FAX = "",
%%% email = "mailto colon arthur_ogawa at sbcglobal.net",
%%% codetable = "ISO/ASCII",
%%% keywords = "latex, page grid, main vertical list",
%%% supported = "yes",
%%% abstract = "utilities package",
%%% docstring = "The checksum field above generated by ltxdoc",
%%% }
%</package>
% \fi
%
% \iffalse ltxdoc klootch
% The following references the \file{README-LTXUTIL} file,
% which contains basic information about this package.
% The contents of this file are generated when
% you typeset the programmer's documentation.
% Search on "{filecontents*}{README-LTXUTIL}" to locate it.
% \fi\input{README-LTXUTIL}%
%
% \subsection{Bill of Materials}
%
% Following is a list of the files in this distribution arranged
% according to provenance.
%
% \subsubsection{Primary Source}%
% One single file generates all.
%\begin{verbatim}
%ltxutil.dtx
%\end{verbatim}
%
% \subsubsection{Generated by \texttt{latex ltxutil.dtx}}%
% Typesetting the source file under pdflatex
% generates the readme and the documentation.
%\begin{verbatim}
%README-LTXUTIL ltxutil.pdf
%\end{verbatim}
%
% \subsubsection{Generated by \texttt{tex ltxutil.dtx}}%
% Typesetting this file with \TeX\ generates
% the package file.
%\begin{verbatim}
%ltxutil.sty
%\end{verbatim}
%
% \subsubsection{Auxiliary}%
% The following are auxiliary files generated
% in the course of running \LaTeX:
% \begin{verbatim}
%ltxutil.aux ltxutil.idx ltxutil.ind ltxutil.log ltxutil.toc
% \end{verbatim}
%
% \section{Code common to all modules}%
%
% We want to require only one place in this file
% where the version number is stated,
% and we also want to ensure that the version
% number is embedded into every generated file.
%
% Now we declare that
% these files can only be used with \LaTeXe.
% An appropriate message is displayed if
% a different \TeX{} format is used.
% \begin{macrocode}
%<*doc|package>
\NeedsTeXFormat{LaTeX2e}[1995/12/01]%
%</doc|package>
% \end{macrocode}
% As desired, the following modules all
% take common version information:
% \begin{macrocode}
%<kernel&!package&!doc>\typeout{%
%<*package|doc>
\ProvidesFile{%
%</package|doc>
%<*kernel|package|doc>
ltxutil%
%</kernel|package|doc>
%<*doc>
.dtx%
%</doc>
%<package>.sty%
%<*package|doc>
}%
%</package|doc>
% \end{macrocode}
%
% The following line contains, for once and for all,
% the version and date information.
% By various means, this information is reproduced
% consistently in all generated files and in the
% typeset documentation.
% Give credit where due.
% \begin{macrocode}
%<*doc|package|kernel>
%<version>
[2019/01/18/14:29:48 4.2c utilities package (portions licensed from W. E. Baxter web at superscript.com)]% \fileversion
%</doc|package|kernel>
%<kernel&!package&!doc>}%
% \end{macrocode}
%
%
% \section{The driver module \texttt{doc}}
%
% This module, consisting of the present section,
% typesets the programmer's documentation,
% generating the \file{README-LTXUTIL} as required.
%
% Because the only uncommented-out lines of code at the beginning of
% this file constitute the \file{doc} module itself,
% we can simply typeset the \file{.dtx} file directly,
% and there is thus rarely any need to
% generate the ``doc'' {\sc docstrip} module.
% Module delimiters are nonetheless required so that
% this code does not find its way into the other modules.
%
% The \enve{document} command concludes the typesetting run.
%
% \begin{macrocode}
%<*doc>
% \end{macrocode}
%
% \subsection{The Preamble}
% The programmers documentation is formatted
% with the \classname{ltxdoc} class with local customizations,
% and with the usual code line indexing.
% \begin{macrocode}
\documentclass{ltxdoc}
\RequirePackage{ltxdocext}%
\let\url\undefined
\RequirePackage[colorlinks=true,linkcolor=blue]{hyperref}%
%\expandafter\ifx\csname package@font\endcsname\@undefined\else
% \expandafter\RequirePackage\expandafter{\csname package@font\endcsname}%
%\fi
\CodelineIndex\EnableCrossrefs % makeindex -s gind.ist ltxutil
\RecordChanges % makeindex -s gglo.ist -o ltxutil.gls ltxutil.glo
% \end{macrocode}
%
% \subsubsection{Docstrip and info directives}
% We use so many {\sc docstrip} modules that we set the
% \texttt{StandardModuleDepth} counter to 1.
% \begin{macrocode}
\setcounter{StandardModuleDepth}{1}
% \end{macrocode}
% The following command retrieves the date and version information
% from this file.
% \begin{macrocode}
\expandafter\GetFileInfo\expandafter{\jobname.dtx}%
% \end{macrocode}
%
% \subsection{The ``Read Me'' File}
% As promised above, here is the contents of the
% ``Read Me'' file. That file serves a double purpose,
% since it also constitutes the beginining of the
% programmer's documentation. What better thing, after
% all, to have appear at the beginning of the
% typeset documentation?
%
% A good discussion of how to write a ReadMe file can be found in
% Engst, Tonya, ``Writing a ReadMe File? Read This''
% \emph{MacTech} October 1998, p. 58.
%
% Note the appearance of the
% \cmd\StopEventually\ command, which marks the
% dividing line between the user documentation
% and the programmer documentation.
%
% The usual user will not be asked to
% do a full build, not to speak
% of the bootstrap.
% Instructions for carrying out these procedures
% begin the programmer's manual.
%
% \begin{macrocode}
\begin{filecontents*}{README-LTXUTIL}
\title{%
A \LaTeX\ Package of utility macros%
\thanks{%
This file has version number \fileversion,
last revised \filedate.%
}%
\thanks{%
Version \fileversion\ \copyright\ 2019 American Physical Society
}%
}%
\author{%
Arthur Ogawa%
\thanks{\texttt{mailto:arthur\_ogawa at sbcglobal.net}}%
}%
%\iffalse
% For version number and date,
% search on "\fileversion" in the .dtx file,
% or see the end of the README-LTXUTIL file.
%\fi
\maketitle
This file embodies the \classname{ltxutil} package,
the implementation and its user documentation.
The distribution point for this work is
\url{journals.aps.org/revtex},
which contains prebuilt runtime files, documentation, and full source,
ready to add to a TDS-compliant \TeX\ installation.
The \classname{ltxutil} package was commissioned by the American Physical Society
and is distributed under the terms of the \LaTeX\ Project Public License 1.3c,
the same license under which all the portions of \LaTeX\ itself are distributed.
Please see \url{http://ctan.tug.org/macros/latex/base/lppl.txt} for details.
To use this document class, you must have a working
\TeX\ installation equipped with \LaTeXe\
and possibly pdftex and Adobe Acrobat Reader or equivalent.
To install, retrieve the distribution,
unpack it into a directory on the target computer,
and move the file \file{ltxutil.sty}
into a location in your filesystem where it will be found by \LaTeX.
To use, read the user documentation \file{ltxutil.pdf}.
\tableofcontents
\section{Processing Instructions}
The package file \file{ltxutil.sty}
is generated from this file, \file{ltxutil.dtx},
using the {\sc docstrip} facility of \LaTeX
via |tex ltxutil.dtx| (Note: do \emph{not} use \LaTeX\ for this task).
The typeset documentation that you are now reading is generated from
the same file by typesetting it with \LaTeX\ or pdftex
via |latex ltxutil.dtx| or |pdflatex ltxutil.dtx|.
\subsection{Build Instructions}
You may bootstrap this suite of files solely from \file{ltxutil.dtx}.
Prepare by installing \LaTeXe\ (and either tex or pdftex) on your computer,
then carry out the following steps:
\begin{enumerate}
\item
Within an otherwise empty directory,
typeset \file{ltxutil.dtx} with \LaTeX\ or pdflatex;
you will obtain the typeset documentation you are now reading,
along with the file \file{README-LTXUTIL}.
Note: you will have to run \LaTeX, then
\file{makeindex} \texttt{-s gind.ist ltxutil.idx}, then
\file{makeindex} \texttt{-s gglo.ist -o ltxutil.gls ltxutil.glo}, then
\LaTeX\ again in order to obtain a valid index and table of contents.
\item
Now typeset \file{ltxutil.dtx} with \TeX (not \LaTeX),
thereby generating the package file \file{ltxutil.sty}.
\item
Install the following files into indicated locations within your
TDS-compliant \texttt{texmf} tree (you may need root access):
\begin{itemize}
\item
\file{$TEXMF/}\file{tex/}\file{latex/}\file{revtex/}\classname{ltxutil.sty}
\item
\file{$TEXMF/}\file{source/}\file{latex/}\file{revtex/}\classname{ltxutil.dtx}
\item
\file{$TEXMF/}\file{doc/}\file{latex/}\file{revtex/}\classname{ltxutil.pdf}
\end{itemize}
where \file{$TEXMF/} stands for \file{texmf-local/}, or some other \texttt{texmf} tree
in your installation.
\item
Run \texttt{mktexlsr} on \file{$TEXMF/} (you may need root access).
\item
Build and installation are now complete;
now put a \cmd\usepackage\texttt{\{ltxutil\}} in your document preamble!
\end{enumerate}
\subsection{Change Log}
\changes{4.0b}{1999/06/20}{AO: Fixed spurious \texttt{CR} and (return) characters in output file. Also, if the document did not have the \cs{end}\texttt{figure} on a line of its own, the macro wouldn't work. Fixed.}
\changes{4.0b}{1999/06/20}{AO: Removed superfluous \cs{def}s, changed to using \cs{floats@sw} as the flag. Also stopped using DPC's \cs{if@twocolumn} flag: using \cs{floats@sw} instead. Also added \cs{par}\cs{vskip}\cs{z@skip} after the \cs{minipagefootnotes} so that the float box would have zero depth like the kernel one. }
\changes{4.0b}{1999/06/20}{only execute if there really were floats of the given type}
\changes{4.0b}{1999/06/20}{Support the hack with \cs{prepdef}, and delay until \cs{AtBeginDocument} time, since \classname{hyperref} clobbers \cs{caption}.}
\changes{4.0c}{1999/11/13}{(AO, 110) Install hooks for endfloats processing}
\changes{4.0c}{1999/11/13}{(AO, 116) Hyperref compatibility}
\changes{4.0c}{1999/11/13}{(AO, 130) Interference from array package}
\changes{4.0c}{1999/11/13}{*-form mandates pagebreak at each float; only print section head if there is something there.}
\changes{4.0d}{2000/04/10}{(AO, 127) Floats placed [h] to allow page breaks}
\changes{4.0d}{2000/04/10}{(AO, 174) kernel fix}
\changes{4.0d}{2000/05/19}{(AO, 224) Hyperref compatibility.}
\changes{4.0d}{2000/05/23}{Allow things to break over pages by setting array@default.}
\changes{4.0e}{2000/11/16}{(AO, 221) Remove samepage command from @xfloat@prep: If the float can break over pages, we want better control.}
\changes{4.0f}{2001/07/13}{(AO, 404) Hyperref compatibility}
\changes{4.1a}{2008/01/19}{(AO, 459) do not assume \cs{class@name} is defined}%
\changes{4.1a}{2008/01/19}{(AO, 461) Change the csname from \cs{@dotsep} to \cs{ltxu@dotsep}. The former is understood in mu. (What we wanted was a dimension.)}%
\changes{4.1a}{2008/01/19}{(AO, 475) I had not properly reproduced the LaTeX macro \cs{eqnarray}.}%
\changes{4.1a}{2008/01/19}{(AO, 479) Per: Dylan Thurston<dpt at math.harvard.edu>}%
\changes{4.1a}{2008/06/30}{(AO) Make \cs{addtocontents} a \cs{long} \cs{def}; gobble up \cs{footnote}}%
\changes{4.1a}{2008/06/30}{(AO) Remove code that avoided changes to \cs{@xfootnotemark}}%
\changes{4.1a}{2008/06/30}{(AO, 438) Complete rewrite of footnote macros.}
\changes{4.1a}{2008/07/07}{\cs{@xfloat@prep} calls \cs{ltx@footnote@pop} to restore the original \cs{ltx@footmark} and \cs{ltx@foottext} procedures, in case footnote processing has switched.}
\changes{4.1a}{2008/08/12}{\cs{class@documenthook} is the last \cs{AtBeginDocument} token now}
\changes{4.1a}{2008/08/12}{Class extension mechanism \cs{@pushfilename@ltx} and \cs{@p@pfilename@ltx}.}
\changes{4.1a}{2008/08/12}{Class extension mechanism \cs{class@extension}, \cs{class@extensionfile}, and \cs{class@ext@hook}.}
\changes{4.1a}{2008/08/12}{Get rid of \cs{set@typesize@hook} \cs{set@pica@hook} and the \cs{normalsize} directive}%
\changes{4.1b}{2008/08/12}{(AO, 487) Support for video figures and the \cs{setfloatlink} command}%
\changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
\changes{4.1b}{2008/08/12}{Acquire \classname{hyperref} savoire}
\changes{4.1b}{2008/08/12}{Default assignment of \cs{float@sw} now, not at \cs{AtBeginDocument} time.}%
\changes{4.1b}{2008/08/12}{If class option \classoption{lengthcheck} is in effect, log the height of this float class.}
\changes{4.1b}{2008/08/12}{No need to protect against undefined \cs{float@sw}}
\changes{4.1b}{2008/08/12}{Patch the array package even later: after all package patches go in.}
\changes{4.1b}{2008/08/12}{Refine toc processing: provide default.}%
\changes{4.1b}{2008/08/12}{Tally and log the height of a float class}
\changes{4.1d}{2009/03/27}{(AO, 511) Compatability with lineno.sty's erroneous way of detecting fleqn.clo}%
\changes{4.1f}{2009/07/07}{(AO, 515) Hook for setting the font of a footnote}
\changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long}
\changes{4.1g}{2009/10/06}{(AO, 532) Both arguments of \cs{href} get sanitized}%
\changes{4.1g}{2009/10/07}{(AO, 525) Remove phantom paragraph above display math that is given in vertical mode}%
\changes{4.1g}{2009/10/07}{(AO, 539) Use of double-backslash in argument of \cs{section} gives error. The \classname{textcase} package is involved.}%
\changes{4.1n}{2009/12/05}{(AO, 569) Use of \classname{hyperref} interferes with column balancing of last page}%
\changes{4.1n}{2009/12/06}{(AO) Incorporate change to ltmiscen.dtx v1.1i 2000/05/19}%
\changes{4.1n}{2009/12/09}{(AO, 569) execute \classname{atveryend}'s \cs{Call@AfterLastShipout} at the proper time}%
\changes{4.1n}{2009/12/13}{(AO, 574) protect against \classname{lineno.sty}, which forces a visit to the output routine, which appears to destroy the value of \cs{@tempdima}}%
\changes{4.1n}{2010/01/02}{(AO, 571) Interface \cs{set@footnotewidth} for determining the set width of footnotes}%
\changes{4.1n}{2010/01/02}{(AO, 571) allow split after last line of footnote}%
\changes{4.1n}{2010/01/06}{(AO, 572) title block footnotes numbered independently from body footnotes}%
\changes{4.1p}{2010/02/24}{(AO, 582) A patch of \classname{hyperref.sty} to provide backward compatibility to \TeX Live 2007's version 6.75r}%
\changes{4.2a}{2017/11/21}{(MD) Use updated best practice to use https and doi.org}%
\changes{4.2a}{2018/12/12}{(MD) Updated name of README file and use standard fonts when typesetting}%
\end{filecontents*}
% \end{macrocode}
%
% \subsection{The Document Body}
%
% Here is the document body, containing only a
% \cmd\DocInput\ directive---referring to this very file.
% This very cute self-reference is a common \classname{ltxdoc} idiom.
% \begin{macrocode}
\begin{document}%
\expandafter\DocInput\expandafter{\jobname.dtx}%
\end{document}
% \end{macrocode}
%
% \begin{macrocode}
%</doc>
% \end{macrocode}
%
% \section{Using this package}
% Once this package is installed on your filesystem, you can employ it in
% adding functionality to \LaTeX\ by invoking it in your document or document class.
%
% \subsection{Invoking the package}
% In your document, you can simply call it up in your preamble:
% \begin{verbatim}
%\documentclass{book}%
%\usepackage{ltxutil}%
%\begin{document}
%<your document here>
%\end{document}\end{verbatim}
% However, the preferred way is to invoke this package from within your
% customized document class:
% \begin{verbatim}
%\NeedsTeXFormat{LaTeX2e}[1995/12/01]%
%\ProvidesClass{myclass}%
%\RequirePackage{ltxutil}%
%\LoadClass{book}%
%<class customization commands>
%\endinput\end{verbatim}
%
% Once loaded, the package gives you acccess to certain procedures,
% usually to be invoked by a \LaTeX\ command or environment, but not at the document level.
%
%
% \section{Compatibility with \LaTeX's Required Packages}
% Certain packages, usually ones written by members of the
% \LaTeX\ Project itself, have been designated ``required'' and
% are distributed as part of standard \LaTeX.
% These packages have been placed in a priviledged position
% vis \'a vis the \LaTeX\ kernel in that they override the definitions of certain kernel macros.
%
% The \classname{ltxutil} package will be incompatible with any package that
% redefines any of the kernel macros that \classname{ltxutil} patches---if that
% package is loaded \emph{after} \classname{ltxutil}. This means that for
% greatest compatibility, \classname{ltxutil} should be loaded \emph{after},
% say, \classname{ftnright}, which overwrites \LaTeX's kernel
% procedures \cmd\@outputdblcol, \cmd\@startcolumn, and \cmd\@makecol.
%
% Hereinafter follows some notes on specific \LaTeX\ packages.
%
% \subsection{array}
% This package alters the way tabular environments are done,
% therefore it could run afoul of the \LaTeX\ ``required'' package \classname{array} or any
% package that calls for it to be loaded.
% However, this package has provisions for remaining compatible with \classname{array}.
% So long as the version of \classname{array} that is used with this package has the appropriate
% meanings for the procedures it overwrites, all should be well.
%
% \subsection{longtable}
% David Carlisle's \classname{longtable} package modifies both the \LaTeX\ kernel and the
% \classname{array} package. This package must therefore alter \cmd\LT@array.
% For now, that job is handled by \classname{ltxgrid}.
%
%
%\StopEventually{}
%
% \section{Implementation of package}
%
% Special acknowledgment: this package uses concepts pioneered
% and first realized by William Baxter (mailto:web at superscript.com)
% in his SuperScript line of commercial typesetting tools, and
% which are used here with his permission.
%
% \subsection{Beginning of the \file{package} {\sc docstrip} module}
% \begin{macrocode}
%<*package>
\def\package@name{ltxutil}%
\expandafter\PackageInfo\expandafter{\package@name}{%
Utility macros for \protect\LaTeXe,
by A. Ogawa (arthur_ogawa at sbcglobal.net)%
}%
%</package>
% \end{macrocode}
%
% \subsection{Banner and beginning of the \file{kernel} {\sc docstrip} module}%
% \begin{macrocode}
%<*kernel>
% \end{macrocode}
%
% \subsection{Errors and warnings}
%
% \begin{macro}{\class@err}
% \begin{macro}{\class@warn}
% \begin{macro}{\class@info}
% A few shorthands for Class messages.
% Your document class should define \cmd\class@name.
% \begin{macrocode}
\def\class@err#1{\ClassError{\class@name}{#1}\@eha}%
\def\class@warn#1{\ClassWarningNoLine{\class@name}{#1}}%
\def\class@info#1{\ClassInfo{\class@name}{#1}}%
\def\obsolete@command#1{%
\class@warn@end{Command \string#1\space is obsolete.^^JPlease remove from your document}%
\global\let#1\@empty
#1%
}%
\def\replace@command#1#2{%
\class@warn@end{Command \string#1\space is obsolete;^^JUse \string#2\space instead}%
\global\let#1#2%
#1%
}%
\def\replace@environment#1#2{%
\class@warn@end{Environment #1 is obsolete;^^JUse #2 instead}%
\glet@environment{#1}{#2}%
\@nameuse{#1}%
}%
\def\incompatible@package#1{%
\@ifpackageloaded{#1}{%
\def\@tempa{I cannot continue. You must remove the \string\usepackage\ statement that caused that package to be loaded.}%
\ClassError{\class@name}{The #1 package cannot be used with \class@name}%
\@tempa\stop
}{%
\class@info{#1 was not loaded (OK!)}%
}%
}%
\def\class@warn@end#1{%
\gappdef\class@enddocumenthook{\class@warn{#1}}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \changes{4.1a}{2008/01/19}{(AO, 459) do not assume \cs{class@name} is defined}%
% Give \cmd\class@name\ a meaning if it does not already have one.
% \begin{macrocode}
\ifx\undefined\class@name
\def\class@name{ltxutil}%
\class@warn{You should define the class name before reading in this package. Using default}%
\fi
% \end{macrocode}
%
% \subsection{New Tools}%
%
% \begin{macro}{\t@}
% \begin{macrocode}
\def\t@{to}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dimen@iii}
% \begin{macrocode}
\dimendef\dimen@iii\thr@@
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\halignt@}
% \begin{macrocode}
\def\halignt@{\halign\t@}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\f@ur}
% Analogous to \cmd\@ne, \cmd\tw@, and \cmd\thr@@.
% \begin{macrocode}
\chardef\f@ur=4\relax
\chardef\cat@letter=11\relax
\chardef\other=12\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\let@environment}
% \begin{macro}{\glet@environment}
% The directive \cmd\let@environment\ takes care of a common programming
% idiom whereby one environment is made a synonym for another.
% \begin{macrocode}
\def\let@environment#1#2{%
\expandafter\let
\csname#1\expandafter\endcsname\csname#2\endcsname
\expandafter\let
\csname end#1\expandafter\endcsname\csname end#2\endcsname
}%
\def\glet@environment#1#2{%
\global\expandafter\let
\csname#1\expandafter\endcsname\csname#2\endcsname
\global\expandafter\let
\csname end#1\expandafter\endcsname\csname end#2\endcsname
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tracingplain}
% The command \cmd\tracingplain\ causes \TeX's tracing parameters to
% return to the values set by default. This command is sometimes
% useful when you have said \cmd\tracingall\ somewhere and want to
% restore.
% The \cmd\traceoutput\ command causes \cmd\tracingoutput\ diagnostics
% upon \cmd\shipout.
% \begin{macrocode}
\newcommand\tracingplain{%
\tracingonline\z@\tracingcommands\z@\tracingstats\z@
\tracingpages\z@\tracingoutput\z@\tracinglostchars\@ne
\tracingmacros\z@\tracingparagraphs\z@\tracingrestores\z@
\showboxbreadth5\showboxdepth3\relax %\errorstopmode
}%
\newcommand\traceoutput{%
\appdef\@resetactivechars{\showoutput}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\say}
% \begin{macro}{\saythe}
% The commands \cmd\say\ and \cmd\saythe\ cause diagnostic messages in the
% \TeX\ log that give the value of a control sequence name or a register
% respectively.
% \begin{macrocode}
\newcommand\say[1]{\typeout{<\noexpand#1=\meaning#1>}}%
\newcommand\saythe[1]{\typeout{<\noexpand#1=\the#1>}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fullinterlineskip}
% Resets the \cmd\prevdepth\ so that the full amount of \cmd\baselineskip\ glue will be inserted by
% the \cmd\baselinesklip\ mechanism.
% Can be invoked just after a \cmd\hrule\ to undo its default suppression of base line skip.
% \begin{macrocode}
\def\fullinterlineskip{\prevdepth\z@}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\count@i}
% \begin{macro}{\count@ii}
%
% \begin{macrocode}
\countdef\count@i\@ne
\countdef\count@ii\tw@
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Boolean Control}%
% We introduce just enough of the Boolean calculus for \TeX.
% Alan Jeffrey was the pioneer here, with an article in TUGboat
% (Vol. 11, No. 2, page 237).
% This implementation owes a debt to
% William Baxter (web at superscript.com).
% See articles by Baxter and Ogawa in the proceedings of the
% 1994 TUG meeting, TUGboat Vol.~15, No.~3.
%
% \begin{macro}{\prepdef}
% \begin{macro}{\appdef}
% \begin{macro}{\gappdef}
%
% Provide the capability of performing head- and tail patches.
% The procedure \cmd\prepdef\ prepends to the given macro
% the tokens specified in its second argument.
% Likewise for \cmd\appdef, except that it appends.
% Note that the first 10 toks registers are utility registers,
% and we simply make a control sequence name, \cmd\toks@ii, for one of
% them.
% \begin{macrocode}
\long\def\prepdef#1#2{%
\@ifxundefined#1{\toks@{}}{\toks@\expandafter{#1}}%
\toks@ii{#2}%
\edef#1{\the\toks@ii\the\toks@}%
}%
\long\def\appdef#1#2{%
\@ifxundefined#1{\toks@{}}{\toks@\expandafter{#1}}%
\toks@ii{#2}%
\edef#1{\the\toks@\the\toks@ii}%
}%
\long\def\gappdef#1#2{%
\@ifxundefined#1{\toks@{}}{\toks@\expandafter{#1}}%
\toks@ii{#2}%
\global\edef#1{\the\toks@\the\toks@ii}%
}%
\long\def\appdef@val#1#2{%
\appdef#1{{#2}}%
}%
\long\def\appdef@e#1#2{%
\expandafter\appdef
\expandafter#1%
\expandafter{#2}%
}%
\long\def\appdef@eval#1#2{%
\expandafter\appdef@val
\expandafter#1%
\expandafter{#2}%
}%
\toksdef\toks@ii=\tw@
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@ifxundefined}
% \begin{macro}{\@ifnotrelax}
% \begin{macro}{\@argswap}
% \begin{macro}{\@argswap@val}
%
% Certain utility procedures use \cmd\@ifxundefined,
% which is defined here in terms of \cmd\@ifx.
% Others use \cmd\@ifnotrelax, namely when
% the control sequence name is manufactured by
% the use of \cmd\csname.
%
% The procedures \cmd\@argswap and \cmd\@argswap@val
% are used to facilitate control of expansion.
%
% \begin{macrocode}
\long\def\@ifxundefined#1{\@ifx{\undefined#1}}%
\long\def\@ifnotrelax#1#2#3{\@ifx{\relax#1}{#3}{#2}}%
\long\def\@argswap#1#2{#2#1}%
\long\def\@argswap@val#1#2{#2{#1}}%
\def\@ifxundefined@cs#1{\expandafter\@ifx\expandafter{\csname#1\endcsname\relax}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@boolean}
% \begin{macro}{\@boole@def}
% In order to define \cmd\@ifx, we first must create the
% ``defining word'' (term taken form our Forth vocabulary)
% \cmd\@boole@def, which employs \cmd\@boolean\ to do its job.
% \begin{macrocode}
\def\@boolean#1#2{%
\long\def#1{%
#2% \if<something>
\expandafter\true@sw
\else
\expandafter\false@sw
\fi
}%
}%
\def\@boole@def#1#{\@boolean{#1}}% Implicit #2
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@booleantrue}
% \begin{macro}{\@booleanfalse}
% The procedures \cmd\@booleantrue\ and
% \cmd\@booleanfalse\ are assignment operators
% for Boolean flags.
% \begin{macrocode}
\def\@booleantrue#1{\let#1\true@sw}%
\def\@booleanfalse#1{\let#1\false@sw}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@ifx}
% \begin{macro}{\@ifx@empty}
% \begin{macro}{\@if@empty}
% \begin{macro}{\@ifcat}%
% \begin{macro}{\@ifdim}%
% \begin{macro}{\@ifeof}%
% \begin{macro}{\@ifhbox}%
% \begin{macro}{\@ifhmode}%
% \begin{macro}{\@ifinner}%
% \begin{macro}{\@ifmmode}%
% \begin{macro}{\@ifnum}%
% \begin{macro}{\@ifodd}%
% \begin{macro}{\@ifvbox}%
% \begin{macro}{\@ifvmode}%
% \begin{macro}{\@ifvoid}%
% We can now invoke the defining word to create
% the procedures \cmd\@ifx\ and friends.
%
% Compatibility Note: earlier versions of this package
% defined a procedure \cmd\@ifempty. However, for compatibility with AMS\LaTeX,
% we must avoid the following three names:
% \cmd\@ifempty, \cmd\@xifempty, and \cmd\@ifnotempty.
%
% \begin{macrocode}
\@boole@def\@ifx#1{\ifx#1}%
\@boole@def\@ifx@empty#1{\ifx\@empty#1}%
\@boole@def\@if@empty#1{\if!#1!}%
%\@boole@def\@if@sw#1{\csname if#1\endcsname}%
\def\@if@sw#1#2{#1\expandafter\true@sw\else\expandafter\false@sw#2}%
\@boole@def\@ifdim#1{\ifdim#1}%
\@boole@def\@ifeof#1{\ifeof#1}%
\@boole@def\@ifhbox#1{\ifhbox#1}%
\@boole@def\@ifhmode{\ifhmode}%
\@boole@def\@ifinner{\ifinner}%
\@boole@def\@ifmmode{\ifmmode}%
\@boole@def\@ifnum#1{\ifnum#1}%
\@boole@def\@ifodd#1{\ifodd#1}%
\@boole@def\@ifvbox#1{\ifvbox#1}%
\@boole@def\@ifvmode{\ifvmode}%
\@boole@def\@ifvoid#1{\ifvoid#1}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\true@sw}
% \begin{macro}{\false@sw}
%
% Note that when a Boolean operator expands, it
% employs two macros that act as selectors, defined here.
%
% \begin{macrocode}
\long\def\true@sw#1#2{#1}%
\long\def\false@sw#1#2{#2}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\loopuntil}
% \begin{macro}{\loopwhile}
%
% Loop control using the Boolean idiom.
% Superior to \cmd\loop\dots\cmd\repeat\ because these can be nested.
% The tail of the argument must have a Boolean predicate.
%
% \begin{macrocode}
\long\def\loopuntil#1{#1{}{\loopuntil{#1}}}%
\long\def\loopwhile#1{#1{\loopwhile{#1}}{}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@provide}
%
% A defining word that refuses to clobber a prior meaning.
%
% \begin{macrocode}
\def\@provide#1{%
\@ifx{\undefined#1}{\true@sw}{\@ifx{\relax#1}{\true@sw}{\false@sw}}%
{\def#1}{\def\j@nk}%
}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Begin Document Structure}
% The standard \LaTeX\ mechanism \cmd\AtBeginDocument\
% is inadequate because the \cmd\vsize\ is bound much too early.
% We supply here a mechanism whereby decisions about the
% page layout can be deferred until \cmd\AtBeginDocument\ time.
%
% The problem we are working around is that the \cmd\AtBeginDocument\
% hook in \cmd\document\ appears long after the calculation of
% \cmd\vsize\ and \cmd\hsize, that is, \LaTeX\ provides no mechanism
% for deferring the decision about the page grid until \cmd\AtBeginDocument\ time.
% We fix things by prepending a hook at the very beginning of \cmd\document.
%
% As it turns out, though, it appears feasible to simply invoke the desired
% column grid command at \cmd\AtBeginDocument\ time, since the MVL has nothing in it
% at that time that would be problematical.
%
% The facility depends on the stability of this part
% of \LaTeX's kernel code (the first token of \cmd\document),
% which could change, you see. But considering that \LaTeX\ is
% at this point essentially stagnant once more, we risk it.
%
% \begin{macro}{\document}
% We begin by installing hooks into \cmd\document\ that
% we will manage ourselves.
% First, we do as \cmd\document\ does: end the group
% begun by \cmd\begin. Last, we conclude our shenanigans by absorbing
% the first token of the expansion of \cmd\document, which
% we assume to be \cmd\endgroup.
% \changes{4.1a}{2008/08/12}{Get rid of \cs{set@typesize@hook} \cs{set@pica@hook} and the \cs{normalsize} directive}%
% \begin{macrocode}
\prepdef\document{%
\endgroup
\document@inithook
\true@sw{}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\document@inithook}
% To use, simply \cmd\appdef\cmd\document@inithook\arg{your tokens here}.
% \begin{macrocode}
\let\document@inithook\@empty
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\class@documenthook}
% \begin{macro}{\class@enddocumenthook}
% \changes{4.1a}{2008/08/12}{\cs{class@documenthook} is the last \cs{AtBeginDocument} token now}
% We install the last \cmd\AtBeginDocument\ hook, namely the
% procedure \cmd\class@documenthook. Within the document class,
% we will use this hook exclusively, so as to avoid interference from other packages.
% Similarly with \cmd\class@enddocumenthook, installed via \cmd\AtEndDocument.
%
% A document class using this package should do as this package does and just say,
% \cmd\appdef\ \cmd\class@documenthook\ instead of \cmd\AtBeginDocument,
% and \cmd\appdef\ \cmd\class@enddocumenthook\ instead of \cmd\AtEndDocument.
% \begin{macrocode}
\appdef\document@inithook{%
\AtBeginDocument{\class@documenthook}%
}%
\AtEndDocument{%
\class@enddocumenthook
}%
\let\class@documenthook\@empty
\let\class@enddocumenthook\@empty
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\enddocument}
% \begin{macro}{\check@aux}
% \begin{macro}{\do@check@aux}
% \changes{4.1n}{2009/12/05}{(AO, 569) Use of \classname{hyperref} interferes with column balancing of last page}%
% The standard \LaTeX\ \enve{document} processing is a potential problem,
% particularly when the output routine has been changed by \classname{ltxgrid}.
% We separate out the procedure that checks the auxiliary file at the end of
% the job so that later it can be called from the safety of the output
% routine.
% We will do this to ensure that the \cmd\@mainaux\ stream is not closed until
% the last page of the job is shipped out, and that can only be done by coordinating
% with the output routine.
% \begin{macrocode}
\def\enddocument{%
% \end{macrocode}
% \changes{4.1n}{2009/12/06}{(AO) Incorporate change to ltmiscen.dtx v1.1i 2000/05/19}%
% The following line from \filename{ltmiscen.dtx} `resets \cmd\AtEndDocument for latex/3060'.
% \begin{macrocode}
\let\AtEndDocument\@firstofone
% \end{macrocode}
% \begin{macrocode}
\@enddocumenthook
\@checkend{document}%
% \end{macrocode}
% The \cmd\clear@document\ statement ends the current page (we must guarantee no further shipouts),
% then executes all cleanup procedures that must occur only after the last shipout.
% Clients will queue up their procedures via \cmd\AfterLastShipout, if it exists, otherwise by doing \cmd\appdef\cmd\clear@document.
% \begin{macrocode}
\clear@document
% \end{macrocode}
% We are very close to ending the \TeX\ run, now.
% \begin{macrocode}
\check@aux
\deadcycles\z@
\@@end
}%
\def\check@aux{\do@check@aux}%
\def\do@check@aux{%
\@if@sw\if@filesw\fi{%
\immediate\closeout\@mainaux
\let\@setckpt\@gobbletwo
\let\@newl@bel\@testdef
\@tempswafalse
\makeatletter
\input\jobname.aux\relax
}{}%
\@dofilelist
\@ifdim{\font@submax >\fontsubfuzz\relax}{%
\@font@warning{%
Size substitutions with differences\MessageBreak
up to \font@submax\space have occured.\@gobbletwo
}%
}{}%
\@defaultsubs
\@refundefined
\@if@sw\if@filesw\fi{%
\@ifx{\@multiplelabels\relax}{%
\@if@sw\if@tempswa\fi{%
\@latex@warning@no@line{%
Label(s) may have changed.
Rerun to get cross-references right
}%
}{}%
}{%
\@multiplelabels
}%
}{}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\clear@document}
% \changes{4.1n}{2009/12/05}{(AO, 569) Use of \classname{hyperref} interferes with column balancing of last page}%
% The procedure \cmd\clear@document\ is responsible for flushing out the last page of the document,
% if not already done.
% The procedure then executes those procedures that must wait for execution until
% after the last page is shipped out.
% Clients of \classname{ltxutil}, such as \classname{ltxgrid} and \classname{revtex4}
% will queue these procedures up via \cmd\AfterLastShipout, if it exists, otherwise by doing \cmd\appdef\cmd\clear@document.
%
% The command \cmd\Call@AfterLastShipout\ is provided by Heiko Oberdiek's \classname{atveryend} package.
% This package is compatible with \classname{ltxutil}.
%
% Note on compatibility with \classname{atveryend}:
% we arrange for \cmd\Call@AfterLastShipout\ to be called from the safety of the output routine,
% thereby ensuring that all of the procedures queued up by that package's
% \cmd\AfterLastShipout\ are executed at the right time.
% We also ensure that \cmd\Call@AfterLastShipout\ has a default definition, in case the package was never loaded.
% \changes{4.1n}{2009/12/09}{(AO, 569) execute \classname{atveryend}'s \cs{Call@AfterLastShipout} at the proper time}%
% \begin{macrocode}
\def\clear@document{%
\clearpage
\do@output@cclv{%
\Call@AfterLastShipout
}%
}%
\appdef\class@documenthook{%
\providecommand\Call@AfterLastShipout{}%
}%
% \end{macrocode}
% \end{macro}
%
% \subsection{Class Extensions}%
% \changes{4.1a}{2008/08/12}{Class extension mechanism \cs{class@extension}, \cs{class@extensionfile}, and \cs{class@ext@hook}.}
% The \LaTeX\ procedure \cmd\@onefilewithoptions\ is the vehicle for reading in
% a \LaTeX\ class or package.
% The APS RevTeX class implements the use of what are called ``substyles'',
% actually extensions to the class itself.
% Any document class can do likewise.
%
% \begin{macro}{\class@extension}
% \begin{macro}{\class@extensionfile}
% \begin{macro}{\class@ext@hook}
% A procedure similar to \LaTeX's \cmd\@onefilewithoptions, but as an extension to the
% current document class.
%
% Read in the given file as if it were a document class file.
% Usage: \cmd\class@extensionfile\ \arg{class} \cmd\@extension,
% where \marg{class} is a file (similar to \file{aps.rtx}) and where \cmd\@extension\ is
% the file extension for \marg{class}.
% For instance, to read in the file \file{aps.rtx},
% do \cmd\class@extensionfile\ \texttt{\{aps\}} \cmd\substyle@ext,
% where the latter has been define to expand to \file{.rtx}.
%
% Features supported include
% passing existing class options on to the class extension,
% \cmd\AtEndOfClass\ processing,
% a stack that restores \cmd\@currname, \cmd\@currext, \cmd\@clsextension, and the \cmd\catcode\ of `@',
% fall-back to a control sequence name (with leading `rtx@') if no file exists.
%
% Note that \cmd\LoadClass\ gives one the ability to write a class that calls in
% another class as a (sort of) module: this scheme is like \cmd\LoadClass, but
% turned inside out.
% \begin{macrocode}
\def\class@extension#1#2{%
\IfFileExists{#1.#2}{%
\expandafter\class@extensionfile\csname ver@\@currname.\@currext\endcsname{#1}#2%
}{%
\csname rtx@#1\endcsname
}%
}%
\def\class@extensionfile#1#2#3{%
\@pass@ptions#3\@unusedoptionlist{#2}%
\global\let\@unusedoptionlist\@empty
\expandafter\class@ext@hook\csname#2.#3-h@@k\endcsname#1{#2}#3%
}%
\def\class@ext@hook#1#2#3#4{%
\@pushfilename@ltx
\makeatletter
\let\CurrentOption\@empty
\@reset@ptions
\let#1\@empty
\xdef\@currname{#3}%
\global\let\@currext#4%
\global\let\@clsextension\@currext
\input{#3.#4}%
\@ifl@ter#4{#3}#2{%
\class@info{Class extension later than: #2}%
}{%
\class@info{Class extension earlier: #2}%
\@@end
}%
#1%
\let#1\@undefined
\expandafter\@p@pfilename@ltx\@currnamestack@ltx\@nil
\@reset@ptions
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@pushfilename}
% \begin{macro}{\@p@pfilename}
% \changes{4.1a}{2008/08/12}{Class extension mechanism \cs{@pushfilename@ltx} and \cs{@p@pfilename@ltx}.}
% But! \LaTeX\ does not provide for a class extension other than \file{.cls}, therefore we
% must extend \LaTeX's file name stack with the file extension of a class extension.
% This way, procedures like
% \cmd\ProvidesPackage, \cmd\OptionNotUsed, \cmd\ProcessOptions, \cmd\@reset@ptions\
% will still work properly.
% \begin{macrocode}
\def\@pushfilename@ltx{%
\xdef\@currnamestack@ltx{%
{\@currname}%
{\@currext}%
{\@clsextension}%
{\the\catcode`\@}%
\@currnamestack@ltx
}%
}%
\def\@p@pfilename@ltx#1#2#3#4#5\@nil{%
\gdef\@currname{#1}%
\gdef\@currext{#2}%
\gdef\@clsextension{#3}%
\catcode`\@#4\relax
\gdef\@currnamestack@ltx{#5}%
}%
\global\let\@currnamestack@ltx\@empty
% \end{macrocode}
% \end{macro}
% \end{macro}
% We carefully patch \LaTeX\ so that the current value of \cmd\@clsextension\ can be
% restored after reading in a class file.
%
% \subsection{Type Tools}%
%
% \begin{macro}{\flushing}
% Undoes \cmd\centering. Should also undo \cmd\raggedleft\ and \cmd\raggedright.
% \begin{macrocode}
\def\flushing{%
\let\\\@normalcr
\leftskip\z@skip
\rightskip\z@skip
\@rightskip\z@skip
\parfillskip\@flushglue
}%
% \end{macrocode}
% \end{macro}
%
% \changes{4.1g}{2009/10/07}{(AO, 539) Use of double-backslash in argument of \cs{section} gives error. The \classname{textcase} package is involved.}%
% \begin{macro}{\@centercr}
% The \cmd\@centercr\ command is the replacement for \cmd\@normalcr\ when setting type centered or ragged.
% Normally, the meaning of \cmd\\ is \cmd\@normalcr, which \LaTeX\ defines via \cmd\DeclareRobustCommand.
% In centered or ragged typesetting, the meaning of \cmd\\ is \cmd\@centercr,
% therefore it ought to to be defined via \cmd\DeclareRobustCommand\ (but unfortunately is not).
% The fact that it is not is yet another of \LaTeX's early failures that will never get fixed.
%
% The following exemplar fails under \LaTeX\ version 2005/12/01, package \classname{textcase} 2004/10/07 v0.07:
% \begin{verbatim}
%\documentclass{article}%
%\usepackage[overload]{textcase}
%\begin{document}
%\centering
%\section{\MakeTextUppercase{Section\\title}}
%Text
%\end{document}
% \end{verbatim}
% The solution is to promote \cmd\@centercr\ to a robust command, just the same as \cmd\\.
% We do that here without needing to know the meaning of the command.
% \begin{macrocode}
\expandafter\DeclareRobustCommand\expandafter\@centercr\expandafter{\@centercr}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Display Math}%
%
% \begin{macro}{\eqnarray@LaTeX}
% \begin{macro}{\eqnarray@fleqn@fixed}
% Team \LaTeX\ has stated they will never repair Leslie's broken definition of \env{eqnarray}.
% Let us be bold\dots.
%
% Note on \classname{hyperref} package compatibility: that package overrides
% \cmd\eqnarray\ by wrapping it up in a larger procedure, so its changes
% are compatible with this package's changes.
%
% \changes{4.1a}{2008/01/19}{(AO, 475) I had not properly reproduced the LaTeX macro \cs{eqnarray}.}%
% \begin{macrocode}
\def\eqnarray@LaTeX{%
\stepcounter{equation}%
\def\@currentlabel{\p@equation\theequation}%
\global\@eqnswtrue
\m@th
\global\@eqcnt\z@
\tabskip\@centering
\let\\\@eqncr
$$\everycr{}\halign to\displaywidth\bgroup
\hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
&\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${##}$\hfil
&\global\@eqcnt\tw@ \hskip \tw@\arraycolsep
$\displaystyle{##}$\hfil\tabskip\@centering
&\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
\tabskip\z@skip
\cr
}
\long\def\eqnarray@fleqn@fixed{%
\stepcounter{equation}\def\@currentlabel{\p@equation\theequation}%
\global\@eqnswtrue\m@th\global\@eqcnt\z@
\tabskip\ltx@mathindent
\let\\=\@eqncr
\setlength\abovedisplayskip{\topsep}%
\ifvmode\addtolength\abovedisplayskip{\partopsep}\fi
\addtolength\abovedisplayskip{\parskip}%
\setlength\belowdisplayskip{\abovedisplayskip}%
\setlength\belowdisplayshortskip{\abovedisplayskip}%
\setlength\abovedisplayshortskip{\abovedisplayskip}%
$$%
\everycr{}%
\halignt@\linewidth\bgroup
\hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
&\global\@eqcnt\@ne
\hskip\tw@\eqncolsep
\hfil${{}##{}}$\hfil
&\global\@eqcnt\tw@
\hskip\tw@\eqncolsep
$\displaystyle{##}$\hfil\tabskip\@centering
&\global\@eqcnt\thr@@\hb@xt@\z@\bgroup\hss##\egroup
\tabskip\z@skip
\cr
}%
\@ifx{\eqnarray\eqnarray@LaTeX}{%
\class@info{Repairing broken LaTeX eqnarray}%
\let\eqnarray\eqnarray@fleqn@fixed
\newlength\eqncolsep
\setlength\eqncolsep\z@
\let\eqnarray@LaTeX\relax
\let\eqnarray@fleqn@fixed\relax
}{}%
% \end{macrocode}
% The macro \cmd\ltx@mathindent\ is assigned to the \cmd\tabskip\ glue just
% before the alignment preamble is expanded, the value therefore applying at the
% left of the first column.
%
% The below value specifies the display math to be set centered, as is common practice.
% Alternatively, \cmd\tabskip\ can be set to a different glue value, accomplishing
% flush-left display math.
%
% Note that the \filename{fleqn.clo} package provides its own meaning for
% the eqnarray environment, which is also broken. We do not patch that package, however.
%
% \changes{4.1d}{2009/03/27}{(AO, 511) Compatability with lineno.sty's erroneous way of detecting fleqn.clo}%
% Bug note: The \filename{lineno.sty} package detects \filename{fleqn.clo}
% by testing whether \cmd\mathindent\ is defined, instead of using correct \LaTeXe\ means.
% Even though our eqnarray environment is modelled after \filename{fleqn.clo},
% we must program defensively here.
% \begin{macrocode}
\def\ltx@mathindent{\@centering}%
\def\set@eqnarray@skips{}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{4.1g}{2009/10/07}{(AO, 525) Remove phantom paragraph above display math that is given in vertical mode}%
%\begin{macro}{\prep@math}
%\begin{macro}{\prep@math@patch}
% If we are in vertical mode when display math mode is entered (via \verb+$$+),
% \TeX\ will first enter horizontal mode, then display math mode; this results in a phantom paragraph
% containing a single \cmd\hbox\ consisting of the \cmd\parindent\ box followed by the \cmd\parskipfillskip\ glue.
% Of course, that \cmd\hbox\ is accompanied by \cmd\parskip\ glue and \cmd\baselineskip\ glue.
%
% The \cmd\prep@math\ procedure removes the \cmd\parindent\ box, thereby (magically) eliminating the phantom paragraph.
% The \cmd\prep@math@patch\ procedure headpatches the \env{equation} and \env{eqnarray} environments
% to accomplish this removal of the phantom paragraph.
%
% Note that there are three remaining ways to enter display math mode that we do not treat:
% the \env{displaymath} environment (equivalent to \cmd\[/\cmd\]), and the primitive the \verb+$$+ markup.
% I refrain from treating the first case because \env{displaymath} already detects the case
% where it is entered from vertical mode: I do not wish to engage in the dubious enterprise of attempting to correct a procedure that is ill conceived from the outset.
% As to the primitive \verb+$$+, there is no help for users who insist upon employing procedural markup in their documents.
% in their documents.
% \begin{macrocode}
\def\prep@math{%
\@ifvmode{\everypar{{\setbox\z@\lastbox}}}{}%
}%
\def\prep@math@patch{%
\prepdef\equation{\prep@math}%
\prepdef\eqnarray{\prep@math}%
}%
% \end{macrocode}
% A document class may invoke \cmd\prep@math@patch\ at any point it wishes to prevent the appearance
% of the phantom paragraph: it may be a global declaration or a local one.
% \end{macro}
% \end{macro}
%
% We fail to patch \cmd\[, \cmd\equation, however.
%
% \subsection{Footnotes}
%
% \changes{4.0d}{2000/04/10}{(AO, 174) kernel fix}
%
% \begin{macro}{\footnotemark}
% \begin{macro}{\footnotetest}
% \begin{macro}{\ltx@xfootnote}
% \begin{macro}{\ltx@footmark}
% \begin{macro}{\ltx@foottext}
% \begin{macro}{\ltx@make@current@footnote}
% We repair an error in the \LaTeX\ kernel (see \file{ltfloat.dtx}) involving footnotes.
% The symptom is that the \cmd\footnotemark\ command does not work properly within a \env{minipage} environment.
% The source of the problem is in the way the \cmd\footnotemark\ and \cmd\@xfootnotemark\ procedures are defined:
% they do not share the method, used by \cmd\footnote\ and other procedures, that allows a context switch to
% change the way footnotes behave within a minipage environment.
% This is a \LaTeX\ bug of long standing; our fix dates to 1987.
%
% While we are at it, we rewrite both the \cmd\footnote, \cmd\footnotemark\ and \cmd\footnotetext\ procedures,
% achieving a cleaner separation of syntax and semantics.
% Note that the \cmd\@footnotetext\ procedure is not involved in context switching;
% \classname{hyperref} will take over that procedure, substituting its own processing around
% its argument and passing this to \cmd\H@@footnotetext.
% We anticipate this, and do our context switching on \cmd\H@@footnotetext.
%
% The \cmd\@makefnmark\ continues as the method of formatting the footnote mark.
%
% A note about the context switch mentioned above:
% the \env{minipage} environment executes the following in order to alter the way footnotes
% behave:\begin{verbatim}
%\def\@mpfn{mpfootnote}%
%\def\thempfn{\thempfootnote}%
%\let\@footnotetext\@mpfootnotetext
%\let\@makefnmark\@mpmakefnmark
%\c@mpfootnote\z@\end{verbatim}
% This code changes the counter used in autonumbered footnotes, the choice of footnote marker,
% and the procedure used on the footnote text. Changing the counter is needed because minipage
% footnotes are in their own sequence, and the footnote marker is customarily different within
% a minipage. The procedure that works on the footnote text must be different because the footnotes
% are placed at the bottom of the minipage, not the bottom of the text column.
%
% Note that \LaTeX\ initially defines \cmd\@mpfn\ as \texttt{footnote} and \cmd\thempfn\ as \cmd\thefootnote,
% so we are initially doing general footnotes.
%
% Any procedure that establishes a minipage-like context (e.g., floats) can do the same as the mimipage context switch
% illustrated above.
% \changes{4.1a}{2008/06/30}{(AO, 438) Complete rewrite of footnote macros.}
%
% Three user-level command, \cmd\footnote, \cmd\footnotemark, and \cmd\footnotetext\ are defined (see the \LaTeX\ manual for user-level details).
% \begin{macro}{\footnote}
% The first user-level command is \cmd\footnote.
% A simple way to look at this command is to think of it as
% \cmd\footnotemark\ \oarg{number} \cmd\footnotetext\ \oarg{number} \arg{text},
% where the optional argument is the same in both calls.
% We also define a syntactical helper procedure \cmd\ltx@xfootnote.
%
% We employ the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc,
% passing in the procedure to execute, in this case \cmd\ltx@footmark,
% which sets the footnote mark.
% In any case, we end on the procedure \cmd\ltx@foottext, which sets the footnote text.
% \begin{macrocode}
\def\footnote{\@ifnextchar[\ltx@xfootnote\ltx@yfootnote}%
\def\ltx@xfootnote[#1]{%
\ltx@def@footproc\ltx@footmark[#1]%
\expandafter\ltx@foottext\expandafter{\the\csname c@\@mpfn\endcsname}%
}%
\def\ltx@yfootnote{%
\ltx@stp@footproc\ltx@footmark
\expandafter\ltx@foottext\expandafter{\the\csname c@\@mpfn\endcsname}%
}%
% \end{macrocode}
% The \cmd\footmark\ user-level command is next.
% Here we use the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc\ again,
% but unlike \cmd\footnote, we do not set the footnote text.
% \begin{macrocode}
\def\footnotemark{\@ifnextchar[\ltx@xfootmark\ltx@yfootmark}%
\def\ltx@xfootmark{\ltx@def@footproc\ltx@footmark}%
\def\ltx@yfootmark{\ltx@stp@footproc\ltx@footmark}%
\def\ltx@footmark#1{%
\leavevmode
\ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
\begingroup
\expandafter\ltx@make@current@footnote\expandafter{\@mpfn}{#1}%
\expandafter\@argswap@val\expandafter{\Hy@footnote@currentHref}{\hyper@linkstart {link}}%
\@makefnmark
\hyper@linkend
\endgroup
\ifhmode\spacefactor\@x@sf\fi
\relax
}%
% \end{macrocode}
% The third user-level command is \cmd\footnotetext.
% As with \cmd\footnotemark, we use the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc,
% this time passing in the procedure \cmd\ltx@foottext, which sets the footnote text.
% \begin{macrocode}
\def\footnotetext{\@ifnextchar[\ltx@xfoottext\ltx@yfoottext}%
\def\ltx@xfoottext{\ltx@def@footproc\ltx@foottext}%
\def\ltx@yfoottext{\ltx@stp@footproc\ltx@foottext}%
\long\def\ltx@foottext#1#2{%
\begingroup
\expandafter\ltx@make@current@footnote\expandafter{\@mpfn}{#1}%
\@footnotetext{#2}%
\endgroup
}%
% \end{macrocode}
% Here are the definitions of the procedures \cmd\ltx@stp@footproc\ and \cmd\ltx@def@footproc.
% The require argument is the procedure to execute afterwards, and
% \cmd\ltx@def@footproc\ parses a bracket-delimited argument (it is not optional).
% In each case the given procedure is executed with an argument prepared for it:
% the value of the footnote counter.
% \begin{macrocode}
\def\ltx@def@footproc#1[#2]{%
\begingroup
\csname c@\@mpfn\endcsname #2\relax
\unrestored@protected@xdef\@thefnmark{\thempfn}%
\expandafter\endgroup
\expandafter#1%
\expandafter{\the\csname c@\@mpfn\endcsname}%
}%
\def\ltx@stp@footproc#1{%
\expandafter\stepcounter\expandafter{\@mpfn}%
\protected@xdef\@thefnmark{\thempfn}%
\expandafter#1%
\expandafter{\the\csname c@\@mpfn\endcsname}%
}%
% \end{macrocode}
% Here we provide for our good friend \classname{hyperref}
% to enter in like a bull in a china shop. If it is not loaded,
% we do what it would have done, but gentlier and without hypertext functionality.
% \begin{macrocode}
\appdef\class@documenthook{%
\let\footnote@latex\footnote
\@ifpackageloaded{hyperref}{}{%
\let\H@@footnotetext\@footnotetext
\def\@footnotetext{\H@@footnotetext}%
\let\H@@mpfootnotetext\@mpfootnotetext
\def\@mpfootnotetext{\H@@mpfootnotetext}%
}%
}%
% \end{macrocode}
% In the following, we must use \LaTeX's rococco equipment in the form of \cmd\protected@edef,
% because of the presence of a font switch in the meaning of \cmd\thempfootnote.
% But, really, isn't this a sloppy conflation of semantics and presentation?
% \begin{macrocode}
\def\ltx@make@current@footnote#1#2{%
\csname c@#1\endcsname#2\relax
\protected@edef\Hy@footnote@currentHref{\@currentHref-#1.\csname the#1\endcsname}%
}%
\def\thempfootnote@latex{{\itshape \@alph \c@mpfootnote }}%
\def\ltx@thempfootnote{\@alph\c@mpfootnote}%
\@ifx{\thempfootnote\thempfootnote@latex}{%
\class@info{Repairing hyperref-unfriendly LaTeX definition of \string\mpfootnote}%
\let\thempfootnote\ltx@thempfootnote
}{}%
% \end{macrocode}
%
% Note on \classname{hyperref} compatibility:
% In its ``Automated \LaTeX\ hypertext cross-references'',
% the \classname{hyperref} package alters footnote processing,
% but it does nothing to address the several issues of concern to us.
%
% The \classname{hyperref} package takes over the \cmd\@mpfootnotetext\ and
% \cmd\@footnotetext\ procedures, wrapping the argument in its own code.
% It also rewrites \cmd\@footnotemark, making it a hyperlink, and
% \cmd\@xfootnotenext, removing from it all hypertext capabilities.
%
% However, if the \cmd\footnotemark\ command has been supplied with an optional argument,
% \classname{hyperref}'s changes do not apply: it punts in this case.
%
% At the same time, it attempts to turn off its changes during
% \cmd\maketitle\ processing, destroying one of the capabilities we desire.
%
% We make ourself \classname{hyperref} savvy:
% we re-implement footnote processing, using \classname{hyperref} capabilities if that
% package has been loaded.
%
% Any other package that rewrites \LaTeX's footnote macros will be incompatible
% with this package.
% \changes{4.1a}{2008/06/30}{(AO) Remove code that avoided changes to \cs{@xfootnotemark}}%
%
% Two thoughts about \classname{hyperref}: what for does it define \cmd\realfootnote?
% Apparently even SR himself cannot remember.
%
% Also: a document class that desires high hypertext capabilities might
% well wish to reimplement \cmd\maketitle\ so that footnotes called out from there
% are hypertext links: the \classname{hyperref} package's
% ``Automated \LaTeX\ hypertext cross-references''
% does not do any of this:
%\begin{quotation}
% But the special footnotes in |\maketitle| are much too hard to deal with properly.
% Let them revert to plain behaviour.
%\end{quotation}
% Note that the document class, in reimplementing \cmd\maketitle, must ensure
% that the \classname{hyperref} package does not clobber its own definition!
%
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@footnotetext}
% \begin{macro}{\@mpfootnotetext}
% \begin{macro}{\@tpfootnotetext}
% \begin{macro}{\make@footnotetext}
% \begin{macro}{\set@footnotewidth}
% The two procedures \cmd\@footnotetext\ and \cmd\@mpfootnotetext\ share code.
% We make that explicit here.
%
% Note that the procedure calling \cmd\make@footnotetext\ will open a group
% with \cmd\bgroup\ which is then closed by \cmd\minipagefootnote@drop.
%
% Difference from \LaTeX: here we do not set \cmd\floatingpenalty\ to infinity.
% Doing this must date back to a time when \LaTeX\ could not accomodate split insertions (footnotes).
% I cannot think of any other reason to do have done this.
% At any rate, with the \classname{ltxgrid} package, split insertions are properly
% taken care of, so we allow it.
%
% We provide the hook \cmd\set@footnotewidth\
% that sets the footnote on a particular measure.
% Some page grids are such as to set a footnote in a context where \cmd\columnwidth
% is not the right parameter to use for the set width of a footnote.
% In such a case, for the applicable scope, you should define
% \cmd\set@footnotewidth\ to perform this job correctly.
%
% If we are setting type on multiple page grids, we must still ensure that all footnotes that
% find their way into the \cmd\footins\ insert register are set on the same width.
% This implies the need for a document to have an ``overall'' page grid, which determines the set width of all footnotes
% with the exception of minipage footnotes.
%
% In general, remember that footnotes, like all insertions (including floats),
% are a step outside of the galley context, and all aspects of insertions need to be
% properly handled, including the set width.
% \begin{macrocode}
\def\@makefnmark{%
\hbox{%
\@textsuperscript{%
\normalfont\itshape\@thefnmark
}%
}%
}%
% \end{macrocode}
% \begin{macrocode}
\long\def\@footnotetext{%
\insert\footins\bgroup
\make@footnotetext
}%
% \end{macrocode}
% \begin{macrocode}
\long\def\@mpfootnotetext{%
\minipagefootnote@pick
\make@footnotetext
}%
% \end{macrocode}
% Procedure \cmd\make@footnotetext\ sets the footnote \verb+#1+ into type, with the proper
% font, color, leading, width, and label in effect.
% It also establishes a strut and null glue at the end of the last paragraph of the footnote;
% The strut helps compensate for the lack of \cmd\interlineskip\ glue between \cmd\insert s;
% the glue establishes a feasible \cmd\vsplit\ point between footnotes.
%
% Note that in the title block (\classname{ltxfront}), the alternative definition, under the name \cmd\frontmatter@footnotetext, is used.
% The only material difference there is the reference to \cmd\frontmatter@makefntext\ instead of \cmd\@makefntext.
%
% Dependency note: the \cmd\@makefntext\ procedure is used to further process the footnote text
% and to execute the \cmd\@makefnmark\ procedure to produce the footnote mark.
% The definition of the former is customarily found in the document class (hereunder that of \filename{article.cls}),
% the latter in \filename{latex.ltx}. They are as follows:
% \begin{verbatim}
%\newcommand\@makefntext[1]{%
% \parindent 1em\noindent
% \hb@xt@1.8em{\hss\@makefnmark}%
% #1%
%}%
%\def\@makefnmark{%
% \hbox{\@textsuperscript{\normalfont\@thefnmark}}%
%}%
% \end{verbatim}
%
% \changes{4.1n}{2010/01/06}{(AO, 572) title block footnotes numbered independently from body footnotes}%
% \begin{macrocode}
\long\def\make@footnotetext#1{%
\set@footnotefont
% \end{macrocode}
% As noted above, we do \emph{not} do \cmd\floatingpenalty\ \cmd\@MM, as in standard \LaTeX.
% \begin{macrocode}
\set@footnotewidth
\@parboxrestore
\protected@edef\@currentlabel{%
% \end{macrocode}
% Note that we employ \cmd\@mpfn\ as a level of redirection for the footnotecounter.
% \begin{macrocode}
\csname p@\@mpfn\endcsname\@thefnmark
}%
\color@begingroup
\@makefntext{%
\rule\z@\footnotesep\ignorespaces#1%
% \end{macrocode}
% \changes{4.1n}{2010/01/02}{(AO, 571) allow split after last line of footnote}%
% The following strut and glue are for spacing and splitting, as mentioned above.
% \begin{macrocode}
\@finalstrut\strutbox\vadjust{\vskip\z@skip}%
}%
\color@endgroup
\minipagefootnote@drop
}%
% \end{macrocode}
% \changes{4.1f}{2009/07/07}{(AO, 515) Hook for setting the font of a footnote}
% \cmd\set@footnotefont\ is the procedure for setting the font of a footnote.
% Other aspects of the environment may be set using this hook.
% \begin{macrocode}
\def\set@footnotefont{%
\reset@font\footnotesize
\interlinepenalty\interfootnotelinepenalty
\splittopskip\footnotesep
\splitmaxdepth\dp\strutbox
}%
% \end{macrocode}
% \cmd\set@footnotewidth\ is the procedure for setting the width of a footnote.
% The default page grid, a single, full-width column, sets footnotes on the width of the text.
% \changes{4.1n}{2010/01/02}{(AO, 571) Interface \cs{set@footnotewidth} for determining the set width of footnotes}%
% \begin{macrocode}
\def\set@footnotewidth{\set@footnotewidth@one}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Floats}
%
% \subsubsection{Usage notes}%
% We extend the \LaTeX\ kernel for three purposes:
% \begin{enumerate}
%
% \item
% When the \cmd\footnote\ command is used within the
% scope of a float, we do as \env{minipage} does.
%
% \item
% We provide a mechanism to write floats out to an external
% stream for temporary storage (deferred floats).
%
% \item
% We provide mechanism for placing a float \texttt{here}
% invariably, that is, floats are unfloated.
% This mechanism is used to read the external stream mentioned above.
%
% \end{enumerate}
%
% To use these mechanisms, the document class should
% define a float, say, \env{figure} as per usual, and in addition:
% \begin{enumerate}
%
% \item
% Optionally define an alternative, say \env{figure@write} as follows:
% \begin{verbatim}\newenvironment{figure@write}{%
% \write@float{figure}%
%}{%
% \endwrite@float
%}\end{verbatim}
% That is, the alternative environment executes \cmd\write@float\
% instead of \cmd\@float.
% Note that this step is not needed if the float environment
% is defined in the simple way of \file{classes.dtx}.
% However, an environment like \env{longtable} will require it.
%
% \item
% Install into \cmd\AtBeginDocument\ a call to \cmd\do@if@floats,
% with the float name and an appropriate file extension as its arguments.
% \begin{verbatim}\appdef\class@documenthook{\do@if@floats{figure}{.fgx}}\end{verbatim}
%
% \item
% Optionally define a text entity \cmd\figuresname\ that will
% be the text of the head that is set over the
% deferred floats.
% If not defined, there will be no head.
%
% \item
% Optionally define a user-level command to allow
% the document to determine where the figures are printed out
% (default is to print at end of document). E.g.,
% \begin{verbatim}\newcommand\printfigures{\print@float{figure}}\end{verbatim}
% \item
% Install into \cmd\appdef\cmd\class@enddocumenthook\ a call to \cmd\printfigures,
% or, if the latter is not defined, as follows:
% \begin{verbatim}\appdef\class@enddocumenthook{\print@float{figure}}\end{verbatim}
% Note that installing this command into \cmd\AtBeginDocument
% is best done earlier than calls that assume the last page of
% the document is at hand.
%
% \end{enumerate}
%
% \subsubsection{Robustifying fragile commands}%
% Certain of \LaTeX's commands cannot be written out to a file or appear within a \cmd\mark\ command argument
% because they do calculations during expansion.
% We provide for a little help, but without changing the meanings of these commands.
%
% \begin{macro}{\addtocontents}
% \begin{macro}{\robustify@contents}
%
% \changes{4.1a}{2008/06/30}{(AO) Make \cs{addtocontents} a \cs{long} \cs{def}; gobble up \cs{footnote}}%
% \begin{macrocode}
\def\robustify@contents{%
\let \label \@gobble
\let \index \@gobble
\let \glossary \@gobble
\let\footnote \@gobble
\def\({\string\(}%
\def\){\string\)}%
\def\\{\string\\}%
}%
\long\def\addtocontents#1#2{%
\protected@write\@auxout{\robustify@contents}{\string \@writefile {#1}{#2}}%
}%
% \end{macrocode}
%
% \end{macro}
% \end{macro}
%
% \subsubsection{Preparing for the \classname{hyperref package}}%
%
% \begin{macro}{\addcontentsline}
% \begin{macro}{\label}
% \begin{macro}{\ltx@contentsline}
% \changes{4.1b}{2008/08/12}{Refine toc processing: provide default.}%
% The \classname{hyperref} package assumes that the \cmd\contentsline\ command will be given four arguments.
% Therefore it cannot successfully process a \filename{.toc} file that had been written by standard \LaTeX.
% We fix things up by always writing that fourth argument and by supplying a \cmd\contentsline\ command that
% can read them.
%
% We also give the \cmd\newlabel\ command's second argument five tokens.
%
% Finally, we wrap \LaTeX's \cmd\contentsline\ command with code to detect the case
% where the expected procedure is not defined, and we give it a syntax with no semantics.
%
% We switch over to this new definition only after \classname{hyperref} has loaded.
% \begin{macrocode}
\def\addcontentsline#1#2#3{%
\addtocontents{#1}{%
\protect\contentsline{#2}{#3}{\thepage}{}%
}%
}%
\def\label#1{%
\@bsphack
\protected@write\@auxout{}{%
\string\newlabel{#1}{{\@currentlabel}{\thepage}{}{}{}}%
}%
\@esphack
}%
\def\ltx@contentsline#1{%
\expandafter\@ifnotrelax\csname l@#1\endcsname{}{%
\expandafter\let\csname l@#1\endcsname\@gobbletwo
}%
\contentsline@latex{#1}%
}%
\appdef\document@inithook{%
\let\contentsline@latex\contentsline
\let\contentsline\ltx@contentsline
}%
% \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Footnotes within floats, unfloating floats, float font}%
%
% \begin{macro}{\caption}
% DPC: Er a bit of a hack, but seems best way of supporting normal
% \LaTeX\ syntax at this point: If a caption is used below a table,
% then put out the footnotes before the caption.
% \changes{4.0b}{1999/06/20}{Support the hack with \cs{prepdef}, and delay until \cs{AtBeginDocument} time, since \classname{hyperref} clobbers \cs{caption}.}
% \begin{macrocode}
\appdef\class@documenthook{%
\prepdef\caption{\minipagefootnote@here}%
}%
% \end{macrocode}
%
% Note on \classname{hyperref} compatibility:
% this change to the \cmd\caption\ command is compatible with the
% ``Automated \LaTeX\ hypertext cross-references'' patches of that package.
%
% All the same, I think Sebastian's changes to \cmd\caption\ and \cmd\@caption\
% could bear with some improvement.
% The following implementation requires knowing only the pattern part of the
% \cmd\@caption\ macro:
%\begin{verbatim}
%\def\caption{%
% \H@refstepcounter\@captype
% \hyper@makecurrent{\@captype}%
% \@dblarg{\H@caption\@captype}%
%}%
%\def\H@caption#1[#2]#3{%
% \@caption{#1}[#2]{%
% \ifHy@nesting
% \hyper@@anchor{\@currentHref}{#3}%
% \else
% \hyper@@anchor{\@currentHref}{\relax}#3%
% \fi
% }%
%}\end{verbatim}
%
% \end{macro}
%
% \begin{macro}{\minipagefootnote@init}
% \begin{macro}{\minipagefootnote@here}
% \begin{macro}{\minipagefootnote@foot}
% \begin{macro}{\minipagefootnote@pick}
% \begin{macro}{\minipagefootnote@drop}
% Procedure to deal with footnotes accumulated within a minipage environment.
% These procedures encapsulate all uses of the \cmd\@mpfootins\ box.
%
%
% Note: \cmd\minipagefootnote@here\ must \emph{not} be executed within the MVL!
% \begin{macrocode}
\def\minipagefootnote@init{%
\setbox\@mpfootins\box\voidb@x
}%
\def\minipagefootnote@pick{%
\global\setbox\@mpfootins\vbox\bgroup
\unvbox\@mpfootins
}%
\def\minipagefootnote@drop{%
\egroup
}%
\def\minipagefootnote@here{%
\par
\@ifvoid\@mpfootins{}{%
\vskip\skip\@mpfootins
\fullinterlineskip
\@ifinner{%
\vtop{\unvcopy\@mpfootins}%
{\setbox\z@\lastbox}%
}{}%
\unvbox\@mpfootins
}%
}%
\def\minipagefootnote@foot{%
\@ifvoid\@mpfootins{}{%
\insert\footins\bgroup\unvbox\@mpfootins\egroup
}%
}%
\def\endminipage{%
\par
\unskip
\minipagefootnote@here
\@minipagefalse %% added 24 May 89
\color@endgroup
\egroup
\expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\floats@sw}
% \changes{4.1b}{2008/08/12}{Default assignment of \cs{float@sw} now, not at \cs{AtBeginDocument} time.}%
% The Boolean \cmd\floats@sw\ signifies that floats are to be floated;
% if false, that floats are to be deferred to the end of the document.
% Note that the assignment of this Boolean is to be overridden by
% the document class in response to user-selected options.
% \begin{macrocode}
\@booleantrue\floats@sw
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xfloat}
% \begin{macro}{\@mpmakefntext}
% The float start-code is redefined to set up footnotes in the style of minipage.
% Also, the \cmd\floats@sw\ Boolean informs us that floats are to be
% all placed \texttt{here}.
% Note that, to protect against the Boolean being undefined
% at this late hour, we default it globally to true.
%
% \changes{4.0b}{1999/06/20}{AO: Removed superfluous \cs{def}s, changed to using \cs{floats@sw} as the flag. Also stopped using DPC's \cs{if@twocolumn} flag: using \cs{floats@sw} instead. Also added \cs{par}\cs{vskip}\cs{z@skip} after the \cs{minipagefootnotes} so that the float box would have zero depth like the kernel one. }
% \changes{4.0c}{1999/11/13}{(AO, 110) Install hooks for endfloats processing}
% \changes{4.0d}{2000/04/10}{(AO, 127) Floats placed [h] to allow page breaks}
% \changes{4.0d}{2000/05/19}{(AO, 224) Hyperref compatibility.}
% \changes{4.0e}{2000/11/16}{(AO, 221) Remove samepage command from @xfloat@prep: If the float can break over pages, we want better control.}
% \changes{4.1a}{2008/07/07}{\cs{@xfloat@prep} calls \cs{ltx@footnote@pop} to restore the original \cs{ltx@footmark} and \cs{ltx@foottext} procedures, in case footnote processing has switched.}
% \changes{4.1b}{2008/08/12}{No need to protect against undefined \cs{float@sw}}
%
% \begin{macrocode}
\let\@xfloat@LaTeX\@xfloat
\def\@xfloat#1[#2]{%
\@xfloat@prep
\@nameuse{fp@proc@#2}%
\floats@sw{\@xfloat@LaTeX{#1}[#2]}{\@xfloat@anchored{#1}[]}%
}%
\def\@xfloat@prep{%
\ltx@footnote@pop
\def\@mpfn{mpfootnote}%
\def\thempfn{\thempfootnote}%
\c@mpfootnote\z@
\let\H@@footnotetext\H@@mpfootnotetext
}%
\let\ltx@footnote@pop\@empty
\def\@xfloat@anchored#1[#2]{%
\def\@captype{#1}%
\begin@float@pagebreak
\let\end@float\end@float@anchored
\let\end@dblfloat\end@float@anchored
\hsize\columnwidth
\@parboxrestore
\@floatboxreset
\minipagefootnote@init
}%
\def\end@float@anchored{%
\minipagefootnote@here
\par\vskip\z@skip
\par
\end@float@pagebreak
}%
\def\begin@float@pagebreak{\par\addvspace\intextsep}%
\def\end@float@pagebreak{\par\addvspace\intextsep}%
\def\@mpmakefntext#1{%
\parindent=1em
\noindent
\hb@xt@1em{\hss\@makefnmark}%
#1%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Writing floats out to a file}%
%
% \begin{macro}{\do@if@floats}
% \changes{4.1b}{2008/08/12}{No need to protect against undefined \cs{float@sw}}
% The procedure \cmd\do@if@floats\ should be executed at
% \cmd\class@documenthook\ time: it arranges to write out
% the floats of the given class to a temporary file, to be
% read back later (deferred floats),
% given that \cmd\floats@sw\ is false.
% Note that, to protect against the Boolean being undefined
% at this late hour, we default it globally to true.
% \begin{macrocode}
\def\do@if@floats#1#2{%
\floats@sw{}{%
% \end{macrocode}
% Open the stream to save out the document's floats of this class.
% \begin{macrocode}
\expandafter\newwrite
\csname#1write\endcsname
\expandafter\def
\csname#1@stream\endcsname{\jobname#2}%
\expandafter\immediate
\expandafter\openout
\csname#1write\endcsname
\csname#1@stream\endcsname\relax
% \end{macrocode}
% Swap environments.
% If the class writer has defined, e.g., \env{figure@write},
% then we use this as the procedure to execute for writing
% the float out to the external stream.
% Otherwise, the replacement of \cmd\@float\ by \cmd\write@float\
% should do the right thing for float environments defined
% in the simple way of \classname{classes.dtx}.
% \begin{macrocode}
\@ifxundefined\@float@LaTeX{%
\let\@float@LaTeX\@float
\let\@dblfloat@LaTeX\@dblfloat
\let\@float\write@float
\let\@dblfloat\write@floats
}{}%
\let@environment{#1@float}{#1}%
\let@environment{#1@floats}{#1*}%
\@ifxundefined@cs{#1@write}{}{%
\let@environment{#1}{#1@write}%
}%
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\print@float}
% The procedure \cmd\print@float\ prints out the
% deferred floats.
% \changes{4.0b}{1999/06/20}{only execute if there really were floats of the given type}
% \changes{4.0c}{1999/11/13}{*-form mandates pagebreak at each float; only print section head if there is something there.}
% \changes{4.0d}{2000/05/23}{Allow things to break over pages by setting array@default.}
% \changes{4.1b}{2008/08/12}{If class option \classoption{lengthcheck} is in effect, log the height of this float class.}
%
% Here, we make use of the \cmd\floats@sw\ Boolean to select
% the non-floating type of processing.
% \begin{macrocode}
\def\triggerpar{\leavevmode\@@par}%
\def\oneapage{\def\begin@float@pagebreak{\newpage}\def\end@float@pagebreak{\newpage}}%
\def\print@float#1#2{%
\lengthcheck@sw{%
\total@float{#1}%
}{}%
\@ifxundefined@cs{#1write}{}{%
\begingroup
\@booleanfalse\floats@sw
#2%
\raggedbottom
\def\array@default{v}% floats must
\let\@float\@float@LaTeX
\let\@dblfloat\@dblfloat@LaTeX
\let\trigger@float@par\triggerpar
\let@environment{#1}{#1@float}%
\let@environment{#1*}{#1@floats}%
\expandafter\prepdef\csname#1\endcsname{\trigger@float@par}%
\expandafter\prepdef\csname#1*\endcsname{\trigger@float@par}%
\@namedef{fps@#1}{h!}%
\expandafter\immediate
\expandafter\closeout
\csname#1write\endcsname
\everypar{%
\global\let\trigger@float@par\relax
\global\everypar{}\setbox\z@\lastbox
\@ifxundefined@cs{#1sname}{}{%
\begin@float@pagebreak
\expandafter\section
\expandafter*%
\expandafter{%
\csname#1sname\endcsname
}%
}%
}%
\input{\csname#1@stream\endcsname}%
\endgroup
\global\expandafter\let\csname#1write\endcsname\relax
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tally@float}
% \begin{macro}{\total@float}
% \changes{4.1b}{2008/08/12}{Tally and log the height of a float class}
% If we are tallying column inches, \cmd\tally@float\ tallies a contribution to \cmd\ftype@\ \cmd\@captype,
% depending upon the width of \cmd\@currbox.
% In effect, each float class is tallied in two sections, one for narrow, one for wide floats.
%
% If statistics are wanted, \cmd\total@float\ logs the tally for the given float class.
% \changes{4.1f}{2009/07/10}{(AO, 518) Tally register overflow when locument is long}
% The quantity \cmd\@twopowerfourteen\ is $2^{14}$, \cmd\@twopowertwo\ is $2^{2}$.
% \begin{macrocode}
\chardef\@xvi=16\relax
\mathchardef\@twopowerfourteen="4000
\mathchardef\@twopowertwo="4
\def\tally@float#1{%
\begingroup
% \end{macrocode}
% We strip all but the least significant 5 bits from \cmd\count\ \cmd\@currbox,
% and put them into \cmd\@tempcnta. We then subtract 16 from \cmd\count\ \cmd\@currbox
% (unless this would make it negative), effectively reversing the process
% carried out in \cmd\@float.
% \begin{macrocode}
\@tempcnta\count\@currbox
\divide\@tempcnta\@xxxii
\multiply\@tempcnta\@xxxii
\advance\count\@currbox-\@tempcnta
\divide\@tempcnta\@xxxii
\@ifnum{\count\@currbox>\@xvi}{%
\advance\count\@currbox-\@xvi\@booleantrue\@temp@sw
}{%
\@booleanfalse\@temp@sw
}%
% \end{macrocode}
% If so desired, we log the characteristics of this float object:
% float class and float placement parameters, height, depth, and width.
% \begin{macrocode}
\show@box@size@sw{%
\class@info{Float #1
(\the\@tempcnta)[\@temp@sw{16+}{}\the\count\@currbox]^^J%
(\the\ht\@currbox+\the\dp\@currbox)X\the\wd\@currbox
}%
}{}%
\endgroup
% \end{macrocode}
% Here we tally the height of this float object.
% \begin{macrocode}
\expandafter\let
\expandafter\@tempa
\csname fbox@\csname ftype@#1\endcsname\endcsname
\@ifnotrelax\@tempa{%
\@ifhbox\@tempa{%
\setbox\@tempboxa\vbox{\unvcopy\@currbox\hrule}%
\dimen@\ht\@tempboxa
\divide\dimen@\@twopowerfourteen
\@ifdim{\wd\@tempboxa<\textwidth}{%
\advance\dimen@\ht\@tempa
\global\ht\@tempa\dimen@
}{%
\advance\dimen@\dp\@tempa
\global\dp\@tempa\dimen@
}%
}{}%
}{}%
}%
\def\total@float#1{%
\expandafter\let
\expandafter\@tempa
\csname fbox@\csname ftype@#1\endcsname\endcsname
\@ifnotrelax\@tempa{%
\@ifhbox\@tempa{%
\@tempdima\the\ht\@tempa\divide\@tempdima\@twopowertwo\@tempcnta\@tempdima
\@tempdimb\the\dp\@tempa\divide\@tempdimb\@twopowertwo\@tempcntb\@tempdimb
\class@info{Total #1: Column(\the\@tempcnta pt), Page(\the\@tempcnta pt)}%
}{}%
}{}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\write@float}
% \begin{macro}{\write@floats}
% \begin{macro}{\write@@float}
% Handles the case where the name of the float is the same as
% that of the stream. Note that
% \env{longtable} does \emph{not} fit this case.
% Note also: \cmd\write@float\ is \emph{not} a user-level environment,
% therefore it is properly not defined with \cmd\newenvironment.
% \begin{macrocode}
\def\write@float#1{\write@@float{#1}{#1}}%
\def\endwrite@float{\@Esphack}%
\def\write@floats#1{\write@@float{#1*}{#1}}%
\def\endwrite@floats{\@Esphack}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\write@@float}
% \changes{4.0b}{1999/06/20}{AO: Fixed spurious \texttt{CR} and (return) characters in output file. Also, if the document did not have the \cs{end}\texttt{figure} on a line of its own, the macro wouldn't work. Fixed.}
% \begin{macrocode}
\def\write@@float#1#2{%
\ifhmode
\@bsphack
\fi
\chardef\@tempc\csname#2write\endcsname
\toks@{\begin{#1}}%
\def\@tempb{#1}%
\expandafter\let\csname end#1\endcsname\endwrite@float
\catcode`\^^M\active
\@makeother\{\@makeother\}\@makeother\%
\write@floatline
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\write@floatline}
% \begin{macro}{\@write@floatline}
% \begin{macro}{\float@end@tag}
% The procedure \cmd\write@floatline\ only parses;
% it passes its result to \cmd\@write@floatline, which
% writes the line to output, then tests the line
% for the \cmd\end\arg{float} tokens with
% aid of the \cmd\float@end@tag\ procedure.
% \begin{macrocode}
\begingroup
\catcode`\[\the\catcode`\{\catcode`\]\the\catcode`\}\@makeother\{\@makeother\}%
\gdef\float@end@tag#1\end{#2}#3\@nul[%
\def\@tempa[#2]%
\@ifx[\@tempa\@tempb][\end[#2]][\write@floatline]%
]%
\obeylines%
\gdef\write@floatline#1^^M[%
\begingroup%
\newlinechar`\^^M%
\toks@\expandafter[\the\toks@#1]\immediate\write\@tempc[\the\toks@]%
\endgroup%
\toks@[]%
\float@end@tag#1\end{}\@nul%
]%
\endgroup
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \subsection{Counters}
% The following definitions override those of the \LaTeX\ kernel,
% providing for a greater range of inputs.
% \begin{macrocode}
\def\@alph#1{\ifcase#1\or a\or b\or c\or d\else\@ialph{#1}\fi}
% \end{macrocode}
%
% \begin{macrocode}
\def\@ialph#1{\ifcase#1\or \or \or \or \or e\or f\or g\or h\or i\or j\or
k\or l\or m\or n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or
y\or z\or aa\or bb\or cc\or dd\or ee\or ff\or gg\or hh\or ii\or jj\or
kk\or ll\or mm\or nn\or oo\or pp\or qq\or rr\or ss\or tt\or uu\or
vv\or ww\or xx\or yy\or zz\else\@ctrerr\fi}
% \end{macrocode}
%
%
% \subsection{Customization of Sections}%
%
% Patch the standard \LaTeX\ sectioning procedure to:
%\begin{itemize}
%\item
% Allow a sectioning command to trigger the title page, or more generally
% to recognize that it is the first object in the document,
% so we headpatch \cmd\@startsection.
%
%\item
% Allow a tail command in |#6| to uppercase the title, so we retain
% DPC's braces.
%
%\item
% Allow each type of sectioning command to format its number differently,
% so we generalize \cmd\@seccntformat.
%
%\item
% Allow each type of sectioning command to format its argument differently,
% so we generalize \cmd\@hangfrom.
%
%\item
% Allow the starred form of the command to
% mark (the running head) and
% make an entry in the TOC,
% so we put \cmd\@ssect\ on the same footing as \cmd\@sect.
%
% Note that the tokens passed to the TOC now are \emph{not}
% the optional argument of the command, but the required.
% This means that the user can no longer use the former
% to put variant content in to the TOC as the Manual says.
%
% Instead, the optional argument is used to put an alternative
% title into the running headers, a better choice.
%
%\end{itemize}
%
% \begin{macro}{\@startsection}
% Patch a head hook into the basic sectioning command.
% Treat \cmd\@sect\ and \cmd\@ssect\ on an equal footing:
% now their pattern parts are identical.
% \begin{macrocode}
\def\@startsection#1#2#3#4#5#6{%
\@startsection@hook
\if@noskipsec \leavevmode \fi
\par
\@tempskipa #4\relax
\@afterindenttrue
\ifdim \@tempskipa <\z@
\@tempskipa -\@tempskipa \@afterindentfalse
\fi
\if@nobreak
\everypar{}%
\else
\addpenalty\@secpenalty\addvspace\@tempskipa
\fi
\@ifstar
{\@dblarg{\@ssect@ltx{#1}{#2}{#3}{#4}{#5}{#6}}}%
{\@dblarg{\@sect@ltx {#1}{#2}{#3}{#4}{#5}{#6}}}%
}%
\def\@startsection@hook{}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sect}
% When defining \cmd\@svsec, do not expand \cmd\@seccntformat.
% Put brace characters back where they were before David Carlisle got at them
% (i.e., as if \cmd\@hangfrom\ had two arguments).
% Protect the mark mechanism from an undefined meaning.
% Pass |#8| to the TOC instead of |#7|.
% Remove \cmd\relax\ from the replacement part of \cmd\@svsec.
%
% The procedure \cmd\@hangfrom\ and \cmd\@runin@to\ can
% be used to process the argument of the head.
% The head can define, e.g., \cmd\@hangfrom@section, to
% do its own processing.
%
% In using \cmd\H@refstepcounter\ in place of \cmd\refstepcounter\ we rely on
% either loading before any package that patches the latter, or
% the convention that the former is the original \LaTeX\ procedure.
%
% \begin{macrocode}
\class@info{Repairing broken LateX \string\@sect}%
\def\@sect@ltx#1#2#3#4#5#6[#7]#8{%
\@ifnum{#2>\c@secnumdepth}{%
\def\H@svsec{\phantomsection}%
\let\@svsec\@empty
}{%
\H@refstepcounter{#1}%
\def\H@svsec{%
\phantomsection
}%
\protected@edef\@svsec{{#1}}%
\@ifundefined{@#1cntformat}{%
\prepdef\@svsec\@seccntformat
}{%
\expandafter\prepdef
\expandafter\@svsec
\csname @#1cntformat\endcsname
}%
}%
\@tempskipa #5\relax
\@ifdim{\@tempskipa>\z@}{%
\begingroup
\interlinepenalty \@M
#6{%
\@ifundefined{@hangfrom@#1}{\@hang@from}{\csname @hangfrom@#1\endcsname}%
{\hskip#3\relax\H@svsec}{\@svsec}{#8}%
}%
\@@par
\endgroup
\@ifundefined{#1mark}{\@gobble}{\csname #1mark\endcsname}{#7}%
\addcontentsline{toc}{#1}{%
\@ifnum{#2>\c@secnumdepth}{%
\protect\numberline{}%
}{%
\protect\numberline{\csname the#1\endcsname}%
}%
#8}%
}{%
\def\@svsechd{%
#6{%
\@ifundefined{@runin@to@#1}{\@runin@to}{\csname @runin@to@#1\endcsname}%
{\hskip#3\relax\H@svsec}{\@svsec}{#8}%
}%
\@ifundefined{#1mark}{\@gobble}{\csname #1mark\endcsname}{#7}%
\addcontentsline{toc}{#1}{%
\@ifnum{#2>\c@secnumdepth}{%
\protect\numberline{}%
}{%
\protect\numberline{\csname the#1\endcsname}%
}%
#8}%
}%
}%
\@xsect{#5}%
}%
\def\@hang@from#1#2#3{\@hangfrom{#1#2}#3}%
\def\@runin@to #1#2#3{#1#2#3}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ssect}
% Put brace characters back where they were before David Carlisle got at them
% (as if \cmd\@hangfrom\ has two arguments).
% Possibly set a mark.
% Make a TOC entry.
%
% Note that, for compatibility with the \classname{hyperref} package, we
% need to provide the interface required by that package
% (actually required by \file{pdfmark.def} and \file{nameref.sty}),
% namely
% the definition of \cmd\@currentlabelname\ (but now removed),
% the insertion of the procedure \cmd\Sectionformat\ (but why is this needed?), and
% the call to \cmd\phantomsection\ (which must precede the call to \cmd\addcontentsline).
% We also have to sidestep the patch to \cmd\@ssect\ in that same file, therefore
% we use a different control sequence name in the call from \cmd\@startsection.
% \changes{4.0c}{1999/11/13}{(AO, 116) Hyperref compatibility}
% \changes{4.0f}{2001/07/13}{(AO, 404) Hyperref compatibility}
% \begin{macrocode}
\def\@ssect@ltx#1#2#3#4#5#6[#7]#8{%
% \end{macrocode}
% Removed |\def\@currentlabelname{#8}|
% \begin{macrocode}
\def\H@svsec{\phantomsection}%
\@tempskipa #5\relax
\@ifdim{\@tempskipa>\z@}{%
\begingroup
\interlinepenalty \@M
#6{%
\@ifundefined{@hangfroms@#1}{\@hang@froms}{\csname @hangfroms@#1\endcsname}%
% \end{macrocode}
% Removed |{\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}|
% \begin{macrocode}
{\hskip#3\relax\H@svsec}{#8}%
}%
\@@par
\endgroup
\@ifundefined{#1smark}{\@gobble}{\csname #1smark\endcsname}{#7}%
\addcontentsline{toc}{#1}{\protect\numberline{}#8}%
}{%
\def\@svsechd{%
#6{%
\@ifundefined{@runin@tos@#1}{\@runin@tos}{\csname @runin@tos@#1\endcsname}%
% \end{macrocode}
% Removed |{\hskip#3\relax\H@svsec}{\Sectionformat{#8}{#1}}|
% \begin{macrocode}
{\hskip#3\relax\H@svsec}{#8}%
}%
\@ifundefined{#1smark}{\@gobble}{\csname #1smark\endcsname}{#7}%
\addcontentsline{toc}{#1}{\protect\numberline{}#8}%
}%
}%
\@xsect{#5}%
}%
\def\@hang@froms#1#2{#1#2}%
\def\@runin@tos #1#2{#1#2}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\init@hyperref}
% \changes{4.1b}{2008/08/12}{Acquire \classname{hyperref} savoire}
% Document classes that incorporate this package will be \classname{hyperref}-savvy.
% (To accomplish this, we ensure that \cmd\hyperanchor\ and \cmd\hyper@last\ are both defined.)
% Being \classname{hyperref}-savvy levels some requirements on us, but the benefits are many.
%
% One is that the TOC will not get amnesia and require a full set of three typesetting runs before its formatting is stable.
% Instead, only two runs are required: the first updates the auxiliary file, the second the TOC.
% However, the formatting of the document does not change.
%
% Another aspect of being \classname{hyperref}-savvy is that the syntax of commands in the \file{.aux} file will not change
% if \classname{hyperref} is turned on or off.
%
% Note that \cmd\hyper@anchorstart\ and \cmd\hyper@anchorend\ constitute the programming interface
% for a hypertext anchor (the target of a hypertext link); \cmd\hyper@linkstart\ and \cmd\hyper@linkend\
% are the interface for a hypertext link.
% \begin{macrocode}
\def\init@hyperref{%
\providecommand\phantomsection{}%
\providecommand\hyper@makecurrent[1]{}%
\providecommand\Hy@raisedlink[1]{}%
\providecommand\hyper@anchorstart[1]{}%
\providecommand\hyper@anchorend{}%
\providecommand\hyper@linkstart[2]{}%
\providecommand\hyper@linkend{}%
\providecommand\@currentHref{}%
}%
\let\H@refstepcounter\refstepcounter
\appdef\document@inithook{%
\init@hyperref
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sec@upcase}
% Upper case for sections (optional upper case items). These are
% created so that some headings can be toggled between mixed case and
% upper case readily.
% Headings that might be changed can be wrapped in the style file in
% \cmd\sec@upcase\arg{text} constructs;
% the expansion of \cmd\sec@upcase\ is
% controlled here. It is \cmd\relax\ by default (mixed case heads), and
% can easily be changed to \cmd\uppercase\ if desired.
% If mixed-case headings are wanted by the editor, authors {\em must}
% supply mixed case text, although this is what authors should be doing
% anyway.
% (Mixed can be converted to upper,
% but the reverse transformation cannot be automated.)
%
% The following setting gives the \LaTeX\ default.
% \begin{macrocode}
\def\sec@upcase#1{\relax{#1}}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Patch the \env{tabular} and \env{array} Environments}
%
% \begin{macro}{\endtabular}
% \begin{macro}{\endarray}
% \changes{4.1b}{2008/08/12}{Patch the array package even later: after all package patches go in.}
% We headpatch the begin processing and tailpatch the end processing
% of the \env{tabular} and \env{array} environments.
% A document class can define these hooks as needed.
%
% We proceed with care to make further patches to
% support tabulars that break over pages.
% Our patches will not necessarily be effective for
% other packages that replace the \LaTeX\ \env{array} and \env{tabular}
% environments. I know of none that do so.
% \begin{macrocode}
\appdef\document@inithook{%
\@ifpackageloaded{array}{\switch@array}{\switch@tabular}%
\prepdef\endtabular{\endtabular@hook}%
\@provide\endtabular@hook{}%
\prepdef\endarray{\endarray@hook}%
\@provide\endarray@hook{}%
\providecommand\array@hook{}%
% \end{macrocode}
% Install, effectively, a head patch to \cmd\tabular.
% In order to avoid interference from, e.g., the \classname{array} package,
% we must perform this patch only \emph{after} packages load.
% \changes{4.0c}{1999/11/13}{(AO, 130) Interference from array package}
% \begin{macrocode}
\prepdef\@tabular{\tabular@hook}%
\@provide\tabular@hook{}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\switch@tabular}
% \begin{macro}{\switch@array}
% The two procedures \cmd\switch@tabular\ and \cmd\switch@array\
% apply needed patches to the various tabular procedures,
% the former applying to the \LaTeX\ kernel, the latter to the
% required \classname{array} package (and to the number of other
% required packages that load it).
%
% \begin{macrocode}
\def\switch@tabular{%
\let\@array@sw\@array@sw@array
\@ifx{\@array\@array@LaTeX}{%
\@ifx{\multicolumn\multicolumn@LaTeX}{%
\@ifx{\@tabular\@tabular@LaTeX}{%
\@ifx{\@tabarray\@tabarray@LaTeX}{%
\@ifx{\array\array@LaTeX}{%
\@ifx{\endarray\endarray@LaTeX}{%
\@ifx{\endtabular\endtabular@LaTeX}{%
\@ifx{\@mkpream\@mkpream@LaTeX}{%
\@ifx{\@addamp\@addamp@LaTeX}{%
\@ifx{\@arrayacol\@arrayacol@LaTeX}{%
\@ifx{\@tabacol\@tabacol@LaTeX}{%
\@ifx{\@arrayclassz\@arrayclassz@LaTeX}{%
\@ifx{\@tabclassiv\@tabclassiv@LaTeX}{%
\@ifx{\@arrayclassiv\@arrayclassiv@LaTeX}{%
\@ifx{\@tabclassz\@tabclassz@LaTeX}{%
\@ifx{\@classv\@classv@LaTeX}{%
\@ifx{\hline\hline@LaTeX}{%
\@ifx{\@tabularcr\@tabularcr@LaTeX}{%
\@ifx{\@xtabularcr\@xtabularcr@LaTeX}{%
\@ifx{\@xargarraycr\@xargarraycr@LaTeX}{%
\@ifx{\@yargarraycr\@yargarraycr@LaTeX}{%
\true@sw
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
{%
\class@info{Patching LaTeX tabular.}%
}{%
\class@info{Unrecognized LaTeX tabular. Please update this document class! (Proceeding with fingers crossed.)}%
}%
\let\@array\@array@ltx
\let\multicolumn\multicolumn@ltx
\let\@tabular\@tabular@ltx
\let\@tabarray\@tabarray@ltx
\let\array\array@ltx
\let\endarray\endarray@ltx
\let\endtabular\endtabular@ltx
\let\@mkpream\@mkpream@ltx
\let\@addamp\@addamp@ltx
\let\@arrayacol\@arrayacol@ltx
\let\@tabacol\@tabacol@ltx
\let\@arrayclassz\@arrayclassz@ltx
\let\@tabclassiv\@tabclassiv@ltx
\let\@arrayclassiv\@arrayclassiv@ltx
\let\@tabclassz\@tabclassz@ltx
\let\@classv\@classv@ltx
\let\hline\hline@ltx
\let\@tabularcr\@tabularcr@ltx
\let\@xtabularcr\@xtabularcr@ltx
\let\@xargarraycr\@xargarraycr@ltx
\let\@yargarraycr\@yargarraycr@ltx
}%
% \end{macrocode}
% \changes{4.1b}{2008/08/12}{(AO, 505) Try to accommodate \classname{colortbl}.}
% \begin{macrocode}
\def\switch@array{%
\@ifpackageloaded{colortbl}{\let\switch@array@info\colortbl@message}{\let\switch@array@info\array@message}%
\let\@array@sw\@array@sw@LaTeX
\@ifx{\@array\@array@array}{%
\@ifx{\@tabular\@tabular@array}{%
\@ifx{\@tabarray\@tabarray@array}{%
\@ifx{\array\array@array}{%
\@ifx{\endarray\endarray@array}{%
\@ifx{\endtabular\endtabular@array}{%
\@ifx{\@mkpream\@mkpream@array}{%
\@ifx{\@classx\@classx@array}{%
\@ifx{\insert@column\insert@column@array}{%
\@ifx{\@arraycr\@arraycr@array}{%
\@ifx{\@xarraycr\@xarraycr@array}{%
\@ifx{\@xargarraycr\@xargarraycr@array}{%
\@ifx{\@yargarraycr\@yargarraycr@array}{%
\true@sw
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}%
}{%
\false@sw
}{%
\class@info{Patching array package.}%
}{%
\switch@array@info
}%
\let\@array \@array@array@new
\let\@@array \@array % Cosi fan tutti
\let\@tabular \@tabular@array@new
\let\@tabarray \@tabarray@array@new
\let\array \array@array@new
\let\endarray \endarray@array@new
\let\endtabular\endtabular@array@new
\let\@mkpream \@mkpream@array@new
\let\@classx \@classx@array@new
\let\@arrayacol\@arrayacol@ltx
\let\@tabacol \@tabacol@ltx
\let\insert@column\insert@column@array@new
\expandafter\let\csname endtabular*\endcsname\endtabular % Cosi fan tutti
\let\@arraycr \@arraycr@new
\let\@xarraycr \@xarraycr@new
\let\@xargarraycr\@xargarraycr@new
\let\@yargarraycr\@yargarraycr@new
}%
\def\array@message{%
\class@info{Unrecognized array package. Please update this document class! (Proceeding with fingers crossed.)}%
}%
\def\colortbl@message{%
\class@info{colortbl package is loaded. (Proceeding with fingers crossed.)}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@array@sw}
% The Boolean \cmd\@array@sw\ must be different depending on
% whether the \classname{array} package is loaded.
% \begin{macrocode}
\def\@array@sw@LaTeX{\@ifx{\\\@tabularcr}}%
\def\@array@sw@array{\@ifx{\d@llarbegin\begingroup}}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabular}
% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
% We provide the old versions of \cmd\@tabular\ along with the respective new versions.
% The change here is to avoid committing to LR mode. That will be done later (as late as possible, naturally).
%
% Compatibility note: I had done \cmd\let\ \cmd\col@sep\ \cmd\@undefined\ here, but
% this was not compatible with \classname{colortbl}. I have removed that statement.
% \begin{macrocode}
\def\@tabular@LaTeX{%
\leavevmode
\hbox\bgroup$%
\let\@acol\@tabacol
\let\@classz\@tabclassz
\let\@classiv\@tabclassiv
\let\\\@tabularcr
\@tabarray
}%
\def\@tabular@ltx{%
\let\@acoll\@tabacoll
\let\@acolr\@tabacolr
\let\@acol\@tabacol
\let\@classz\@tabclassz
\let\@classiv\@tabclassiv
\let\\\@tabularcr
\@tabarray
}%
\def\@tabular@array{%
\leavevmode
\hbox\bgroup$%
\col@sep\tabcolsep
\let\d@llarbegin\begingroup
\let\d@llarend\endgroup
\@tabarray
}%
\def\@tabular@array@new{%
\let\@acoll\@tabacoll
\let\@acolr\@tabacolr
\let\@acol\@tabacol
% \end{macrocode}
% \let\col@sep\@undefined
% \begin{macrocode}
\let\d@llarbegin\begingroup
\let\d@llarend\endgroup
\@tabarray
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabarray}
% Here we provide old and new versions of the \cmd\@tabarray\ procedure.
% The change here is to parametrize the default vertical alignment,
% which is 'c' in standard \LaTeX.
% Under some circumstances, we want to change this to, say, 'v'.
%
% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
% FIXME: must decouple \env{array} and \env{tabular}. Done (it seems).
%
% Note on \classname{colortbl}: this package head-patches \cmd\@tabarray
% with its own command \cmd\CT@start, and tails onto \cmd\endarray\ with \cmd\CT@end.
% It fortuitously does the former at \cmd\AtBeginDocument\ time, and, fortuitously,
% we do not patch \cmd\endarray, which it overwrites.
% \begin{macrocode}
\def\@tabarray@LaTeX{%
\m@th\@ifnextchar[\@array{\@array[c]}%
}%
\def\@tabarray@ltx{%
\m@th\@ifnextchar[\@array{\expandafter\@array\expandafter[\array@default]}%
}%
\def\@tabarray@array{%
\@ifnextchar[{\@@array}{\@@array[c]}%
}%
\def\@tabarray@array@new{%
\@ifnextchar[{\@@array}{\expandafter\@@array\expandafter[\array@default]}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabularcr}
% \begin{macro}{\@tbpen}
% \begin{macro}{\@tabularcr}
% \begin{macro}{\@xtabularcr}
% \begin{macro}{\@xargarraycr}
% \begin{macro}{\@yargarraycr}
% \begin{macro}{\@arraycr}
% \begin{macro}{\@xarraycr}
% We provide for the \cmd\\ command within \env{tabular} to provide control over page breaking, just the same as
% that of \env{eqnarray}.
%
% The count register \cmd\intertabularlinepenalty\ is similar to \cmd\interdisplaylinepenalty: it is the penalty
% associated with each row of a tabular. When it is set to \cmd\@M, the tabular will cleave together.
%
% The count register \cmd\@tbpen\ is similar to \cmd\@eqpen: it memorizes the penalty to use after the current tabular row.
% If the \cmd\\ command is in its star form, then \cmd\@eqpen\ is set to \cmd\@M.
%
% We append code to \cmd\samepage\ so that a tabular within its scope will cleave together.
%
% We keep the standard definition of \cmd\@tabularcr\ in \cmd\@tabularcr@LaTeX\ for reference,
% and provide a new definition that works like \cmd\@eqncr: it sets \cmd\@tbpen\ to \cmd\@M\ if the star was given.
%
% We also provide new versions of \cmd\@xtabularcr, \cmd\@xargarraycr, and \cmd\@yargarraycr, all of which invoke \cmd\@tbpen.
%
% The \cmd\switch@tabular\ procedure switches in the new definitions.
% \begin{macrocode}
\newcount\intertabularlinepenalty
\intertabularlinepenalty=100
\newcount\@tbpen
\appdef\samepage{\intertabularlinepenalty\@M}%
\def\@tabularcr@LaTeX{{\ifnum 0=`}\fi \@ifstar \@xtabularcr \@xtabularcr}%
\def\@tabularcr@ltx{{\ifnum 0=`}\fi \@ifstar {\global \@tbpen \@M \@xtabularcr }{\global \@tbpen \intertabularlinepenalty \@xtabularcr }}%
\def\@xtabularcr@LaTeX{\@ifnextchar [\@argtabularcr {\ifnum 0=`{\fi }\cr }}%
\def\@xtabularcr@ltx{\@ifnextchar [\@argtabularcr {\ifnum 0=`{\fi }\cr \noalign {\penalty \@tbpen }}}%
\def\@xargarraycr@LaTeX#1{\@tempdima #1\advance \@tempdima \dp \@arstrutbox \vrule \@height \z@ \@depth \@tempdima \@width \z@ \cr}%
\def\@xargarraycr@ltx#1{\@tempdima #1\advance \@tempdima \dp \@arstrutbox \vrule \@height \z@ \@depth \@tempdima \@width \z@ \cr \noalign {\penalty \@tbpen }}%
\def\@yargarraycr@LaTeX#1{\cr \noalign {\vskip #1}}%
\def\@yargarraycr@ltx#1{\cr \noalign {\penalty \@tbpen \vskip #1}}%
% \end{macrocode}
%
% If the \classname{array} package has been loaded, we must alter the meanings of
% \cmd\@arraycr, \cmd\@xarraycr, \cmd\@xargarraycr, and \cmd\@yargarraycr.
% In this case, it is \cmd\switch@array\ that switches in the new definitions.
% \begin{macrocode}
\def\@arraycr@array{%
\relax
\iffalse{\fi\ifnum 0=`}\fi
\@ifstar \@xarraycr \@xarraycr
}%
\def\@arraycr@new{%
\relax
\iffalse{\fi\ifnum 0=`}\fi
\@ifstar {\global \@tbpen \@M \@xarraycr }{\global \@tbpen \intertabularlinepenalty \@xarraycr }%
}%
\def\@xarraycr@array{%
\@ifnextchar [%]
\@argarraycr {\ifnum 0=`{}\fi\cr}%
}%
\def\@xarraycr@new{%
\@ifnextchar [%]
\@argarraycr {\ifnum 0=`{}\fi\cr \noalign {\penalty \@tbpen }}%
}%
\def\@xargarraycr@array#1{%
\unskip
\@tempdima #1\advance\@tempdima \dp\@arstrutbox
\vrule \@depth\@tempdima \@width\z@
\cr
}%
\def\@xargarraycr@new#1{%
\unskip
\@tempdima #1\advance\@tempdima \dp\@arstrutbox
\vrule \@depth\@tempdima \@width\z@
\cr
\noalign {\penalty \@tbpen }%
}%
\def\@yargarraycr@array#1{%
\cr
\noalign{\vskip #1}%
}%
\def\@yargarraycr@new#1{%
\cr
\noalign{\penalty \@tbpen \vskip #1}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\array}
% We provide old and new versions of the \cmd\array\ procedure for both \LaTeX\ and the \classname{array} package.
% The change here is to accomodate the new procedures that will be called for the array boundaries, even
% though at present they are not special.
% A thought: here is where matrices can be readily accomodated.
% \begin{macrocode}
\def\array@LaTeX{%
\let\@acol\@arrayacol
\let\@classz\@arrayclassz
\let\@classiv\@arrayclassiv
\let\\\@arraycr
\let\@halignto\@empty
\@tabarray
}%
\def\array@ltx{%
\@ifmmode{}{\@badmath$}%
\let\@acoll\@arrayacol
\let\@acolr\@arrayacol
\let\@acol\@arrayacol
\let\@classz\@arrayclassz
\let\@classiv\@arrayclassiv
\let\\\@arraycr
\let\@halignto\@empty
\@tabarray
}%
\def\array@array{%
\col@sep\arraycolsep
\def\d@llarbegin{$}\let\d@llarend\d@llarbegin\gdef\@halignto{}%
\@tabarray
}
\def\array@array@new{%
\@ifmmode{}{\@badmath$}%
\let\@acoll\@arrayacol
\let\@acolr\@arrayacol
\let\@acol\@arrayacol
% \end{macrocode}
% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
% Removed: \verb+\let\col@sep\@undefined+
% \begin{macrocode}
\def\d@llarbegin{$}%
\let\d@llarend\d@llarbegin
\gdef\@halignto{}%
\@tabarray
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@array}
% Here we provide old and new versions of \cmd\@array.
% The change here is to provide a convenient, flexible, and extensible
% mechanism for new vertical alignment options.
%
% Instead of testing the optional argument with \cmd\if, we
% use a dispatcher based on \cmd\csname.
%
% We also refrain from using \cmd\ialign, which would set
% the \cmd\tabskip\ to the wrong value.
%
% Finally, the procedure to set the \cmd\@arstrutbox\
% is broken out so that it can be patched.
% \begin{macrocode}
\def\@array@LaTeX[#1]#2{%
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
\bgroup
\setbox\@arstrutbox\hbox{%
\vrule \@height\arraystretch\ht\strutbox
\@depth\arraystretch \dp\strutbox
\@width\z@}%
\@mkpream{#2}%
\edef\@preamble{%
\ialign \noexpand\@halignto
\bgroup \@arstrut \@preamble \tabskip\z@skip \cr}%
\let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
\let\tabularnewline\\%
\let\par\@empty
\let\@sharp##%
\set@typeset@protect
\lineskip\z@skip\baselineskip\z@skip
\ifhmode \@preamerr\z@ \@@par\fi
\@preamble
}%
\def\@array@ltx[#1]#2{%
\@nameuse{@array@align@#1}%
\set@arstrutbox
\@mkpream{#2}%
\prepdef\@preamble{%
\tabskip\tabmid@skip
\@arstrut
}%
\appdef\@preamble{%
\tabskip\tabright@skip
\cr
\array@row@pre
}%
% \let\@startpbox\@@startpbox
% \let\@endpbox\@@endpbox
\let\tabularnewline\\%
\let\par\@empty
\let\@sharp##%
\set@typeset@protect
\lineskip\z@skip\baselineskip\z@skip
\tabskip\tableft@skip\relax
\ifhmode \@preamerr\z@ \@@par\fi
\everycr{}%
\expandafter\halign\expandafter\@halignto\expandafter\bgroup\@preamble
}%
%
\def\set@arstrutbox{%
\setbox\@arstrutbox\hbox{%
\vrule \@height\arraystretch\ht\strutbox
\@depth\arraystretch \dp\strutbox
\@width\z@
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@array@array}
%
% \begin{macrocode}
\def\@array@array[#1]#2{%
\@tempdima \ht \strutbox
\advance \@tempdima by\extrarowheight
\setbox \@arstrutbox \hbox{\vrule
\@height \arraystretch \@tempdima
\@depth \arraystretch \dp \strutbox
\@width \z@}%
\begingroup
\@mkpream{#2}%
\xdef\@preamble{\noexpand \ialign \@halignto
\bgroup \@arstrut \@preamble
\tabskip \z@ \cr}%
\endgroup
\@arrayleft
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi
\bgroup
\let \@sharp ##\let \protect \relax
\lineskip \z@
\baselineskip \z@
\m@th
\let\\\@arraycr \let\tabularnewline\\\let\par\@empty \@preamble
}%
\def\@array@array@new[#1]#2{%
\@tempdima\ht\strutbox
\advance\@tempdima by\extrarowheight
\setbox\@arstrutbox\hbox{%
\vrule \@height\arraystretch\@tempdima
\@depth \arraystretch\dp\strutbox
\@width \z@
}%
\begingroup
\@mkpream{#2}%
\xdef\@preamble{\@preamble}%
\endgroup
\prepdef\@preamble{%
\tabskip\tabmid@skip
\@arstrut
}%
\appdef\@preamble{%
\tabskip\tabright@skip
\cr
\array@row@pre
}%
\@arrayleft
\@nameuse{@array@align@#1}%
\m@th
\let\\\@arraycr
\let\tabularnewline\\%
\let\par\@empty
\let\@sharp##%
\set@typeset@protect
\lineskip\z@\baselineskip\z@
\tabskip\tableft@skip
\everycr{}%
\expandafter\halign\expandafter\@halignto\expandafter\bgroup\@preamble
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endarray}
% Here we provide old and new versions of \cmd\endarray.
% The change here is to use a single procedure to close
% out any array-like structure, namely \cmd\endarray@ltx.
% It merely closes out the \cmd\halign.
% \begin{macrocode}
\def\endarray@LaTeX{%
\crcr\egroup\egroup
}%
\def\endarray@ltx{%
\crcr\array@row@pst\egroup\egroup
}%
\def\endarray@array{%
\crcr \egroup \egroup \@arrayright \gdef\@preamble{}%
}%
\def\endarray@array@new{%
\crcr\array@row@pst\egroup\egroup % Same as \endarray@ltx
\@arrayright
\global\let\@preamble\@empty
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endtabular}
%
% \begin{macrocode}
\def\endtabular@LaTeX{%
\crcr\egroup\egroup $\egroup
}%
\def\endtabular@ltx{%
\endarray
}%
\def\endtabular@array{%
\endarray $\egroup
}%
\def\endtabular@array@new{%
\endarray
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{endtabular*}
% Here we provide a proper definition for the star-form of \enve{endtabular}.
% It is one of the enduring curiosities that the \LaTeX\ kernel continues to use
% dangerously and inappropriately ``optimized'' definitions for such commands.
% \begin{macrocode}
\@namedef{endtabular*}{\endtabular}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\multicolumn}
%
% \begin{macrocode}
\long\def\multicolumn@LaTeX#1#2#3{%
\multispan{#1}\begingroup
\@mkpream{#2}%
\def\@sharp{#3}\set@typeset@protect
\let\@startpbox\@@startpbox\let\@endpbox\@@endpbox
\@arstrut \@preamble\hbox{}\endgroup\ignorespaces
}%
\long\def\multicolumn@ltx#1#2#3{%
\multispan{#1}%
\begingroup
\@mkpream{#2}%
\def\@sharp{#3}%
\set@typeset@protect
%\let\@startpbox\@@startpbox\let\@endpbox\@@endpbox
\@arstrut
\@preamble
\hbox{}%
\endgroup
\ignorespaces
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@array@align@}
% \begin{macro}{\array@default}
% Here are the various procedures for the vertical alignment options.
% The change from standard \LaTeX\ is that we do not go into math mode
% in every case: only when required by \cmd\vcenter.
% Also, we use \cmd\aftergroup\ to close out the boxes and modes we have started.
% It requires only that each procedure issue exactly one unmatched \cmd\bgroup.
%
% We establish here the default vertical alignment.
% \begin{macrocode}
\def\@array@align@t{\leavevmode\vtop\bgroup}%
\def\@array@align@b{\leavevmode\vbox\bgroup}%
\def\@array@align@c{\leavevmode\@ifmmode{\vcenter\bgroup}{$\vcenter\bgroup\aftergroup$\aftergroup\relax}}%
\def\@array@align@v{%
\@ifmmode{%
\@badmath
\vcenter\bgroup
}{%
\@ifinner{%
$\vcenter\bgroup\aftergroup$
}{%
\@@par\bgroup
}%
}%
}%
\def\array@default{c}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\array@row@pre}
% \begin{macro}{\array@row@pst}
% \begin{macro}{\array@row@rst}
% The procedure \cmd\array@row@rst\ reestablishes a default context for
% an alignment, so that they can be nested.
% Any environment or procedure that alters the way alignments are formatted
% must patch this procedure to restore from that alteration.
% To start things off, we equate \cmd\@array@align@v\ to \cmd\@array@align@c,
% because it does not make sense to do the former in any context other
% than the MVL or in a list that will be unboxed onto the MVL.
% \begin{macrocode}
\def\array@row@rst{%
\let\@array@align@v\@array@align@c
}%
\def\array@row@pre{}%
\def\array@row@pst{}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\toprule}
% \begin{macro}{\colrule}
% \begin{macro}{\botrule}
% Default definitions for \cmd\toprule, \cmd\colrule, \cmd\botrule
% \begin{macrocode}
\newcommand\toprule{\tab@rule{\column@font}{\column@fil}{\frstrut}}%
\newcommand\colrule{\unskip\lrstrut\\\tab@rule{\body@font}{}{\frstrut}}%
\newcommand\botrule{\unskip\lrstrut\\\noalign{\hline@rule}{}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hline}
% \begin{macrocode}
\def\hline@LaTeX{%
\noalign{\ifnum0=`}\fi\hrule \@height \arrayrulewidth \futurelet
\reserved@a\@xhline
}%
\def\hline@ltx{%
\noalign{%
\ifnum0=`}\fi
\hline@rule
\futurelet\reserved@a\@xhline
% \noalign ended in \@xhline
}%
\def\@xhline@unneeded{%
\say\reserved@a
\ifx\reserved@a\hline
\vskip\doublerulesep
\vskip-\arrayrulewidth
\fi
\ifnum0=`{\fi}%
}%
\def\tab@rule#1#2#3{%
\crcr
\noalign{%
\hline@rule
\gdef\@arstrut@hook{%
\global\let\@arstrut@hook\@empty
#3%
}%
\gdef\cell@font{#1}%
\gdef\cell@fil{#2}%
}%
}%
\def\column@font{}%
\def\column@fil{}%
\def\body@font{}%
\def\cell@font{}%
\def\frstrut{}%
\def\lrstrut{}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arstrut@hline}
% \begin{macro}{\@arstrut@org}
% \begin{macro}{\@arstrut@hook}
% \begin{macro}{\@arstrutbox@hline}
% \begin{macro}{\set@arstrutbox}
% \begin{macro}{\hline@rule}
% The procedure \cmd\@arstrut@hline\ is substantially the same as
% \cmd\@arstrut, except the strut copied in is \cmd\@arstrutbox@hline
% instead of \cmd\@arstrutbox.
%
% The procedure \cmd\@arstrut@hook\ is redefined in \cmd\tab@rule!
%
% The register \cmd\@arstrutbox@hline.
%
% We append to \cmd\set@arstrutbox\ the code necessary to set a strut following an \cmd\hline.
%
% The procedure \cmd\hline@rule\ lays down a rule, and changes the meaning of \cmd\@arstrut\
% so that the next line will be correctly strutted.
%
% The \cmd\@arstrut@hline@clnc\ is a klootch, a magic number.
% \begin{macrocode}
\def\@arstrut@hline{%
\relax
\@ifmmode{\copy}{\unhcopy}\@arstrutbox@hline
\@arstrut@hook
}%
%
\let\@arstrut@org\@arstrut
\def\@arstrut@hook{%
\global\let\@arstrut\@arstrut@org
}%
%
\newbox\@arstrutbox@hline
\appdef\set@arstrutbox{%
\setbox\@arstrutbox@hline\hbox{%
\setbox\z@\hbox{$0^{0}_{}$}%
\dimen@\ht\z@\advance\dimen@\@arstrut@hline@clnc
\@ifdim{\dimen@<\arraystretch\ht\strutbox}{\dimen@=\arraystretch\ht\strutbox}{}%
\vrule \@height\dimen@
\@depth\arraystretch \dp\strutbox
\@width\z@
}%
}%
%
\def\hline@rule{%
\hrule \@height \arrayrulewidth
\global\let\@arstrut\@arstrut@hline
}%
\def\@arstrut@hline@clnc{2\p@}% % Klootch: magic number
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tableft@skip}
% \begin{macrocode}
\def\tableft@skip{\z@skip}%
\def\tabmid@skip{\z@skip}%\@flushglue
\def\tabright@skip{\z@skip}%
\def\tableftsep{\tabcolsep}%
\def\tabmidsep{\tabcolsep}%
\def\tabrightsep{\tabcolsep}%
\def\cell@fil{}%
\def\pbox@hook{}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arstrut}
% \begin{macrocode}
\appdef\@arstrut{\@arstrut@hook}%
\let\@arstrut@hook\@empty
\def\@addtopreamble{\appdef\@preamble}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mkpream}
% \begin{macrocode}
\def\@mkpream@LaTeX#1{%
\@firstamptrue\@lastchclass6
\let\@preamble\@empty
\let\protect\@unexpandable@protect
\let\@sharp\relax
\let\@startpbox\relax\let\@endpbox\relax
\@expast{#1}%
\expandafter\@tfor \expandafter
\@nextchar \expandafter:\expandafter=\reserved@a\do
{\@testpach\@nextchar
\ifcase \@chclass \@classz \or \@classi \or \@classii \or \@classiii
\or \@classiv \or\@classv \fi\@lastchclass\@chclass}%
\ifcase \@lastchclass \@acol
\or \or \@preamerr \@ne\or \@preamerr \tw@\or \or \@acol \fi
}%
\def\@mkpream@ltx#1{%
\@firstamptrue
\@lastchclass6
\let\@preamble\@empty
\let\protect\@unexpandable@protect
\let\@sharp\relax
%\let\@startpbox\relax\let\@endpbox\relax
\@expast{#1}%
\expandafter\@tfor\expandafter\@nextchar\expandafter:\expandafter=\reserved@a
\do{%
\expandafter\@testpach\expandafter{\@nextchar}%
\ifcase\@chclass
\@classz
\or
\@classi
\or
\@classii
\or
\@classiii
\or
\@classiv
\or
\@classv
\fi
\@lastchclass\@chclass
}%
\ifcase\@lastchclass
\@acolr % right-hand column
\or
\or
\@preamerr\@ne
\or
\@preamerr\tw@
\or
\or
\@acolr % right-hand column
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\insert@column}
% \begin{macrocode}
\def\insert@column@array{%
\the@toks \the \@tempcnta
\ignorespaces \@sharp \unskip
\the@toks \the \count@ \relax
}%
\def\insert@column@array@new{%
\the@toks\the\@tempcnta
\array@row@rst\cell@font
\ignorespaces\@sharp\unskip
\the@toks\the\count@
\relax
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mkpream@relax}
% The procedure \cmd\@mkpream@relax\ participates in a strange and wonderful
% method of binding the alignment procedure---but only certain parts thereof.
%
% Here is how it works: in \LaTeX, the \classname{array} package, and in the
% \classname{longtable} package alike, there is a need to create an alignment
% preamble (using \cmd\@mkpream) for use by the upcoming \cmd\halign.
% Then, in both \classname{array} and \classname{longtable}, \TeX's \cmd\edef\
% is used to `compile in place' that alignment preamble.
%
% In the case of \classname{array},
% the operation is done in order to pre-expand the use of \texttt{*};
% in \classname{longtable}, it is to set the widths of the columns.
%
% Now, during this \cmd\edef, certain control sequence names must \emph{not}
% be expanded, and those are robustified by \cmd\@mkpream@relax.
%
% \begin{macrocode}
\def\@mkpream@relax{%
\let\tableftsep \relax
\let\tabmidsep \relax
\let\tabrightsep \relax
\let\array@row@rst\relax
\let\cell@font \relax
\let\@startpbox \relax
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mkpream}
% We insert \cmd\@mkpream@relax\ at the head of the procedure.
% The robustifying of \cmd\@startpbox\ and \cmd\@endpbox\ is taken over by this mechanism.
% We also invoke \cmd\@acolr\ instead of \cmd\@acol\ when a right-hand column is at hand.
%
% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
% Note on \classname{colortbl}: this package head-patches \cmd\@mkpream\ to robustify
% a number of its commands during the construction of the alignment preamble.
% The best we can do is to supplement the \cmd\@mkpream@relax\ procedure to perform this action.
% \begin{macrocode}
\def\@mkpream@array#1{%
\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
\let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
\@temptokena{#1}\@tempswatrue
\@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
\count@\m@ne
\let\the@toks\relax
\prepnext@tok
\expandafter \@tfor \expandafter \@nextchar
\expandafter :\expandafter =\the\@temptokena \do
{\@testpach
\ifcase \@chclass \@classz \or \@classi \or \@classii
\or \save@decl \or \or \@classv \or \@classvi
\or \@classvii \or \@classviii
\or \@classx
\or \@classx \fi
\@lastchclass\@chclass}%
\ifcase\@lastchclass
\@acol \or
\or
\@acol \or
\@preamerr \thr@@ \or
\@preamerr \tw@ \@addtopreamble\@sharp \or
\or
\else \@preamerr \@ne \fi
\def\the@toks{\the\toks}%
}%
\def\@mkpream@array@new#1{%
\gdef\@preamble{}%
\@lastchclass\f@ur
\@firstamptrue
\let\@sharp\relax
\@mkpream@relax
%\let\@startpbox\relax\let\@endpbox\relax
\@temptokena{#1}\@tempswatrue
\@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
\count@\m@ne
\let\the@toks\relax
\prepnext@tok
\expandafter\@tfor\expandafter\@nextchar\expandafter:\expandafter=\the\@temptokena
\do{%
\@testpach
\ifcase\@chclass
\@classz
\or
\@classi
\or
\@classii
\or
\save@decl
\or
\or
\@classv
\or
\@classvi
\or
\@classvii
\or
\@classviii
\or
\@classx
\or
\@classx
\fi
\@lastchclass\@chclass
}%
\ifcase\@lastchclass
\@acolr % right-hand column
\or
\or
\@acolr % right-hand column
\or
\@preamerr\thr@@
\or
\@preamerr\tw@\@addtopreamble\@sharp
\or
\or
\else
\@preamerr\@ne
\fi
\def\the@toks{\the\toks}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mkpream@relax}
% \changes{4.1b}{2008/08/12}{(AO, 505) try to accommodate \classname{colortbl}.}
% David P. Carlisle's \classname{colortbl} package headpatches \cmd\@mkpream\ in place
% during package loading, so it does not know whom it is working on.
% Let us try to accomodate this package by doing what it would have liked to have done.
%
% Note: it would be far better to break out this mechanism in the \classname{array} package.
% \begin{macrocode}
\appdef\@mkpream@relax{%
\let\CT@setup \relax
\let\CT@color \relax
\let\CT@do@color \relax
\let\color \relax
\let\CT@column@color\relax
\let\CT@row@color \relax
\let\CT@cell@color \relax
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@addamp}
% \begin{macrocode}
\def\@addamp@LaTeX{%
\if@firstamp\@firstampfalse\else\edef\@preamble{\@preamble &}\fi
}%
\def\@addamp@ltx{%
\if@firstamp\@firstampfalse\else\@addtopreamble{&}\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arrayacol}
% \begin{macrocode}
\def\@arrayacol@LaTeX{%
\edef\@preamble{\@preamble \hskip \arraycolsep}%
}%
\def\@arrayacol@ltx{%
\@addtopreamble{\hskip\arraycolsep}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabacol}
% \begin{macrocode}
\def\@tabacoll{%
\@addtopreamble{\hskip\tableftsep\relax}%
}%
\def\@tabacol@LaTeX{%
\edef\@preamble{\@preamble \hskip \tabcolsep}%
}%
\def\@tabacol@ltx{%
\@addtopreamble{\hskip\tabmidsep\relax}%
}%
\def\@tabacolr{%
\@addtopreamble{\hskip\tabrightsep\relax}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arrayclassz}
% \begin{macrocode}
\def\@arrayclassz@LaTeX{%
\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
\or \or \@addamp \or
\@acolampacol \or \@firstampfalse \@acol \fi
\edef\@preamble{\@preamble
\ifcase \@chnum
\hfil$\relax\@sharp$\hfil \or $\relax\@sharp$\hfil
\or \hfil$\relax\@sharp$\fi}%
}%
\def\@arrayclassz@ltx{%
\ifcase\@lastchclass
\@acolampacol
\or
\@ampacol
\or
\or
\or
\@addamp
\or
\@acolampacol
\or
\@firstampfalse\@acoll
\fi
\ifcase\@chnum
\@addtopreamble{%
\hfil\array@row@rst$\relax\@sharp$\hfil
}%
\or
\@addtopreamble{%
\array@row@rst$\relax\@sharp$\hfil
}%
\or
\@addtopreamble{%
\hfil\array@row@rst$\relax\@sharp$%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabclassz}
% \begin{macrocode}
\def\@tabclassz@LaTeX{%
\ifcase\@lastchclass
\@acolampacol
\or
\@ampacol
\or
\or
\or
\@addamp
\or
\@acolampacol
\or
\@firstampfalse\@acol
\fi
\edef\@preamble{%
\@preamble{%
\ifcase\@chnum
\hfil\ignorespaces\@sharp\unskip\hfil
\or
\hskip1sp\ignorespaces\@sharp\unskip\hfil
\or
\hfil\hskip1sp\ignorespaces\@sharp\unskip
\fi}}%
}%
\def\@tabclassz@ltx{%
\ifcase\@lastchclass
\@acolampacol
\or
\@ampacol
\or
\or
\or
\@addamp
\or
\@acolampacol
\or
\@firstampfalse\@acoll
\fi
\ifcase\@chnum
\@addtopreamble{%
{\hfil\array@row@rst\cell@font\ignorespaces\@sharp\unskip\hfil}%
}%
\or
\@addtopreamble{%
{\cell@fil\hskip1sp\array@row@rst\cell@font\ignorespaces\@sharp\unskip\hfil}%
}%
\or
\@addtopreamble{%
{\hfil\hskip1sp\array@row@rst\cell@font\ignorespaces\@sharp\unskip\cell@fil}%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabclassiv}
% \begin{macrocode}
\def\@tabclassiv@LaTeX{%
\@addtopreamble\@nextchar
}%
\def\@tabclassiv@ltx{%
\expandafter\@addtopreamble\expandafter{\@nextchar}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@arrayclassiv}
% \begin{macrocode}
\def\@arrayclassiv@LaTeX{%
\@addtopreamble{$\@nextchar$}%
}%
\def\@arrayclassiv@ltx{%
\expandafter\@addtopreamble\expandafter{\expandafter$\@nextchar$}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@classv}
% \begin{macrocode}
\def\@classv@LaTeX{%
\@addtopreamble{\@startpbox{\@nextchar}\ignorespaces
\@sharp\@endpbox}%
}%
\def\@classv@ltx{%
\expandafter\@addtopreamble
\expandafter{%
\expandafter \@startpbox
\expandafter {\@nextchar}%
\pbox@hook\array@row@rst\cell@font\ignorespaces\@sharp\@endpbox
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@classx}
% \begin{macrocode}
\def\@classx@array{%
\ifcase \@lastchclass
\@acolampacol \or
\@addamp \@acol \or
\@acolampacol \or
\or
\@acol \@firstampfalse \or
\@addamp
\fi
}%
\def\@classx@array@new{%
\ifcase \@lastchclass
\@acolampacol
\or
\@addamp \@acol
\or
\@acolampacol
\or
\or
\@firstampfalse\@acoll
\or
\@addamp
\fi
}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Repair other broken parts of \LaTeX}
%
% \begin{macro}{\@xbitor}
% Expansion part has extraneous space token. Removed.
% \begin{macrocode}
\def\@xbitor@LaTeX #1{\@tempcntb \count#1
\ifnum \@tempcnta =\z@
\else
\divide\@tempcntb\@tempcnta
\ifodd\@tempcntb \@testtrue\fi
\fi}%
\def\@xbitor@ltx#1{%
\@tempcntb\count#1\relax
\@ifnum{\@tempcnta=\z@}{}{%
\divide\@tempcntb\@tempcnta
\@ifodd\@tempcntb{\@testtrue}{}%
}%
}%
\@ifx{\@xbitor\@xbitor@LaTeX}{%
\class@info{Repairing broken LaTeX \string\@xbitor}%
}{%
\class@info{Unrecognized LaTeX \string\@xbitor. Please update this document class! (Proceeding with fingers crossed.)}%
}%
\let\@xbitor\@xbitor@ltx
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Syntax}
% \begin{macro}{\@gobble@opt@one}
% The \cmd\@gobble@opt@one\ command eats up an optional argument
% and one required argument.
% \begin{macrocode}
\newcommand*\@gobble@opt@one[2][]{}%
% \end{macrocode}
% \end{macro}
%
% \subsection{Auto-indented Contents}
% Facility to automatically determine the proper indentation of
% the TOC entries.
%
% Note on \classname{hyperref} compatibility:
% We must respect that
% \cmd\contentsline\ now has a fourth argument.
% So, instead of trying to override the meaning of \cmd\contentsline,
% we use the aux file to remember max values from one run to the next.
%
% In this respect, this package retains compatibility with
% \classname{hyperref}.
%
% \begin{macro}{\@starttoc}
% Install hooks at beginning and end of the TOC processing.
% \begin{macrocode}
\def\@starttoc#1{%
\begingroup
\toc@pre
\makeatletter
\@input{\jobname.#1}%
\if@filesw
\expandafter\newwrite\csname tf@#1\endcsname
\immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
\fi
\@nobreakfalse
\toc@post
\endgroup
}%
\def\toc@pre{}%
\def\toc@post{}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\toc@@font}
% Interface for setting the formatting characteristics of this part
% of the TOC.
%
% Note: \cmd\toc@@font\ is the common font for all auto-sizing toc commands,
% although this, too, could become a dispatcher.
% \changes{4.1a}{2008/01/19}{(AO, 461) Change the csname from \cs{@dotsep} to \cs{ltxu@dotsep}. The former is understood in mu. (What we wanted was a dimension.)}%
% \begin{macrocode}
\def\toc@@font{}%
\def\ltxu@dotsep{\z@}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@section}
% Interface for determining which TOC elements are automatically indented.
%
% All of the \cmd\l@\dots\ commands simply go through the
% utility procedure \cmd\l@@sections. The calling convention is
% to pass the name of self and the name of parent.
% If you want to exclude any of these from the indentation
% scheme, simply leave the \cmd\l@\dots\ command undefined.
%
% Note that the parent of ``section'' is nil, so we have to define a stub.
% \begin{verbatim}\def\l@section{\l@@sections{}{section}}% Implicit #3#4\end{verbatim}
% \begin{verbatim}\def\tocleft@{\z@}%\end{verbatim}
% \begin{verbatim}\def\l@subsection{\l@@sections{section}{subsection}}% Implicit #3#4\end{verbatim}
% \begin{verbatim}\def\l@subsubsection{\l@@sections{subsection}{subsubsection}}% Implicit #3#4\end{verbatim}
% \begin{verbatim}\def\l@paragraph{\l@@sections{subsubsection}{paragraph}}% Implicit #3#4\end{verbatim}
% \begin{verbatim}\def\l@subparagraph#1#2{\l@@sections{paragraph}{subparagraph}}% Implicit #3#4\end{verbatim}
% \end{macro}
%
% Glom some \cmd\dimen\ registers.
% \begin{macrocode}
\let\tocdim@section \leftmargini
\let\tocdim@subsection \leftmarginii
\let\tocdim@subsubsection \leftmarginiii
\let\tocdim@paragraph \leftmarginiv
\let\tocdim@appendix \leftmarginv
\let\tocdim@pagenum \leftmarginvi
% \end{macrocode}
%
% \begin{macro}{\toc@pre@auto}
% \begin{macro}{\toc@post@auto}
% We patch \cmd\@starttoc\ to:
% 1) before TOC processing,
% initialize the max registers and
% set the needed dimensions from
% the values stored in the auxiliary file, and
% 2) after TOC processing,
% store out those max register values into the auxiliary file.
%
% Note that the font is set here: all other TOC entries must
% override these font settings.
%
% To activate this override of the standard \LaTeX\ processing,
% the substyle does: \cmd\let\cmd\toc@pre\cmd\toc@pre@auto\
% and \cmd\let\cmd\toc@post\cmd\toc@post@auto.
% \begin{macrocode}
\def\toc@pre@auto{%
\toc@@font
\@tempdima\z@
\toc@setindent\@tempdima{section}%
\toc@setindent\@tempdima{subsection}%
\toc@setindent\@tempdima{subsubsection}%
\toc@setindent\@tempdima{paragraph}%
\toc@letdimen{appendix}%
\toc@letdimen{pagenum}%
}%
\def\toc@post@auto{%
\if@filesw
\begingroup
\toc@writedimen{section}%
\toc@writedimen{subsection}%
\toc@writedimen{subsubsection}%
\toc@writedimen{paragraph}%
\toc@writedimen{appendix}%
\toc@writedimen{pagenum}%
\endgroup
\fi
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\toc@setindent}
% \begin{macrocode}
\def\toc@setindent#1#2{%
\csname tocdim@#2\endcsname\tocdim@min\relax
\@ifundefined{tocmax@#2}{\@namedef{tocmax@#2}{\z@}}{}%
\advance#1\@nameuse{tocmax@#2}\relax
\expandafter\edef\csname tocleft@#2\endcsname{\the#1}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\toc@letdimen}
% \begin{macrocode}
\def\toc@letdimen#1{%
\csname tocdim@#1\endcsname\tocdim@min\relax
\@ifundefined{tocmax@#1}{\@namedef{tocmax@#1}{\z@}}{}%
\expandafter\let\csname tocleft@#1\expandafter\endcsname\csname tocmax@#1\endcsname
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\toc@writedimen}
% \begin{macrocode}
\def\toc@writedimen#1{%
\immediate\write\@auxout{%
\gdef\expandafter\string\csname tocmax@#1\endcsname{%
\expandafter\the\csname tocdim@#1\endcsname
}%
}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@@sections}
% The procedure for formatting the indented TOC entries.
% We use control sequence names such as \cmd\tocmax@section\ and
% \cmd\tocleft@section, the former being written to the auxiliary file
% and the latter only defined for the duration of the TOC processing.
%
% Note that the assignment of \cmd\box\cmd\@tempboxa\ by \cmd\set@tocdim@pagenum\
% must endure over the invocation of |#3|: it contains the
% page number which will be set just before the \cmd\par.
%
% The arguments:\begin{enumerate}
% \item[\#1] superior section
% \item[\#2] this section
% \item[\#3] content, including possible \cmd\numberline
% \item[\#4] page number\end{enumerate}
% \begin{macrocode}
\def\l@@sections#1#2#3#4{%
\begingroup
\everypar{}%
\set@tocdim@pagenum\@tempboxa{#4}%
\global\@tempdima\csname tocdim@#2\endcsname
\leftskip\csname tocleft@#2\endcsname\relax
\dimen@\csname tocleft@#1\endcsname\relax
\parindent-\leftskip\advance\parindent\dimen@
\rightskip\tocleft@pagenum plus 1fil\relax
\skip@\parfillskip\parfillskip\z@
\let\numberline\numberline@@sections
\@nameuse{l@f@#2}%
\ignorespaces#3\unskip\nobreak\hskip\skip@
\hb@xt@\rightskip{\hfil\unhbox\@tempboxa}\hskip-\rightskip\hskip\z@skip
% \end{macrocode}
% \changes{4.1n}{2009/12/13}{(AO, 574) protect against \classname{lineno.sty}, which forces a visit to the output routine, which appears to destroy the value of \cs{@tempdima}}%
%
% By side effect, set the value of, e.g., \cmd\tocdim@section.
%
% Note that the \cmd\par\ must not be executed before the value of \cmd\@tempdima\ is expanded (outside the current group).
% Otherwise, the \classname{lineno.sty} package may interfere (it unfortunately does a global assignment of \cmd\@tempdima).
% \begin{macrocode}
\expandafter\par
\expandafter\aftergroup\csname tocdim@#2%
\expandafter\endcsname
\expandafter\endgroup
\the\@tempdima\relax
}%
% \end{macrocode}
% \changes{4.1a}{2008/01/19}{(AO, 479) Per: Dylan Thurston<dpt at math.harvard.edu>}%
% In the call to \cmd\set@tocdim@pagenum, I am now exposing the use of the particular box register.
% \begin{macrocode}
\def\set@tocdim@pagenum#1#2{%
\setbox#1\hbox{\ignorespaces#2}%
\@ifdim{\tocdim@pagenum<\wd#1}{\global\tocdim@pagenum\wd#1}{}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\numberline@@sections}
% \changes{4.1a}{2008/01/19}{(AO, 461) Change the csname from \cs{@dotsep} to \cs{ltxu@dotsep}. The former is understood in mu. (What we wanted was a dimension.)}%
% The utility procedure for all \cmd\numberline\ processing in indented TOC entries.
% The first argument is self.
%
% We use \cmd\@tempdima\ to pass a value around (via global assignment) because
% \cmd\numberline\ executes inside a group if the
% \classname{hyperref} package is loaded.
% Would that it were not so!
% \begin{macrocode}
\def\numberline@@sections#1{%
\leavevmode\hb@xt@-\parindent{%
\hfil
\@if@empty{#1}{}{%
\setbox\z@\hbox{#1.\kern\ltxu@dotsep}%
\@ifdim{\@tempdima<\wd\z@}{\global\@tempdima\wd\z@}{}%
\unhbox\z@
}%
}%
\ignorespaces
}%
\def\tocdim@min{\z@}%
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Lists}
% \begin{macro}{\list}
% Using \cmd\parshape\ to implement lists was always suspect
% (can you get behind \cmd\parshape\cmd\@ne?) and we now see that
% it was a mistake all along. Why? Because \cmd\parshape, like
% \cmd\hangindent, achieves its effect via ``shifting'' the \cmd\hbox es
% in a paragraph
% instead of using \cmd\leftskip\ and \cmd\parindent, which is
% robust during column balancing.
%
% We introduce the alternative method with a hook into
% the \LaTeX\ kernel procedure \cmd\list, which is
% the implementation of all lists.
%
% \begin{macrocode}
\def\list#1#2{%
\ifnum \@listdepth >5\relax
\@toodeep
\else
\global\advance\@listdepth\@ne
\fi
\rightmargin\z@
\listparindent\z@
\itemindent\z@
\csname @list\romannumeral\the\@listdepth\endcsname
\def\@itemlabel{#1}%
\let\makelabel\@mklab
\@nmbrlistfalse
#2\relax
\@trivlist
\parskip\parsep
\set@listindent
\ignorespaces
}%
\def\set@listindent@parshape{%
\parindent\listparindent
\advance\@totalleftmargin\leftmargin
\advance\linewidth-\rightmargin
\advance\linewidth-\leftmargin
\parshape\@ne\@totalleftmargin\linewidth
}%
\def\set@listindent@{%
\parindent\listparindent
\advance\@totalleftmargin\leftmargin
\advance\rightskip\rightmargin
\advance\leftskip\@totalleftmargin
}%
\let\set@listindent\set@listindent@parshape
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Hypertext capabilities}
%
% \begin{macro}{\href}
% \begin{macro}{\url}
% \begin{macro}{\URL@prefix}
% \begin{macro}{\doi}
% \begin{macro}{\doibase}
% \changes{4.1b}{2008/08/12}{(AO, 487) Support for video figures and the \cs{setfloatlink} command}%
% We provide support for the \cmd\href, \cmd\url, and \cmd\doi\ commands.
% Packages, like \classname{hyperref}, may override these definitions
% and provide better semantics.
% \changes{4.1g}{2009/10/06}{(AO, 532) Both arguments of \cs{href} get sanitized}%
% \changes{4.1j}{2009/10/24}{(AO, 545) Provide definition for \cs{doi} that does hypertext}%
% \begin{macrocode}
\providecommand\href[0]{\begingroup\@sanitize@url\@href}%
\def\@href#1{\@@startlink{#1}\endgroup\@@href}%
\def\@@href#1{#1\@@endlink}%
\providecommand \url [0]{\begingroup\@sanitize@url \@url }%
\def \@url #1{\endgroup\@href {#1}{\URL@prefix#1}}%
\providecommand \URL@prefix [0]{URL }%
\providecommand\doi[0]{\begingroup\@sanitize@url\@doi}%
\def\@doi#1{\endgroup\@@startlink{\doibase#1}doi:\discretionary {}{}{}#1\@@endlink }%
%changes{4.2a}{2017/11/21}{(MD) Use updated best practice to use https and doi.org}%
\providecommand \doibase [0]{https://doi.org/}%
\providecommand \@sanitize@url[0]{\chardef\cat@space\the\catcode`\ \@sanitize\catcode`\ \cat@space}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@startlink}
% \begin{macro}{\@@endlink}
% \begin{macro}{\pdfstartlink@attr}
% \begin{macro}{\hypertext@enable@ltx}
% How we define \cmd\@@startlink\ and \cmd\@@endlink\ will depend on
% whether we are running under \textsc{pdflatex}.
% If so, and if PDF output is requested, then we use its primitives
% to implement hypertext,
% breaking out the link attributes in \cmd\pdfstartlink@attr\
% and using the \classname{hyperref} defaults;
% \cmd\pdfstartlink@attr\ can be redefined by a client package.
% Otherwise we fall back the Hyper\TeX\ standard and leave things to the DVI translator.
% \changes{4.1j}{2009/10/25}{(AO, 545) hypertext capabilities off by default; enable with \classoption{hypertext}}
%
% A class or package that wishes to employ hypertext capabilities should
% execute the \cmd\hypertext@enable@ltx\ procedure.
% \begin{macrocode}
\def\@@startlink#1{}%
\def\@@endlink{}%
\@ifxundefined \pdfoutput {\true@sw}{\@ifnum{\z@=\pdfoutput}{\true@sw}{\false@sw}}%
{%
\def\@@startlink@hypertext#1{\leavevmode\special{html:<a href="#1">}}%
\def\@@endlink@hypertext{\special{html:</a>}}%
}{%
\def\@@startlink@hypertext#1{%
\leavevmode
\pdfstartlink\pdfstartlink@attr
user{/Subtype/Link/A<</Type/Action/S/URI/URI(#1)>>}%
\relax
}%
\def\@@endlink@hypertext{\pdfendlink}%
\def\pdfstartlink@attr{attr{/Border[0 0 1 ]/H/I/C[0 1 1]}}%
}%
\def\hypertext@enable@ltx{%
\let\@@startlink\@@startlink@hypertext
\let\@@endlink\@@endlink@hypertext
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\href}
% \changes{4.1p}{2010/02/24}{(AO, 582) A patch of \classname{hyperref.sty} to provide backward compatibility to \TeX Live 2007's version 6.75r}%
% The \cmd\href\ command of \classname{hyperref} was extend somewhere
% between versions 6.75r and 6.80e. We apply a repair to the earlier
% version (if present) so that it works like the later version.
%
% The issue is the presence of whitespace, either following the \cmd\href\ token
% or following the first argument's closing brace character.
%
% \begin{macrocode}
\def\href@Hy{\hyper@normalise \href@ }%
\def\href@Hy@ltx{\@ifnextchar\bgroup\Hy@href{\hyper@normalise\href@}}%
\def\Hy@href#{\hyper@normalise\href@}%
\begingroup
\endlinechar=-1 %
\catcode`\^^A=14 %
\catcode`\^^M\active
\catcode`\%\active
\catcode`\#\active
\catcode`\_\active
\catcode`\$\active
\catcode`\&\active
\gdef\hyper@normalise@ltx{^^A
\begingroup
\catcode`\^^M\active
\def^^M{ }^^A
\catcode`\%\active
\let%\@percentchar
\let\%\@percentchar
\catcode`\#\active
\def#{\hyper@hash}^^A
\def\#{\hyper@hash}^^A
\@makeother\&^^A
\edef&{\string&}^^A
\edef\&{\string&}^^A
\edef\textunderscore{\string_}^^A
\let\_\textunderscore
\catcode`\_\active
\let_\textunderscore
\let~\hyper@tilde
\let\~\hyper@tilde
\let\textasciitilde\hyper@tilde
\let\\\@backslashchar
\edef${\string$}^^A
\Hy@safe@activestrue
\hyper@n@rmalise
}^^A
\catcode`\#=6 ^^A
\gdef\Hy@ActiveCarriageReturn@ltx{^^M}^^A
\gdef\hyper@n@rmalise@ltx#1#2{^^A
\def\Hy@tempa{#2}^^A
\ifx\Hy@tempa\Hy@ActiveCarriageReturn
\Hy@ReturnAfterElseFi{^^A
\hyper@@normalise{#1}^^A
}^^A
\else
\Hy@ReturnAfterFi{^^A
\hyper@@normalise{#1}{#2}^^A
}^^A
\fi
}^^A
\gdef\hyper@@normalise@ltx#1#2{^^A
\edef\Hy@tempa{^^A
\endgroup
\noexpand#1{\Hy@RemovePercentCr#2%^^M\@nil}^^A
}^^A
\Hy@tempa
}^^A
\gdef\Hy@RemovePercentCr@ltx#1%^^M#2\@nil{^^A
#1^^A
\ifx\limits#2\limits
\else
\Hy@ReturnAfterFi{^^A
\Hy@RemovePercentCr #2\@nil
}^^A
\fi
}^^A
\endgroup
\def\switch@hyperref@href{%
\expandafter\@ifx\expandafter{\csname href \endcsname\href@Hy}{
\class@info{Repairing hyperref 6.75r \string\href}%
\let\hyper@normalise\hyper@normalise@ltx
\let\hyper@@normalise\hyper@@normalise@ltx
\let\hyper@n@rmalise\hyper@n@rmalise@ltx
\let\Hy@ActiveCarriageReturn\Hy@ActiveCarriageReturn@ltx
\let\Hy@RemovePercentCr\Hy@RemovePercentCr@ltx
\let\href\href@Hy@ltx
}{}%
}%
\appdef\document@inithook{\switch@hyperref@href}%
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\typeout}
% We make the \cmd\typeout\ procedure of \LaTeX\ be \cmd\long,
% because sometimes we are talking about \cmd\par.
% \begin{macrocode}
\def\typeout@org#1{%
\begingroup
\set@display@protect
\immediate\write\@unused{#1}%
\endgroup
}%
\long\def\typeout@ltx#1{%
\begingroup
\set@display@protect
\immediate\write\@unused{#1}%
\endgroup
}%
\@ifx{\typeout\typeout@org}{%
\class@info{Making \string\typeout\space \string\long}%
\let\typeout\typeout@ltx
}{}%
% \end{macrocode}
% \end{macro}
%
% \subsection{End of the \file{kernel} {\sc docstrip} module}
% Here ends the module.
% \begin{macrocode}
%</kernel>
% \end{macrocode}
%
% \Finale
% \iffalse Here ends the programmer's documentation.\fi
% \endinput
%
\endinput
%%EOF
|