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
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
26580
26581
26582
26583
26584
26585
26586
26587
26588
26589
26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
26611
26612
26613
26614
26615
26616
26617
26618
26619
26620
26621
26622
26623
26624
26625
26626
26627
26628
26629
26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
26640
26641
26642
26643
26644
26645
26646
26647
26648
26649
26650
26651
26652
26653
26654
26655
26656
26657
26658
26659
26660
26661
26662
26663
26664
26665
26666
26667
26668
26669
26670
26671
26672
26673
26674
26675
26676
26677
26678
26679
26680
26681
26682
26683
26684
26685
26686
26687
26688
26689
26690
26691
26692
26693
26694
26695
26696
26697
26698
26699
26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
26717
26718
26719
26720
26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
26754
26755
26756
26757
26758
26759
26760
26761
26762
26763
26764
26765
26766
26767
26768
26769
26770
26771
26772
26773
26774
26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
26785
26786
26787
26788
26789
26790
26791
26792
26793
26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
26804
26805
26806
26807
26808
26809
26810
26811
26812
26813
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
26824
26825
26826
26827
26828
26829
26830
26831
26832
26833
26834
26835
26836
26837
26838
26839
26840
26841
26842
26843
26844
26845
26846
26847
26848
26849
26850
26851
26852
26853
26854
26855
26856
26857
26858
26859
26860
26861
26862
26863
26864
26865
26866
26867
26868
26869
26870
26871
26872
26873
26874
26875
26876
26877
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
26897
26898
26899
26900
26901
26902
26903
26904
26905
26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
26918
26919
26920
26921
26922
26923
26924
26925
26926
26927
26928
26929
26930
26931
26932
26933
26934
26935
26936
26937
26938
26939
26940
26941
26942
26943
26944
26945
26946
26947
26948
26949
26950
26951
26952
26953
26954
26955
26956
26957
26958
26959
26960
26961
26962
26963
26964
26965
26966
26967
26968
26969
26970
26971
26972
26973
26974
26975
26976
26977
26978
26979
26980
26981
26982
26983
26984
26985
26986
26987
26988
26989
26990
26991
26992
26993
26994
26995
26996
26997
26998
26999
27000
27001
27002
27003
27004
27005
27006
27007
27008
27009
27010
27011
27012
27013
27014
27015
27016
27017
27018
27019
27020
27021
27022
27023
27024
27025
27026
27027
27028
27029
27030
27031
27032
27033
27034
27035
27036
27037
27038
27039
27040
27041
27042
27043
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065
27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082
27083
27084
27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105
27106
27107
27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
27166
27167
27168
27169
27170
27171
27172
27173
27174
27175
27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221
27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262
27263
27264
27265
27266
27267
27268
27269
27270
27271
27272
27273
27274
27275
27276
27277
27278
27279
27280
27281
27282
27283
27284
27285
27286
27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300
27301
27302
27303
27304
27305
27306
27307
27308
27309
27310
27311
27312
27313
27314
27315
27316
27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
27329
27330
27331
27332
27333
27334
27335
27336
27337
27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
27365
27366
27367
27368
27369
27370
27371
27372
27373
27374
27375
27376
27377
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399
27400
27401
27402
27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421
27422
27423
27424
27425
27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538
27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614
27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628
27629
27630
27631
27632
27633
27634
27635
27636
27637
27638
27639
27640
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672
27673
27674
27675
27676
27677
27678
27679
27680
27681
27682
27683
27684
27685
27686
27687
27688
27689
27690
27691
27692
27693
27694
27695
27696
27697
27698
27699
27700
27701
27702
27703
27704
27705
27706
27707
27708
27709
27710
27711
27712
27713
27714
27715
27716
27717
27718
27719
27720
27721
27722
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732
27733
27734
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751
27752
27753
27754
27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857
27858
27859
27860
27861
27862
27863
27864
27865
27866
27867
27868
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879
27880
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897
27898
27899
27900
27901
27902
27903
27904
27905
27906
27907
27908
27909
27910
27911
27912
27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925
27926
27927
27928
27929
27930
27931
27932
27933
27934
27935
27936
27937
27938
27939
27940
27941
27942
27943
27944
27945
27946
27947
27948
27949
27950
27951
27952
27953
27954
27955
27956
27957
27958
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968
27969
27970
27971
27972
27973
27974
27975
27976
27977
27978
27979
27980
27981
27982
27983
27984
27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
27998
27999
28000
28001
28002
28003
28004
28005
28006
28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
28020
28021
28022
28023
28024
28025
28026
28027
28028
28029
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046
28047
28048
28049
28050
28051
28052
28053
28054
28055
28056
28057
28058
28059
28060
28061
28062
28063
28064
28065
28066
28067
28068
28069
28070
28071
28072
28073
28074
28075
28076
28077
28078
28079
28080
28081
28082
28083
28084
28085
28086
28087
28088
28089
28090
28091
28092
28093
28094
28095
28096
28097
28098
28099
28100
28101
28102
28103
28104
28105
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115
28116
28117
28118
28119
28120
28121
28122
28123
28124
28125
28126
28127
28128
28129
28130
28131
28132
28133
28134
28135
28136
28137
28138
28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
28150
28151
28152
28153
28154
28155
28156
28157
28158
28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
28170
28171
28172
28173
28174
28175
28176
28177
28178
28179
28180
28181
28182
28183
28184
28185
28186
28187
28188
28189
28190
28191
28192
28193
28194
28195
28196
28197
28198
28199
28200
28201
28202
28203
28204
28205
28206
28207
28208
28209
28210
28211
28212
28213
28214
28215
28216
28217
28218
28219
28220
28221
28222
28223
28224
28225
28226
28227
28228
28229
28230
28231
28232
28233
28234
28235
28236
28237
28238
28239
28240
28241
28242
28243
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264
28265
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
28281
28282
28283
28284
28285
28286
28287
28288
28289
28290
28291
28292
28293
28294
28295
28296
28297
28298
28299
28300
28301
28302
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
28318
28319
28320
28321
28322
28323
28324
28325
28326
28327
28328
28329
28330
28331
28332
28333
28334
28335
28336
28337
28338
28339
28340
28341
28342
28343
28344
28345
28346
28347
28348
28349
28350
28351
28352
28353
28354
28355
28356
28357
28358
28359
28360
28361
28362
28363
28364
28365
28366
28367
28368
28369
28370
28371
28372
28373
28374
28375
28376
28377
28378
28379
28380
28381
28382
28383
28384
28385
28386
28387
28388
28389
28390
28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409
28410
28411
28412
28413
28414
28415
28416
28417
28418
28419
28420
28421
28422
28423
28424
28425
28426
28427
28428
28429
28430
28431
28432
28433
28434
28435
28436
28437
28438
28439
28440
28441
28442
28443
28444
28445
28446
28447
28448
28449
28450
28451
28452
28453
28454
28455
28456
28457
28458
28459
28460
28461
28462
28463
28464
28465
28466
28467
28468
28469
28470
28471
28472
28473
28474
28475
28476
28477
28478
28479
28480
28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
28498
28499
28500
28501
28502
28503
28504
28505
28506
28507
28508
28509
28510
28511
28512
28513
28514
28515
28516
28517
28518
28519
28520
28521
28522
28523
28524
28525
28526
28527
28528
28529
28530
28531
28532
28533
28534
28535
28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
28549
28550
28551
28552
28553
28554
28555
28556
28557
28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
28571
28572
28573
28574
28575
28576
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612
28613
28614
28615
28616
28617
28618
28619
28620
28621
28622
28623
28624
28625
28626
28627
28628
28629
28630
28631
28632
28633
28634
28635
28636
28637
28638
28639
28640
28641
28642
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652
28653
28654
28655
28656
28657
28658
28659
28660
28661
28662
28663
28664
28665
28666
28667
28668
28669
28670
28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
28681
28682
28683
28684
28685
28686
28687
28688
28689
28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
28700
28701
28702
28703
28704
28705
28706
28707
28708
28709
28710
28711
28712
28713
28714
28715
28716
28717
28718
28719
28720
28721
28722
28723
28724
28725
28726
28727
28728
28729
28730
28731
28732
28733
28734
28735
28736
28737
28738
28739
28740
28741
28742
28743
28744
28745
28746
28747
28748
28749
28750
28751
28752
28753
28754
28755
28756
28757
28758
28759
28760
28761
28762
28763
28764
28765
28766
28767
28768
28769
28770
28771
28772
28773
28774
28775
28776
28777
28778
28779
28780
28781
28782
28783
28784
28785
28786
28787
28788
28789
28790
28791
28792
28793
28794
28795
28796
28797
28798
28799
28800
28801
28802
28803
28804
28805
28806
28807
28808
28809
28810
28811
28812
28813
28814
28815
28816
28817
28818
28819
28820
28821
28822
28823
28824
28825
28826
28827
28828
28829
28830
28831
28832
28833
28834
28835
28836
28837
28838
28839
28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
28851
28852
28853
28854
28855
28856
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
28872
28873
28874
28875
28876
28877
28878
28879
28880
28881
28882
28883
28884
28885
28886
28887
28888
28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
28907
28908
28909
28910
28911
28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
28930
28931
28932
28933
28934
28935
28936
28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
28984
28985
28986
28987
28988
28989
28990
28991
28992
28993
28994
28995
28996
28997
28998
28999
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
29019
29020
29021
29022
29023
29024
29025
29026
29027
29028
29029
29030
29031
29032
29033
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044
29045
29046
29047
29048
29049
29050
29051
29052
29053
29054
29055
29056
29057
29058
29059
29060
29061
29062
29063
29064
29065
29066
29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
29095
29096
29097
29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
29121
29122
29123
29124
29125
29126
29127
29128
29129
29130
29131
29132
29133
29134
29135
29136
29137
29138
29139
29140
29141
29142
29143
29144
29145
29146
29147
29148
29149
29150
29151
29152
29153
29154
29155
29156
29157
29158
29159
29160
29161
29162
29163
29164
29165
29166
29167
29168
29169
29170
29171
29172
29173
29174
29175
29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
29196
29197
29198
29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
29218
29219
29220
29221
29222
29223
29224
29225
29226
29227
29228
29229
29230
29231
29232
29233
29234
29235
29236
29237
29238
29239
29240
29241
29242
29243
29244
29245
29246
29247
29248
29249
29250
29251
29252
29253
29254
29255
29256
29257
29258
29259
29260
29261
29262
29263
29264
29265
29266
29267
29268
29269
29270
29271
29272
29273
29274
29275
29276
29277
29278
29279
29280
29281
29282
29283
29284
29285
29286
29287
29288
29289
29290
29291
29292
29293
29294
29295
29296
29297
29298
29299
29300
29301
29302
29303
29304
29305
29306
29307
29308
29309
29310
29311
29312
29313
29314
29315
29316
29317
29318
29319
29320
29321
29322
29323
29324
29325
29326
29327
29328
29329
29330
29331
29332
29333
29334
29335
29336
29337
29338
29339
29340
29341
29342
29343
29344
29345
29346
29347
29348
29349
29350
29351
29352
29353
29354
29355
29356
29357
29358
29359
29360
29361
29362
29363
29364
29365
29366
29367
29368
29369
29370
29371
29372
29373
29374
29375
29376
29377
29378
29379
29380
29381
29382
29383
29384
29385
29386
29387
29388
29389
29390
29391
29392
29393
29394
29395
29396
29397
29398
29399
29400
29401
29402
29403
29404
29405
29406
29407
29408
29409
29410
29411
29412
29413
29414
29415
29416
29417
29418
29419
29420
29421
29422
29423
29424
29425
29426
29427
29428
29429
29430
29431
29432
29433
29434
29435
29436
29437
29438
29439
29440
29441
29442
29443
29444
29445
29446
29447
29448
29449
29450
29451
29452
29453
29454
29455
29456
29457
29458
29459
29460
29461
29462
29463
29464
29465
29466
29467
29468
29469
29470
29471
29472
29473
29474
29475
29476
29477
29478
29479
29480
29481
29482
29483
29484
29485
29486
29487
29488
29489
29490
29491
29492
29493
29494
29495
29496
29497
29498
29499
29500
29501
29502
29503
29504
29505
29506
29507
29508
29509
29510
29511
29512
29513
29514
29515
29516
29517
29518
29519
29520
29521
29522
29523
29524
29525
29526
29527
29528
29529
29530
29531
29532
29533
29534
29535
29536
29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
29547
29548
29549
29550
29551
29552
29553
29554
29555
29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
29566
29567
29568
29569
29570
29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
29587
29588
29589
29590
29591
29592
29593
29594
29595
29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
29612
29613
29614
29615
29616
29617
29618
29619
29620
29621
29622
29623
29624
29625
29626
29627
29628
29629
29630
29631
29632
29633
29634
29635
29636
29637
29638
29639
29640
29641
29642
29643
29644
29645
29646
29647
29648
29649
29650
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
29666
29667
29668
29669
29670
29671
29672
29673
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683
29684
29685
29686
29687
29688
29689
29690
29691
29692
29693
29694
29695
29696
29697
29698
29699
29700
29701
29702
29703
29704
29705
29706
29707
29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
29728
29729
29730
29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
29750
29751
29752
29753
29754
29755
29756
29757
29758
29759
29760
29761
29762
29763
29764
29765
29766
29767
29768
29769
29770
29771
29772
29773
29774
29775
29776
29777
29778
29779
29780
29781
29782
29783
29784
29785
29786
29787
29788
29789
29790
29791
29792
29793
29794
29795
29796
29797
29798
29799
29800
29801
29802
29803
29804
29805
29806
29807
29808
29809
29810
29811
29812
29813
29814
29815
29816
29817
29818
29819
29820
29821
29822
29823
29824
29825
29826
29827
29828
29829
29830
29831
29832
29833
29834
29835
29836
29837
29838
29839
29840
29841
29842
29843
29844
29845
29846
29847
29848
29849
29850
29851
29852
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
29868
29869
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880
29881
29882
29883
29884
29885
29886
29887
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
29903
29904
29905
29906
29907
29908
29909
29910
29911
29912
29913
29914
29915
29916
29917
29918
29919
29920
29921
29922
29923
29924
29925
29926
29927
29928
29929
29930
29931
29932
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
29953
29954
29955
29956
29957
29958
29959
29960
29961
29962
29963
29964
29965
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982
29983
29984
29985
29986
29987
29988
29989
29990
29991
29992
29993
29994
29995
29996
29997
29998
29999
30000
30001
30002
30003
30004
30005
30006
30007
30008
30009
30010
30011
30012
30013
30014
30015
30016
30017
30018
30019
30020
30021
30022
30023
30024
30025
30026
30027
30028
30029
30030
30031
30032
30033
30034
30035
30036
30037
30038
30039
30040
30041
30042
30043
30044
30045
30046
30047
30048
30049
30050
30051
30052
30053
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077
30078
30079
30080
30081
30082
30083
30084
30085
30086
30087
30088
30089
30090
30091
30092
30093
30094
30095
30096
30097
30098
30099
30100
30101
30102
30103
30104
30105
30106
30107
30108
30109
30110
30111
30112
30113
30114
30115
30116
30117
30118
30119
30120
30121
30122
30123
30124
30125
30126
30127
30128
30129
30130
30131
30132
30133
30134
30135
30136
30137
30138
30139
30140
30141
30142
30143
30144
30145
30146
30147
30148
30149
30150
30151
30152
30153
30154
30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
30166
30167
30168
30169
30170
30171
30172
30173
30174
30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
30186
30187
30188
30189
30190
30191
30192
30193
30194
30195
30196
30197
30198
30199
30200
30201
30202
30203
30204
30205
30206
30207
30208
30209
30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
30223
30224
30225
30226
30227
30228
30229
30230
30231
30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
30245
30246
30247
30248
30249
30250
30251
30252
30253
30254
30255
30256
30257
30258
30259
30260
30261
30262
30263
30264
30265
30266
30267
30268
30269
30270
30271
30272
30273
30274
30275
30276
30277
30278
30279
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289
30290
30291
30292
30293
30294
30295
30296
30297
30298
30299
30300
30301
30302
30303
30304
30305
30306
30307
30308
30309
30310
30311
30312
30313
30314
30315
30316
30317
30318
30319
30320
30321
30322
30323
30324
30325
30326
30327
30328
30329
30330
30331
30332
30333
30334
30335
30336
30337
30338
30339
30340
30341
30342
30343
30344
30345
30346
30347
30348
30349
30350
30351
30352
30353
30354
30355
30356
30357
30358
30359
30360
30361
30362
30363
30364
30365
30366
30367
30368
30369
30370
30371
30372
30373
30374
30375
30376
30377
30378
30379
30380
30381
30382
30383
30384
30385
30386
30387
30388
30389
30390
30391
30392
30393
30394
30395
30396
30397
30398
30399
30400
30401
30402
30403
30404
30405
30406
30407
30408
30409
30410
30411
30412
30413
30414
30415
30416
30417
30418
30419
30420
30421
30422
30423
30424
30425
30426
30427
30428
30429
30430
30431
30432
30433
30434
30435
30436
30437
30438
30439
30440
30441
30442
30443
30444
30445
30446
30447
30448
30449
30450
30451
30452
30453
30454
30455
30456
30457
30458
30459
30460
30461
30462
30463
30464
30465
30466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
30479
30480
30481
30482
30483
30484
30485
30486
30487
30488
30489
30490
30491
30492
30493
30494
30495
30496
30497
30498
30499
30500
30501
30502
30503
30504
30505
30506
30507
30508
30509
30510
30511
30512
30513
30514
30515
30516
30517
30518
30519
30520
30521
30522
30523
30524
30525
30526
30527
30528
30529
30530
30531
30532
30533
30534
30535
30536
30537
30538
30539
30540
30541
30542
30543
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553
30554
30555
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571
30572
30573
30574
30575
30576
30577
30578
30579
30580
30581
30582
30583
30584
30585
30586
30587
30588
30589
30590
30591
30592
30593
30594
30595
30596
30597
30598
30599
30600
30601
30602
30603
30604
30605
30606
30607
30608
30609
30610
30611
30612
30613
30614
30615
30616
30617
30618
30619
30620
30621
30622
30623
30624
30625
30626
30627
30628
30629
30630
30631
30632
30633
30634
30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
30645
30646
30647
30648
30649
30650
30651
30652
30653
30654
30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
30666
30667
30668
30669
30670
30671
30672
30673
30674
30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
30686
30687
30688
30689
30690
30691
30692
30693
30694
30695
30696
30697
30698
30699
30700
30701
30702
30703
30704
30705
30706
30707
30708
30709
30710
30711
30712
30713
30714
30715
30716
30717
30718
30719
30720
30721
30722
30723
30724
30725
30726
30727
30728
30729
30730
30731
30732
30733
30734
30735
30736
30737
30738
30739
30740
30741
30742
30743
30744
30745
30746
30747
30748
30749
30750
30751
30752
30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
30780
30781
30782
30783
30784
30785
30786
30787
30788
30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
30805
30806
30807
30808
30809
30810
30811
30812
30813
30814
30815
30816
30817
30818
30819
30820
30821
30822
30823
30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
30839
30840
30841
30842
30843
30844
30845
30846
30847
30848
30849
30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
30880
30881
30882
30883
30884
30885
30886
30887
30888
30889
30890
30891
30892
30893
30894
30895
30896
30897
30898
30899
30900
30901
30902
30903
30904
30905
30906
30907
30908
30909
30910
30911
30912
30913
30914
30915
30916
30917
30918
30919
30920
30921
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931
30932
30933
30934
30935
30936
30937
30938
30939
30940
30941
30942
30943
30944
30945
30946
30947
30948
30949
30950
30951
30952
30953
30954
30955
30956
30957
30958
30959
30960
30961
30962
30963
30964
30965
30966
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976
30977
30978
30979
30980
30981
30982
30983
30984
30985
30986
30987
30988
30989
30990
30991
30992
30993
30994
30995
30996
30997
30998
30999
31000
31001
31002
31003
31004
31005
31006
31007
31008
31009
31010
31011
31012
31013
31014
31015
31016
31017
31018
31019
31020
31021
31022
31023
31024
31025
31026
31027
31028
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038
31039
31040
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054
31055
31056
31057
31058
31059
31060
31061
31062
31063
31064
31065
31066
31067
31068
31069
31070
31071
31072
31073
31074
31075
31076
31077
31078
31079
31080
31081
31082
31083
31084
31085
31086
31087
31088
31089
31090
31091
31092
31093
31094
31095
31096
31097
31098
31099
31100
31101
31102
31103
31104
31105
31106
31107
31108
31109
31110
31111
31112
31113
31114
31115
31116
31117
31118
31119
31120
31121
31122
31123
31124
31125
31126
31127
31128
31129
31130
31131
31132
31133
31134
31135
31136
31137
31138
31139
31140
31141
31142
31143
31144
31145
31146
31147
31148
31149
31150
31151
31152
31153
31154
31155
31156
31157
31158
31159
31160
31161
31162
31163
31164
31165
31166
31167
31168
31169
31170
31171
31172
31173
31174
31175
31176
31177
31178
31179
31180
31181
31182
31183
31184
31185
31186
31187
31188
31189
31190
31191
31192
31193
31194
31195
31196
31197
31198
31199
31200
31201
31202
31203
31204
31205
31206
31207
31208
31209
31210
31211
31212
31213
31214
31215
31216
31217
31218
31219
31220
31221
31222
31223
31224
31225
31226
31227
31228
31229
31230
31231
31232
31233
31234
31235
31236
31237
31238
31239
31240
31241
31242
31243
31244
31245
31246
31247
31248
31249
31250
31251
31252
31253
31254
31255
31256
31257
31258
31259
31260
31261
31262
31263
31264
31265
31266
31267
31268
31269
31270
31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
31426
31427
31428
31429
31430
31431
31432
31433
31434
31435
31436
31437
31438
31439
31440
31441
31442
31443
31444
31445
31446
31447
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462
31463
31464
31465
31466
31467
31468
31469
31470
31471
31472
31473
31474
31475
31476
31477
31478
31479
31480
31481
31482
31483
31484
31485
31486
31487
31488
31489
31490
31491
31492
31493
31494
31495
31496
31497
31498
31499
31500
31501
31502
31503
31504
31505
31506
31507
31508
31509
31510
31511
31512
31513
31514
31515
31516
31517
31518
31519
31520
31521
31522
31523
31524
31525
31526
31527
31528
31529
31530
31531
31532
31533
31534
31535
31536
31537
31538
31539
31540
31541
31542
31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825
31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
31867
31868
31869
31870
31871
31872
31873
31874
31875
31876
31877
31878
31879
31880
31881
31882
31883
31884
31885
31886
31887
31888
31889
31890
31891
31892
31893
31894
31895
31896
31897
31898
31899
31900
31901
31902
31903
31904
31905
31906
31907
31908
31909
31910
31911
31912
31913
31914
31915
31916
31917
31918
31919
31920
31921
31922
31923
31924
31925
31926
31927
31928
31929
31930
31931
31932
31933
31934
31935
31936
31937
31938
31939
31940
31941
31942
31943
31944
31945
31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
32004
32005
32006
32007
32008
32009
32010
32011
32012
32013
32014
32015
32016
32017
32018
32019
32020
32021
32022
32023
32024
32025
32026
32027
32028
32029
32030
32031
32032
32033
32034
32035
32036
32037
32038
32039
32040
32041
32042
32043
32044
32045
32046
32047
32048
32049
32050
32051
32052
32053
32054
32055
32056
32057
32058
32059
32060
32061
32062
32063
32064
32065
32066
32067
32068
32069
32070
32071
32072
32073
32074
32075
32076
32077
32078
32079
32080
32081
32082
32083
32084
32085
32086
32087
32088
32089
32090
32091
32092
32093
32094
32095
32096
32097
32098
32099
32100
32101
32102
32103
32104
32105
32106
32107
32108
32109
32110
32111
32112
32113
32114
32115
32116
32117
32118
32119
32120
32121
32122
32123
32124
32125
32126
32127
32128
32129
32130
32131
32132
32133
32134
32135
32136
32137
32138
32139
32140
32141
32142
32143
32144
32145
32146
32147
32148
32149
32150
32151
32152
32153
32154
32155
32156
32157
32158
32159
32160
32161
32162
32163
32164
32165
32166
32167
32168
32169
32170
32171
32172
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
32296
32297
32298
32299
32300
32301
32302
32303
32304
32305
32306
32307
32308
32309
32310
32311
32312
32313
32314
32315
32316
32317
32318
32319
32320
32321
32322
32323
32324
32325
32326
32327
32328
32329
32330
32331
32332
32333
32334
32335
32336
32337
32338
32339
32340
32341
32342
32343
32344
32345
32346
32347
32348
32349
32350
32351
32352
32353
32354
32355
32356
32357
32358
32359
32360
32361
32362
32363
32364
32365
32366
32367
32368
32369
32370
32371
32372
32373
32374
32375
32376
32377
32378
32379
32380
32381
32382
32383
32384
32385
32386
32387
32388
32389
32390
32391
32392
32393
32394
32395
32396
32397
32398
32399
32400
32401
32402
32403
32404
32405
32406
32407
32408
32409
32410
32411
32412
32413
32414
32415
32416
32417
32418
32419
32420
32421
32422
32423
32424
32425
32426
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
32447
32448
32449
32450
32451
32452
32453
32454
32455
32456
32457
32458
32459
32460
32461
32462
32463
32464
32465
32466
32467
32468
32469
32470
32471
32472
32473
32474
32475
32476
32477
32478
32479
32480
32481
32482
32483
32484
32485
32486
32487
32488
32489
32490
32491
32492
32493
32494
32495
32496
32497
32498
32499
32500
32501
32502
32503
32504
32505
32506
32507
32508
32509
32510
32511
32512
32513
32514
32515
32516
32517
32518
32519
32520
32521
32522
32523
32524
32525
32526
32527
32528
32529
32530
32531
32532
32533
32534
32535
32536
32537
32538
32539
32540
32541
32542
32543
32544
32545
32546
32547
32548
32549
32550
32551
32552
32553
32554
32555
32556
32557
32558
32559
32560
32561
32562
32563
32564
32565
32566
32567
32568
32569
32570
32571
32572
32573
32574
32575
32576
32577
32578
32579
32580
32581
32582
32583
32584
32585
32586
32587
32588
32589
32590
32591
32592
32593
32594
32595
32596
32597
32598
32599
32600
32601
32602
32603
32604
32605
32606
32607
32608
32609
32610
32611
32612
32613
32614
32615
32616
32617
32618
32619
32620
32621
32622
32623
32624
32625
32626
32627
32628
32629
32630
32631
32632
32633
32634
32635
32636
32637
32638
32639
32640
32641
32642
32643
32644
32645
32646
32647
32648
32649
32650
32651
32652
32653
32654
32655
32656
32657
32658
32659
32660
32661
32662
32663
32664
32665
32666
32667
32668
32669
32670
32671
32672
32673
32674
32675
32676
32677
32678
32679
32680
32681
32682
32683
32684
32685
32686
32687
32688
32689
32690
32691
32692
32693
32694
32695
32696
32697
32698
32699
32700
32701
32702
32703
32704
32705
32706
32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
32721
32722
32723
32724
32725
32726
32727
32728
32729
32730
32731
32732
32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
32758
32759
32760
32761
32762
32763
32764
32765
32766
32767
32768
32769
32770
32771
32772
32773
32774
32775
32776
32777
32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791
32792
32793
32794
32795
32796
32797
32798
32799
32800
32801
32802
32803
32804
32805
32806
32807
32808
32809
32810
32811
32812
32813
32814
32815
32816
32817
32818
32819
32820
32821
32822
32823
32824
32825
32826
32827
32828
32829
32830
32831
32832
32833
32834
32835
32836
32837
32838
32839
32840
32841
32842
32843
32844
32845
32846
32847
32848
32849
32850
32851
32852
32853
32854
32855
32856
32857
32858
32859
32860
32861
32862
32863
32864
32865
32866
32867
32868
32869
32870
32871
32872
32873
32874
32875
32876
32877
32878
32879
32880
32881
32882
32883
32884
32885
32886
32887
32888
32889
32890
32891
32892
32893
32894
32895
32896
32897
32898
32899
32900
32901
32902
32903
32904
32905
32906
32907
32908
32909
32910
32911
32912
32913
32914
32915
32916
32917
32918
32919
32920
32921
32922
32923
32924
32925
32926
32927
32928
32929
32930
32931
32932
32933
32934
32935
32936
32937
32938
32939
32940
32941
32942
32943
32944
32945
32946
32947
32948
32949
32950
32951
32952
32953
32954
32955
32956
32957
32958
32959
32960
32961
32962
32963
32964
32965
32966
32967
32968
32969
32970
32971
32972
32973
32974
32975
32976
32977
32978
32979
32980
32981
32982
32983
32984
32985
32986
32987
32988
32989
32990
32991
32992
32993
32994
32995
32996
32997
32998
32999
33000
33001
33002
33003
33004
33005
33006
33007
33008
33009
33010
33011
33012
33013
33014
33015
33016
33017
33018
33019
33020
33021
33022
33023
33024
33025
33026
33027
33028
33029
33030
33031
33032
33033
33034
33035
33036
33037
33038
33039
33040
33041
33042
33043
33044
33045
33046
33047
33048
33049
33050
33051
33052
33053
33054
33055
33056
33057
33058
33059
33060
33061
33062
33063
33064
33065
33066
33067
33068
33069
33070
33071
33072
33073
33074
33075
33076
33077
33078
33079
33080
33081
33082
33083
33084
33085
33086
33087
33088
33089
33090
33091
33092
33093
33094
33095
33096
33097
33098
33099
33100
33101
33102
33103
33104
33105
33106
33107
33108
33109
33110
33111
33112
33113
33114
33115
33116
33117
33118
33119
33120
33121
33122
33123
33124
33125
33126
33127
33128
33129
33130
33131
33132
33133
33134
33135
33136
33137
33138
33139
33140
33141
33142
33143
33144
33145
33146
33147
33148
33149
33150
33151
33152
33153
33154
33155
33156
33157
33158
33159
33160
33161
33162
33163
33164
33165
33166
33167
33168
33169
33170
33171
33172
33173
33174
33175
33176
33177
33178
33179
33180
33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222
33223
33224
33225
33226
33227
33228
33229
33230
33231
33232
33233
33234
33235
33236
33237
33238
33239
33240
33241
33242
33243
33244
33245
33246
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267
33268
33269
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
33280
33281
33282
33283
33284
33285
33286
33287
33288
33289
33290
33291
33292
33293
33294
33295
33296
33297
33298
33299
33300
33301
33302
33303
33304
33305
33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
33320
33321
33322
33323
33324
33325
33326
33327
33328
33329
33330
33331
33332
33333
33334
33335
33336
33337
33338
33339
33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
33351
33352
33353
33354
33355
33356
33357
33358
33359
33360
33361
33362
33363
33364
33365
33366
33367
33368
33369
33370
33371
33372
33373
33374
33375
33376
33377
33378
33379
33380
33381
33382
33383
33384
33385
33386
33387
33388
33389
33390
33391
33392
33393
33394
33395
33396
33397
33398
33399
33400
33401
33402
33403
33404
33405
33406
33407
33408
33409
33410
33411
33412
33413
33414
33415
33416
33417
33418
33419
33420
33421
33422
33423
33424
33425
33426
33427
33428
33429
33430
33431
33432
33433
33434
33435
33436
33437
33438
33439
33440
33441
33442
33443
33444
33445
33446
33447
33448
33449
33450
33451
33452
33453
33454
33455
33456
33457
33458
33459
33460
33461
33462
33463
33464
33465
33466
33467
33468
33469
33470
33471
33472
33473
33474
33475
33476
33477
33478
33479
33480
33481
33482
33483
33484
33485
33486
33487
33488
33489
33490
33491
33492
33493
33494
33495
33496
33497
33498
33499
33500
33501
33502
33503
33504
33505
33506
33507
33508
33509
33510
33511
33512
33513
33514
33515
33516
33517
33518
33519
33520
33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
33536
33537
33538
33539
33540
33541
33542
33543
33544
33545
33546
33547
33548
33549
33550
33551
33552
33553
33554
33555
33556
33557
33558
33559
33560
33561
33562
33563
33564
33565
33566
33567
33568
33569
33570
33571
33572
33573
33574
33575
33576
33577
33578
33579
33580
33581
33582
33583
33584
33585
33586
33587
33588
33589
33590
33591
33592
33593
33594
33595
33596
33597
33598
33599
33600
33601
33602
33603
33604
33605
33606
33607
33608
33609
33610
33611
33612
33613
33614
33615
33616
33617
33618
33619
33620
33621
33622
33623
33624
33625
33626
33627
33628
33629
33630
33631
33632
33633
33634
33635
33636
33637
33638
33639
33640
33641
33642
33643
33644
33645
33646
33647
33648
33649
33650
33651
33652
33653
33654
33655
33656
33657
33658
33659
33660
33661
33662
33663
33664
33665
33666
33667
33668
33669
33670
33671
33672
33673
33674
33675
33676
33677
33678
33679
33680
33681
33682
33683
33684
33685
33686
33687
33688
33689
33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
33704
33705
33706
33707
33708
33709
33710
33711
33712
33713
33714
33715
33716
33717
33718
33719
33720
33721
33722
33723
33724
33725
33726
33727
33728
33729
33730
33731
33732
33733
33734
33735
33736
33737
33738
33739
33740
33741
33742
33743
33744
33745
33746
33747
33748
33749
33750
33751
33752
33753
33754
33755
33756
33757
33758
33759
33760
33761
33762
33763
33764
33765
33766
33767
33768
33769
33770
33771
33772
33773
33774
33775
33776
33777
33778
33779
33780
33781
33782
33783
33784
33785
33786
33787
33788
33789
33790
33791
33792
33793
33794
33795
33796
33797
33798
33799
33800
33801
33802
33803
33804
33805
33806
33807
33808
33809
33810
33811
33812
33813
33814
33815
33816
33817
33818
33819
33820
33821
33822
33823
33824
33825
33826
33827
33828
33829
33830
33831
33832
33833
33834
33835
33836
33837
33838
33839
33840
33841
33842
33843
33844
33845
33846
33847
33848
33849
33850
33851
33852
33853
33854
33855
33856
33857
33858
33859
33860
33861
33862
33863
33864
33865
33866
33867
33868
33869
33870
33871
33872
33873
33874
33875
33876
33877
33878
33879
33880
33881
33882
33883
33884
33885
33886
33887
33888
33889
33890
33891
33892
33893
33894
33895
33896
33897
33898
33899
33900
33901
33902
33903
33904
33905
33906
33907
33908
33909
33910
33911
33912
33913
33914
33915
33916
33917
33918
33919
33920
33921
33922
33923
33924
33925
33926
33927
33928
33929
33930
33931
33932
33933
33934
33935
33936
33937
33938
33939
33940
33941
33942
33943
33944
33945
33946
33947
33948
33949
33950
33951
33952
33953
33954
33955
33956
33957
33958
33959
33960
33961
33962
33963
33964
33965
33966
33967
33968
33969
33970
33971
33972
33973
33974
33975
33976
33977
33978
33979
33980
33981
33982
33983
33984
33985
33986
33987
33988
33989
33990
33991
33992
33993
33994
33995
33996
33997
33998
33999
34000
34001
34002
34003
34004
34005
34006
34007
34008
34009
34010
34011
34012
34013
34014
34015
34016
34017
34018
34019
34020
34021
34022
34023
34024
34025
34026
34027
34028
34029
34030
34031
34032
34033
34034
34035
34036
34037
34038
34039
34040
34041
34042
34043
34044
34045
34046
34047
34048
34049
34050
34051
34052
34053
34054
34055
34056
34057
34058
34059
34060
34061
34062
34063
34064
34065
34066
34067
34068
34069
34070
34071
34072
34073
34074
34075
34076
34077
34078
34079
34080
34081
34082
34083
34084
34085
34086
34087
34088
34089
34090
34091
34092
34093
34094
34095
34096
34097
34098
34099
34100
34101
34102
34103
34104
34105
34106
34107
34108
34109
34110
34111
34112
34113
34114
34115
34116
34117
34118
34119
34120
34121
34122
34123
34124
34125
34126
34127
34128
34129
34130
34131
34132
34133
34134
34135
34136
34137
34138
34139
34140
34141
34142
34143
34144
34145
34146
34147
34148
34149
34150
34151
34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
34162
34163
34164
34165
34166
34167
34168
34169
34170
34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
34186
34187
34188
34189
34190
34191
34192
34193
34194
34195
34196
34197
34198
34199
34200
34201
34202
34203
34204
34205
34206
34207
34208
34209
34210
34211
34212
34213
34214
34215
34216
34217
34218
34219
34220
34221
34222
34223
34224
34225
34226
34227
34228
34229
34230
34231
34232
34233
34234
34235
34236
34237
34238
34239
34240
34241
34242
34243
34244
34245
34246
34247
34248
34249
34250
34251
34252
34253
34254
34255
34256
34257
34258
34259
34260
34261
34262
34263
34264
34265
34266
34267
34268
34269
34270
34271
34272
34273
34274
34275
34276
34277
34278
34279
34280
34281
34282
34283
34284
34285
34286
34287
34288
34289
34290
34291
34292
34293
34294
34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
34307
34308
34309
34310
34311
34312
34313
34314
34315
34316
34317
34318
34319
34320
34321
34322
34323
34324
34325
34326
34327
34328
34329
34330
34331
34332
34333
34334
34335
34336
34337
34338
34339
34340
34341
34342
34343
34344
34345
34346
34347
34348
34349
34350
34351
34352
34353
34354
34355
34356
34357
34358
34359
34360
34361
34362
34363
34364
34365
34366
34367
34368
34369
34370
34371
34372
34373
34374
34375
34376
34377
34378
34379
34380
34381
34382
34383
34384
34385
34386
34387
34388
34389
34390
34391
34392
34393
34394
34395
34396
34397
34398
34399
34400
34401
34402
34403
34404
34405
34406
34407
34408
34409
34410
34411
34412
34413
34414
34415
34416
34417
34418
34419
34420
34421
34422
34423
34424
34425
34426
34427
34428
34429
34430
34431
34432
34433
34434
34435
34436
34437
34438
34439
34440
34441
34442
34443
34444
34445
34446
34447
34448
34449
34450
34451
34452
34453
34454
34455
34456
34457
34458
34459
34460
34461
34462
34463
34464
34465
34466
34467
34468
34469
34470
34471
34472
34473
34474
34475
34476
34477
34478
34479
34480
34481
34482
34483
34484
34485
34486
34487
34488
34489
34490
34491
34492
34493
34494
34495
34496
34497
34498
34499
34500
34501
34502
34503
34504
34505
34506
34507
34508
34509
34510
34511
34512
34513
34514
34515
34516
34517
34518
34519
34520
34521
34522
34523
34524
34525
34526
34527
34528
34529
34530
34531
34532
34533
34534
34535
34536
34537
34538
34539
34540
34541
34542
34543
34544
34545
34546
34547
34548
34549
34550
34551
34552
34553
34554
34555
34556
34557
34558
34559
34560
34561
34562
34563
34564
34565
34566
34567
34568
34569
34570
34571
34572
34573
34574
34575
34576
34577
34578
34579
34580
34581
34582
34583
34584
34585
34586
34587
34588
34589
34590
34591
34592
34593
34594
34595
34596
34597
34598
34599
34600
34601
34602
34603
34604
34605
34606
34607
34608
34609
34610
34611
34612
34613
34614
34615
34616
34617
34618
34619
34620
34621
34622
34623
34624
34625
34626
34627
34628
34629
34630
34631
34632
34633
34634
34635
34636
34637
34638
34639
34640
34641
34642
34643
34644
34645
34646
34647
34648
34649
34650
34651
34652
34653
34654
34655
34656
34657
34658
34659
34660
34661
34662
34663
34664
34665
34666
34667
34668
34669
34670
34671
34672
34673
34674
34675
34676
34677
34678
34679
34680
34681
34682
34683
34684
34685
34686
34687
34688
34689
34690
34691
34692
34693
34694
34695
34696
34697
34698
34699
34700
34701
34702
34703
34704
34705
34706
34707
34708
34709
34710
34711
34712
34713
34714
34715
34716
34717
34718
34719
34720
34721
34722
34723
34724
34725
34726
34727
34728
34729
34730
34731
34732
34733
34734
34735
34736
34737
34738
34739
34740
34741
34742
34743
34744
34745
34746
34747
34748
34749
34750
34751
34752
34753
34754
34755
34756
34757
34758
34759
34760
34761
34762
34763
34764
34765
34766
34767
34768
34769
34770
34771
34772
34773
34774
34775
34776
34777
34778
34779
34780
34781
34782
34783
34784
34785
34786
34787
34788
34789
34790
34791
34792
34793
34794
34795
34796
34797
34798
34799
34800
34801
34802
34803
34804
34805
34806
34807
34808
34809
34810
34811
34812
34813
34814
34815
34816
34817
34818
34819
34820
34821
34822
34823
34824
34825
34826
34827
34828
34829
34830
34831
34832
34833
34834
34835
34836
34837
34838
34839
34840
34841
34842
34843
34844
34845
34846
34847
34848
34849
34850
34851
34852
34853
34854
34855
34856
34857
34858
34859
34860
34861
34862
34863
34864
34865
34866
34867
34868
34869
34870
34871
34872
34873
34874
34875
34876
34877
34878
34879
34880
34881
34882
34883
34884
34885
34886
34887
34888
34889
34890
34891
34892
34893
34894
34895
34896
34897
34898
34899
34900
34901
34902
34903
34904
34905
34906
34907
34908
34909
34910
34911
34912
34913
34914
34915
34916
34917
34918
34919
34920
34921
34922
34923
34924
34925
34926
34927
34928
34929
34930
34931
34932
34933
34934
34935
34936
34937
34938
34939
34940
34941
34942
34943
34944
34945
34946
34947
34948
34949
34950
34951
34952
34953
34954
34955
34956
34957
34958
34959
34960
34961
34962
34963
34964
34965
34966
34967
34968
34969
34970
34971
34972
34973
34974
34975
34976
34977
34978
34979
34980
34981
34982
34983
34984
34985
34986
34987
34988
34989
34990
34991
34992
34993
34994
34995
34996
34997
34998
34999
35000
35001
35002
35003
35004
35005
35006
35007
35008
35009
35010
35011
35012
35013
35014
35015
35016
35017
35018
35019
35020
35021
35022
35023
35024
35025
35026
35027
35028
35029
35030
35031
35032
35033
35034
35035
35036
35037
35038
35039
35040
35041
35042
35043
35044
35045
35046
35047
35048
35049
35050
35051
35052
35053
35054
35055
35056
35057
35058
35059
35060
35061
35062
35063
35064
35065
35066
35067
35068
35069
35070
35071
35072
35073
35074
35075
35076
35077
35078
35079
35080
35081
35082
35083
35084
35085
35086
35087
35088
35089
35090
35091
35092
35093
35094
35095
35096
35097
35098
35099
35100
35101
35102
35103
35104
35105
35106
35107
35108
35109
35110
35111
35112
35113
35114
35115
35116
35117
35118
35119
35120
35121
35122
35123
35124
35125
35126
35127
35128
35129
35130
35131
35132
35133
35134
35135
35136
35137
35138
35139
35140
35141
35142
35143
35144
35145
35146
35147
35148
35149
35150
35151
35152
35153
35154
35155
35156
35157
35158
35159
35160
35161
35162
35163
35164
35165
35166
35167
35168
35169
35170
35171
35172
35173
35174
35175
35176
35177
35178
35179
35180
35181
35182
35183
35184
35185
35186
35187
35188
35189
35190
35191
35192
35193
35194
35195
35196
35197
35198
35199
35200
35201
35202
35203
35204
35205
35206
35207
35208
35209
35210
35211
35212
35213
35214
35215
35216
35217
35218
35219
35220
35221
35222
35223
35224
35225
35226
35227
35228
35229
35230
35231
35232
35233
35234
35235
35236
35237
35238
35239
35240
35241
35242
35243
35244
35245
35246
35247
35248
35249
35250
35251
35252
35253
35254
35255
35256
35257
35258
35259
35260
35261
35262
35263
35264
35265
35266
35267
35268
35269
35270
35271
35272
35273
35274
35275
35276
35277
35278
35279
35280
35281
35282
35283
35284
35285
35286
35287
35288
35289
35290
35291
35292
35293
35294
35295
35296
35297
35298
35299
35300
35301
35302
35303
35304
35305
35306
35307
35308
35309
35310
35311
35312
35313
35314
35315
35316
35317
35318
35319
35320
35321
35322
35323
35324
35325
35326
35327
35328
35329
35330
35331
35332
35333
35334
35335
35336
35337
35338
35339
35340
35341
35342
35343
35344
35345
35346
35347
35348
35349
35350
35351
35352
35353
35354
35355
35356
35357
35358
35359
35360
35361
35362
35363
35364
35365
35366
35367
35368
35369
35370
35371
35372
35373
35374
35375
35376
35377
35378
35379
35380
35381
35382
35383
35384
35385
35386
35387
35388
35389
35390
35391
35392
35393
35394
35395
35396
35397
35398
35399
35400
35401
35402
35403
35404
35405
35406
35407
35408
35409
35410
35411
35412
35413
35414
35415
35416
35417
35418
35419
35420
35421
35422
35423
35424
35425
35426
35427
35428
35429
35430
35431
35432
35433
35434
35435
35436
35437
35438
35439
35440
35441
35442
35443
35444
35445
35446
35447
35448
35449
35450
35451
35452
35453
35454
35455
35456
35457
35458
35459
35460
35461
35462
35463
35464
35465
35466
35467
35468
35469
35470
35471
35472
35473
35474
35475
35476
35477
35478
35479
35480
35481
35482
35483
35484
35485
35486
35487
35488
35489
35490
35491
35492
35493
35494
35495
35496
35497
35498
35499
35500
35501
35502
35503
35504
35505
35506
35507
35508
35509
35510
35511
35512
35513
35514
35515
35516
35517
35518
35519
35520
35521
35522
35523
35524
35525
35526
35527
35528
35529
35530
35531
35532
35533
35534
35535
35536
35537
35538
35539
35540
35541
35542
35543
35544
35545
35546
35547
35548
35549
35550
35551
35552
35553
35554
35555
35556
35557
35558
35559
35560
35561
35562
35563
35564
35565
35566
35567
35568
35569
35570
35571
35572
35573
35574
35575
35576
35577
35578
35579
35580
35581
35582
35583
35584
35585
35586
35587
35588
35589
35590
35591
35592
35593
35594
35595
35596
35597
35598
35599
35600
35601
35602
35603
35604
35605
35606
35607
35608
35609
35610
35611
35612
35613
35614
35615
35616
35617
35618
35619
35620
35621
35622
35623
35624
35625
35626
35627
35628
35629
35630
35631
35632
35633
35634
35635
35636
35637
35638
35639
35640
35641
35642
35643
35644
35645
35646
35647
35648
35649
35650
35651
35652
35653
35654
35655
35656
35657
35658
35659
35660
35661
35662
35663
35664
35665
35666
35667
35668
35669
35670
35671
35672
35673
35674
35675
35676
35677
35678
35679
35680
35681
35682
35683
35684
35685
35686
35687
35688
35689
35690
35691
35692
35693
35694
35695
35696
35697
35698
35699
35700
35701
35702
35703
35704
35705
35706
35707
35708
35709
35710
35711
35712
35713
35714
35715
35716
35717
35718
35719
35720
35721
35722
35723
35724
35725
35726
35727
35728
35729
35730
35731
35732
35733
35734
35735
35736
35737
35738
35739
35740
35741
35742
35743
35744
35745
35746
35747
35748
35749
35750
35751
35752
35753
35754
35755
35756
35757
35758
35759
35760
35761
35762
35763
35764
35765
35766
35767
35768
35769
35770
35771
35772
35773
35774
35775
35776
35777
35778
35779
35780
35781
35782
35783
35784
35785
35786
35787
35788
35789
35790
35791
35792
35793
35794
35795
35796
35797
35798
35799
35800
35801
35802
35803
35804
35805
35806
35807
35808
35809
35810
35811
35812
35813
35814
35815
35816
35817
35818
35819
35820
35821
35822
35823
35824
35825
35826
35827
35828
35829
35830
35831
35832
35833
35834
35835
35836
35837
35838
35839
35840
35841
35842
35843
35844
35845
35846
35847
35848
35849
35850
35851
35852
35853
35854
35855
35856
35857
35858
35859
35860
35861
35862
35863
35864
35865
35866
35867
35868
35869
35870
35871
35872
35873
35874
35875
35876
35877
35878
35879
35880
35881
35882
35883
35884
35885
35886
35887
35888
35889
35890
35891
35892
35893
35894
35895
35896
35897
35898
35899
35900
35901
35902
35903
35904
35905
35906
35907
35908
35909
35910
35911
35912
35913
35914
35915
35916
35917
35918
35919
35920
35921
35922
35923
35924
35925
35926
35927
35928
35929
35930
35931
35932
35933
35934
35935
35936
35937
35938
35939
35940
35941
35942
35943
35944
35945
35946
35947
35948
35949
35950
35951
35952
35953
35954
35955
35956
35957
35958
35959
35960
35961
35962
35963
35964
35965
35966
35967
35968
35969
35970
35971
35972
35973
35974
35975
35976
35977
35978
35979
35980
35981
35982
35983
35984
35985
35986
35987
35988
35989
35990
35991
35992
35993
35994
35995
35996
35997
35998
35999
36000
36001
36002
36003
36004
36005
36006
36007
36008
36009
36010
36011
36012
36013
36014
36015
36016
36017
36018
36019
36020
36021
36022
36023
36024
36025
36026
36027
36028
36029
36030
36031
36032
36033
36034
36035
36036
36037
36038
36039
36040
36041
36042
36043
36044
36045
36046
36047
36048
36049
36050
36051
36052
36053
36054
36055
36056
36057
36058
36059
36060
36061
36062
36063
36064
36065
36066
36067
36068
36069
36070
36071
36072
36073
36074
36075
36076
36077
36078
36079
36080
36081
36082
36083
36084
36085
36086
36087
36088
36089
36090
36091
36092
36093
36094
36095
36096
36097
36098
36099
36100
36101
36102
36103
36104
36105
36106
36107
36108
36109
36110
36111
36112
36113
36114
36115
36116
36117
36118
36119
36120
36121
36122
36123
36124
36125
36126
36127
36128
36129
36130
36131
36132
36133
36134
36135
36136
36137
36138
36139
36140
36141
36142
36143
36144
36145
36146
36147
36148
36149
36150
36151
36152
36153
36154
36155
36156
36157
36158
36159
36160
36161
36162
36163
36164
36165
36166
36167
36168
36169
36170
36171
36172
36173
36174
36175
36176
36177
36178
36179
36180
36181
36182
36183
36184
36185
36186
36187
36188
36189
36190
36191
36192
36193
36194
36195
36196
36197
36198
36199
36200
36201
36202
36203
36204
36205
36206
36207
36208
36209
36210
36211
36212
36213
36214
36215
36216
36217
36218
36219
36220
36221
36222
36223
36224
36225
36226
36227
36228
36229
36230
36231
36232
36233
36234
36235
36236
36237
36238
36239
36240
36241
36242
36243
36244
36245
36246
36247
36248
36249
36250
36251
36252
36253
36254
36255
36256
36257
36258
36259
36260
36261
36262
36263
36264
36265
36266
36267
36268
36269
36270
36271
36272
36273
36274
36275
36276
36277
36278
36279
36280
36281
36282
36283
36284
36285
36286
36287
36288
36289
36290
36291
36292
36293
36294
36295
36296
36297
36298
36299
36300
36301
36302
36303
36304
36305
36306
36307
36308
36309
36310
36311
36312
36313
36314
36315
36316
36317
36318
36319
36320
36321
36322
36323
36324
36325
36326
36327
36328
36329
36330
36331
36332
36333
36334
36335
36336
36337
36338
36339
36340
36341
36342
36343
36344
36345
36346
36347
36348
36349
36350
36351
36352
36353
36354
36355
36356
36357
36358
36359
36360
36361
36362
36363
36364
36365
36366
36367
36368
36369
36370
36371
36372
36373
36374
36375
36376
36377
36378
36379
36380
36381
36382
36383
36384
36385
36386
36387
36388
36389
36390
36391
36392
36393
36394
36395
36396
36397
36398
36399
36400
36401
36402
36403
36404
36405
36406
36407
36408
36409
36410
36411
36412
36413
36414
36415
36416
36417
36418
36419
36420
36421
36422
36423
36424
36425
36426
36427
36428
36429
36430
36431
36432
36433
36434
36435
36436
36437
36438
36439
36440
36441
36442
36443
36444
36445
36446
36447
36448
36449
36450
36451
36452
36453
36454
36455
36456
36457
36458
36459
36460
36461
36462
36463
36464
36465
36466
36467
36468
36469
36470
36471
36472
36473
36474
36475
36476
36477
36478
36479
36480
36481
36482
36483
36484
36485
36486
36487
36488
36489
36490
36491
36492
36493
36494
36495
36496
36497
36498
36499
36500
36501
36502
36503
36504
36505
36506
36507
36508
36509
36510
36511
36512
36513
36514
36515
36516
36517
36518
36519
36520
36521
36522
36523
36524
36525
36526
36527
36528
36529
36530
36531
36532
36533
36534
36535
36536
36537
36538
36539
36540
36541
36542
36543
36544
36545
36546
36547
36548
36549
36550
36551
36552
36553
36554
36555
36556
36557
36558
36559
36560
36561
36562
36563
36564
36565
36566
36567
36568
36569
36570
36571
36572
36573
36574
36575
36576
36577
36578
36579
36580
36581
36582
36583
36584
36585
36586
36587
36588
36589
36590
36591
36592
36593
36594
36595
36596
36597
36598
36599
36600
36601
36602
36603
36604
36605
36606
36607
36608
36609
36610
36611
36612
36613
36614
36615
36616
36617
36618
36619
36620
36621
36622
36623
36624
36625
36626
36627
36628
36629
36630
36631
36632
36633
36634
36635
36636
36637
36638
36639
36640
36641
36642
36643
36644
36645
36646
36647
36648
36649
36650
36651
36652
36653
36654
36655
36656
36657
36658
36659
36660
36661
36662
36663
36664
36665
36666
36667
36668
36669
36670
36671
36672
36673
36674
36675
36676
36677
36678
36679
36680
36681
36682
36683
36684
36685
36686
36687
36688
36689
36690
36691
36692
36693
36694
36695
36696
36697
36698
36699
36700
36701
36702
36703
36704
36705
36706
36707
36708
36709
36710
36711
36712
36713
36714
36715
36716
36717
36718
36719
36720
36721
36722
36723
36724
36725
36726
36727
36728
36729
36730
36731
36732
36733
36734
36735
36736
36737
36738
36739
36740
36741
36742
36743
36744
36745
36746
36747
36748
36749
36750
36751
36752
36753
36754
36755
36756
36757
36758
36759
36760
36761
36762
36763
36764
36765
36766
36767
36768
36769
36770
36771
36772
36773
36774
36775
36776
36777
36778
36779
36780
36781
36782
36783
36784
36785
36786
36787
36788
36789
36790
36791
36792
36793
36794
36795
36796
36797
36798
36799
36800
36801
36802
36803
36804
36805
36806
36807
36808
36809
36810
36811
36812
36813
36814
36815
36816
36817
36818
36819
36820
36821
36822
36823
36824
36825
36826
36827
36828
36829
36830
36831
36832
36833
36834
36835
36836
36837
36838
36839
36840
36841
36842
36843
36844
36845
36846
36847
36848
36849
36850
36851
36852
36853
36854
36855
36856
36857
36858
36859
36860
36861
36862
36863
36864
36865
36866
36867
36868
36869
36870
36871
36872
36873
36874
36875
36876
36877
36878
36879
36880
36881
36882
36883
36884
36885
36886
36887
36888
36889
36890
36891
36892
36893
36894
36895
36896
36897
36898
36899
36900
36901
36902
36903
36904
36905
36906
36907
36908
36909
36910
36911
36912
36913
36914
36915
36916
36917
36918
36919
36920
36921
36922
36923
36924
36925
36926
36927
36928
36929
36930
36931
36932
36933
36934
36935
36936
36937
36938
36939
36940
36941
36942
36943
36944
36945
36946
36947
36948
36949
36950
36951
36952
36953
36954
36955
36956
36957
36958
36959
36960
36961
36962
36963
36964
36965
36966
36967
36968
36969
36970
36971
36972
36973
36974
36975
36976
36977
36978
36979
36980
36981
36982
36983
36984
36985
36986
36987
36988
36989
36990
36991
36992
36993
36994
36995
36996
36997
36998
36999
37000
37001
37002
37003
37004
37005
37006
37007
37008
37009
37010
37011
37012
37013
37014
37015
37016
37017
37018
37019
37020
37021
37022
37023
37024
37025
37026
37027
37028
37029
37030
37031
37032
37033
37034
37035
37036
37037
37038
37039
37040
37041
37042
37043
37044
37045
37046
37047
37048
37049
37050
37051
37052
37053
37054
37055
37056
37057
37058
37059
37060
37061
37062
37063
37064
37065
37066
37067
37068
37069
37070
37071
37072
37073
37074
37075
37076
37077
37078
37079
37080
37081
37082
37083
37084
37085
37086
37087
37088
37089
37090
37091
37092
37093
37094
37095
37096
37097
37098
37099
37100
37101
37102
37103
37104
37105
37106
37107
37108
37109
37110
37111
37112
37113
37114
37115
37116
37117
37118
37119
37120
37121
37122
37123
37124
37125
37126
37127
37128
37129
37130
37131
37132
37133
37134
37135
37136
37137
37138
37139
37140
37141
37142
37143
37144
37145
37146
37147
37148
37149
37150
37151
37152
37153
37154
37155
37156
37157
37158
37159
37160
37161
37162
37163
37164
37165
37166
37167
37168
37169
37170
37171
37172
37173
37174
37175
37176
37177
37178
37179
37180
37181
37182
37183
37184
37185
37186
37187
37188
37189
37190
37191
37192
37193
37194
37195
37196
37197
37198
37199
37200
37201
37202
37203
37204
37205
|
% \iffalse meta-comment
%
% memoir.dtx
% Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net
% Maintainer: Lars Madsen (daleif at math dot au dot dk)
% Copyright 2001--2010 Peter R. Wilson
% Copyright 2011-- Lars Madsen
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version.
% The latest version of the license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of
% LaTeX version 2008/05/04 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% This work consists of the files listed in the README file.
%
% \fi
% \CheckSum{31045}
%
% \changes{v0.1}{2001/05/20}{First public alpha release}
% \changes{v0.2}{2001/06/03}{First beta release}
% \changes{v0.3}{2001/07/09}{Bug fixing}
% \changes{v0.31}{2001/07/09}{Bug fixing}
% \changes{v0.32}{2001/08/03}{Fix for old versions of amsmath package}
% \changes{v0.33}{2001/08/03}{Added controllable chapter/LoF spacing}
% \changes{v0.33}{2001/08/03}{Fixed bug in \cs{appendixpage}}
% \changes{v1.0}{2001/10/30}{First production release}
% \changes{v1.0a}{2001/12/07}{Feature fixes} ^^A never released
% \changes{v1.1}{2002/03/10}{More fixups}
% \changes{v1.1}{2002/03/10}{Replaced all the subfigure code}
% \changes{v1.1}{2002/03/28}{Added sidebars}
% \changes{v1.1}{2002/03/28}{Upgraded verse typesetting}
% \changes{v1.2}{2002/07/07}{Added 17pt option}
% \changes{v1.2}{2002/07/07}{Added extra \cs{provide} commands}
% \changes{v1.2}{2002/07/27}{Major verbatim, box and file additions}
% \changes{v1.2}{2002/07/27}{Removed extraneous space from change marks}
% \changes{v1.2}{2002/07/27}{Extra optarg in \cs{chapter} and \cs{chapter*}}
% \changes{v1.2}{2002/07/27}{Twiddled font sizes a little}
% \changes{v1.2}{2002/08/27}{Fixed 12pt bug}
% \changes{v1.3}{2002/09/27}{Minor tweaks wrt v1.2}
% \changes{v1.3}{2002/10/10}{Extra trimming styles}
% \changes{v1.3}{2002/10/10}{Major extensions for indexing}
% \changes{v1.3}{2002/11/14}{Automatically call a patch file}
% \changes{v1.3a}{2002/11/22}{Fixed nasty figure/table bug}
% \changes{v1.4}{2003/02/27}{Added patches v1.1}
% \changes{v1.4}{2003/02/27}{Added patches v1.3}
% \changes{v1.4}{2003/11/16}{Including current patches}
% \changes{v1.4}{2003/11/16}{Added patches v1.2}
% \changes{v1.4}{2003/11/22}{Added patches v1.4}
% \changes{v1.4}{2003/11/22}{Added patches v1.5}
% \changes{v1.4}{2003/11/22}{Added patches v1.6}
% \changes{v1.4}{2003/11/22}{Added patches v1.7}
% \changes{v1.4}{2003/11/30}{Added patches v1.8}
% \changes{v1.4}{2003/11/30}{Added patches v1.9}
% \changes{v1.6}{2004/01/31}{Decided to issue v1.4 as v1.6 on the way to
% the golden section 1.6180339887...}
% \changes{v1.61}{2004/03/14}{Changes to clo files, and footnotes}
% \changes{v1.61}{2004/03/21}{Removed a potential problem with the
% hangul package}
% \changes{v1.618}{2005/09/02}{Folded in all v1.61 patches}
% \changes{v1.618}{2005/09/15}{Some minor extensions}
% \changes{v1.618}{2005/09/25}{Support for glossaries}
% \changes{v1.6180}{2006/06/12}{Footnote font fix}
% \changes{v1.61803}{2008/05/26}{Folded in all mempatch v4.9a patches}
% \changes{v1.618033}{2008/06/02}{Fixed(?) page layout algorithms}
% \changes{v1.6180339}{2008/07/23}{Unemulated if... packages}
% \changes{v1.6180339}{2008/07/23}{Folded in all mempatch v5.1 patches}
% \changes{v1.6180339a}{2008/08/07}{Removed extra space in footnotes}
% \changes{v1.6180339c}{2009/01/21}{Minor bug fixes and extensions}
% \changes{v1.6180339c}{2009/01/25}{A few more}
% \changes{v1.6180339d}{2009/02/04}{Fixed a bug in the running
% head/foot widths}
% \changes{v1.6180339f}{2009/03/16}{Start of `f' version.}
% \changes{v1.6180339f}{2009/03/16}{Fixed problem with companion pagestyle
% and added 2 col Toc}
% \changes{v1.6180339f}{2009/04/25}{Extended description lists}
% \changes{v1.6180339f}{2009/07/12}{Added three \cs{memlet...} macros}
% \changes{v1.6180339g}{2009/07/13}{Fixed a bug regading extre enties
% in the page note list}
% \changes{v1.61803398}{2009/07/17}{Added bidi (RTL) support}
% \changes{v1.61803398}{2009/07/27}{Fixed bug in \cs{@setclcnt}, added simple pagestyle}
% \changes{v1.61803398}{2009/08/08}{changed the code that defined the
% main function out of \cs{newlistof}}
% \changes{v1.61803398}{2009/09/10}{fixed bug with upquote}
% \changes{v1.61803398b}{2009/09/21}{fixed typo}
% \changes{v1.61803398c}{2009/11/13}{fixed typo}
% \changes{v1.61803398d}{2009/11/13}{fixed infelicity with \cs{@starttoc}}
% \changes{v1.61803398d}{2009/12/01}{fixed bug in ifxetex, ifpdf,...}
% \changes{v1.61803398d}{2009/12/18}{made \cs{subcaptionref} robust}
% \changes{v1.61803398d}{2010/xx/xx}{several changes}
% \changes{v1.618033988}{2010/02/16}{bumped version to v1.618033988}
% \changes{v1.618033988b}{2010/02/17}{fixed typo that broke \cs{feetbelowfloat}}
% \changes{v1.618033988c}{2010/02/20}{fixed sporadic space in \cs{@footnotetext}}
% \changes{v1.618033988d}{2010/02/26}{fixed bug in
% \cs{marginparmargin}\{left\} in twoside mode}
%
% \changes{v3.6}{2010/04/19}{Reversioned memoir to a more suitable scheme}
% \changes{v3.6d}{2010/07/01}{Various bug fixes}
% \changes{v3.6e}{2010/08/20}{Maintenance}
% \changes{v3.6f}{2010/08/22}{Bad typo}
% \changes{v3.6g}{2010/09/19}{Maintenance}
% \changes{v3.6h}{2011/02/13}{Various things}
% \changes{v3.6i}{2011/02/18}{Two bug fixes}
% \changes{v3.6j}{2011/03/06}{Bug fixes}
% \changes{v3.6k}{2013/05/17}{Various fixes and long overdue maintenance}
% \changes{v3.7}{2013/05/22}{Bumped version}
% \changes{v3.7b}{2013/05/30}{Bugfix, sidecaption}
% \changes{v3.7c}{2015/03/05}{Bugfix}
% \changes{v3.7d}{2015/04/23}{Misc. bugfixes}
% \changes{v3.7e}{2015/07/08}{Per request from LaTeX Team, etex is not
% autoloaded on newer kernels}
% \changes{v3.7f}{2016/05/16}{Maintenance, luatex85 and booktabs update}
%
% \changes{v3.7h}{2018/12/12}{Maintenance, removing some emulated packages}
% \changes{v3.7i}{2019/11/15}{Maintenance, various edits}
% \changes{v3.7j}{2019/11/21}{Typo in embeded textcase, now that it is
% inside \cs{IfFileExists} \# needs to be doubled}
% \changes{v3.7k}{2020/03/25}{Maintenance}
% \changes{v3.7l}{2020/06/02}{Small preparation for october kernel update}
% \changes{v3.7m}{2020/09/10}{More preparations for october kernel update}
% \changes{v3.7n}{2020/10/04}{Foced # doubling in AtBegin/EndX macros
% to ensure backwards compatability}
% \changes{v3.7o}{2021/03/23}{Maintenance and a provide for the kernel}
% \changes{v3.7p}{2021/06/16}{Small adjustments of memoir vs memhfixc}
% \changes{v3.7q}{2022/02/20}{Maintenance}
% \changes{v3.7r}{2022/07/29}{Maintenance}
% \changes{v3.7.19}{2022/11/17}{Maintenance}
%
% \def\dtxfile{memoir.dtx}
%
% \def\fileversion{v0.1} \def\filedate{2001/05/20}
% \def\fileversion{v0.2} \def\filedate{2001/06/03}
% \def\fileversion{v0.3} \def\filedate{2001/07/14}
% \def\fileversion{v0.31} \def\filedate{2001/07/24}
% \def\fileversion{v0.32} \def\filedate{2001/08/03}
% \def\fileversion{v0.33} \def\filedate{2001/08/31}
% \def\fileversion{v1.0} \def\filedate{2001/11/17}
% \def\fileversion{v1.0a} \def\filedate{2001/12/07}
% \def\fileversion{v1.1} \def\filedate{2002/03/28}
% \def\fileversion{v1.1a} \def\filedate{2002/04/28}
% \def\fileversion{v1.2} \def\filedate{2002/08/10}
% \def\fileversion{v1.2} \def\filedate{2002/08/27}
% \def\fileversion{v1.3} \def\filedate{2002/11/14}
% \def\fileversion{v1.3a} \def\filedate{2002/11/22}
% \def\fileversion{v1.4} \def\filedate{2003/12/18}
% \def\fileversion{v1.6} \def\filedate{2004/01/31}
% \def\fileversion{v1.61} \def\filedate{2004/04/04}
% \def\fileversion{v1.618} \def\filedate{2005/09/27}
% \def\fileversion{v1.6180} \def\filedate{2006/06/12}
% \def\fileversion{v1.61803} \def\filedate{2008/05/26}
% \def\fileversion{v1.618033} \def\filedate{2008/06/02}
% \def\fileversion{v1.6180339} \def\filedate{2008/07/23}
% \def\fileversion{v1.6180339a} \def\filedate{2008/08/07}
% \def\fileversion{v1.6180339c} \def\filedate{2009/01/21}
% \def\fileversion{v1.6180339c} \def\filedate{2009/01/25}
% \def\fileversion{v1.6180339d} \def\filedate{2009/02/04}
% \def\fileversion{v1.6180339e} \def\filedate{2009/02/06}
% \def\fileversion{v1.6180339f} \def\filedate{2009/07/12}
% \def\fileversion{v1.6180339g} \def\filedate{2009/07/13}
% \def\fileversion{v1.61803398} \def\filedate{2009/09/10}
% \def\fileversion{v1.61803398b} \def\filedate{2009/09/21}
% \def\fileversion{v1.61803398c} \def\filedate{2009/11/17}
% \def\fileversion{v1.61803398d} \def\filedate{2009/11/23}
% \def\fileversion{v1.618033988} \def\filedate{2010/02/16}
% \def\fileversion{v1.618033988b} \def\filedate{2010/02/17}
% \def\fileversion{v1.618033988c} \def\filedate{2010/02/20}
% \def\fileversion{v3.6} \def\filedate{2010/04/19}
% \def\fileversion{v3.6d} \def\filedate{2010/07/01}
% \def\fileversion{v3.6e} \def\filedate{2010/08/20}
% \def\fileversion{v3.6f} \def\filedate{2010/08/22}
% \def\fileversion{v3.6g} \def\filedate{2010/09/19}
% \def\fileversion{v3.6h} \def\filedate{2011/02/13}
% \def\fileversion{v3.6i} \def\filedate{2011/02/18}
% \def\fileversion{v3.6j} \def\filedate{2011/03/06}
% \def\fileversion{v3.6k} \def\filedate{2013/05/17}
% \def\fileversion{v3.7} \def\filedate{2013/05/22}
% \def\fileversion{v3.7b} \def\filedate{2013/05/30}
% \def\fileversion{v3.7c} \def\filedate{2015/03/05}
% \def\fileversion{v3.7d} \def\filedate{2015/04/23}
% \def\fileversion{v3.7e} \def\filedate{2015/07/08}
% \def\fileversion{v3.7f} \def\filedate{2016/05/16}
% \def\fileversion{v3.7g} \def\filedate{2018/04/04}
% \def\fileversion{v3.7h} \def\filedate{2018/12/12}
% \def\fileversion{v3.7i} \def\filedate{2019/11/15}
% \def\fileversion{v3.7j} \def\filedate{2019/11/21}
% \def\fileversion{v3.7k} \def\filedate{2020/03/25}
% \def\fileversion{v3.7l} \def\filedate{2020/06/02}
% \def\fileversion{v3.7m} \def\filedate{2020/09/10}
% \def\fileversion{v3.7n} \def\filedate{2020/10/04}
% \def\fileversion{v3.7o} \def\filedate{2021/03/23}
% \def\fileversion{v3.7p} \def\filedate{2021/06/16}
% \def\fileversion{v3.7q} \def\filedate{2022/02/20}
% \def\fileversion{v3.7r} \def\filedate{2022/07/29}
% \def\fileversion{v3.7.19} \def\filedate{2022/11/17}
% \title{The LaTeX \Lpack{memoir} class for configurable book
% typesetting: Source code\thanks{This
% file (\texttt{\dtxfile}) has version number \fileversion, last revised
% \filedate.}}
%
% \author{%
% Peter Wilson\\ ^^A\thanks{\texttt{herries dot press at earthlink dot net}}\\
% Herries Press \\
% (maintained by Lars Madsen\thanks{\texttt{daleif at math dot au dot dk}}\ )}
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
% The \Lpack{memoir} class is designed for typesetting
% general books such as novels, biographies, histories,
% and so on, although as it supports all the functionality of the
% standard \Lpack{book} class it can also be used for technical writing.
% It provides more functions than the standard class as well as
% presenting a more friendly interface for the book designer.
% It can also simulate the typesetting style of the standard \Lpack{article}
% class.
%
% The class was first released in mid 2001 and has been well used ever
% since.
% \end{abstract}
%
% \tableofcontents
% \listoftables
%
% \StopEventually{}
%
%
%
% \section{Introduction}
%
% This document provides the commented source
% for the LaTeX \Lpack{memoir} class, which is designed for typesetting
% general books such as novels, biographies, histories,
% and so on. It has all the functionality of the standard \Lpack{book}
% class and, as well as providing some extra functions, also provides
% a more friendly interface for the document designer. As it can encompass
% everything that the \Lpack{book} class provides it may also be used
% for technical writing.
%
% The default appearance of a document typeset with this class is
% the same as if it had been typeset with the \Lpack{book} class and
% it can be made to simulate the \Lpack{article} class..
% The class, though, includes extra facilities that make it easy to
% change the appearance of such things as the page headers and footers,
% the style of chapter and other sectional headings, and the style of
% captions. It also makes it easy to both change the style of the
% Table of Contents, List of Figures, etc., as well as creating new
% kinds of `List of\ldots'. New types of floats, if needed, can be
% created very simply. Epigraphs can be put into the document in a
% variety of styles.
%
% The class provides a variety of page, chapter and captioning
% styles that you can choose from if you don't want to create your own.
%
% Documents can be typeset in 9pt, 10pt, 11pt, 12pt, 14pt or 17pt font
% sizes, and if you have scaleable fonts available they can be set at any size.
% There is a reasonably intuitive means of setting the margins
% and placement of the text on a page. There is an option to put
% trim marks on the printed pages if the stock sheets need to be trimmed
% down to the final page size. For those whose publishers like a
% manuscript to look as though it was typewritten, there is an option
% to do this (double spacing, ragged right, no hyphenation,
% fixed width font). There is also an unsophisticated means of flagging any
% revisions to the text.
%
% As this is a new class, by default it does not support the old
% LaTeX v2.09
% font commands, namely the \cs{bf}, \cs{sl}, \cs{it} and \cs{sc} commands;
% it warns about using the \cs{em} command but does support it.
%
%
% I hope that apart from the font commands the class
% is compatible with
% `standard' LaTeX.
%
% Development of this class would never have been started without
% the wonderful work done by Leslie Lamport and others~\cite{CLASSES}
% from whom I have learned a great deal and borrowed much code.
%
% Sections~\ref{sec:docstrip} through~\ref{sec:ic} describe some
% administrative elements and code for general use later in the
% specification.
% The macros forming the class file are defined in sections~\ref{sec:opt}
% through~\ref{sec:init}.
%
% This manual is typeset according to the conventions of the
% \LaTeX{} \textsc{docstrip} utility which enables the automatic
% extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
%
%
% \section{A driver for this document} \label{sec:docstrip}
%
% The next series of code contains the documentation driver file for
% \LaTeX, i.e., the file that will produce the documentation you are
% currently reading. This will be extracted from this file by the
% \textsc{docstrip} program.
%
% \begin{macrocode}
%<*driver>
\documentclass[twoside]{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{url,array}
%%\usepackage[draft=false,
%% plainpages=false,
%% pdfpagelabels,
%% bookmarksnumbered,
%% hyperindex=true
%% ]{hyperref} % Doesn't work with indexing of \DescribeMacro
\providecommand{\phantomsection}{} % just in case hyperref not used
% \end{macrocode}
%
% We do want an index, using linenumbers, but not update information.
% \begin{macrocode}
\EnableCrossrefs
\CodelineIndex
%% \RecordChanges
% \end{macrocode}
% We had better have page headings to aid navigation, but I don't
% like Uppercased titles.
% \begin{macrocode}
\makeatletter
\@mparswitchfalse
\makeatother
\renewcommand{\MakeUppercase}[1]{#1}
\pagestyle{headings}
% \end{macrocode}
% We may use so many \file{docstrip} modules that we set the
% \texttt{StandardModuleDepth} counter to 1.
% \begin{macrocode}
\setcounter{StandardModuleDepth}{1}
% \end{macrocode}
% Some commonly used abbreviations
% \begin{macrocode}
\newcommand*{\Lopt}[1]{\textsf {#1}} % typeset an option
\newcommand*{\file}[1]{\texttt {#1}} % typeset a file
\newcommand*{\Lcount}[1]{\textsl {\small#1}} % typeset a counter
\newcommand*{\pstyle}[1]{\textsl {#1}} % typeset a pagestyle
\newcommand*{\Lenv}[1]{\texttt {#1}} % typeset an environment
\newcommand*{\Lpack}[1]{\textsf {#1}} % typeset a package
\newcommand*{\ctt}{\textsc{ctt}} % comp.text.tex
\newenvironment{PW}{\em}{}
\newenvironment{dlf}{\em}{}
\newcommand*{\theTeXbook}{\textit{The \TeX book}}
\let\oldllap\llap
\def\llap#1{\oldllap{#1\quad}} % might be evil
% \end{macrocode}
% We want the full details printed.
% \begin{macrocode}
\begin{document}
\DeleteShortVerb{\|}
\raggedbottom
%\raggedright
\DocInput{\jobname.dtx}
\PrintIndex
%% \PrintChanges
\end{document}
%</driver>
% \end{macrocode}
%
%
% ^^A There are some elements we do not want to appear in the index.
% \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
% \DoNotIndex{\@centercr,\@cite}
% \DoNotIndex{\@dotsep,\@empty,\@gobble,\@gobbletwo,\@ignoretrue}
% \DoNotIndex{\@input,\@ixpt,\@m}
% \DoNotIndex{\@minus,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
% \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
% \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
% \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
% \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
% \DoNotIndex{\advance,\Alph,\alph}
% \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
% \DoNotIndex{\bullet}
% \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
% \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
% \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
% \DoNotIndex{\EnableCrossrefs,\end,\endgroup}
% \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
% \DoNotIndex{\fbox}
% \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
% \DoNotIndex{\global,\halign,\hbox,\hfil,\hfill,\hrule}
% \DoNotIndex{\hsize,\hskip,\hspace,\hss}
% ^^A \DoNotIndex{\if@tempswa,\fi}
% \DoNotIndex{\ifcase,\or,\fi}
% \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
% \DoNotIndex{\input}
% \DoNotIndex{\jobname,\kern,\leavevmode,\let}
% \DoNotIndex{\list,\llap,\long,\m@ne,\m@th}
% \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
% \DoNotIndex{\NeedsTeXFormat,\newdimen}
% \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
% \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
% \DoNotIndex{\par,\paragraph,\paragraphmark,\parfillskip}
% \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
% \DoNotIndex{\protect,\ProvidesClass}
% \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
% \DoNotIndex{\rightskip,\rlap,\rmfamily,\roman}
% \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
% \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
% \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
% \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
% \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
% \DoNotIndex{\wd,\xiipt,\year,\z@}
% \DoNotIndex{\@namedef,\@nameuse,\csname,\endcsname}
%
%
%
% \section{Identification} \label{sec:id}
%
% The \Lpack{memoir} document class can only be used with LaTeX2e,
% so we make
% sure that an appropriate message is displayed when another \TeX{}
% format is used.
% \begin{macrocode}
%<class>\NeedsTeXFormat{LaTeX2e}
% \end{macrocode}
%
% ^^A Use the Golden Section as the version number (1.6180339887 4989484820 4586834365)
% \changes{v3.6}{2010/04/19}{Not any more, apparently people does not
% know the numeric value of the golden ration very well}
%
%
% Announce the name, option files and version for LaTeX2e files:
% \begin{macrocode}
%<class>\ProvidesClass{memoir}%
%<class> [2022/11/17 v3.7.19 configurable book, report, article document class]
% \end{macrocode}
% In the manual it is useful to know the current version.
% \begin{macrocode}
%<class>\newcommand\memversion{v3.7.19, 2022/11/17}
%<9pt>\ProvidesFile{mem9.clo}%
%<9pt> [2022/07/29 v0.5 memoir class 9pt size option]
%<10pt>\ProvidesFile{mem10.clo}%
%<10pt> [2022/07/29 v0.5 memoir class 10pt size option]
%<11pt>\ProvidesFile{mem11.clo}%
%<11pt> [2022/07/29 v0.5 memoir class 11pt size option]
%<12pt>\ProvidesFile{mem12.clo}%
%<12pt> [2022/07/29 v0.5 memoir class 12pt size option]
%<14pt>\ProvidesFile{mem14.clo}%
%<14pt> [2022/07/29 v0.5 memoir class 14pt size option]
%<17pt>\ProvidesFile{mem17.clo}%
%<17pt> [2022/07/29 v0.5 memoir class 17pt size option]
%<20pt>\ProvidesFile{mem20.clo}%
%<20pt> [2022/07/29 v0.5 memoir class 20pt size option]
%<25pt>\ProvidesFile{mem25.clo}%
%<25pt> [2022/07/29 v0.5 memoir class 25pt size option]
%<30pt>\ProvidesFile{mem30.clo}%
%<30pt> [2022/07/29 v0.5 memoir class 30pt size option]
%<36pt>\ProvidesFile{mem36.clo}%
%<36pt> [2022/07/29 v0.5 memoir class 36pt size option]
%<48pt>\ProvidesFile{mem48.clo}%
%<48pt> [2022/07/29 v0.5 memoir class 48pt size option]
%<60pt>\ProvidesFile{mem60.clo}%
%<60pt> [2022/07/29 v0.5 memoir class 60pt size option]
% \end{macrocode}
%
%
% \section{Initial Code} \label{sec:ic}
%
% \begin{macrocode}
%<*class>
% \end{macrocode}
%
% (2022/02/20): In order to be able to use a patching approach instead
% of overwriting kernel macros, we will now require the
% \Lpack{etoolbox} package.
% \begin{macrocode}
\RequirePackage{etoolbox}
% \end{macrocode}
%
% Note (2001/08/03): Old versions of the \Lpack{amsmath} package did odd
% things with \cs{@tempa}, \cs{@tempb} and \cs{@tempc}. I have now replaced
% any use of these with \cs{@memtempa}, etc.
%
%
% In this part we define a few commands that are used later on.
%
% \begin{macro}{\@ptsize}
% \begin{macro}{\@memptsize}
% The \cs{@ptsize} control sequence is normally used to store the
% second digit of the
% pointsize we are typesetting in. So, normally, it's value is one
% of 0, 1 or 2.
%
% \cs{@memptsize} stores the full pointsize.
% \changes{v1.61803}{2008/01/30}{Added \cs{@memptsize}}
% \begin{macrocode}
\newcommand*{\@ptsize}{}
\newcommand*{\@memptsize}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Any new lengths that depend on the point size option must be declared
% before the options are executed.
% \begin{macro}{\onelineskip}
% \begin{macro}{\lxvchars}
% \begin{macro}{\xlvchars}
% The length \cs{onelineskip} is the vertical space taken
% by a normal line of text. The lengths \cs{lxvchars} and \cs{xlvchars} are
% the approximate lengths required for typesetting lines with either 65 or 45
% characters.
% \begin{macrocode}
\newlength{\onelineskip}
\newlength{\lxvchars}
\newlength{\xlvchars}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@memcnta}
% \begin{macro}{\c@memmarkcntra}
% We need a scratch count register and a scratch counter.
% \changes{v1.61803}{2008/10/30}{Added @memmarkcntra scratch counter}
% \begin{macrocode}
\newcount\@memcnta
\newcounter{@memmarkcntra}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{v1.0a}{2001/11/28}{Deleted count register \cs{@memtempa}}
%
% \begin{macro}{\if@restonecol}
% When the document has to be printed in two columns, we sometimes
% have to temporarily switch to one column. This switch is used to
% remember to switch back.
% \begin{macrocode}
\newif\if@restonecol
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@openright}
% This is TRUE if chapters are to start on righthand (recto) pages;
% this is the default. FALSE means chapters can start on any page.
% \begin{macrocode}
\newif\if@openright
\@openrighttrue
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@openleft}
% This is TRUE if chapters are to start on lefthand (verso) pages.
% \begin{macrocode}
\newif\if@openleft
\@openleftfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@mainmatter}
% This is TRUE if the main part of the document is being currently procesed;
% this is the default.
% \begin{macrocode}
\newif\if@mainmatter
\@mainmattertrue
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@memoldfont}
% This is TRUE if the \Lopt{oldfontcommands} option is used.
% \changes{v1.0a}{2002/01/29}{Added \cs{if@memoldfont}}
% \begin{macrocode}
\newif\if@memoldfont
\@memoldfontfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifextrafontsizes}
% This is TRUE if the \Lopt{extrafontsizes} option is used.
% \changes{v1.61803}{2008/01/30}{Added \cs{ifextrafontsizes}}
% \begin{macrocode}
\newif\ifextrafontsizes
\extrafontsizesfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@memerror}
% \begin{macro}{\@memwarn}
% Two macros to save some space when reporting errors or warnings.
% The macros take the same arguments, ignoring the first in each case,
% as \cs{ClassError} and \cs{ClassWarning}, e.g., \\
% \verb?\@memwarn{Message}? \\
% instead of \\
% \verb?\ClassWarning{memoir}{Message}?.
% \changes{v1.4}{2003/02/27}{Added \cs{@memerror} and \cs{@memwarn}}
% \begin{macrocode}
\newcommand*{\@memerror}{\ClassError{memoir}}
\newcommand*{\@memwarn}{\ClassWarning{memoir}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \changes{v3.7m}{2020/08/05}{Added \cs{IfFormatAtLeastTF}}
% \begin{macro}{\IfFormatAtLeastTF}
% Credit to Frank Mittelbach. Using
% \cs{IfFormatAtLeastTF}\marg{date}\marg{true}\marg{false} we can
% execute \meta{true} if the format is dated after the given
% \meta{date} (in {\scriptsize\ttfamily YYYY/MM/DD} format) and
% \meta{false} otherwise. The main use is for when we get info that
% certain features are being added to the \LaTeX\ format, features
% that we want to base class features on. Then this is an easy method
% for providing the code only avaiable on newer formats and code left
% over for those still using the older \LaTeX\ formats.\footnote{The \dots TF is a
% \LaTeX3 convention.}
% \begin{macrocode}
\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\ifsamename}
% \begin{macro}{\nametest}
% The macro \cs{nametest}\marg{name1}\marg{name2} tests whether the
% characters forming the two arguments are the same or not. If they are the
% same then \cs{ifsamename} is set TRUE, otherwise it is set FALSE. \meta{name1}
% and \meta{name2} must both be either macro names (including the backslash)
% or must both not be macro names. That is, you cannot do
% \verb?\nametest{\cs}{cs}?.
% \changes{v1.61803398d}{2010/02/13}{added some \% because the macro
% was leaking spaces}
% \begin{macrocode}
\newif\ifsamename
\newcommand{\nametest}[2]{%
\samenamefalse%
\begingroup%
\def\@memtempa{#1}\def\@memtempb{#2}%
\ifx \@memtempa\@memtempb%
\endgroup%
\samenametrue%
\else%
\endgroup%
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifm@m@And}
% \begin{macro}{\m@m@Andtrue}
% \begin{macro}{\m@m@Andfalse}
% \begin{macro}{\ifm@m@Or}
% \begin{macro}{\m@m@Ortrue}
% \begin{macro}{\m@m@Orfalse}
% \begin{macro}{\ifm@m@Xor}
% \begin{macro}{\m@m@Xortrue}
% \begin{macro}{\m@m@Xorfalse}
% These are for `if A and B', `if A or B' and `if A xor B'.
%
% For A and B:
% \begin{verbatim}
% \m@m@Andfalse
% \ifA
% \ifB
% \m@mAndtrue
% \fi
% \fi
% \end{verbatim}
% For A or B:
% \begin{verbatim}
% \m@m@Ortrue
% \ifA
% \else
% \ifB
% \else
% \m@m@Orfalse
% \fi
% \fi
% \end{verbatim}
% For A xor B:
% \begin{verbatim}
% \m@m@Xortrue
% \ifA
% \ifB
% \m@m@Xfalse
% \fi
% \else
% \ifB
% \else
% \m@m@Xorfalse
% \fi
% \fi
% \end{verbatim}
% \changes{v1.618}{2005/09/09}{Added \cs{ifm@m@And}, \cs{ifm@m@Or} and \cs{ifm@m@Xor}}
% \begin{macrocode}
\newif\ifm@m@And
\newif\ifm@m@Or
\newif\ifm@m@Xor
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \changes{v0.3}{2001/07/09}{Deleted \cs{fillline} and \cs{makecommand} as
% they were not used}
%
%
% \begin{macro}{\kill@lastcounter}
% \cs{kill@lastcounter}\marg{cntr}\footnote{With thanks to Stefan Ulrich
% (\texttt{ulrich@cis.uni-muenchen.de}) who answered a question on this
% on \ctt, 2001/07/09. (Also answered by Heiko Oberdiek,
% \texttt{oberdiek@ruf.uni-freiburg.de}).}
% kills the counter \meta{cntr}. This macro is an extension to the
% suggestions as it also makes the last count register reusable.
% \emph{The macro must only be used when the last allocated counter is to
% be killed.}
% For example with:\\
% \verb?\newcounter{fred} \kill@lastcounter{fred} \newcounter{fred}? \\
% there is no error with the second \cs{newcounter}.
% \changes{v0.3}{2001/07/09}{Added \cs{kill@counter}}
% \changes{v1.618}{2005/09/02}{Ensured \cs{kill@counter} zeroed the counter}
% \begin{macrocode}
\newcommand{\kill@lastcounter}[1]{%
% \end{macrocode}
% Deallocate the last counter register. From \theTeXbook, \verb?\count10? is
% the number of the last register. The counter should be zeroed before being
% deallocated otherwise an immediatally following \cs{newcount} may not
% be zero when allocated\footnote{Discovered and fix provided by Robert
% Schlicht on 2005/08/31.}.
% \begin{macrocode}
\count\count10 \z@
\advance\count10 \m@ne
% \end{macrocode}
% Set the internal counter definition to \cs{relax}.
% \begin{macrocode}
\expandafter\let\csname c@#1\endcsname\relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@name@p@xdf}
% \begin{macro}{\@name@unresp@xdef}
% \begin{macro}{\@namelet}
% \begin{macro}{\@namelongdef}
% Utility definition macros, along the lines of the kernel's \cs{@namedef}.
% \changes{v1.4}{2003/11/22}{Added \cs{@namelet} and friends (from patch v1.8)}
% \begin{macrocode}
\newcommand{\@name@p@xdef}[1]{%
\expandafter\protected@xdef\csname #1\endcsname}
\newcommand{\@name@unresp@xdef}[1]{%
\expandafter\unrestored@protected@xdef\csname #1\endcsname}
\newcommand{\@namelet}[1]{%
\expandafter\let\csname #1\endcsname}
\newcommand{\@namelongdef}[1]{%
\long\expandafter\def\csname #1\endcsname}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memletcmdtxt}
% \begin{macro}{\memlettxttxt}
% \begin{macro}{\memlettxtcmd}
% More utility macros (for the user but perhaps better not to tell them about
% it in the manual) \\
% \verb?\memletcmdtxt{\cmd}{txt} -> \let\cmd\txt? \\
% \verb?\memlettxttxt{txta}{txtb} -> \let\txta\txtb? \\
% \verb?\memlettxtcmd{txt}{\cmd} -> \let\txt\cmd? \\
% \changes{v1.6180339f}{2009/06/25}{Added \cs{memletcmdtxt}, \cs{memlettxttxt}
% and \cs{memlettxtcmd}}
% \begin{macrocode}
\newcommand*{\memletcmdtxt}[2]{\expandafter\let\expandafter#1\csname#2\endcsname}
\newcommand*{\memlettxttxt}[1]{\expandafter\memletcmdtxt\csname#1\endcsname}
\newcommand*{\memlettxtcmd}[2]{\expandafter\let\csname#1\endcsname#2}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@nameedef}
% A shorthand for using \cs{protected@edef}.
% \begin{macrocode}
\newcommand{\@nameedef}[1]{%
\expandafter\protected@edef\csname #1\endcsname}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\memjustarg}
% \begin{macro}{\memgobble}
% Utility macros \emph{that are not to be changed by any user!}
% \changes{v1.618}{2005/09/25}{Added \cs{memjustarg} and \cs{memgobble}}
% \begin{macrocode}
\newcommand{\memjustarg}[1]{#1}
\newcommand{\memgobble}[1]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \changes{v3.6k}{2013/05/14}{Added macro used macros}
% \begin{macro}{\memsetmacroused}
% \begin{macro}{\memsetmacrounused}
% \begin{macro}{\memifmacroused}
% We may want to make auto adjustment to the layout unless the user
% has used certain macros (in which case the user is responsible for
% their own actions). To make this macro test easier, we provide a
% few utility macros. Their use should be self explanatory. Though
% note that the macro being marked as used, is given in full, i.e.,
% \begin{verbatim}
% \memsetmacroused\setlrmargins
% \end{verbatim}
% \begin{macrocode}
\newcommand\memsetmacroused[1]{%
\@namedef{mem@macro@used@\expandafter\@gobble\string#1}{00}}
\newcommand\memsetmacrounused[1]{%
\@namedef{mem@macro@used@\expandafter\@gobble\string#1}{01}}
\newcommand\memifmacroused[1]{%
\if\@nameuse{mem@macro@used@\expandafter\@gobble\string#1}%
\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
% \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memsetlengthmin}
% \begin{macro}{\memsetlengthmax}
% Returns the min or max of two lengths. Note we may alter this in
% the future to use \cs{dimexpr}.
% \begin{macrocode}
\newcommand\memsetlengthmin[3]{\ifdim#2<#3\setlength{#1}{#2}\else\setlength{#1}{#3}\fi}
\newcommand\memsetlengthmax[3]{\ifdim#2>#3\setlength{#1}{#2}\else\setlength{#1}{#3}\fi}
% \end{macrocode}
%
% \end{macro}
% \end{macro}
%
% \subsection{Classes, Packages and Files}
%
% \begin{macro}{\@memfakeusepackage}
% \cs{@memfakeusepackage}\marg{pack} fools \LaTeX{} into thinking
% that the \meta{pack.sty} package has been loaded.
% \changes{v1.4}{2003/11/22}{Added \cs{@memfakeusepackage} (from patch v1.9)}
% \begin{macrocode}
\newcommand*{\@memfakeusepackage}[1]{%
\@namelet{ver@#1.sty}\@empty}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\EmulatedPackage}
% \begin{macro}{\EmulatedPackageWithOptions}
% There was some discussion on CTT\footnote{\textit{Re: breakurl + pdfetex
% for generating .dvi}, March 2005.} about how to prevent loading of
% a package. My response was to use \cs{@memfakusepackage}. Donald Arseneau
% came up with this comprehensive solution (there was a little discussion
% about naming with my final suggestion as here). \\
% \cs{EmulatedPackage}\marg{package}\oarg{date} \\
% \cs{EmulatedPackageWithOptions}\marg{option-list}\marg{package}\oarg{date} \\
%
% \changes{v1.618}{2005/09/04}{Added \cs{EmulatedPackage} and
% \cs{EmulatedPackageWithOptions}}
% \changes{v1.6180339}{2008/07/23}{Extended \cs{EmulatedPackage}}
% \begin{macrocode}
\providecommand*{\EmulatedPackage}{}
\renewcommand*{\EmulatedPackage}[1]{%
\@ifnextchar[{\@emulated@package{#1}}%
{\@emulated@package{#1}[\@empty]}%]
}
\providecommand*{\EmulatedPackageWithOptions}{}
\renewcommand*{\EmulatedPackageWithOptions}[2]{%
\PassOptionsToPackage{#1}{#2}%
\EmulatedPackage{#2}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@emulated@package}
% The workhorse for the user commands.
% \begin{macrocode}
\def\@emulated@package#1[#2]{%
\expandafter\xdef\csname ver@#1.\@pkgextension\endcsname{#2}%
\@ifundefined{opt@#1.\@pkgextension}%
{\@namedef{opt@#1.\@pkgextension}{}}{}%
\wlog{Package #1 \ifx\@empty#2\else[#2] \fi
\if,\csname opt@#1.\@pkgextension\endcsname,\else
(with options \csname opt@#1.\@pkgextension\endcsname) \fi
emulated by \@currname.}%
}
\@onlypreamble\EmulatedPackage
\@onlypreamble\EmulatedPackageWithOptions
\@onlypreamble\@emulated@package
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DisemulatePackage}
% \cs{DisemulatePackage}\marg{package} undoes a previous
% \cs{EmulatedPackage...}
% \changes{v1.61803}{2008/01/30}{Added \cs{DisemulatePackage} from memptach v4.5}
% \changes{v1.6180339}{2008/07/23}{Fixed \cs{DisemulatePackage} from mempatch v5.1}
% \begin{macrocode}
\newcommand*{\DisemulatePackage}[1]{%
\@namelet{ver@#1.\@pkgextension}\relax}
\@onlypreamble\DisemulatePackage
% \end{macrocode}
% \end{macro}
%
% \noindent
% From 2020/10/01 format onwards we will implement file hooks via the
% features provided by the \LaTeX\ kernel. This makes our code easier
% to do (actually, users really ought to use these hook macros instead
% of the ones the class provides) and it eliminates the need for us to
% redefine \cmd{\InputIfFileExists}.
% \changes{v3.7m}{2020/08/06}{Reimplemented file/package/class hooks}
% \begin{macrocode}
\IfFormatAtLeastTF{2020/10/01}{
% \end{macrocode}
% As mentioned in \cite{LTHOOKS,LTFILEHOOK} the kernel provides hooks
% at the start of files, packages and classes. The class you implement
% the latter via our definition of the file hook. We will now instead
% use the separate hooks. Note that we will \emph{not} be adding any
% extra labels to these hooks and will provide no interface to do
% so. If more control is needed, please use the kernel interface directly.
% \begin{macro}{\AtBeginFile}
% \begin{macro}{\AtEndFile}
% \cs{AtBeginFile}\marg{file}\marg{code} inserts \meta{code}
% just before \meta{file} is input. Similarly \cs{AtEndFile} inserts
% just after input.
%
% \textbf{Breaking change:} In the old implemenation
% \verb!\AtEndFile{file}! worked for \texttt{file.tex} even if one
% did not speficy the extension. Now you will need to use
% \verb!\AtEndFile{file.tex}! explicitly.
% \changes{v3.7n}{2020/10/04}{The old AtXFile code required \#\
% doubling. The new does not, and this is not backwards compatible. By
% suggestion from David Carlisle we change the code a little such that
% \#\ is needed}
% We add a \cs{temp} trick suggested by David Carlisle as the old code
% required \#\ doubling and the new does not. To be backwards
% compatible we force required \#\ doubling.
% \changes{v3.7q}{2022/01/07}{The LaTeX team reversed the order of the
% hook name}
% \begin{macrocode}
\newcommand\AtBeginFile[2]{\def\temp{\AddToHook{file/#1/before}{#2}}\temp}
\newcommand\AtEndFile[2]{\def\temp{\AddToHook{file/#1/after}{#2}}\temp}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\AtBeginPackage}
% \begin{macro}{\AtEndPackage}
% \begin{macro}{\RequireAtEndPackage}
% \cs{AtBeginPackage}\marg{pack}\marg{code} inserts \meta{code}
% just before the \meta{pack} package is input, and \cs{AtEndPackage}
% is the equivalent for after input. \cs{RequireAtEndPackage} inserts
% \meta{code} either at the end of \meta{pack}, or immediately if
% \meta{pack} has already been input.
% \changes{v3.7n}{2020/10/04}{The old AtXPackage code required \#\
% doubling. The new does not, and this is not backwards compatible. By
% suggestion from David Carlisle we change the code a little such that
% \#\ is needed}
% We add a \cs{temp} trick suggested by David Carlisle as the old code
% required \#\ doubling and the new does not. To be backwards
% compatible we force required \#\ doubling.
% \changes{v3.7q}{2022/01/07}{The LaTeX team reversed the order of the
% hook name}
% \begin{macrocode}
\newcommand\AtBeginPackage[2]{\def\temp{\AddToHook{package/#1/before}{#2}}\temp}
\newcommand\AtEndPackage[2]{\def\temp{\AddToHook{package/#1/after}{#2}}\temp}
\newcommand{\RequireAtEndPackage}[2]{%
\@ifpackageloaded{#1}{#2}{\AtEndPackage{#1}{#2}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\AtBeginClass}
% \begin{macro}{\AtEndClass}
% \begin{macro}{\RequireAtEndClass}
% \cs{AtBeginClass}\marg{class}\marg{code} and friends are the class
% equivalents of \cs{AtBeginPackage} and friends.
% \changes{v3.7n}{2020/10/04}{The old AtXPackage code required \#\
% doubling. The new does not, and this is not backwards compatible. By
% suggestion from David Carlisle we change the code a little such that
% \#\ is needed}
% We add a \cs{temp} trick suggested by David Carlisle as the old code
% required \#\ doubling and the new does not. To be backwards
% compatible we force required \#\ doubling.
% \changes{v3.7q}{2022/01/07}{The LaTeX team reversed the order of the
% hook name}
% \begin{macrocode}
\newcommand\AtBeginClass[2]{\def\temp{\AddToHook{class/#1/before}{#2}}\temp}
\newcommand\AtEndClass[2]{\def\temp{\AddToHook{class/#1/after}{#2}}\temp}
\newcommand{\RequireAtEndClass}[2]{%
\@ifclassloaded{#1}{#2}{\AtEndClass{#1}{#2}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macrocode}
}{% back to the code for older formats
% \end{macrocode}
% \noindent
% Here follows the old code, which will still be used on older formats:
%
% Code, based on a hint from Morten H{\o}gholm\footnote{CTT posting
% 2005/11/08, \textit{Re: Checking for packages froma class...
% revisited}} that the \Lpack{scrlfile} package from
% \Lpack{koma-script} includes commands such as \\
% \cs{AfterFile}\marg{file}\marg{code} \\
% plus before and after classes and packages.
% \changes{v1.16803}{2008/01/30}{Added various \cs{AtBegin...} and
% \cs{AtEnd...} macros (mempatch v4.2)}
%
% Extend the \cs{InputIfFileExists} macro to call hooks before and
% the actual inputting. The kernel version (as of 2005/11/21) is:
% \begin{verbatim}
% \newcommand{\InputIfFileExists}[2]{%
% \IfFileExists{#1}%
% {\#2\@addtofilelist{#1}\@@input \@filef@und}}
% \end{verbatim}
% and as of 2019/10/01:
% \begin{verbatim}
% \DeclareRobustCommand \InputIfFileExists[2]{%
% \IfFileExists{#1}%
% {\expandafter\@swaptwoargs\expandafter
% {\@filef@und}{#2\@addtofilelist{#1}\@@input}}}
% \end{verbatim}
% Just to make sure we still work on formats prior and after
% 2019/10/01 we `redefine' both
%
% \begin{macro}{\InputIfFileExists}
% Effectively all file input is handled by this macro. Extend it
% by adding pre- and post- input hooks.
%
% \changes{3.7i}{2019/10/22}{Added latest kernel changes, special
% thanks to Phelype Oleinik}
% \begin{macrocode}
\ifcsname InputIfFileExists \endcsname% looking for an explicit space
% here aka the robust version
\DeclareRobustCommand \InputIfFileExists[2]{%
\IfFileExists{#1}%
{%
\expandafter\@swaptwoargs\expandafter
{\@filef@und\m@matendf{#1}\killm@matf{#1}}{%
#2\@addtofilelist{#1}\m@matbeginf{#1}\@@input%
}%
}%
}
\else
% Old definition
\renewcommand{\InputIfFileExists}[2]{%
\IfFileExists{#1}%
{#2\@addtofilelist{#1}\m@matbeginf{#1}%
\@@input \@filef@und
\m@matendf{#1}%
\killm@matf{#1}}}
\fi
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@matbeginf}
% \begin{macro}{\m@matendf}
% \cs{m@matbeginf}\marg{file} calls macro \cs{file-m@mfb} if it
% is defined. Similarly \cs{m@matendf}\marg{file} calls
% \cs{file-m@mfe} if it is defined.
% \begin{macrocode}
\newcommand{\m@matbeginf}[1]{\@ifundefined{#1-m@mfb}{}%
{\@nameuse{#1-m@mfb}}}
\newcommand{\m@matendf}[1]{\@ifundefined{#1-m@mfe}{}%
{\@nameuse{#1-m@mfe}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\killm@matf}
% \cs{killm@matf}\marg{file} undefines the \cs{file-m@mfb} and
% \cs{file-m@mfe} macros.
% ^^A \begin{macrocode}
% ^^A we use the better defintion below
% ^^A % \newcommand*{\killm@matf}[1]{%
% ^^A % \@namelet{#1-m@mfb}\relax
% ^^A % \@namelet{#1-m@mfe}\relax}
% ^^A
% ^^A \end{macrocode}
%
% ^^A \subsection{Input files into tabulars, and etex}
%
% M.J. Williams (CTT \textit{\cs{noalign} problem with \cs{input} and
% tabular in memoir class}, 28 Aug 2007) reported that using \cs{input} in a
% tabular resulted in errors. His example was:
% \begin{verbatim}
% ...
% \begin{tabular}{c|c} \hline
% 1 & 2 \\ \hline
% \input{data} \hline
% 5 & 6 \\ \hline
% \end{tabular}
% \end{verbatim}
% where \texttt{data.tex} contains the single line (and no newline) \\
% \verb?3 & 4 \\?
%
% Morten H{\o}gholm noted that the problem
% was caused by \Lpack{memoir}'s extension to \cs{input}
% and gave a solution that depends on processing via
% \texttt{etex} rather than \texttt{tex}.
%
% Here's Morten's fix. Quoting, in part:
% \begin{quotation}
% \Lpack{memoir} extends the file loading mechanism by providing
% \cs{AtBeginFile} and \cs{AtEndFile} whose arguments are executed as
% the names indicate. \ldots after inputting a file the storage bins are
% emptied. The problem [in your case] is that this emptying is an
% assignment and so starts a new tabular cell and \cs{hline} is only
% allowed after \verb?\\? or other \cs{hline}s.
%
% \ldots the tabular environment wraps each tabular cell in additional
% groups so one can do an explicit test for which type of group we are in.
% If tested to be in an align group \emph{and} in vertical mode it means
% TeX hasn't found something to start a new cell and
% then \cs{noalign} can be used.
% \end{quotation}
%
% \begin{macrocode}
%% \ifetex
\newcommand*{\killm@matf}[1]{%
\ifnum 6=\currentgrouptype
\ifvmode
\expandafter\expandafter\expandafter\@firstoftwo
\expandafter\expandafter\expandafter\noalign
\fi
\fi
\@firstofone
{\@namelet{#1-m@mfb}\relax
\@namelet{#1-m@mfe}\relax
}%
}
%% \fi
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\AtBeginFile}
% \begin{macro}{\AtEndFile}
% \cs{AtBeginFile}\marg{file}\marg{code} inserts \meta{code}
% just before \meta{file} is input. Similarly \cs{AtEndFile} inserts
% just after input.
% \begin{macrocode}
\newcommand{\AtBeginFile}[2]{\@ifundefined{#1-m@mfb}%
{\@namedef{#1-m@mfb}{#2}}%
{\expandafter\addtodef\csname #1-m@mfb\endcsname{}{#2}}}
\newcommand{\AtEndFile}[2]{\@ifundefined{#1-m@mfe}%
{\@namedef{#1-m@mfe}{#2}}%
{\expandafter\addtodef\csname #1-m@mfe\endcsname{}{#2}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\AtBeginPackage}
% \begin{macro}{\AtEndPackage}
% \begin{macro}{\RequireAtEndPackage}
% \cs{AtBeginPackage}\marg{pack}\marg{code} inserts \meta{code}
% just before the \meta{pack} package is input, and \cs{AtEndPackage}
% is the equivalent for after input. \cs{RequireAtEndPackage} inserts
% \meta{code} either at the end of \meta{pack}, or immediately if
% \meta{pack} has already been input.
% \begin{macrocode}
\newcommand{\AtBeginPackage}[2]{%
\AtBeginFile{#1.\@pkgextension}{#2}}
\newcommand{\AtEndPackage}[2]{%
\AtEndFile{#1.\@pkgextension}{#2}}
\newcommand{\RequireAtEndPackage}[2]{%
\@ifpackageloaded{#1}{#2}%
{\AtEndFile{#1.\@pkgextension}{#2}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\AtBeginClass}
% \begin{macro}{\AtEndClass}
% \begin{macro}{\RequireAtEndClass}
% \cs{AtBeginClass}\marg{class}\marg{code} and friends are the class
% equivalents of \cs{AtBeginPackage} and friends.
% \begin{macrocode}
\newcommand{\AtBeginClass}[2]{%
\AtBeginFile{#1.\@clsextension}{#2}}
\newcommand{\AtEndClass}[2]{%
\AtEndFile{#1.\@clsextension}{#2}}
\newcommand{\RequireAtEndClass}[2]{%
\@ifclassloaded{#1}{#2}%
{\AtEndFile{#1.\@clsextension}{#2}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
} % end of els part of format check
% \end{macrocode}
%
%
%
% \begin{macro}{\phantomsection}
% A command needed if the \Lpack{hyperref} package is used, for putting
% before certain \cs{addcontentsline} commands.
% \begin{macrocode}
\newcommand{\phantomsection}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\nofiles}
% The kernel's \cs{nofiles}, which surprisingly may be called \emph{before}
% the class is loaded, lets \cs{makeindex} to \cs{relax}. This could
% cause problems\footnote{As reported by Heiko Oberdiek on 2005/07/09.}
% with my initial version of \cs{makeindex}.
% Here's the kernel \cs{nofiles} definition:
% \begin{verbatim}
% \def\nofiles{%
% \@fileswfalse% flag for suppressing \immediate \writes
% \typeout{No auxiliary output files.^^J}%
% \long\def\protected@write##1##2##3%
% {\write\m@ne{}\if@nobreak\ifvmode\nobreak\fi\fi}%
% \let\makeindex\relax
% \let\makeglossary\relax}
% \end{verbatim}
% To get it to work for when \cs{makeindex}es optional argument is
% used I let \cs{makeindex} itself deal with \cs{nofiles} (and
% also \cs{makeglossary}).
% \changes{v1.618}{2005/09/25}{Modified the kernel's \cs{nofiles}}
% \begin{macrocode}
\renewcommand*{\nofiles}{%
\@fileswfalse% flag for suppressing \immediate \writes
\typeout{No auxiliary output files.^^J}%
\long\def\protected@write##1##2##3%
{\write\m@ne{}\if@nobreak\ifvmode\nobreak\fi\fi}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\memsetcounter}
% A wrapper round \cs{setcounter}. I want to use this in the \texttt{aux} file.
% \changes{v1.61803}{2008/01/30}{Added \cs{memsetcounter}}
% \begin{macrocode}
\newcommand*{\memsetcounter}[2]{\setcounter{#1}{#2}}
\AtBeginDocument{\immediate\write\@mainaux{%
\string\providecommand*{\string\memsetcounter}[2]{}}}
% \end{macrocode}
% \end{macro}
%
% \subsection{For package documentation}
%
% Some macros that may be useful for documenting LaTeX code. These
% have principally come from \texttt{doc.dtx}.
%
% \begin{macro}{\bs}
% Prints \verb?\?
% \begin{macrocode}
\def\bs{\texttt{\char`\\}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@nohyphenation}
% \begin{macro}{\meta}
% \begin{macro}{\meta@font@select}
% From \texttt{doc.dtx} \\
% \cs{meta}\marg{arg} prints \meta{arg}.
% \begin{macrocode}
\ifx\l@nohyphenation\undefined
\newlanguage\l@nohyphenation
\fi
\DeclareRobustCommand{\meta}[1]{%
\ensuremath\langle
\ifmmode \expandafter \nfss@text \fi
{%
\meta@font@select
\edef\meta@hyphen@restore
{\hyphenchar\the\font\the\hyphenchar\font}%
\hyphenchar\font\m@ne
\language\l@nohyphenation
#1\/%
\meta@hyphen@restore
}\ensuremath\rangle
}
\def\meta@font@select{\itshape}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\marg}
% \begin{macro}{\oarg}
% \begin{macro}{\parg}
% Robust versions of the \texttt{doc.dtx} macros. \\
% \cs{marg}\marg{arg} prints \marg{arg} \\
% \cs{oarg}\marg{arg} prints \oarg{arg} \\
% \cs{parg}\marg{arg} prints \parg{arg} \\
% \begin{macrocode}
\DeclareRobustCommand{\marg}[1]{%
{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
\DeclareRobustCommand{\oarg}[1]{%
{\ttfamily\char`\[}\meta{#1}{\ttfamily\char`\]}}
\DeclareRobustCommand{\parg}[1]{%
{\ttfamily\char`\(}\meta{#1}{\ttfamily\char`\)}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cs}
% \verb?\cs{arg}? prints \cs{arg}.
% \begin{macrocode}
\DeclareRobustCommand{\cs}[1]{\texttt{\char`\\#1}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\cmdprint}
% \begin{macro}{\cmd}
% From Heiko Oberdiek CTT 2001/05/26 (print and index a command) \\
% \verb?\cmdprint{\fred}? prints \verb?\fred? \\
% \verb?\cmd{\fred}? prints and indexes \verb?\fred?. NOTE It assumes that
% \verb!?! is the `actual' character for MakeIndex (it is normally \verb!@!
% but that is not much use if a command includes \verb!@! as part of its name).
% \begin{macrocode}
\newcommand{\cmdprint}[1]{\texttt{\string#1}}
\newcommand{\cmd}[1]{\cmdprint{#1}%
\index{\expandafter\@gobble\string#1?\string\cmdprint{\string#1}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
%
% \subsection{Checking the processor}
%
% As of November 2019, we load the \Lpack{iftex} package in order to
% the the various processor tests. The package was updated in 2019 to
% cover the functionality of the \Lpack{ifpdf}, \Lpack{ifetex},
% \Lpack{ifxetex} and \Lpack{ifluatex} packages. You can find details
% about its use in \cite{IFTEX}.
% \changes{v3.7i}{2019/11/11}{Changed
% ifX package loading to just loading the new \Lpack{iftex}
% package. At the request of the LaTeX Project Team.}
% \begin{macrocode}
\RequirePackage{iftex}[2019/11/07]
% \end{macrocode}
% The \Lpack{iftex} provides the following tests
% (and several more):
% \begin{macro}{\ifpdf}
% True if the output mode is PDF. Useful if for example you are
% working in an environment where you need to provide explicit code
% for the LaTeX+dvips route.
% \end{macro}
% \begin{macro}{\ifxetex}
% True if the XeTeX engine is being used.
% \end{macro}
% \begin{macro}{\ifluatex}
% True if the LuaTeX engine is being used. Useful if you want to add
% code that only apply under the LuaTeX based engines.
% \end{macro}
%
%
%
% ^^A % Prior to 2008/07/22 the \Lpack{hyperref} package was modified in such a
% ^^A % way as to produce warnings about versions of the \Lpack{ifpdf} and
% ^^A % \Lpack{ifxetex} packages when \Lpack{hyperref} was used with versions
% ^^A % v1.618033,
% ^^A % v1.61803, or v1.618 mempatch v4.9 of the class.
% ^^A % \Lpack{hyperref}'s author refused to
% ^^A % make any changes to his package, insisting that emulating a package was
% ^^A % `ugly hacking'. He did, though, provide an example code that could be
% ^^A % added to memoir
% ^^A % to use a package if it was available. I have used it for the emulations
% ^^A % in this section. There will be no further changes to the class to accomodate
% ^^A % any further changes to \Lpack{hyperref} --- it's easy for a package to
% ^^A % determine what class is being used and make arrangements accordingly,
% ^^A % especially as there are not all that many classes. There are hundreds
% ^^A % of packages that might be used with a particular class and it would be
% ^^A % senseless for a class to attempt to take account of everything that might
% ^^A % be used with it.
% ^^A %
% ^^A % Note (2016/05/16): Due to recent changes in Luatex, most notably the
% ^^A % removal of several \cs{pdf...} macro, several PDF tests fail with
% ^^A % LuaLaTeX. As a temporary measure the following is used to restore
% ^^A % the old functionality when a newer LuaLaTeX is used. Code courtesy
% ^^A % of David Carlisle. At some point we will include some of this into
% ^^A % the class.
% ^^A % \changes{v3.7f}{2016/05/16}{Temp measure to make the class work with
% ^^A % updated luatex}
% ^^A % \changes{v3.7g}{2018/03/09}{\Lpack{luatex85} removed again, now
% ^^A % relying on external \cs{if<engine>} packages and have rewritten the
% ^^A % macros that use \cs{pdf...}}
% ^^A % ^^A % \begin{macrocode}
% ^^A % ^^A \ifx\pdfextension\@undefined\else
% ^^A % ^^A \RequirePackage{luatex85}
% ^^A % ^^A \fi
% ^^A % ^^A
% ^^A % ^^A % \end{macrocode}
% ^^A %
% ^^A %
% ^^A % \begin{macro}{\ifpdf}
% ^^A % This can be used to check whether or not a document is being processed
% ^^A % by \LaTeX{} or pdf\LaTeX. We will simply require the \Lpack{ifpdf} package.
% ^^A % \changes{v1.0}{2001/09/21}{Made checking of \cs{pdfouput} more robust}
% ^^A % \changes{v1.618}{2005/09/03}{Prohibit loading the ifpdf package (mempatch v3.9)}
% ^^A % \changes{v1.618033}{2008/06/02}{Further improved pdf checking}
% ^^A % \changes{v1.6180339}{2008/07/23}{Use ifpdf package if available}
% ^^A % \changes{v1.61803398d}{2009/12/01}{if \cs{ifpdf} is already
% ^^A % defined, e.g. using \cs{RequirePackage} before \cs{documentclass},
% ^^A % then using \cs{newif}\cs{ifpdf} will cause TeX to eat up a lot of
% ^^A % code. We fix this using a hint by Will Robertson.}
% ^^A % \changes{v3.7g}{2018/03/08}{As of 2018, we will no longer be
% ^^A % emulating \cs{if}\meta{engine} packages, you'll get an error if you
% ^^A % do not have them}
% ^^A % \begin{macrocode}
% ^^A % \RequirePackage{ifpdf}[2017/03/15]
% ^^A % \end{macrocode}
% ^^A % \end{macro}
% ^^A %
% ^^A % \begin{macro}{\ifetex}
% ^^A % Check if \texttt{etex} is being used. We will simply require the \Lpack{ifetex} package.
% ^^A % \changes{v1.61803}{2008/01/30}{Added check for etex (mempatch v4.9)}
% ^^A % \changes{v1.618033}{2008/06/02}{Improved check for etex}
% ^^A % \changes{v1.6180339}{2008/07/23}{Use an ifetex package if available}
% ^^A % \changes{v1.6180339c}{2008/12/27}{Changed ifetex message from Warning to Info}
% ^^A % \changes{v3.7g}{2018/03/08}{As of 2018, we will no longer be
% ^^A % emulating \cs{if}\meta{engine} packages, you'll get an error if you
% ^^A % do not have them}
% ^^A % \begin{macrocode}
% ^^A % \RequirePackage{ifetex}
% ^^A % \end{macrocode}
% ^^A % \end{macro}
% ^^A % Having supplied an \cs{ifpdf} to check if pdfLaTeX is being used,
% ^^A % here's one for XeTeX.
% ^^A %
% ^^A % \begin{macro}{\ifxetex}
% ^^A % Checks if XeTeX is being used. We will simply require the \Lpack{ifxetex} package.
% ^^A % \changes{v1.61803}{2008/01/30}{Added checks for XeTeX (mempatch v4.9)}
% ^^A % \changes{v1.6180339}{2008/07/23}{Use ifxetex package if available}
% ^^A % \changes{v1.61803398d}{2009/12/01}{if \cs{ifxetex} is already
% ^^A % defined, e.g. using \cs{RequirePackage} before \cs{documentclass},
% ^^A % then using \cs{newif}\cs{ifxetex} will cause TeX to eat up a lot of
% ^^A % code. We fix this using a hint by Will Robertson.}
% ^^A % \changes{v3.7g}{2018/03/08}{As of 2018, we will no longer be
% ^^A % emulating \cs{if}\meta{engine} packages, you'll get an error if you
% ^^A % do not have them}
% ^^A % \begin{macrocode}
% ^^A % \RequirePackage{ifxetex}[2010/09/12]
% ^^A % \end{macrocode}
% ^^A % \end{macro}
% ^^A %
% ^^A % \begin{macro}{\ifluatex}
% ^^A % Check if \texttt{luatex} is being used. We will simply require the \Lpack{ifluatex} package.
% ^^A % \changes{v1.61803}{2008/01/30}{Added check for luatex}
% ^^A % \changes{v1.6180339}{2008/07/23}{Use an ifluatex package if available}
% ^^A % \changes{v1.6180339c}{2008/12/31}{It seems that Heiko Oberdiek has created an
% ^^A % ifluatex package.}
% ^^A % \changes{v1.61803398d}{2009/12/01}{if \cs{ifluatex} is already
% ^^A % defined, e.g. using \cs{RequirePackage} before \cs{documentclass},
% ^^A % then using \cs{newif}\cs{ifluatex} will cause TeX to eat up a lot of
% ^^A % code. We fix this using a hint by Will Robertson.}
% ^^A % \changes{v3.7g}{2018/03/08}{As of 2018, we will no longer be
% ^^A % emulating \cs{if}\meta{engine} packages, you'll get an error if you
% ^^A % do not have them}
% ^^A % \begin{macrocode}
% ^^A % \RequirePackage{ifluatex}[2016/05/16]
% ^^A %
% ^^A % \end{macrocode}
% ^^A % \end{macro}
% ^^A %
%
%
%
% \subsection{Extending an existing macro}
%
%
% My usual technique for modifying the code of an existing
% macro was to use \cs{renewcommand}. However it slowly became apparent that
% many of such modifications merely consisted of adding some code at
% either the start or end of the existing definition. In June 2000 I
% posed a question
% on the \texttt{comp.text.tex} newsgroup about this, and
% Michael Downes\footnote{\texttt{epsmjd@ams.org}} and
% Heiko Oberdiek\footnote{\texttt{oberdiek@ruf.uni-freiburg.de}}
% were kind enough to respond.
% The responses arrived almost simultaneously, both
% supplying methods for adding code at the end of a macro defined to take
% one argument. Michael Downes' response included a remark about it probably
% being too much effort to formulate a general way of doing this.
% Heiko Oberdiek almost immediately replied with such a generalisation.
%
% The following code, which I have extracted from a package that I
% wrote but which I did not submit to CTAN, incorporates the work of both
% Michael and Heiko. I have added a bit. All errors are my responsibility.
% Michael went on the write the \Lpack{patchcmd} package which is
% a generalisation of the facilities below and so there was no need for
% my more restricted package.
% \changes{v0.33}{2001/08/31}{Replaced \cs{appendiarg} with \cs{addtodef}
% and friends}
%
% \begin{macro}{\wo@dmacro}
% Heiko Oberdiek suggested\footnote{Via email on 2000/07/12.} that
% \meta{macro} should be tested for being the name of a macro, rather than
% using the normal \LaTeX{} test against it being undefined. He supplied
% the code for performing the macro name test.
%
% \cs{wo@dmacro} is a helper for handling the string `macro:'.
% \begin{macrocode}
\edef\wo@dmacro{%
\string m\string a\string c\string r\string o\string :%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\wo@difmacro@begingroup}
% This seems to take two arguments:
% \cs{wo@difmacro@begingroup}\marg{macro}\marg{code}, where
% \meta{macro} should be the name of a defined macro and \meta{code}
% is code to be executed if and only if \meta{macro} \emph{is} a
% defined macro.
% \begin{macrocode}
\def\wo@difmacro@begingroup#1{%
% \end{macrocode}
% Start a group.
% \begin{macrocode}
\begingroup
% \end{macrocode}
% Test if \verb?#1? is a defined macro; \cs{wo@dparsemacro} does most of the work.
% \begin{macrocode}
\edef\x{%
\noexpand\wo@dparsemacro\meaning#1\wo@dmacro\string -%
}%
\x\@nil{#1}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\wo@dparsemacro}
% This is called by \cs{wo@difmacro@begingroup}. If \meta{macro} is not
% a defined macro it prints a warning and closes the group begun by
% \cs{wo@difmacro@begingroup}. Otherwise it process the \meta{code} which
% \emph{must} close the group.
% \begin{macrocode}
\begingroup
\edef\x{\endgroup
\def\noexpand\wo@dparsemacro##1\wo@dmacro##2\string -}%
\x#3\@nil#4{%
\ifx\\#3\\%
\endgroup
\@memwarn{\string `\string #4\string ' is not a macro}%
\expandafter\@gobble
\else
\expandafter\@firstofone
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\addtodef}
% \begin{macro}{\addtodef*}
% \begin{macro}{\wo@daddtodef}
% The command \cs{addtodef}\marg{macro}\marg{start-stuff}\marg{end-stuff}
% adds stuff at the start and/or end of an argumentless macro.
% Initially the code for appending was a reimplementation of the
% kernel \cs{g@addto@macro} command (from \file{ltclass.dtx}).
% Later, at Michael Downes' suggestion, I combined
% appending and prepending stuff into a single command.
% Actually, there is no real need to have both
% \cs{addtodef} and \cs{addtodef*} as the body of the command
% being amended has no argument,
% but both versions are provided for consistency.
%
% The kernel \cs{@star@or@long} and \cs{l@ngrel@x} commands
% (in \file{ltdefns.dtx}) are used to handle
% the potential \verb?*? after the command name.
% \begin{macrocode}
\def\addtodef{\@star@or@long\wo@daddtodef}
% \end{macrocode}
% The \cs{@star@or@long} command dealt with a possible \verb?*? and now
% \cs{wo@daddtodef} does the work. It picks up the three arguments
% that the user thinks belong to \cs{addtodef}, namely \meta{macro},
% \meta{start-stuff} and \meta{end-stuff}.
% \begin{macrocode}
\long\def\wo@daddtodef#1#2#3{%
% \end{macrocode}
% Check if \meta{macro} has been defined.
% \begin{macrocode}
\wo@difmacro@begingroup{#1}{%
% \end{macrocode}
% If \meta{macro} is defined then store the tokens corresponding to the
% body of \meta{macro} and the extra \meta{-stuff} in token registers.
% \begin{macrocode}
\@temptokena{#2}%
\toks@\expandafter{#1#3}%
% \end{macrocode}
% Do an expanded definition for \cs{x}, so that calling \cs{x}
% will \cs{def} a new version of \meta{macro}, whose body consists of the
% saved tokens (i.e., the orginal body plus the extra stuff).
% As Michael Downes noted, single letter control sequences do not take any of
% \TeX's hash table space.
% \cs{l@ngrel@x}
% has been previously set to either \cs{long} or \cs{relax} by \cs{@star@or@long},
% and so may make the new definition of \meta{macro} to be \cs{long}.
% \begin{macrocode}
\edef\x{\endgroup
\l@ngrel@x\def\noexpand#1{\the\@temptokena \the\toks@}}%
% \end{macrocode}
% Finally, call \cs{x} to perform the new definition.
% \begin{macrocode}
\x
}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\addtoiargdef}
% \begin{macro}{\addtoiargdef*}
% \begin{macro}{\wo@daddtoiargdef}
% This adds stuff at the start and/or end of a macro that takes one argument.
% It is a modification of Michael Downes' appending
% code\footnote{Posted to \ctt{} on 15~June 2000,\\
% URL: \url{http://www.dejanews.com/getdoc.xp?AN=635057844}.}
% which was:
% \begin{small}\begin{verbatim}
% \def\appendef#1#2{%
% \begingroup
% \toks@\expandafter{#1{##1}#2}%
% \edef\x{\endgroup \def\noexpand#1####1{\the\toks@}}%
% \x}
% \end{verbatim}
% \par\end{small}
%
% \begin{macrocode}
\def\addtoiargdef{\@star@or@long\wo@daddtoiargdef}
\long\def\wo@daddtoiargdef#1#2#3{%
\wo@difmacro@begingroup{#1}{%
\@temptokena{#2}%
\toks@\expandafter{#1{##1}#3}%
\edef\x{\endgroup
\l@ngrel@x\def\noexpand#1####1{\the\@temptokena \the\toks@}}%
\x
}%
}
% \end{macrocode}
% For the record, Heiko Oberdiek produced the following
% version\footnote{Posted to \ctt{} on 16~June 2000,\\
% URL: \url{http://www.dejanews.com/getdoc.xp?AN=635095381}.}
% which avoids the use of a token register.
% \begin{small}\begin{verbatim}
% \newcommand{\appendiargdef}[2]{%
% \long\expandafter\def\expandafter#1\expandafter
% ##\expandafter1\expandafter{#1{##1}#2}}
% \end{verbatim}
% \par\end{small}
%
% \end{macro}
% \end{macro}
% \end{macro}
%
% Continuing the saga, Michael came up with a pretty general solution for
% modifying a macro with any number (up to 9) of arguments which he
% sent to me on 2000/07/13; this became
% the \Lpack{patchcmd} package which is on CTAN. I'm sure that Michael
% would have given me permission to include it here if he had not tragically
% passed away in 2003. I miss his encouragement, advice, and skills.
%
% \begin{macro}{\patchcmd}
% \cs{patchcmd}\marg{macro}\marg{start-stuff}\marg{end-stuff} inserts
% \meta{start-stuff} at the beginning of the definition of \meta{macro}
% and \meta{end-stuff} at the end of the definition. \meta{macro}
% can have 0--9 arguments and be defined by \cs{newcommand} (and associates)
% or with \cs{DeclareRobustCommand}. For macros that use \cs{futurelet}
% (e.g., those with starred forms or optional arguments) only prepending
% works --- any non-empty \meta{end-stuff} will mess things up. \cs{patchcmd}
% does not work with macros that have delimited arguments.
% \changes{v1.618}{2005/09/05}{Added \cs{patchcmd}}
%
% \begin{macrocode}
%%%%%%%%%%%%%%%% Michael Downes' patchcmd 2000/07/31 v1.03 %%%%%%%%
\newcommand{\patchcommand}[1]{%
\expandafter\patchcmd@a\meaning#1??->@\@nil#1%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\patchcmd@a}
% \begin{macrocode}
\long\def\patchcmd@a#1#2#3->#4#5\@nil#6{%
\ifx @#4\relax \patchcmdError#6#1%
\expandafter\@gobbletwo % discard the other two arguments
\else
\if l#2\toks@{\patchcmd@e{}#6}% l in this position means \long
\else \toks@{\patchcmd@e*#6}% not \long
\fi
\patchcmd@b #3@#4#5 ? ? ? \@nil#6%
\expandafter\the\expandafter\toks@
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\patchcmd@b}
% \begin{macrocode}
\def\patchcmd@b#1:#2@#3#4 #5#6 #7 #8\@nil#9{%
\if \ifx @#7@\expandafter
\ifx\csname #6\endcsname#9T\else F\fi\else F\fi T%
\toks@\expandafter{\expandafter\patchcommand\csname #6 \endcsname}%
\else
\ifx @#2@% No arguments
\toks@\expandafter{\the\toks@ 0}%
\else
\patchcmd@c 0#2{\string##}0%
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\patchcmd@c}
% \begin{macrocode}
\def\patchcmd@c#1#2#3{%
\if\string###2% % yes it's a # token
\ifodd 0#31 % and it's followed by a number
\if 0#3\patchcmd@d#1\fi % number=0? then we're done
\else \patchcmd@d D% # not a number: must be a delimited arg
\fi
\else \patchcmd@d D% not a # token: must be a delmited arg
\fi
\patchcmd@c#3}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\patchcmd@d}
% \begin{macrocode}
\def\patchcmd@d#1{%
\if D#1%
%%% \PackageError{patchcmd}{Cannot change a macro that has
%%% delimited arguments}\@ehd
\@memerror{%
Cannot change a macro that has delimited arguments}{\@ehd}
\else
\toks@\expandafter{\the\toks@ #1}%
\fi
\begingroup
\aftergroup\@gobble
\let\patchcmd@c\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\patchcmd@e}
% \begin{macrocode}
\def\patchcmd@e#1#2#3#4#5{%
\begingroup
\edef\@##1{%
\@temptokena\noexpand\expandafter{%
\noexpand#2%
\ifnum#3>0 {####1}\ifnum#3>1 {####2}\ifnum#3>2 {####3}%
\ifnum#3>3 {####4}\ifnum#3>4 {####5}\ifnum#3>5 {####6}%
\ifnum#3>6 {####7}\ifnum#3>7 {####8}\ifnum#3>8 {####9}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi
##1%
}%
}
\@{#5}%
\edef\@##1{\endgroup
\noexpand\renewcommand#1\noexpand#2\ifcase#3 \else [#3]\fi
{##1\the\@temptokena}}%
\@{#4}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\patchcmdError}
% \begin{macrocode}
\long\def\patchcmdError#1#2{%
\begingroup
\toks@{Not redefinable}%
\ifcat\relax\noexpand#1% Is it a control sequence?
\begingroup
\let#1=?\ifx ?\relax % Is it "\relax"?
\endgroup % accept current value of \toks@
\else \endgroup
\if\ifx\relax#1u\else #2\fi u%
\toks@{Not defined}%
\fi
\fi
\fi
\edef\@{\endgroup
%%% \noexpand\PackageError{patchcmd}{%
%%% \the\toks@: \string#1}\noexpand\@ehd}%
\noexpand\@memerror{%
\the\toks@: \string#1}\noexpand\@ehd}%
\@}
%%%%%%%%%%%%%%%%%%%%% end of patchcmd code %%%%%%%%%%%%%%%%%%%%%%%%%%%
% \end{macrocode}
% \end{macro}
%
% Prevent later loading of the original \Lpack{patchcmd} package.
% \begin{macrocode}
%%\@memfakeusepackage{patchcmd}
% \end{macrocode}
%
% \changes{v1.61803398}{2009/07/18}{Added support for bidi}
% \subsection{Support for the bidi package (RTL typesetting)}
%
% The \Lpack{bidi} package (system) enables bidirectional typesetting.
% As part of
% being able to accomplish this it often needs to exchange, for example,
% \cs{leftskip} and \cs{rightskip} depending on whether it is setting
% left-to-right (LTR) or right-to-left (RTL). In the case of \Lpack{memoir}
% the initial \Lpack{bidi} system implementation used a \Lpack{bidimemoir}
% class developed by Vafa Khalighi. Now, with Vafa's help, the necessary
% changes have been incorporated in \Lpack{memoir}; the \Lpack{bidimemoir}
% class is no longer needed.
%
% \begin{macro}{\memRTLleftskip}
% \begin{macro}{\memRTLrightskip}
% \begin{macro}{\memRTLvleftskip}
% \begin{macro}{\memRTLvrightskip}
% \begin{macro}{\memRTLraggedright}
% \begin{macro}{\memRTLraggedleft}
% \begin{macro}{\memRTLmainraggedright}
% \begin{macro}{\memRTLmainraggedleft}
% These are the hooks required to support the \Lpack{bidi} package,
% plus some we added that \Lpack{bidi} can use. The idea behind the
% \cs{XmainraggedX} macros are documents fully in RTL mode, then it
% makes sense to have the raggedness of the header and footer
% reversed. By default they do what the normally do, but in main RTL
% mode, \Lpack{bidi} can redefine them to reverse the order of the
% headers, i.e. the `left' part of the header is typeset as the
% `right' part.
% \changes{v3.6h}{2010/10/22}{Added \cs{mem@RTLmainraggedX} macros}
% \changes{v3.6k}{2011/06/24}{the \cs{mem@RTLvX} macros should point
% at \cs{vX} not \cs{X}}
% \begin{macrocode}
\newcommand*{\memRTLleftskip}{\leftskip}
\newcommand*{\memRTLrightskip}{\rightskip}
\newcommand*{\memRTLvleftskip}{\vleftskip}
\newcommand*{\memRTLvrightskip}{\vrightskip}
\newcommand*{\memRTLraggedright}{\raggedright}
\newcommand*{\memRTLraggedleft}{\raggedleft}
\newcommand*{\memRTLmainraggedright}{\raggedright}
\newcommand*{\memRTLmainraggedleft}{\raggedleft}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% It is expected that the \Lpack{bidi} package will redefine these as:
% \begin{verbatim}
% \renewcommand*{\memRTLleftskip}{\if@RTL\rightskip\else\leftskip\fi}
% \renewcommand*{\memRTLrightskip}{\if@RTL\leftskip\else\rightskip\fi}
% \renewcommand*{\memRTLvleftskip}{\if@RTL\vrightskip\else\vleftskip\fi}
% \renewcommand*{\memRTLvrightskip}{\if@RTL\vleftskip\else\vrightskip\fi}
% \renewcommand*{\memRTLraggedright}{\if@RTL\raggedleft\else\raggedright\fi}
% \renewcommand*{\memRTLraggedleft}{\if@RTL\raggedright\else\raggedleft\fi}
% \renewcommand*{\memRTLmainraggedright}{\if@RTLmain\raggedleft\else\raggedright\fi}
% \renewcommand*{\memRTLmainraggedleft}{\if@RTLmain\raggedright\else\raggedleft\fi}
% \end{verbatim}
%
% \section{Declaration of Options} \label{sec:opt}
%
%
% \subsection{Setting Paper Sizes}
%
% The variables \cs{paperheight} and \cs{paperwidth} should reflect the
% physical paper size after trimming.
%
% Option \Lopt{letterpaper} will be the default.
%
% \begin{macro}{\stockheight}
% \begin{macro}{\stockwidth}
% \begin{macro}{\trimtop}
% \begin{macro}{\trimedge}
% The lengths \cs{stockheight} and \cs{stockwidth} should be the height and
% width of the stock sheet before trimming. For example, this is the
% physical size
% of a single sheet that might be laser-printed. The lengths \cs{trimtop}
% and \cs{trimedge} are the amount that will be trimmed off the top and fore
% edge of the physical sheet.
% For desk printer output the size of the trimmed sheet is often the
% same as the physical sheet. In other words the \cs{paper...} and \cs{stock...}
% sizes are the same and the trims are zero. This class assumes that this
% is the normal case.
% \changes{v3.7.19}{2022/10/28}{\cs{stockheight} and \cs{stockwidth}
% may now be defined in the kernel, so we test for that}
% \begin{macrocode}
\@ifundefined{stockwidth}{\newdimen{\stockheight}}{}
\@ifundefined{stockwidth}{\newdimen{\stockwidth}}{}
\newlength{\trimtop}
\newlength{\trimedge}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% The class provides an extended range of stock sizes. It may be useful at some
% point to have macros for these.
%
% \begin{macro}{\stockdbill}
% \begin{macro}{\stockstatement}
% \begin{macro}{\stockexecutive}
% \begin{macro}{\stockletter}
% \begin{macro}{\stockold}
% \begin{macro}{\stocklegal}
% \begin{macro}{\stockledger}
% \begin{macro}{\stockbroadsheet}
% US stock sizes.
% \changes{v1.61803}{2008/01/30}{Major expansion of stock size options}
% \begin{macrocode}
\newcommand*{\stockdbill} {\stockheight=7in \stockwidth=3in}
\newcommand*{\stockstatement} {\stockheight=8.5in \stockwidth=5.5in}
\newcommand*{\stockexecutive} {\stockheight=10.5in \stockwidth=7.25in}
\newcommand*{\stockletter} {\stockheight=11in \stockwidth=8.5in}
\newcommand*{\stockold} {\stockheight=12in \stockwidth=9in}
\newcommand*{\stocklegal} {\stockheight=14in \stockwidth=8.5in}
\newcommand*{\stockledger} {\stockheight=17in \stockwidth=11in}
\newcommand*{\stockbroadsheet}{\stockheight=22in \stockwidth=17in}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\stockpottvo}
% \begin{macro}{\stockfoolscapvo}
% \begin{macro}{\stockcrownvo}
% \begin{macro}{\stockpostvo}
% \begin{macro}{\stocklargecrownvo}
% \begin{macro}{\stocklargepostvo}
% \begin{macro}{\stocksmalldemyvo}
% Traditional British octavo sizes.
% \begin{macrocode}
\newcommand*{\stockpottvo} {\stockheight=6.25in \stockwidth=4in}
\newcommand*{\stockfoolscapvo} {\stockheight=6.75in \stockwidth=4.25in}
\newcommand*{\stockcrownvo} {\stockheight=7.5in \stockwidth=5in}
\newcommand*{\stockpostvo} {\stockheight=8in \stockwidth=5in}
\newcommand*{\stocklargecrownvo}{\stockheight=8in \stockwidth=5.25in}
\newcommand*{\stocklargepostvo} {\stockheight=8.25in \stockwidth=5.25in}
\newcommand*{\stocksmalldemyvo} {\stockheight=8.5in \stockwidth=5.675in}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\stockdemyvo}
% \begin{macro}{\stockmediumvo}
% \begin{macro}{\stocksmallroyalvo}
% \begin{macro}{\stockroyalvo}
% \begin{macro}{\stocksuperroyalvo}
% \begin{macro}{\stockimperialvo}
% \begin{macrocode}
\newcommand*{\stockdemyvo} {\stockheight=8.75in \stockwidth=5.675in}
\newcommand*{\stockmediumvo} {\stockheight=9in \stockwidth=5.75in}
\newcommand*{\stocksmallroyalvo}{\stockheight=9.25in \stockwidth=6.175in}
\newcommand*{\stockroyalvo} {\stockheight=10in \stockwidth=6.25in}
\newcommand*{\stocksuperroyalvo}{\stockheight=10.25in \stockwidth=6.75in}
\newcommand*{\stockimperialvo} {\stockheight=11in \stockwidth=7.5in}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\stockmcrownvo}
% \begin{macro}{\stockmlargecrownvo}
% \begin{macro}{\stockmdemyvo}
% \begin{macro}{\stockmsmallroyalvo}
% Metric stock sizes.
% \begin{macrocode}
\newcommand*{\stockmcrownvo} {\stockheight=186mm \stockwidth=123mm}
\newcommand*{\stockmlargecrownvo} {\stockheight=198mm \stockwidth=129mm}
\newcommand*{\stockmdemyvo} {\stockheight=216mm \stockwidth=138mm}
\newcommand*{\stockmsmallroyalvo} {\stockheight=234mm \stockwidth=156mm}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\stockao}
% \begin{macro}{\stockai}
% \begin{macro}{\stockaii}
% \begin{macro}{\stockaiii}
% \begin{macro}{\stockaiv}
% \begin{macro}{\stockav}
% \begin{macro}{\stockavi}
% \begin{macro}{\stockavii}
% The A series, A0 --- A7.
% \changes{v1.6180339c}{2008/12/26}{Extended the A and B stock/paper size
% seies with A/B0 through A/B6}
% \changes{v3.7i}{2019/11/04}{Added A7 stock}
% \begin{macrocode}
\newcommand*{\stockao} {\stockheight=1189mm \stockwidth=841mm}
\newcommand*{\stockai} {\stockheight=841mm \stockwidth=594mm}
\newcommand*{\stockaii} {\stockheight=594mm \stockwidth=420mm}
\newcommand*{\stockaiii}{\stockheight=420mm \stockwidth=297mm}
\newcommand*{\stockaiv} {\stockheight=297mm \stockwidth=210mm}
\newcommand*{\stockav} {\stockheight=210mm \stockwidth=148mm}
\newcommand*{\stockavi} {\stockheight=148mm \stockwidth=105mm}
\newcommand*{\stockavii}{\stockheight=105mm \stockwidth=74mm}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\stockbo}
% \begin{macro}{\stockbi}
% \begin{macro}{\stockbii}
% \begin{macro}{\stockbiii}
% \begin{macro}{\stockbiv}
% \begin{macro}{\stockbv}
% \begin{macro}{\stockbvi}
% \begin{macro}{\stockbvii}
% The B series, B0 --- B7.
% \changes{v3.7i}{2019/11/04}{added B7 stock}
% \begin{macrocode}
\newcommand*{\stockbo} {\stockheight=1414mm \stockwidth=1000mm}
\newcommand*{\stockbi} {\stockheight=1000mm \stockwidth=707mm}
\newcommand*{\stockbii} {\stockheight=707mm \stockwidth=500mm}
\newcommand*{\stockbiii}{\stockheight=500mm \stockwidth=353mm}
\newcommand*{\stockbiv} {\stockheight=353mm \stockwidth=250mm}
\newcommand*{\stockbv} {\stockheight=250mm \stockwidth=176mm}
\newcommand*{\stockbvi} {\stockheight=176mm \stockwidth=125mm}
\newcommand*{\stockbvii}{\stockheight=125mm \stockwidth=88mm}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% It will be useful also to provide macros that set the page sizes.
%
% \begin{macro}{\pagedbill}
% \begin{macro}{\pagestatement}
% \begin{macro}{\pageexecutive}
% \begin{macro}{\pageletter}
% \begin{macro}{\pageold}
% \begin{macro}{\pagelegal}
% \begin{macro}{\pageledger}
% \begin{macro}{\pagebroadsheet}
% \changes{v1.6180339c}{\cs{pageheight} and \cs{pagewidth} should be
% \cs{paperheight} and \cs{paperwidth}
% (courtesy Wilhelm Muller)}
% US page sizes.
% \begin{macrocode}
\newcommand*{\pagedbill} {\paperheight=7in \paperwidth=3in}
\newcommand*{\pagestatement} {\paperheight=8.5in \paperwidth=5.5in}
\newcommand*{\pageexecutive} {\paperheight=10.5in \paperwidth=7.25in}
\newcommand*{\pageletter} {\paperheight=11in \paperwidth=8.5in}
\newcommand*{\pageold} {\paperheight=12in \paperwidth=9in}
\newcommand*{\pagelegal} {\paperheight=14in \paperwidth=8.5in}
\newcommand*{\pageledger} {\paperheight=17in \paperwidth=11in}
\newcommand*{\pagebroadsheet}{\paperheight=22in \paperwidth=17in}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pagepottvo}
% \begin{macro}{\pagefoolscapvo}
% \begin{macro}{\pagecrownvo}
% \begin{macro}{\pagepostvo}
% \begin{macro}{\pagelargecrownvo}
% \begin{macro}{\pagelargepostvo}
% \begin{macro}{\pagesmalldemyvo}
% British traditional page sizes, octavo.
% \begin{macrocode}
\newcommand*{\pagepottvo} {\paperheight=6.25in \paperwidth=4in}
\newcommand*{\pagefoolscapvo} {\paperheight=6.75in \paperwidth=4.25in}
\newcommand*{\pagecrownvo} {\paperheight=7.5in \paperwidth=5in}
\newcommand*{\pagepostvo} {\paperheight=8in \paperwidth=5in}
\newcommand*{\pagelargecrownvo}{\paperheight=8in \paperwidth=5.25in}
\newcommand*{\pagelargepostvo} {\paperheight=8.25in \paperwidth=5.25in}
\newcommand*{\pagesmalldemyvo} {\paperheight=8.5in \paperwidth=5.675in}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pagedemyvo}
% \begin{macro}{\pagemediumvo}
% \begin{macro}{\pagesmallroyalvo}
% \begin{macro}{\pageroyalvo}
% \begin{macro}{\pagesuperroyalvo}
% \begin{macro}{\pageimperialvo}
% \begin{macrocode}
\newcommand*{\pagedemyvo} {\paperheight=8.75in \paperwidth=5.675in}
\newcommand*{\pagemediumvo} {\paperheight=9in \paperwidth=5.75in}
\newcommand*{\pagesmallroyalvo}{\paperheight=9.25in \paperwidth=6.175in}
\newcommand*{\pageroyalvo} {\paperheight=10in \paperwidth=6.25in}
\newcommand*{\pagesuperroyalvo}{\paperheight=10.25in \paperwidth=6.75in}
\newcommand*{\pageimperialvo} {\paperheight=11in \paperwidth=7.5in}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\pagemcrownvo}
% \begin{macro}{\pagemlargecrownvo}
% \begin{macro}{\pagemdemyvo}
% \begin{macro}{\pagemsmallroyalvo}
% Metric sizes.
% \begin{macrocode}
\newcommand*{\pagemcrownvo} {\paperheight=186mm \paperwidth=123mm}
\newcommand*{\pagemlargecrownvo} {\paperheight=198mm \paperwidth=129mm}
\newcommand*{\pagemdemyvo} {\paperheight=216mm \paperwidth=138mm}
\newcommand*{\pagemsmallroyalvo} {\paperheight=234mm \paperwidth=156mm}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pageao}
% \begin{macro}{\pageai}
% \begin{macro}{\pageaii}
% \begin{macro}{\pageaiii}
% \begin{macro}{\pageaiv}
% \begin{macro}{\pageav}
% \begin{macro}{\pageavi}
% \begin{macro}{\pageavii}
% The A series, A0 --- A7.
% \changes{v3.7i}{2019/11/04}{added A7 paper}
% \begin{macrocode}
\newcommand*{\pageao} {\paperheight=1189mm \paperwidth=841mm}
\newcommand*{\pageai} {\paperheight=841mm \paperwidth=594mm}
\newcommand*{\pageaii} {\paperheight=594mm \paperwidth=420mm}
\newcommand*{\pageaiii}{\paperheight=420mm \paperwidth=297mm}
\newcommand*{\pageaiv} {\paperheight=297mm \paperwidth=210mm}
\newcommand*{\pageav} {\paperheight=210mm \paperwidth=148mm}
\newcommand*{\pageavi} {\paperheight=148mm \paperwidth=105mm}
\newcommand*{\pageavii}{\paperheight=105mm \paperwidth=74mm}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pagebo}
% \begin{macro}{\pagebi}
% \begin{macro}{\pagebii}
% \begin{macro}{\pagebiii}
% \begin{macro}{\pagebiv}
% \begin{macro}{\pagebv}
% \begin{macro}{\pagebvi}
% \begin{macro}{\pagebvii}
% The B series, B0 --- B7.
% \changes{v3.7i}{2019/11/04}{Added B7 paper}
% \begin{macrocode}
\newcommand*{\pagebo} {\paperheight=1414mm \paperwidth=1000mm}
\newcommand*{\pagebi} {\paperheight=1000mm \paperwidth=707mm}
\newcommand*{\pagebii} {\paperheight=707mm \paperwidth=500mm}
\newcommand*{\pagebiii}{\paperheight=500mm \paperwidth=353mm}
\newcommand*{\pagebiv} {\paperheight=353mm \paperwidth=250mm}
\newcommand*{\pagebv} {\paperheight=250mm \paperwidth=176mm}
\newcommand*{\pagebvi} {\paperheight=176mm \paperwidth=125mm}
\newcommand*{\pagebvii}{\paperheight=125mm \paperwidth=88mm}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Declare the stock size options.
%
% Metric paper stock sizes.
% \changes{v1.6180339c}{2008/12/26}{Extended class options to include stock
% sizes A0, A1, A2, B0, B1 and B2}
% \changes{v3.7i}{2019/11/04}{Added a7paper and b7paper options}
% \begin{macrocode}
\DeclareOption{a0paper}{\stockao}
\DeclareOption{a1paper}{\stockai}
\DeclareOption{a2paper}{\stockaii}
\DeclareOption{a3paper}{\stockaiii}
\DeclareOption{a4paper}{\stockaiv}
\DeclareOption{a5paper}{\stockav}
\DeclareOption{a6paper}{\stockavi}
\DeclareOption{a7paper}{\stockavii}
\DeclareOption{b0paper}{\stockbo}
\DeclareOption{b1paper}{\stockbi}
\DeclareOption{b2paper}{\stockbii}
\DeclareOption{b3paper}{\stockbiii}
\DeclareOption{b4paper}{\stockbiv}
\DeclareOption{b5paper}{\stockbv}
\DeclareOption{b6paper}{\stockbvi}
\DeclareOption{b7paper}{\stockbvii}
\DeclareOption{mcrownvopaper}{\stockmcrownvo}
\DeclareOption{mlargecrownvopaper}{\stockmlargecrownvo}
\DeclareOption{mdemyvopaper}{\stockmdemyvo}
\DeclareOption{msmallroyalvopaper}{\stockmsmallroyalvo}
% \end{macrocode}
% US paper stock sizes.
% \begin{macrocode}
\DeclareOption{dbillpaper}{\stockdbill}
\DeclareOption{statementpaper}{\stockstatement}
\DeclareOption{executivepaper}{\stockexecutive}
\DeclareOption{letterpaper}{\stockletter}
\DeclareOption{oldpaper}{\stockold}
\DeclareOption{legalpaper}{\stocklegal}
\DeclareOption{ledgerpaper}{\stockledger}
\DeclareOption{broadsheetpaper}{\stockbroadsheet}
% \end{macrocode}
% British octavo stock paper sizes.
% \begin{macrocode}
\DeclareOption{pottvopaper}{\stockpottvo}
\DeclareOption{foolscapvopaper}{\stockfoolscapvo}
\DeclareOption{crownvopaper}{\stockcrownvo}
\DeclareOption{postvopaper}{\stockpostvo}
\DeclareOption{largecrownvopaper}{\stocklargecrownvo}
\DeclareOption{largepostvopaper}{\stocklargepostvo}
\DeclareOption{smalldemyvopaper}{\stocksmalldemyvo}
\DeclareOption{demyvopaper}{\stockdemyvo}
\DeclareOption{mediumvopaper}{\stockmediumvo}
\DeclareOption{smallroyalvopaper}{\stocksmallroyalvo}
\DeclareOption{royalvopaper}{\stockroyalvo}
\DeclareOption{superroyalvopaper}{\stocksuperroyalvo}
\DeclareOption{imperialvopaper}{\stockimperialvo}
% \end{macrocode}
% Ebook.
% \begin{macrocode}
\DeclareOption{ebook}
{\setlength\stockheight {9in}%
\setlength\stockwidth {6in}}
% \end{macrocode}
%
% The \Lopt{landscape} option switches the values of the height and width,
% assuming that the dimensions were originally given for portrait
% orientation. (At the suggestion of Wilhelm M\"{u}ller made this independent
% of the option sequence).
% \changes{v1.6180339c}{2008/12/26}{`Stabilised' the landscape option and
% added a portrait option}.
% \begin{macro}{\ifmemlandscape}
% \begin{macro}{\memlandscapetrue}
% \begin{macro}{\memlandscapefalse}
% \begin{macrocode}
\newif\ifmemlandscape
\memlandscapefalse
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
\DeclareOption{landscape}{\memlandscapetrue}
\DeclareOption{portrait}{\memlandscapefalse}
% \end{macrocode}
%
%
% \subsection{Choosing the type size}
%
% The type size options are handled by defining \cs{@ptsize} to contain
% the last digit of the size in question and branching on \cs{ifcase}
% statements. This is done for historical reasons to stay compatible
% with other packages that use the \cs{@ptsize} variable to select
% special actions. It makes the declarations of size options less
% than 10pt or more than 20pt difficult. In this class \texttt{9} is used
% for the \Lopt{9pt} option, assuming that the class will never define a
% \Lopt{19pt} option. For larger options the full complement of digits
% are used.
%
% In any event, \cs{@memptsize} holds the complete size.
%
% Option \Lopt{10pt} will be the default.
% \changes{v1.2}{2002/07/07}{Added 17pt option}
% \changes{v1.61803}{2008/01/30}{Added pt options 20 to 60.}
% \changes{v1.61803}{2008/01/30}{Used \cs{@memptsize}}
% \begin{macrocode}
\renewcommand*{\@ptsize}{0}
\renewcommand*{\@memptsize}{10}
\DeclareOption{9pt}{\renewcommand*{\@ptsize}{9}\renewcommand*{\@memptsize}{9}}
\DeclareOption{10pt}{\renewcommand*{\@ptsize}{0}\renewcommand*{\@memptsize}{10}}
\DeclareOption{11pt}{\renewcommand*{\@ptsize}{1}\renewcommand*{\@memptsize}{11}}
\DeclareOption{12pt}{\renewcommand*{\@ptsize}{2}\renewcommand*{\@memptsize}{12}}
\DeclareOption{14pt}{\renewcommand*{\@ptsize}{4}\renewcommand*{\@memptsize}{14}}
\DeclareOption{17pt}{\renewcommand*{\@ptsize}{7}\renewcommand*{\@memptsize}{17}}
\DeclareOption{20pt}{\renewcommand*{\@ptsize}{20}\renewcommand*{\@memptsize}{20}}
\DeclareOption{25pt}{\renewcommand*{\@ptsize}{25}\renewcommand*{\@memptsize}{25}}
\DeclareOption{30pt}{\renewcommand*{\@ptsize}{30}\renewcommand*{\@memptsize}{30}}
\DeclareOption{36pt}{\renewcommand*{\@ptsize}{36}\renewcommand*{\@memptsize}{36}}
\DeclareOption{48pt}{\renewcommand*{\@ptsize}{48}\renewcommand*{\@memptsize}{48}}
\DeclareOption{60pt}{\renewcommand*{\@ptsize}{60}\renewcommand*{\@memptsize}{60}}
% \end{macrocode}
%
% \begin{macro}{\if@nyptsizeopt}
% \begin{macro}{\@nyptsizeopttrue}
% \begin{macro}{\@nyptsizeoptfalse}
% \begin{macro}{\anyptfilebase}
% \begin{macro}{\anyptsize}
% For any point size:
% \changes{v1.61803}{2008/02/29}{Added *pt option}
% \begin{macrocode}
\newif\if@nyptsizeopt
\@nyptsizeoptfalse
\providecommand*{\anyptfilebase}{mem}
\providecommand*{\anyptsize}{10}
\DeclareOption{*pt}{\@nyptsizeopttrue}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Two-side or one-side printing}
%
% For two-sided printing we use the switch \cs{if@twoside}. In
% addition we have to set the \cs{if@mparswitch} to get any margin
% paragraphs into the outside margin. The default is \Lopt{twoside}.
% \begin{macro}{\if@twoside}
% \begin{macro}{\if@mparswitch}
% \begin{macrocode}
\DeclareOption{twoside}{\@twosidetrue \@mparswitchtrue}
\DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Two column printing}
%
% Two-column and one-column printing is again realized via a switch
% which is defined in the kernel. The default is single column printing.
%
% \begin{macro}{\if@twocolumn}
% \begin{macrocode}
\DeclareOption{onecolumn}{\@twocolumnfalse}
\DeclareOption{twocolumn}{\@twocolumntrue}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{The \Lopt{draft} option}
%
% If the user requests \Lopt{draft} we show any overfull boxes,
% marginal notes are allowed, and any copyright notices are not
% printed. For symmetry, we also define a \Lopt{final} option
% which is the default.
%
% The user can use the \cs{ifdraftdoc} flag to add additional effects: \\
% \verb?\ifdraftdoc <additional code> \fi?
% \begin{macro}{\ifdraftdoc}
% \begin{macrocode}
\newif\ifdraftdoc\draftdocfalse
\setlength{\overfullrule}{\z@}
\DeclareOption{final}{\setlength{\overfullrule}{\z@}
\draftdocfalse
\msdocfalse}
\DeclareOption{draft}{\setlength\overfullrule{5pt}%
\draftdoctrue
\msdocfalse}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \Lopt{ms} option}
%
% \begin{macro}{\ifmsdoc}
% The \Lopt{ms} option makes the document look as though it was produced
% on a typewriter. We use a flag for remembering this. The user may also
% use the flag for specifying \Lopt{ms} effects.
% \begin{macrocode}
\newif\ifmsdoc
\msdocfalse
\DeclareOption{ms}{%
\msdoctrue
\draftdocfalse
\setlength\overfullrule{\z@}
}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \Lopt{showtrims} option}
%
% The \Lopt{showtrims} option will display crosses at the corners
% of the logical pages showing where the stock should be trimmed.
%
% \begin{macro}{\ifshowtrims}
% \begin{macrocode}
\newif\ifshowtrims
\showtrimsfalse
\DeclareOption{showtrims}{\showtrimstrue}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \Lopt{article} option}
%
% The \Lopt{article} option typesets as a simulation of the
% \Lpack{article} class.
% \changes{v0.3}{2001/07/09}{Added article option}
% \begin{macro}{\ifartopt}
% \cs{ifartopt} is a flag (TRUE) if the \Lopt{article} option is called.
% \begin{macrocode}
\newif\ifartopt
\artoptfalse
\DeclareOption{article}{\artopttrue}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \Lopt{subfigure} option}
%
% The \Lopt{subfigure} option has been made a no-op since version 1.1
% and finally removed in version 1.61803. It was:
% \changes{v0.3}{2001/07/09}{Added subfigure option}
% \changes{v1.1}{2002/03/10}{Effectively removed subfigure option}
% \changes{v1.61803}{2008/01/30}{Removed subfigure option}
% \begin{verbatim}
% \DeclareOption{subfigure}{%
% \ClassWarningNoLine{memoir}{The subfigure option is not required}}
% \end{verbatim}
%
% \subsection{The openright, openleft and openany options}
%
% The \Lopt{openright} option specifies that Chapters must begin on
% recto pages. The \Lopt{openleft} option specifies that Chapters
% must begin on verso pages and the \Lopt{openany} option lets Chapters
% start on any page.
% \changes{v1.0}{2001/10/24}{Added the openleft option}
% \begin{macrocode}
\DeclareOption{openright}{\@openrighttrue}
\DeclareOption{openany}{\@openrightfalse}
\DeclareOption{openleft}{\@openlefttrue}
% \end{macrocode}
%
% \begin{macro}{\openright}
% \begin{macro}{\openany}
% \begin{macro}{\openleft}
% Commands that can be used to change the option in the middle of the
% document\footnote{Openleft provided to meet a request by
% Vladimir G.~Ivanovic (\texttt{vladimir@acm.org}) in September 2001.}.
% \begin{macrocode}
\newcommand{\openright}{\@openrighttrue\@openleftfalse%
\gdef\clearforchapter{\cleartorecto}}
\newcommand{\openany}{\@openrightfalse\@openleftfalse%
\gdef\clearforchapter{\clearpage}}
\newcommand{\openleft}{\@openlefttrue
\gdef\clearforchapter{\cleartoverso}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Equation numbering on the left}
%
% The \Lopt{leqno} option prints equation numbers on the left. This
% is implemented via an external class option file.
% \begin{macrocode}
\DeclareOption{leqno}{\input{leqno.clo}}
% \end{macrocode}
%
% \subsection{Flush left math displays}
%
% The \Lopt{fleqn} option redefines the displayed math environments
% so that they are left adjusted with an indent of \cs{mathindent}
% from the current left margin. This
% is implemented via an external class option file.
% \begin{macrocode}
\DeclareOption{fleqn}{\input{fleqn.clo}}
% \end{macrocode}
%
% \subsection{Open bibliography}
%
% The \Lopt{openbib} option redefines the \verb?thebibliography? so that each
% block starts on a new line, and succeeding lines in a block are
% indented by \cs{bibindent}.
% \changes{v1.0a}{2001/11/28}{Replaced \cs{AtEndOfPackage} with \cs{AtEndOfClass}}
% \begin{macrocode}
\DeclareOption{openbib}{%
\AtEndOfClass{%
\renewcommand\@openbib@code{%
\advance\leftmargin\bibindent
\itemindent -\bibindent
\listparindent \itemindent
\parsep \z@
}%
\renewcommand\newblock{\par}}}
% \end{macrocode}
%
% \subsection{Old font commands}
%
% The \Lopt{oldfontcommands} option enables commands like \cs{bf} and friends.
% \changes{v1.0a}{2002/01/29}{Added the oldfontcommands option}
% \begin{macrocode}
\DeclareOption{oldfontcommands}{\@memoldfonttrue}
% \end{macrocode}
%
% \subsection{Extra font sizes}
%
% The \Lopt{extrafontsizes} options indicates that extended font sizes (above 25pt)
% are available.
% \changes{v1.61803}{2008/01/30}{Added extrafontsizes option.}
% \begin{macrocode}
\DeclareOption{extrafontsizes}{\extrafontsizestrue}
% \end{macrocode}
%
% \subsection{The \Lopt{fullptlayout} option}
% \changes{v3.7g}{2018/03/09}{Added the \Lopt{fullptlayout} option}
% \begin{macro}{\mem@settopoint}
% By default the class will truncate some layout lengths to a whole
% number of points.\footnote{Presumably because it looks better when
% the layout is written to the log.} This might not be desirable, so the
% \Lopt{fullptlayout} class option disables this truncation.
% \begin{macrocode}
\newcommand\mem@settopoint[1]{\@settopoint{#1}}
\DeclareOption{fullptlayout}{\renewcommand\mem@settopoint{\@gobble}}
% \end{macrocode}
% \end{macro}
%
%
% \changes{v1.6180339f}{2009/07/12}{Added dead man switch for etex}
% \subsection{ETeX}
%
% If found we automatically load the eTeX package right after
% executing the class options. Though, some odd \LaTeX\ installations
% may have the eTeX pacakge, but is not based on eTeX (eventhough that
% is what the LaTeX-project have recommended for several years now),
% so we add a dead mans switch to disable the loading.
%
% \medskip\noindent
% Update 2015: Since the 2015 LaTeX kernel automatically takes care of
% allocating extra registers, the \Lpack{etex} package is no longer
% needed with newer kernels. Therefore automatic loading \Lpack{etex}
% now only happen if the kernel is pre 2015.
% \begin{macro}{\ifmem@noetex}
% \begin{macro}{\mem@noetextrue}
% \begin{macro}{\mem@noetexfalse}
% \begin{macrocode}
\newif\ifmem@noetex
\mem@noetexfalse
\DeclareOption{noetex}{\mem@noetextrue}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \section{Executing Options} \label{sec:xopt}
%
% Here we execute the default options to initialize certain
% variables.
% \begin{macrocode}
\ExecuteOptions{final,letterpaper,10pt,onecolumn,openright,twoside,
portrait}
% \end{macrocode}
%
% The \cs{ProcessOptions} command causes the execution of the code
% for every option \Lopt{foo}
% which is declared and for which the user typed
% the \Lopt{foo} option in his
% \cs{documentclass} command. For every option \Lopt{bar} he typed,
% which is not declared, the option is assumed to be a global option.
% All options will be passed as document options to any
% \cs{usepackage} command in the document preamble.
%
% \cs{ProcessOptions*} processes the options in the order they are given
% in the \cs{documentclass} command, instead of the definition order.
% \changes{v1.6180339c}{2008/12/26}{Change \cs{ProcessOptions} to
% \cs{ProcessOptions*} and handle landscape/portrait
% option after \cs{ProcessOptions*}}
% \begin{macrocode}
\ProcessOptions*
\ifmemlandscape
\setlength\@tempdima {\stockheight}
\setlength\stockheight{\stockwidth}
\setlength\stockwidth {\@tempdima}
\fi
% \end{macrocode}
% Load the eTeX package if found, and if the user has not explicitly
% asked us not to.
%
% \medskip\noindent
% Update 2015: Since 2015 the LaTeX kernel automatically
% allocate extra registers, thus that part of the \Lpack{etex}
% package is no longer needed for newer \LaTeX\ kernels. At the
% request of the LaTeX Team, we now only load \Lpack{etex} on older
% kernels.
% \changes{v3.7e}{2015/07/08}{Only load \Lpack{etex} on older kernels}
% \begin{macrocode}
\ifmem@noetex\relax\else
\ifx\e@alloc\@undefined
\IfFileExists{etex.sty}{\RequirePackage{etex}}{}
\fi
\fi
% \end{macrocode}
% \begin{macro}{\memoirpostopthook}
% A user could define this \emph{before} the \cs{documentclass} command
% to do something at this point. For example, to set up a new stock size: \\
% \verb?\def\memoirpostopthook{\stockheight=44in \stockwidth=34in}?
% \changes{v1.618033}{2008/06/02}{Added \cs{memoirpostopthook}}
% \begin{macrocode}
\providecommand*{\memoirpostopthook}{}
\memoirpostopthook
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cleartorecto}
% A repeat of \cs{cleardoublepage}; clears to a recto (odd-numbered) page.
% \begin{macrocode}
\def\cleartorecto{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}\thispagestyle{cleared}%
\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cleartoverso}
% Clears to a verso (even-numbered) page.
% \begin{macrocode}
\def\cleartoverso{\clearpage\if@twoside
\ifodd\c@page\hbox{}\thispagestyle{cleared}%
\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
% \end{macrocode}
% \end{macro}
%
% Set \cs{clearforchapter} according to the options.
% \begin{macrocode}
\if@openleft
\openleft
\else
\if@openright
\openright
\else
\openany
\fi
\fi
% \end{macrocode}
%
% \begin{macro}{\@ivpt}
% \begin{macro}{\@xxxpt}
% \begin{macro}{\@xxxvipt}
% \begin{macro}{\@xlviiipt}
% \begin{macro}{\@lxpt}
% \begin{macro}{\@lxxiipt}
% \begin{macro}{\@lxxxivpt}
% \begin{macro}{\@xcvipt}
% \begin{macro}{\@cviiipt}
% \begin{macro}{\@cxxpt}
% \begin{macro}{\@cxxxiipt}
% \changes{v1.61803}{2008/01/30}{Added a bunch of \cs{@...pt} macros}
% \begin{macrocode}
\newcommand*{\@ivpt}{4}
\newcommand*{\@xxxpt}{30}
\newcommand*{\@xxxvipt}{36}
\newcommand*{\@xlviiipt}{48}
\newcommand*{\@lxpt}{60}
\newcommand*{\@lxxiipt}{72}
\newcommand*{\@lxxxivpt}{84}
\newcommand*{\@xcvipt}{96}
\newcommand*{\@cviiipt}{108}
\newcommand*{\@cxxpt}{120}
\newcommand*{\@cxxxiipt}{132}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Now that all the options have been executed we can load the
% chosen class option file that contains all size dependent code. The
% larger sizes are only made available for the \Lopt{extrafontsizes} option.
%
% \begin{macro}{\memfontfamily}
% \begin{macro}{\memfontenc}
% \begin{macro}{\memfontpack}
% The default font and coding as set by the kernel is \texttt{cmr} and
% \texttt{OT1} respectively, giving Knuth's original Computer Modern Roman
% font at a set of fixed sizes (maximum of 24.88pt). If we are to have
% any size font we have to go to a scaleable font. As the Latin Modern font
% is a scaleable version of Computer Modern, and all modern LaTeX distributions
% include it, I am using this by default.
%
% By defining these three macros \emph{before}
% the \cs{documentclass} any other font and package can be used.
% \begin{macrocode}
\providecommand*{\memfontfamily}{lmr}
\providecommand*{\memfontenc}{T1}
\providecommand*{\memfontpack}{lmodern}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Deal with the `anyptsize' (\Lopt{*pt}) option first. In this case the macros
% \cs{anyptfilebase} and \cs{anyptsize} should have been defined by the
% author \emph{before} the \cs{documentclass} command, and a file \\
% \verb?\anyptfilebase\anyptsize.clo? should exist (if not the file will
% default to \verb?mem10.clo?).
% \changes{v1.61803}{2008/01/30}{Extended the loading of \texttt{.clo} files.}
% \begin{macrocode}
\if@nyptsizeopt
\newcommand*{\@nyptclofile}{\anyptfilebase\anyptsize.clo}
\IfFileExists{\@nyptclofile}{\def\@memptsize{\anyptsize}}{%
\@memerror{You have used the `*pt' option but \MessageBreak
file \@nyptclofile\space can't be found}%
{I'll use mem10.clo instead}
\renewcommand*{\@nyptclofile}{mem10.clo}%
\def\@memptsize{10}%
}
\renewcommand*{\@ptsize}{\@memptsize}
\usefont{\memfontenc}{\memfontfamily}{m}{n}
\input{\@nyptclofile}
\usepackage{\memfontpack}\usepackage[\memfontenc]{fontenc}
\else
% \end{macrocode}
% Now for the fixed pt size options.
% \begin{macrocode}
\ifextrafontsizes
\usefont{\memfontenc}{\memfontfamily}{m}{n}
\input{mem\@memptsize.clo}
\usepackage{\memfontpack}\usepackage[\memfontenc]{fontenc}
\else
\ifnum\@memptsize > 17\relax
\@memerror{The `extrafontsizes' option is required to use \MessageBreak
the `\@memptsize pt' option}%
{The 17pt option will be used instead}
\input{mem17.clo}
\else
\ifnum\@ptsize = 9\relax
\input{mem\@ptsize.clo}
\else
\input{mem1\@ptsize.clo}
\fi
\fi
\fi
\fi
%</class>
% \end{macrocode}
%
%
% \section{Fonts and spaces} \label{sec:docl}
% \label{sec:maincode}
%
% In this section we deal with most of the aspects that are related
% to font sizes, and spacing that is related to the size of the body font.
%
% \subsection{Fonts}
%
% \LaTeX\ offers the user commands to change the size of the font,
% relative to the `main' size. Each relative size changing command
% \cs{size} executes the command
% \verb?\@setfontsize\size? \meta{font-size} \meta{baselineskip} where:
%
% \begin{description}
% \item[\meta{font-size}] The absolute size of the font to use from
% now on.
%
% \item[\meta{baselineskip}] The normal value of \cs{baselineskip}
% for the size of the font selected. (The actual value will be
% \cs{baselinestretch} * \meta{baselineskip}.)
% \end{description}
%
% A number of commands, defined in the \LaTeX\ kernel, shorten the
% following definitions and are used throughout. They are listed in
% the first part of Table~\ref{tab:sh}. Those in the second part are introduced
% by the class.
%
% \begin{table}
% \centering
% \caption{Shorthand font point size commands}\label{tab:sh}
% \begin{tabular}{ll@{\qquad}ll@{\qquad}ll} \hline
% & & & & \cs{@ivpt} & 4 \\
% \cs{@vpt} & 5 & \cs{@vipt} & 6 & \cs{@viipt} & 7 \\
% \cs{@viiipt} & 8 & \cs{@ixpt} & 9 & \cs{@xpt} & 10 \\
% \cs{@xipt} & 10.95 & \cs{@xiipt} & 12 & \cs{@xivpt} & 14.4\\
% \cs{@xviipt} & 17.28 & \cs{@xxpt} & 20.74 & \cs{@xxvpt} & 24.88\\ \hline
% \cs{@xxxpt} & 30 & \cs{@xxxvipt} & 36 & \cs{@xlviiipt} & 48 \\
% \cs{@lxpt} & 60 & \cs{@lxxiipt} & 72 & \cs{@lxxxivpt} & 84 \\
% \cs{@xcvipt} & 96 & \cs{@cviiipt} & 108 & \cs{@cxxpt} & 120 \\
% \cs{@cxxxiipt} & 132 \\ \hline
% \end{tabular}
% \end{table}
%
% \begin{macro}{\normalsize}
% \begin{macro}{\@normalsize}
%
% The user level command for the main size is \cs{normalsize}.
% Internally \LaTeX\ uses \cs{@normalsize} when it refers to the
% main size. \cs{@normalsize} will be defined to work like
% \cs{normalsize} if the latter is redefined from its default
% definition (that just issues an error message). Otherwise, in the standard
% classes \cs{@normalsize} simply selects a 10pt/12pt size, but here
% it selects among the wider range.
%
% The \cs{normalsize} macro also sets new values for\\
% \cs{abovedisplayskip}, \cs{abovedisplayshortskip} and
% \cs{belowdisplayshortskip}.
%
% For the larger sizes I have set \cs{abovedisplayskip} to the font size
% and \cs{belowdisplayshortskip} to 0.5\cs{onelineskip}.
%
% \begin{macrocode}
%<*9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
% \end{macrocode}
% \changes{v0.11 (mem14.clo)}{2001/10/30}{Changed baseline skip from 17.28pt to 17.5pt}
% \changes{v1.61803}{2008/01/30}{Added files mem20.clo through mem60.clo}
% \changes{v1.61803}{2008/01/30}{Changed .clo files to accomodate \cs{extrafontsizes}}
% \begin{macrocode}
\renewcommand{\normalsize}{%
%<*9pt>
\@setfontsize\normalsize\@ixpt\@xpt
\abovedisplayskip 9\p@ \@plus 2\p@ \@minus 4.5\p@
\abovedisplayshortskip \z@ \@plus 3\p@
\belowdisplayshortskip 5.5\p@ \@plus 2.5\p@ \@minus 3\p@
%</9pt>
%<*10pt>
\@setfontsize\normalsize\@xpt\@xiipt
\abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
%</10pt>
%<*11pt>
\@setfontsize\normalsize\@xipt{13.6}%
\abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
%</11pt>
%<*12pt>
\@setfontsize\normalsize\@xiipt{14.5}%
\abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
%</12pt>
%<*14pt>
\@setfontsize\normalsize\@xivpt{17.5}%
\abovedisplayskip 14\p@ \@plus3\p@ \@minus8\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 7\p@ \@plus3.5\p@ \@minus3\p@
%</14pt>
%<*17pt>
\@setfontsize\normalsize\@xviipt{22}%
\abovedisplayskip 15\p@ \@plus4\p@ \@minus8\p@
\abovedisplayshortskip \z@ \@plus4\p@
\belowdisplayshortskip 8\p@ \@plus4\p@ \@minus3\p@
%</17pt>
%<*20pt>
\@setfontsize\normalsize\@xxpt{25}%
\abovedisplayskip 20\p@ \@plus5\p@ \@minus9\p@
\abovedisplayshortskip \z@ \@plus5\p@
\belowdisplayshortskip 12.5\p@ \@plus6\p@ \@minus3\p@
%</20pt>
%<*25pt>
\@setfontsize\normalsize\@xxvpt{30}%
\abovedisplayskip 25\p@ \@plus6\p@ \@minus10\p@
\abovedisplayshortskip \z@ \@plus6\p@
\belowdisplayshortskip 15\p@ \@plus7.5\p@ \@minus4\p@
%</25pt>
%<*30pt>
\@setfontsize\normalsize\@xxxpt{37}%
\abovedisplayskip 30\p@ \@plus7\p@ \@minus11\p@
\abovedisplayshortskip \z@ \@plus7\p@
\belowdisplayshortskip 18\p@ \@plus9\p@ \@minus4\p@
%</30pt>
%<*36pt>
\@setfontsize\normalsize\@xxxvipt{45}%
\abovedisplayskip 36\p@ \@plus8\p@ \@minus12\p@
\abovedisplayshortskip \z@ \@plus8\p@
\belowdisplayshortskip 22\p@ \@plus11\p@ \@minus5\p@
%</36pt>
%<*48pt>
\@setfontsize\normalsize\@xlviiipt{60}%
\abovedisplayskip 48\p@ \@plus9\p@ \@minus13\p@
\abovedisplayshortskip \z@ \@plus9\p@
\belowdisplayshortskip 30\p@ \@plus15\p@ \@minus7\p@
%</48pt>
%<*60pt>
\@setfontsize\normalsize\@lxpt{72}%
\abovedisplayskip 60\p@ \@plus10\p@ \@minus14\p@
\abovedisplayshortskip \z@ \@plus10\p@
\belowdisplayshortskip 36\p@ \@plus18\p@ \@minus9\p@
%</60pt>
% \end{macrocode}
% The \cs{belowdisplayskip} is always equal to the
% \cs{abovedisplayskip}. The parameters of the first level list are
% always given by \cs{@listI}.
% \begin{macrocode}
\belowdisplayskip \abovedisplayskip
\let\@listi\@listI}
% \end{macrocode}
%
% We initially choose the normalsize font.
% \begin{macrocode}
\normalsize
% \end{macrocode}
% \changes{v3.7r}{2022/07/26}{Make \cs{normalsize} robust in the same
% manner as in \file{size10.clo}}
% \begin{macrocode}
\ifx\MakeRobust\@undefined \else
\MakeRobust\normalsize
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\small}
% This code is similar to that for \cs{normalsize}.
% (Robert Schlicht\footnote{\texttt{w.m.l@gmx.net}, via email on 2004/03/11.}
% noted that in some cases \% signs were missing after \verb?\@setfontsize?).
%
% For the larger sizes I have set \cs{topsep} to 2/3\cs{onelineskip}
% and \cs{parsep} to 1/2\cs{topsep}.
% \changes{v1.61}{2004/03/12}{Added missing percent signs to some uses of
% \cs{@setfontsize}}
% \changes{v3.7r}{2022/07/26}{Make robust}
% \begin{macrocode}
\DeclareRobustCommand{\small}{%
%<*9pt>
\@setfontsize\small\@viiipt{9.5}%
\abovedisplayskip 6\p@ \@plus 2\p@ \@minus 4\p@
\abovedisplayshortskip \z@ \@plus 2\p@
\belowdisplayshortskip 4\p@ \@plus 2\p@ \@minus 2\p@
\def\@listi{\leftmargin\leftmargini
\topsep 2\p@ \@plus 2\p@ \@minus 2\p@
\parsep 1\p@ \@plus\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</9pt>
%<*10pt>
\@setfontsize\small\@ixpt{11}%
\abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@
\abovedisplayshortskip \z@ \@plus2\p@
\belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
\def\@listi{\leftmargin\leftmargini
\topsep 4\p@ \@plus2\p@ \@minus2\p@
\parsep 2\p@ \@plus\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</10pt>
%<*11pt>
\@setfontsize\small\@xpt\@xiipt
\abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 6\p@ \@plus2\p@ \@minus2\p@
\parsep 3\p@ \@plus2\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</11pt>
%<*12pt>
\@setfontsize\small\@xipt{13.6}%
\abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 9\p@ \@plus3\p@ \@minus5\p@
\parsep 4.5\p@ \@plus2\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</12pt>
%<*14pt>
\@setfontsize\small\@xiipt{14.5}%
\abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 11\p@ \@plus4\p@ \@minus6\p@
\parsep 6\p@ \@plus3\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</14pt>
%<*17pt>
\@setfontsize\small\@xivpt{17}%
\abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 7\p@ \@plus4\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 11\p@ \@plus4\p@ \@minus6\p@
\parsep 6\p@ \@plus3\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</17pt>
%<*20pt>
\@setfontsize\small\@xviipt{22}%
\abovedisplayskip 17\p@ \@plus4\p@ \@minus8\p@
\abovedisplayshortskip \z@ \@plus4\p@
\belowdisplayshortskip 11\p@ \@plus4\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 14\p@ \@plus5\p@ \@minus7\p@
\parsep 7\p@ \@plus2\p@ \@minus3\p@
\itemsep \parsep}%
%</20pt>
%<*25pt>
\@setfontsize\small\@xxpt{25}%
\abovedisplayskip 20\p@ \@plus5\p@ \@minus9\p@
\abovedisplayshortskip \z@ \@plus5\p@
\belowdisplayshortskip 12.5\p@ \@plus6\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 16\p@ \@plus5\p@ \@minus8\p@
\parsep 8\p@ \@plus3\p@ \@minus4\p@
\itemsep \parsep}%
%</25pt>
%<*30pt>
\@setfontsize\small\@xxvpt{30}%
\abovedisplayskip 25\p@ \@plus6\p@ \@minus10\p@
\abovedisplayshortskip \z@ \@plus6\p@
\belowdisplayshortskip 15\p@ \@plus7.5\p@ \@minus4\p@
\def\@listi{\leftmargin\leftmargini
\topsep 20\p@ \@plus7\p@ \@minus10\p@
\parsep 10\p@ \@plus4\p@ \@minus5\p@
\itemsep \parsep}%
%</30pt>
%<*36pt>
\@setfontsize\small\@xxxpt{37}%
\abovedisplayskip 30\p@ \@plus7\p@ \@minus11\p@
\abovedisplayshortskip \z@ \@plus7\p@
\belowdisplayshortskip 18\p@ \@plus9\p@ \@minus4\p@
\def\@listi{\leftmargin\leftmargini
\topsep 24\p@ \@plus8\p@ \@minus12\p@
\parsep 12\p@ \@plus4\p@ \@minus6\p@
\itemsep \parsep}%
%</36pt>
%<*48pt>
\@setfontsize\small\@xxxvipt{45}%
\abovedisplayskip 36\p@ \@plus8\p@ \@minus12\p@
\abovedisplayshortskip \z@ \@plus8\p@
\belowdisplayshortskip 22\p@ \@plus11\p@ \@minus5\p@
\def\@listi{\leftmargin\leftmargini
\topsep 30\p@ \@plus10\p@ \@minus15\p@
\parsep 15\p@ \@plus5\p@ \@minus7\p@
\itemsep \parsep}%
%</48pt>
%<*60pt>
\@setfontsize\small\@xlviiipt{60}%
\abovedisplayskip 48\p@ \@plus9\p@ \@minus13\p@
\abovedisplayshortskip \z@ \@plus9\p@
\belowdisplayshortskip 30\p@ \@plus15\p@ \@minus7\p@
\def\@listi{\leftmargin\leftmargini
\topsep 40\p@ \@plus13\p@ \@minus20\p@
\parsep 20\p@ \@plus6\p@ \@minus10\p@
\itemsep \parsep}%
%</60pt>
\belowdisplayskip \abovedisplayskip
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\footnotesize}
% This code is similar to that for \cs{small}.
% \changes{v3.7r}{2022/07/26}{Make robust}
% \begin{macrocode}
\DeclareRobustCommand{\footnotesize}{%
%<*9pt>
\@setfontsize\footnotesize\@viipt{8}%
\abovedisplayskip 6\p@ \@plus 2\p@ \@minus 4\p@
\abovedisplayshortskip \z@ \@plus 2\p@
\belowdisplayshortskip 4\p@ \@plus 2\p@ \@minus 2\p@
\def\@listi{\leftmargin\leftmargini
\topsep 2\p@ \@plus 2\p@ \@minus 2\p@
\parsep 1\p@ \@plus\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</9pt>
%<*10pt>
\@setfontsize\footnotesize\@viiipt{9.5}%
\abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@
\abovedisplayshortskip \z@ \@plus\p@
\belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@
\def\@listi{\leftmargin\leftmargini
\topsep 3\p@ \@plus\p@ \@minus\p@
\parsep 2\p@ \@plus\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</10pt>
%<*11pt>
\@setfontsize\footnotesize\@ixpt{11}%
\abovedisplayskip 8\p@ \@plus2\p@ \@minus4\p@
\abovedisplayshortskip \z@ \@plus\p@
\belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
\def\@listi{\leftmargin\leftmargini
\topsep 4\p@ \@plus2\p@ \@minus2\p@
\parsep 2\p@ \@plus\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</11pt>
%<*12pt>
\@setfontsize\footnotesize\@xpt\@xiipt
\abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 6\p@ \@plus2\p@ \@minus2\p@
\parsep 3\p@ \@plus2\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</12pt>
%<*14pt>
\@setfontsize\footnotesize\@xipt{13.6}%
\abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 6.5\p@ \@plus3.5\p@ \@minus3\p@
\parsep 4\p@ \@plus3\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</14pt>
%<*17pt>
\@setfontsize\footnotesize\@xiipt{14}%
\abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 6.5\p@ \@plus3.5\p@ \@minus3\p@
\parsep 4\p@ \@plus3\p@ \@minus\p@
\itemsep \parsep
%% \itemindent\z@
}%
%</17pt>
%<*20pt>
\@setfontsize\footnotesize\@xivpt{17.5}%
\abovedisplayskip 14\p@ \@plus3\p@ \@minus8\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 7\p@ \@plus3.5\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 12\p@ \@plus4\p@ \@minus6\p@
\parsep 6\p@ \@plus2\p@ \@minus3\p@
\itemsep \parsep}%
%</20pt>
%<*25pt>
\@setfontsize\footnotesize\@xviipt{22}%
\abovedisplayskip 17\p@ \@plus4\p@ \@minus8\p@
\abovedisplayshortskip \z@ \@plus4\p@
\belowdisplayshortskip 11\p@ \@plus4\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 14\p@ \@plus5\p@ \@minus7\p@
\parsep 7\p@ \@plus2\p@ \@minus3\p@
\itemsep \parsep}%
%</25pt>
%<*30pt>
\@setfontsize\footnotesize\@xxpt{25}%
\abovedisplayskip 20\p@ \@plus5\p@ \@minus9\p@
\abovedisplayshortskip \z@ \@plus5\p@
\belowdisplayshortskip 12.5\p@ \@plus6\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 16\p@ \@plus5\p@ \@minus8\p@
\parsep 8\p@ \@plus3\p@ \@minus4\p@
\itemsep \parsep}%
%</30pt>
%<*36pt>
\@setfontsize\footnotesize\@xxvpt{30}%
\abovedisplayskip 25\p@ \@plus6\p@ \@minus10\p@
\abovedisplayshortskip \z@ \@plus6\p@
\belowdisplayshortskip 15\p@ \@plus7.5\p@ \@minus4\p@
\def\@listi{\leftmargin\leftmargini
\topsep 20\p@ \@plus7\p@ \@minus10\p@
\parsep 10\p@ \@plus4\p@ \@minus5\p@
\itemsep \parsep}%
%</36pt>
%<*48pt>
\@setfontsize\footnotesize\@xxxpt{37}%
\abovedisplayskip 30\p@ \@plus7\p@ \@minus11\p@
\abovedisplayshortskip \z@ \@plus7\p@
\belowdisplayshortskip 18\p@ \@plus9\p@ \@minus4\p@
\def\@listi{\leftmargin\leftmargini
\topsep 24\p@ \@plus8\p@ \@minus12\p@
\parsep 12\p@ \@plus4\p@ \@minus6\p@
\itemsep \parsep}%
%</48pt>
%<*60pt>
\@setfontsize\footnotesize\@xxxvipt{45}%
\abovedisplayskip 36\p@ \@plus8\p@ \@minus12\p@
\abovedisplayshortskip \z@ \@plus8\p@
\belowdisplayshortskip 22\p@ \@plus11\p@ \@minus5\p@
\def\@listi{\leftmargin\leftmargini
\topsep 30\p@ \@plus10\p@ \@minus15\p@
\parsep 15\p@ \@plus5\p@ \@minus7\p@
\itemsep \parsep}%
%</60pt>
\belowdisplayskip \abovedisplayskip
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\miniscule}
% \begin{macro}{\scriptsize}
% \begin{macro}{\tiny}
% \begin{macro}{\large}
% \begin{macro}{\Large}
% \begin{macro}{\LARGE}
% \begin{macro}{\huge}
% \begin{macro}{\Huge}
% \begin{macro}{\HUGE}
% These are all much simpler than the previous macros, they just
% select a new fontsize, but leave the parameters for displays and
% lists alone. The class provides two additional sizes, \cs{miniscule}
% and \cs{HUGE}, with respect to the usual set. For the larger sizes (e.g.,
% 72pt and above) I have
% made the \cs{baselineskip} approximately 20 precent larger than the pt size.
% \changes{v1.2}{2002/07/27}{Added \cs{miniscule} and \cs{HUGE} font sizes}
% \changes{v1.2}{2002/07/27}{Twiddled some font sizes to get regular steps}
% \changes{v1.2a}{2002/08/27}{Fixed 12pt scriptsize bug}
% \changes{v3.7r}{2022/07/26}{Make robust}
% \begin{macrocode}
%<*9pt>
\ifextrafontsizes
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@ivpt{5}}
\else
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@vpt{6}}
\fi
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@vpt{6}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@vipt{7}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xpt{12}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@xipt{13.6}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xiipt{14.5}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@xivpt{18}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xviipt{22}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xxpt{25}}
%</9pt>
%<*10pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@vpt{6}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@vipt{7}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@viipt{8}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xipt{13.6}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@xiipt{14.5}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xivpt{18}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@xviipt{22}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xxpt{25}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xxvpt{30}}
%</10pt>
%<*11pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@vipt{7}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@viipt{8}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@viiipt{9.5}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xiipt{14.5}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@xivpt{18}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xviipt{22}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@xxpt{25}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xxvpt{30}}
\ifextrafontsizes
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xxxpt{37}}
\else
\let\HUGE=\Huge
\fi
%</11pt>
%<*12pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@viipt{8}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@viiipt{9.5}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@ixpt\@xpt}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xivpt{18}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@xviipt{22}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xxpt{25}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@xxvpt{30}}
\ifextrafontsizes
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xxxpt{37}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xxxvipt{45}}
\else
\let\Huge=\huge
\let\HUGE=\huge
\fi
%</12pt>
%<*14pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@viiipt{9.5}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@ixpt{10}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xpt{12}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xviipt{22}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@xxpt{25}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xxvpt{30}}
\ifextrafontsizes
\DeclareRobustCommand{\huge}{\@setfontsize\Huge\@xxxpt{37}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xxxvipt{45}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xlviiipt{60}}
\else
\let\huge=\LARGE
\let\Huge=\LARGE
\let\HUGE=\LARGE
\fi
%</14pt>
%<*17pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@ixpt{10}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xpt{12}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xipt{13.6}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xxpt{25}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@xxvpt{30}}
\ifextrafontsizes
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xxxpt{37}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@xxxvipt{45}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xlviiipt{60}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@lxpt{72}}
\else
\let\LARGE=\Large
\let\huge=\Large
\let\Huge=\Large
\let\HUGE=\Large
\fi
%</17pt>
%<*20pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xpt{12}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xipt{13.6}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xiipt{14.5}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xxvpt{30}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@xxxpt{37}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xxxvipt{45}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@xlviiipt{60}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@lxpt{72}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@lxxiipt{86}}
%</20pt>
%<*25pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xipt{13.6}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xiipt{14.5}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xivpt{17.5}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xxxpt{37}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@xxxvipt{45}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xlviiipt{60}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@lxpt{72}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@lxxiipt{86}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@lxxxivpt{100}}
%</25pt>
%<*30pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xiipt{14.5}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xivpt{17.5}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xviipt{22}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xxxvipt{45}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@xlviiipt{60}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@lxpt{72}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@lxxiipt{86}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@lxxxivpt{100}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@xcvipt{116}}
%</30pt>
%<*36pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xivpt{17.5}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xviipt{22}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xxpt{25}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@xlviiipt{60}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@lxpt{72}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@lxxiipt{86}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@lxxxivpt{100}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@xcvipt{116}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@cviiipt{132}}
%</36pt>
%<*48pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xviipt{22}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xxpt{25}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xxvpt{30}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@lxpt{72}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@lxxiipt{86}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@lxxxivpt{100}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@xcvipt{116}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@cviiipt{132}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@cxxpt{144}}
%</48pt>
%<*60pt>
\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@xxpt{25}}
\DeclareRobustCommand{\tiny}{\@setfontsize\tiny\@xxvpt{30}}
\DeclareRobustCommand{\scriptsize}{\@setfontsize\scriptsize\@xxxpt{37}}
\DeclareRobustCommand{\large}{\@setfontsize\large\@lxxiipt{86}}
\DeclareRobustCommand{\Large}{\@setfontsize\Large\@lxxxivpt{100}}
\DeclareRobustCommand{\LARGE}{\@setfontsize\LARGE\@xcvipt{116}}
\DeclareRobustCommand{\huge}{\@setfontsize\huge\@cviiipt{132}}
\DeclareRobustCommand{\Huge}{\@setfontsize\Huge\@cxxpt{144}}
\DeclareRobustCommand{\HUGE}{\@setfontsize\HUGE\@cxxxiipt{162}}
%</60pt>
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macrocode}
%</9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
%<*class>
% \end{macrocode}
%
% \begin{macro}{\captionsize}
% This internal command holds the font size for captions.
% \begin{macrocode}
\newcommand{\captionsize}{\normalsize}
% \end{macrocode}
% \end{macro}
%
% \subsection{Paragraphing}
%
% \begin{macro}{\lineskip}
% \begin{macro}{\normallineskip}
% These parameters control \TeX's behaviour when two lines tend to
% come too close together.
% \begin{macrocode}
\setlength\lineskip{1\p@}
\setlength\normallineskip{1\p@}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\baselinestretch}
% This is used as a multiplier for \cs{baselineskip}. The default is
% to \emph{not} stretch the baselines.
% \begin{macrocode}
\renewcommand{\baselinestretch}{}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\parskip}
% \begin{macro}{\onelineskip}
%
% \cs{parskip} is additional vertical space between paragraphs; default
% is zero.
%
%
% \cs{onelineskip} is the default space between baselines.
% \changes{v0.11 (mem14.clo)}{2001/10/30}{Changed \cs{onelineskip} from 17.28pt to 17.5pt}
% \begin{macrocode}
\setlength\parskip{0\p@ \@plus \p@}
%</class>
%<*9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
%<9pt>\setlength{\onelineskip}{\@xpt\p@}
%<10pt>\setlength{\onelineskip}{\@xiipt\p@}
%<11pt>\setlength{\onelineskip}{13.6\p@}
%<12pt>\setlength{\onelineskip}{14.5\p@}
%<14pt>\setlength{\onelineskip}{17.5\p@}
%<17pt>\setlength{\onelineskip}{22\p@}
%<20pt>\setlength{\onelineskip}{25\p@}
%<25pt>\setlength{\onelineskip}{30\p@}
%<30pt>\setlength{\onelineskip}{37\p@}
%<36pt>\setlength{\onelineskip}{45\p@}
%<48pt>\setlength{\onelineskip}{60\p@}
%<60pt>\setlength{\onelineskip}{72\p@}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\parindent}
% \cs{parskip} gives extra vertical space between paragraphs and
% \cs{parindent} is the width of the paragraph indentation.
% \begin{macrocode}
\if@twocolumn
\setlength\parindent{1em}
\else
%<9pt> \setlength\parindent{12\p@}
%<10pt> \setlength\parindent{15\p@}
%<11pt> \setlength\parindent{17\p@}
%<12pt> \setlength\parindent{1.5em}
%<14pt> \setlength\parindent{1.5em}
%<17pt> \setlength\parindent{1.5em}
%<20pt> \setlength\parindent{1.5em}
%<25pt> \setlength\parindent{1.5em}
%<30pt> \setlength\parindent{1.5em}
%<36pt> \setlength\parindent{1.5em}
%<48pt> \setlength\parindent{1.5em}
%<60pt> \setlength\parindent{1.5em}
\fi
%</9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\smallskipamount}
% \begin{macro}{\medskipamount}
% \begin{macro}{\bigskipamount}
% The values for these three parameters are set in the LaTeX kernel.
% Historically they have been size invariant, but I have changed them for
% the larger sizes (\cs{smallskipamount} is 1/4 the fontsize, and the others
% each double up on the next lower).
% \changes{v1.61803}{2008/01/30}{(small/med/big)skips not invraiant for larger font sizes.}
% \changes{v1.61803}{2008/01/30}{Changed (small/med/big)skips for 17pt}
% \begin{macrocode}
%<*9pt|10pt|11pt|12pt|14pt>
\setlength\smallskipamount{3\p@ \@plus 1\p@ \@minus 1\p@}
\setlength\medskipamount{6\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\bigskipamount{12\p@ \@plus 4\p@ \@minus 4\p@}
%</9pt|10pt|11pt|12pt|14pt>
%<*17pt|20pt|25pt|30pt|36pt|48pt|60pt>
%<*17pt>
\setlength\smallskipamount{4\p@ \@plus1\p@ \@minus1\p@}
\setlength\medskipamount{8\p@ \@plus2\p@ \@minus2\p@}
\setlength\bigskipamount{17\p@ \@plus4\p@ \@minus4\p@}
%</17pt>
%<*20pt>
\setlength\smallskipamount{5\p@ \@plus1\p@ \@minus1\p@}
\setlength\medskipamount{10\p@ \@plus2\p@ \@minus2\p@}
\setlength\bigskipamount{20\p@ \@plus4\p@ \@minus4\p@}
%</20pt>
%<*25pt>
\setlength\smallskipamount{6\p@ \@plus1\p@ \@minus1\p@}
\setlength\medskipamount{12\p@ \@plus2\p@ \@minus2\p@}
\setlength\bigskipamount{24\p@ \@plus4\p@ \@minus4\p@}
%</25pt>
%<*30pt>
\setlength\smallskipamount{5\p@ \@plus1\p@ \@minus1\p@}
\setlength\medskipamount{10\p@ \@plus2\p@ \@minus2\p@}
\setlength\bigskipamount{20\p@ \@plus4\p@ \@minus4\p@}
%</30pt>
%<*36pt>
\setlength\smallskipamount{9\p@ \@plus2\p@ \@minus2\p@}
\setlength\medskipamount{18\p@ \@plus4\p@ \@minus4\p@}
\setlength\bigskipamount{36\p@ \@plus8\p@ \@minus8\p@}
%</36pt>
%<*48pt>
\setlength\smallskipamount{12\p@ \@plus3\p@ \@minus3\p@}
\setlength\medskipamount{24\p@ \@plus6\p@ \@minus6\p@}
\setlength\bigskipamount{48\p@ \@plus12\p@ \@minus12\p@}
%</48pt>
%<*60pt>
\setlength\smallskipamount{15\p@ \@plus4\p@ \@minus4\p@}
\setlength\medskipamount{30\p@ \@plus8\p@ \@minus8\p@}
\setlength\bigskipamount{60\p@ \@plus16\p@ \@minus16\p@}
%</60pt>
%</17pt|20pt|25pt|30pt|36pt|48pt|60pt>
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@lowpenalty}
% \begin{macro}{\@medpenalty}
% \begin{macro}{\@highpenalty}%
% The commands \cs{nopagebreak} and \cs{nolinebreak} put in penalties
% to discourage these breaks at the point they are put in.
% They use \cs{@lowpenalty}, \cs{@medpenalty} or \cs{@highpenalty},
% dependent on their argument.
% \begin{macrocode}
%<*class>
\@lowpenalty 51
\@medpenalty 151
\@highpenalty 301
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\clubpenalty}
% \begin{macro}{\widowpenalty}
% These penalties are used to discourage club and widow lines.
% The default values are 150 each, but we want stronger discouragement.
% \begin{macrocode}
\clubpenalty 1000
\widowpenalty 1000
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\displaywidowpenalty}
% \begin{macro}{\predisplaypenalty}
% \begin{macro}{\postdisplaypenalty}
% Discourage, but do not prevent, widows in front of a math display
% and forbid breaking directly in front of a display. Allow break
% after a display without a penalty. The default values are
% used, therefore we only show them here.
% \begin{macrocode}
% \displaywidowpenalty 50
% \predisplaypenalty 10000
% \postdisplaypenalty 0
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\interlinepenalty}
% Allow the breaking of a page in the middle of a paragraph.
% \begin{macrocode}
% \interlinepenalty 0
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\brokenpenalty}
% We allow the breaking of a page after a hyphenated line.
% \begin{macrocode}
% \brokenpenalty 100
% \end{macrocode}
% \end{macro}
%
%
%
%
% \subsection{Vertical spacing}
%
% \begin{macro}{\headheight}
% \begin{macro}{\headsep}
% \begin{macro}{\topskip}
% \begin{macro}{\footskip}
% The \cs{headheight} is the height of the box that will contain the
% running head. In this class it is point size dependent ---
% \cs{onelineskip} (normally it is a constant 12pt).
%
% The \cs{headsep} is the distance between the bottom
% of the running head and the top of the text. For the larger sizes
% this is 1.8 times the fontsize.
%
% The \cs{topskip} is the \cs{baselineskip} for the first line on a page;
% \LaTeX's output routine will not work properly if it has the
% value 0pt, so do not do that! For the lareger sizes this is the font size.
%
% The distance from the baseline of the box which contains the
% running footer to the baseline of last line of text is controlled
% by the \cs{footskip}. For the larger sizes this is 2.5 times the
% font size.
% \changes{v0.11 (mem14.clo)}{2001/10/30}{Changed \cs{headheight} from 16pt to 17.5pt}
% \changes{v0.11 (mem11.clo)}{2002/03/10}{Changed \cs{headheight} from 13pt to 13.6pt}
% \changes{v0.4b (mem12.clo)}{2010/10/19}{Changed \cs{headheight} from 14pt to 14.5pt}
% \begin{macrocode}
%</class>
%<*9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
%<*9pt>
\setlength\headheight{11\p@}
\setlength\headsep{.225in}
\setlength\topskip{9\p@}
\setlength\footskip{.33in}
%</9pt>
%<*10pt>
\setlength\headheight{12\p@}
\setlength\headsep{.25in}
\setlength\topskip{10\p@}
\setlength\footskip{.35in}
%</10pt>
%<*11pt>
\setlength\headheight{13.6\p@}
\setlength\headsep{.275in}
\setlength\topskip{11\p@}
\setlength\footskip{.38in}
%</11pt>
%<*12pt>
\setlength\headheight{14.5\p@}
\setlength\headsep{.275in}
\setlength\topskip{12\p@}
\setlength\footskip{30\p@}
%</12pt>
%<*14pt>
\setlength\headheight{17.5\p@}
\setlength\headsep{.30in}
\setlength\topskip{14.4\p@}
\setlength\footskip{.4in}
%</14pt>
%<*17pt>
\setlength\headheight{22\p@}
\setlength\headsep{.30in}
\setlength\topskip{14.4\p@}
\setlength\footskip{.4in}
%</17pt>
%<*20pt>
\setlength\headheight{25\p@}
\setlength\headsep{36\p@}
\setlength\topskip{20\p@}
\setlength\footskip{50\p@}
%</20pt>
%<*25pt>
\setlength\headheight{30\p@}
\setlength\headsep{45\p@}
\setlength\topskip{25\p@}
\setlength\footskip{62\p@}
%</25pt>
%<*30pt>
\setlength\headheight{37\p@}
\setlength\headsep{54\p@}
\setlength\topskip{30\p@}
\setlength\footskip{75\p@}
%</30pt>
%<*36pt>
\setlength\headheight{45\p@}
\setlength\headsep{65\p@}
\setlength\topskip{36\p@}
\setlength\footskip{90\p@}
%</36pt>
%<*48pt>
\setlength\headheight{60\p@}
\setlength\headsep{86\p@}
\setlength\topskip{48\p@}
\setlength\footskip{120\p@}
%</48pt>
%<*60pt>
\setlength\headheight{72\p@}
\setlength\headsep{108\p@}
\setlength\topskip{60\p@}
\setlength\footskip{150\p@}
%</60pt>
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\maxdepth}
% \begin{macro}{\@maxdepth}
% The \TeX\ primitive register \cs{maxdepth} has a function that is
% similar to that of \cs{topskip}. The register \cs{@maxdepth} should
% always contain a copy of \cs{maxdepth}. In both plain \TeX\ and
% \LaTeX~2.09 \cs{maxdepth} had a fixed value of \texttt{4pt}; in
% native \LaTeX 2e mode we let the value depend on the typesize. We
% set it so that \cs{maxdepth} $+$ \cs{topskip} $=$ typesize $\times
% 1.5$. As it happens, in these classes \cs{topskip} is equal to the
% typesize, therefor we set \cs{maxdepth} to half the value of
% \cs{topskip}.
% \begin{macrocode}
\setlength\maxdepth{.5\topskip}
\setlength\@maxdepth\maxdepth
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \subsection{Footnotes}
%
% \begin{macro}{\footnotesep}
% \cs{footnotesep} is the height of the strut placed at the beginning
% of every footnote. It equals the height of a normal \cs{footnotesize}
% strut, so no extra space appears between footnotes.
% \changes{v1.61803}{2007/01/30}{Changed nearly all \cs{footnotesep}}
% \begin{macrocode}
%<9pt>\setlength\footnotesep{5.6\p@}
%<10pt>\setlength\footnotesep{6.65\p@}
%<11pt>\setlength\footnotesep{7.7\p@}
%<12pt>\setlength\footnotesep{8.4\p@}
%<14pt>\setlength\footnotesep{9.5\p@}
%<17pt>\setlength\footnotesep{10.15\p@}
%<20pt>\setlength\footnotesep{12.6\p@}
%<25pt>\setlength\footnotesep{15.4\p@}
%<30pt>\setlength\footnotesep{17.5\p@}
%<36pt>\setlength\footnotesep{21\p@}
%<48pt>\setlength\footnotesep{25.9\p@}
%<60pt>\setlength\footnotesep{31.5\p@}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\footins}
% \verb?\skip\footins? is the space between the last line of the main
% text and the top of the first footnote.
% \begin{macrocode}
%<9pt>\setlength{\skip\footins}{8\p@ \@plus 2\p@ \@minus 2\p@}
%<10pt>\setlength{\skip\footins}{9\p@ \@plus 4\p@ \@minus 2\p@}
%<11pt>\setlength{\skip\footins}{10\p@ \@plus 4\p@ \@minus 2\p@}
%<12pt>\setlength{\skip\footins}{10.8\p@ \@plus 4\p@ \@minus 2\p@}
%<14pt>\setlength{\skip\footins}{13\p@ \@plus 4\p@ \@minus 2\p@}
%<17pt>\setlength{\skip\footins}{16\p@ \@plus 5\p@ \@minus 3\p@}
%<20pt>\setlength{\skip\footins}{19\p@ \@plus 7\p@ \@minus 3\p@}
%<25pt>\setlength{\skip\footins}{24\p@ \@plus 8\p@ \@minus 4\p@}
%<30pt>\setlength{\skip\footins}{29\p@ \@plus 10\p@ \@minus 5\p@}
%<36pt>\setlength{\skip\footins}{35\p@ \@plus 12\p@ \@minus 6\p@}
%<48pt>\setlength{\skip\footins}{47\p@ \@plus 16\p@ \@minus 8\p@}
%<60pt>\setlength{\skip\footins}{59\p@ \@plus 20\p@ \@minus 10\p@}
% \end{macrocode}
% \end{macro}
%
% \subsection{Floats}
%
% \paragraph{Floats on a text page}
%
% \begin{macro}{\floatsep}
% \begin{macro}{\textfloatsep}
% \begin{macro}{\intextsep}
% When a floating object is placed on a page with text, these
% parameters control the separation between the float and the other
% objects on the page. These parameters are used for both
% one-column mode and single-column floats in two-column mode.
%
% \cs{floatsep} is the space between adjacent floats that are moved
% to the top or bottom of the text page. For the larger sizes this is
% \cs{bigskip}.
%
% \cs{textfloatsep} is the space between the main text and floats
% at the top or bottom of the page. For the larger sizes this is
% 1.45\cs{onelineskip}.
%
% \cs{intextsep} is the space between in-text floats and the text.
% \begin{macrocode}
%<*9pt>
\setlength\floatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\intextsep {12\p@ \@plus 2\p@ \@minus 2\p@}
%</9pt>
%<*10pt>
\setlength\floatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\intextsep {12\p@ \@plus 2\p@ \@minus 2\p@}
%</10pt>
%<*11pt>
\setlength\floatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\intextsep {12\p@ \@plus 2\p@ \@minus 2\p@}
%</11pt>
%<*12pt>
\setlength\floatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\intextsep {14\p@ \@plus 4\p@ \@minus 4\p@}
%</12pt>
%<*14pt>
\setlength\floatsep {14\p@ \@plus 4\p@ \@minus 4\p@}
\setlength\textfloatsep{20\p@ \@plus 4\p@ \@minus 4\p@}
\setlength\intextsep {14\p@ \@plus 4\p@ \@minus 4\p@}
%</14pt>
%<*17pt>
\setlength\floatsep {15\p@ \@plus 4\p@ \@minus 4\p@}
\setlength\textfloatsep{25\p@ \@plus 4\p@ \@minus 5\p@}
\intextsep \floatsep
%</17pt>
%<*20pt>
\setlength\floatsep {20\p@ \@plus 4\p@ \@minus 4\p@}
\setlength\textfloatsep{36\p@ \@plus 4\p@ \@minus 8\p@}
\intextsep \floatsep
%</20pt>
%<*25pt>
\setlength\floatsep {24\p@ \@plus 4\p@ \@minus 4\p@}
\setlength\textfloatsep{43\p@ \@plus 4\p@ \@minus 8\p@}
\intextsep \floatsep
%</25pt>
%<*30pt>
\setlength\floatsep {30\p@ \@plus 6\p@ \@minus 6\p@}
\setlength\textfloatsep{54\p@ \@plus 6\p@ \@minus 12\p@}
\intextsep \floatsep
%</30pt>
%<*36pt>
\setlength\floatsep {36\p@ \@plus 8\p@ \@minus 8\p@}
\setlength\textfloatsep{65\p@ \@plus 8\p@ \@minus 16\p@}
\intextsep \floatsep
%</36pt>
%<*48pt>
\setlength\floatsep {48\p@ \@plus 12\p@ \@minus 12\p@}
\setlength\textfloatsep{87\p@ \@plus 12\p@ \@minus 24\p@}
\intextsep \floatsep
%</48pt>
%<*60pt>
\setlength\floatsep {60\p@ \@plus 16\p@ \@minus 16\p@}
\setlength\textfloatsep{104\p@ \@plus 16\p@ \@minus 32\p@}
\intextsep \floatsep
%</60pt>
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\dblfloatsep}
% \begin{macro}{\dbltextfloatsep}
% When floating objects that span the whole \cs{textwidth} are placed
% on a text page and \LaTeX{} is in twocolumn mode the separation
% between the float and the text is controlled by \cs{dblfloatsep}
% and \cs{dbltextfloatsep}.
%
% \cs{dblfloatsep} is the space between adjacent floats that are moved
% to the top or bottom of the text page.
%
% \cs{dbltextfloatsep} is the space between the main text and floats
% at the top or bottom of the page.
%
% \begin{macrocode}
%<*9pt>
\setlength\dblfloatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
%</9pt>
%<*10pt>
\setlength\dblfloatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
%</10pt>
%<*11pt>
\setlength\dblfloatsep {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
%</11pt>
%<*12pt>
\setlength\dblfloatsep {14\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
%</12pt>
%<*14pt>
\setlength\dblfloatsep {14\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
%</14pt>
%<*17pt>
\setlength\dblfloatsep {15\p@ \@plus 4\p@ \@minus 4\p@}
\setlength\dbltextfloatsep{25\p@ \@plus 5\p@ \@minus 5\p@}
%</17pt>
%<*20pt>
\dblfloatsep \floatsep
\dbltextfloatsep \textfloatsep
%</20pt>
%<*25pt>
\dblfloatsep \floatsep
\dbltextfloatsep \textfloatsep
%</25pt>
%<*30pt>
\dblfloatsep \floatsep
\dbltextfloatsep \textfloatsep
%</30pt>
%<*36pt>
\dblfloatsep \floatsep
\dbltextfloatsep \textfloatsep
%</36pt>
%<*48pt>
\dblfloatsep \floatsep
\dbltextfloatsep \textfloatsep
%</48pt>
%<*60pt>
\dblfloatsep \floatsep
\dbltextfloatsep \textfloatsep
%</60pt>
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \paragraph{Floats on their own page or column}
%
% \begin{macro}{\@fptop}
% \begin{macro}{\@fpsep}
% \begin{macro}{\@fpbot}
% When floating objects are placed on separate pages the layout of
% such pages is controlled by these parameters. At the top of the
% page \cs{@fptop} amount of stretchable whitespace is inserted, at
% the bottom of the page we get an \cs{@fpbot} amount of stretchable
% whitespace. Between adjacent floats the \cs{@fpsep} is inserted.
% For the larger sizes \cs{@fpsep} is .7\cs{onelineskip}.
%
% These parameters are used for the placement of floating objects
% in one column mode, or in single column floats in two column
% mode.
%
% Note that at least one of the two parameters \cs{@fptop} and
% \cs{@fpbot} should contain a \verb?plus ...fil? to allow filling the
% remaining empty space.
% \begin{macrocode}
%<*9pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{9\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
%</9pt>
%<*10pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{8\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
%</10pt>
%<*11pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{8\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
%</11pt>
%<*12pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{10\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
%</12pt>
%<*14pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{10\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
%</14pt>
%<*17pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{12\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
%</17pt>
%<*20pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{17\p@ \@plus 2fil}
\@fpbot \@fptop
%</20pt>
%<*25pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{21\p@ \@plus 2fil}
\@fpbot \@fptop
%</25pt>
%<*30pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{26\p@ \@plus 2fil}
\@fpbot \@fptop
%</30pt>
%<*36pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{31\p@ \@plus 2fil}
\@fpbot \@fptop
%</36pt>
%<*48pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{42\p@ \@plus 2fil}
\@fpbot \@fptop
%</48pt>
%<*60pt>
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{50\p@ \@plus 2fil}
\@fpbot \@fptop
%</60pt>
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@dblfptop}
% \begin{macro}{\@dblfpsep}
% \begin{macro}{\@dblfpbot}
% Double column floats in two column mode are handled with similar
% parameters.
% \begin{macrocode}
%<*9pt>
\setlength\@dblfptop{0\p@ \@plus 1fil}
\setlength\@dblfpsep{7\p@ \@plus 2fil}
\setlength\@dblfpbot{0\p@ \@plus 1fil}
%</9pt>
%<*10pt>
\setlength\@dblfptop{0\p@ \@plus 1fil}
\setlength\@dblfpsep{8\p@ \@plus 2fil}
\setlength\@dblfpbot{0\p@ \@plus 1fil}
%</10pt>
%<*11pt>
\setlength\@dblfptop{0\p@ \@plus 1fil}
\setlength\@dblfpsep{8\p@ \@plus 2fil}
\setlength\@dblfpbot{0\p@ \@plus 1fil}
%</11pt>
%<*12pt>
\setlength\@dblfptop{0\p@ \@plus 1fil}
\setlength\@dblfpsep{10\p@ \@plus 2fil}
\setlength\@dblfpbot{0\p@ \@plus 1fil}
%</12pt>
%<*14pt>
\setlength\@dblfptop{0\p@ \@plus 1fil}
\setlength\@dblfpsep{12\p@ \@plus 2fil}
\setlength\@dblfpbot{0\p@ \@plus 1fil}
%</14pt>
%<*17pt>
\setlength\@dblfptop{0\p@ \@plus 1fil}
\setlength\@dblfpsep{12\p@ \@plus 2fil}
\setlength\@dblfpbot{0\p@ \@plus 1fil}
%</17pt>
%<*20pt>
\@dblfptop \@fptop
\@dblfpsep \@fpsep
\@dblfpbot \@dblfptop
%</20pt>
%<*25pt>
\@dblfptop \@fptop
\@dblfpsep \@fpsep
\@dblfpbot \@dblfptop
%</25pt>
%<*30pt>
\@dblfptop \@fptop
\@dblfpsep \@fpsep
\@dblfpbot \@dblfptop
%</30pt>
%<*36pt>
\@dblfptop \@fptop
\@dblfpsep \@fpsep
\@dblfpbot \@dblfptop
%</36pt>
%<*48pt>
\@dblfptop \@fptop
\@dblfpsep \@fpsep
\@dblfpbot \@dblfptop
%</48pt>
%<*60pt>
\@dblfptop \@fptop
\@dblfpsep \@fpsep
\@dblfpbot \@dblfptop
%</60pt>
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{The measure}
%
% The width of a line of text (and therefore the text block) is termed
% the \emph{measure}.
%
% \begin{macro}{\lxvchars}
% The length \cs{lxvchars} is the approximate length of a normal
% text line containing 65 characters (a typesetters rule of thumb is
% that there should be about 60--70 characters per line).
% \begin{macrocode}
%<9pt>\setlength\lxvchars{276\p@} %
%<10pt>\setlength\lxvchars{300\p@} % standard 345pt
%<11pt>\setlength\lxvchars{324\p@} % standard 360pt
%<12pt>\setlength\lxvchars{336\p@} % standard 390pt
%<14pt>\setlength\lxvchars{408\p@} %
%<17pt>\setlength\lxvchars{444\p@} %
%<20pt>\setlength\lxvchars{528\p@} %
%<25pt>\setlength\lxvchars{626\p@} %
%<30pt>\setlength\lxvchars{748\p@} %
%<36pt>\setlength\lxvchars{891\p@} %
%<48pt>\setlength\lxvchars{1177\p@} %
%<60pt>\setlength\lxvchars{1463\p@} %
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xlvchars}
% The length \cs{xlvchars} is the approximate length of a normal
% double column text line containing 45 characters
% (a typesetters rule of thumb is
% that there should be about 40--50 characters per column line).
% \begin{macrocode}
%<9pt>\setlength\xlvchars{192\p@} %
%<10pt>\setlength\xlvchars{204\p@} %
%<11pt>\setlength\xlvchars{216\p@} %
%<12pt>\setlength\xlvchars{240\p@} %
%<14pt>\setlength\xlvchars{288\p@} %
%<17pt>\setlength\xlvchars{312\p@} %
%<20pt>\setlength\xlvchars{365\p@} %
%<25pt>\setlength\xlvchars{438\p@} %
%<30pt>\setlength\xlvchars{518\p@} %
%<36pt>\setlength\xlvchars{617\p@} %
%<48pt>\setlength\xlvchars{815\p@} %
%<60pt>\setlength\xlvchars{1014\p@} %
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\marginparsep}
% \begin{macro}{\marginparpush}
% \cs{marginparsep} is the horizontal space between the text block and
% marginal notes, while \cs{marginparpush} is the minimum vertical
% separation between the notes.
% \begin{macrocode}
\if@twocolumn
%<*9pt|10pt|11pt|12pt|14pt>
\setlength\marginparsep{10\p@}
%</9pt|10pt|11pt|12pt|14pt>
%<*17pt|20pt|25pt|30pt|36pt|48pt|60pt>
\setlength\marginparsep{1em}
%</17pt|20pt|25pt|30pt|36pt|48pt|60pt>
\else
%<*9pt|10pt|11pt|12pt|14pt>
\setlength\marginparsep{7\p@}
%</9pt|10pt|11pt|12pt|14pt>
%<*17pt|20pt|25pt|30pt|36pt|48pt|60pt>
\setlength\marginparsep{0.7em}
%</17pt|20pt|25pt|30pt|36pt|48pt|60pt>
\fi
%<9pt|10pt|11pt>\setlength{\marginparpush}{5\p@}
%<12pt|14pt>\setlength{\marginparpush}{7\p@}
%<*17pt|20pt|25pt|30pt|36pt|48pt|60pt>
\setlength\marginparpush{0.5em}
%</17pt|20pt|25pt|30pt|36pt|48pt|60pt>
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
%</9pt|10pt|11pt|12pt|14pt|17pt|20pt|25pt|30pt|36pt|48pt|60pt>
%<*class>
% \end{macrocode}
%
% \section{Page Layout}
%
%
% \subsection{The typeblock and margins}
%
% All margin dimensions are measured from a point one inch from the
% top and lefthand side of the page.
%
% \begin{macro}{\setlxvchars}
% \begin{macro}{\setxlvchars}
% These were suggested and supplied by Morten H{\o}gholm (18 May 2003).
%
% \cs{setlxvchars}\oarg{fontspec} sets \cs{lxvchars} to the length of a line
% containing 65 characters in the \meta{fontspec}.
%
% Similarly
% \cs{setxlvchars}\oarg{fontspec} sets \cs{xlvchars} for 45 characters.
% \changes{v1.4}{2003/11/22}{Added \cs{setlxvchars} and \cs{setxlvchars}
% (from patch v1.6)}
% \begin{macrocode}
\newcommand*{\setlxvchars}[1][\normalfont]{\begingroup
#1
\settowidth{\lxvchars}{abcdefghijklmnopqrstuvwxyz}%
\setlength{\lxvchars}{2.042\lxvchars}%
\addtolength{\lxvchars}{33.41pt}%
\global\lxvchars=\lxvchars
\endgroup}
\newcommand*{\setxlvchars}[1][\normalfont]{\begingroup
#1
\settowidth{\xlvchars}{abcdefghijklmnopqrstuvwxyz}%
\setlength{\xlvchars}{1.415\xlvchars}%
\addtolength{\xlvchars}{23.03pt}%
\global\xlvchars=\xlvchars
\endgroup}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setrectanglesize}
% The macro \cs{setrectanglesize}\marg{H}\marg{W}\marg{r}
% calculates the height and width of a rectangle given any two out of
% the three arguments. An unvalued argument is denoted by \verb?*?.
%
% Table~\ref{tab:setrect} shows the argument combinations and the result
% for each combination.
% \begin{table}
% \centering
% \caption{Arguments and results for \cs{setrectanglesize}}\label{tab:setrect}
% \begin{tabular}{ccc|l} \hline
% H & W & r & Result \\ \hline
% * & W & r & $H = rW$ \\{}
% * & W & * & $H = W$ \\{}
% * & * & r & ambiguous \\{}
% * & * & * & ambiguous \\{}
% H & W & r & $H, W$ \\
% H & W & * & $H, W$ \\
% H & * & r & $W = rH$ \\
% H & * & * & $W = H$ \\
% \hline
% \end{tabular}
% \end{table}
%
% The
% calculated height and width are stored in \cs{@tempdima} and \cs{@tempdimb}
% respectively. Both lengths are set to zero if there is an error.
% \changes{v1.61803}{2008/01/30}{Used \cs{setlength} instead of TeX syntax so that the calc package
% can be used with page layout (Morten H{\o}gholm mempatch v4.5)}
% \begin{macrocode}
\newcommand*{\setrectanglesize}[3]{%
\nametest{#1}{*}%
\ifsamename % H = *
\nametest{#2}{*}%
\ifsamename % W = *
\@memerror{%
The combination of argument values is ambiguous.\MessageBreak
The lengths will be set to zero}{\@ehd}%
\setlength{\@tempdima}{0pt}%
\setlength{\@tempdimb}{0pt}%
\else % W
\nametest{#3}{*}%
\ifsamename % r = *
\setlength{\@tempdimb}{#2}%
\setlength{\@tempdima}{\@tempdimb}%
\else % r
\setlength{\@tempdimb}{#2}%
\setlength{\@tempdima}{#3\@tempdimb}%
\fi
\fi
\else % H
\nametest{#2}{*}%
\ifsamename % W = *
\nametest{#3}{*}%
\ifsamename % r = *
\setlength{\@tempdima}{#1}%
\setlength{\@tempdimb}{\@tempdima}%
\else % r
\setlength{\@tempdima}{#1}%
\setlength{\@tempdimb}{#3\@tempdima}%
\fi
\else % W
\setlength{\@tempdima}{#1}%
\setlength{\@tempdimb}{#2}%
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setfillsize}
% Consider a set of 4 lengths, $T$, $L$, $C$, and $R$, such that
% $T = L + C + R$, where $T$ is a fixed size and normally $C$ is also fixed.
% Also $L$ and $R$ may be specified independently of each other or as a
% ratio (i.e., $L = rR$ or $R = rL$).
% The macro
% \cs{setfillsize}\marg{T}\marg{C}\marg{L}\marg{R}\marg{r}
% maintains these constraints among the variables, where an unvalued
% argument is denoted by \verb?*?.
%
% Table~\ref{tab:setfill} shows the argument combinations and the result
% for each combination.
% \begin{table}
% \centering
% \caption{Arguments and results for \cs{setfillsize}}\label{tab:setfill}
% \begin{tabular}{cccc|ll} \hline
% C & L & R & r & Result & \\ \hline
% * & * & R & r & $L = rR$, & $C = T - L - R$ \\{}
% * & * & R & * & $L = R$, & $C = T - L - R$ \\{}
% * & * & * & r & ambigous & \\{}
% * & * & * & * & ambiguous & \\{}
% * & L & R & r & $L$, $R$, & $C = T - L - R$ \\{}
% * & L & R & * & $L$, $R$, & $C = T - L - R$ \\{}
% * & L & * & r & $R = rL$, & $C = T - L - R$ \\{}
% * & L & * & * & $R = L$, & $C = T - L - R$ \\{}
% C & * & R & r & $L = T - C - R$ & $C$ \\
% C & * & R & * & $L = T - C - R$, & $C$ \\
% C & * & * & r & $L + R = T - C$, $R = rL$, & $C$ \\
% C & * & * & * & $L + R = T - C$, $R = L$, & $C$ \\
% C & L & R & r & ambiguous & $C$ \\
% C & L & R & * & ambiguous & $C$ \\
% C & L & * & r & $R = T - C - L$, & $C$ \\
% C & L & * & * & $R = T - C - L$, & $C$ \\
% \hline
% \end{tabular}
% ^^A \MakeShortVerb{\|}
% \end{table}
%
%
% The
% calculated values of \texttt{C}, \texttt{L} and \texttt{R} are stored
% \cs{@tempdimc},
% \cs{@tempdima} and \cs{@tempdimb} respectively. If there is an error
% the lengths are set to zero.
% \begin{macrocode}
\newcommand*{\setfillsize}[5]{%
\nametest{#2}{*}%
\ifsamename % C = *
\nametest{#3}{*}%
\ifsamename % L = *
\nametest{#4}{*}%
\ifsamename % R = *
\@memerror{%
The combination of argument values is ambiguous.\MessageBreak
The lengths will be set to zero}{\@ehd}
\setlength{\@tempdima}{0pt}%
\setlength{\@tempdimb}{0pt}%
\setlength{\@tempdimc}{0pt}%
\else % R
\nametest{#5}{*}%
\ifsamename % r = *
\setlength{\@tempdimb}{#4}%
\setlength{\@tempdima}{\@tempdimb}%
\setlength{\@tempdimc}{#1}%
\advance\@tempdimc -\@tempdima
\advance\@tempdimc -\@tempdimb
\else % r
\setlength{\@tempdimb}{#4}%
\setlength{\@tempdima}{#5\@tempdimb}%
\setlength{\@tempdimc}{#1}%
\advance\@tempdimc -\@tempdima
\advance\@tempdimc -\@tempdimb
\fi
\fi
\else % L
\nametest{#4}{*}%
\ifsamename % R = *
\nametest{#5}{*}%
\ifsamename % r = *
\setlength{\@tempdima}{#3}%
\setlength{\@tempdimb}{\@tempdima}
\setlength{\@tempdimc}{#1}%
\advance\@tempdimc -\@tempdima
\advance\@tempdimc -\@tempdimb
\else % r
\setlength{\@tempdima}{#3}%
\setlength{\@tempdimb}{#5\@tempdima}
\setlength{\@tempdimc}{#1}%
\advance\@tempdimc -\@tempdima
\advance\@tempdimc -\@tempdimb
\fi
\else % R
\setlength{\@tempdima}{#3}%
\setlength{\@tempdimb}{#4}%
\setlength{\@tempdimc}{#1}%
\advance\@tempdimc -\@tempdima
\advance\@tempdimc -\@tempdimb
\fi
\fi
\else % C is valued
\nametest{#3}{*}%
\ifsamename % L = *
\nametest{#4}{*}%
\ifsamename % R = *
\nametest{#5}{*}%
\ifsamename % r = *
\setlength{\@tempdimc}{#2}%
\setlength{\@tempdima}{#1}%
\advance\@tempdima -\@tempdimc
\@tempdima = 0.5\@tempdima
\@tempdimb = \@tempdima
\else % r (CODE PERHAPS FIXED)
\setlength{\@tempdimc}{#2} % C
\setlength{\@tempdimb}{#1} % T
\advance\@tempdimb -\@tempdimc % T - C
\@tempdima = 1000sp
\setlength{\@tempdima}{#5\@tempdima} % 1000r sp
\advance\@tempdima by 1000sp % 1000(1+r)sp
\@tempcnta = \@tempdima % 1000(1+r)
\@tempdima = \@tempdimb % T - C
\divide\@tempdima by \@tempcnta % (T-C)/1000(1+r) pts
\@tempdima = 1000\@tempdima % (T-C)/(1+r) pts = L
\advance\@tempdimb by -\@tempdima % = R
\fi
\else % R
\setlength{\@tempdimc}{#2}%
\setlength{\@tempdimb}{#4}%
\setlength{\@tempdima}{#1}%
\advance\@tempdima -\@tempdimc
\advance\@tempdima -\@tempdimb
\fi
\else % L
\nametest{#4}{*}%
\ifsamename % R = *
\setlength{\@tempdimc}{#2}%
\setlength{\@tempdima}{#3}%
\setlength{\@tempdimb}{#1}%
\advance\@tempdimb -\@tempdimc
\advance\@tempdimb -\@tempdima
\else % R
\@memerror{%
The combination of argument values is ambiguous.\MessageBreak
The lengths will be set to zero}{\@ehd}%
\setlength{\@tempdima}{0pt}%
\setlength{\@tempdimb}{0pt}%
\setlength{\@tempdimc}{#2}%
\fi
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setstocksize}
% \begin{macro}{\settrims}
% \begin{macro}{\settrimmedsize}
% \cs{setstocksize}\marg{height}\marg{width} sets the height
% and width of the stock material and
% \cs{settrims}\marg{top}\marg{edge} sets the trim lengths
% for the top and side (fore edge) of the stock.
% The macro \cs{settrimmedsize}\marg{height}\marg{width}\marg{ratio}
% sets the size for the trimmed page, based on \cs{setrectanglesize}.
% \begin{macrocode}
\newcommand{\setstocksize}[2]{%
\setlength{\stockheight}{#1}%
\setlength{\stockwidth}{#2}}
\newcommand{\settrims}[2]{%
\setlength{\trimtop}{#1}%
\setlength{\trimedge}{#2}}
\newcommand{\settrimmedsize}[3]{%
\setrectanglesize{#1}{#2}{#3}%
\setlength{\paperheight}{\@tempdima}%
\setlength{\paperwidth}{\@tempdimb}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\settypeblocksize}
% \cs{settypeblocksize}\marg{height}\marg{width}\marg{ratio}
% calulates the \cs{textheight} and \cs{textwidth} from two out of the
% three arguments.
% \changes{v3.6k}{2013/05/14}{Marked \cs{settypeblocksize} as being used}
% \begin{macrocode}
\newcommand{\settypeblocksize}[3]{%
\memsetmacroused\settypeblocksize%
\setrectanglesize{#1}{#2}{#3}%
\setlength{\textheight}{\@tempdima}%
\setlength{\textwidth}{\@tempdimb}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\binding}
% \begin{macro}{\setbinding}
% The length \cs{binding} is an allowance on the spine margin for
% binding. \cs{setbinding}\marg{length} sets the \cs{binding}.
% \changes{v1.6180339c}{2008/12/29}{Added binding offset code to the
% layout functions}
% \begin{macrocode}
\newlength{\binding}
\newcommand*{\setbinding}[1]{\setlength{\binding}{#1}}
\setbinding{0pt}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\spinemargin}
% \begin{macro}{\foremargin}
% \begin{macro}{\setlrmargins}
% \cs{setlrmargins}\marg{L}\marg{R}\marg{r} sets the Left (spine)
% and Right (fore edge) margins with constant typeblock.
% \changes{v1.6180339c}{2008/12/29}{Added binding to \cs{setlrmargins}}
% \changes{v3.6k}{2013/05/14}{Marked \cs{setlrmargins} as being used}
% \begin{macrocode}
\newlength{\spinemargin}
\newlength{\foremargin}
\newcommand{\setlrmargins}[3]{%
\memsetmacroused\setlrmargins%
\advance\paperwidth -\binding
\setfillsize{\paperwidth}{\textwidth}{#1}{#2}{#3}%
\setlength{\textwidth}{\@tempdimc}%
\setlength{\spinemargin}{\@tempdima}%
\setlength{\foremargin}{\@tempdimb}%
\advance\paperwidth \binding
\advance\spinemargin \binding}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setlrmarginsandblock}
% \cs{setlrmarginsandblock}\marg{L}\marg{R}\marg{r} sets the Left (spine)
% and Right (fore edge) margins with variable typeblock.
% \changes{v1.6180339c}{2008/12/29}{Added binding to \cs{setlrmarginsandblock}}
% \begin{macrocode}
\newcommand{\setlrmarginsandblock}[3]{%
\advance\paperwidth -\binding
\setfillsize{\paperwidth}{*}{#1}{#2}{#3}%
\setlength{\textwidth}{\@tempdimc}%
\setlength{\spinemargin}{\@tempdima}%
\setlength{\foremargin}{\@tempdimb}%
\advance\paperwidth \binding
\advance\spinemargin \binding}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\uppermargin}
% \begin{macro}{\lowermargin}
% \begin{macro}{\setulmargins}
% \cs{setulmargins}\marg{L}\marg{R}\marg{r} sets the Left (upper)
% and Right (lower) margins with constant typeblock.
% \changes{v3.6k}{2013/05/14}{Marked \cs{setulmargins} as being used}
% \begin{macrocode}
\newlength{\uppermargin}
\newlength{\lowermargin}
\newcommand{\setulmargins}[3]{%
\memsetmacroused\setulmargins%
\setfillsize{\paperheight}{\textheight}{#1}{#2}{#3}%
\setlength{\textheight}{\@tempdimc}%
\setlength{\uppermargin}{\@tempdima}%
\setlength{\lowermargin}{\@tempdimb}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setulmarginsandblock}
% \cs{setulmarginsandblock}\marg{L}\marg{R}\marg{r} sets the Left (upper)
% and Right (lower) margins with variable typeblock.
% \begin{macrocode}
\newcommand{\setulmarginsandblock}[3]{%
\setfillsize{\paperheight}{*}{#1}{#2}{#3}%
\setlength{\textheight}{\@tempdimc}%
\setlength{\uppermargin}{\@tempdima}%
\setlength{\lowermargin}{\@tempdimb}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\headdrop}
% \begin{macro}{\setheaderspaces}
% \cs{setheaderspaces}\marg{L}\marg{R}\marg{r} sets the Left (head margin)
% and Right (headsep) spacing with constant headheight.
% \begin{macrocode}
\newlength{\headdrop}
\newcommand{\setheaderspaces}[3]{%
\setfillsize{\uppermargin}{\headheight}{#1}{#2}{#3}%
\setlength{\headheight}{\@tempdimc}%
\setlength{\headdrop}{\@tempdima}%
\setlength{\headsep}{\@tempdimb}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setheadfoot}
% \cs{setheadfoot}\marg{headheight}\marg{footskip}
% sets the headheight and the footskip.
% \begin{macrocode}
\newcommand{\setheadfoot}[2]{%
\setlength{\headheight}{#1}%
\setlength{\footskip}{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setcolsepandrule}
% \cs{setcolsepandrule}\marg{colsep}\marg{thickness}
% sets the column separation and the rule thickness.
% \changes{v1.0}{2001/09/20}{Changed \cs{setcolseprule} to
% \cs{setcolsepandrule} to match the documentation.}
% \begin{macrocode}
\newcommand{\setcolsepandrule}[2]{%
\setlength{\columnsep}{#1}%
\setlength{\columnseprule}{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmarginnotes}
% \cs{setmarginnotes}\marg{sep}\marg{width}\marg{push}
% sets the marginpar parameters.
% \changes{v3.6k}{2013/05/14}{Marked \cs{setmarginnotes} as being used}
% \begin{macrocode}
\newcommand{\setmarginnotes}[3]{%
\memsetmacroused\setmarginnotes%
\setlength{\marginparsep}{#1}%
\setlength{\marginparwidth}{#2}%
\setlength{\marginparpush}{#3}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setfootins}
% \cs{setfootins}\marg{length}\marg{length} sets
% \cs{skip}\cs{footins} and its minipage counterpart. It will also
% set \cs{skip}\cs{footinsv@r} and similar for minipages to the same
% values. These are used by for example \cs{twocolumnfootnotes}.
% \begin{macrocode}
\newcommand\setfootins[2]{
\setlength{\skip\footins}{#1}
\setlength{\skip\footinsv@r}{#1}
\setlength{\skip\@mpfootins}{#2}
% not explicitly used
\setlength{\skip\@mpfootinsv@r}{#2}
}
% \end{macrocode}
%
% \end{macro}
%
%
% Initialise the paper size and trimming to their default values.
% \begin{macrocode}
\settrimmedsize{\stockheight}{\stockwidth}{*}
\settrims{\z@}{\z@}
% \end{macrocode}
%
% What now follows is the standard class's method for setting up
% the dimensions.
%
% Set \cs{@tempdimb} to size-dependent initial line length and
% set \cs{@tempdima} to the maximum textwidth for the paper width,
% an inch margin on either side. In the standard classes the initial
% line length is about 14\% greater than \cs{lxvchars}.
% \begin{macrocode}
\setlength{\@tempdimb}{1.14\lxvchars}
\setlength\@tempdima{\paperwidth}
\addtolength\@tempdima{-2in}
% \end{macrocode}
%
% \begin{macro}{\textwidth}
% Now set the \cs{textwidth} depending on the number of columns. In twocolumn
% mode each column should be no wider than \cs{@tempdimb}.
% \begin{macrocode}
\if@twocolumn
\ifdim\@tempdima>2\@tempdimb\relax
\setlength\textwidth{2\@tempdimb}
\else
\setlength\textwidth{\@tempdima}
\fi
% \end{macrocode}
% In onecolumn
% the text should not be wider than the minumum of the paperwidth (less
% 2in for the margins) and the maximum length of the character line.
% \begin{macrocode}
\else
\ifdim\@tempdima>\@tempdimb\relax
\setlength\textwidth{\@tempdimb}
\else
\setlength\textwidth{\@tempdima}
\fi
\fi
% \end{macrocode}
% Adjust the width to be a whole number of points.
% \changes{v3.7g}{2018/03/09}{Switch to private truncating macro so we
% can disable truncation via class option}
% \begin{macrocode}
\mem@settopoint\textwidth
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\textheight}
% The \cs{textheight} is the height of the text block, excluding
% headers and footers. This is set according to the \cs{paperheight},
% to an integral number of lines, and allowing a 1in margin at the
% top and bottom and a further 1.5in for headers and footers.
% \begin{macrocode}
\setlength\@tempdima{\paperheight}
\addtolength\@tempdima{-3.5in}
% \end{macrocode}
% Divide this height by the \cs{baselineskip} to get the number of lines.
% Then (re)calculate the \cs{textheight} and finally add the \cs{topskip}.
% \begin{macrocode}
\divide\@tempdima\baselineskip
\@tempcnta=\@tempdima
\setlength\textheight{\@tempcnta\baselineskip}
\addtolength\textheight{\topskip}
% \end{macrocode}
% \end{macro}
%
% The margins are calculated.
%
% \begin{macro}{\oddsidemargin}
% \begin{macro}{\marginparwidth}
% \begin{macro}{\evensidemargin}
% The margins depend on the paper size, also for two sided
% printing the inner margin is made smaller than the outer.
% \begin{macrocode}
\if@twoside
\setlength\@tempdima {\paperwidth}
\addtolength\@tempdima {-\textwidth}
\setlength\oddsidemargin {.4\@tempdima}
\addtolength\oddsidemargin {-1in}
\setlength\marginparwidth {.6\@tempdima}
\addtolength\marginparwidth{-\marginparsep}
\addtolength\marginparwidth{-0.4in}
\else
\setlength\@tempdima {\paperwidth}
\addtolength\@tempdima {-\textwidth}
\setlength\oddsidemargin {.5\@tempdima}
\addtolength\oddsidemargin {-1in}
\setlength\marginparwidth {.5\@tempdima}
\addtolength\marginparwidth{-\marginparsep}
\addtolength\marginparwidth{-0.8in} % don't know why this isn't .4
\fi
\ifdim\marginparwidth>2in
\setlength\marginparwidth{2in}%
\fi
% \end{macrocode}
% Set these values to integer numbers of points, and afterwards calculate the
% \cs{evensidemargin}.
% Jonathon Stickel (\url{jjstickel@vcn.com}) on 2008/05/30 noted that
% \cs{marginparwidth} had to be positive for the initial setting of the sidebar
% geometry through \cs{setsidebars}.
% \changes{v1.618033}{2008/06/02}{Ensured initial value of \cs{marginparwidth}
% was positive}
% \changes{v3.7g}{2018/03/09}{Switch to private truncating macro so we
% can disable truncation via class option}
% \begin{macrocode}
\mem@settopoint\oddsidemargin
\mem@settopoint\marginparwidth
\ifdim\marginparwidth<1pt \setlength\marginparwidth{1pt}\fi
\setlength\evensidemargin {\paperwidth}
\addtolength\evensidemargin{-2in}
\addtolength\evensidemargin{-\textwidth}
\addtolength\evensidemargin{-\oddsidemargin}
\mem@settopoint\evensidemargin
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\topmargin}
% The \cs{topmargin} is the distance below the top of the printable
% area (1in below the top of the paper) and the top of the box
% containing the running head.
% \changes{v3.7g}{2018/03/09}{Switch to private truncating macro so we
% can disable truncation via class option}
% \begin{macrocode}
\setlength\topmargin {\paperheight}
\addtolength\topmargin{-2in}
\addtolength\topmargin{-\headheight}
\addtolength\topmargin{-\headsep}
\addtolength\topmargin{-\textheight}
\addtolength\topmargin{-\footskip}
\addtolength\topmargin{-.5\topmargin}
\mem@settopoint\topmargin
% \end{macrocode}
% \end{macro}
%
% That is the end of the classical algorithm. Now calculate the
% user-friendly dimensions. The calculations are simpler than in
% the general case as the \cs{paperwidth} and \cs{paperheight} is the
% same as the \cs{stockwidth} and \cs{stockheight}.
%
% We can get the spine
% and edge margins from the \cs{oddsidemargin}.
% \begin{macrocode}
\setlength{\spinemargin}{\oddsidemargin}
\addtolength{\spinemargin}{1in}
\setlrmargins{\spinemargin}{*}{*}
% \end{macrocode}
%
% Similarly we can get the upper and lower margins from the
% \cs{topmargin}, \cs{headheight} and \cs{headskip}.
% \begin{macrocode}
\setlength{\uppermargin}{\topmargin}
\addtolength{\uppermargin}{1in}
\addtolength{\uppermargin}{\headheight}
\addtolength{\uppermargin}{\headsep}
\setulmargins{\uppermargin}{*}{*}
% \end{macrocode}
%
% \begin{macro}{\@memznegtest}
% DA suggested this in a private email (2003/002/13) to make error
% checking and reporting a bit more (space) efficient. Use like \\
% \verb?\@memznegtest{\marginparsep}? instead of \\
% \begin{verbatim}
% \ifdim\marginparsep>\z@\else
% \@memerror{\protect\marginparsep\space is zero or negative}{\@ehd}%
% \fi
% \end{verbatim}
% If its length variable argument is zero or less it reports an error.
%
% \changes{v1.4}{2003/02/27}{Added \cs{@memznegtest}}
% \changes{v1.618033}{2008/06/02}{Changed \cs{@memznegtest} and
% \cs{@memnegtest} to issue warnings instead of errors}
%
% \begin{macrocode}
\newcommand*{\@memznegtest}[1]{%
\ifdim#1>\z@\else
%%%% \@memerror{\protect#1\space is zero or negative}{\@ehd}%
\@memwarn{\protect#1\space is zero or negative}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@memnegtest}
% Reports an error if its length variable argument is negative.
% \changes{v1.4}{2003/02/27}{Added \cs{@memnegtest}}
% \begin{macrocode}
\newcommand*{\@memnegtest}[1]{%
\ifdim#1<\z@
%%%% \@memerror{\protect#1\space is negative}{\@ehd}%
\@memwarn{\protect#1\space is negative}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mclassicht}
% The classic adjustment of the \cs{textheight} to get an integral number
% of lines (given an integral number of baselineskips returns a height
% giving one more line in the block).
% \changes{v1.61803}{2008/01/30}{Added \cs{m@mclassicht}, \cs{m@mlinesht}
% and \cs{m@mnearestht} (mempatch v4.5)}
% \begin{macrocode}
\newcommand*{\m@mclassicht}{%
\setlength{\@tempdima}{\textheight}%
\divide\@tempdima \baselineskip
\@tempcnta=\@tempdima
\setlength{\textheight}{\@tempcnta\baselineskip}%
\addtolength{\textheight}{\topskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mlinesht}
% The adjustment of the \cs{textheight} to get an integral number
% of lines (given an inegral number of baselineskips returns a height
% giving that number of lines).
% \begin{macrocode}
\newcommand*{\m@mlinesht}{%
\setlength{\@tempdima}{\textheight}%
\advance\@tempdima -\baselineskip
\divide\@tempdima \baselineskip
\@tempcnta=\@tempdima
\setlength{\textheight}{\@tempcnta\baselineskip}%
\addtolength{\textheight}{\topskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mnearestht}
% The adjustment of the \cs{textheight} to get an integral number
% of lines with the calculated height being as the closest to the given
% height. Algorithm supplied by Lars Madsen and Morten H{\o}gholm on
% 2006/07/27.
% \begin{macrocode}
\newcommand*{\m@mnearestht}{%
\setlength{\@tempdima}{\textheight}%
\advance\@tempdima -\topskip
\advance\@tempdima 0.5\baselineskip
\divide\@tempdima \baselineskip
\@tempcnta=\@tempdima
\setlength{\textheight}{\@tempcnta\baselineskip}%
\addtolength{\textheight}{\topskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@autoadjust@marginparwidth}
% This macro implements an algorithm, to automatically adjust
% \cs{marginparwidth} to the current values of \cs{spinemargin} and
% \cs{foremargin} (i.e., the inner and outer margins). It may be used
% within \cs{fixthelayout} in case the user has not changed
% \cs{marginparwidth} using \cs{setmarginnotes}.
% \begin{macrocode}
\newcommand\mem@autoadjust@marginparwidth{%
\if@twocolumn
\memsetlengthmin\marginparwidth\spinemargin\foremargin
\else
\if@twoside
\ifcase\m@mmpar@margin\relax% 0 - left
\memsetlengthmin\marginparwidth\spinemargin\foremargin
\or% 1 - right
\memsetlengthmin\marginparwidth\spinemargin\foremargin
\or% 2 - outer
\setlength\marginparwidth{\foremargin}
\or% 3 - inner
\setlength\marginparwidth{\spinemargin}
\fi
\else % oneside
\ifnum\m@mmpar@margin=0% left
\setlength\marginparwidth{\spinemargin}
\else% right
\setlength\marginparwidth{\foremargin}
\fi
\fi
\fi
\addtolength\marginparwidth{-2\marginparsep}
\ifdim\marginparwidth<1pt\setlength\marginparwidth{1pt}\fi%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@reset@used@macros}
% This macro is used to unset used macros. It is a manually
% maintained macro. A better version would have been to let
% \cs{memsetmacroused} record its use in a list, and then loop over
% this list. Maybe some other time.
% \begin{macrocode}
\newcommand\mem@reset@used@macros{%
\memsetmacrounused\setmarginnotes
\memsetmacrounused\settypeblocksize
\memsetmacrounused\setulmargins
\memsetmacrounused\setlrmargins
}
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\checkthelayout}
% \cs{checkthelayout}\oarg{text} is the user level macro for
% checking the layout. The \meta{text} argument controls which
% algorithm should be used to calculate the \cs{textheight}.
% \changes{v1.61803}{2008/01/30}{Extended \cs{checkthelayout} to include a choice
% of algorithms (mempatch v4.5)}
% \changes{v1.61803}{2008/01/30}{Changed some page layout tests to negative from zero or negative
% (mempatch v4.5)}
% \begin{macrocode}
\newcommand*{\checkthelayout}[1][classic]{%
% \end{macrocode}
% First check the dimensions are not (zero or) negative.
% \begin{macrocode}
\@memnegtest{\trimedge}
\@memnegtest{\trimtop}
\@memznegtest{\stockwidth}
\@memznegtest{\paperwidth}
\@memznegtest{\textwidth}
%%% \@memznegtest{\spinemargin}
\@memnegtest{\spinemargin}
%%% \@memznegtest{\foremargin}
\@memnegtest{\foremargin}
\@memznegtest{\marginparsep}
\@memznegtest{\marginparwidth}
\@memznegtest{\stockheight}
\@memznegtest{\paperheight}
\@memznegtest{\textheight}
%%% \@memznegtest{\uppermargin}
\@memnegtest{\uppermargin}
%%% \@memznegtest{\lowermargin}
\@memnegtest{\lowermargin}
%%% \@memznegtest{\headheight}
\@memnegtest{\headheight}
%%% \@memznegtest{\headsep}
\@memnegtest{\headsep}
%%% \@memznegtest{\footskip}
\@memnegtest{\footskip}
% \end{macrocode}
%
% Carry on regardless. We may need to adjust the \cs{textheight}
% to get an integral number of lines.
% \begin{macrocode}
\nametest{#1}{classic}%
\ifsamename
\m@mclassicht
\else
\nametest{#1}{lines}%
\ifsamename
\m@mlinesht
\else
\nametest{#1}{nearest}%
\ifsamename
\m@mnearestht
\else
\nametest{#1}{fixed}
\ifsamename
\else% not classic, lines, nearest, or fixed
\@memerror{Optional argument is not one of:\MessageBreak
classic, fixed, lines, or nearest. \MessageBreak
I will assume the default}%
{\@ehc}%
\fi
\fi
\fi
\fi
\setulmargins{\uppermargin}{*}{*}
% \end{macrocode}
%
% Check that all the sums add up correctly, or
% at least to within a small (\cs{@tempdimb}) error.
% \changes{v1.618033}{2008/06/02}{Added more information about problematic
% layout values}
% \begin{macrocode}
\@tempdimb = -1pt
\@tempdima=\stockwidth
\advance\@tempdima -\trimedge
\advance\@tempdima -\paperwidth
\ifdim\@tempdima<\@tempdimb
\@tempdima = -\@tempdima
\@memerror{\protect\paperwidth\space (\the\paperwidth) and/or
\protect\trimedge\space (\the\trimedge)
are too large for \protect\stockwidth\space (\the\stockwidth)
by \the\@tempdima}%
{\@ehd}
\fi
\@tempdima = \paperwidth
\advance\@tempdima -\foremargin
\advance\@tempdima -\textwidth
\advance\@tempdima -\spinemargin
\ifdim\@tempdima<\@tempdimb
\@tempdima = -\@tempdima
\@memerror{\protect\spinemargin\space (\the\spinemargin) and/or
\protect\textwidth\space (\the\textwidth) and/or
\protect\foremargin\space (\the\foremargin)
are too large for \protect\paperwidth\space (\the\paperwidth)
by \the\@tempdima}%
{\@ehd}
\fi
\@tempdima = \stockheight
\advance\@tempdima -\trimtop
\advance\@tempdima -\paperheight
\ifdim\@tempdima<\@tempdimb
\@tempdima = -\@tempdima
\@memerror{\protect\paperheight\space (\the\paperheight) and/or
\protect\trimtop\space (\the\trimtop)
are too large for \protect\stockheight\space (\the\stockheight)
by \the\@tempdima}%
{\@ehd}
\fi
\@tempdima = \paperheight
\advance\@tempdima -\uppermargin
\advance\@tempdima -\textheight
\advance\@tempdima -\lowermargin
\ifdim\@tempdima<\@tempdimb
\@tempdima = -\@tempdima
\@memerror{\protect\uppermargin\space (\the\uppermargin) and/or
\protect\textheight\space (\the\textheight) and/or
\protect\lowermargin\space (\the\lowermargin)
are too large for \protect\paperheight\space (\the\paperheight)
by \the\@tempdima}%
{\@ehd}
\fi
\@tempdima = \uppermargin
\advance\@tempdima -\headheight
\advance\@tempdima -\headsep
\ifdim\@tempdima<\@tempdimb
\@tempdima = -\@tempdima
\@memerror{\protect\headheight\space (\the\headheight) and/or
\protect\headsep\space (\the\headsep)
are too large for \protect\uppermargin\space (\the\uppermargin)
by \the\@tempdima}%
{\@ehd}
\fi
\@tempdima = \lowermargin
\advance\@tempdima -\footskip
\ifdim\@tempdima<\z@
\@tempdima = -\@tempdima
\@memerror{\protect\footskip\space (\the\footskip)
is too large for \protect\lowermargin\space (\the\lowermargin)
by \the\@tempdima}%
{\@ehd}
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\fixthelayout}
% Calculate the normal
% \LaTeX{} page layout parameter values. We'll do the heights first
% as they are independent of the number of columns and the side printing.
% \changes{v1.0a}{2002/01/18}{Added \cs{fixthelayout}}
% \begin{macrocode}
\newcommand*{\fixthelayout}{%
\topmargin = \trimtop
\advance\topmargin \uppermargin
\advance\topmargin -\headsep
\advance\topmargin -\headheight
\advance\topmargin -1in\relax
% \end{macrocode}
%
% Now the \cs{oddsidemargin}.
% \begin{macrocode}
\oddsidemargin = \stockwidth
\advance\oddsidemargin -\trimedge
\advance\oddsidemargin -\paperwidth
\advance\oddsidemargin \spinemargin
\advance\oddsidemargin -1in\relax
% \end{macrocode}
%
% And the \cs{evensidemargin}.
% \begin{macrocode}
\evensidemargin = \trimedge
\advance\evensidemargin \foremargin
\advance\evensidemargin -1in\relax
% \end{macrocode}
%
%
% Set the values to the nearest whole point.
% \changes{v3.7g}{2018/03/09}{Switch to private truncating macro so we
% can disable truncation via class option}
% \begin{macrocode}
\mem@settopoint\textwidth
\mem@settopoint\oddsidemargin
\mem@settopoint\evensidemargin
% \end{macrocode}
% Fix standard page layouts after possible change of \cs{textwidth}.
% \changes{v1.6180339f}{2009/03/16}{Added \cs{fixheaderwidths} to \cs{fixthelayout}}
% \begin{macrocode}
\fixheaderwidths
% \end{macrocode}
% Autoadjust \cs{marginparwidth} unless the user have used
% \cs{setmarginnotes}. Plus add a reset of the recordedmacros, just in
% case \cs{fixthelayout} is being used several times.
% \changes{v3.6k}{2013/05/15}{Added autoadjust}
% \begin{macrocode}
\memifmacroused\setmarginnotes{}{\mem@autoadjust@marginparwidth}
\mem@reset@used@macros
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\typeoutlayout}
% \begin{macro}{\settypeoutlayoutunit}
% \begin{macro}{\mem@typeouttwolengths}
% \begin{macro}{\mem@typeoutonelength}
% Why not type out the calculated versions of the designed values?
% \changes{v1.0a}{2002/01/18}{Added \cs{typeoutlayout}}
% \changes{v1.0a}{2002/01/25}{Added column info to \cs{typeoutlayout}}
% \changes{v1.61803}{2008/01/30}{Added sidecap and sidebar data to \cs{typeoutlayout}
% (mempatch v4.6)}
% \changes{v1.61803398d}{2010/02/04}{Added information about side feet}
% \changes{v3.6g}{2010/09/17}{Added feature such that user can change
% the unit used by \cs{typeoutlayout}, requested by Rasmus Villemoes}
% Using the macro \cs{settypeoutlayoutunit}\marg{unit} before
% \cs{typeoutlayout} (or more often \cs{checkandfixthelayout}), the
% user can choose the unit in which the list is typeset. The code is
% inspired by the \texttt{printlen} package.
% \begin{macrocode}
\newcommand\settypeoutlayoutunit[1]{
\nametest{#1}{pt}
\ifsamename
\def\mem@tl@unit{#1}
\def\mem@tl@unitperpt{1.0}
\else
\nametest{#1}{pc}
\ifsamename
\def\mem@tl@unit{#1}
\def\mem@tl@unitperpt{0.083333}
\else
\nametest{#1}{in}
\ifsamename
\def\mem@tl@unit{#1}
\def\mem@tl@unitperpt{0.013837}
\else
\nametest{#1}{mm}
\ifsamename
\def\mem@tl@unit{#1}
\def\mem@tl@unitperpt{0.351459}
\else
\nametest{#1}{cm}
\ifsamename
\def\mem@tl@unit{#1}
\def\mem@tl@unitperpt{0.0351459}
\else
\nametest{#1}{bp}
\ifsamename
\def\mem@tl@unit{#1}
\def\mem@tl@unitperpt{0.996264}
\else
\nametest{#1}{dd}
\ifsamename
\def\mem@tl@unit{#1}
\def\mem@tl@unitperpt{0.9345718}
\else
\nametest{#1}{cc}
\ifsamename
\def\mem@tl@unit{#1}
\def\mem@tl@unitperpt{0.0778809}
\else
\@memerror{Unknown unit '#1' not suitable for layout listing}{}
\fi
\fi
\fi
\fi
\fi
\fi
\fi
\fi
}
% \end{macrocode}
% Default value is \texttt{pt}, other supported are \texttt{mm},
% \texttt{cm}, \texttt{in}, \texttt{bp}, \texttt{dd} and \texttt{cc}.
% \begin{macrocode}
\settypeoutlayoutunit{pt}
% \end{macrocode}
% To help with the typesetting, we need to helper macros:
% \begin{macrocode}
\newcommand\mem@typeouttwolengths[4]{
% #1 = text before
% #2 = first length
% #3 = text between
% #4 = second length
\setlength\@tempdimc{\mem@tl@unitperpt #2}
\edef\l@first{\strip@pt\@tempdimc}%
\setlength\@tempdimc{\mem@tl@unitperpt #4}
\edef\l@second{\strip@pt\@tempdimc}%
\typeout{#1: \l@first\mem@tl@unit\space#3\space\l@second\mem@tl@unit}
}
\newcommand\mem@typeoutonelength[2]{
% #1 = text before
% #2 = first length
\setlength\@tempdimc{\mem@tl@unitperpt #2}
\edef\l@first{\strip@pt\@tempdimc}%
\typeout{#1: \l@first\mem@tl@unit}
}
% \end{macrocode}
% Thirdly \cs{typeoutlayout} need to be rewritten to take care of the
% extra convertions
% \begin{macrocode}
\newcommand*{\typeoutlayout}{%
\typeout{}
\typeout{******************************************************}
% \typeout{Stock height and width:
% \the\stockheight\space by \the\stockwidth}
% \typeout{Top and edge trims:
% \the\trimtop\space and \the\trimedge}
% \typeout{Page height and width:
% \the\paperheight\space by \the\paperwidth}
% \typeout{Text height and width:
% \the\textheight\space by \the\textwidth}
% \typeout{Spine and edge margins:
% \the\spinemargin\space and \the\foremargin}
% \typeout{Upper and lower margins:
% \the\uppermargin\space and \the\lowermargin}
% \typeout{Headheight and headsep:
% \the\headheight\space and \the\headsep}
% \typeout{Footskip:
% \the\footskip}
% \typeout{Columnsep and columnseprule:
% \the\columnsep\space and \the\columnseprule}
% \typeout{Marginparsep and marginparwidth:
% \the\marginparsep\space and \the\marginparwidth}
% \typeout{Sidecapsep and sidecapwidth:
% \the\sidecapsep\space and \the\sidecapwidth}
% \typeout{Sidebarhsep and sidebarwidth:
% \the\sidebarhsep\space and \the\sidebarwidth}
% \typeout{Sidebarvsep and sidebartopsep:
% \the\sidebarvsep\space and \the\sidebartopsep}
% \typeout{Sidebarheight:
% \the\dimen\sideins}
% \typeout{Sidefoothsep and sidefootwidth:
% \the\sidefoothsep\space and \the\sidefootwidth}
% \typeout{Sidefootvsep and sidefootheight:
% \the\sidefootvsep\space and \the\sidefootheight}
\mem@typeouttwolengths{Stock height and width}{\stockheight}{by}{\stockwidth}
\mem@typeouttwolengths{Top and edge trims}{\trimtop}{and}{\trimedge}
\mem@typeouttwolengths{Page height and width}{\paperheight}{by}{\paperwidth}
\mem@typeouttwolengths{Text height and width}{\textheight}{by}{\textwidth}
\mem@typeouttwolengths{Spine and edge margins}{\spinemargin}{and}{\foremargin}
\mem@typeouttwolengths{Upper and lower margins}{\uppermargin}{and}{\lowermargin}
\mem@typeouttwolengths{Headheight and headsep}{\headheight}{and}{\headsep}
\mem@typeoutonelength{Footskip}{\footskip}
\mem@typeouttwolengths{Columnsep and columnseprule}{\columnsep}{and}{\columnseprule}
\mem@typeouttwolengths{Marginparsep and marginparwidth}{\marginparsep}{and}{\marginparwidth}
\mem@typeouttwolengths{Sidecapsep and sidecapwidth}{\sidecapsep}{and}{\sidecapwidth}
\mem@typeouttwolengths{Sidebarhsep and sidebarwidth}{\sidebarhsep}{and}{\sidebarwidth}
\mem@typeouttwolengths{Sidebarvsep and sidebartopsep}{\sidebarvsep}{and}{\sidebartopsep}
\mem@typeoutonelength{Sidebarheight}{\dimen\sideins}
\mem@typeouttwolengths{Sidefoothsep and sidefootwidth}{\sidefoothsep}{and}{\sidefootwidth}
\mem@typeouttwolengths{Sidefootvsep and sidefootheight}{\sidefootvsep}{and}{\sidefootheight}
\typeout{******************************************************}
\typeout{}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\checkandfixthelayout}
% This macro checks and fixes the layout, and reports the result. It takes the
% same optional argument as \cs{checkthelayout}.
% \changes{v0.2}{2001/06/03}{Replaced \cs{fixpagelayout} by \cs{checkandfixthelayout}}
% \changes{v1.0a}{2002/01/18}{Partitioned \cs{checkandfixthelayout}}
% \changes{v1.61803}{2008/01/30}{Changed \cs{checkandfixthelayout}
% for the extended \cs{checkthelayout} (mempatch v4.5)}
% \begin{macrocode}
\newcommand*{\checkandfixthelayout}[1][classic]{%
\checkthelayout[#1]%
\fixthelayout
\typeoutlayout}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\mem@fixpagelayout}
% \changes{v3.7g}{2018/03/09}{Changed to use this instead of
% \cs{fixpdflayout} and \cs{fixdvipslayout}, then we no longer need \Lpack{luatex85}}
% Outputting the size of the output document. This is a little tricky as
% the various engines do not quite agree on which variables to use. As
% of 2018 we will be using this: First of \cs{pdfpageheight/width} is
% used by pdf(e)tex based enginges. We set them if they are
% defined. Just incase someone need to be able to patch this, we make
% it into a macro and just run it at the start of the cocument
% \begin{macrocode}
\newcommand\mem@fixpagelayout{%
\@ifundefined{pdfpageheight}{}{\pdfpageheight=\the\stockheight}
\@ifundefined{pdfpagewidth}{}{\pdfpagewidth=\the\stockwidth}
% \end{macrocode}
% Next comes the two macros that recent luaTeX versions use instead of
% the \cs{pdf...} equivalents.
% \begin{macrocode}
\@ifundefined{pageheight}{}{\pageheight=\the\stockheight}
\@ifundefined{pagewidth}{}{\pagewidth=\the\stockwidth}
% \end{macrocode}
% If is unclear why these were added to the class sources in the first
% place, we'll just leave them.
% \begin{macrocode}
\@ifundefined{pdfvorigin}{}{\ifdim\pdfvorigin=0pt\pdfvorigin=1in\fi}
\@ifundefined{pdfhorigin}{}{\ifdim\pdfhorigin=0pt\pdfhorigin=1in\fi}
% \end{macrocode}
% Lastly we need to output a special to the DVI, but other engines can
% also understand specials, so to not end up getting those pesky
% non-PDF special warnings, we need some engine tests before emiting
% the data to the DVI.
% \begin{macrocode}
\ifluatex\else
\ifxetex\else
\ifpdf\else
\AtBeginDvi{\special{papersize=\the\stockwidth,\the\stockheight}}
\fi
\fi
\fi
}
\AtBeginDocument{\mem@fixpagelayout}
% \end{macrocode}
%
% \changes{v3.7k}{2020/03/25}{Added a link to \cs{mem@fixpagelayout}}
% \begin{macrocode}
\let\refixpagelayout\mem@fixpagelayout
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fixpdflayout}
% \begin{macro}{\fixdvipslayout}
% As of 2018 these are disabled
% ^^A % Page layout with pdf\LaTeX{} seems a bit iffy.
% ^^A % At the suggestion of Lars Madsen, help with
% ^^A % setting viewer (e.g., ghostview)
% ^^A % window sizes for dvi/ps. \cs{fixdvipslayout} does for \file{dvi} output
% ^^A % as \cs{fixpdflayout} does for \file{pdf} output.
% \changes{v1.4}{2003/11/22}{Added \cs{fixpdflayout} (from patch v1.6)}
% \changes{v1.4}{2003/12/01}{Added \cs{fixdvipslayout} }
% \changes{v1.61803398}{2009/08/17}{on ctt dynamotwain suggested a
% change to \cs{fixpdflayout} and the following \cs{AtBeginDocument}
% such that the \cs{special} is not outputtet when running xelatex}
% \begin{macrocode}
\newcommand*{\fixpdflayout}{%
\ClassWarning{memoir}{As of 2018, \string\fixpdflayout\ is no longer used}
% \pdfpageheight=\the\stockheight
% \pdfpagewidth=\the\stockwidth
% \ifxetex\else
% \ifdim\pdfvorigin=0pt\pdfvorigin=1in\fi
% \ifdim\pdfhorigin=0pt\pdfhorigin=1in\fi
% \fi
}
\newcommand*{\fixdvipslayout}{%
\ClassWarning{memoir}{As of 2018, \string\fixdvipslayout\ is no longer used}
%\AtBeginDvi{\special{papersize=\the\stockwidth,\the\stockheight}}
}
% \end{macrocode}
% ^^A % \AtBeginDocument{%
% ^^A % \ifxetex
% ^^A % \fixpdflayout
% ^^A % \else
% ^^A % \ifpdf
% ^^A % \ifnum\pdfoutput<\@ne
% ^^A % \fixdvipslayout
% ^^A % \else
% ^^A % \fixpdflayout
% ^^A % \fi
% ^^A % \else
% ^^A % \fixdvipslayout
% ^^A % \fi
% ^^A % \fi}
%
% ^^A % With a landscape document when going \texttt{latex -> dvips} the
% ^^A % resulting \file{.ps} file
% ^^A % may apear upside down in \texttt{ghostview}. If this happens, try putting
% ^^A % the following in the document preamble:
% ^^A % \begin{verbatim}
% ^^A % \addtodef{\fixdvipslayout}{}{%
% ^^A % \special{!TeXDict begin /landplus90{true}store end }}
% ^^A % \end{verbatim}
% ^^A % See \texttt{http://www.radicaleye.com.dvips.html} (DVIPS Home Page) for
% ^^A % an explanation.
% ^^A %
% ^^A % Some other potential specials for PostScript printing may be
% ^^A % (at least for an HP 5SiMx LaserJet duplex printer):
% ^^A % \begin{verbatim}
% ^^A % \special{!TeXDict begin <</Duplex true>>
% ^^A % setpagedevice end} % duplex
% ^^A % \special{!TeXDict begin <</Tumble true>>
% ^^A % setpagedevice end} % short side binding
% ^^A % \end{verbatim}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\typeoutstandardlayout}
% Types out the current values of the standard page layout parameters.
% \changes{v1.0a}{2002/01/25}{Added \cs{typeoutstandardlayout}}
% \changes{v3.6g}{2010/09/17}{changed such that the user can change
% the unit being used}
% \begin{macrocode}
\newcommand{\typeoutstandardlayout}{%
\typeout{}
\typeout{******************************************************}
% \typeout{Page height and width:
% \the\paperheight\space by \the\paperwidth}
\mem@typeouttwolengths{Page height and width}{\paperheight}{by}{\paperwidth}
% \typeout{Text height and width:
% \the\textheight\space by \the\textwidth}
\mem@typeouttwolengths{Text height and width}{\textheight}{by}{\textwidth}
% \typeout{Oddside and evenside margins:
% \the\oddsidemargin\space and \the\evensidemargin}
\mem@typeouttwolengths{Oddside and evenside margins}{\oddsidemargin}{and}{\evensidemargin}
% \typeout{Topmargin and footskip:
% \the\topmargin\space and \the\footskip}
\mem@typeouttwolengths{Topmargin and footskip}{\topmargin}{and}{\footskip}
% \typeout{Headheight and headsep:
% \the\headheight\space and \the\headsep}
\mem@typeouttwolengths{Headheight and headsep}{\headheight}{and}{\headsep}
% \typeout{Columnsep and columnseprule:
% \the\columnsep\space and \the\columnseprule}
\mem@typeouttwolengths{Columnsep and columnseprule}{\columnsep}{and}{\columnseprule}
% \typeout{Marginparsep and marginparwidth:
% \the\marginparsep\space and \the\marginparwidth}
\mem@typeouttwolengths{Marginparsep and marginparwidth}{\marginparsep}{and}{\marginparwidth}
\typeout{******************************************************}
\typeout{}
}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Some predefined layouts}
%
% A few predefined layouts for the textblock are presented. The \cs{checkandfixthelayout}
% macro \emph{must} be called afterwards.
%
% \begin{macro}{\medievalpage}
% This implements Jan Tschichold's reconstruction of the page and textblock
% layout used by medieval scribes and the early printers.
% The spine, top, edge and bottom margins are in the ratios 2:3:4:6.
%
% \cs{medievalpage}\oarg{num} positions the typeblock on the page with the
% margins in the above ratios. The spine margin is (page width)/\meta{num}
% (default 9). This must be an integer.
% \changes{v1.61803}{2008/01/30}{Added \cs{medievalpage}}
% \begin{macrocode}
%%%% s = w/#1, t = 1.5s, e = 2s, f = 3s
\newcommand*{\medievalpage}[1][9]{%
\spinemargin=\paperwidth
\divide\spinemargin #1\relax
\uppermargin = 1.5\spinemargin
\setlrmarginsandblock{\spinemargin}{*}{2}
\setulmarginsandblock{\uppermargin}{*}{2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\isopage}
% An implementation of Bringhurst's layout for ISO proportioned pages.
% It works for any page though. The edge margin is twice the spine,
% and the bottom margin is twice the top.
%
% \cs{isopage}\oarg{num} positions and sizes the typeblock on the page
% according to the above ratios. The spine is (page width)/\meta{num}
% and the top margin id (page height)/\meta{num}. \meta{num} must be
% an integer.
% \changes{v1.61803}{2008/01/30}{Added \cs{isopage}}
% \begin{macrocode}
% s = w/#1, e = 2s, t = h/#1, f = 2h
\newcommand*{\isopage}[1][9]{%
\spinemargin=\paperwidth
\divide\spinemargin #1\relax
\uppermargin=\paperheight
\divide\uppermargin #1\relax
\setlrmarginsandblock{\spinemargin}{*}{2}
\setulmarginsandblock{\uppermargin}{*}{2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\semiisopage}
% An variation on Bringhurst's layout for ISO proportioned pages.
% It works for any page though. The top margin is the same as the spine,
% and the edge and bottom margins are twice the spine.
%
% \cs{semiisopage}\oarg{num} positions and sizes the typeblock on the page
% according to the above ratios. The spine is (page width)/\meta{num}.
% \meta{num} must be an integer.
% \changes{v1.61803}{2008/01/30}{Added \cs{isopage}}
% \begin{macrocode}
%%% s = w/#1, t = s, e = 2s, f = e
\newcommand*{\semiisopage}[1][9]{%
\spinemargin=\paperwidth
\divide\spinemargin #1\relax
\uppermargin=\spinemargin
\setlrmarginsandblock{\spinemargin}{*}{2}
\setulmarginsandblock{\uppermargin}{*}{2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setpagebl}
% \begin{macro}{\setpageml}
% \begin{macro}{\setpagetl}
% \begin{macro}{\setpagetm}
% \cs{setpagebl}\marg{height}\marg{width}\marg{ratio} sets a page smaller than
% the stock size at the bottom left of the stock. The arguments are the
% the same as for \cs{settrimmedsize};
% \meta{height}, \meta{width} and \meta{ratio} of height and width
% (choose any two) of the desired page size. The trims are adjusted to suit.
% \cs{setpagetl} puts the page at the top left, \cs{setpageml} at the
% middle left, and \cs{setpagetm} at the top middle.
% \changes{v1.61803}{2008/01/30}{Added \cs{setpagebl}, \cs{setpageml}, and
% \cs{setpagetl}}
% \changes{v1.6180339c}{2008/12/26}{Added \cs{setpagetm}}
% \begin{macrocode}
\newcommand*{\setpagebl}[3]{%
\settrimmedsize{#1}{#2}{#3}%
\trimtop=\stockheight \advance\trimtop -\paperheight
\trimedge=\stockwidth \advance\trimedge -\paperwidth}
\newcommand*{\setpageml}[3]{%
\settrimmedsize{#1}{#2}{#3}
\trimtop=\stockheight \advance\trimtop -\paperheight
\advance\trimtop -0.5\trimtop
\trimedge=\stockwidth \advance\trimedge -\paperwidth}
\newcommand*{\setpagetl}[3]{%
\settrimmedsize{#1}{#2}{#3}
\trimtop=0pt
\trimedge=\stockwidth \advance\trimedge -\paperwidth}
\newcommand*{\setpagetm}[3]{%
\settrimmedsize{#1}{#2}{#3}%
\trimtop=0pt
\trimedge=\stockwidth \advance\trimedge -\paperwidth
\advance\trimedge -0.5\trimedge}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setpagetr}
% \begin{macro}{\setpagemr}
% \begin{macro}{\setpagebr}
% \begin{macro}{\setpagebm}
% \begin{macro}{\setpagecc}
% Similar to those above, these macros set the page on the stock
% at the top right, middle right, bottom right, bottom middle, and centered.
% \changes{v1.6180339c}{2008/12/26}{Added \cs{setpagetr}, \cs{setpagemr}, \cs{setpagebr},
% \cs{setpagebm} and \cs{setpagecc}}
% \changes{v3.7k}{2020/03/15}{Added \cs{setpagemm} as an alias to \cs{setpagecc}}
% \begin{macrocode}
\newcommand*{\setpagetr}[3]{%
\settrimmedsize{#1}{#2}{#3}%
\trimtop=0pt
\trimedge=0pt}
\newcommand*{\setpagemr}[3]{%
\settrimmedsize{#1}{#2}{#3}%
\trimtop=\stockheight \advance\trimtop -\paperheight
\advance\trimtop -0.5\trimtop
\trimedge=0pt}
\newcommand*{\setpagebr}[3]{%
\settrimmedsize{#1}{#2}{#3}%
\trimtop=\stockheight \advance\trimtop -\paperheight
\trimedge=0pt}
\newcommand*{\setpagebm}[3]{%
\settrimmedsize{#1}{#2}{#3}%
\trimtop=\stockheight \advance\trimtop -\paperheight
\trimedge=\stockwidth \advance\trimedge -\paperwidth
\advance\trimedge -0.5\trimedge}
\newcommand*{\setpagecc}[3]{%
\settrimmedsize{#1}{#2}{#3}%
\trimtop=\stockheight \advance\trimtop -\paperheight
\advance\trimtop -0.5\trimtop
\trimedge=\stockwidth \advance\trimedge -\paperwidth
\advance\trimedge -0.5\trimedge}
\let\setpagemm\setpagecc
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \subsection{Float placement parameters}
%
%
% All float parameters are given default values in the \LaTeX{}
% kernel. For this reason counters only need to be set with
% \cs{setcounter} and other parameters are set using \cs{renewcommand}.
%
% \paragraph{Limits for the placement of floating objects}
%
% The settings here make it easier to place floats than with the
% standard classes.
%
% \begin{macro}{\c@topnumber}
% The \Lcount{topnumber} counter holds the maximum number of
% floats that can appear on the top of a text page (classically 2)
% \begin{macrocode}
\setcounter{topnumber}{3}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\topfraction}
% This indicates the maximum part of a text page that can be
% occupied by floats at the top (classically 0.7).
% \begin{macrocode}
\renewcommand{\topfraction}{.85}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@bottomnumber}
% The \Lcount{bottomnumber} counter holds the maximum number of
% floats that can appear on the bottom of a text page (classically 1).
% \begin{macrocode}
\setcounter{bottomnumber}{2}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bottomfraction}
% This indicates the maximum part of a text page that can be
% occupied by floats at the bottom (classically 0.3).
% \begin{macrocode}
\renewcommand{\bottomfraction}{.5}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@totalnumber}
% This indicates the maximum number of floats that can appear on
% any text page (classically 3).
% \begin{macrocode}
\setcounter{totalnumber}{4}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\textfraction}
% This indicates the minimum part of a text page that has to be
% occupied by text (classically 0.2).
% \begin{macrocode}
\renewcommand{\textfraction}{.1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\floatpagefraction}
% This indicates the minimum part of a page that has to be
% occupied by floating objects before a `float page' is
% produced (classically 0.5).
% \begin{macrocode}
\renewcommand{\floatpagefraction}{.7}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@dbltopnumber}
% The \Lcount{dbltopnumber} counter holds the maximum number of
% two column floats that can appear on the top of a two column text
% page (classically 2).
% \begin{macrocode}
\setcounter{dbltopnumber}{3}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dbltopfraction}
% This indicates the maximum part of a two column text page that
% can be occupied by two column floats at the top (classically 0.7).
% \begin{macrocode}
\renewcommand{\dbltopfraction}{.85}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dblfloatpagefraction}
% This indicates the minimum part of a page that has to be
% occupied by two column wide floating objects before a `float
% page' is produced (classically 0.5).
% \begin{macrocode}
\renewcommand{\dblfloatpagefraction}{.7}
% \end{macrocode}
% \end{macro}
%
%
% \section{Page Styles}
%
% The page style \pstyle{foo} is defined by defining the command
% \cs{ps@foo}. This command should make only local definitions.
% There should be no stray spaces in the definition, since they
% could lead to mysterious extra spaces in the output.
%
% \begin{macro}{\@evenhead}
% \begin{macro}{\@oddhead}
% \begin{macro}{\@evenfoot}
% \begin{macro}{\@oddfoot}
% The \cs{ps@...} command defines the macros \cs{@oddhead},
% \cs{@oddfoot}, \cs{@evenhead}, and \cs{@evenfoot} to define the running
% heads and feet---e.g., \cs{@oddhead} is the macro to produce the
% contents of the heading box for odd-numbered pages. It is called
% inside an \cs{hbox} of width \cs{textwidth}.
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Marking conventions}
%
% To make headings determined by the sectioning commands, the page
% style defines the commands \cs{chaptermark}, \cs{sectionmark},
% \ldots,\\
% where \cs{chaptermark}\marg{TEXT} is called by
% \cs{chapter} to set a mark, and so on.
%
% The \cs{...mark} commands and the \cs{...head} macros are defined
% with the help of the following macros. (All the \cs{...mark}
% commands should be initialized to no-ops.)
%
% \LaTeX{} extends \TeX's \cs{mark} facility by producing two kinds
% of marks, a `left' and a `right' mark, using the following
% commands:
% \begin{flushleft}
% \cs{markboth}\marg{LEFT}\marg{RIGHT}: Adds both marks.
%
% \cs{markright}\marg{RIGHT}: Adds a `right' mark.
%
% \cs{leftmark}: Used in the \cs{@oddhead}, \cs{@oddfoot}, \cs{@evenhead}
% or \cs{@evenfoot} macros, it gets the current `left'
% mark. \cs{leftmark} works like \TeX's \cs{botmark}
% command.
%
% \cs{rightmark}: Used in the \cs{@oddhead}, \cs{@oddfoot}, \cs{@evenhead}
% or \cs{@evenfoot} macros, it gets the current
% `right' mark. \cs{rightmark} works like \TeX's
% \cs{firstmark} command.
% \end{flushleft}
%
% The marking commands work reasonably well for right marks
% `numbered within' left marks--e.g., the left mark is changed by a
% \cs{chapter} command and the right mark is changed by a \cs{section}
% command. However, it does produce somewhat anomalous results if
% two \cs{markboth}'s occur on the same page.
%
%
% Commands like \cs{tableofcontents} that should set the marks in some
% page styles use a \cs{@mkboth} command, which is \cs{let} by the
% pagestyle command (\cs{ps@...}) to \cs{markboth} for setting the
% heading or to \cs{@gobbletwo} to do nothing.
%
%
%
% \subsection{Defining the page styles}
%
% This class provides a set of commands for the user to define new
% pagestyles. Essentially defining a pagestyle consists of defining the
% macros \cs{@evenhead}, \cs{@oddhead}, \cs{@evenfoot}, and \cs{@oddfoot}.
% For this class, each header and footer is treated as three parts: a left,
% center, and right part. In this case, defining a pagestyle consists of
% specifying these 12 portions of the running headers and footers. The
% width of the headers/footers may also be specified, rules may be drawn
% below the headers and/or above the footers, and the complete header and/or
% footer may be offset with respect to the textblock when the width is not
% the same as the textwidth.
%
% In the following \meta{style} is the name of a pagestyle being defined
% (e.g., \verb?ruled?).
%
% \changes{v1.61803398d}{2010/02/09}{Added the following three macros}
% \begin{macro}{\mem@set@ps@xtra@info}
% \begin{macro}{\mem@ps@find@real}
% \begin{macro}{\mem@ps@safe@change}
% The class supports an aliasing feature, where a page style name can
% actually call the code from another. Quite handy. But There might be
% problems if a use try to modify an alias page style. We care for
% this by storing some information about each page style, and throwing
% an error if the user atempts to alter a page style marked as an
% alias.
%
% \verb?\mem@set@ps@xtra@info? store two things: the name of the style
% we are an alias for (if we are not an alias it will be blank) and an
% indicator whether we are an alias (00 if we are and 01 if we are not).
% \begin{macrocode}
\newcommand\mem@set@ps@xtra@info[3]{%
\@namedef{ps@#1@aliasfor}{#2}%
\@namedef{ps@#1@isalias}{#3}}
% \end{macrocode}
% \verb?\mem@ps@find@real? starts at a given page style, if it is
% marked as an alias, it will recursively go down the chain of aliases
% and save the name of the first real page style in \verb?\@tempa?.
% \begin{macrocode}
\newcommand\mem@ps@find@real[1]{%
\if\@nameuse{ps@#1@isalias}\relax
\mem@ps@find@real{\@nameuse{ps@#1@aliasfor}}
\else\def\@tempa{#1}\fi}
% \end{macrocode}
% \verb?\mem@ps@safe@change? takes a page style name, checks to see if
% it is defined, if it is, it checks to see if it is safe to change
% it.
% \changes{v3.7c}{2014/05/20}{Typo reported by Werner Grundlingh}
% \begin{macrocode}
\newcommand\mem@ps@safe@change[1]{%
\@ifundefined{ps@#1}{%
\@memerror{Undefined pagestyle '#1', so I cannot change it}{}}{}
\if\@nameuse{ps@#1@isalias}\relax \mem@ps@find@real{#1}
\@memerror{The pagestyle '#1' is marked as an alias page style.^^J
Modifying an alias page style may give unexpected results.^^J The
alias chain resolves to the real page style '\@tempa', so try
issuing^^J \string\copypagestyle{#1}{\@tempa}^^J
before modifying '#1'}{} \fi }
% \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\makeevenhead}
% The command
% \cs{makeevenhead}\marg{style}\marg{left}\marg{center}\marg{right}
% specifies that the left, center and right portions of the even header for
% pagestyle \meta{style} are defined as the other three arguments, respectiveley.
% Internally it defines the commands \cs{styleeheadl}, \cs{styleeheadc} and
% \cs{styleeheadr} to be \meta{left}, \meta{center} and \meta{right} respectively.
% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand{\makeevenhead}[4]{%
\mem@ps@safe@change{#1}
\@namedef{#1eheadl}{#2}
\@namedef{#1eheadc}{#3}
\@namedef{#1eheadr}{#4}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makeoddhead}
% \begin{macro}{\makeevenfoot}
% \begin{macro}{\makeoddfoot}
% These three macros are similar to \cs{makeevenhead} except that they are
% for the oddhead, evenfoot and oddfoot.
% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand{\makeoddhead}[4]{%
\mem@ps@safe@change{#1}
\@namedef{#1oheadl}{#2}
\@namedef{#1oheadc}{#3}
\@namedef{#1oheadr}{#4}
}
\newcommand{\makeevenfoot}[4]{%
\mem@ps@safe@change{#1}
\@namedef{#1efootl}{#2}
\@namedef{#1efootc}{#3}
\@namedef{#1efootr}{#4}
}
\newcommand{\makeoddfoot}[4]{%
\mem@ps@safe@change{#1}
\@namedef{#1ofootl}{#2}
\@namedef{#1ofootc}{#3}
\@namedef{#1ofootr}{#4}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\makerunningwidth}
% \begin{macro}{\makerunningheadwidth}
% \begin{macro}{\makerunningfootwidth}
% \begin{macro}{\m@mhfstyle}
% \begin{macro}{\m@mopthfwidth}
% The macro \cs{makerunningwidth}\marg{style}\oarg{ftlength}\marg{length}
% sets the
% width of the headers and footers of pagestyle \meta{style} to
% be \meta{length}, but if \meta{ftlength} is present the footer
% width is set to \meta{ftlength}. The lengths are stored as the
% macros \cs{styleheadrunwidth} and \cs{stylefootrunwidth}. The two
% widths can be set individually using
% \cs{makerunningheadwidth}\marg{style}\marg{length} and
% \cs{makerunningfootwidth}\marg{style}\marg{length}.
% \changes{v1.6180339c}{2008/12/26}{Enabled the width of headers and footers
% to be different
% (requested by Wilhelm M\"{u}ller).}
% \changes{v1.6180339c}{2009/01/13}{Added \cs{makerunningheadwidth}
% and \cs{makerunningfootwidth}}.
% \changes{v1.6180339d}{2009/02/04}{Fixed a mental bug, /daleif}
% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand*{\makerunningwidth}[1]{%
\mem@ps@safe@change{#1}%
\def\m@mhfstyle{#1}%
\m@mopthfwidth}
\newcommand*{\m@mopthfwidth}[2][\@mpty]{%
% \setlength\@tempdima{#2}
\@namedef{\m@mhfstyle headrunwidth}{#2}%
% \expandafter\edef\csname \m@mhfstyle headrunwidth\endcsname{\the\@tempdima}
\ifx\@mpty #1
\@namedef{\m@mhfstyle footrunwidth}{#2}%
% \expandafter\edef\csname \m@mhfstyle footrunwidth\endcsname{\the\@tempdima}
\else
\@namedef{\m@mhfstyle footrunwidth}{#1}%
% \setlength\@tempdima{#1}
% \expandafter\edef\csname \m@mhfstyle footrunwidth\endcsname{\the\@tempdima}
\fi}
\newcommand*{\makerunningheadwidth}[2]{%
% \setlength\@tempdima{#2}%
% \expandafter\edef\csname \m@mhfstyle headrunwidth\endcsname{\the\@tempdima}%
\mem@ps@safe@change{#1}%
\@namedef{#1headrunwidth}{#2}%
}
\newcommand*{\makerunningfootwidth}[2]{%
% \setlength\@tempdima{#2}%
\mem@ps@safe@change{#1}%
\@namedef{#1footrunwidth}{#2}%
% \expandafter\edef\csname \m@mhfstyle footrunwidth\endcsname{\the\@tempdima}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\normalrulethickness}
% \begin{macro}{\footruleheight}
% \begin{macro}{\footruleskip}
% \begin{macro}{\makeheadrule}
% \begin{macro}{\makefootrule}
% \cs{normalrulethickness} is the thickness of a normal horizontal
% or vertical rule.
% \cs{footruleheight} is the height of a normal rule above a footer (actually zero).
% \cs{footruleskip} is a distance sufficient to ensure that a foot rule
% will appear between the bottom of the textblock and above any actual footer.
%
% (There was a \ctt{} thread \textit{ngerman, fancyhdr and \cs{footrulewidth} --- bug?}
% in December 2002 that bears on the definitions below).
% \changes{v1.4}{2003/02/27}{Make \cs{normalrulethickness} a length,
% not a macro (patch 1.1)}
% \changes{v1.4}{2003/02/27}{Initialise \cs{footruleheight} to 0pt, not
% \cs{z@skip} (patch 1.1)}
% \begin{macrocode}
\newlength{\normalrulethickness}
\setlength{\normalrulethickness}{0.4pt}
\newcommand{\footruleheight}{0pt}
\newcommand{\footruleskip}{0.3\normalbaselineskip}
% \end{macrocode}
% The macro \cs{makeheadrule}\marg{style}\marg{width}\marg{height}
% specifies the width and height of the header rule for \meta{style}.
%
% Similarly
% \cs{makefootrule}\marg{style}\marg{width}\marg{height}\marg{skip}
% specifies the width, height and skip for the footrule.
% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \changes{v3.7d}{2015/04/22}{Moved \cs{...(head|foot)ruleprefix} out and
% added them else where}
% \begin{macrocode}
\newcommand{\makeheadrule}[3]{%
\mem@ps@safe@change{#1}%
\@namedef{#1headrule}{%
\hrule\@width #2\@height #3 \vskip-#3}}
\newcommand{\makefootrule}[4]{%
\mem@ps@safe@change{#1}%
\@namedef{#1footrule}{%
\vskip-#4\vskip-#3%
\hrule\@width #2\@height #3 \vskip #4}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \changes{v3.6h}{2011/01/25}{Added this macro}
% \begin{macro}{\makeheadfootruleprefix}
% We insert a maro at the start of the head and foot rule. By default
% it does nothing, but it can be ised to specify a different color to
% the head or foot rules.
% \begin{macrocode}
\newcommand\makeheadfootruleprefix[3]{%
\@namedef{#1headruleprefix}{#2}%
\@namedef{#1footruleprefix}{#3}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makeheadposition}
% \cs{makeheadposition}\marg{style}\marg{eheadpos}\marg{oheadpos}\marg{efootpos}\marg{ofootpos}
% specifies the horizontal positioning of the even and odd headers and footers,
% respectively,
% for the pagestyle \meta{style}. Each of the \meta{...pos} arguments may be
% either \verb?flushleft?, \verb?center? or \verb?flushright?, with the obvious meanings.
% An empty argument (or an unrecognised one) is equivalent to \verb?center?.
% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand{\makeheadposition}[5]{%
\mem@ps@safe@change{#1}%
% \end{macrocode}
% Do the even head position first.
% \begin{macrocode}
\nametest{flushleft}{#2}
\ifsamename
\@namedef{#1evenheadpl}{\relax} \@namedef{#1evenheadpr}{\hss}
\else
\nametest{flushright}{#2}
\ifsamename
\@namedef{#1evenheadpl}{\hss} \@namedef{#1evenheadpr}{\relax}
\else
\@namedef{#1evenheadpl}{\hss} \@namedef{#1evenheadpr}{\hss}
\fi
\fi
% \end{macrocode}
% And similarly for the odd head and even \& odd footers.
% \begin{macrocode}
\nametest{flushleft}{#3}
\ifsamename
\@namedef{#1oddheadpl}{\relax} \@namedef{#1oddheadpr}{\hss}
\else
\nametest{flushright}{#3}
\ifsamename
\@namedef{#1oddheadpl}{\hss} \@namedef{#1oddheadpr}{\relax}
\else
\@namedef{#1oddheadpl}{\hss} \@namedef{#1oddheadpr}{\hss}
\fi
\fi
\nametest{flushleft}{#4}
\ifsamename
\@namedef{#1evenfootpl}{\relax} \@namedef{#1evenfootpr}{\hss}
\else
\nametest{flushright}{#4}
\ifsamename
\@namedef{#1evenfootpl}{\hss} \@namedef{#1evenfootpr}{\relax}
\else
\@namedef{#1evenfootpl}{\hss} \@namedef{#1evenfootpr}{\hss}
\fi
\fi
\nametest{flushleft}{#5}
\ifsamename
\@namedef{#1oddfootpl}{\relax} \@namedef{#1oddfootpr}{\hss}
\else
\nametest{flushright}{#5}
\ifsamename
\@namedef{#1oddfootpl}{\hss} \@namedef{#1oddfootpr}{\relax}
\else
\@namedef{#1oddfootpl}{\hss} \@namedef{#1oddfootpr}{\hss}
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makepsmarks}
% \begin{macro}{\makepshook}
% The macro \cs{makepsmarks}\marg{style}\marg{code} specifies that
% \meta{code} is the definition of the hook for pagestyle \meta{style}.
% \cs{makepshook} was a deprecated version of \cs{makepsmarks} and is
% now deleted.
% \changes{v1.0}{2001/11/15}{Added \cs{makepsmarks} and deprecated
% \cs{makepshook}}
% \changes{v1.4}{2003/12/14}{Deleted \cs{makepshook}}
% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand{\makepsmarks}[2]{\mem@ps@safe@change{#1}\@namedef{#1pshook}{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mhe@dreset}
% To cater for potential baselineskip changes, such as \verb?\linespread{2}?,
% we have to ensure they don't percolate into the header/footer.
% (See CTT thread \textit{memoir + linespread}, 2004/02/11)
% \changes{v1.61}{2004/03/14}{Added \cs{m@mhe@dreset}}
% \begin{macrocode}
\newcommand*{\m@mhe@dreset}{\def\baselinestretch{1}\normalsize}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makeheadfootvposition}
% The headers and footers are typeset inside \cs{parbox}'es, using
% \cs{makeheadfootvposition}\marg{style}\marg{headvpos}\marg{footvpost}
% users can specify whether the alignment should be b,t or~c.The
% default is~b.
% \changes{v1.6180339c}{2009/01/13}{Added support for
% controlling the alignment of the headers and footers}
% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand*\makeheadfootvposition[3]{%
\mem@ps@safe@change{#1}%
\@namedef{#1headvplacement}{#2}\@namedef{#1footvplacement}{#3}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\mem@maxheadheight}
% \begin{macro}{\mem@maxfootheight}
% \begin{macro}{\mem@sayonce@head}
% \begin{macro}{\mem@sayonce@foot}
% \begin{macro}{\mem@hf@measure@vbox}
% \begin{macro}{\mem@toolarge@header@message}
% \begin{macro}{\mem@toolarge@footer@message}
% \changes{v3.6h}{2010/10/21}{Added the above seven macros to be able
% to measure the headers and warn users if their design takes them outside.}
% \verb?\mem@maxheadheight? and \verb?\mem@maxfootheight? globally
% stores the max measured head and foot heights. Actually the footer
% ought to be measuring the total height and depth. We may add this
% later. The two XsayonceX macros are toggles used such that we can
% add a warning at only the first bad head/foot. We repeat the message
% at the end of the document.
% \begin{macrocode}
\newlength\mem@maxheadheight
\newlength\mem@maxfootheight
\newcommand\mem@sayonce@head{00}
\newcommand\mem@sayonce@foot{00}
% \end{macrocode}
% This is the work horse of this construction. First argument is the
% height to compare against, second should be \texttt{head} or
% \texttt{foot}, third is the warning message, and the fourth is the
% material to be measured. The idea to taken from \Lpack{fancyhdr}.
% \begin{macrocode}
\newcommand\mem@hf@measure@vbox[4]{%
\setbox0\vbox{#4}%
\ifdim\ht0>#1\relax%
\setlength\@tempdima{\@nameuse{mem@max#2height}}%
\ifdim\ht0>\@tempdima\relax%
\expandafter\global\@nameuse{mem@max#2height}=\ht0%
\expandafter\if\@nameuse{mem@sayonce@#2}\relax%
\@memwarn{#3}%
\global\@namedef{mem@sayonece@#2}{01}%
\fi%
\fi%
\fi%
\box0%
}
% \end{macrocode}
% Warning messages
% \begin{macrocode}
\newcommand\mem@toolarge@header@message{%
The material used in the headers is too large^^J%
(\the\mem@maxheadheight) for the given head height
(\the\headheight), it is recommended to^^J%
either increase the head height or redesign the header^^J%
(in both cases you will find help in the memoir manual).%
}
\newcommand\mem@toolarge@footer@message{%
The material used in the footer is too large^^J%
(\the\mem@maxfootheight) for the given foot skip
(\the\footskip), it is recommended to^^J%
either increase the foot skip or redesign the footer^^J%
(in both cases you will find help in the memoir manual).%
}
% \end{macrocode}
% To make things easier to read we make two short cut macros
% \begin{macrocode}
\newcommand\mem@hvboxm[1]{%
\mem@hf@measure@vbox\headheight{head}\mem@toolarge@header@message{#1}}
\newcommand\mem@fvboxm[1]{%
\mem@hf@measure@vbox\footskip{foot}\mem@toolarge@footer@message{#1}}
% \end{macrocode}
% Make sure to repeat the message at the end of the document. This
% will show the max value up until the point where the end of document
% stuff is executed.
% \begin{macrocode}
\AtEndDocument{
\ifdim\mem@maxheadheight>\headheight
\@memwarn{\mem@toolarge@header@message}
\fi
\ifdim\mem@maxfootheight>\footskip
\@memwarn{\mem@toolarge@footer@message}
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\mem@ps@entry@wrap}
% \changes{v3.6h}{2010/10/06}{Added this to help bidi control the
% typesetting direction of the header and footer}
% This macro is wrapped around eash entry in the headers and
% footers. By default it does nothing, but can be redefined by
% packages such as \Lpack{bidi} to control the typesetting direction
% in the header. Bidi for example has two modes such that headers
% can be RTL locally while the header stay at LTR. If this macro is
% changed, it will be a good idea to coordinate it with the bidi
% maintainer.
% \begin{macrocode}
\newcommand\mem@ps@entry@wrap{}
% \end{macrocode}
%
% \end{macro}
% \begin{macro}{\mem@ps@HLH}
% \changes{v3.6d}{2010/10/06/24}{Factored \cs{makepagestyle}}
% The entries in the header used in \cs{makepagestyle} (below) are
% more or less the same. It depends on \emph{head/foot},
% \emph{odd/even} and a shorter \emph{o/e}. So to make the code more
% maintainable we factor this out into a generator macro. The
% explanation for the code being used is kept below (see
% \cs{makepagestyle}).
% \changes{v3.6k}{2012/05/31}{Forgot to separate head/foot position into the
% factorization, propblem reported by Wybo Dekker on
% http://tex.stackexchange.com/q/56141/3929}
% \begin{macrocode}
\newcommand\mem@ps@HLH[4]{%
% #1 ps name
% #2 type: head, foot
% #3 odd/even
% #4 odd/even short (o,e)
\@namedef{#1@#3#2}{%
\@nameuse{#1#3#2pl}\hb@xt@\@nameuse{#1#2runwidth}{\m@mhe@dreset%
% \end{macrocode}
% In footers the line goes before the text, so we test and add the
% footline if \texttt{\#2} equals \texttt{foot}.
% \changes{v3.6h}{2010/10/06}{added the entry wrapper}
% \changes{v3.6h}{201010/10/21}{Added the header/footer measuring feature.}
% For the header/footer measuring stuff we look at \#2 and make the
% suiting macro from that value.
% \changes{v3.6h}{2010/10/22}{Added \cs{memRTLmainraggedX} macros such
% that \Lpack{bidi} can also change the order of the header if RTL is
% the main direction of the document.}
% \begin{macrocode}
\nametest{#2}{head}\ifsamename\let\mem@hfboxer\mem@hvboxm\else\let\mem@hfboxer\mem@fvboxm\fi%
% \end{macrocode}
% \changes{v3.7d}{2015/04/22}{Moved \cs{...footruleprefix} outside
% \cs{...footrule}. Otherwise copy does not work correctly. Reported
% at http://tex.stackexchange.com/q/231454/3929}
% \begin{macrocode}
\mem@hfboxer{\nametest{#2}{foot}\ifsamename%
\begingroup% to prevent colors from bleeding into the footer
\@nameuse{#1#2ruleprefix}%
\@nameuse{#1#2rule}%
\endgroup%
\fi%
\hbox{%
\rlap{%
\parbox[\@nameuse{#1#2vplacement}]{\@nameuse{#1#2runwidth}}{%
\memRTLmainraggedright\@nameuse{#1ps#2strut}%
\mem@ps@entry@wrap{\@nameuse{#1#4#2l}}%
\@nameuse{#1ps#2strut}}}\hfill
\parbox[\@nameuse{#1#2vplacement}]{\@nameuse{#1#2runwidth}}{%
\centering\@nameuse{#1ps#2strut}%
\mem@ps@entry@wrap{\@nameuse{#1#4#2c}}%
\@nameuse{#1ps#2strut}}\hfill
\llap{%
\parbox[\@nameuse{#1#2vplacement}]{\@nameuse{#1#2runwidth}}{%
\memRTLmainraggedleft\@nameuse{#1ps#2strut}%
\mem@ps@entry@wrap{\@nameuse{#1#4#2r}}%
\@nameuse{#1ps#2strut}}}%
}%
% \end{macrocode}
% In the header the line goes under the text, so we test and add the
% headline if \texttt{\#2} equals \texttt{head}.
% \changes{v3.6k}{2012/05/31}{Forgot to separate head/foot position into the
% factorization}
% \changes{v3.7d}{2015/04/22}{Moved \cs{...headruleprefix} outside
% \cs{...headrule}. Otherwise copy does not work correctly.}
% \begin{macrocode}
\nametest{#2}{head}\ifsamename%
\@nameuse{#1#2ruleprefix}%
\@nameuse{#1#2rule}%
\fi%
}}\@nameuse{#1#3#2pr}}%
% \end{macrocode}
% And end by letting the LaTeX head/foot use our version
% \begin{macrocode}
\@namedef{@#3#2}{\@nameuse{#1@#3#2}}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makepagestyle}
% At last we can put everything together for defining a new pagestyle,
% via the macro \cs{makepagestyle}\marg{style} which initially sets up
% a new pagestyle \meta{style} corresponding the the \LaTeX{} \verb?empty?
% pagestyle. The prior macros can then be used to make modifications
% to the style.
% \changes{v1.0}{2001/11/15}{Now 2 stage process for defining \cs{@evenhead}
% and friends}
% \changes{v1.61}{2004/03/14}{Added \cs{m@mhe@dreset} at several points in
% \cs{makepagestyle} (from patch 2.1)}
% \changes{v1.61803}{2008/01/30}{Removed extraneous spaces from pagestyle code
% (mempatch v4.6)}
% \changes{v1.61803398d}{2010/02/09}{Added storing extra information
% about page styles}
% We also make sure to specify that this is a `real' page style, and
% thus sets the empty alias name and the alias test to 01.
% \begin{macrocode}
\newcommand{\makepagestyle}[1]{%
\mem@set@ps@xtra@info{#1}{}{01}%
% \end{macrocode}
% First define the macro \cs{ps@style}, which in turn defines the macros
% \cs{@evenhead}, \cs{@oddhead}, \cs{@evenfoot} and \cs{@oddfoot}.
% \changes{v3.6d}{20101/06/24}{Factored \cs{makepagestyle}, such
% that \cs{#1@evenhead} and friends are made using \emph{one} single
% macro. We keep the original code just in case.}
% \begin{macrocode}
\@namedef{ps@#1}{%
\mem@ps@HLH{#1}{head}{even}{e}%
\mem@ps@HLH{#1}{head}{odd}{o}%
\mem@ps@HLH{#1}{foot}{even}{e}%
\mem@ps@HLH{#1}{foot}{odd}{o}%
% \@namedef{#1@evenhead}{%
% \end{macrocode}
% The code for the definition of \cs{@evenhead} and friends is based on code
% from Piet van Oostrum's \Lpack{fancyhdr} package~\cite{FANCYHDR}. The three
% parts of the header are put into parboxes, with fills between them, and
% the whole lot is put into a box the width of the header. Fillers are put
% before and after the main box which control the header position.
%
% First the left filler which is either \cs{relax} or \cs{hss}, and then
% start the main box.
% \changes{v1.6180339c}{2008/12/26}{Replaced \cs{...runwidth} by \cs{...headrunwidth}
% or \cs{...footrunwidth}, as appropriate for headers and footers.}
% \changes{v1.6180339c}{2009/01/13}{Replaced \cs{parbox}\texttt[b]
% with \cs{parbox}\texttt{[\cs{nameuse{#1headvplacement}}]} etc.}
% \begin{macrocode}
% \@nameuse{#1evenhpl}\hb@xt@\@nameuse{#1headrunwidth}{\m@mhe@dreset%
% \vbox{\hbox{%
% \end{macrocode}
% The left part of the header.
% \begin{macrocode}
% \rlap{\parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
% \raggedright\@nameuse{#1eheadl}\strut}}\hfill
% \end{macrocode}
% The center part of the header.
% \begin{macrocode}
% \parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
% \centering\@nameuse{#1eheadc}\strut}\hfill
% \end{macrocode}
% The right part of the header.
% \begin{macrocode}
% \llap{\parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
% \raggedleft\@nameuse{#1eheadr}\strut}}}%
% \end{macrocode}
% Finally, the header rule and finish with the right filler, which
% is either \cs{relax} or \cs{hss}.
% \begin{macrocode}
% \@nameuse{#1headrule}}}\@nameuse{#1evenhpr}}%
% \end{macrocode}
% The code for the \cs{@oddhead}, \cs{@evenfoot} and \cs{@oddfoot} follows
% a similar pattern. Here is \cs{@oddhead}.
% \begin{macrocode}
% \@namedef{#1@oddhead}{%
% \@nameuse{#1oddhpl}\hb@xt@\@nameuse{#1headrunwidth}{\m@mhe@dreset%
% \vbox{\hbox{%
% \rlap{\parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
% \raggedright\@nameuse{#1oheadl}\strut}}\hfill
% \parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
% \centering\@nameuse{#1oheadc}\strut}\hfill
% \llap{\parbox[\@nameuse{#1headvplacement}]{\@nameuse{#1headrunwidth}}{%
% \raggedleft\@nameuse{#1oheadr}\strut}}}%
% \@nameuse{#1headrule}}}\@nameuse{#1oddhpr}}%
% \end{macrocode}
% And \cs{@evenfoot}. For the footers the rules come \emph{before} any foot
% entries.
% \begin{macrocode}
% \@namedef{#1@evenfoot}{%
% \@nameuse{#1evenfpl}\hb@xt@\@nameuse{#1footrunwidth}{\m@mhe@dreset%
% \vbox{\@nameuse{#1footrule}\hbox{%
% \rlap{\parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
% \raggedright\@nameuse{#1efootl}\strut}}\hfill
% \parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
% \centering\@nameuse{#1efootc}\strut}\hfill
% \llap{\parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
% \raggedleft\@nameuse{#1efootr}\strut}}}%
% }}\@nameuse{#1evenfpr}}%
% \end{macrocode}
% Lastly the \cs{@oddfoot}.
% \begin{macrocode}
% \@namedef{#1@oddfoot}{%
% \@nameuse{#1oddfpl}\hb@xt@\@nameuse{#1footrunwidth}{\m@mhe@dreset%
% \vbox{\@nameuse{#1footrule}\hbox{%
% \rlap{\parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
% \raggedright\@nameuse{#1ofootl}\strut}}\hfill
% \parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
% \centering\@nameuse{#1ofootc}\strut}\hfill
% \llap{\parbox[\@nameuse{#1footvplacement}]{\@nameuse{#1footrunwidth}}{%
% \raggedleft\@nameuse{#1ofootr}\strut}}}%
% }}\@nameuse{#1oddfpr}}%
% \end{macrocode}
% Now we define \cs{@evenhead} etc., in terms of \verb?#1@evenhead?.
% \begin{macrocode}
% \def\@evenhead{\@nameuse{#1@evenhead}}%
% \def\@oddhead{\@nameuse{#1@oddhead}}%
% \def\@evenfoot{\@nameuse{#1@evenfoot}}%
% \def\@oddfoot{\@nameuse{#1@oddfoot}}%
% \end{macrocode}
% To finish off the definition of \cs{ps@style}, add in a hook which can be
% defined so that it adds additional code, if required.
% \begin{macrocode}
\@nameuse{#1pshook}}%
% \end{macrocode}
% \changes{v3.6d}{2010/06/24}{Added strut initialization} Next we
% initialize the struts being used. Remember the for the
% \pstyle{empty} style, the strut should be empty.
% \begin{macrocode}
\nametest{#1}{empty}%
\ifsamename%
\@namedef{#1psheadstrut}{}\@namedef{#1psfootstrut}{}%
\else%
\@namedef{#1psheadstrut}{\strut}\@namedef{#1psfootstrut}{\strut}%
\fi%
% \end{macrocode}
%
% The final part of setting up the new pagestyle
% is defining all the macros called by \cs{ps@style}, and giving them
% default values. Make the headers and footers empty.
% \begin{macrocode}
\makeevenhead{#1}{}{}{}%
\makeoddhead{#1}{}{}{}%
\makeevenfoot{#1}{}{}{}%
\makeoddfoot{#1}{}{}{}%
% \end{macrocode}
% Make the headers/footers the same width as the \cs{textwidth},
% center them, and ensure that the rules have zero height so that they
% will be invisible. Also initialize the head/foot prefixes.
% \changes{v3.6h}{2011/01/25}{Added the \cs{makeheadfootruleprefix}}
% \begin{macrocode}
\makerunningwidth{#1}{\textwidth}%
\makeheadposition{#1}{}{}{}{}%
\makeheadrule{#1}{\textwidth}{0pt}%
\makefootrule{#1}{\textwidth}{\footruleheight}{\footruleskip}%
\makeheadfootruleprefix{#1}{}{}
% \end{macrocode}
% Set the initial vertical header and footer positions.
% \changes{v1.6180339c}{2009/01/13}{Added head/foot position initialisation}
% \begin{macrocode}
\makeheadfootvposition{#1}{b}{b}%
% \end{macrocode}
% Finally, there is no addtional code needed, so make the hook empty, and
% we are done.
% \begin{macrocode}
\makepsmarks{#1}{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\aliaspagestyle}
% The command \cs{aliaspagestyle}\marg{alias}\marg{original}
% defines the \meta{alias} pagestyle to be an alias for the
% \meta{original} pagestyle.
% \changes{v1.61803398d}{2010/02/09}{Added page style storing info}
% We remember to set the stored alias name, and sets the alias test to
% true (00).
% \begin{macrocode}
\newcommand{\aliaspagestyle}[2]{%
\mem@set@ps@xtra@info{#1}{#2}{00}%
\@namedef{ps@#1}{\@nameuse{ps@#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\copypagestyle}
% The command \cs{copypagestyle}\marg{new}\marg{original}
% defines the \meta{new} pagestyle to be a copy of the
% \meta{original} pagestyle.
%
% It first makes the \meta{new} (empty) pagestyle then defines the internals
% in terms of the \meta{original} internals.
% \changes{v1.2}{2002/08/10}{Added \cs{copypagestyle}}
% \changes{v1.61803}{2008/01/30}{Added missing elements to \cs{copypagestyle}
% (per Erik Quaeghebeur mempatch v4.9)}
% \begin{macrocode}
\newcommand{\copypagestyle}[2]{%
\makepagestyle{#1}%
% \end{macrocode}
% Do the headers and footers.
% \begin{macrocode}
\makeevenhead{#1}{\@nameuse{#2eheadl}}%
{\@nameuse{#2eheadc}}{\@nameuse{#2eheadr}}%
\makeoddhead{#1}{\@nameuse{#2oheadl}}%
{\@nameuse{#2oheadc}}{\@nameuse{#2oheadr}}%
\makeevenfoot{#1}{\@nameuse{#2efootl}}%
{\@nameuse{#2efootc}}{\@nameuse{#2efootr}}%
\makeoddfoot{#1}{\@nameuse{#2ofootl}}%
{\@nameuse{#2ofootc}}{\@nameuse{#2ofootr}}%
% \end{macrocode}
% Set the width.
% \begin{macrocode}
\makerunningwidth{#1}[\@nameuse{#2footrunwidth}]{\@nameuse{#2headrunwidth}}%
% \end{macrocode}
% Specify the \cs{headposition}.
% \changes{v3.6k}{2012/05/31}{some macro renaming}
% \begin{macrocode}
\@namedef{#1evenheadpl}{\@nameuse{#2evenheadpl}}%
\@namedef{#1oddheadpl}{\@nameuse{#2oddheadpl}}%
\@namedef{#1evenheadpr}{\@nameuse{#2evenheadpr}}%
\@namedef{#1oddheadpr}{\@nameuse{#2oddheadpr}}%
% \end{macrocode}
% Also vertically
% \changes{v1.6180339c}{2008/01/13}{Also copy the vertical positions}
% \changes{v1.6180339e}{2008/02/06}{Bug fix, reported by Per
% Starb\"ack on ctt}
% \begin{macrocode}
\makeheadfootvposition{#1}{\@nameuse{#2headvplacement}}{\@nameuse{#2footvplacement}}%
% \end{macrocode}
% Specify the feet
% \changes{v3.6k}{2012/05/31}{some macro renaming}
% \begin{macrocode}
\@namedef{#1evenfootpl}{\@nameuse{#2evenfootpl}}%
\@namedef{#1oddfootpl}{\@nameuse{#2oddfootpl}}%
\@namedef{#1evenfootpr}{\@nameuse{#2evenfootpr}}%
\@namedef{#1oddfootpr}{\@nameuse{#2oddfootpr}}%
% \end{macrocode}
% Specify the head and foot rules and the prefixes.
% \changes{v3.6h}{2011/01/25}{Added the \cs{makeheadfootruleprefix}}
% \begin{macrocode}
\@namedef{#1headrule}{\@nameuse{#2headrule}}%
\@namedef{#1footrule}{\@nameuse{#2footrule}}%
\@namedef{#1headruleprefix}{\@nameuse{#2headruleprefix}}%
\@namedef{#1footruleprefix}{\@nameuse{#2footruleprefix}}%
% \end{macrocode}
% \changes{v3.6d}{2010/06/24}{Added strut copying to \cs{copypagestyle}}
% And remember the struts
% \begin{macrocode}
\@namedef{#1psheadstrut}{\@nameuse{#2psheadstrut}}
\@namedef{#1psfootstrut}{\@nameuse{#2psfootstrut}}
% \end{macrocode}
% \end{macro}
% And pick up the hook. We end the macro here.
% \begin{macrocode}
\makepsmarks{#1}{\@nameuse{#2pshook}}}
% \end{macrocode}
%
%
% \begin{macro}{\ifonlyfloats}
% \cs{ifonlyfloats}\marg{yes}\marg{no} processes \meta{yes} if the macro is
% called on a page consisting only of floats, otherwise \meta{no} is
% processed. \cs{if@fcolmade} is specified in \file{ltoutput.dtx}.
% \changes{v1.0}{2001/11/14}{Added \cs{ifonlyfloats}}
% \begin{macrocode}
\newcommand{\ifonlyfloats}[2]{\if@fcolmade #1\else #2\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mergepagefloatstyle}
% \cs{mergepagefloatstyle}\marg{style}\marg{textstyle}\marg{floatstyle}
% makes a new page style \meta{style} that is \meta{textstyle} on normal
% pages but uses \meta{floatstyle} on float-only pages. Both \meta{textstyle}
% and \meta{floatstyle} must have been previously defined.
% \changes{v1.0}{2001/11/15}{Added \cs{mergepagefloatstyle}}
% \begin{macrocode}
\newcommand{\mergepagefloatstyle}[3]{%
% \end{macrocode}
% Make sure that the two styles have been called, otherwise we get some
% undefined errors.
% \begin{macrocode}
\@nameuse{ps@#3}\@nameuse{ps@#2}%
% \end{macrocode}
% Specify the pagestyle's headers and footers.
% \begin{macrocode}
\@namedef{ps@#1}{%
\def\@evenhead{\ifonlyfloats{\@nameuse{#3@evenhead}}%
{\@nameuse{#2@evenhead}}}%
\def\@oddhead{\ifonlyfloats{\@nameuse{#3@oddhead}}%
{\@nameuse{#2@oddhead}}}%
\def\@evenfoot{\ifonlyfloats{\@nameuse{#3@evenfoot}}%
{\@nameuse{#2@evenfoot}}}%
\def\@oddfoot{\ifonlyfloats{\@nameuse{#3@oddfoot}}%
{\@nameuse{#2@oddfoot}}}%
% \end{macrocode}
% Set the hook to the \meta{textstyle} on the assumption that that is
% more complex that required for a float page.
% \begin{macrocode}
\@namedef{#1pshook}{\@nameuse{#2pshook}}%
% \end{macrocode}
% That's it.
% \begin{macrocode}
}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makeheadfootstrut}
% \changes{v3.6d}{2010/06/24}{Added \cs{makeheadfootstrut}}
% In each `field' of the header a strut is added to keep alignment
% right. This macro can be used to change a particular strut
% configuration. Each combination is initialy set by
% \cs{makepagestyle} to be equal to \cs{strut}, except the
% \pstyle{empty} style, where the strut is empty by default.
% \begin{macrocode}
\newcommand*\makeheadfootstrut[3]{%
\@namedef{#1psheadstrut}{#2}\@namedef{#1psfootstrut}{#3}}
% \end{macrocode}
% \end{macro}
%
% The pagestyles \pstyle{empty} and \pstyle{plain} are defined
% in \file{latex.dtx}. However, I will redefine them here, just in
% case someone takes a fancy to modifying them.
%
% \begin{macro}{\ps@empty}
% The \pstyle{empty} pagestyle is simple, it's just what we get when
% we call \cs{makepagestyle}.
% \begin{macrocode}
\makepagestyle{empty}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ps@plain}
% The \pstyle{plain} pagestyle is also simple, it just puts the
% page number at the bottom middle of the page.
% We call \verb?\makepagestyle{plain}? and then adjust as required.
% \begin{macrocode}
\makepagestyle{plain}
\makeevenfoot{plain}{}{\thepage}{}
\makeoddfoot{plain}{}{\thepage}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ps@simple}
% The \pstyle{simple} page style simply puts the page number in the header
% at the outer margin.
% \changes{v1.61803398}{2009/07/26}{PW: Added the `simple' pagestyle}
% \begin{macrocode}
\makepagestyle{simple}
\makeevenhead{simple}{\thepage}{}{}
\makeoddhead{simple}{}{}{\thepage}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\nouppercaseheads}
% \begin{macro}{\uppercaseheads}
% \begin{macro}{\memUChead}
% Spurred by Lars Madsen's \Lpack{memexsupp} v0.5 package here is a
% way of switching uppercasing in the headings pagestyle.
% \changes{v1.61803}{2008/01/30}{Added \cs{(no)uppercaseheads} and
% \cs{memUChead} (mempatch v4.9)}
% \changes{v3.6k}{2011/05/20}{Making \cs{memUChead} equal to
% \cs{relax} can cause problems when users want to \cs{provide} it in
% other applications. It is now redefined into the empty string.}
% \changes{v3.6k}{2012/09/13}{Default upper case now \cs{MakeTextUppercase}}
% \begin{macrocode}
\newcommand*{\nouppercaseheads}{\def\memUChead{}}
\newcommand*{\uppercaseheads}{\def\memUChead{\MakeTextUppercase}}
\uppercaseheads
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% The macros \cs{createplainmark}, \cs{createmark} and \cs{addtopsmarks}
% are modified versions of code supplied by Lars Madsen.
% \changes{v1.61803}{2008/01/30}{Added, and used, \cs{createplainmark},
% \cs{createmark} and \cs{addtopsmarks}}
% \begin{macro}{\createplainmark}
% \cs{createplainmark}\marg{type}\marg{marks}\marg{text} creates a
% \cs{typemark} (\meta{type} is \texttt{toc}, \texttt{bib}, etc)
% with \meta{marks} (left, both, right) whose contents are \meta{text}.
% For example \verb?\createplainmark{toc}{both}{\contentsname}?. The
% difference between plain and regular marks, is that plain marks use
% a fixed text, whereas regular marks recieve dynamic text and thus
% is given an argument.
% \begin{macrocode}
\newcommand*{\createplainmark}[3]{%
\nametest{#2}{left}%
\ifsamename
\@namedef{#1mark}{\markboth{\memUChead{#3}}{}}%
\else
\nametest{#2}{right}%
\ifsamename
\@namedef{#1mark}{\markright{\memUChead{#3}}}%
\else
\nametest{#2}{both}%
\ifsamename\else
\@memerror{%
Unknown mark setting type `#2' for #1mark}{%
I expected `left', `both' or `right'. \MessageBreak
I will assume you meant `both'}%
\fi
\@namedef{#1mark}{\markboth{\memUChead{#3}}{\memUChead{#3}}}%
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\createmark}
% \cs{createmark}\marg{division}\marg{marks}\marg{show}\marg{prefix}\marg{postfix}
% creates a \cs{divisionmark} with \meta{marks} (= \texttt{left}, \texttt{both}
% or \texttt{right}) controlling which marks are set,
% \meta{show} (= \texttt{shownumber}, \texttt{nonumber} or \texttt{notitle}) controls the
% display of the divison number in \cs{mainmatter}, \meta{prefix} is text
% before the number and \meta{postfix} is text after the number.
% \begin{macrocode}
\newcommand\createmark[5]{%
% \end{macrocode}
% Handle \texttt{(show/no)number/notitle}.
% \changes{v3.7i}{2019/11/07}{Added notitle show option and
% reimplemented its checking a bit}
% \begin{macrocode}
% \def\@tempa{00}
% \nametest{#3}{nonumber}%
% \ifsamename
% \def\@tempa{01}%
% \else
% \nametest{#3}{shownumber}
% \ifsamename\else
% \@memerror{Unknown numbering value `#3' for #1mark}%
% {I expected `shownumber' or `nonumber'.\MessageBreak
% I will assume you meant `shownumber'}%
% \fi
% \fi
% \expandafter\if\@tempa% compares the two \@tempa digits
% \@namedef{#1marksn}##1{##1}%
% \else
% \@namedef{#1marksn}{\@gobble}%
% \fi
\def\@tempa{1}
\nametest{#3}{nonumber}%
\ifsamename
\def\@tempa{0}
\else
\nametest{#3}{shownumber}
\ifsamename
\def\@tempa{1}
\else
\nametest{#3}{notitle}
\ifsamename
\def\@tempa{2}
\else
\@memerror{Unknown numbering value `#3' for
#1mark,\MessageBreak
please use one of 'shownumber', 'nonumber' or 'notitle'}%
{I expected `shownumber', `nonumber' or 'notitle'.\MessageBreak
I will assume you meant `shownumber'}%
\fi
\fi
\fi
\@namedef{#1markst}##1{##1}
\ifcase\@tempa\relax
% nonumber
\@namedef{#1marksn}{\@gobble}%
\or % 1
% shownumber
\@namedef{#1marksn}##1{##1}
\or % 2, 2 implies shownumber
% shownumber
\@namedef{#1marksn}##1{##1}
\@namedef{#1markst}{\@gobble}
\fi
% \end{macrocode}
% The three \meta{marks} cases, \texttt{left}, \texttt{both} and
% \texttt{right}; fails to \texttt{both}.
% \changes{v3.7f}{2015/08/25}{Sporious spaces}
% \begin{macrocode}
\nametest{#2}{left}%
\ifsamename
\@namedef{#1mark}##1{%
\@setclcnt{#1}{@memmarkcntra}%
\advance\c@@memmarkcntra\m@ne
\markboth{%
\memUChead{%
\ifnum \c@secnumdepth > \c@@memmarkcntra
\if@mainmatter
\@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
\fi
\fi
% \end{macrocode}
% \changes{v3.7i}{2019/11/07}{Added macro to get rid of the title if needed}
% \begin{macrocode}
\@nameuse{#1markst}{##1}%
}%
}%
{}% just left
}%
\else
\nametest{#2}{right}
\ifsamename
\@namedef{#1mark}##1{%
\@setclcnt{#1}{@memmarkcntra}%
\advance\c@@memmarkcntra\m@ne
\markright{%
\memUChead{%
\ifnum \c@secnumdepth > \c@@memmarkcntra
\if@mainmatter%
\@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
\fi%
\fi%
% \end{macrocode}
% \changes{v3.7i}{2019/11/07}{Added macro to get rid of the title if needed}
% \begin{macrocode}
\@nameuse{#1markst}{##1}%
}%
}%
}%
\else
\nametest{#2}{both}%
\ifsamename\else
\@memerror{%
Unknown mark setting type `#2' for #1mark}{%
I expected `left', `both' or `right'. \MessageBreak
I will assume you meant `both'}%
\fi
\@namedef{#1mark}##1{%
\@setclcnt{#1}{@memmarkcntra}%
\advance\c@@memmarkcntra\m@ne
\markboth{%
\memUChead{%
\ifnum \c@secnumdepth > \c@@memmarkcntra
\if@mainmatter
\@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
\fi
\fi
% \end{macrocode}
% \changes{v3.7i}{2019/11/07}{Added macro to get rid of the title if needed}
% \begin{macrocode}
\@nameuse{#1markst}{##1}%
}%
}{%
\memUChead{%
\ifnum \c@secnumdepth > \c@@memmarkcntra
\if@mainmatter
\@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
\fi
\fi
% \end{macrocode}
% \changes{v3.7i}{2019/11/07}{Added macro to get rid of the title if needed}
% \begin{macrocode}
\@nameuse{#1markst}{##1}%
}%
}%
}%
\fi
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\addtopsmarks}
% \cs{addtopsmarks}\marg{pagestyle}\marg{prepend}\marg{append} inserts
% \meta{prepend} and \meta{append} at the start and end of the current
% definition of \cs{pagestylepshook}.
% \changes{v1.61803398d}{2010/02/09}{Added safe to change test}
% \begin{macrocode}
\newcommand\addtopsmarks[3]{%
\mem@ps@safe@change{#1}%
\expandafter\addtodef\expandafter{\csname #1pshook\endcsname}{#2}{#3}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\clearplainmark}
% \begin{macro}{\clearmark}
% For some page styles it is handy to be able to make sure that no
% section or otherwise add data to the \cs{left-} and
% \cs{rightmark}. The macros \cs{clearplainmark} and \cs{clearmark}
% will take one argument specifying which mark to clear, and then
% redefine this mark to do nothing or to gobble its given argument.
% \begin{macrocode}
\newcommand\clearplainmark[1]{%
\@namedef{#1mark}{}}
\newcommand\clearmark[1]{%
\@namedef{#1mark}{\@gobble}}
% \end{macrocode}
%
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ps@headings}
% The \pstyle{headings} pagestyle behaves differently for
% twosided and onesided printing. This is a rewrite of the
% standard style.
% \changes{v1.1}{2002/03/10}{Added \cs{tocmark} etc., to \cs{ps@headings}}
% \changes{v1.61803}{2008/01/30}{Used \cs{memUChead} in \cs{ps@headings}
% (mempatch v4.9)}
% \changes{v1.61803}{2008/01/30}{For twosided docs set both marks for ToC, etc. (mempatch v4.9)}
% \changes{v1.61803}{2008/01/30}{Eliminated \cs{@mkboth} as never used
% (mempatch v4.9)}
% \changes{v1.61803}{2008/01/30}{Added \cs{glossarymark} to \cs{ps@headings}}
% \begin{macrocode}
\if@twoside
% \end{macrocode}
% The footer is empty and the header contains the page number and
% one of the marks.
% \begin{macrocode}
\makepagestyle{headings}
\makepsmarks{headings}{%
\def\chaptermark##1{%
\markboth{\memUChead{%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\@chapapp\ \thechapter. \ %
\fi
\fi
##1}}{}}%
\def\tocmark{\markboth{\memUChead{\contentsname}}{\memUChead{\contentsname}}}%
\def\lofmark{\markboth{\memUChead{\listfigurename}}{\memUChead{\listfigurename}}}%
\def\lotmark{\markboth{\memUChead{\listtablename}}{\memUChead{\listtablename}}}%
\def\bibmark{\markboth{\memUChead{\bibname}}{\memUChead{\bibname}}}%
\def\indexmark{\markboth{\memUChead{\indexname}}{\memUChead{\indexname}}}%
\def\sectionmark##1{%
\markright{\memUChead{%
\ifnum \c@secnumdepth > \z@
\thesection. \ %
\fi
##1}}}}
% \end{macrocode}
% And here's a version of the above \cs{makepsmarks} using \cs{createmark} and
% \cs{createplainmark}.
% \begin{macrocode}
\makepsmarks{headings}{%
\createmark{chapter}{left}{shownumber}{\@chapapp\ }{. \ }
\createmark{section}{right}{shownumber}{}{. \ }
\createplainmark{toc}{both}{\contentsname}
\createplainmark{lof}{both}{\listfigurename}
\createplainmark{lot}{both}{\listtablename}
\createplainmark{bib}{both}{\bibname}
\createplainmark{index}{both}{\indexname}
\createplainmark{glossary}{both}{\glossaryname}
}
\makeevenhead{headings}{\thepage}{}{\slshape\leftmark}
\makeoddhead{headings}{\slshape\rightmark}{}{\thepage}
\else
% \end{macrocode}
% For one sided printing even and odd pages are treated the same,
% so no need to bother with the evenhead, and
% just the \cs{rightmark} is used.
% \begin{macrocode}
\makepagestyle{headings}
\makepsmarks{headings}{%
\def\chaptermark##1{%
\markright{\memUChead{%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\@chapapp\ \thechapter. \ %
\fi
\fi
##1}}}%
\def\tocmark{\markright{\memUChead{\contentsname}}}%
\def\lofmark{\markright{\memUChead{\listfigurename}}}%
\def\lotmark{\markright{\memUChead{\listtablename}}}%
\def\bibmark{\markright{\memUChead{\bibname}}}%
\def\indexmark{\markright{\memUChead{\indexname}}}}
% \end{macrocode}
% And here's a version of the above \cs{makepsmarks} using \cs{createmark} and
% \cs{createplainmark}.
% \begin{macrocode}
\makepsmarks{headings}{%
\createmark{chapter}{right}{shownumber}{\@chapapp\ }{. \ }
\createplainmark{toc}{right}{\contentsname}
\createplainmark{lof}{right}{\listfigurename}
\createplainmark{lot}{right}{\listtablename}
\createplainmark{bib}{right}{\bibname}
\createplainmark{index}{right}{\indexname}
\createplainmark{glossary}{right}{\glossaryname}
}
\makeoddhead{headings}{\slshape\rightmark}{}{\thepage}
\fi
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ps@myheadings}
% The \pstyle{myheadings} page style is simpler because the user
% has to specify the contents using \cs{markboth} and \cs{markright}
% commands. This is the definition used in the standard classes.
% \changes{v1.1}{2002/03/10}{Added \cs{tocmark} etc., to \cs{ps@myheadings}}
% \begin{verbatim}}
% \newcommand{\ps@myheadings}{%
% \let\@oddfoot\@empty\let\@evenfoot\@empty
% \def\@evenhead{\thepage\hfil{\slshape\leftmark}}%
% \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
% \let\@mkboth\@gobbletwo
% \let\chaptermark\@gobble
% \let\sectionmark\@gobble
% }
% \end{verbatim}
% Translating that into our terms we get:
% \changes{v1.0}{2001/11/15}{Changed the code for creating the myheadings pagestyle}
% \changes{v1.4}{2003/11/22}{Further change to myheadings pagestyle code}
% \begin{macrocode}
\makepagestyle{myheadings}
\makepsmarks{myheadings}{%
\let\chaptermark\@gobble
\let\sectionmark\@gobble
\def\tocmark{}%
\def\lofmark{}%
\def\lotmark{}%
\def\bibmark{}%
\def\indexmark{}%
\def\glossarymark{}}
\makeevenhead{myheadings}{\thepage}{}{\slshape\leftmark}
\makeoddhead{myheadings}{\slshape\rightmark}{}{\thepage}
% \end{macrocode}
% (Kai von Fintel (\texttt{fintel@mit.edu}) emailed me on 2003/02/24
% saying that the original \verb?\let\tocmark\@gobble? in the myheadings
% pagestyle did nasty things
% to the ToC, etc. Now using \verb?\def\tocmark{}?.)
% \end{macro}
%
% \begin{macro}{\ps@chapter}
% \begin{macro}{\ps@part}
% \begin{macro}{\ps@cleared}
% The standard classes use the \pstyle{plain} pagestyle for the first page
% of a chapter. This class uses the \pstyle{chapter} instead, which is
% aliased to \pstyle{plain}. Similarly for parts.
% Further, \cs{cleardoublepage} uses whatever
% pagestyle is in effect for the empty verso page. I find that this
% looks odd if the header contains a chapter name. This class uses
% the \pstyle{cleared} pagestyle in this case. I have aliased this
% to \pstyle{empty}; the \pstyle{plain} would be another reasonable choice.
% \begin{macrocode}
\aliaspagestyle{chapter}{plain}
\aliaspagestyle{part}{plain}
\aliaspagestyle{cleared}{empty}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cleardoublepage}
% A slight adjustment to the kernel definition to set a pagestyle.
% \begin{macrocode}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}\thispagestyle{cleared}%
\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\ps@ruled}
% Partly to show how it is done, the class provides a \pstyle{ruled} pagestyle.
% In this style the headers and footers are the same width as the textblock,
% there is a rule under the header, page numbers are set in the footers
% at the outside of the page. Even page headers have the chapter number
% and title at the left, and odd page headers have the section title
% at the right.
%
% Start by making the (empty) \pstyle{ruled} pagestyle.
% \begin{macrocode}
\makepagestyle{ruled}
% \end{macrocode}
% There is no need to change the default width (which is the \cs{textwidth}),
% nor the default positions (centered),
% nor to make the footrule visible. We do, though, have to put the page
% numbers into the footers.
% \begin{macrocode}
\makeevenfoot{ruled}{\thepage}{}{}
\makeoddfoot{ruled}{}{}{\thepage}
% \end{macrocode}
% Make the header rule visible and equal to the \cs{textwidth}.
% \begin{macrocode}
\makeheadrule{ruled}{\textwidth}{\normalrulethickness}
% \end{macrocode}
%
% \begin{macro}{\@ruledmarks}
% We have to make sure that the \cs{chapter} and \cs{section} commands make
% the appropriate marks for use in the headers. We use the hook for this.
% Note that contrary to normal \LaTeX{} practice, the titles are not
% automatically upper-cased. The marks for the tocbibinds also need adjusting.
% \changes{v1.1}{2002/03/10}{Changed \cs{@ruledmarks} to cater for tocbibind}
% \begin{macrocode}
\newcommand{\@ruledmarks}{%
\def\chaptermark##1{%
\markboth{%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\thechapter. \ %
\fi
\fi
##1}{}}
\def\sectionmark##1{\markright{##1}}
\def\tocmark{\markboth{\contentsname}{}}
\def\lofmark{\markboth{\listfigurename}{}}
\def\lotmark{\markboth{\listtablename}{}}
\def\bibmark{\markboth{\bibname}{}}
\def\indexmark{\markboth{\indexname}{}}
\def\glossarymark{\markboth{\glossaryname}{}}
}
% \end{macrocode}
% And here's a version using \cs{createmark} and friends.
% \begin{macrocode}
\renewcommand*{\@ruledmarks}{%
\nouppercaseheads
\createmark{chapter}{left}{shownumber}{}{. \space}
\createmark{section}{right}{shownumber}{}{. \space}
\createplainmark{toc}{both}{\contentsname}
\createplainmark{lof}{both}{\listfigurename}
\createplainmark{lot}{both}{\listtablename}
\createplainmark{bib}{both}{\bibname}
\createplainmark{index}{both}{\indexname}
\createplainmark{glossary}{both}{\glossaryname}}
\makepsmarks{ruled}{\@ruledmarks}
% \end{macrocode}
% \end{macro}
%
% We can now define the even page header which is to have the chapter title
% at the left. As the chapter mark did no upper-casing we will print it
% using small caps, but just use the normal font for section title on
% the odd page header.
% \begin{macrocode}
\makeevenhead{ruled}{\scshape\leftmark}{}{}
\makeoddhead{ruled}{}{}{\rightmark}
% \end{macrocode}
% \end{macro}
% This is all that we need to do for the \pstyle{ruled} pagestyle.
%
% \begin{macro}{\ps@Ruled}
% Also define a \pstyle{Ruled} pagestyle similar to \pstyle{ruled} except that the
% headers and footers are 10\% wider than the textblock, sticking out
% into the fore edge.
% \begin{macrocode}
\makepagestyle{Ruled}
\makerunningwidth{Ruled}{1.1\textwidth}
\makeheadposition{Ruled}{flushright}{flushleft}{flushright}{flushleft}
\makeevenfoot{Ruled}{\thepage}{}{}
\makeoddfoot{Ruled}{}{}{\thepage}
\makeheadrule{Ruled}{1.1\textwidth}{\normalrulethickness}
\makepsmarks{Ruled}{\@ruledmarks}
\makeevenhead{Ruled}{\scshape\leftmark}{}{}
\makeoddhead{Ruled}{}{}{\rightmark}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\headwidth}
% \begin{macro}{\ps@companion}
% A \pstyle{companion} pagestyle like the one in the
% \textit{\LaTeX{} Companion} series.
% We need the \cs{headwidth} length for this.
% \changes{v1.1}{2002/03/10}{Added \cs{tocmark} etc., to \cs{ps@companion}}
% \begin{macrocode}
\newlength{\headwidth}
\makepagestyle{companion}
\setlength{\headwidth}{\textwidth}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\makerunningwidth{companion}{\headwidth}
\makeheadrule{companion}{\headwidth}{\normalrulethickness}
\makeheadposition{companion}{flushright}{flushleft}{}{}
\makepsmarks{companion}{%
\def\chaptermark##1{\markboth{##1}{##1}} % left mark & right marks
\def\sectionmark##1{\markright{%
\ifnum \c@secnumdepth>\z@
\thesection. \ %
\fi
##1}}
\def\tocmark{\markboth{\contentsname}{\contentsname}}
\def\lofmark{\markboth{\listfigurename}{\listfigurename}}
\def\lotmark{\markboth{\listtablename}{\listtablename}}
\def\bibmark{\markboth{\bibname}{\bibname}}
\def\indexmark{\markboth{\indexname}{\indexname}}}
% \end{macrocode}
% And here's a version of the above \cs{makepsmarks} using \cs{createmark} and
% \cs{createplainmark}.
% \begin{macrocode}
\makepsmarks{companion}{%
\nouppercaseheads
\createmark{chapter}{both}{nonumber}{}{}
\createmark{section}{right}{shownumber}{}{. \space}
\createplainmark{toc}{both}{\contentsname}
\createplainmark{lof}{both}{\listfigurename}
\createplainmark{lot}{both}{\listtablename}
\createplainmark{bib}{both}{\bibname}
\createplainmark{index}{both}{\indexname}
\createplainmark{glossary}{both}{\glossaryname}}
\makeevenhead{companion}{\normalfont\bfseries\thepage}{}%
{\normalfont\bfseries\leftmark}
\makeoddhead{companion}{\normalfont\bfseries\rightmark}{}%
{\normalfont\bfseries\thepage}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Another pagestyle called \pstyle{showlocs} can be used to show the
% locations of the header, footer and textblock. I would expect that
% this would be mainly used as an example for authors to create their
% own similar styles.
% \changes{v1.6180339c}{2008/12/28}{Added the showlocs pagestyle and supporting
% macros}
% \changes{v1.6180339c}{2009/01/25}{Added more supporting macros for the
% showlocs pagestyle}
%
% \begin{macro}{\ifshowheadfootloc}
% \begin{macro}{\showheadfootloctrue}
% \begin{macro}{\showheadfootlocfalse}
% \begin{macro}{\showheadfootlocon}
% \begin{macro}{\showheadfootlocoff}
% \begin{macro}{\ifshowtextblockloc}
% \begin{macro}{\showtextblockloctrue}
% \begin{macro}{\showtextblocklocfalse}
% \begin{macro}{\showtextblocklocon}
% \begin{macro}{\showtextblocklocoff}
% Booleans controlling the appearance, or not, of the header/footer lines
% and text frame in \pstyle{showlocs}.
% \begin{macrocode}
\newif\ifshowheadfootloc
\showheadfootloctrue
\newcommand*{\showheadfootlocon}{\showheadfootloctrue}
\newcommand*{\showheadfootlocoff}{\showheadfootlocfalse}
\newif\ifshowtextblockloc
\showtextblockloctrue
\newcommand*{\showtextblocklocon}{\showtextblockloctrue}
\newcommand*{\showtextblocklocoff}{\showtextblocklocfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\framepichook}
% \changes{v3.6k}{2013/05/08}{Added \cs{framepichook}}
% The two macros \cs{framepichead} and \cs{framepictextfoot} are used
% to make up the \texttt{showlocs} page style. They are both zero
% width \texttt{picture} environments. The very first thing in these
% \texttt{picture} environments, is a call to \cs{framepichook}
% (empty by default), which could be used to change the color of the
% frame.
% \begin{macrocode}
\newcommand\framepichook{}
% \end{macrocode}
%
% \end{macro}
% \begin{macro}{\framepichead}
% For producing a zero-sized picture of a line at the base of the header.
% It is meant to be used as the left part of the header for a pagestyle.
% \changes{v1.6180339c}{2008/12/28}{Added \cs{framepichead}}
% \changes{v3.6k}{2013/05/08}{Added \cs{framepichook}}
% \begin{macrocode}
\newcommand*{\framepichead}{%
\ifshowheadfootloc
\begin{picture}(0,0)
\framepichook
\unitlength 1pt
\put(0,0){\line(1,0){\strip@pt\textwidth}}
\end{picture}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\framepictextfoot}
% For producing a zero-sized picture of a line at the base of the footer
% and a frame around the text block. It is meant to be used as the left
% part of a footer for a pagestyle.
% \changes{v1.6180339c}{2008/12/28}{Added \cs{framepictextfoot}}
% \changes{v3.6k}{2013/05/08}{Added \cs{framepichook}}
% \begin{macrocode}
\newcommand*{\framepictextfoot}{%
\begin{picture}(0,0)
\framepichook
\unitlength 1pt
\ifshowheadfootloc
\put(0,0){\line(1,0){\strip@pt\textwidth}}
\fi
\ifshowtextblockloc
\put(0,\strip@pt\footskip)%
{\framebox(\strip@pt\textwidth,\strip@pt\textheight){}}
\fi
\end{picture}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ps@showlocs}
% The \pstyle{showlocs} pagestyle. This is more to show what can be done.
% \changes{v1.6180339c}{2008/12/28}{Added the showlocs pagestyle}
% \begin{macrocode}
\makepagestyle{showlocs}
\makeevenhead{showlocs}{\framepichead\thepage}{\thepage}{\thepage}
\makeoddhead{showlocs}{\framepichead\thepage}{\thepage}{\thepage}
\makeevenfoot{showlocs}{\framepictextfoot\thepage}{\thepage}{\thepage}
\makeoddfoot{showlocs}{\framepictextfoot\thepage}{\thepage}{\thepage}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fixheaderwidths}
% The companion pagestyle, at least, needs adjusting (at \cs{fixthelayout} time)
% if the \cs{textwidth} has changed from its initial value.
% \changes{v1.6180339f}{2009/03/16}{Added \cs{fixheaderwidths}}
% \begin{macrocode}
\newcommand*{\fixheaderwidths}{%
% companion pagestyle
\setlength{\headwidth}{\textwidth}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\makerunningwidth{companion}{\headwidth}
\makeheadrule{companion}{\headwidth}{\normalrulethickness}
\makefootrule{companion}{\textwidth}{\footruleheight}{\footruleskip}
}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Page numbering}
%
% The kernel includes the \cs{pagenumbering} command for setting the
% style (arabic, roman, etc.) of the page numbers, and at the same
% time it resets the page counter. I want a version that resets the style
% but not the number\footnote{Added to meet a request by Daniel Richard G.
% (\texttt{skunk@mit.edu}) September 2001.}.
%
% \begin{macro}{\pagenumbering}
% \begin{macro}{\pagenumbering*}
% \cs{pagenumbering}\marg{style} is the normal version whereas
% the starred version does not reset the counter.
% \changes{v1.0}{2001/09/21}{Added \cs{pagenumbering} and \cs{pagenumbering*} }
% \begin{macrocode}
\renewcommand{\pagenumbering}{%
\@ifstar{\@smempnum}{\@mempnum}}
% \end{macrocode}
% \begin{macro}{\@smempnum}
% \begin{macrocode}
\newcommand{\@smempnum}[1]{%
\gdef\thepage{\csname @#1\endcsname \c@page}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@mempnum}
% \begin{macrocode}
\newcommand{\@mempnum}[1]{%
\@smempnum{#1}\global\c@page \@ne}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@storedpagenumber}
% A counter to store the page number.
% \begin{macrocode}
\newcounter{storedpagenumber}
\setcounter{storedpagenumber}{1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\savepagenumber}
% \begin{macro}{\restoregenumber}
% \cs{savepagenumber} saves the current page number and \cs{restorepagenumber}
% sets the page number to the stored value.
% \changes{v1.0}{2001/09/24}{Added \cs{savepagenumber} and \cs{restorepagenumber}}
% \begin{macrocode}
\newcommand{\savepagenumber}{\global\c@storedpagenumber \c@page}
\newcommand{\restorepagenumber}{\global\c@page \c@storedpagenumber}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \section{Non-traditional spacing}
% \changes{v1.61803}{2008/01/30}{Added non-traditional spacing
% (mempatch v4.6)}
%
% \subsection{Double spacing}
%
% This is an embedding and extension of the code from the \Lpack{setspace}
% package, with
% names changed.
%
% \begin{macro}{\setSpacing}
% \cs{setSpacing}\marg{num} effectively increases the \cs{baselineskip} to
% \meta{num}*\cs{baselineskip}.
% (In package was \cs{setstretch}).
% \begin{macrocode}
\newcommand*{\setSpacing}[1]{%
\def\baselinestretch{#1}%
\@currsize}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setSingleSpace}
% \begin{macro}{\setFootnoteSpacing}
% \begin{macro}{\setFloatSpacing}
% \cs{setSingleSpace}\marg{num} effectively increases the \cs{baselineskip} for
% single spacing to \meta{num}*\cs{baselineskip} (\meta{num} should be
% close to 1.0). (In package was \cs{SetSinglespace}). We extend with
% two extra macros \cs{setFootnoteSpacing} and \cs{setFloatSpacing}
% which can be used to explicitly set the spacing inside page notes
% (fotnotes and friends) and inside floats. Changing
% \cs{setSingleSpace} will also set page note and float spacings to
% the same value.
% \changes{v3.6g}{2010/09/19}{Added two extra 'single' spacing macros}
% \begin{macrocode}
\newcommand*{\setSingleSpace}[1]{%
\def\m@m@singlespace{#1}%
\def\m@m@footnote@spacing{#1}%
\def\m@m@float@spacing{#1} %
}
\setSingleSpace{1}
\newcommand*\setPagenoteSpacing[1]{\def\m@m@footnote@spacing{#1}}
\newcommand*\setFloatSpacing[1] {\def\m@m@float@spacing{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\SingleSpacing}
% \begin{macro}{\SingleSpacing*}
% \cs{SingleSpacing} starts single spacing. (In package was \cs{singlespacing}).
% \changes{v3.6g}{2010/09/19}{Added reset of the float and page note spacings}
% \begin{macrocode}
\newcommand*{\SingleSpacing}{%
\setSpacing{\m@m@singlespace}%
\edef\m@m@footnote@spacing{\baselinestretch}%
\edef\m@m@float@spacing{\baselinestretch}%
% \end{macrocode}
% \changes{v3.7h}{2018/09/19}{Added the ifstar and \cs{@noocument}}
% We can have a strange interaction with \Lpack{tikz} if this
% \cs{vskip} is emitted in the preamble. We use a trick (via David
% Carlisle) to check whether we are in the preamble, and only emit the
% vskip if we are not. \cs{@ifstar} added to let the user disable the
% vskip if needed.
% \begin{macrocode}
\@ifstar{}{\ifx\@nodocument\relax\vskip\baselineskip\fi}% correction for coming into single spacing
}
\SingleSpacing
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@OnehalfSpacing}
% \begin{macro}{\OnehalfSpacing}
% \cs{OnehalfSpacing} starts `one and a half' spacing, which to most
% thesis nitpickers will look like double spacing.
% (In package was \cs{onehalfspacing}). The starred version
% \cs{OnehalfSpacing*} will also give page notes and floats the same spacing
% \changes{v3.6g}{2010/09/19}{Made \cs{OnehalfSpacing} into a starred
% version such that the starred version makes everything one half
% spaced including page notes and floats}
% \begin{macrocode}
\newcommand*{\@OnehalfSpacing}{
\setSpacing{1.25}% default (10pt)
\ifcase \@ptsize \relax % 10pt
\setSpacing{1.25}%
\or% 11pt
\setSpacing{1.213}%
\or% 12pt
\setSpacing{1.241}%
\or\or% 14pt
\setSpacing{1.20}%
\or\or\or% 17pt
\setSpacing{1.16}%
\or\or% 9pt
\setSpacing{1.35}%
\else% the extended sizes
\setSpacing{1.16}%
\fi}
\newcommand*\OnehalfSpacing{%
\@ifstar{%
\@OnehalfSpacing%
\edef\m@m@footnote@spacing{\baselinestretch}%
\edef\m@m@float@spacing{\baselinestretch}%
}{\@OnehalfSpacing}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\DoubleSpacing}
% \begin{macro}{\@DoubleSpacing}
% \cs{DoubleSpacing} starts double spacing, which to most thesis nitpickers
% will look far too spaced out. (In package was
% \cs{doublespacing}). The starred version will also set the page note
% and float spacing to the same value.
% \changes{v3.6g}{2010/09/19}{Extended with a starred version.}
% \begin{macrocode}
\newcommand*{\@DoubleSpacing}{
\setSpacing{1.667}% default (10pt)
\ifcase \@ptsize \relax % 10pt
\setSpacing{1.667}%
\or% 11pt
\setSpacing{1.618}%
\or% 12pt
\setSpacing{1.655}%
\or\or% 14pt
\setSpacing{1.60}%
\or\or\or% 17pt
\setSpacing{1.545}%
\or\or% 9pt
\setSpacing{1.8}%
\else% larger sizes
\setSpacing{1.5}%
\fi}
\newcommand*\DoubleSpacing{%
\@ifstar{%
\@DoubleSpacing%
\edef\m@m@footnote@spacing{\baselinestretch}%
\edef\m@m@float@spacing{\baselinestretch}%
}{\@DoubleSpacing}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@setsize}
% Modify the kernel command.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check what this does!!!!!!!!
% \begin{macrocode}
\renewcommand*{\@setsize}[4]{%
\@nomath#1%
\let\@currsize#1%
\baselineskip #2%
\baselineskip \baselinestretch\baselineskip
\parskip \baselinestretch\parskip
\setbox\strutbox \hbox{%
\vrule height.7\baselineskip
depth .3\baselineskip
width \z@}%
\skip\footins \baselinestretch\skip\footins
\normalbaselineskip\baselineskip#3#4}
% \end{macrocode}
% \end{macro}
%
%
% \begin{environment}{SingleSpace}
% Environment form of \cs{SingleSpacing}. (In package was \texttt{singlespace}).
% \begin{macrocode}
\newenvironment{SingleSpace}{%
\vskip\baselineskip
\setSpacing{\m@m@singlespace}%
\vskip -\baselineskip
}{\par}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{SingleSpace*}
% Don't use this; it's only here to match the \Lpack{setspace} package.
% (In package was \texttt{singlespace*}).
% \begin{macrocode}
\newenvironment{SingleSpace*}{%
%% \vskip\baselineskip
\setSpacing{\m@m@singlespace}%
\vskip 0.5\baselineskip
}{\vskip -0.5\baselineskip}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\m@mrestore@spacing}
% \begin{macrocode}
\newcommand*{\m@mrestore@spacing}{%
\par
\vskip \parskip
\vskip \baselineskip
\endgroup
\vskip -\parskip
\vskip -\baselineskip}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{Spacing}
% \verb?\begin{Spacing}{num}? increases the \cs{baselineskip}
% to \verb?num*\baselineskip?. (In package was \texttt{spacing}).
% \begin{macrocode}
\newenvironment{Spacing}[1]{%
\par
\begingroup
\setSpacing{#1}}{\m@mrestore@spacing}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{OnehalfSpace}
% Environment form of \cs{OnehalfSpacing}. (In package was \texttt{onehalfspace}).
% \changes{v3.6g}{2010/09/19}{Added starred version of environment to
% complement the starred macro version}
% \begin{macrocode}
\newenvironment{OnehalfSpace}{%
\begingroup
\OnehalfSpacing}{\m@mrestore@spacing}
\newenvironment{OnehalfSpace*}{%
\begingroup
\OnehalfSpacing*}{\m@mrestore@spacing}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{DoubleSpace}
% Environment form of \cs{DoubleSpacing}. (In package was \texttt{doublespace}).
% \changes{v3.6g}{2010/09/19}{Added starred version of environment to
% complement the starred macro version}
% \begin{macrocode}
\newenvironment{DoubleSpace}{%
\begingroup
\DoubleSpacing}{\m@mrestore@spacing}
\newenvironment{DoubleSpace*}{%
\begingroup
\DoubleSpacing}{\m@mrestore@spacing}
% \end{macrocode}
% \end{environment}
%
%
% Deal with spacing around displays.
%
% \begin{macro}{\memdskipstretch}
% \begin{macro}{\setDisplayskipStretch}
% \begin{macro}{\noDisplayskipStretch}
% \cs{setDisplayskipStretch}\marg{num} changes space around displays by the
% factor (1+\meta{num}). \cs{noDisplaydkipStretch} keeps the regular
% spacing around displays. (In package were \cs{setdisplayskipstretch} and
% the \texttt{nodisplayskipstretch} option).
% \begin{macrocode}
\newcommand*{\memdskipstretch}{0.0}
\newcommand*{\setDisplayskipStretch}[1]{%
\renewcommand*{\memdskipstretch}{#1}}
\newcommand*{\noDisplayskipStretch}{\setDisplayskipStretch{0.0}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memdskips}
% Macro added to the kernel hook \cs{everydisplay}, changing the settings
% of displayskips
% \begin{macrocode}
\newcommand*{\memdskips}{%
\advance\abovedisplayskip \memdskipstretch\abovedisplayskip
\advance\belowdisplayskip \memdskipstretch\belowdisplayskip
\advance\abovedisplayshortskip \memdskipstretch\abovedisplayshortskip
\advance\belowdisplayshortskip \memdskipstretch\belowdisplayshortskip}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\everydisplay}
% \begin{macrocode}
\everydisplay\expandafter{%
\the\everydisplay
\memdskips}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xfloat}
% Reset \cs{baselinestretch} in floats. Because of a package like
% \Lpack{fixltx2e} (recommended package), we have to delay the
% addition.
% \changes{v3.7d}{2014/07/28}{Delayed addition to
% \cs{@xfloat}. Reported by Ulrike Fischer}.
% \changes{v3.7g}{2017/05/08}{Delayed the addition of the adjustment
% to the float until after \cs{normalsize}. Reported at \protect\url{https://tex.stackexchange.com/q/368422/3929}}
% \begin{macrocode}
\AtBeginDocument{
\let\m@m@xfloat\@xfloat
\def\@xfloat #1[#2]{%
\m@m@xfloat #1[#2]%
\def\baselinestretch{\m@m@float@spacing}%
\normalsize%
\@nameuse{#1adjustment}%
}
}
% \end{macrocode}
% \end{macro}
%
% The extra spacing does not add space before and after a minipage.
% The solution, hinted at by Donald Arseneau, is to create a new
% environment. I came up with a solution which DA then much improved upon
% (CTT \textit{setspace and minipages}, 2006/11/28).
% This is like minipage from an author's view, except that it is
% always top positioned and acts like a paragraph.
% \begin{macro}{\memPD}
% \begin{macrocode}
\newdimen\memPD
% \end{macrocode}
% \end{macro}
% \begin{environment}{vminipage}
% The user view, just as for \texttt{minipage}, but ensures the \texttt{t}
% position and as a new paragraph. It is like \texttt{minipage} but with
% better fore and aft spacing.
% \begin{macrocode}
\newenvironment{vminipage}{%
\par
\@ifnextchar[%]
\@ivminipage
{\@iiiminipage t\relax[s]}
}{%
\par\global\memPD=\prevdepth
\endminipage
\par
\kern-\memPD% no pagebreak allowed here
\hbox{\vrule depth \memPD width \z@}}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\@ivminipage}
% Deal with first optional argument to \texttt{vminipage}.
% \begin{macrocode}
\def\@ivminipage[#1]{%
\@ifnextchar[%]
{\@iiminipage{t}}{\@iiiminipage{t}\relax[s]}}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Abnormal parskips}
%
% Non-zero, positive \cs{parskip}, which is not to be encouraged. Code
% based on Robin Fairbairns \Lpack{parskip} package and the NTG classes.
%
% \begin{macro}{\ifm@mnzpskip}
% \begin{macro}{\m@mnzpskiptrue}
% \begin{macro}{\m@mnzpskipfalse}
% \cs{ifm@mnzpskip} is TRUE if \cs{parskip} set to anything but 0pt.
% \begin{macrocode}
\newif\ifm@mnzpskip
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\traditionalparskip}
% \begin{macro}{\m@mabparskip}
% \begin{macro}{\abnormalparskip}
% \begin{macro}{\nonzeroparskip}
% \cs{traditionalparskip} sets \cs{parskip} to 0pt.
% \cs{abnormalparskip}\marg{length} sets \cs{parskip} to \meta{length}.
% \cs{nonzeroparskip} sets \cs{parskip} to a non-zero value that might be
% not too bad (any non-zero \cs{parskip} is not good).
% \changes{v1.61803398c}{2009/11/13}{\cs{parskip} was set to \cs{z@},
% thus the stretch was missing, this broke \cs{flushbottom}}
% \begin{macrocode}
\newcommand*{\traditionalparskip}{%
\setlength\parskip{0\p@ \@plus \p@}
\m@mnzpskipfalse}
\newskip\m@mabparskip
\newcommand*{\abnormalparskip}[1]{%
\setlength{\parskip}{#1}\m@mabparskip=#1\relax
\m@mnzpskiptrue}
\newcommand*{\nonzeroparskip}{\abnormalparskip{%
0.5\baselineskip
\@plus .1\baselineskip \@minus .1\baselineskip% NTG
%% 0.5/baselineskip \@plus 2pt% RF
}}
\traditionalparskip
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@minpagerestore}
% This needs extending: here's what NTG does, but I've put the
% appropriate code later.
% \begin{verbatim}
% \providecommand*{\@minipagerestore}{%
% \parskip=.5\baselineskip \@plus .1\baselineskip \@minus .1\baselineskip}
% \end{verbatim}
% \end{macro}
%
% \section{Titles}
%
% For books the title is usually designed specifically for the particular
% work, so originally the class did not provide a \cs{maketitle} command or
% any of the \cs{title} and other commands that normally go along with this.
% After some thought I decided to add in the code from the
% \Lpack{titling} package~\cite{TITLING}. However, in this case life
% is a bit simpler as there is no pre-existing class code.
% \changes{v0.3}{2001/07/09}{Added titling code}
%
% \begin{macro}{\pretitle}
% \begin{macro}{\@bspretitle}
% \begin{macro}{\posttitle}
% \begin{macro}{\@bsposttitle}
% \begin{macro}{\preauthor}
% \begin{macro}{\@bspreauthor}
% \begin{macro}{\postauthor}
% \begin{macro}{\@bspostauthor}
% \begin{macro}{\predate}
% \begin{macro}{\@bspredate}
% \begin{macro}{\postdate}
% \begin{macro}{\@bspostdate}
% To provide some flexibilty in the titling style of the document,
% user level commands are provided that can be changed to reconfigure
% the appearance resulting from \cs{maketitle}.
% \begin{macrocode}
\newcommand{\pretitle}[1]{\def\@bspretitle{#1}}
\newcommand{\posttitle}[1]{\def\@bsposttitle{#1}}
\newcommand{\preauthor}[1]{\def\@bspreauthor{#1}}
\newcommand{\postauthor}[1]{\def\@bspostauthor{#1}}
\newcommand{\predate}[1]{\def\@bspredate{#1}}
\newcommand{\postdate}[1]{\def\@bspostdate{#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}
%
% These are defined initially
% to mimic the normal \LaTeX{} style.
% \begin{macrocode}
\pretitle{\begin{center}\LARGE}
\posttitle{\par\end{center}\vskip 0.5em}
\preauthor{\begin{center}
\large \lineskip .5em%
\begin{tabular}[t]{c}}
\postauthor{\end{tabular}\par\end{center}}
\predate{\begin{center}\large}
\postdate{\par\end{center}}
% \end{macrocode}
%
% \begin{macro}{\maketitlehooka}
% \begin{macro}{\maketitlehookb}
% \begin{macro}{\maketitlehookc}
% \begin{macro}{\maketitlehookd}
% The four hooks which will be called by \cs{maketitle}. These are initially
% vacuous.
% \begin{macrocode}
\newcommand{\maketitlehooka}{}
\newcommand{\maketitlehookb}{}
\newcommand{\maketitlehookc}{}
\newcommand{\maketitlehookd}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\thanksmarkseries}
% \begin{macro}{\@bsmarkseries}
% \begin{macro}{\symbolthanksmark}
% These are for specifying the kind of series for thanks markers.
% \begin{macrocode}
\newcommand{\thanksmarkseries}[1]{%
\def\@bsmarkseries{\renewcommand{\thefootnote}%
{\@nameuse{#1}{footnote}}}}
\newcommand{\symbolthanksmark}{\thanksmarkseries{\fnsymbol}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\continuousmarks}
% \begin{macro}{\@bscontmark}
% These are for (non) zeroing of the footnote counter.
% \begin{macrocode}
\newcommand{\@bscontmark}{\setcounter{footnote}{0}}
\newcommand{\continuousmarks}{\def\@bscontmark{}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\thanksheadextra}
% \begin{macro}{\@bsthanksheadpre}
% \begin{macro}{\@bsthanksheadpost}
% These are for inserting stuff before and after a mark in the titling.
% \begin{macrocode}
\newcommand{\thanksheadextra}[2]{%
\def\@bsthanksheadpre{#1}%
\def\@bsthanksheadpost{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \changes{v1.2}{2002/08/10}{Deprecated \cs{thanksfootextra}}
% \changes{v1.2}{2002/08/10}{Removed \cs{thanksfootpre} and \cs{thanksfootpost}}
% \changes{v1.4}{2003/12/14}{Removed \cs{thanksfootextra}}
%
% \begin{macro}{\thanksmark}
% This adds a thanks mark. The \cs{footnotemark} could have been used directly
% but it is fragile in a moving argument.
% \begin{macrocode}
\DeclareRobustCommand{\thanksmark}[1]{\footnotemark[#1]}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thanksgap}
% This specifies some horizontal space.
% \begin{macrocode}
\newcommand{\thanksgap}[1]{\hspace{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tamark}
% This stores the current definition of \cs{@thefnmark}. For some reason
% using \cs{@thefnmark} directly only gave the last value.
% \begin{macrocode}
\newcommand{\tamark}{\@thefnmark}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thanksmarkwidth}
% A length determining the size of the box for typesetting
% a thanks marker.
% \begin{macrocode}
\newlength{\thanksmarkwidth}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thanksmarksep}
% A length determining the inset of thanks footnotes.
% \changes{v1.2}{2002/08/10}{Replaced \cs{thanksmargin} by \cs{thanksmarksep}}
% \begin{macrocode}
\newlength{\thanksmarksep}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thanksmarkstyle}
% \begin{macro}{\thanksscript}
% \cs{thanksscript} is a wrapper round the actual mark stuff to be typeset.
% The user can define this via \cs{thanksmarkstyle}\marg{code}.
% The default is a superscript mark.
% \changes{v1.2}{2002/08/10}{Added \cs{thanksmarkstyle}}
% \begin{macrocode}
\newcommand{\thanksmarkstyle}[1]{\def\thanksscript##1{#1}}
\thanksmarkstyle{\textsuperscript{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\makethanksmarkhook}
% A vacuous macro used as a hook into \cs{makethanksmark}.
% \begin{macrocode}
\newcommand{\makethanksmarkhook}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thanksfootmark}
% This typesets the thanks footnote mark.
% \changes{v1.2}{2002/08/10}{Complete rewrite of \cs{thanksfootmark}}
% \begin{macrocode}
\newcommand{\thanksfootmark}{%
\ifdim\thanksmarkwidth < \z@
% \end{macrocode}
% Negative width, mark is in the margin.
% \begin{macrocode}
\llap{\hb@xt@ -\thanksmarkwidth{%
\hss\normalfont\thanksscript{\tamark}}%
\hspace*{-\thanksmarkwidth}}%
\else
\ifdim\thanksmarkwidth = \z@
% \end{macrocode}
% Zero width, mark is at (inside) the margin.
% \begin{macrocode}
{\normalfont\thanksscript{\tamark}}%
\else
% \end{macrocode}
% Positive width.
% \begin{macrocode}
\hb@xt@\thanksmarkwidth{\hss\normalfont\thanksscript{\tamark}}%
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makethanksmark}
% This sets the general indentations for the thanks footnote,
% and typesets the mark. The code is a simplified version of that
% for typesetting ToC entries.
% \changes{v1.2}{2002/08/10}{Minor changes to \cs{makethanksmark}}
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{makethanksmark}}
% \changes{v1.61803398b}{2009/09/21}{fixed typo, \cs{thanksmarksep}
% not \cs{thanksmark}}
% \begin{macrocode}
\newcommand{\makethanksmark}{%
\leavevmode%
\parindent 1em\noindent
%%% \leftskip\thanksmarksep\relax
\memRTLleftskip\thanksmarksep\relax
%%% \advance\leftskip\thanksmarkwidth
\advance\memRTLleftskip\thanksmarkwidth
%%% \null\nobreak\hskip-\leftskip\relax
\null\nobreak\hskip-\memRTLleftskip\relax
\makethanksmarkhook\relax
\thanksfootmark}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\usethanksrule}
% \begin{macro}{\cancelhanksrule}
% Simple macros that let \cs{footnoterule} to another rule definition.
% \begin{macrocode}
\newcommand{\usethanksrule}{\let\footnoterule\thanksrule}
\newcommand{\cancelthanksrule}{\let\footnoterule\@bsfootnoterule}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% Now set up the rest of the thanks defaults, styling having been
% done earlier.
% \begin{macrocode}
\thanksmarkseries{fnsymbol} % symbols
\thanksheadextra{}{}
\setlength{\thanksmarkwidth}{1.8em}
\setlength{\thanksmarksep}{-\thanksmarkwidth}
% \end{macrocode}
% \begin{macro}{\thanksrule}
% \begin{macro}{\@bsfootnoterule}
% These are saved versions of the \cs{footnoterule} definition as it
% is at the end of the preamble.
% \begin{macrocode}
\AtBeginDocument{%
\let\thanksrule\footnoterule
\let\@bsfootnoterule\footnoterule
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\droptitle}
% A titling block has \cs{droptitle} amount of additional vertical space
% above it (normally zero).
% \begin{macrocode}
\newlength{\droptitle}
\setlength{\droptitle}{0pt}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\maketitle}
% The following is a
% modification of \cs{maketitle} as in the \Lpack{article}, \Lpack{report},
% and \Lpack{book} classes. It sets the pagestyle to \pstyle{title}.
% \changes{v1.4}{2004/01/21}{Removed the \cs{rlap} from \cs{@makefnmark}
% in \cs{maketitle} so multiple \cs{thanks}
% work per \cs{footnote}}
% \changes{v1.618}{2005/09/03}{Fix to remove extra blank page when
% \cs{maketitle} (and \cs{@maketitle}) is used within adjustwidth
% inside a titlingpage (mempatch v3.2)}
% \begin{macrocode}
\newcommand{\maketitle}{\par
\begingroup
\@bsmarkseries
\def\@makefnmark{\@textsuperscript{%
\normalfont\@bsthanksheadpre \tamark \@bsthanksheadpost}}%
\long\def\@makefntext##1{\makethanksmark ##1}
\if@twocolumn
\ifnum \col@number=\@ne
\@maketitle
\else
\twocolumn[\@maketitle]%
\fi
\else
\ifdim\pagetotal>\z@
\newpage
\fi
\global\@topnum\z@
\@maketitle
\fi
\thispagestyle{title}\@thanks
\endgroup
\@bscontmark % \setcounter{footnote}{0}%
}
\aliaspagestyle{title}{plain}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mem@titlefootkill}
% \cs{@mem@titlefootkill}\marg{note} Warn about footnotes in titles.
% \begin{macrocode}
\newcommand*{\@mem@titlefootkill}[1]{%
\@memwarn{Do not use \string\footnote\space in
\string\maketitle.\MessageBreak
Use \protect\thanks\space instead}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@maketitle}
% Our version of \cs{@maketitle}.
% Footnotes are killed in the title; see the thread `\cs{title}, \cs{author}
% and \cs{footnote} feature in memoir class', February 2003.
% \changes{v1.4}{2003/11/16}{Killed footnote in titles (from patch v1.4)}
% \begin{macrocode}
\newcommand{\@maketitle}{%
\let\footnote\@mem@titlefootkill
\ifdim\pagetotal>\z@
\newpage
\fi
\null
\vskip 2em%
\vspace*{\droptitle}
\maketitlehooka
{\@bspretitle \@title \@bsposttitle}
\maketitlehookb
{\@bspreauthor \@author \@bspostauthor}
\maketitlehookc
{\@bspredate \@date \@bspostdate}
\maketitlehookd
\par
\vskip 1.5em}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{mem@titlingpage}
% \begin{environment}{titlingpage}
% \begin{environment}{titlingpage*}
% \begin{macro}{\titlingpageend}
% The \Lenv{titlingpage} environment sets the pagestyle to be \pstyle{titlingpage},
% disables the footnote rule and ensures that the page is single
% column. At the end it switches back to twocolumn if neccessary,
% and then starts a new page as number 1. On the other hand
% \Lenv{titlingpage*}, does \emph{not} reset the page counter.
%
% At the end of the titlingpage we clear the page to let the next data
% start on a new page. However there is a slight complication
% here. Should we clear to next page or to next righthand page. One
% could argue that under \Lopt{twoside} going to next right hand page
% would be best, but then there is also \Lopt{openany}. In order to
% make this configurable we will factor this out in a configurable
% macro, and leave the defaults as they are so not to mess with
% existing documents.
% \changes{v3.6k}{2012/12/24}{Added \Lenv{titlingpage*} env}
% \changes{v3.7g}{2018/03/06}{Added \cs{titlingpageend}}
% \begin{macrocode}
\newcommand\titlingpageend[2]{%
\def\mem@titlingpage@clear@for@twoside{#1}%
\def\mem@titlingpage@clear@for@oneside{#2}%
}
% default
\titlingpageend{\cleardoublepage}{\clearpage}
\newenvironment{mem@titlingpage}%
{\let\footnoterule\relax
\let\footnotesize\small
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\thispagestyle{titlingpage}%
\if\mem@titlpg@reset\setcounter{page}{\@ne}\fi%
}{%
\thispagestyle{titlingpage}%
\if@restonecol \twocolumn \fi
% \if@twoside \cleardoublepage \else \clearpage \fi
\if@twoside \mem@titlingpage@clear@for@twoside \else \mem@titlingpage@clear@for@oneside \fi
\if\mem@titlpg@reset\setcounter{page}{\@ne}\fi}
\newenvironment{titlingpage}{%
\def\mem@titlpg@reset{00}%
\begin{mem@titlingpage}}{%
\end{mem@titlingpage}}
\newenvironment{titlingpage*}{%
\def\mem@titlpg@reset{01}%
\begin{mem@titlingpage}}{%
\end{mem@titlingpage}}
\aliaspagestyle{titlingpage}{empty}
% \end{macrocode}
% \end{macro}
% \end{environment}
% \end{environment}
% \end{environment}
%
% \begin{macro}{\emptythanks}
% This macro discards all prior \cs{thanks} texts.
% \begin{macrocode}
\newcommand{\emptythanks}{\global\let\@thanks\@empty}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\andnext}
% The kernel \cs{and} macro puts space between author's names. The
% \cs{andnext} macro puts a newline between the names.
% \changes{v1.6}{2004/01/28}{Added \cs{andnext}}
% \begin{macrocode}
\newcommand*{\andnext}{%
\end{tabular}\\ \begin{tabular}[t]{c}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@bsmtitlempty}
% \cs{@bsmtitlempty} is a helper macro to save some macro space.
% It empties some elements of \cs{maketitle}.
% \changes{v3.6k}{2012/07/01}{Removed \cs{thanksfootextra}, seems to
% have been forgotten back in 2003.}
% \begin{macrocode}
\newcommand{\@bsmtitlempty}{%
\global\let\maketitle\relax
\global\let\@maketitle\relax
\global\let\title\relax
\global\let\author\relax
\global\let\date\relax
\global\let\thanksmarkseries\relax
\global\let\thanksfootextra\relax
\global\let\thanksmark\relax
\global\let\thanksgap\relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\keepthetitle}
% This macro undefines all the titling commands except for
% \cs{thetitle}, \cs{theauthor} and \cs{thedate}.
% \changes{v1.6}{2004/01/28}{changed \cs{keepthetitle} to cater for \cs{andnext}}
% \begin{macrocode}
\newcommand{\keepthetitle}{%
\@bsmtitlempty
\global\let\thanks\relax
\global\let\and\relax
\global\let\andnext\relax
\global\let\@thanks\@empty
\global\let\@title\@empty
\global\let\@author\@empty
\global\let\@date\@empty}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\killtitle}
% \cs{killtitle} undefines the remaining macros of \cs{maketitle}.
% \begin{macrocode}
\newcommand{\killtitle}{%
\keepthetitle
\global\let\thetitle\relax
\global\let\theauthor\relax
\global\let\thedate\relax}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\thetitle}
% \begin{macro}{\theauthor}
% \begin{macro}{\thedate}
% In order to make the \cs{title}, etc., values available for printing
% their definitions (in \file{ltsect.dtx}) need extending to save their
% arguments. We have to make sure that extraneous material,
% like \cs{thanks}, is excluded from the saved texts.
% \changes{v1.4}{2003/11/16}{Gobble footnotes in \cs{title}, \cs{author}
% and \cs{date} (from patch v1.4)}
% \changes{v1.6}{2004/01/28}{Added \cs{andnext} handling to \cs{author}}
% \begin{macrocode}
\addtoiargdef{\title}{%
\begingroup\let\footnote\@gobble}{%
\begingroup
\renewcommand{\thanks}[1]{}
\renewcommand{\thanksmark}[1]{}
\renewcommand{\thanksgap}[1]{}
\protected@xdef\thetitle{#1}
\endgroup\endgroup}
\addtoiargdef{\author}{%
\begingroup\let\footnote\@gobble}{%
\begingroup
\renewcommand{\thanks}[1]{}
\renewcommand{\and}{\unskip, }
\renewcommand{\andnext}{\unskip, }
\renewcommand{\thanksmark}[1]{}
\renewcommand{\thanksgap}[1]{}
\protected@xdef\theauthor{#1}
\endgroup\endgroup}
\addtoiargdef{\date}{%
\begingroup\let\footnote\@gobble}{%
\begingroup
\renewcommand{\thanks}[1]{}
\renewcommand{\thanksmark}[1]{}
\renewcommand{\thanksgap}[1]{}
\protected@xdef\thedate{#1}
\endgroup\endgroup}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \section{Parts, chapters and other divisions}
%
% \subsection{Building blocks} The definitions in this part of a
% class file usually make use of two internal macros, \cs{@startsection} and
% \cs{secdef}. To understand
% what is going on here, we describe their syntax.
%
% \DescribeMacro{\@startsection}
% The macro \cs{@startsection} has 6 required arguments, optionally
% followed by a $*$, an optional argument and a required argument:
%
% \cs{@startsection}\meta{name}\meta{level}\meta{indent}^^A
% \meta{beforeskip}\meta{afterskip}\meta{style}
% optional * %\\
% \null\hphantom{\bslash @startsection}^^A
% \oarg{altheading}\meta{heading}
%
% It is a generic command to start a section, the arguments have
% the following meaning:
%
% \begin{description}
% \item[\meta{name}] The name of the user level command, e.g.,
% `section'.
% \item[\meta{level}] A number, denoting the depth of the section
% --- e.g., chapter = 0, section = 1, etc. A section number
% will be printed if and only if \meta{level} $<=$ the value
% of the \Lcount{secnumdepth} counter.
% \item[\meta{indent}] The indentation of the heading from the left
% margin
% \item[\meta{beforeskip}] The absolute value of this argument
% gives the skip to leave above the heading. If it is
% negative, then the paragraph indent of the text following
% the heading is suppressed.
% \item[\meta{afterskip}] If positive, this gives the skip to leave
% below the heading, else it gives the skip to leave to the
% right of a run-in heading.
% \item[\meta{style}] Commands to set the style of the heading.
% \item[$*$] When this is missing the heading is numbered and the
% corresponding counter is incremented.
% \item[\meta{altheading}] Gives an alternative heading to use in
% the table of contents and in the running heads. This should
% be present when the $*$ form is used.
% \item[\meta{heading}] The heading of the new section.
% \end{description}
% A sectioning command is normally defined to \cs{@startsection} and
% its first six arguments.
%
% \DescribeMacro{\secdef}
% The macro \cs{secdef} can be used when a sectioning command is
% defined without using \cs{@startsection}. It has two arguments:
%
% \cs{secdef}\meta{unstarcmds}\meta{starcmds}
%
% \begin{description}
% \item[\meta{unstarcmds}] Used for the normal form of a
% sectioning command.
% \item[\meta{starcmds}] Used for the $*$-form of a
% sectioning command.
% \end{description}
%
% You can use \cs{secdef} as follows:
% \begin{verbatim}
% \def\chapter { ... \secdef \CMDA \CMDB }
% \def\CMDA [#1]#2{ ... } % Command to define
% % \chapter[...]{...}
% \def\CMDB #1{ ... } % Command to define
% % \chapter*{...}
% \end{verbatim}
%
% \DescribeMacro{\@hangfrom}
% Internally the \cs{@startsection} macro uses \verb?\@hangfrom{NUM}?, where
% \verb?NUM? is the sectional number, to produce a hanging paragraph. That is,
% the second and later lines of a multiline title are indented from the
% left margin by the width of the number.
% The definition of \cs{@hangfrom}, from \file{ltsect.dtx}, is:
% \begin{verbatim}
% \def\@hangfrom#1{\setbox\@tempboxa\hbox{{#1}}%
% \hangindent \wd\@tempboxa\noindent\box\@tempboxa}
% \end{verbatim}
%
% To get a normal paragraphed title you can do: \\
% \verb?\renewcommand{\@hangfrom}[1]{#1}? \\
% or as a block paragraph: \\
% \verb?\renewcommand{\@hangfrom}[1]{\noindent #1}? \\
%
% \DescribeMacro{\@seccntformat}
% The \cs{@startsection} macro also uses \verb?\@seccntformat{NUM}? to format
% the section number, including the space after it. Its definition,
% from \file{ltsect.dtx}, is
% \begin{verbatim}
% \def\@seccntformat#1{\csname the#1\endcsname\quad}
% \end{verbatim}
% This is the command to change if you need different number formatting. For
% example the combination
% \begin{verbatim}
% \renewcommand{\@seccntformat}[1]{\llap{\csname the#1\endcsname\quad}}
% \renewcommand{\@hangfrom}[1]{\noindent #1}
% \end{verbatim}
% will hang the section numbers in the margin.
%
% \begin{table}
% \centering
% \caption{Document division levels}\label{tab:levels}
% \begin{tabular}{lr} \hline
% Division & Level \\ \hline
% book & -2 \\
% part & -1 \\
% chapter & 0 \\
% section & 1 \\
% subsection & 2 \\
% subsubsection & 3 \\
% paragraph & 4 \\
% subparagraph & 5 \\
% \hline
% \end{tabular}
% \end{table}
%
% The values used for the document division levels are the same
% as defined by the standard \LaTeX{} classes, with the exception
% of the book division which is a memoir addition, and are given in
% Table~\ref{tab:levels}.
% \changes{v1.61803}{2008/01/30}{Added book division (from mempatch v4.4)}
% \subsection{Mark commands}
%
% \begin{macro}{\bookpagemark}
% \begin{macro}{\partmark}
% \begin{macro}{\chaptermark}
% \begin{macro}{\sectionmark}
% \begin{macro}{\subsectionmark}
% \begin{macro}{\subsubsectionmark}
% \begin{macro}{\paragraphmark}
% \begin{macro}{\subparagraphmark}
% The default initialisations of the \cs{...mark} commands for use in
% the pagestyles. Most are already defined in the kernel but they are
% all noted here.
% \begin{macrocode}
\newcommand*{\bookpagemark}[1]{}
\newcommand*{\partmark}[1]{}
\newcommand*{\chaptermark}[1]{}
% \newcommand*{\sectionmark}[1]{}
% \newcommand*{\subsectionmark}[1]{}
% \newcommand*{\subsubsectionmark}[1]{}
% \newcommand*{\paragraphmark}[1]{}
% \newcommand*{\subparagraphmark}[1]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibmark}
% Marks for the bibliography, which may be filled with \cs{bibname}.
% \changes{v1.1}{2002/03/10}{Added \cs{bibmark}}
% \begin{macrocode}
\newcommand*{\bibmark}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\indexmark}
% Marks for the index, which may be filled with \cs{indexname}.
% \changes{v1.1}{2002/03/10}{Added \cs{indexmark}}
% \begin{macrocode}
\newcommand*{\indexmark}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\glossarymark}
% Marks for the glossary, which may be filled with \cs{glossaryname}.
% \changes{v1.618}{2005/09/25}{Added \cs{glossarymark}}
% \begin{macrocode}
\newcommand*{\glossarymark}{}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Define Counters}
%
% \begin{macro}{\c@secnumdepth}
% The value of the counter \Lcount{secnumdepth} gives the depth of
% the highest-level sectioning command that is to produce section
% numbers.
% \begin{macrocode}
\setcounter{secnumdepth}{2}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@book}
% \begin{macro}{\c@part}
% \begin{macro}{\c@chapter}
% \begin{macro}{\c@section}
% \begin{macro}{\c@subsection}
% \begin{macro}{\c@subsubsection}
% \begin{macro}{\c@paragraph}
% \begin{macro}{\c@subparagraph}
% These counters are used for the sectioning numbers. The macro\\
% \cs{newcounter}\marg{newctr}\oarg{oldctr}\\
% defines\meta{newctr} to be a counter, which is reset to zero when
% counter \meta{oldctr} is stepped. Counter \meta{oldctr} must
% already be defined.
%
% Book, part and chapter are the top level document divisions.
% \begin{macrocode}
\newcounter{book} \setcounter{book}{0}
\newcounter{part} \setcounter{part}{0}
\newcounter{chapter} \setcounter{chapter}{0}
% \end{macrocode}
% The lower level divisions get reset by higher level divisions.
% \begin{macrocode}
\newcounter{section}[chapter]
\newcounter{subsection}[section]
\newcounter{subsubsection}[subsection]
\newcounter{paragraph}[subsubsection]
\newcounter{subparagraph}[paragraph]
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\thebook}
% \begin{macro}{\thepart}
% \begin{macro}{\thechapter}
% \begin{macro}{\thesection}
% \begin{macro}{\thesubsection}
% \begin{macro}{\thesubsubsection}
% \begin{macro}{\theparagraph}
% \begin{macro}{\thesubparagraph}
% For any counter \Lcount{CTR}, \cs{theCTR} is a macro that defines
% the printed version of counter \Lcount{CTR}. It is defined in
% terms of the following macros:
%
% \cs{arabic}\marg{COUNTER} prints the value of
% \meta{COUNTER} as an arabic numeral.
%
% \cs{roman}\marg{COUNTER} prints the value of
% \meta{COUNTER} as a lowercase roman numeral.
%
% \cs{Roman}\marg{COUNTER} prints the value of
% \meta{COUNTER} as an uppercase roman numeral.
%
% \cs{alph}\marg{COUNTER} prints the value of \meta{COUNTER}
% as a lowercase letter: $1 =$~a, $2 =$~ b, etc.
%
% \cs{Alph}\marg{COUNTER} prints the value of \meta{COUNTER}
% as an uppercase letter: $1 =$~A, $2 =$~B, etc.
%
% \begin{macrocode}
\renewcommand*{\thebook}{\@Roman\c@book}
\renewcommand*{\thepart}{\@Roman\c@part}
\renewcommand*{\thechapter}{\@arabic\c@chapter}
\renewcommand*{\thesection}{\thechapter.\@arabic\c@section}
\renewcommand*{\thesubsection}{%
\thesection.\@arabic\c@subsection}
\renewcommand*{\thesubsubsection}{%
\thesubsection.\@arabic\c@subsubsection}
\renewcommand*{\theparagraph}{%
\thesubsubsection.\@arabic\c@paragraph}
\renewcommand*{\thesubparagraph}{%
\theparagraph.\@arabic\c@subparagraph}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@chapapp}
% \cs{@chapapp} is initially defined as \cs{chaptername}. The \cs{appendix}
% command redfines it as \cs{appendixname}.
% \begin{macrocode}
\newcommand{\@chapapp}{\chaptername}
% \end{macrocode}
% \end{macro}
%
% \subsection{Front, main and back matter}
%
% These are the three main logical divisions in a book. As noted earlier,
% the boolean \cs{if@mainmatter} is TRUE iff the main matter is being
% processed. Chapters will be unnumbered when \cs{if@mainmatter} is FALSE.
%
% \begin{macro}{\frontmatter}
% \begin{macro}{\frontmatter*}
% The \cs{frontmatter} command starts roman numbering and turns off
% chapter numbering.
% It ensures that lower level divisions will not have chapter numbers,
% nor will figures or tables. It
% also ensures that the next page will be recto.
% The starred version makes no changes to the page numbering\footnote{The
% starred versions were added to meet a request by Daniel Richard G.
% (\texttt{skunk@mit.edu}) in September 2001.}.
% \changes{v0.3}{2001/07/09}{\cs{frontmatter} switches off numbering via
% the secnumdepth counter}
% \changes{v1.0}{2001/09/21}{Added \cs{frontmatter*} command}
% \begin{macrocode}
\newcommand{\frontmatter}{%
\@ifstar{\@smemfront}{\@memfront}}
% \end{macrocode}
% \begin{macro}{\@memfront@floats}
% \changes{v1.6180339f}{Added \cs{@memfront@floats}}
% Factoring out the float counter domination, in case someone wants
% something added or changed
% \begin{macrocode}
\newcommand\@memfront@floats{%
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@smemfront}
% \begin{macrocode}
\newcommand{\@smemfront}{%
\cleardoublepage
\@mainmatterfalse
\setcounter{secnumdepth}{-10}
\@memfront@floats
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@memfront}
% \begin{macrocode}
\newcommand{\@memfront}{%
\@smemfront\pagenumbering{roman}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\mainmatter}
% \begin{macro}{\mainmatter*}
% The \cs{mainmatter} command starts arabic numbering and turns on chapter numbering.
% It sets numbering to the normal state. It
% also ensures that the next page will be recto. The starred version does
% not change the page numbering.
%
% Romano Giannetti suggested that \cs{mainmatter} (and \cs{backmatter}) should
% be almost no-ops with the article option.
% \changes{v0.3}{2001/07/09}{\cs{mainmatter} switches on section numbering
% via the secnumdepth counter}
% \changes{v1.0}{2001/09/21}{Added \cs{mainmatter*} command}
% \begin{macrocode}
\newcommand{\mainmatter}{%
\@ifstar{\@smemmain}{\@memmain}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@memmain@floats}
% \changes{v1.6180339f}{}{Added \cs{@memmain@floats}}
% Factoring out the float counter domination, in case someone wants
% something added or changed
% \begin{macrocode}
\newcommand\@memmain@floats{%
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@smemmain}
% If \cs{frontmatter} and \cs{mainmatter} are used with the article option,
% then a page numbering / margin problem can occur if the frontmatter ends
% on an odd page --- the first mainmatter next page is odd as well which throws
% puts two odd-margined pages together.
%
% One fix from Morten is to always \cs{cleardoublepage} for twosided articles.
%
% One fix from me is for the ...matter macros to just switch on/off section
% numbering.
%
% Morten's is simpler to implement.
%
% \changes{v1.1}{2002/03/10}{Modified \cs{@smemmain} to reset the secnumdepth
% counter to maxsecnumdepth}
% \changes{v1.4}{2003/11/22}{Included cognizance of article option in \cs{@smemmain}
% (from patch v1.7)}
% \changes{v1.61803}{2008/01/30}{Changed timing of \cs{clear[double]page} in
% \cs{@smemmain} (David Wilson, mempatch v4.5)}
% \changes{v1.61803}{2008/01/30}{Changed clear pages in \cs{@smemmain}
% (mempatch v4.9)}
% \begin{macrocode}
\newcommand*{\@smemmain}{%
\@mainmattertrue
\setcounter{secnumdepth}{\value{maxsecnumdepth}}
\ifartopt
\if@twoside
\cleardoublepage
\else
\clearpage
\fi
\else
\cleardoublepage
\@memmain@floats
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@memmain}
% \begin{macrocode}
\newcommand{\@memmain}{%
\@smemmain\pagenumbering{arabic}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@memback@floats}
% \changes{v1.6180339f}{Added \cs{@memback@floats}}
% Factoring out the float counter domination, in case someone wants
% something added or changed
% \begin{macrocode}
\newcommand\@memback@floats{%
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\setcounter{figure}{0}
\setcounter{table}{0}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\backmatter}
% This command turns off chapter numbering but leaves the page numbering alone.
% It twiddles the numbering caption numbering.
% The back matter may start on any new page.
% \changes{v0.3}{2001/07/09}{\cs{backmatter} uses the secnumdepth counter}
% \changes{v1.4}{2003/11/22}{Included cognizance of article option in \cs{backmatter}
% (from patch v1.7)}
% \begin{macrocode}
\newcommand{\backmatter}{%
\ifartopt
\clearpage
\else
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\fi
\@mainmatterfalse
\setcounter{secnumdepth}{-10}
\ifartopt\else
\@memback@floats
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Book}
%
% This was added at the request of Frederic Connes who said that in
% Frency typography there was often a division above the \cs{part} level.
%
% \begin{macro}{\theHbook}
% \begin{macro}{\toclevel@book}
% These are needed if the \Lpack{hyperref} is used.
% \changes{v3.7.19}{2022/10/25}{Changing \cs{theH...} definitions to
% \cs{def} for better compability with future hyperref}
% \begin{macrocode}
\def\theHbook{\arabic{book}}
\def\toclevel@book{-2}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\book}
% \begin{macro}{\book*}
% \cs{book}\marg{title} starts a new book division called \meta{title}.
% The actual typesetting of the title is done by \cs{@book} or \cs{@sbook}.
% \changes{v1.61803}{2008/01/30}{Added \cs{book} and its entourage (mempatch v4.4)}
% \begin{macrocode}
\newcommand*{\book}{%
\@setupbook
\secdef\@book\@sbook}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\beforebookskip}
% \begin{macro}{\midbookskip}
% \begin{macro}{\afterbookskip}
% These three macros are the skips before, in the middle, and after the
% Book heading.
% \begin{macrocode}
\newcommand*{\beforebookskip}{\null\vfil}
\newcommand*{\midbookskip}{\par\vskip 2\onelineskip}
\newcommand*{\afterbookskip}{\vfil\newpage}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@setupbook}
% This macro does the work of setting up for the \cs{book} command.
% A single column page, normally recto, with a \pstyle{book} pagestyle is
% started.
% \begin{macrocode}
\newcommand{\@setupbook}{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{book}%
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\beforebookskip}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\booknamefont}
% \begin{macro}{\booknumfont}
% \begin{macro}{\booktitlefont}
% These three macros specify the fonts for the book name and number, and
% for the book title, respectively.
% \begin{macrocode}
\newcommand*{\booknamefont}{\normalfont\huge\bfseries}
\newcommand*{\booknumfont}{\normalfont\huge\bfseries}
\newcommand*{\booktitlefont}{\normalfont\Huge\bfseries}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\printbookname}
% \begin{macro}{\booknamenum}
% \begin{macro}{\printbooknum}
% \begin{macro}{\printbooktitle}
% Macros to print the various books of a Book heading.
% \begin{macrocode}
\newcommand*{\printbookname}{\booknamefont \bookname}
\newcommand*{\booknamenum}{\space}
\newcommand*{\printbooknum}{\booknumfont \thebook}
\newcommand*{\printbooktitle}[1]{\booktitlefont #1}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\membookinfo}
% \begin{macro}{\membookstarinfo}
% \begin{macrocode}
\newcommand{\membookinfo}[3]{}
\newcommand{\membookstarinfo}[1]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@book}
% \cs{@book}\oarg{short}\marg{long} typesets the title of a \cs{book}
% book. There is a number if \cs{secnumdepth} is greater than -3.
% \begin{macrocode}
\long\def\@book[#1]#2{%
\M@gettitle{#1}%
% \end{macrocode}
% For continuity we store the toc entry in \verb?\f@rtoc? before
% writing it to the \verb?.toc? file. We also provide a hook to be
% able to transform it.
% \changes{v3.6k}{2012/09/18}{Provided \cs{f@rtoc} and hook}
% \changes{v3.6k}{2013/04/24}{Added \cs{mempreaddbooktotochook} and \cs{mempostaddbooktotochook}}
% \begin{macrocode}
\def\f@rtoc{#1}%
\@nameuse{book@f@rtoc@before@write@hook}%
\phantomsection
\mempreaddbooktotochook
\ifnum \c@secnumdepth >-3\relax
\refstepcounter{book}%
\addcontentsline{toc}{book}%
{\protect\booknumberline{\thebook}\f@rtoc}%
\membookinfo{\thebook}{\f@rtoc}{#2}%
\else
\addcontentsline{toc}{book}{\f@rtoc}%
\membookinfo{}{\f@rtoc}{#2}%
\fi
\mempostaddbooktotochook
% \end{macrocode}
% Empty the marks, center the title on the page, and set the normal font.
% \changes{v3.6j}{2011/03/03}{Set \cs{parskip} to zero, such that a
% non-zero \cs{parskip} does not interfer with the title layout}
% \begin{macrocode}
\bookpagemark{#1}%
{\centering
\interlinepenalty \@M
\parskip\z@
\normalfont
% \end{macrocode}
% Print the number, if there is one, then the title below. Macro \cs{@endbook}
% tidies everything up at the end.
% \begin{macrocode}
\ifnum \c@secnumdepth >-3\relax
\printbookname \booknamenum \printbooknum
\midbookskip
\fi
\printbooktitle{#2}\par}%
\@endbook}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mempreaddbooktotochook}
% \begin{macro}{\mempostaddbooktotochook}
% Hooks executed just before and just after \cs{book} adds something
% to the ToC. Does nothing by default
% \begin{macrocode}
\newcommand\mempreaddbooktotochook{}
\newcommand\mempostaddbooktotochook{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@sbook}
% \cs{@sbook}\marg{long} formats the title of a \cs{book*} book. It is
% simpler than \cs{@book} because there is no number to print.
% \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@sbook}}
% \changes{v3.6j}{2011/03/03}{Set \cs{parskip} to zero here as well}
% \begin{macrocode}
\long\def\@sbook#1{%
\M@gettitle{#1}%
\phantomsection
\membookstarinfo{#1}%
{\centering
\interlinepenalty \@M
\parskip\z@
\normalfont
\printbooktitle{#1}\par}%
\@endbook}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifm@mnobooknewpage}
% \begin{macro}{\m@mnobooknewpagetrue}
% \begin{macro}{\m@mnobooknewpagefalse}
% \begin{macro}{\bookblankpage}
% \begin{macro}{\nobookblankpage}
% The declaration \cs{nobookblankpage} prevents \cs{book} from
% outputting a further (blank) page when it finishes. The default is set by
% \cs{bookblankpage}.
% \begin{macrocode}
\newif\ifm@mnobooknewpage
\m@mnobooknewpagefalse
\newcommand*{\bookblankpage}{\m@mnobooknewpagefalse}
\newcommand*{\nobookblankpage}{\m@mnobooknewpagetrue}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bookpageend}
% \begin{macro}{\@endbook}
% This finishes off both \cs{@book} and \cs{@sbook}.
% Following a \cs{nobookblankpage} nothing is done, otherwise
% (after \cs{bookblankpage}) the current page is flushed,
% and an extra blank page is created if both \Lopt{twoside} and
% \Lopt{openright} are in effect.
% At the end, if necessary, two column mode is switched back on.
% \changes{v1.61803398}{2009/07/26}{PW: Added \cs{bookpageend} as cover for \cs{@endbook}}
% \begin{macrocode}
\newcommand*{\bookpageend}{\afterbookskip
\ifm@mnobooknewpage
\else
\if@twoside
\if@openright
\null
\thispagestyle{afterbook}%
\newpage
\fi
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\def\@endbook{\bookpageend}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ps@book}
% \begin{macro}{\ps@afterbook}
% Pagestyles for the book page and the (blank) page after a book page.
% \begin{macrocode}
\aliaspagestyle{book}{empty}
\aliaspagestyle{afterbook}{empty}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Part}
%
% \begin{macro}{\part}
% \cs{part}\marg{title} starts a new Part called \meta{title}.
% The actual typesetting of the title is done by \cs{@part} or \cs{@spart}.
% \begin{macrocode}
\newcommand{\part}{%
\@setuppart
\secdef\@part\@spart}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\beforepartskip}
% \begin{macro}{\midpartskip}
% \begin{macro}{\afterpartskip}
% These three macros are the skips before, in the middle, and after the
% Part heading.
% \changes{v1.61803}{2008/01/30}{Changed \cs{midpartskip} (mempatch v4.9)}
% \begin{macrocode}
\newcommand{\beforepartskip}{\null\vfil}
\newcommand{\midpartskip}{\par\vskip 2\onelineskip}
\newcommand{\afterpartskip}{\vfil\newpage}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@setuppart}
% This macro does the work of setting up for the \cs{part} command.
% A single column page, normally recto, with a \pstyle{part} pagestyle is started.
% \begin{macrocode}
\newcommand{\@setuppart}{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{part}%
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\beforepartskip}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\partnamefont}
% \begin{macro}{\partnumfont}
% \begin{macro}{\parttitlefont}
% These three macros specify the fonts for the part name and number, and
% for the part title, respectively.
% \changes{v0.2}{2001/06/03}{Rewrote the typesetting for Part titles}
% \begin{macrocode}
\newcommand{\partnamefont}{\normalfont\huge\bfseries}
\newcommand{\partnumfont}{\normalfont\huge\bfseries}
\newcommand{\parttitlefont}{\normalfont\Huge\bfseries}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\printpartname}
% \begin{macro}{\partnamenum}
% \begin{macro}{\printpartnum}
% \begin{macro}{\printparttitle}
% Macros to print the various parts of a Part heading.
% \begin{macrocode}
\newcommand{\printpartname}{\partnamefont \partname}
\newcommand{\partnamenum}{\space}
\newcommand{\printpartnum}{\partnumfont \thepart}
\newcommand{\printparttitle}[1]{\parttitlefont #1}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\mempartinfo}
% \begin{macro}{\mempartstarinfo}
% \verb?\mempartinfo{\thepart}{short}{long}? \\
% \verb?\mempartstarinfo{long}? \\
% \changes{v1.61803}{2008/01/30}{Made \cs{mempartinfo} long (mempatch v4.9).}
% \begin{macrocode}
\newcommand{\mempartinfo}[3]{}
\newcommand{\mempartstarinfo}[1]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@part}
% \cs{@part}\oarg{short}\marg{long} typesets the title of a \cs{part}
% part. There is a number if \cs{secnumdepth} is greater than -2.
% \changes{v1.3}{2002/11/14}{Used \cs{partnumberline} in \cs{@part}}
% \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@part}}
% \changes{v1.618}{2005/09/03}{Replaced \cs{markboth} by \cs{partmark}
% in \cs{@part} courtesy of Frederic Connes (mempatch v3.11)}
% \begin{macrocode}
\long\def\@part[#1]#2{%
\M@gettitle{#1}%
% \end{macrocode}
% For continuity we store the toc entry in \verb?\f@rtoc? before
% writing it to the \verb?.toc? file. We also provide a hook to be
% able to transform it.
% \changes{v3.6k}{2012/09/18}{Provided \cs{f@rtoc} and hook}
% \changes{v3.6k}{2013/04/24}{Added \cs{mempreaddparttotochook} and \cs{mempostaddparttotochook}}
% \begin{macrocode}
\def\f@rtoc{#1}%
\@nameuse{part@f@rtoc@before@write@hook}%
\phantomsection
\mempreaddparttotochook
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
\addcontentsline{toc}{part}%
{\protect\partnumberline{\thepart}\f@rtoc}%
\mempartinfo{\thepart}{\f@rtoc}{#2}%
\else
\addcontentsline{toc}{part}{\f@rtoc}%
\mempartinfo{}{\f@rtoc}{#2}%
\fi
\mempostaddparttotochook
% \end{macrocode}
% Empty the marks, center the title on the page, and set the normal font.
% \changes{v3.6j}{2011/03/03}{Set \cs{parskip} to zero inside the
% group, such that a non-zero \cs{parskip} does not interfer with the
% title layout}
% \begin{macrocode}
\partmark{#1}%
{\centering
\interlinepenalty \@M
\parskip\z@
\normalfont
% \end{macrocode}
% Print the number, if there is one, then the title below. Macro \cs{@endpart}
% tidies everything up at the end.
% \begin{macrocode}
\ifnum \c@secnumdepth >-2\relax
\printpartname \partnamenum \printpartnum
\midpartskip
\fi
\printparttitle{#2}\par}%
\@endpart}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mempreaddparttotochook}
% \begin{macro}{\mempostaddparttotochook}
% Hooks executed just before and just after \cs{part} adds something
% to the ToC. Does nothing by default
% \begin{macrocode}
\newcommand\mempreaddparttotochook{}
\newcommand\mempostaddparttotochook{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@spart}
% \cs{@spart}\marg{long} formats the title of a \cs{part*} part. It is
% simpler than \cs{@part} because there is no number to print.
% \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@spart}}
% \changes{v3.6j}{2011/03/03}{Set \cs{parskip} to zero here as well}
% \begin{macrocode}
\long\def\@spart#1{%
\M@gettitle{#1}%
\phantomsection
\mempartstarinfo{#1}%
{\centering
\interlinepenalty \@M
\parskip\z@
\normalfont
\printparttitle{#1}\par}%
\@endpart}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifm@mnopartnewpage}
% \begin{macro}{\m@mnopartnewpagetrue}
% \begin{macro}{\m@mnopartnewpagefalse}
% \begin{macro}{\partblankpage}
% \begin{macro}{\nopartblankpage}
% The declaration \cs{nopartblankpage} prevents \cs{part} from
% outputting a blank page when it finishes. The default is set by
% \cs{partblankpage}. This code was originally supplied by Frederic Connes.
% \changes{v1.61803}{2008/01/30}{Added \cs{partblankpage} and
% \cs{nopartblankpage} (mempatch v v4.4).}
% \begin{macrocode}
\newif\ifm@mnopartnewpage
\m@mnopartnewpagefalse
\newcommand*{\partblankpage}{\m@mnopartnewpagefalse}
\newcommand*{\nopartblankpage}{\m@mnopartnewpagetrue}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\partpageend}
% \begin{macro}{\@endpart}
% This finishes off both \cs{@part} and \cs{@spart}.
% Following a \cs{nopartblankpage} nothing is done, otherwise
% (after \cs{partblankpage}) the current page is flushed.
% In the standard \Lpack{book} class if
% two-sided mode is on a blank page is then produced. I think that this looks
% odd when the \Lopt{openany} option is in force, so here it only produces
% an extra blank page if both \Lopt{twoside} and \Lopt{openright} are
% in effect.
%
% At the end, if necessary, two column mode is switched back on.
% \changes{v1.61803}{2008/01/30}{Used the afterpart pagestyle in \cs{@endpart}}
% \changes{v1.61803398}{2009/07/26}{PW: Added \cs{partpageend} as cover for \cs{@endpart}}
% \begin{macrocode}
\newcommand*{\partpageend}{\afterpartskip
\ifm@mnopartnewpage
\else
\if@twoside
\if@openright
\null
\thispagestyle{afterpart}%
\newpage
\fi
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\def\@endpart{\partpageend}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ps@afterpart}
% Pagestyle for the (blank) page after a part page.
% \changes{v1.61803}{2008/01/30}{Added afterpart pagestyle (mempatch v4.4)}
% \begin{macrocode}
\aliaspagestyle{afterpart}{empty}
% \end{macrocode}
% \end{macro}
%
% \subsection{Chapter}
%
% \begin{macro}{\chapter}
% The command to start a new chapter. Chapters always start on a new page
% with a \pstyle{chapter} pagestyle. Floats are not allowed at the top of the page.
% The typesetting is done by either \cs{@chapter} or \cs{@schapter}.
% \changes{v0.3}{2001/07/09}{Changed \cs{chapter} for article option}
% \changes{v1.0}{2001/10/24}{Changed chapter page clearing to \cs{clearforchapter}}
% \changes{v1.2}{2002/07/27}{New optarg in \cs{chapter} for short heading}
% \changes{v1.618}{2005/09/03}{Made article chapter start on a newline (mempatch v3.5)}
% \changes{v3.6e}{2010/07/16}{Factored out the \cs{@afterindentfalse}}
% \changes{v3.6h}{2011/02/07}{Added the chapter block}
% \begin{macrocode}
\newcommand\chapter{%
% \end{macrocode}
% The block macro can be defined to execute a \cs{FloatBlock} when we
% are in article mode. Outside article mode \cs{clearforchapter} is
% expected to be used for this.
% \begin{macrocode}
\ifartopt\par\@nameuse{chapterblock}\else
\clearforchapter
\thispagestyle{chapter}
\global\@topnum\z@
\fi
% \@afterindentfalse
\m@mindentafterchapter
\@ifstar{\@m@mschapter}{\@m@mchapter}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mindentafterchapter}
% \begin{macro}{\indentafterchapter}
% \begin{macro}{\noindentafterchapter}
% In order to make whether to indent the first paragraph after af
% chapter configurable, we store \verb?\@afterindenttrue/false? in
% \verb?\m@mindentafterchapter?, and provide
% \verb?\indentafterchapter? and \verb?\noindentafterchapter? to set
% it to a suitable value.
% \begin{macrocode}
\newcommand*\indentafterchapter{\def\m@mindentafterchapter{\@afterindenttrue}}
\newcommand*\noindentafterchapter{\def\m@mindentafterchapter{\@afterindentfalse}}
% \end{macrocode}
% Default is not to indent.
% \begin{macrocode}
\noindentafterchapter
% \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@m@mchapter}
% \begin{macro}{\ch@pt@c}
% \begin{macro}{\m@m@empty}
% Intermediate and support macros for the extra optional argument
% to \cs{chapter}. Have to do this long windedly otherwise dear old
% \Lpack{hyperref} barfs.
%
% The code for two optional arguments is based on a posting
% to \ctt{} by Robin Fairbairns (1997/04/12 \textit{Re: Several optional
% arguments for macro?}).
% \changes{v1.618}{2005/09/04}{Major changes to \cs{chapter} macros (from Morten Hogholm 2005/08/30)}
% \begin{macrocode}
\newcommand{\@m@mchapter}[1][]{%
\def\ch@pt@c{#1}% capture first optional arg
\@ifnextchar[{\@chapter}{\@chapter[]}%
}
\def\m@m@empty{\@empty}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memchapinfo}
% \begin{macro}{\memchapstarinfo}
% \begin{macro}{\memappchapinfo}
% \begin{macro}{\memappchapstarinfo}
% \verb?\memchapinfo{num}{toc}{head}{full}? \\
% \verb?\memchapstarinfo{short}{full}?
% \changes{v1.618}{2005/09/06}{Added \cs{memchapinfo}}
% \begin{macrocode}
\newcommand{\memchapinfo}[4]{}
\newcommand{\memchapstarinfo}[2]{}
\newcommand{\memappchapinfo}[4]{}
\newcommand{\memappchapstarinfo}[2]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifm@mpn@new@chap}
% \begin{macro}{\m@mpn@new@chapfalse}
% \begin{macro}{\m@mpn@new@chaptrue}
% \begin{macro}{\ifm@mpn@new@schap}
% \begin{macro}{\m@mpn@new@schapfalse}
% \begin{macro}{\m@mpn@new@schaptrue}
% These are for supporting the page/end notes, flagging that a
% \verb?\chapter(*)? has been called.
% \changes{v1.61803}{2008/01/30}{Added \cs{ifm@mpn@new@chap} and
% \cs{ifm@mpn@new@chap} (mempatch v4.5)}
% \begin{macrocode}
\newif\ifm@mpn@new@chap
\m@mpn@new@chapfalse
\newif\ifm@mpn@new@schap
\m@mpn@new@schapfalse
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@chapter}
% \begin{macro}{\f@rtoc}
% \begin{macro}{\f@rhdr}
% \begin{macro}{\f@rbody}
% \cs{@chapter}\oarg{tocmark}\marg{title}
% typesets the title of a \cs{chapter}.
% There is a number if \cs{secnumdepth} is greater than -1 and \cs{@mainmatter}
% is TRUE.
%
% \changes{v1.2}{2002/07/27}{Complete rewrite of \cs{@chapter}}
% \changes{v1.3}{2002/11/14}{Changed \cs{numberline} to \cs{chapternumberline}
% in \cs{@chapter}}
% \changes{v1.61803}{2008/01/30}{Added \cs{f@rbody} to \cs{@chapter},
% plus newchapter flag (mempatch v4.5)}
% \changes{v1.6180339g}{2009/07/13}{added \cs{m@mpn@new@schapfalse}
% otherwise both might end up true at the same time}
% \begin{macrocode}
\def\@chapter[#1]#2{%
\m@mpn@new@chaptrue%
\m@mpn@new@schapfalse%
\def\f@rbdy{#2}%
\ifx\ch@pt@c\@empty % no optional args
\def\f@rtoc{#2}%
\def\f@rhdr{#2}%
\else % at least one opt arg
\let\f@rtoc\ch@pt@c
\ifx\@empty#1\@empty
\let\f@rhdr\ch@pt@c
\else
\def\f@rhdr{#1}%
\fi
\fi
\m@m@Andfalse
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\m@m@Andtrue
\fi
\fi
\ifm@m@And
\refstepcounter{chapter}%
\fi
% \end{macrocode}
% Deal with the \Lopt{article} option.
% \begin{macrocode}
\ifartopt
\@makechapterhead{#2}%
\@afterheading
\chaptermark{\f@rhdr}%
\else
% \end{macrocode}
% Store the (short) title via \cs{chaptermark}, and add some whitespace to
% the LoF and LoT. Then fiddle when we are using two columns, calling
% \cs{@makechapterhead} to do the typesetting.
% \changes{v0.3}{2001/07/09}{Changed \cs{@chapter} for article option}
% \begin{macrocode}
\chaptermark{\f@rhdr}
\insertchapterspace
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\fi
\@afterheading
\fi
% \end{macrocode}
% When working with \Lpack{hyperref} it is not possible to add, say,
% upper casing to ToC entries via \cs{cftchapterfont}. We provide a
% hook, such that users can transform \cs{f@rtoc} before it is
% actually written to the \texttt{.toc} file.
% \changes{v3.6k}{2012/09/18}{Added}
% \begin{macrocode}
\@nameuse{chapter@f@rtoc@before@write@hook}%
% \end{macrocode}
% Vittorio De Martino (\texttt{demartino.vittoria@grtn.it}) on
% 31 March 2003 reported that for articled chapters, which do not do
% any \cs{clearpage}, \cs{addcontents} had to come after the title.
% \changes{v1.4}{2003/11/16}{Changed \cs{@chapter} to match patches v1.n}
% \changes{v3.6k}{2013/04/24}{Added pretoc and posttoc hooks}
% \begin{macrocode}
\mempreaddchaptertotochook%
\ifm@m@And
\ifanappendix
\addcontentsline{toc}{appendix}{%
\protect\chapternumberline{\thechapter}\f@rtoc}%
\memappchapinfo{\thechapter}{\f@rtoc}{\f@rhdr}{#2}%
\else
\addcontentsline{toc}{chapter}{%
\protect\chapternumberline{\thechapter}\f@rtoc}%
\memchapinfo{\thechapter}{\f@rtoc}{\f@rhdr}{#2}%
\fi
\else
\addcontentsline{toc}{chapter}{\f@rtoc}%
\ifanappendix
\memappchapinfo{}{\f@rtoc}{\f@rhdr}{#2}%
\else
\memchapinfo{}{\f@rtoc}{\f@rhdr}{#2}%
\fi
\fi
\mempostaddchaptertotochook%
% \end{macrocode}
% Add hook for title referencing.
% \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@chapter}}
% \changes{v3.6k}{2013/04/24}{Added \cs{memendofchapterhook}}.
% The hook at the very end can be used to automatically add a new page
% right after \cs{chapter}.
% \begin{macrocode}
\ifheadnameref\M@gettitle{\f@rhdr}\else\M@gettitle{\f@rtoc}\fi%
\memendofchapterhook%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\mempreaddchaptertotochook}
% \begin{macro}{\mempostaddchaptertotochook}
% \begin{macro}{\memendofchapterhook}
% These two hooks are executed before \cs{chapter} adds anything to
% the TOC and after it does so. It can be used to add hooks into the
% TOC such that parts can be switched on and off. By default they do nothing.
% \begin{macrocode}
\newcommand\mempreaddchaptertotochook{}
\newcommand\mempostaddchaptertotochook{}
\newcommand\memendofchapterhook{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\settocpreprocessor}
% \changes{v3.6k}{2012/09/18}{Added}
% This can be used to set a hook which users can fill in in order to
% get the toc material preprocessed before writing it to the
% \verb?.toc? file. The primary use for this is as a workaround when
% \Lpack{hyperref} is used, and one want to have, say, upper cased toc
% entries. Example of use
% \begin{verbatim}
% \makeatletter
% \settocpreprocessor{chapter}{%
% \let\temp@f@rtoc\f@rtoc
% \def\f@rtoc{\texorpdfstring{\MakeTextUppercase{\temp@f@rtoc}}{\temp@f@rtoc}}
% }
% \makeatother
% \end{verbatim}
% The idea comes from \url{http://tex.stackexchange.com/q/11892/3929}
% eliminating the need for patching.
% \begin{macrocode}
\newcommand\settocpreprocessor[2]{%
\@namedef{#1@f@rtoc@before@write@hook}{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makechapterhead}
% This \emph{really} typesets a \cs{chapter}. Leave some whitespace and prepare to
% set \cs{raggedright}.
% \changes{v1.3}{2002/10/10}{Added \cs{printchapternonum} to
% \cs{@makechapterhead}}
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{@makechapterhead}}
% \changes{v3.6j}{2011/03/01}{Set \cs{parskip} to zero such that a
% non-zero \cs{parskip} to not interfer with the placement of the title}
% \begin{macrocode}
\def\@makechapterhead#1{%
\chapterheadstart%
{%
\parskip \z@
\parindent \z@ \memRTLraggedright \normalfont
% \end{macrocode}
% If there is a number, typeset it, otherwise call \cs{printchapternonum}.
% \begin{macrocode}
\ifm@m@And
\printchaptername \chapternamenum \printchapternum
\afterchapternum %
\else
\printchapternonum
\fi
% \end{macrocode}
% Typeset the title.
% \begin{macrocode}
\interlinepenalty\@M
\printchaptertitle{#1} %
\afterchaptertitle %
}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\insertchapterspace}
% By default, a \cs{chapter} inserts some vertical space into the LoF and LoT.
% The macro \cs{insertchapterspace} performs the insertion.
% \changes{v0.33}{2001/08/31}{Added \cs{insertchapterspace}}
% \begin{macrocode}
\newcommand*{\insertchapterspace}{%
\addtocontents{lof}{\protect\addvspace{10pt}}%
\addtocontents{lot}{\protect\addvspace{10pt}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\beforechapskip}
% \begin{macro}{\midchapskip}
% \begin{macro}{\afterchapskip}
% Lengths separating the various parts of a chapter heading.
% \begin{macrocode}
\newlength{\beforechapskip}\setlength{\beforechapskip}{50pt}
\newlength{\midchapskip}\setlength{\midchapskip}{20pt}
\newlength{\afterchapskip}\setlength{\afterchapskip}{40pt}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@chs@def@ult}
% This sets up all the definitions and defaults used in \cs{@makechapterhead}
% and \cs{@makeschapterhead}.
% \changes{v1.3}{2002/10/10}{Added \cs{printchapternonum} to \cs{@chs@def@ult}}
% \changes{v1.61803}{2008/01/30}{Made \cs{@chs@def@ult} set all default chapter values}
% \begin{macro}{\chapterheadstart}
% \begin{macro}{\printchaptername}
% \begin{macro}{\chapternamenum}
% \begin{macro}{\printchapternum}
% \begin{macro}{\afterchapternum}
% \begin{macro}{\printchapternum}
% \begin{macro}{\printchapternonum}
% \begin{macro}{\printchaptertitle}
% \begin{macro}{\afterchaptertitle}
% \begin{macrocode}
\newcommand{\@chs@def@ult}{%
\def\chapterheadstart{\vspace*{\beforechapskip}}%
\def\printchaptername{\chapnamefont \@chapapp}%
\def\chapternamenum{\space}%
\def\printchapternum{\chapnumfont \thechapter}%
\def\afterchapternum{\par\nobreak\vskip \midchapskip}%
\def\printchapternonum{}%
\def\printchaptertitle##1{\chaptitlefont ##1}%
\def\afterchaptertitle{\par\nobreak\vskip \afterchapskip}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\chapnamefont}
% \begin{macro}{\chapnumfont}
% \begin{macro}{\chaptitlefont}
% Fonts for setting chapter name, number, and title.
% \begin{macrocode}
\def\chapnamefont{\normalfont\huge\bfseries}%
\def\chapnumfont{\normalfont\huge\bfseries}%
\def\chaptitlefont{\normalfont\Huge\bfseries}%
\setlength{\beforechapskip}{50pt}%
\setlength{\midchapskip}{20pt}%
\setlength{\afterchapskip}{40pt}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \begin{macro}{\@m@mschapter}
% This deals with the new optional argument for starred chapters.
% \begin{macrocode}
\newcommand{\@m@mschapter}[2][\@empty]{%
\@schapter{#2}%
\ifx \@empty#1
\def\f@rhdr{#2}%
\else% opt arg
\def\f@rhdr{#1}%
\setcounter{secnumdepth}{-10}%
\chaptermark{#1}%
\setcounter{secnumdepth}{\value{maxsecnumdepth}}%
\fi
\ifanappendix
\memappchapstarinfo{\f@rhdr}{#2}%
\else
\memchapstarinfo{\f@rhdr}{#2}%
\fi
\ifheadnameref\M@gettitle{\f@rhdr}\else\M@gettitle{#2}\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@schapter}
% \begin{macro}{\f@rbdy}
% \cs{@schapter}\marg{long} typesets the title of a
% \cs{chapter*}. It is easier than the \cs{@chapter} as there is no number
% to worry about.
% \changes{v0.3}{2001/07/09}{Changed \cs{@schapter} for article option}
% \changes{v1.2}{2002/07/27}{Major rewrite of \cs{@schapter}}
% \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@schapter}}
% \changes{v1.61803}{2008/01/30}{Changed \cs{@schapter} like
% \cs{@chapter} (mempatch v4.5)}
% \changes{v1.6180339g}{2009/07/13}{added \cs{m@mpn@new@chapfalse}
% otherwise both might end up true at the same time}
% \begin{macrocode}
\newcommand{\@schapter}[1]{%
\m@mpn@new@schaptrue%
\m@mpn@new@chapfalse%
\def\f@rbdy{#1}%
\ifartopt
\@makeschapterhead{#1}%
\else
\if@twocolumn
\@topnewpage[\@makeschapterhead{#1}]%
\else
\@makeschapterhead{#1}%
\fi
\fi
\@afterheading}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@makeschapterhead}
% This \emph{really} typesets a \cs{chapter*}, and is similar to \cs{@makechapterhead}.
% \changes{v1.3}{2002/10/10}{Added \cs{printchapternonum} to
% \cs{@makeschapterhead}}
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{@makeschapterhead}}
% \changes{v3.6j}{2011/0301}{Made sure the \cs{parskip} is zero inside
% the title area, otherwise placement might come out wrong}
% \begin{macrocode}
\def\@makeschapterhead#1{%
\chapterheadstart
{%
\parskip \z@%
\parindent \z@ \memRTLraggedright \normalfont
\printchapternonum
\interlinepenalty\@M
\printchaptertitle{#1}%
\afterchaptertitle}%
}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Chapter styling}
%
%
% \begin{macro}{\makechapterstyle}
% \begin{macro}{\chapterstyle}
% \cs{chapterstyle}\marg{style} is like \cs{pagestyle}, except it's for
% chapters.
%
% \cs{makechapterstyle}\marg{style}\marg{text} creates
% or overrides the \meta{style} chapter style defining it as \meta{text}
% So, \verb?\makechapterstyle{fred}{code}? specifies that the chapter style
% \pstyle{fred}
% is defined as the macro \verb?\chs@fred{code}?,
% and \verb?\chapterstyle{fred}? calls the macro \cs{chs@fred}.
% \begin{macrocode}
\newcommand{\makechapterstyle}[2]{\@namedef{chs@#1}{\@chs@def@ult #2}}
\newcommand{\chapterstyle}[1]{\@nameuse{chs@#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Set the \pstyle{default} chapter style.
% \changes{v0.2}{2001/06/03}{Added code when making the default chapterstyle}
% \changes{v1.61803}{2008/01/30}{Simplified specification of the default chapterstyle}
% \begin{macrocode}
\makechapterstyle{default}{}%
%% \setlength{\beforechapskip}{50pt}
%% \def\chapterheadstart{\vspace*{\beforechapskip}}
%% \def\chapnamefont{\normalfont\huge\bfseries}
%% \def\printchaptername{\chapnamefont \@chapapp}
%% \def\chapternamenum{\space}
%% \def\chapnumfont{\normalfont\huge\bfseries}
%% \def\printchapternum{\chapnumfont \thechapter}
%% \setlength{\midchapskip}{20pt}
%% \def\afterchapternum{\par\nobreak\vskip \midchapskip}
%% \def\printchapternonum{}
%% \def\chaptitlefont{\normalfont\Huge\bfseries}
%% \def\printchaptertitle##1{\chaptitlefont ##1}
%% \setlength{\afterchapskip}{40pt}
%% \def\afterchaptertitle{\par\nobreak\vskip \afterchapskip}
\chapterstyle{default}
% \end{macrocode}
%
% \begin{macro}{\chs@section}
% The \pstyle{section} chapter style. It prints the heading as though it
% were a section.
% \changes{v1.0a}{2002/01/18}{Made \cs{chapnumfont} change in section
% chapterstyle explicit}
% \begin{macrocode}
\makechapterstyle{section}{%
\chapterstyle{default}
\renewcommand{\printchaptername}{}
\renewcommand{\chapternamenum}{}
\renewcommand{\chapnumfont}{\normalfont\Huge\bfseries}
\renewcommand{\printchapternum}{\chapnumfont \thechapter\space}
\renewcommand{\afterchapternum}{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@article}
% The \pstyle{article} chapter style. It prints the heading as though it
% were a section in an \Lpack{article} class document.
% \changes{v0.3}{2001/07/09}{Added article chapterstyle}
% \changes{v1.0a}{2002/01/18}{Made \cs{chapnumfont} change in article chapterstyle explicit}
% \changes{v1.4}{2003/11/22}{Replaced \cs{space} by \cs{quad} in article chapterstyle
% (from patch v1.7)}
% \begin{macrocode}
\makechapterstyle{article}{%
\chapterstyle{default}
\setlength{\beforechapskip}{3.5ex \@plus 1ex \@minus .2ex}
\renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}
\setlength{\afterchapskip}{2.3ex \@plus .2ex}
\renewcommand{\printchaptername}{}
\renewcommand{\chapternamenum}{}
\renewcommand{\chaptitlefont}{\normalfont\Large\bfseries}
\renewcommand{\chapnumfont}{\chaptitlefont}
\renewcommand{\printchapternum}{\chapnumfont \thechapter\quad}
\renewcommand{\afterchapternum}{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@reparticle}
% The \pstyle{reparticle} chapter style. It replicates the appearance
% of a \cs{section} in an \Lpack{article} class document.
% \changes{v1.61803}{2008/01/30}{Added reparticle chapterstyle (mempatch v4.3)}
% \begin{macrocode}
\makechapterstyle{reparticle}{%
\chapterstyle{default}
\setlength{\beforechapskip}{3.5ex \@plus 1ex \@minus .2ex}
\renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}
\setlength{\afterchapskip}{2.3ex \@plus .2ex}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chaptitlefont}{\normalfont\Large\bfseries}
\renewcommand*{\chapnumfont}{\chaptitlefont}
\renewcommand*{\printchapternum}{\@hangfrom{\chapnumfont \thechapter\quad}}%
\renewcommand*{\afterchapternum}{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\reparticle}
% Call this to get division heads to replicate the \Lopt{article} class.
% For example: \\
% \verb?\ifartopt \reparticle \fi? \\
% The \cs{chapter} commands must still be used, though.
% \changes{v1.61803}{2008/01/30}{Added \cs{reparticle} (mempatch v4.3)}
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{reparticle}}
% \begin{macrocode}
\newcommand*{\reparticle}{%
\chapterstyle{reparticle}
\setsecheadstyle{\normalfont\large\bfseries\memRTLraggedright}%
\setsubsecheadstyle{\normalfont\bfseries\memRTLraggedright}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@hangnum}
% The \pstyle{hangnum} style puts the chapter number in the margin.
% \begin{macrocode}
\makechapterstyle{hangnum}{%
\chapterstyle{default}
\renewcommand*{\chapnumfont}{\chaptitlefont}
\settowidth{\chapindent}{\chapnumfont 999}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{%
\noindent\llap{\makebox[\chapindent][l]{\chapnumfont \thechapter}}}
\renewcommand*{\afterchapternum}{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chapindent}
% \begin{macro}{\chs@companion}
% The \pstyle{companion} style is like that in the \textit{\LaTeX{} Companion}
% series. It requires the \cs{chapindent} length. The user needs
% to be careful to have a wide enough spine margin on verso pages
% if the title may appear on a verso page.
% \changes{v0.31}{2001/07/24}{Changed adjustwidth* to adjustwidth in companion chapterstyle}
% \begin{macrocode}
\newlength{\chapindent}
\makechapterstyle{companion}{%
\chapterstyle{default}
\renewcommand*{\chapnamefont}{\normalfont\LARGE\scshape}
\renewcommand*{\printchaptername}{\raggedleft\chapnamefont \@chapapp}
\renewcommand*{\chapnumfont}{\normalfont\Huge}
\setlength{\chapindent}{\marginparsep}
\addtolength{\chapindent}{\marginparwidth}
\renewcommand*{\printchaptertitle}[1]{%
\begin{adjustwidth}{}{-\chapindent}
\raggedleft \chaptitlefont ##1\par\nobreak
\end{adjustwidth}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\chs@demo}
% An exotic chapter style for demonstration purposes.
% \begin{macrocode}
\makechapterstyle{demo}{%
\chapterstyle{default}
\renewcommand*{\printchaptername}{\centering}
\renewcommand*{\printchapternum}{\chapnumfont \numtoName{\c@chapter}}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\sffamily}
\renewcommand*{\printchaptertitle}[1]{%
\hrule\vskip\onelineskip \raggedleft \chaptitlefont ##1}
\renewcommand*{\afterchaptertitle}%
{\vskip\onelineskip \hrule\vskip \afterchapskip}}
% \end{macrocode}
% \end{macro}
%
% \changes{v1.61803}{2008/01/30}{Added chapterstyles: bianchi, bringhurst,
% brotherton, chappel, culver, dash, demo2, ell, Ger,
% lyhne, madsen, pedersen, southall, thatcher, veelo,
% verville, demo3 (mempatch v4.6)}
% \begin{macro}{\chs@bianchi}
% Posted to CTT on 2003/12/09, \textit{New chapter style: chapter vs chapter*}
% by Stefano Bianchi.
% \begin{macrocode}
\makechapterstyle{bianchi}{%
\chapterstyle{default}
\renewcommand*{\chapnamefont}{\normalfont\Large\sffamily\itshape}
\renewcommand*{\chapnumfont}{\normalfont\huge}
\renewcommand*{\printchaptername}{%
\chapnamefont\centering\@chapapp}
\renewcommand*{\printchapternum}{\chapnumfont \textit{\thechapter}}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\sffamily}
\renewcommand*{\printchaptertitle}[1]{%
\hrule\vskip\onelineskip \centering \chaptitlefont\textbf{##1}\par}
\renewcommand*{\afterchaptertitle}{\vskip\onelineskip \hrule\vskip
\afterchapskip}
\renewcommand*{\printchapternonum}{%
\vphantom{\chapnumfont \textit{9}}\afterchapternum}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@bringhurst}
% My bringhurst style.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to bringhurst chapterstyle}
% \changes{c3.6k}{2012/09/18}{\cs{MakeLowercase} $\to$ \cs{MakeTextLowercase}}
% \begin{macrocode}
\makechapterstyle{bringhurst}{%
\chapterstyle{default}
\renewcommand*{\chapterheadstart}{}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{}
\renewcommand*{\afterchapternum}{}
\renewcommand*{\printchaptertitle}[1]{%
\memRTLraggedright\Large\scshape\MakeTextLowercase{##1}}
\renewcommand*{\afterchaptertitle}{%
\vskip\onelineskip \hrule\vskip\onelineskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@brotherton}
% An extremely simple chapterstyle created by William Adams for Mike
% Brotherton's science fiction novel \textit{Star Dragon}, posted to CTT
% 2006/12/09, \textit{An example of a novel?}.
% \begin{macrocode}
\makechapterstyle{brotherton}{%
\chapterstyle{default}
\renewcommand*{\printchapternum}{\chapnumfont
\ifanappendix \thechapter \else \numtoName{\c@chapter}\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@chappell}
% My Chappell style
% \begin{macrocode}
\makechapterstyle{chappell}{%
\chapterstyle{default}
\setlength{\beforechapskip}{0pt}
\renewcommand*{\chapnamefont}{\large\centering}
\renewcommand*{\chapnumfont}{\large}
\renewcommand*{\printchapternonum}{%
\vphantom{\printchaptername \chapnumfont 1}
\afterchapternum
\vskip \onelineskip \vskip -\topskip}
\renewcommand*{\chaptitlefont}{\Large\itshape}
\renewcommand*{\printchaptertitle}[1]{%
\hrule\vskip\onelineskip \centering\chaptitlefont ##1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@culver}
% By me in an answer to Christopher Culver on CTT,
% \textit{"Biblical" formatting, how?} on 2004/03/29,where I called it
% the `biblical' style.
% \begin{macrocode}
\makechapterstyle{culver}{%
\chapterstyle{default}
\chapterstyle{article}%
\renewcommand*{\thechapter}{\Roman{chapter}}
\renewcommand*{\printchapternum}{% center number/title
\centering\chapnumfont \thechapter\space\space}%
\renewcommand*{\printchapternonum}{\centering}
\renewcommand*{\clearforchapter}{}% no new page
\aliaspagestyle{chapter}{headings}}% no special pagestyle
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@dash}
% A very simple style of mine but I couldn't think of a good name for it.
% \begin{macrocode}
\makechapterstyle{dash}{%
\chapterstyle{default}
\setlength{\beforechapskip}{5\onelineskip}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chapnumfont}{\normalfont\large}
\settoheight{\midchapskip}{\chapnumfont 1}
\renewcommand*{\printchapternum}{\centering \chapnumfont
\rule[0.5\midchapskip]{1em}{0.4pt} \thechapter\
\rule[0.5\midchapskip]{1em}{0.4pt}}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 0.5\onelineskip}
\renewcommand*{\printchapternonum}{\centering
\vphantom{\chapnumfont 1}\afterchapternum}
\renewcommand*{\chaptitlefont}{\normalfont\Large}
\renewcommand*{\printchaptertitle}[1]{\centering \chaptitlefont ##1}
\setlength{\afterchapskip}{2.5\onelineskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@demo2}
% My second version of the demo chapterstyle.
% \begin{macrocode}
\makechapterstyle{demo2}{%
\chapterstyle{default}
\renewcommand*{\printchaptername}{\centering}
\renewcommand*{\printchapternum}{\chapnumfont
\ifanappendix \thechapter \else \numtoName{\c@chapter}\fi}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\sffamily}
\renewcommand*{\printchaptertitle}[1]{%
\hrule\vskip\onelineskip \raggedleft \chaptitlefont ##1}
\renewcommand*{\afterchaptertitle}{%
\vskip\onelineskip \hrule\vskip \afterchapskip}
\setlength{\beforechapskip}{3\baselineskip}
\renewcommand*{\printchapternonum}{%
\vphantom{\chapnumfont One}
\afterchapternum%
\vskip\topskip}
\setlength{\beforechapskip}{2\onelineskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@demo3}
% My third version of the demo chapterstyle.
% \begin{macrocode}
\makechapterstyle{demo3}{%
\chapterstyle{default}
\renewcommand*{\printchaptername}{\centering}
\renewcommand*{\chapnumfont}{\normalfont\HUGE\itshape}
\renewcommand*{\printchapternum}{\chapnumfont
\ifanappendix \thechapter \else \numtoName{\c@chapter}\fi}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\sffamily}
\renewcommand*{\printchaptertitle}[1]{%
\hrule\vskip\onelineskip \raggedleft \chaptitlefont ##1}
\renewcommand*{\afterchaptertitle}{%
\vskip\onelineskip \hrule\vskip \afterchapskip}
\setlength{\beforechapskip}{0pt}
\setlength{\midchapskip}{2\onelineskip}
\setlength{\afterchapskip}{2\onelineskip}
\renewcommand*{\printchapternonum}{%
\vphantom{\chapnumfont One}
\afterchapternum%
\vskip\topskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@ell}
% Another of my styles which I'll probably use for my next book.
%
% James Dietrich\footnote{\texttt{jdietrch@fastmail.fm}} (2014/05/29)
% reports that the line and number part of the \textsf{ell} chapter
% style does not align correctly if the page is excessively
% stretched. The style is reimplemented using \Lenv{tabularx} instead.
% \changes{v3.7d}{2014/11/05}{Reimplemeted the ell chapter style}
% \begin{macro}{\chs@ell@helper}
% For code reuse (the slightly strange values come from trial and
% error to match the original look):
% \begin{macrocode}
\newcommand\chs@ell@helper[1]{%
\par%
\begin{adjustwidth}{}{-\chapindent}
\begin{tabularx}{\linewidth}{>{\raggedleft\arraybackslash}X|}%|emacs
\leavevmode\chapnumfont #1\vphantom{1}%
\hspace*{3.6pt}%
\rule[-13.5pt]{0pt}{14.8mm}%
\\%
\hline%
\end{tabularx}%
\end{adjustwidth}%
\par%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\makechapterstyle{ell}{%
\chapterstyle{default}
\renewcommand*{\chapnumfont}{\normalfont\HUGE\sffamily}
\renewcommand*{\chaptitlefont}{\normalfont\huge\sffamily}
\settowidth{\chapindent}{\chapnumfont 111}
% \renewcommand*{\chapterheadstart}{\begingroup
% \vspace*{\beforechapskip}%
% \begin{adjustwidth}{}{-\chapindent}%
% \hrulefill
% \smash{\rule{0.4pt}{15mm}}
% \end{adjustwidth}\endgroup}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{%
% \begin{adjustwidth}{}{-\chapindent}
% \hfill
% \raisebox{10mm}[0pt][0pt]{\chapnumfont \thechapter}%
% \hspace*{1em}
% \end{adjustwidth}\vspace*{-3.0\onelineskip}
\chs@ell@helper{\thechapter}%
}
\renewcommand\printchapternonum{%
\chs@ell@helper{}\afterchapternum}
\renewcommand*{\printchaptertitle}[1]{%
%\vskip\onelineskip
\raggedleft {\chaptitlefont ##1}\par\nobreak}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@ger}
% Posted to CTT on 2002/04/12 \textit{Fancy Headings, Chapter Headings} by Gerardo Garcia.
% \begin{macrocode}
\makechapterstyle{ger}{%
\chapterstyle{default}
\renewcommand*{\chapterheadstart}{\vspace*{\beforechapskip}
\mbox{}\\\mbox{}\rule[0pt]{\textwidth}{0.4pt}\par}
\setlength{\midchapskip}{20pt}
\renewcommand*{\printchaptertitle}[1]{\chaptitlefont ##1
\\\mbox{}\rule[5pt]{\textwidth}{0.4pt}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@lyhne}
% Posted to CTT 2006/02/09 \textit{Glossary}, by Anders Lyhne.
% It requires the \Lpack{graphicx} package. I have modified it to remove the
% new length and adjusted the unnumbered appearance.
% \begin{macrocode}
\makechapterstyle{lyhne}{% needs graphicx package
\chapterstyle{default}
\setlength{\beforechapskip}{1.5cm}
\setlength{\afterchapskip}{1cm}
\setlength{\midchapskip}{2cm}
\renewcommand*{\chapnamefont}{\normalfont\normalsize\scshape\raggedleft}
\renewcommand*{\chaptitlefont}{\normalfont\normalsize\bfseries\sffamily\raggedleft}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{\makebox[0pt][l]{\hspace{0.2em}%
\resizebox{!}{2ex}{\chapnamefont\bfseries\sffamily\thechapter}}}
\renewcommand*{\afterchapternum}{\par\hspace{1.5cm}\hrule\vspace{0.2cm}}
\renewcommand*{\printchapternonum}{\vphantom{\chapnamefont 1}\afterchapternum}
\renewcommand*{\afterchaptertitle}{\vskip 0.2cm
\hrule\vskip\afterchapskip}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\chs@madsen}
% Posted to CTT on 2003/12/09, \textit{New chapter style: chapter vs chapter*}
% by Lars Madsen.
% This requires the \Lpack{graphicx} package,
% \changes{v1.61803398c}{2009/11/15}{Updated to provide a better
% unnumbered look}
% \changes{v3.6d}{2010/05/13}{the unnumbered version may be executed
% in a context where \cs{thechapter} is not weldefined, replaced with
% a 1}
% \begin{macrocode}
\makechapterstyle{madsen}{% requires graphicx package
\chapterstyle{default}
\renewcommand*{\chapnamefont}{%
\normalfont\Large\scshape\raggedleft}
\renewcommand*{\chaptitlefont}{%
\normalfont\Huge\bfseries\sffamily\raggedleft}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{%
\makebox[0pt][l]{\hspace{0.4em}%
\resizebox{!}{4ex}{%
\chapnamefont\bfseries\sffamily\thechapter}%
}%
}%
\renewcommand*{\printchapternonum}{%
\chapnamefont \phantom{\printchaptername \chapternamenum%
\makebox[0pt][l]{\hspace{0.4em}%
\resizebox{!}{4ex}{%
\chapnamefont\bfseries\sffamily 1}%
}%
}%
\afterchapternum %
}%
\renewcommand*{\afterchapternum}{%
\par\hspace{1.5cm}\hrule\vskip\midchapskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\colorchapnum}
% \begin{macro}{\colorchaptitle}
% \begin{macro}{\chs@pedersen}
% Posted to CTT 2006/01/31, \textit{Chapter style}, by Troels Pedersen.
% It requires the \Lpack{graphicx} package and possibly the \Lpack{color}
% package. I have used a \cs{sidebar} instead of the original \cs{marginpar},
% and eliminated a new length. The original color specification, the same for
% the title and nunmber, can now be set via \cs{colorchapnum} and
% \cs{colorchaptitle}.
% \begin{macrocode}
\newcommand*{\colorchapnum}{}
\newcommand*{\colorchaptitle}{}
\makechapterstyle{pedersen}{%
\chapterstyle{default}
\setlength{\beforechapskip}{-20pt}
\setlength{\afterchapskip}{10pt}
\renewcommand*{\chapnamefont}{\normalfont\LARGE\itshape}
\renewcommand*{\chapnumfont}{\normalfont\HUGE\itshape\colorchapnum}
\renewcommand*{\chaptitlefont}{\normalfont\huge\itshape\colorchaptitle}
\renewcommand*{\afterchapternum}{}
\renewcommand*{\printchaptername}{}
\setlength{\midchapskip}{20mm}% was \numberheight
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{%
\sidebar{\raisebox{0pt}[0pt][0pt]{\makebox[0pt][l]{%
\resizebox{!}{\midchapskip}{\chapnumfont\thechapter}}}}}
\renewcommand*{\printchaptertitle}[1]{\chaptitlefont ##1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\chs@southall}
% Style provided by Thomas Dye. I have modified the original to eliminate
% the use of new lengths.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to southall chapterstyle}
% \begin{macrocode}
%% Thomas Dye's southall chapter style
\makechapterstyle{southall}{%
\chapterstyle{default}
\setlength{\afterchapskip}{5\baselineskip}
\setlength{\beforechapskip}{36pt}% \headindent
\setlength{\midchapskip}{\textwidth}% \rightblock
\addtolength{\midchapskip}{-\beforechapskip}
\renewcommand*{\chapterheadstart}{\vspace*{2\baselineskip}}
\renewcommand*{\chaptitlefont}{\huge\rmfamily\memRTLraggedright}
\renewcommand*{\chapnumfont}{\chaptitlefont}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\afterchapternum}{}
\renewcommand*{\printchapternum}{%
\begin{minipage}[t][\baselineskip][b]{\beforechapskip}
{\vspace{0pt}\chapnumfont%%%\figureversion{lining}
\thechapter}
\end{minipage}}
\renewcommand*{\printchaptertitle}[1]{%
\hfill\begin{minipage}[t]{\midchapskip}
{\vspace{0pt}\chaptitlefont ##1\par}\end{minipage}}
\renewcommand*{\afterchaptertitle}{%
\par\vspace{\baselineskip}%
\hrulefill \par\nobreak\noindent \vskip \afterchapskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@thatcher}
% Original posted to CTT on 2006/01/18 by Scott Thatcher,
% \textit{memoir: chapter headings capitalize math symbols}. I have modified
% it to cater for multiline titles, appendices, and unnumbered
% chapters.
% \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
% \changes{c3.6k}{2012/09/18}{\cs{MakeLowercase} $\to$ \cs{MakeTextLowercase}}
% \begin{macrocode}
\makechapterstyle{thatcher}{%
\chapterstyle{default}
\renewcommand*{\chapterheadstart}{}
\renewcommand*{\printchaptername}{%
\centerline{\chapnumfont{\@chapapp\ \thechapter}}}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chapnumfont}{\normalfont\scshape\MakeTextLowercase}
\renewcommand*{\printchapternum}{}
\renewcommand*{\afterchapternum}{%
\par\centerline{\parbox{0.5in}{\hrulefill}}\par}
\renewcommand*{\printchapternonum}{%
\vphantom{\chapnumfont \@chapapp 1}\par
\parbox{0.5in}{}\par}
\renewcommand*{\chaptitlefont}{\normalfont\large}
\renewcommand*{\printchaptertitle}[1]{%
\centering \chaptitlefont\MakeTextUppercase{##1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@veelo}
% This, from Baastian Veelo, has been noted in the documentation for
% quite a time.
% I have modified the original to eliminate the need for extra lengths.
% It well suits trimmed documents.
% We are scaling the chapter number, which most DVI viewers
% will not display accurately. It requires the graphicx package.
% \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
% \begin{macrocode}
\makechapterstyle{veelo}{%
% \chapterstyle{default}
\setlength{\afterchapskip}{40pt}
\renewcommand*{\chapterheadstart}{\vspace*{40pt}}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 25pt}
\renewcommand*{\chapnamefont}{\normalfont\LARGE\flushright}
\renewcommand*{\chapnumfont}{\normalfont\HUGE}
\renewcommand*{\chaptitlefont}{\normalfont\HUGE\bfseries\flushright}
\renewcommand*{\printchaptername}{%
\chapnamefont\MakeTextUppercase{\@chapapp}}
\renewcommand*{\chapternamenum}{}
% \setlength{\numberheight}{18mm}
% \setlength{\barlength}{\paperwidth}
% \addtolength{\barlength}{-\textwidth}
% \addtolength{\barlength}{-\spinemargin}
\setlength{\beforechapskip}{18mm}% \numberheight
\setlength{\midchapskip}{\paperwidth}% \barlength
\addtolength{\midchapskip}{-\textwidth}
\addtolength{\midchapskip}{-\spinemargin}
\renewcommand*{\printchapternum}{%
\makebox[0pt][l]{%
\hspace{.8em}%
\resizebox{!}{\beforechapskip}{\chapnumfont \thechapter}%
\hspace{.8em}%
\rule{\midchapskip}{\beforechapskip}%
}%
}%
\makeoddfoot{plain}{}{}{\thepage}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@verville}
% I posted the original to CTT on 2005/01/18, \textit{Headers and special
% formatting of sections}, in answer to a question by
% Guy Verville. This version caters for unnumbered chapters.
% \begin{macrocode}
\makechapterstyle{verville}{%
% \chapterstyle{default}
\setlength{\beforechapskip}{0pt}
\renewcommand*{\printchaptername}{}
\renewcommand*{\printchapternum}{%
\hrule \vskip 0.5\onelineskip
\Huge \centering \thechapter.\ }
\renewcommand*{\printchapternonum}{%
\hrule \vskip 0.5\onelineskip
\Huge \centering}
\renewcommand*{\afterchapternum}{}
\setlength{\midchapskip}{0pt}
\renewcommand*{\printchaptertitle}[1]{%
##1 \par
\vskip 0.5\onelineskip
\hrule}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@crosshead}
% A centered chapterstyle (from Bringhurst)
% \changes{v1.61803}{2008/01/30}{Added chapterstyles: crosshead, dowding,
% komalike, ntglike, tandh, and wilsondob}
% \begin{macrocode}
\makechapterstyle{crosshead}{%
\setlength{\beforechapskip}{2\onelineskip}%
\renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}%
\setlength{\afterchapskip}{2\onelineskip \@plus .2\onelineskip
\@minus 0.2\onelineskip}%
\renewcommand*{\printchaptername}{}%
\renewcommand*{\chapternamenum}{}%
\renewcommand*{\chapnumfont}{\normalfont\LARGE\bfseries}%
\renewcommand*{\chaptitlefont}{\chapnumfont}%
\renewcommand*{\printchapternum}{%
\centering\chapnumfont \thechapter\quad}%
\renewcommand{\afterchapternum}{}%
\renewcommand*{\printchapternonum}{\centering}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@dowding}
% A centered chapterstyle (from Dowding's \textit{Finer Points})
% \begin{macrocode}
\makechapterstyle{dowding}{%
\setlength{\beforechapskip}{2\onelineskip}%
\setlength{\afterchapskip}{1.5\onelineskip \@plus .1\onelineskip
\@minus 0.167\onelineskip}%
\renewcommand*{\chapnamefont}{\normalfont}%
\renewcommand*{\chapnumfont}{\chapnamefont}%
\renewcommand*{\printchapternum}{\centering\chapnumfont \ifanappendix \thechapter
\else \numtoName{\c@chapter}\fi}%
\renewcommand*{\chaptitlefont}{\normalfont\itshape\huge\centering}%
\renewcommand*{\printchapternonum}{%
\vphantom{\printchaptername}\vskip\midchapskip}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@komalike}
% A chapterstyle approximating the KOMA script style (\texttt{scrbook.cls})
% \begin{macrocode}
\makechapterstyle{komalike}{%
\setlength{\beforechapskip}{2\onelineskip}%
\setlength{\afterchapskip}{1.5\onelineskip \@plus .1\onelineskip
\@minus 0.167\onelineskip}%
\renewcommand*{\printchaptername}{}%
\renewcommand*{\chapternamenum}{}%
\renewcommand*{\chapnumfont}{\normalfont\LARGE\sffamily\bfseries}%
\renewcommand*{\printchapternum}{\chapnumfont \thechapter\space}%
\renewcommand*{\afterchapternum}{}%
\renewcommand*{\chaptitlefont}{\normalfont\LARGE\sffamily\bfseries}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@ntglike}
% A chapterstyle approximating the NTG style (\texttt{boek.cls})
% \begin{macrocode}
\makechapterstyle{ntglike}{%
\setlength{\beforechapskip}{50pt \@plus 20pt}%
\renewcommand*{\chapnamefont}{\normalfont\Large\bfseries}%
\renewcommand*{\chapnumfont}{\normalfont\Large\bfseries}%
\renewcommand*{\chaptitlefont}{\normalfont\Large\bfseries}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@tandh}
% A chapterstyle based on Thames \& Hudson \textit{Typography}.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to tandh chapterstyle}
% \begin{macrocode}
\makechapterstyle{tandh}{%
\setlength{\beforechapskip}{1\onelineskip}%
\setlength{\afterchapskip}{2\onelineskip \@plus .1\onelineskip
\@minus 0.167\onelineskip}%
\renewcommand*{\printchaptername}{}%
\renewcommand*{\chapternamenum}{}%
\renewcommand*{\chapnumfont}{\normalfont\huge\bfseries}%
\renewcommand*{\printchapternum}{\chapnumfont \thechapter\quad}%
\renewcommand*{\afterchapternum}{}%
\renewcommand*{\chaptitlefont}{\chapnumfont\memRTLraggedright}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chs@wilsondob}
% A chapterstyle based on Adrian Wilson's \textit{Design of books}.
% \begin{macrocode}
\makechapterstyle{wilsondob}{%
\setlength{\beforechapskip}{2\onelineskip}%
\setlength{\afterchapskip}{4\onelineskip \@plus .1\onelineskip
\@minus 0.167\onelineskip}%
\renewcommand*{\printchaptername}{}%
\renewcommand*{\chapternamenum}{}%
\renewcommand*{\chapnumfont}{\normalfont\Huge\itshape}%
\renewcommand*{\printchapternum}{\raggedleft\chapnumfont \thechapter\quad}%
\renewcommand*{\afterchapternum}{}%
\renewcommand*{\chaptitlefont}{\chapnumfont}%
\renewcommand*{\printchapternonum}{\raggedleft}}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Lower level headings}
%
% These commands all make use of \cs{@startsection}. However,
% for the purposes of the class the kernel version needs modification
% to support:
% \begin{itemize}
% \item make short pages (where a section heading is moved to the top
% of the next page) ragged bottom;
% \item provide headings with two optional arguments.
% \end{itemize}
%
%
% We will tweak \cs{@startsection} so that a short page (where a section
% heading is moved from the bottom of the page to the top of the next)
% can be set \cs{raggedbottom}.
%
% \begin{macro}{\ifraggedbottomsection}
% \begin{macro}{\raggedbottomsectiontrue}
% \begin{macro}{\raggedbottomsectionfalse}
% \begin{macro}{\raggedbottomsection}
% \begin{macro}{\normalbottomsection}
% \begin{macro}{\bottomsectionpenalty}
% \cs{raggedbottomsectiontrue} for ragged short pages.
% \changes{v1.3}{2002/11/14}{Added \cs{ifraggedbottomsection}}
% \changes{v1.61803}{2008/01/30}{Added \cs{raggedbottomsection} and
% \cs{normalbottomsection}}
% \changes{v3.6k}{2012/07/22}{Made the \cs{raggedbottomsection}
% penalty configurable}
% \begin{macrocode}
\newif\ifraggedbottomsection
\raggedbottomsectionfalse
\newcommand*{\raggedbottomsection}{\raggedbottomsectiontrue}
\newcommand*{\normalbottomsection}{\raggedbottomsectionfalse}
\newcommand*{\bottomsectionpenalty}{\z@}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bottomsectionskip}
% Decreasing this length increases short page bottom flushness.
% \changes{v1.3}{2002/11/14}{Added \cs{bottomsectionskip}}
% \begin{macrocode}
\newlength{\bottomsectionskip}
\setlength{\bottomsectionskip}{10mm}
% \end{macrocode}
% \end{macro}
%
% We will add a second optional argument for \cs{section}, etc.
% See the \ctt{} thread \textit{`Long headers'} 15 Jan 2003.
%
% The kernel \cs{@dblarg} is used in situations where the default
% value for an optional argument is the same as the required argument.
% Schematically, \\
% \verb?\@dblarg -> Main, Main? \\
% The macros \cs{@trplargomm} and \cs{@trplargoom} are extensions to this
% idea for two optional arguments.
%
% \begin{macro}{\@trplargomm}
% \begin{macro}{\@xtrplargomm}
% \begin{macro}{\@xxtrplarg}
% \verb?\@trplargomm -> Opt, Main, Main?
% \begin{macrocode}
\newcommand{\@trplargomm}[1]{%
\@ifnextchar[{\@xtrplargomm{#1}}%
{\@xxtrplarg{#1}}}
\long\def\@xtrplargomm#1[#2]{\@dblarg{#1[#2]}}
\newcommand{\@xxtrplarg}[2]{#1[{#2}][{#2}]{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@trplargoom}
% \begin{macro}{\@xtrplargoom}
% \verb?\@trplargoom -> Opt, Opt, Main?
% \begin{macrocode}
\newcommand{\@trplargoom}[1]{%
\@ifnextchar[{\@xtrplargoom{#1}}%
{\@xxtrplarg{#1}}}
\long\def\@xtrplargoom#1[#2]{%
\@ifnextchar[{#1[{#2}]}%
{#1[{#2}][{#2}]}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memsecinfo}
% \begin{macro}{\memsecstarinfo}
% \verb?\memsecinfo{secname}{\thenum}{toc}{head}{title}? \\
% \verb?\memsecstarinfo{secname}{title}? \\
% \begin{macrocode}
\newcommand{\memsecinfo}[5]{}
\newcommand{\memsecstarinfo}[2]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@startsection}
% \begin{macro}{\m@msecn@me}
% Change kernel \cs{@startsection} to: \\
% \begin{itemize}
% \item Make short pages raggedbottom. This is based on the thread
% \textit{Can \cs{flushbottom} and \cs{section} be made to live together?}
% on \ctt{} in September 2002.
% \changes{v1.3}{2002/11/14}{Modified \cs{@startsection} for raggedbottoming}
% \item add an extra optional argument.
% \changes{v1.4}{2003/11/22}{Added extra optional arg to \cs{@startsection}
% (from patch v1.4)}
% \item make sure it is not effected by a non-zero \cs{parskip}
% \changes{v3.6j}{2011/03/02}{added the above feature}
% \end{itemize}
% The original is in \file{ltsect.dtx}. \\
% \cs{@startsection}\marg{name}\marg{level}\marg{indent} \\
% \hspace*{1.5in} \marg{beforeskip}\marg{afterskip}\marg{style}
% \begin{macrocode}
\renewcommand{\@startsection}[6]{%
% \end{macrocode}
% \changes{v3.6h}{2011/02/07}{Added float block hook}
% \begin{macrocode}
\@nameuse{#1block}%
% \end{macrocode}
% Do raggedbottom stuff.
% \changes{v3.6k}{2012/07/22}{Made the \cs{raggedbottomsection}
% penalty configurable}
% \begin{macrocode}
\ifraggedbottomsection\if@nobreak\else
\vskip\z@\@plus\bottomsectionskip
\penalty\bottomsectionpenalty
\vskip\z@\@plus -\bottomsectionskip
\fi\fi
% \end{macrocode}
% Save the section name.
% \begin{macrocode}
\def\m@msecn@me{#1}%
% \end{macrocode}
% The original code.
% \begin{macrocode}
\if@noskipsec \leavevmode \fi
\par
\@tempskipa #4\relax
\@afterindenttrue
\ifdim \@tempskipa <\z@
\@tempskipa -\@tempskipa \@afterindentfalse
\fi
\if@nobreak
\everypar{}%
\else
% \end{macrocode}
% Slight change such that the effect of \cs{parskip} is cancelled
% \changes{v3.6j}{2011/03/02}{Adding a negative \cs{parskip} seem to
% be able to remove the effect of a non-zero \cs{parskip}}
% \begin{macrocode}
\addpenalty\@secpenalty\addvspace\@tempskipa
\addvspace{-\parskip}% <--- added 2011/03/02
\fi
% \end{macrocode}
% For the extra optional argument, change the original \verb?\@dblarg{\@sect{...?
% below to \verb?\@trplargoom{\M@sect{...?.
% \begin{macrocode}
\@ifstar
{\@ssect{#3}{#4}{#5}{#6}}%
{\@trplargoom{\M@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{v3.6j}{2011/03/02}{Added the change of the kernel \cs{@xsect}}
% \begin{macro}{\@xsect}
% In order to fulfill removing the effect that a non-zero
% \cs{parskip} has on the sectional spacing, we also have to patch
% the kernel \cs{@xsect}. (The original is found in latex.ltx)
% \begin{macrocode}
\def\@xsect#1{%
\@tempskipa #1\relax
\ifdim \@tempskipa>\z@
\par \nobreak
\vskip \@tempskipa
\vskip-\parskip%<--- added 2011/03/02
\@afterheading
\else
\@nobreakfalse
\global\@noskipsectrue
\everypar{%
\if@noskipsec
\global\@noskipsecfalse
{\setbox\z@\lastbox}%
\clubpenalty\@M
\begingroup \@svsechd \endgroup
\unskip
\@tempskipa #1\relax
\hskip -\@tempskipa
\else
\clubpenalty \@clubpenalty
\everypar{}%
\fi}%
\fi
\ignorespaces}
% \end{macrocode}
% \end{macro}
% %
% \begin{macro}{\M@sect}
% At least the \Lpack{hyperref} and \Lpack{nameref} packages, and
% possibly other packages, modify the kernel \cs{@sect} assuming 8 args.
% That's why I've called my version, which has 9 args, something
% else (i.e., \cs{M@sect}). This version also has the support
% for title referencing. \\
% \cs{M@sect}\marg{name}\marg{level}\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\\ \hspace*{0.5in} \oarg{toc}\oarg{head}\marg{title}
% \changes{v1.4}{2003/11/22}{Added \cs{M@sect}}
% \begin{macrocode}
\def\M@sect#1#2#3#4#5#6[#7][#8]#9{%
\ifheadnameref\M@gettitle{#8}\else\M@gettitle{#7}\fi
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\memsecinfo{#1}{}{#7}{#8}{#9}%
\else
\refstepcounter{#1}%
\protected@edef\@svsec{\@seccntformat{#1}\relax}%
\memsecinfo{#1}{\@nameuse{the#1}}{#7}{#8}{#9}%
\fi
\@tempskipa #5\relax
\ifdim \@tempskipa>\z@
\begingroup
#6{%
\@hangfrom{\hskip #3\relax\@svsec}%
\interlinepenalty \@M #9\@@par}%
\endgroup
\csname #1mark\endcsname{#8}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}%
\else
\def\@svsechd{%
#6{\hskip #3\relax
\@svsec #9}%
\csname #1mark\endcsname{#8}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}}%
\fi
\@xsect{#5}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@ssect}
% Add hook for name reference to \cs{section*} etc. \\
% \cs{@ssect}\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{title}
% \changes{v1.61803}{2008/01/30}{Used corrected number of arguments to
% \cs{memsecstarinfo} in \cs{@ssect} (Gabriel Guernik, mempatch v4.1)}
% \begin{macrocode}
\let\@mem@old@ssect\@ssect
\def\@ssect#1#2#3#4#5{%
\M@gettitle{#5}%
\memsecstarinfo{\m@msecn@me}{#5}%
\@mem@old@ssect{#1}{#2}{#3}{#4}{#5}}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\section}
% A normal heading with white space above and below and no indentation
% of the first paragraph.
% By default the heading is set in a \verb?\Large\bfseries? font.
% \begin{macrocode}
\newcommand{\section}{%
\sechook%
\@startsection{section}{1}% level 1
{\secindent}% heading indent
{\beforesecskip}% skip before the heading
{\aftersecskip}% skip after the heading
{\normalfont\secheadstyle}} % font
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sechook}
% \begin{macro}{\setsechook}
% \cs{sechook} is called at the start of a \cs{section} and
% \cs{setsechook}\marg{code} redefines it.
% \begin{macrocode}
\newcommand{\sechook}{}
\newcommand{\setsechook}[1]{\renewcommand{\sechook}{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\secindent}
% \begin{macro}{\beforesecskip}
% \begin{macro}{\aftersecskip}
% \begin{macro}{\secheadstyle}
% \begin{macro}{\setsecindent}
% \begin{macro}{\setbeforesecskip}
% \begin{macro}{\setaftersecskip}
% \begin{macro}{\setsecheadstyle}
% \cs{secindent} is the indentation of the section heading from the left margin,
% \cs{beforesecskip} and \cs{aftersecskip} specify the white space before
% and after the heading, and \cs{secheadstyle} specifies the heading style.
% These are set to the default values for the \Lpack{book} class,
% except that the heading will be \cs{raggedright}, thus preventing
% hyphenation. The
% \cs{set...} commands are for the user to change the values.
% \changes{v1.61803398}{@009/07/17}{Added bidi support to default secheadstyle}
% \begin{macrocode}
\newlength{\secindent}
\newcommand{\setsecindent}[1]{\setlength{\secindent}{#1}}
\setsecindent{\z@}
\newskip\beforesecskip
\newcommand{\setbeforesecskip}[1]{\setlength{\beforesecskip}{#1}}
\setbeforesecskip{-3.5ex \@plus -1ex \@minus -.2ex}
\newskip\aftersecskip
\newcommand{\setaftersecskip}[1]{\setlength{\aftersecskip}{#1}}
\setaftersecskip{2.3ex \@plus .2ex}
\newcommand{\secheadstyle}{}
\newcommand{\setsecheadstyle}[1]{\renewcommand{\secheadstyle}{#1}}
\setsecheadstyle{\Large\bfseries\memRTLraggedright}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\subsection}
% A normal heading with white space above and below and no indentation
% of the first paragraph.
% By default the heading is set in a \verb?\large\bfseries? font.
% \begin{macrocode}
\newcommand{\subsection}{%
\subsechook%
\@startsection{subsection}{2}% level 2
{\subsecindent}% heading indent
{\beforesubsecskip}% skip before the heading
{\aftersubsecskip}% skip after the heading
{\normalfont\subsecheadstyle}} % font
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subsechook}
% \begin{macro}{\setsubsechook}
% \cs{subsechook} is called at the start of a \cs{subsection} and
% \cs{setsubsechook}\marg{code} redefines it.
% \begin{macrocode}
\newcommand{\subsechook}{}
\newcommand{\setsubsechook}[1]{\renewcommand{\subsechook}{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\subsecindent}
% \begin{macro}{\beforesubsecskip}
% \begin{macro}{\aftersubsecskip}
% \begin{macro}{\subsecheadstyle}
% \begin{macro}{\setsubsecindent}
% \begin{macro}{\setbeforesubsecskip}
% \begin{macro}{\setaftersubsecskip}
% \begin{macro}{\setsubsecheadstyle}
% The macros for controlling \cs{subsection} headings.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to default subsec headstyle}
% \begin{macrocode}
\newlength{\subsecindent}
\newcommand{\setsubsecindent}[1]{\setlength{\subsecindent}{#1}}
\setsubsecindent{\z@}
\newskip\beforesubsecskip
\newcommand{\setbeforesubsecskip}[1]{\setlength{\beforesubsecskip}{#1}}
\setbeforesubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}
\newskip\aftersubsecskip
\newcommand{\setaftersubsecskip}[1]{\setlength{\aftersubsecskip}{#1}}
\setaftersubsecskip{1.5ex \@plus .2ex}
\newcommand{\subsecheadstyle}{}
\newcommand{\setsubsecheadstyle}[1]{\renewcommand{\subsecheadstyle}{#1}}
\setsubsecheadstyle{\large\bfseries\memRTLraggedright}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\subsubsection}
% A normal heading with white space above and below and no indentation
% of the first paragraph.
% By default the heading is set in a \verb?\normalsize\bfseries? font.
% \begin{macrocode}
\newcommand{\subsubsection}{%
\subsubsechook%
\@startsection{subsubsection}{3}% level 3
{\subsubsecindent}% heading indent
{\beforesubsubsecskip}% skip before the heading
{\aftersubsubsecskip}% skip after the heading
{\normalfont\subsubsecheadstyle}} % font
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subsubsechook}
% \begin{macro}{\setsubsubsechook}
% \cs{subsubsechook} is called at the start of a \cs{subsubsection} and
% \cs{setsubsubsechook}\marg{code} redefines it.
% \begin{macrocode}
\newcommand{\subsubsechook}{}
\newcommand{\setsubsubsechook}[1]{\renewcommand{\subsubsechook}{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\subsubsecindent}
% \begin{macro}{\beforesubsubsecskip}
% \begin{macro}{\aftersubsubsecskip}
% \begin{macro}{\subsubsecheadstyle}
% \begin{macro}{\setsubsubsecindent}
% \begin{macro}{\setbeforesubsubsecskip}
% \begin{macro}{\setaftersubsubsecskip}
% \begin{macro}{\setsubsubsecheadstyle}
% The macros for controlling \cs{subsubsection} headings.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to default subsubsec headstyle}
% \begin{macrocode}
\newlength{\subsubsecindent}
\newcommand{\setsubsubsecindent}[1]{%
\setlength{\subsubsecindent}{#1}}
\setsubsubsecindent{\z@}
\newskip\beforesubsubsecskip
\newcommand{\setbeforesubsubsecskip}[1]{%
\setlength{\beforesubsubsecskip}{#1}}
\setbeforesubsubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}
\newskip\aftersubsubsecskip
\newcommand{\setaftersubsubsecskip}[1]{%
\setlength{\aftersubsubsecskip}{#1}}
\setaftersubsubsecskip{1.5ex \@plus .2ex}
\newcommand{\subsubsecheadstyle}{}
\newcommand{\setsubsubsecheadstyle}[1]{%
\renewcommand{\subsubsecheadstyle}{#1}}
\setsubsubsecheadstyle{\normalsize\bfseries\memRTLraggedright}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \begin{macro}{\paragraph}
% A runin heading with white space above and to the right of the heading.
% By default the heading is set in a \verb?\normalsize\bfseries? font.
% \begin{macrocode}
\newcommand{\paragraph}{%
\parahook%
\@startsection{paragraph}{4}% level 4
{\paraindent}% heading indent
{\beforeparaskip}% skip before the heading
{\afterparaskip}% skip after the heading
{\normalfont\paraheadstyle}} % font
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\parahook}
% \begin{macro}{\setparahook}
% \cs{parahook} is called at the start of a \cs{paragraph} and
% \cs{setparahook}\marg{code} redefines it.
% \begin{macrocode}
\newcommand{\parahook}{}
\newcommand{\setparahook}[1]{\renewcommand{\parahook}{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\paraindent}
% \begin{macro}{\beforeparaskip}
% \begin{macro}{\afterparaskip}
% \begin{macro}{\paraheadstyle}
% \begin{macro}{\setparaindent}
% \begin{macro}{\setbeforeparaskip}
% \begin{macro}{\setafterparaskip}
% \begin{macro}{\setparaheadstyle}
% The macros for controlling \cs{paragraph} headings.
% \begin{macrocode}
\newlength{\paraindent}
\newcommand{\setparaindent}[1]{\setlength{\paraindent}{#1}}
\setparaindent{\z@}
\newskip\beforeparaskip
\newcommand{\setbeforeparaskip}[1]{\setlength{\beforeparaskip}{#1}}
\setbeforeparaskip{3.25ex \@plus 1ex \@minus .2ex}
\newskip\afterparaskip
\newcommand{\setafterparaskip}[1]{\setlength{\afterparaskip}{#1}}
\setafterparaskip{-1em}
\newcommand{\paraheadstyle}{}
\newcommand{\setparaheadstyle}[1]{\renewcommand{\paraheadstyle}{#1}}
\setparaheadstyle{\normalsize\bfseries}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \begin{macro}{\subparagraph}
% A runin heading with white space above and to the right of the heading.
% By default the heading is set in a \verb?\normalsize\bfseries? font.
% \begin{macrocode}
\newcommand{\subparagraph}{%
\subparahook%
\@startsection{subparagraph}{5}% level 5
{\subparaindent}% heading indent
{\beforesubparaskip}% skip before the heading
{\aftersubparaskip}% skip after the heading
{\normalfont\subparaheadstyle}} % font
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subparahook}
% \begin{macro}{\setsubparahook}
% \cs{subparahook} is called at the start of a \cs{subparagraph} and
% \cs{setsubparahook}\marg{code} redefines it.
% \begin{macrocode}
\newcommand{\subparahook}{}
\newcommand{\setsubparahook}[1]{\renewcommand{\subparahook}{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\subparaindent}
% \begin{macro}{\beforesubparaskip}
% \begin{macro}{\aftersubparaskip}
% \begin{macro}{\subparaheadstyle}
% \begin{macro}{\setsubparaindent}
% \begin{macro}{\setbeforesubparaskip}
% \begin{macro}{\setaftersubparaskip}
% \begin{macro}{\setsubparaheadstyle}
% The macros for controlling \cs{subparagraph} headings.
% \begin{macrocode}
\newlength{\subparaindent}
\newcommand{\setsubparaindent}[1]{%
\setlength{\subparaindent}{#1}}
\setsubparaindent{\parindent}
\newskip\beforesubparaskip
\newcommand{\setbeforesubparaskip}[1]{%
\setlength{\beforesubparaskip}{#1}}
\setbeforesubparaskip{3.25ex \@plus 1ex \@minus .2ex}
\newskip\aftersubparaskip
\newcommand{\setaftersubparaskip}[1]{%
\setlength{\aftersubparaskip}{#1}}
\setaftersubparaskip{-1em}
\newcommand{\subparaheadstyle}{}
\newcommand{\setsubparaheadstyle}[1]{%
\renewcommand{\subparaheadstyle}{#1}}
\setsubparaheadstyle{\normalsize\bfseries}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sethangfrom}
% The macro \cs{sethangfrom}\marg{code} is a user-level command
% for changing the definition of \cs{@hangfrom}. Use \verb?#1? in \meta{code}
% for the argument to \cs{@hangfrom} (or \verb?##1? if used inside another macro).
% \changes{v0.2}{2001/06/03}{Added \cs{sethangfrom}}
% \begin{macrocode}
\newcommand{\sethangfrom}[1]{\renewcommand{\@hangfrom}[1]{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setsecnumformat}
% The macro \cs{setsecnumformat}\marg{code} is a user-level command
% for changing the definition of \cs{@seccntformat}. Use \verb?#1? in \meta{code}
% for the argument to \cs{@seccntformat} (or \verb?##1? if used inside another macro).
% \changes{v0.2}{2001/06/03}{Added \cs{setsecnumformat}}
% \begin{macrocode}
\newcommand{\setsecnumformat}[1]{\renewcommand{\@seccntformat}[1]{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hangsecnum}
% \begin{macro}{\defaultsecnum}
% These are declarations for putting sectional numbers in the margin,
% or the default sectional number formatting.
% \changes{v0.2}{2001/06/03}{Added \cs{hangsecnum} and \cs{defaultsecnum}}
% \begin{macrocode}
\newcommand{\hangsecnum}{%
\def\@seccntformat##1{\llap{\csname the##1\endcsname\quad}}}
\newcommand{\defaultsecnum}{%
\def\@seccntformat##1{\csname the##1\endcsname\quad}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Anonymous headings}
%
% \begin{macro}{\plainbreak}
% \cs{plainbreak}\marg{num} generates \meta{num} blanks lines and
% suppresses the indentation of a following paragraph. The starred
% version, \cs{plainbreak*}, does not suppress paragraph indentation.
% \changes{v0.2}{2001/06/03}{Added starred version of \cs{plainbreak}}
% \begin{macrocode}
\newcommand{\plainbreak}{\@ifstar{\@spbreak}{\@pbreak}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@pbreak}
% \begin{macro}{\@spbreak}
% These are the internal forms for the two versions of \cs{plainbreak}.
% The code for \cs{@pbreak} is almost a straight copy of code posted to
% \ctt{} by Donald Arseneau on 2001/03/26.
% \begin{macrocode}
\newcommand*{\@pbreak}[1]{\par
\penalty -100
\vskip #1\onelineskip \@plus 2\onelineskip
\penalty -20
\vskip \z@ \@plus -2\onelineskip
\@afterindentfalse
\@afterheading}
\newcommand*{\@spbreak}[1]{\par
\penalty -100
\vskip #1\onelineskip \@plus 2\onelineskip
\penalty -20
\vskip \z@ \@plus -2\onelineskip
\@afterindenttrue
\@afterheading}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\fancybreak}
% \cs{fancybreak}\marg{text} typesets \meta{text} centered. For example,
% \verb?\fancybreak{{*}\\{* * *}\\{*}}?. It suppresses indentation of the
% following paragraph. The starred version leaves indentation as is.
% \changes{v0.2}{2001/06/03}{Added starred version of \cs{fancybreak}}
% \changes{v1.3}{2002/11/14}{Tweaked \cs{fancybreak} to remove underfull hbox}
% \changes{v1.61803}{2008/01/30}{Changed fancybreak code to end the paragraph
% it started (Dan Leucking mempatch v4.5)}
% \begin{macrocode}
\newcommand{\fancybreak}{\@ifstar{\@sfbreak}{\@fbreak}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@fbreak}
% \begin{macro}{\@sfbreak}
% These are the internal forms for the two versions of \cs{fancybreak}.
% \begin{macrocode}
\newcommand{\@fbreak}[1]{\par
\penalty -100
\noindent\parbox{\linewidth}{\centering #1}%%\null
\par
%% \penalty -20
%% \vskip -\onelineskip
\@afterindentfalse
\@afterheading}
\newcommand{\@sfbreak}[1]{\par
\penalty -100
\noindent\parbox{\linewidth}{\centering #1}%%\null
\par
%% \penalty -20
%% \vskip -\onelineskip
\@afterindenttrue
\@afterheading}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\plainfancybreak}
% The \cs{plainfancybreak}\marg{space}\marg{num}\marg{text} acts
% like \cs{plainbreak}\marg{num} in the middle of a page and like
% \cs{fancybreak}\marg{text} at the bottom of a page. The \meta{space}
% argument is the vertical space required for the \meta{num} blank lines
% and some additional lines of text. From experiments, it seems that
% \meta{space} should be at least (3+\meta{num}) lines (\cs{onelineskip}).
% There is also a starred version, \cs{plainfancybreak*}, to match the other
% starred break commands.
% \changes{v0.2}{2001/06/03}{Added \cs{plainfancybreak} and supporting macros}
% \begin{macrocode}
\newcommand{\plainfancybreak}{\@ifstar{\@spfbreak}{\@pfbreak}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@pfbreak}
% \begin{macro}{\@spfbreak}
% These are the internal macros for the unstarred and starred versions
% of \cs{plainfancybreak}. They essentially do the same thing, except they call,
% respectively, the unstarred and starred internal versions of \cs{plainbreak}
% and \cs{fancybreak}. The code for checking the amount of space left on the
% page is from an early, and abandoned, version of the code for \cs{needspace}.
% \begin{macrocode}
\newcommand{\@pfbreak}[3]{\par
\@tempdimc\pagegoal \advance\@tempdimc-\pagetotal
\ifdim #1>\@tempdimc \@fbreak{#3}\else \@pbreak{#2}\fi}
\newcommand{\@spfbreak}[3]{\par
\@tempdimc\pagegoal \advance\@tempdimc-\pagetotal
\ifdim #1>\@tempdimc \@sfbreak{#3}\else \@spbreak{#2}\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% From the thread \textit{Customizing section hooks in memoir.cls} on \ctt{}
% in October 2002 it appeared that \cs{plainfancybreak} may be fragile.
% Donald Arseneau said that \cs{plainfancybreak} guessed at the amount
% of space available and gave code based on a modified output routine
% to make it more robust. The following code is based on that thread.
% \changes{v1.3}{2002/11/14}{Added lots of code for new \cs{pfbreak}}
%
% \begin{macro}{\pen@ltyabovepfbreak}
% \begin{macro}{\pen@ltybelowpfbreak}
% Penalities for communication with the output routine.
% \begin{macrocode}
\newcommand*{\pen@ltyabovepfbreak}{2}
\newcommand*{\pen@ltybelowpfbreak}{-4}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pfbreakskip}
% The vertical space taken by the plain and fancy breaks.
% \begin{macrocode}
\newlength{\pfbreakskip}
\setlength{\pfbreakskip}{2\baselineskip}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pfbreakdisplay}
% This is the fancybreak display, which must fit into \cs{pfbreakskip}
% vertical space.
% \begin{macrocode}
\newcommand{\pfbreakdisplay}{*\quad*\quad*}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pfbre@kdispl@y}
% Typesets \cs{pfbreakdisplay} vertically and horizontally centered.
% \begin{macrocode}
\def\pfbre@kdispl@y{\vbox to 1\pfbreakskip{\vss
\hb@xt@ \columnwidth{\hss \pfbreakdisplay \hss}%
\vss}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\nopfbreakOutput}
% Save the current output routine.
% \begin{macrocode}
\edef\nopfbreakOutput{\the\output}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pfbreakOutput}
% Special output to handle the \cs{pfbreak}.
% \begin{macrocode}
\def\pfbreakOutput{%
\ifnum\outputpenalty=\pen@ltyabovepfbreak
\nopfbreakOutput
\pfbre@kdispl@y
\nobreak
\vskip-\pfbreakskip
\else\ifnum\outputpenalty=\pen@ltybelowpfbreak
\unvbox 255\relax
\nobreak
\vskip-\pfbreakskip
\pfbre@kdispl@y
\break
\else
\nopfbreakOutput
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\output}
% Use the new \cs{pfbreak} output routine.
% \begin{macrocode}
\output={\pfbreakOutput}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pfbreak}
% Typesets a plain break in the middle of the page, otherwise
% a fancybreak at either the bottom or top of the page.
% \begin{macrocode}
\newcommand{\pfbreak}{\@ifstar{\@spfbreakgap}{\@pfbreakgap}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@pfbreakgap}
% Unstarred version of \cs{pfbreak}.
% \changes{v3.6h}{2010/10/06}{fixed \cs{@pfbreakgab} kudos to DA for
% the fix}
% \begin{macrocode}
\newcommand{\@pfbreakgap}{%
\par {%
\skip@\lastskip
\nobreak
\vskip -\ifdim\prevdepth>\maxdepth \maxdepth
\else\ifdim\prevdepth>-1000pt\prevdepth
\else\ifinner 0pt
\else \pagedepth
\fi \fi \fi
\vskip -\skip@
\ifdim\skip@<\pfbreakskip
\advance\skip@ -1\skip@ \advance\skip@ 1\pfbreakskip
\fi
\penalty\pen@ltyabovepfbreak
\prevdepth\z@ % added
\vskip\skip@
\penalty\pen@ltybelowpfbreak
}
\@afterindentfalse
\@afterheading
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@spfbreakgap}
% Starred version of \cs{pfbreak}.
% \changes{v3.6h}{2010/10/06}{fixed \cs{@pfbreakgab} kudos to DA for
% the fix}
% \begin{macrocode}
\newcommand{\@spfbreakgap}{%
\par {%
\skip@\lastskip
\nobreak
\vskip -\ifdim\prevdepth>\maxdepth \maxdepth
\else\ifdim\prevdepth>-1000pt\prevdepth
\else\ifinner 0pt
\else \pagedepth
\fi \fi \fi
\vskip -\skip@
\ifdim\skip@<\pfbreakskip
\advance\skip@ -1\skip@ \advance\skip@ 1\pfbreakskip
\fi
\penalty\pen@ltyabovepfbreak
\prevdepth\z@ % added
\vskip\skip@
\penalty\pen@ltybelowpfbreak
}
\@afterindenttrue
\@afterheading
}
% \end{macrocode}
% \end{macro}
%
%
% While on the subject of breaks\ldots
%
% \begin{macro}{\noprelistbreak}
% Putting this immediately before a list (e.g., \Lenv{itemize}) should
% prevent a page break at that point.
% \changes{v1.2}{2002/07/27}{Added \cs{noprelistbreak}}
% \begin{macrocode}
\newcommand*{\noprelistbreak}{\@nobreaktrue\nopagebreak}
% \end{macrocode}
% \end{macro}
%
% \subsection{Division head styles}
%
% The styles of the division heads should go together. As an aid the
% class supplies some ready made collections.
% \changes{v1.6180}{2008/01/30}{Added division head styles}
%
% \begin{macro}{\makeheadstyles}
% \begin{macro}{\headstyles}
% \begin{macro}{\@hds@def@ult}
% \begin{macro}{\hds@default}
% \cs{makeheadstyles}\marg{name}\marg{code} creates the \meta{name} collection
% of division head styles, defined by \meta{code}. \cs{headstyles}\marg{name}
% makes the \meta{name} division head styles the current styles.
% \begin{macrocode}
\newcommand{\makeheadstyles}[2]{%
\@namedef{hds@#1}{\@hds@def@ult #2}}
\newcommand*{\headstyles}[1]{\@nameuse{hds@#1}}
% \end{macrocode}
% \cs{@hds@def@ult} is the default set of division head styles.
% \begin{macrocode}
\newcommand*{\@hds@def@ult}{%
% Default \cs{book} style
% \begin{macrocode}
% book
\renewcommand*{\beforebookskip}{\null\vfil}%
\renewcommand*{\midbookskip}{\par\vskip 20pt}%
\renewcommand*{\afterbookskip}{\vfil\newpage}%
\renewcommand*{\booknamefont}{\normalfont\huge\bfseries}%
\renewcommand*{\booknumfont}{\normalfont\huge\bfseries}%
\renewcommand*{\booktitlefont}{\normalfont\Huge\bfseries}%
\renewcommand*{\printbookname}{\booknamefont \bookname}%
\renewcommand*{\booknamenum}{\space}%
\renewcommand*{\printbooknum}{\booknumfont \thebook}%
\renewcommand*{\printbooktitle}[1]{\booktitlefont{##1}}%
% \end{macrocode}
% Default \cs{part} style
% \begin{macrocode}
% part
\renewcommand*{\beforepartskip}{\null\vfil}%
\renewcommand*{\midpartskip}{\par\vskip 20pt}%
\renewcommand*{\afterpartskip}{\vfil\newpage}%
\renewcommand*{\partnamefont}{\normalfont\huge\bfseries}%
\renewcommand*{\partnumfont}{\normalfont\huge\bfseries}%
\renewcommand*{\parttitlefont}{\normalfont\Huge\bfseries}%
\renewcommand*{\printpartname}{\partnamefont \partname}%
\renewcommand*{\partnamenum}{\space}%
\renewcommand*{\printpartnum}{\partnumfont \thepart}%
\renewcommand*{\printparttitle}[1]{\parttitlefont{##1}}%
% \end{macrocode}
% Default \cs{chapter} style.
% \begin{macrocode}
\@chs@def@ult% default chapterstyle
% \end{macrocode}
% Default \cs{section} style
% \changes{v1.61803398}{2009/07/17}{Added bidi support to default sec headstyle}
% \begin{macrocode}
% section
\setsechook{}
\setsecindent{\z@}%
\setbeforesecskip{-3.5ex \@plus -1ex \@minus -.2ex}%
\setaftersecskip{2.3ex \@plus .2ex}%
\setsecheadstyle{\Large\bfseries\memRTLraggedright}%
% \end{macrocode}
% Default \cs{subsection} style
% \changes{v1.61803398}{2009/07/17}{Added bidi support to default subsec headstyle}
% \begin{macrocode}
% subsection
\setsubsechook{}%
\setsubsecindent{\z@}%
\setbeforesubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}%
\setaftersubsecskip{1.5ex \@plus .2ex}%
\setsubsecheadstyle{\large\bfseries\memRTLraggedright}%
% \end{macrocode}
% Default \cs{subsubsection} style
% \changes{v1.61803398}{2009/07/17}{Added bidi support to default subsubsec headstyle}
% \begin{macrocode}
% subsubsection
\setsubsubsechook{}%
\setsubsubsecindent{\z@}%
\setbeforesubsubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}%
\setaftersubsubsecskip{1.5ex \@plus .2ex}%
\setsubsubsecheadstyle{\normalsize\bfseries\memRTLraggedright}%
% \end{macrocode}
% Default \cs{paragraph} style
% \begin{macrocode}
% paragraph
\setparahook{}%
\setparaindent{\z@}%
\setbeforeparaskip{3.25ex \@plus 1ex \@minus .2ex}%
\setafterparaskip{-1em}%
\setparaheadstyle{\normalsize\bfseries}%
% \end{macrocode}
% Default \cs{paragraph} style
% \begin{macrocode}
% subparagraph
\setsubparahook{}%
\setsubparaindent{\parindent}%
\setbeforesubparaskip{3.25ex \@plus 1ex \@minus .2ex}%
\setaftersubparaskip{-1em}%
\setsubparaheadstyle{\normalsize\bfseries}}
% \end{macrocode}
% Set up and use the default head styles
% \begin{macrocode}
\makeheadstyles{default}{}
\headstyles{default}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\addperiod}
% Puts a period at the end of its argument.
% \begin{macrocode}
\newcommand*{\addperiod}[1]{#1.}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hds@memman}
% Head styles used in the \textit{The Memoir Class} user guide. In this,
% as the later ones, only changes from the defaults need specifying.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to the memman headstyles}
% \begin{macrocode}
\makeheadstyles{memman}{%
% book changes
\renewcommand*{\booknamefont}{\normalfont\huge\sffamily}
\renewcommand*{\booknumfont}{\normalfont\huge\sffamily}
\renewcommand*{\booktitlefont}{\normalfont\Huge\sffamily}
\renewcommand*{\midbookskip}{\par\vskip 2\onelineskip}%
% part changes
\renewcommand*{\partnamefont}{\normalfont\huge\sffamily}
\renewcommand*{\partnumfont}{\normalfont\huge\sffamily}
\renewcommand*{\parttitlefont}{\normalfont\Huge\sffamily}
\renewcommand*{\midpartskip}{\par\vskip 2\onelineskip}%
% chapter
\chapterstyle{demo3}
% section
\setbeforesecskip{-1.333\onelineskip
\@plus -0.5\onelineskip \@minus -.5\onelineskip}%
\setaftersecskip{0.667\onelineskip \@plus 0.1\onelineskip}%
\setsecheadstyle{\normalfont\scshape\memRTLraggedright}%
% subsection
\setbeforesubsecskip{-0.667\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
\setsubsecheadstyle{\normalfont\bfseries\memRTLraggedright}%
% subsubsection
\setbeforesubsubsecskip{-0.667\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
\setsubsubsecheadstyle{\normalfont\normalsize\itshape\memRTLraggedright}%
% paragraph
\setbeforeparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setafterparaskip{-1em}%
\setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
% subparagraph
\setsubparaindent{\parindent}%
\setbeforesubparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setaftersubparaskip{-1em}%
\setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hds@bringhurst}
% Head styles based on Bringhurst's book
% \changes{v1.61803398}{2009/07/17}{Added bidi support to bringhurst headstyles}
% \changes{c3.6k}{2012/09/18}{\cs{MakeLowercase} $\to$ \cs{MakeTextLowercase}}
% \begin{macrocode}
\makeheadstyles{bringhurst}{%
% chapter
\chapterstyle{bringhurst}
% section
\setbeforesecskip{-1\onelineskip
\@plus -0.5\onelineskip \@minus -.5\onelineskip}%
\setaftersecskip{1\onelineskip \@plus 0.1\onelineskip}%
\setsecheadstyle{\normalfont\memRTLraggedright\scshape\MakeTextLowercase}%
% subsection
\setbeforesubsecskip{-1.0\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsecskip{1.0\onelineskip \@plus 0.1\onelineskip}%
\setsubsecheadstyle{\sethangfrom{\noindent ####1}\normalfont\itshape\memRTLraggedright}%
% subsubsection
\setbeforesubsubsecskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setaftersubsubsecskip{-1em}%
\setsubsubsecheadstyle{\normalfont\normalsize\scshape\MakeTextLowercase}%
% paragraph
\setbeforeparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setafterparaskip{-1em}%
\setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
% subparagraph
\setsubparaindent{\parindent}%
\setbeforesubparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setaftersubparaskip{-1em}%
\setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hds@crosshead}
% Head styles based on one of Bringhurst's suggestions.
% \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
% \begin{macrocode}
\makeheadstyles{crosshead}{%
\chapterstyle{crosshead}
% section
\setbeforesecskip{-1.25\onelineskip
\@plus -0.5\onelineskip \@minus -.5\onelineskip}%
\setaftersecskip{0.75\onelineskip \@plus 0.1\onelineskip}%
\setsecheadstyle{\normalfont\centering\MakeTextUppercase}%
% subsection
\setbeforesubsecskip{-1.25\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsecskip{0.75\onelineskip \@plus 0.1\onelineskip}%
\setsubsecheadstyle{\normalfont\centering\bfseries}%
% subsubsection
\setbeforesubsubsecskip{-.667\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsubsecskip{.333\onelineskip \@plus 0.1\onelineskip}%
\setsubsubsecheadstyle{\normalfont\normalsize\centering\scshape\MakeTextLowercase}%
% paragraph
\setbeforeparaskip{-.667\onelineskip
\@plus -02.5\onelineskip \@minus -0.25\onelineskip}%
\setafterparaskip{.333\onelineskip \@plus 0.1\onelineskip}%
\setparaheadstyle{\normalfont\normalsize\centering\itshape}%
% subparagraph
\setsubparaindent{\parindent}%
\setbeforesubparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setaftersubparaskip{-1em}%
\setsubparaheadstyle{\normalfont\normalsize\scshape\MakeTextLowercase}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hds@dowding}
% Head styles based on Dowding's \textit{Finer Points}.
% \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
% \changes{c3.6k}{2012/09/18}{\cs{MakeLowercase} $\to$ \cs{MakeTextLowercase}}
% \begin{macrocode}
\makeheadstyles{dowding}{%
% chapter
\chapterstyle{dowding}
% section
\setbeforesecskip{-2\onelineskip
\@plus -0.5\onelineskip \@minus -.5\onelineskip}%
\setaftersecskip{1\onelineskip \@plus 0.1\onelineskip}%
\setsecheadstyle{\normalfont\centering\MakeTextUppercase}%
% subsection
\setbeforesubsecskip{-1.2\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsecskip{0.8\onelineskip \@plus 0.1\onelineskip}%
\setsubsecheadstyle{\normalfont\scshape\centering\MakeTextLowercase}%
% subsubsection
\setbeforesubsubsecskip{-0.667\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
\setsubsubsecheadstyle{\normalfont\normalsize\centering\itshape}%
% paragraph
\setbeforeparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setafterparaskip{-1em}%
\setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
% subparagraph
\setsubparaindent{\parindent}%
\setbeforesubparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setaftersubparaskip{-1em}%
\setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hds@komalike}
% Head styles based on KOMA script classes (\texttt{scrbook.cls}).
% \changes{v1.61803398}{2009/07/17}{Added bidi support to komalike headstyles}
% \begin{macrocode}
\makeheadstyles{komalike}{%
% part
\renewcommand*{\partnamefont}{\huge\sffamily\bfseries}%
\renewcommand*{\partnumfont}{\huge\sffamily\bfseries}%
\renewcommand*{\parttitlefont}{\huge\sffamily\bfseries}%
% chapter
\chapterstyle{komalike}
% section
\setbeforesecskip{-3.5ex \@plus -1ex \@minus -.2ex}%
\setaftersecskip{2.3ex \@plus .2ex}%
\setsecheadstyle{\normalfont\Large\sffamily\bfseries\memRTLraggedright}%
% subsection
\setbeforesubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}%
\setaftersubsecskip{1.5ex \@plus .2ex}%
\setsubsecheadstyle{\normalfont\large\sffamily\bfseries\memRTLraggedright}%
% subsubsection
\setbeforesubsubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}%
\setaftersubsubsecskip{1.5ex \@plus .2ex}%
\setsubsubsecheadstyle{\normalfont\normalsize\sffamily\bfseries\memRTLraggedright}%
% paragraph
\setbeforeparaskip{3.25ex \@plus 1ex \@minus .2ex}%
\setafterparaskip{-1em}%
\setparaheadstyle{\normalfont\normalsize\sffamily\bfseries}%
% subparagraph
\setsubparaindent{\parindent}%
\setbeforesubparaskip{3.25ex \@plus 1ex \@minus .2ex}%
\setaftersubparaskip{-1em}%
\setsubparaheadstyle{\normalfont\normalsize\sffamily\bfseries}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hds@ntglike}
% Head styles based on the NTG classes (\texttt{boek.cls}).
% \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
% \begin{macrocode}
\makeheadstyles{ntglike}{%
% part
\renewcommand*{\partnamefont}{\Large\bfseries\MakeTextUppercase}%
\renewcommand*{\partnumfont}{\Large\bfseries}%
\renewcommand*{\parttitlefont}{\Large\MakeTextUppercase}%
% chapter
\chapterstyle{ntglike}
% section
\setbeforesecskip{-2\onelineskip
\@plus -1\onelineskip \@minus -.5\onelineskip}%
\setaftersecskip{0.5\onelineskip}%
\setsecheadstyle{\normalfont\large\bfseries}%
% subsection
\setbeforesubsecskip{-1\onelineskip
\@plus -.5\onelineskip \@minus -.25\onelineskip}%
\setaftersubsecskip{0.01\onelineskip}%
\setsubsecheadstyle{\normalfont\normalsize\bfseries}%
% subsubsection
\setbeforesubsubsecskip{-1\onelineskip
\@plus -.5\onelineskip \@minus -.25\onelineskip}%
\setaftersubsubsecskip{0.01\onelineskip}%
\setsubsubsecheadstyle{\normalfont\normalsize\slshape}%
% paragraph
\setbeforeparaskip{3.25ex \@plus 1ex \@minus .2ex}%
\setafterparaskip{-1em}%
\setparaheadstyle{\normalfont\normalsize\slshape}%
% subparagraph
\setsubparaindent{\parindent}%
\setbeforesubparaskip{3.25ex \@plus 1ex \@minus .2ex}%
\setaftersubparaskip{-1em}%
\setsubparaheadstyle{\normalfont\normalsize\slshape}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hds@tandh}
% Head styles based on Thames \& Hudson \textit{Typography}.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to tandh headstyles}
% \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
% \begin{macrocode}
\makeheadstyles{tandh}{%
% chapter
\chapterstyle{tandh}
% section
\setbeforesecskip{-2\onelineskip
\@plus -0.5\onelineskip \@minus -.5\onelineskip}%
\setaftersecskip{1\onelineskip \@plus 0.1\onelineskip}%
\setsecheadstyle{\normalfont\memRTLraggedright\MakeTextUppercase}%
% subsection
\setbeforesubsecskip{-1.2\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsecskip{0.8\onelineskip \@plus 0.1\onelineskip}%
\setsubsecheadstyle{\normalfont\Large\itshape\memRTLraggedright}%
% subsubsection
\setbeforesubsubsecskip{-0.667\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
\setsubsubsecheadstyle{\normalfont\normalsize\bfseries\memRTLraggedright}%
% paragraph
\setbeforeparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setafterparaskip{-1em}%
\setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
% subparagraph
\setsubparaindent{\parindent}%
\setbeforesubparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setaftersubparaskip{-1em}%
\setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hds@wilsondob}
% Head styles based on Adrian Wilson's \textit{The Design of Books}.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to wilsondob headstyles}
% \changes{c3.6k}{2012/09/18}{\cs{MakeUppercase} $\to$ \cs{MakeTextUppercase}}
% \begin{macrocode}
\makeheadstyles{wilsondob}{%
% chapter
\chapterstyle{wilsondob}
% section
\setbeforesecskip{-1.333\onelineskip
\@plus -0.5\onelineskip \@minus -.5\onelineskip}%
\setaftersecskip{0.667\onelineskip \@plus 0.1\onelineskip}%
\setsecheadstyle{\normalfont\memRTLraggedright\MakeTextUppercase}%
% subsection
\setbeforesubsecskip{-0.667\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
\setsubsecheadstyle{\normalfont\Large\itshape\memRTLraggedright}%
% subsubsection
\setbeforesubsubsecskip{-0.667\onelineskip
\@plus -0.25\onelineskip \@minus -0.25\onelineskip}%
\setaftersubsubsecskip{0.333\onelineskip \@plus 0.1\onelineskip}%
\setsubsubsecheadstyle{\normalfont\normalsize\memRTLraggedright\scshape\MakeTextLowercase}%
% paragraph
\setbeforeparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setafterparaskip{-1em}%
\setparaheadstyle{\normalfont\normalsize\itshape\addperiod}%
% subparagraph
\setsubparaindent{\parindent}%
\setbeforesubparaskip{1.0\onelineskip
\@plus 0.5\onelineskip \@minus 0.2\onelineskip}%
\setaftersubparaskip{-1em}%
\setsubparaheadstyle{\normalfont\normalsize\itshape\addperiod}}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Appendices}
%
% \begin{macro}{\ifanappendix}
% \begin{macro}{\anappendixtrue}
% \begin{macro}{\anappendixfalse}
% \begin{macro}{\appendix}
% In the standard \Lpack{book} class the \cs{appendix} command does the
% following:
% \begin{itemize}
% \item Resets the chapter and section counters to zero
% \item Sets \cs{@chapapp} to \cs{appendixname}.
% \item Redefines \cs{thechapter} to produce alphabetic appendix numbers.
% \end{itemize}
% \changes{v1.618}{2005/09/03}{Added \cs{ifanappendix} (mempatch v3.12)}
% \begin{macrocode}
\newif\ifanappendix
\anappendixfalse
\newcommand{\appendix}{\par
\setcounter{chapter}{0}%
\setcounter{section}{0}%
\gdef\@chapapp{\appendixname}%
\gdef\thechapter{\@Alph\c@chapter}%
\anappendixtrue}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% This class provides additional appendixing capabilities.
%
%
% \begin{macro}{\appendixpage}
% \begin{macro}{\appendixpage*}
% The command to typeset a page announcing the start of the appendices.
% It is based on the \cs{part} definition. The normal version
% makes an entry in the ToC but the starred version does not.
% \changes{v0.33}{2001/08/31}{Changed implementation of \cs{appendixpage}}
% \begin{macrocode}
\newcommand{\appendixpage}{%
\@ifstar{\@sapppage}{\@apppage}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memapppageinfo}
% \begin{macro}{\memapppagestarinfo}
% \verb?\memapppageinfo{\appendixpagename}? \\
% \verb?\memapppagestarinfo{\appendixpagename}? \\
% \begin{macrocode}
\newcommand{\memapppageinfo}[1]{}
\newcommand{\memapppagestarinfo}[1]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@apppage}
% \cs{@apppage} typesets an appendix page and makes an entry in the ToC.
% \changes{v3.6k}{2013/04/25}{Added \cs{mempre/postaddchaptertotochook}}
% \begin{macrocode}
\def\@apppage{%
\@setuppart
\mempreaddapppagetotochook
\addappheadtotoc
\mempostaddapppagetotochook
\partmark{\appendixpagename}%
\memapppageinfo{\appendixpagename}%
{\centering
\interlinepenalty \@M
\normalfont
\printparttitle{\appendixpagename}\par}%
\@endpart}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\mempreaddapppagetotochook}
% \begin{macro}{\mempostaddapppagetotochook}
% Hooks before and after adding something to the ToC. Does nothing
% by default.
% \begin{macrocode}
\newcommand\mempreaddapppagetotochook{}
\newcommand\mempostaddapppagetotochook{}
% \end{macrocode}
%
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@sapppage}
% \cs{@sapppage} typesets an appendix page and does not make an entry in the ToC.
% \begin{macrocode}
\def\@sapppage{%
\@setuppart
\partmark{\appendixpagename}%
\memapppagestarinfo{\appendixpagename}%
{\centering
\interlinepenalty \@M
\normalfont
\printparttitle{\appendixpagename}\par}%
\@endpart}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\addappheadtotoc}
% This command adds an `appendices' line to the ToC. The style is the same
% as used in \Lpack{tocbibind} for the `List of figures' line. That is,
% as a Chapter heading.
% \changes{v1.61803}{2008/01/30}{Added \cs{phantomsection} to \cs{addappheadtotoc}
% (mempatch v4.9)}
% \begin{macrocode}
\def\addappheadtotoc{%
\phantomsection\addcontentsline{toc}{chapter}{\appendixtocname}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ppsavesec}
% \begin{macro}{\@pprestoresec}
% \begin{macro}{\@ppsaveapp}
% \begin{macro}{\restoreapp}
% For the \Lenv{appendices} environment we need to save and restore the
% main document division number and the appendix number. The \cs{restoreapp}
% command is the one for the user.
% \begin{macrocode}
\newcounter{@ppsavesec}
\newcounter{@ppsaveapp}
\setcounter{@ppsaveapp}{0}
\newcommand{\@ppsavesec}{%
\setcounter{@ppsavesec}{\value{chapter}}}
\newcommand{\@pprestoresec}{%
\setcounter{chapter}{\value{@ppsavesec}}}
\newcommand{\@ppsaveapp}{%
\setcounter{@ppsaveapp}{\value{chapter}}}
\newcommand{\restoreapp}{%
\setcounter{chapter}{\value{@ppsaveapp}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@resets@pp}
% Resets the appropriate sectioning counters and names. This does almost
% exactly what the default \cs{appendix} command does, except that it saves and
% restores sectional numbering. It saves the sectional number at the start
% and restores the appendix number at the end.
% \begin{macrocode}
% \changes{v3.7p}{2021/06/16}{Moved \cs{theHchapter} def here from
% \Lpack{memhfixc}. (discovered by Lars Hoemke, private email 20 Feb 2003)}
\newcommand{\@resets@pp}{%
\par
\@ppsavesec
\setcounter{section}{0}%
\setcounter{chapter}{0}%
\renewcommand\@chapapp{\appendixname}%
\renewcommand\thechapter{\@Alph\c@chapter}%
\restoreapp
\def\theHchapter{\Alph{chapter}}
}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{appendices}
% This is the heart of the package. Start it off by doing the resetting
% done by the \cs{appendix} command but also save the main counters. At the
% end of the environment save the appendix number and restore the main counters.
% \begin{macrocode}
\newenvironment{appendices}%
{\@resets@pp\anappendixtrue}%
{\@ppsaveapp\@pprestoresec\anappendixfalse}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\setthesection}
% The user commands for specifying the numbering style for subappendices.
% \begin{macrocode}
\newcommand{\setthesection}{\thechapter.\Alph{section}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@resets@ppsub}
% Similar to \cs{@resets@pp} except that it is for use within the
% \Lenv{subappendices} environment; as such, it is a bit simpler.
% \changes{v3.7p}{2021/06/16}{Moved \cs{theHsection} def here instead
% of in \Lpack{memhfixc}, Problem reported by Ignasi Furio, private email 13 May 2004}
% \begin{macrocode}
\newcommand{\@resets@ppsub}{
\par
\setcounter{section}{0}
\renewcommand{\thesection}{\setthesection}
\def\theHsection{\theHchapter.\Alph{section}}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifnamesubappendix}
% \begin{macro}{\namesubappendixtrue}
% \begin{macro}{\namesubappendixfalse}
% \begin{macro}{\namedsubappendices}
% \begin{macro}{\unnamedsubappendices}
% Switch for adding an `appendix' name before subappendix numbers.
% \changes{v1.0}{2001/11/13}{Added \cs{ifnamesubappendix}}
% \changes{v1.61803}{2008/01/30}{Added \cs{namedsubappendices} and
% \cs{unnamedsubappendices}}
% \begin{macrocode}
\newif\ifnamesubappendix
\namesubappendixfalse
\newcommand*{\namedsubappendices}{\namesubappendixtrue}
\newcommand*{\unnamedsubappendices}{\namesubappendixfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{environment}{subappendices}
% The environment for subappendices. Start it off by doing the resetting
% of the \cs{section} command.
% \changes{v1.0}{2001/11/13}{Modified subappendices environment}
% \begin{macrocode}
\newenvironment{subappendices}{%
\@resets@ppsub
% \end{macrocode}
% Change the definition of \cs{addappheadtotoc} to give a \texttt{section} entry.
% \changes{v1.618}{2005/09/02}{Fixed bookmark for \cs{appendixpage} (mempatch v2.3)}
% \begin{macrocode}
\def\addappheadtotoc{\phantomsection
\addcontentsline{toc}{section}{\appendixtocname}}
% \end{macrocode}
% To implement the naming we do cunning things with the
% \cs{@seccntformat} command.
% \begin{macrocode}
\ifnamesubappendix
\def\sectionname{\appendixname}
\def\@seccntformat##1{\@ifundefined{##1name}%
{}{\csname ##1name\endcsname\ }%
\csname the##1\endcsname\quad}
\fi
% \end{macrocode}
% We end by redefining \cs{theHsection} introduced in \cs{@resets@ppsub}
% \changes{v3.7p}{2021/06/16}{Moved redef of \cs{theHsection} here instead
% of in \Lpack{memhfixc}}
% \begin{macrocode}
}{%
\def\theHsection{\theHchapter.\arabic{section}}
}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\@formatsecmark@pp}
% Formats the page header for a redefined \cs{sectionmark}.
% \begin{macrocode}
% unused?
% \newcommand{\@formatsecmark@pp}[1]{%
% \MakeUppercase{\appendixname\space
% \ifnum \c@secnumdepth >\z@
% \thesection\quad
% \fi
% #1}}
% \end{macrocode}
% \end{macro}
%
% \subsection{Appendixpage-like pages}
% \changes{v1.618}{2005/09/03}{Added \cs{newleadpage} and friends (mempatch v3.0)}
%
%
% This capability was suggested to me by Lars Madsen on 2004/11/28.
%
% \begin{macro}{\leadpagetoclevel}
% \begin{macro}{\newleadpage}
% \begin{macro}{\renewleadpage}
% \verb?\newleadpage[<page-style>]{<cmdname>}{<title>}? creates new macros
% called \verb?\cmdname? and \verb?\cmdname*? that when called typeset a
% page like an Appendixpage, with a title \verb?<title>? using
% page style \verb?<page-style>? (default empty). The
% plain version adds an entry to the ToC but the starred \verb?\cmdname*?
% does not. \cs{renewleadpage} changes the definitions.
%
% The ToC entry style is set by \cs{leadpagetoclevel} (default chapter). To have a part-type entry: \\
% \verb?\renewcommand*{\leadpagetoclevel}{part}?. \\
% The \cs{partmark} command is used if you need to mark the title.
% \begin{macrocode}
\newcommand*{\leadpagetoclevel}{chapter}
\newcommand*{\newleadpage}[3][empty]{%
\@namedef{#2}{\@ifstar{\dlfm@msapppage{#1}{#2}{#3}}%
{\dlfm@mapppage{#1}{#2}{#3}}}}
\newcommand*{\renewleadpage}[3][empty]{%
\@namedef{#2}{\@ifstar{\dlfm@msapppage{#1}{#2}{#3}}%
{\dlfm@mapppage{#1}{#2}{#3}}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memleadpageinfo}
% \begin{macro}{\memleadpagestarinfo}
% \verb?\memleadpageinfo{pstyle}{name}{title}? \\
% \verb?\memleadpagestarinfo{pstyle}{name}{title}? \\
% \begin{macrocode}
\newcommand{\memleadpageinfo}[3]{}
\newcommand{\memleadpagestarinfo}[3]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\dlfm@msapppage}
% \begin{macro}{\dlfm@mapppage}
% Implement the starred and regular versions of \verb?\(re)newleadpage?
% \begin{macrocode}
\newcommand*{\dlfm@msapppage}[3]{%
\@setuppart
\partmark{#3}%
\memleadpagestarinfo{#1}{#2}{#3}%
{\centering
\interlinepenalty \@M
\normalfont
\printparttitle{#3}\par
\thispagestyle{#1}}%
\dlfm@m@endpart{#1}}
\newcommand*{\dlfm@mapppage}[3]{%
\@setuppart
\phantomsection
\addcontentsline{toc}{\leadpagetoclevel}{#3}%
\partmark{#3}%
\memleadpageinfo{#1}{#2}{#3}%
{\centering
\interlinepenalty \@M
\normalfont
\printparttitle{#3}\par
\thispagestyle{#1}}%
\dlfm@m@endpart{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\dlfm@m@endpart}
% Finishes off a part-like page.
% \begin{macrocode}
\newcommand*{\dlfm@m@endpart}[1]{%
\if@twoside
\if@openright
\null
\thispagestyle{#1}%
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}
% \end{macrocode}
% \end{macro}
%
% \subsection{Paragraphs}
%
% Much of the code in this section is taken from my \textit{Glisterings}
% columns~\cite{GLISTER07,GLISTER08}.
% \changes{v1.6180339c}{2009/01/09}{Added several new paragraph types}
%
% \begin{macro}{\memorigdbs}
% \begin{macro}{\memorigpar}
% \begin{macro}{\atcentercr}
% \cs{memorigdbs} saves the original definition of \verb?\\? and
% \cs{memorigpar} saves the original \cs{par}. The macro \cs{atcentercr}
% provides a user call to \cs{@centercr}. These could come in handy for
% odd paragraph shapes.
% \changes{v1.6180339c}{2009/01/09}{Added \cs{memorigdbs} and
% \cs{memorigpar} \cs{atcentercr}}
% \begin{macrocode}
\let\memorigdbs\\
\let\memorigpar\par
\let\atcentercr\@centercr
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Normal (block) paragraphs}
%
%
% \begin{macro}{\flushleftright}
% Sets the paragraphing to \LaTeX's normal form.
% \changes{v1.61803}{2008/01/30}{Used \cs{@flushglue} in \cs{flushleftright} and
% \cs{centerlastline} (mempatch v4.7)}
% \changes{v1.6180339c}{2009/01/09}{Extended \cs{flushleftright} to set all
% the regular paragraphing controls}
% \begin{macrocode}
\newcommand*{\flushleftright}{%
\let\\\memorigdbs
\leftskip\z@skip
\rightskip\leftskip
\parfillskip\@flushglue
\everypar{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\linenottooshort}
% This declaration \cs{linenottooshort}\oarg{length} specifies paragraphs
% such that the last line is at least about \meta{length} long (the default
% is 4em).
% \changes{v1.6180339c}{2009/01/09}{Added \cs{linenottooshort} paragraph}
% \begin{macrocode}
\newcommand*{\linenottooshort}[1][4em]{%
\@tempdima=\hsize
\advance\@tempdima -#1
\leftskip\z@skip
\rightskip\leftskip
\parfillskip=\@tempdima \@minus \@tempdima}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\russianpar}
% Using \cs{russianpar} instead of \cs{par} to end a paragraph causes it
% to be set according to Russian typography, where the last line of a
% multiline paragraph must be either at least as
% long as \cs{parindent} and have at least \cs{parindent} space at the
% right, or it must be flushleft and flushright.
% \changes{v1.6180339c}{2009/01/09}{Added \cs{russianpar} paragraph}
% \begin{macrocode}
\newcommand*{\russianpar}{\ifhmode\unskip
\strut\vadjust{}\nobreak
\discretionary{}%
{\hbox{\hskip2\parindent
\vrule depth 273sp width 0sp height \ht\strutbox}}%
{\hbox{\hskip\parindent}}%
\hskip-2\parindent \@minus 2\parindent
\hskip\hsize \@minus \hsize
\kern\z@ \parfillskip\z@
\memorigpar
\ifdim\prevdepth=273sp
\nobreak
\vskip-2\baselineskip
\hbox{\strut}%
\fi\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lastlineparrule}
% \begin{macro}{\lastlinerulefill}
% Using \cs{lastlinerulefill} instead of \cs{par} to end a paragraph
% causes all short lines to be filled at the right by a rule
% (\cs{lastlineparrule}) extending to the righthand margin.
% \changes{v1.6180339c}{2009/01/09}{Added \cs{lastlineparrule} and
% \cs{lastlinerulefill} paragraph}
% \begin{macrocode}
\newcommand*{\lastlineparrule}{%
\hrule height 0.5ex depth \@tempdimb\relax}
\newcommand*{\lastlinerulefill}{%
\let\\\@centercr
\@tempdimb=-0.5ex \advance\@tempdimb 0.4pt
\unskip\nobreak\space
\leaders\lastlineparrule\hskip\@flushglue
\vadjust{}{\parfillskip\z@\memorigpar}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Centered lines}
%
% \begin{macro}{\centerlastline}
% This declaration specifies normal paragraphs except that the last line of
% each is centered.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{centerlastline}}
% \begin{macrocode}
\newcommand*{\centerlastline}{%
%%% \leftskip\@flushglue
\memRTLleftskip\@flushglue
%%% \rightskip=\z@ plus -1fil
\memRTLrightskip=\z@ plus -1fil
\parfillskip=\z@ plus 2fil}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\leftcenterright}
% This declaration specifies paragraphs where the first line is flushleft
% (raggedright), the
% last is flushright (raggedleft) and all inbetween are centered.
% Set \verb?\everypar{}? afterwards.
% \changes{v1.6180339c}{2009/01/09}{Added \cs{leftcenterright} paragraph}
% \begin{macrocode}
\newcommand*{\leftcenterright}{%;
\let\\\break
\parindent\z@
\leftskip\@flushglue
\rightskip\leftskip
\parfillskip \z@ \@plus -1fil
\everypar={\hskip \z@ \@plus -1fil}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\centerfloat}
% This is a version of \cs{centering} that can be used to center a wide
% float with respect to the text block (normally the left of a wide float
% is aligned with the left of the textblock). This can only be used for
% centering something where LaTeX knows the width (e.g., a figure or a
% table / tabular).
%
% This is a modified version of code by Robin Fairbairns
% (CTT, \textit{Re: Centering a table: problem with rotating.sty, maybe
% a strange document class?}, 3 Jan 2009).
% \changes{v1.6180339c}{2009/01/11}{Added \cs{centerfloat}}
% \begin{macrocode}
\newcommand*{\centerfloat}{%
\parindent \z@
\leftskip \z@ \@plus 1fil \@minus \textwidth
\rightskip\leftskip
\parfillskip \z@skip}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Ragged}
%
% The kernel code for raggedright (in \file{ltmiscen.dtx}):
% \begin{verbatim}
% \def\raggedright{%
% \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip
% \leftskip\z@skip
% \parindent\z@}
% %% \@flushglue = 0pt plus 1fil %% from ltalloc.dtx
% %% \z@skip = 0pt plus 0pt minus 0pt %%
% \end{verbatim}
% produces very ragged text with no paragraph indent.
%
% \begin{macro}{\ragrparindent}
% \begin{macro}{\raggedyright}
% \cs{raggedyright}\oarg{plus} provides controllable ragged right paragraphs.
% \changes{v1.4}{2003/12/10}{Added \cs{raggedyright}}
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{raggedyright}}
% \begin{macrocode}
\newdimen\ragrparindent
\setlength{\ragrparindent}{\parindent}
\newcommand{\raggedyright}[1][2em]{%
\let\\\@centercr\@rightskip \z@ \@plus #1\relax
%%% \rightskip\@rightskip
\memRTLrightskip\@rightskip
%%% \leftskip\z@skip
\memRTLleftskip\z@skip
\parindent\ragrparindent}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\justlastraggedleft}
% This declaration specifies paragraphs where the lines are justified,
% except for the last which is raggedleft (flushright)..
% \changes{v1.6180339c}{2009/01/09}{Added \cs{justlastraggedleft} paragraph}
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{justlastraggedleft}}
% \begin{macrocode}
\newcommand*{\justlastraggedleft}{%
%%% \leftskip\@flushglue
\memRTLleftskip\@flushglue
%%% \rightskip-\leftskip
\memRTLrightskip-\memRTLleftskip
\parfillskip\leftskip
\parindent \z@}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\raggedrightthenleft}
% This declaration specifies paragraphs where the first line is raggedright
% (flushleft) and all the rest are raggedleft (flushright). Note that
% this alters \cs{everpar}, which may need to be reset afterwards to
% \verb?\everypar{}?.
% \changes{v1.6180339c}{2009/01/09}{Added \cs{raggedrightthenleft} paragraph}
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{raggedrightthenleft}}
% \begin{macrocode}
\newcommand*{\raggedrightthenleft}{%
\parindent \z@
\memRTLleftskip \z@ \@plus 1fill
\memRTLrightskip\@flushglue
\parfillskip \z@
\everypar{\hskip \z@ \@plus -1fill}}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Hanging}
%
% \begin{macro}{\hangfrom}
% This is a user-level
% version of the kernel \cs{@hangfrom} macro (only the name is
% changed) as defined in \file{ltsec.dtx}.
%
% \cs{hangfrom}\marg{text} puts \meta{text} in a box and makes a hanging
% paragraph of the following material (a bit like a description item).
% \changes{v1.4}{2003/11/22}{Added \cs{hangfrom} (from patch v1.9)}
% \begin{macrocode}
\newcommand{\hangfrom}[1]{%
\setbox\@tempboxa\hbox{{#1}}%
\hangindent \wd\@tempboxa\noindent\box\@tempboxa}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hangpara}
% \cs{hangpara}\marg{indent}\marg{afternum} at the start of a
% paragraph will make it hung. If \meta{indent} is positive the left
% will be indented, otherwise the right. If \meta{afternum}, say N,
% is positive the N+1 th lines onwards will be indented. For N negative,
% the first N lines will be indented.
% \begin{macrocode}
\newcommand{\hangpara}[2]{\hangindent#1\hangafter#2\noindent}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{hangparas}
% \verb?\begin{hangparas}?\marg{indent}\marg{afternum} hangs
% a series of paragraphs.
% \begin{macrocode}
\newenvironment{hangparas}[2]{\setlength{\parindent}{\z@}
\everypar={\hangpara{#1}{#2}}}{\par}
% \end{macrocode}
% \end{environment}
%
% \subsubsection{Miscellaneous}
%
% \begin{macro}{\leftspringright}
% \cs{leftspringright}\marg{leftfrac}\marg{rightfrac}\marg{lefttext}\marg{righttext}
% sets the \meta{lefttext} flushleft (raggedright) in a column \meta{leftfrac}
% of the current textwidth and the \meta{righttext} flushright (raggedleft)
% in a column \meta{rightfrac} of the textwidth, with space
% (1.0 - \meta{leftfrac} - \meta{rightfrac})
% of the textwidth between them. Both \meta{leftfrac} and \meta{rightfrac}
% must be given as decimal numbers (e.g., \texttt{0.25} not \texttt{1/4}).
% \changes{v1.6180339c}{2009/01/09}{Added \cs{leftspringright} paragraph}
% \begin{macrocode}
\newcommand{\leftspringright}[4]{%
\@tempdimb=\hsize
\par\noindent\hbox to\@tempdimb{%
\vtop{\hsize=#1\@tempdimb \flushleft#3\par}\hss
\vtop{\hsize=#2\@tempdimb \flushright#4\par}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sourceatright}
% Putting \cs{sourceatright}\oarg{length}\marg{text} at the end of a
% paragraph will set \meta{text} flushright on the same line provided the line
% is short enough to allow \meta{length} (default 2em) between the end of the
% line and \meta{text}. If there is not enough space then \meta{text} is
% set flushright on the following line.
% \changes{v1.6180339c}{2009/01/09}{Added \cs{sourceatright} paragraph}
% \begin{macrocode}
\newcommand*{\sourceatright}[2][2em]{{%
\unskip\nobreak\hfil\penalty50
\hskip#1\hbox{}\nobreak\hfil{#2}
\parfillskip\z@\finalhyphendemerits=0\par}}
% \end{macrocode}
% \end{macro}
%
%
% \section{Lists}
%
% \subsection{General List Parameters}
%
% The following commands are used to set the default values for the list
% environment's parameters. See the \LaTeX{} manual for an explanation
% of the meanings of the parameters. Defaults for the list
% environment are set as follows. First, \cs{rightmargin},
% \cs{listparindent} and \cs{itemindent} are set to 0pt. Then, for a Kth
% level list, the command \cs{@listK} is called, where `K' denotes `i',
% '`i', ... , `vi'. (I.e., \cs{@listiii} is called for a third-level
% list.) By convention, \cs{@listK} should set \cs{leftmargin} to
% \cs{leftmarginK}.
%
%
% \begin{macro}{\leftmargin}
% \begin{macro}{\leftmargini}
% \begin{macro}{\leftmarginii}
% \begin{macro}{\leftmarginiii}
% \begin{macro}{\leftmarginiv}
% \begin{macro}{\leftmarginv}
% \begin{macro}{\leftmarginvi}
% For efficiency, level-one list's values are defined at top level, and
% \cs{@listi} is defined to set only \cs{leftmargin}.
%
% In two column mode the margins should be smaller than in one column typesetting.
% \begin{macrocode}
\if@twocolumn
\setlength{\leftmargini}{2em}
\else
\setlength{\leftmargini}{2.5em}
\fi
% \end{macrocode}
% The value of \cs{leftmargin} has to be set at this outer level.
% \begin{macrocode}
\leftmargin \leftmargini
% \end{macrocode}
% Lower level list margins are calculated so that they are indented
% more than the label in an outer list.
% \begin{macrocode}
\setlength{\leftmarginii}{2.2em}
\setlength{\leftmarginiii}{1.87em}
\setlength{\leftmarginiv}{1.7em}
\if@twocolumn
\setlength{\leftmarginv}{.5em}
\setlength{\leftmarginvi}{.5em}
\else
\setlength{\leftmarginv}{1em}
\setlength{\leftmarginvi}{1em}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\itemindent}
% Here we set the \cs{itemindent} which is the extra indentation before
% a label.
% \begin{macrocode}
\setlength{\itemindent}{\z@}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\labelsep}
% \begin{macro}{\labelwidth}
% \cs{labelsep} is the distance between the label and the text of an
% item; \cs{labelwidth} is the width of the label.
% \begin{macrocode}
\setlength{\labelsep}{0.5em}
\setlength{\labelwidth}{\leftmargini}
\addtolength{\labelwidth}{-\labelsep}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@beginparpenalty}
% \begin{macro}{\@endparpenalty}
% These penalties are inserted before and after a list or paragraph
% environment. They are set to a bonus value to encourage page
% breaking at these points.
% \begin{macro}{\@itempenalty}
% This penalty is inserted between list items.
% \begin{macrocode}
\@beginparpenalty -\@lowpenalty
\@endparpenalty -\@lowpenalty
\@itempenalty -\@lowpenalty
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \begin{macro}{\everylistparindent}
% \begin{macro}{\list}
% The kernel sets \cs{listparindent} to zero within a \cs{list}, where it
% can be overridden in \cs{list}'s second argument. Here it is set to
% \cs{everyparlistindent} by default, which in turn is 0pt.
% \begin{macrocode}
\newdimen\everylistparindent
\everylistparindent \z@
\renewcommand*{\list}[2]{%
\ifnum \@listdepth >5\relax
\@toodeep
\else
\global\advance\@listdepth\@ne
\fi
\rightmargin\z@
\listparindent\everylistparindent
\itemindent\z@
\csname @list\romannumeral\the\@listdepth\endcsname
\def\@itemlabel{#1}%
\let\makelabel\@mklab
\@nmbrlistfalse
#2\relax
\@trivlist
\parskip\parsep
\parindent\listparindent
\advance\linewidth -\rightmargin
\advance\linewidth -\leftmargin
\advance\@totalleftmargin \leftmargin
\parshape \@ne \@totalleftmargin \linewidth
\ignorespaces}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\parsepi}
% \begin{macro}{\topsepi}
% \begin{macro}{\itemsepi}
% \begin{macro}{\parsepii}
% \begin{macro}{\topsepii}
% \begin{macro}{\topsepiii}
% Lists may be nested and the exact layout depends on the level
% of nesting. These lengths are used to control the nesting-level
% aspects.
% \begin{macrocode}
\newlength{\parsepi}
\newlength{\topsepi}
\newlength{\itemsepi}
\newlength{\parsepii}
\newlength{\topsepii}
\newlength{\topsepiii}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\itemsepii}
% \begin{macro}{\itemsepiii}
% \begin{macro}{\partopsepii}
% \begin{macro}{\partopsepii}
% We need some new lengths for lists to cater for non-zero \cs{parskip}.
% \changes{v1.61803}{2008/01/30}{Added \cs{itemsepii}, \cs{itemsepiii} and
% \cs{partopsepii} (mempatch v4.6)}
% \begin{macrocode}
\newlength{\itemsepii}
\newlength{\itemsepiii}
\newlength{\partopsepii}
\newlength{\partopsepiii}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setnzplist}
% Common code for non-zero \cs{parskip} in lists.
% \begin{macrocode}
\newcommand*{\setnzplist}{%
\partopsep \p@ \@plus\z@ \@minus\p@
\topsepi\z@
\parsepi\parskip
\itemsepi\z@
\topsepii\z@
\parsepii\parskip
\itemsepii\z@
\topsepiii\z@
%% \parsepiii\parskip
\itemsepiii\z@}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\defaultlists}
% The standard \LaTeX\ classes have list parameters that give some
% separation between lists and \cs{item}s in lists. This macro sets
% those values. This is a simplification of memoir's original, and will
% apply to any font size.
% \changes{v1.61803}{2008/01/30}{Complete replacement of \cs{defaultlists}
% (mempatch 4.5)}
% \begin{macrocode}
\newcommand*{\defaultlists}{%
\setlength{\partopsep}{0.2\onelineskip \@plus 0.1\onelineskip
\@minus 0.1\onelineskip}%
\parsepi = 0.3333\onelineskip \@plus 0.1667\onelineskip \@minus \p@
\itemsepi = \parsepi
\topsepi = 0.6667\onelineskip \@plus 0.3333\onelineskip
\@minus 0.2\onelineskip
\parsepii = 0.1667\onelineskip \@plus \p@ \@minus \p@
\topsepii = \parsepi
\topsepiii = \parsepii
\everylistparindent \listparindent
% \end{macrocode}
% Additional code to cater for non-zero \cs{parskip}s.
% \changes{v1.61803}{2008/01/30}{Modified \cs{defaultlists} for
% non-zero \cs{parskip} (memptach v4.6)}
% \begin{macrocode}
\itemsepii\parsepii
\itemsepiii\topsepiii
\partopsepiii \p@ \@plus\z@ \@minus\p@
\ifm@mnzpskip
\setnzplist
\fi}
\defaultlists
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\firmlists}
% \begin{macro}{\firmlists*}
% \begin{macro}{\m@msfirmlists}
% \begin{macro}{\m@mfirmlists}
% These give approximately half the vertical spacing of the default lists,
% with all spaces equal. The starred version allows slightly less space
% before and after the list when it is preceded by a blank line.
% \changes{v1.61803}{2008/01/30}{Added \cs{firmlists}, etc. (mempatch v4.5)}
% \begin{macrocode}
\newcommand*{\firmlists}{%
\@ifstar{\m@msfirmlists}{\m@mfirmlists}}
\newcommand*{\m@msfirmlists}{
\setlength{\partopsep}{\z@ \@plus \p@ \@minus \p@}%
\parsepi = 0.1667\onelineskip \@plus 0.0833\onelineskip \@minus \p@
\itemsepi = \parsepi
\topsepi = \parsepi
\parsepii = 0.0833\onelineskip \@plus \p@ \@minus \p@
\topsepii = \parsepi
\topsepiii = \parsepii
\everylistparindent\listparindent}
\newcommand*{\m@mfirmlists}{
\setlength{\partopsep}{0.1\onelineskip \@plus 0.05\onelineskip
\@minus 0.05\onelineskip}%
\parsepi = 0.1667\onelineskip \@plus 0.0833\onelineskip \@minus \p@
\itemsepi = \parsepi
\topsepi = \parsepi
\parsepii = 0.0833\onelineskip \@plus \p@ \@minus \p@
\topsepii = \parsepi
\topsepiii = \parsepii
\everylistparindent\listparindent}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tightlists}
% \begin{macro}{\tightlists*}
% \begin{macro}{\m@mstightlists}
% \begin{macro}{\m@mtightlists}
% This macro sets the parameters for lists that have less open vertical
% space in them. I think that these look neater than the defaults.
% Effectively, no additional vertical space is added.
% The starred version allows slightly no extra space
% before and after the list when it is preceded by a blank line,
% whereas the unstarred version puts half a \cs{onelineskip}
% before \emph{and} after.
% \changes{v1.61803}{2008/01/30}{Revised \cs{tightlists}, etc. (mempatch v4.5)}
% \changes{v1.61803}{2008/01/30}{Revised \cs{tightlists} for non-zero
% \cs{parskip}(mempatch v4.6)}
% \begin{macrocode}
\newcommand*{\tightlists}{%
\@ifstar{\m@mstightlists}{\m@mtightlists}}
\newcommand*{\m@mstightlists}{%
\setlength{\partopsep}{\z@ \@plus \p@ \@minus \p@}%
\parsepi = \z@ \@plus \p@ \@minus \p@
\itemsepi = \parsepi
\topsepi = \z@ \@plus \p@ \@minus \p@
\parsepii = \z@ \@plus \p@ \@minus \p@
\topsepii = \parsepi
\topsepiii = \parsepii
\everylistparindent\parindent
\ifm@mnzpskip
\setnzplist
\partopsepiii\partopsep
\fi}
\newcommand*{\m@mtightlists}{%
\setlength{\partopsep}{0.5\onelineskip \@plus \p@ \@minus \p@}%
\parsepi = \z@ \@plus \p@ \@minus \p@
\itemsepi = \parsepi
\topsepi = \z@ \@plus \p@ \@minus \p@
\parsepii = \z@ \@plus \p@ \@minus \p@
\topsepii = \parsepi
\topsepiii = \parsepii
\everylistparindent\parindent
\ifm@mnzpskip
\setnzplist
\partopsepiii\partopsep
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\firmlist}
% \begin{macro}{\tightlist}
% These two macros can be used at the start of a list environment to
% reduce the vertical gaps. \cs{tightlist} removes all interior spaces
% while \cs{firmlist} only removes some.
% \changes{v0.3}{2001/07/09}{Added \cs{firmlist} and reimplemented the
% original \cs{tightlist}}
% \begin{macrocode}
\newcommand{\firmlist}{%
\setlength{\itemsep}{0.5\itemsep}\setlength{\parskip}{0.5\parskip}}
\newcommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% The space before and after a \Lenv{trivlist} environment is controlled
% by the \cs{topsep} and \cs{partopsep} skips. There are several environments,
% such as \Lenv{center}, that are defined as a \Lenv{trivlist}.
%
% \begin{macro}{\m@msavetopsep}
% \begin{macro}{\m@msavepartopsep}
% \begin{macro}{\savetrivseps}
% \begin{macro}{\restoretrivseps}
% Two skips to store the \cs{topsep} and \cs{partopsep} values and a means
% of setting them and restoring them.
% \changes{v1.6}{2004/01/28}{Added methods for adjusting the space around
% a trivlist}
% \begin{macrocode}
\newskip\m@msavetopsep
\newskip\m@msavepartopsep
\newcommand*{\savetrivseps}{%
\m@msavetopsep\topsep
\m@msavepartopsep\partopsep}
\newcommand*{\restoretrivseps}{%
\topsep\m@msavetopsep
\partopsep\m@msavepartopsep}
% \end{macrocode}
% Save the initial \cs{topsep} and \cs{partopsep} values.
% \begin{macrocode}
\savetrivseps
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\zerotrivseps}
% A macro to zero \cs{topsep} and \cs{partopsep}.
% \begin{macrocode}
\newcommand*{\zerotrivseps}{%
\topsep\z@
\partopsep\z@}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@listI}
% \begin{macro}{\@listi}
% \cs{@listI} defines top level and \cs{@listi} values of
% \cs{leftmargin}, \cs{parsep}, \cs{topsep}, and \cs{itemsep}
%
% \begin{macrocode}
\def\@listi{\leftmargin\leftmargini
\parsep\parsepi
\topsep\topsepi
\itemsep\itemsepi}
\let\@listI\@listi
% \end{macrocode}
% We should initialise these parameters to the standard defaults
% \begin{macrocode}
\defaultlists
\@listi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@listii}
% \begin{macro}{\@listiii}
% \begin{macro}{\@listiv}
% \begin{macro}{\@listv}
% \begin{macro}{\@listvi}
% Here are the same macros for the lower level lists.
% \begin{macrocode}
\def\@listii{\leftmargin\leftmarginii
\labelwidth\leftmarginii
\advance\labelwidth-\labelsep
\topsep\topsepii
\parsep\parsepii
% \end{macrocode}
% \changes{v3.7g}{2016/11/22}{Typo: \cs{itemsep} should here point at
% \cs{itemsepii}, reported by Thomas Koeppe, private email}
% \begin{macrocode}
\itemsep\itemsepii}
\def\@listiii{\leftmargin\leftmarginiii
\labelwidth\leftmarginiii
\advance\labelwidth-\labelsep
\topsep\topsepiii
\parsep\z@
%%% \itemsep\topsep
%%% \partopsep \p@ \@plus\z@ \@minus\p@
\itemsep\itemsepiii
\partopsep\partopsepiii}
\def\@listiv{\leftmargin\leftmarginiv
\labelwidth\leftmarginiv
\advance\labelwidth-\labelsep}
\def\@listv{\leftmargin\leftmarginv
\labelwidth\leftmarginv
\advance\labelwidth-\labelsep}
\def\@listvi{\leftmargin\leftmarginvi
\labelwidth\leftmarginvi
\advance\labelwidth-\labelsep}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Enumerate}
%
%
% The enumerate environment uses four counters: \Lcount{enumi},
% \Lcount{enumii}, \Lcount{enumiii} and \Lcount{enumiv}, where
% \Lcount{enumN} controls the numbering of the Nth level
% enumeration.
%
% \begin{macro}{\theenumi}
% \begin{macro}{\theenumii}
% \begin{macro}{\theenumiii}
% \begin{macro}{\theenumiv}
% The counters are already defined in \file{latex.dtx}, but their
% representation is changed here.
%
% \begin{macrocode}
\renewcommand{\theenumi}{\@arabic\c@enumi}
\renewcommand{\theenumii}{\@alph\c@enumii}
\renewcommand{\theenumiii}{\@roman\c@enumiii}
\renewcommand{\theenumiv}{\@Alph\c@enumiv}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\labelenumi}
% \begin{macro}{\labelenumii}
% \begin{macro}{\labelenumiii}
% \begin{macro}{\labelenumiv}
% The label for each item is generated by the commands\\
% \cs{labelenumi} \ldots\ \cs{labelenumiv}.
% \begin{macrocode}
\newcommand{\labelenumi}{\theenumi.}
\newcommand{\labelenumii}{\theenumii)}
\newcommand{\labelenumiii}{\theenumiii.}
\newcommand{\labelenumiv}{\theenumiv.}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\p@enumii}
% \begin{macro}{\p@enumiii}
% \begin{macro}{\p@enumiv}
% The expansion of \verb?\p@enumN\theenumN? defines the output of a
% \cs{ref} command when referencing an item of the Nth level of an
% enumerated list.
% \begin{macrocode}
\renewcommand{\p@enumii}{\theenumi}
\renewcommand{\p@enumiii}{\theenumi(\theenumii)}
\renewcommand{\p@enumiv}{\p@enumiii\theenumiii}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% The following is taken directly from David Carlisle's
% \Lpack{enumerate} package.
%
% START OF DAVID CARLISLE'S CODE AND COMMENTARY
%
% This package gives the enumerate environment an optional argument
% which determines the style in which the counter is printed.
%
% An occurence of one of the tokens \verb?A a I i? or \verb?1? produces the value
% of the counter printed with (respectively) \verb?\Alph \alph \Roman \roman?
% or \cs{arabic}.
%
% These letters may be surrounded by any strings involving any other
% \TeX\ expressions, however the tokens \verb?A a I i 1? must be inside a
% \verb?{ }? group if they are not to be taken as special.
%
%
% \begin{macro}{\@enlab}
% Internal token register used to build up the label command from the
% optional argument.
% \begin{macrocode}
\newtoks\@enLab
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@enQmark}
% This just expands to a `?'. \cs{ref} will produce this, if no counter
% is printed.
% \begin{macrocode}
\def\@enQmark{?}
% \end{macrocode}
% \end{macro}
%
% The next four macros build up the command that will print the item
% label. They each gobble one token or group from the optional argument,
% and add corresponding tokens to the register \cs{@enLab}. They each end
% with a call to \cs{@enloop}, which starts the processing of the next
% token.
% \begin{macro}{\@enLabel}
% Add the counter to the label. \verb?#2? will be one of the `special'
% tokens \verb?A a I i 1?, and is thrown away. \verb?#1? will be a command
% like \cs{Roman}.
% \begin{macrocode}
\def\@enLabel#1#2{%
\edef\@enThe{\noexpand#1{\@enumctr}}%
\@enLab\expandafter{\the\@enLab\csname the\@enumctr\endcsname}%
\@enloop}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@enSpace}
% \begin{macro}{\@enSp@ce}
% Add a space to the label. The tricky bit is to gobble the space token,
% as you can not do this with a macro argument.
% \begin{macrocode}
\def\@enSpace{\afterassignment\@enSp@ce\let\@memtempa= }
\def\@enSp@ce{\@enLab\expandafter{\the\@enLab\space}\@enloop}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@enGroup}
% Add a \verb?{ }? group to the label.
% \begin{macrocode}
\def\@enGroup#1{\@enLab\expandafter{\the\@enLab{#1}}\@enloop}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@enOther}
% Add anything else to the label
% \begin{macrocode}
\def\@enOther#1{\@enLab\expandafter{\the\@enLab#1}\@enloop}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@enloop}
% \begin{macro}{\@enloop@}
% The body of the main loop.
% Eating tokens this way instead of using \cs{@tfor} lets you see
% spaces and \textbf{all} braces. \cs{@tfor} would treat \verb?a? and
% \verb?{a}? as special, but not \verb?{{a}}?.
% \begin{macrocode}
\def\@enloop{\futurelet\@entemp\@enloop@}
% \end{macrocode}
% \begin{macrocode}
\def\@enloop@{%
\ifx A\@entemp \def\@memtempa{\@enLabel\Alph }\else
\ifx a\@entemp \def\@memtempa{\@enLabel\alph }\else
\ifx i\@entemp \def\@memtempa{\@enLabel\roman }\else
\ifx I\@entemp \def\@memtempa{\@enLabel\Roman }\else
\ifx 1\@entemp \def\@memtempa{\@enLabel\arabic}\else
\ifx \@sptoken\@entemp \let\@memtempa\@enSpace \else
\ifx \bgroup\@entemp \let\@memtempa\@enGroup \else
\ifx \@enum@\@entemp \let\@memtempa\@gobble \else
\let\@memtempa\@enOther
% \end{macrocode}
% Hook for possible extensions
% \begin{macrocode}
\@enhook
% \end{macrocode}
%
% \begin{macrocode}
\fi\fi\fi\fi\fi\fi\fi\fi
% \end{macrocode}
% \end{macro}
% Process the current token, then look at the next.
% \begin{macrocode}
\@memtempa}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@enhook}
% Hook for possible extensions.
% Some packages may want to extend the number of special characters
% that are associated with counter representations. This feature
% was requested to enable Russian alphabetic counting, but here
% I give an example of a footnote symbol counter, triggered by \verb?*?.
%
% To enable a new counter type based on a letter, you just need
% to add a new \cs{ifx} clause by analogy with the code above.
% So for example to make \verb?*? trigger footnote symbol counting.
% a package should do the following.
%
% Initialise the hook, in case the package is loaded before
% \textsf{enumerate}.
%\begin{verbatim}
% \providecommand\@enhook{}
%\end{verbatim}
%
% Add to the hook a new \cs{ifx} clause that associates \verb?*? with the
% \cs{fnsymbol} counter command.
%\begin{verbatim}
% \g@addto@macro\@enhook{%
% \ifx *\@entemp
% \def\@memtempa{\@enLabel\fnsymbol}%
% \fi}
%\end{verbatim}
% This code sequence should work whether it is loaded before or after
% this enumerate package. Any number of new counter types may be added
% in this way.
%
% At this point we just need initialise the hook, taking care not
% to over write any definitions another package may already have added.
% (PRW: as this is now in a class, it can be defined instead of
% \cs{provide}d).
% \begin{macrocode}
%% \providecommand\@enhook{}
\newcommand\@enhook{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\enumerate}
% The new \Lenv{enumerate} environment. This is the first half of the
% original enumerate environment. If there is an optional argument, call
% \cs{@@enum@} to define the label commands, otherwise call
% \cs{@enum@} which is the second half of the original definition.
% \begin{macrocode}
\def\enumerate{%
\ifnum \@enumdepth >3 \@toodeep\else
\advance\@enumdepth \@ne
\edef\@enumctr{enum\romannumeral\the\@enumdepth}\fi
\@ifnextchar[{\@@enum@}{\@enum@}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@enum@}
% Handle the optional argument..
% \begin{macrocode}
\def\@@enum@[#1]{%
% \end{macrocode}
% Initialise the loop which will break apart the optional argument.
% The command to print the label is built up in \cs{@enlab}.
% \cs{@enThe} will be used to define \cs{theenum}\,$n$.
% \begin{macrocode}
\@enLab{}\let\@enThe\@enQmark
% \end{macrocode}
% The \cs{@enum@} below is never expanded, it is used to detect the end
% of the token list.
% \begin{macrocode}
\@enloop#1\@enum@
% \end{macrocode}
% Issue a warning if we did not find one of the `special' tokens.
% \begin{macrocode}
\ifx\@enThe\@enQmark\@warning{The counter will not be printed.%
^^J\space\@spaces\@spaces\@spaces The label is: \the\@enLab}\fi
% \end{macrocode}
% Define \cs{labelenum}$\,n$ and \cs{theenum}$\,n$.
% \begin{macrocode}
\expandafter\edef\csname label\@enumctr\endcsname{\the\@enLab}%
\expandafter\let\csname the\@enumctr\endcsname\@enThe
% \end{macrocode}
% Set the counter to 7 so that we get the width of `vii' if roman
% numbering is in force then set \cs{leftmargin}$\,n$. to the width of the
% label plus \cs{labelsep}.
% \begin{macrocode}
\csname c@\@enumctr\endcsname7
\expandafter\settowidth
\csname leftmargin\romannumeral\@enumdepth\endcsname
{\the\@enLab\hspace{\labelsep}}%
% \end{macrocode}
% Finally call \cs{@enum@} which is the second half of the original
% definition.
% \begin{macrocode}
\@enum@}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@enum@}
% All the list parameters have now been defined, so call \cs{list}. This
% is taken straight from the original definition of \cs{enumerate}.
% \begin{macrocode}
\def\@enum@{\list{\csname label\@enumctr\endcsname}%
{\usecounter{\@enumctr}\def\makelabel##1{\hss\llap{##1}}}}
% \end{macrocode}
% \end{macro}
%
% END OF DAVID CARLISLE'S CODE AND COMMENTARY
%
%
%
% \subsection{Itemize}
%
%
% \begin{macro}{\labelitemi}
% \begin{macro}{\labelitemii}
% \begin{macro}{\labelitemiii}
% \begin{macro}{\labelitemiii}
% Itemization is controlled by the commands: \cs{labelitemi},
% \cs{labelitemii}, etc., which define
% the labels of the various itemization levels: the symbols used are:
% bullet (\textbullet), bold en-dash (\textbf{\textendash}),
% centered asterisk (\textasteriskcentered), and centered dot
% (\textperiodcentered).
%
% \begin{macrocode}
\newcommand{\labelitemi}{\textbullet}
\newcommand{\labelitemii}{\normalfont\bfseries \textendash}
\newcommand{\labelitemiii}{\textasteriskcentered}
\newcommand{\labelitemiv}{\textperiodcentered}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% It seems like a reasonable idea to give the \Lenv{itemize} environment
% an optional argument to match \Lenv{enumerate}. Fortunately this seems
% to be much simpler and I might even be able to work it out for myself.
%
% \begin{environment}{itemize}
% This is a hack at the kernel code for \Lenv{itemize}.
% \begin{macrocode}
\renewcommand{\itemize}[1][\@empty]{%
\ifnum \@itemdepth >\thr@@\@toodeep\else
\advance\@itemdepth\@ne
\ifx \@empty #1\else % optional argument
\@namedef{labelitem\romannumeral\the\@itemdepth}{#1}%
\fi
\edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
\expandafter
\list
\csname\@itemitem\endcsname
{\def\makelabel##1{\hss\llap{##1}}}%
\fi}
\let\enditemize =\endlist
% \end{macrocode}
% \end{environment}
%
% \subsection{Description}
%
% The class defines two description environment, the standard one and a `block'
% one, and also two semi-configurable versions.
%
% \changes{v1.2}{2002/07/27}{Now two `description' environments.}
%
% \begin{environment}{description}
% The description environment is defined here -- while the default itemize
% and enumerate environments are defined in \file{latex.dtx}.
%
% \changes{v1.2}{2002/07/27}{The \texttt{description} environment now matches
% the standard layout.}
% \begin{macrocode}
\newenvironment{description}%
{\list{}{\labelwidth\z@ \itemindent-\leftmargin
\let\makelabel\descriptionlabel}}%
{\endlist}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\descriptionlabel}
% To change the formatting of the label, you must redefine
% \cs{descriptionlabel}.
%
% \begin{macrocode}
\newcommand*{\descriptionlabel}[1]{\hspace\labelsep
\normalfont\bfseries #1}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{blockdescription}
% The `block' description environment.
%
% \changes{v1.2}{2002/07/27}{Renamed original \texttt{description} environment
% to \texttt{blockdescription}.}
% \begin{macrocode}
\newenvironment{blockdescription}%
{\list{}{\labelwidth\z@ \itemindent 0.5em \labelsep 0.5em
\let\makelabel\blockdescriptionlabel}}%
{\endlist}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\blockdescriptionlabel}
% In order to change the formatting of the label, you must redefine
% the macro \cs{blockdescriptionlabel}.
%
% \begin{macrocode}
\newcommand*{\blockdescriptionlabel}[1]{%%% \hspace\labelsep
\normalfont\bfseries #1}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{labelled}
% This is a version of the description environment which takes the
% name, without the backslash, of some \cs{labelcode} as its argument.
% For example:
% \begin{verbatim}
% \newcommand*{\sflabel}[1]{\hspace\labelsep \normalfont\sffamily #1}
% \begin{labelled}{sflabel}
% \item[label] using a sans font for the labels
% \end{verbatim}
% \changes{v1.6180339f}{2009/04/25}{Added labelled environment}
% \begin{macrocode}
\newenvironment{labelled}[1]%
{\list{}{\labelwidth\z@ \itemindent-\leftmargin
\def\m@malabel{\@nameuse{#1}} \let\makelabel\m@malabel}}%
{\endlist}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{flexlabelled}
% \verb?\begin{flexlabelled}{labelcode}{labelwidth}{labelsep}{itemindent}{leftmargin}{rightmargin}?
% lets you specify some of the parameters for a description-like list.
% The first argument is as for the labelled environment. The others are all
% lengths for the various parameters; a \verb?*? instead of a length means
% that that argument is to be ignored.
% \changes{v1.6180339f}{2009/04/25}{Added flexlabelled environment}
% \begin{macrocode}
\newenvironment{flexlabelled}[6]%
{\list{}{\nametest{#2}{*}%
\ifsamename\else \labelwidth #2 \fi
\nametest{#3}{*}%
\ifsamename\else \labelsep #3 \fi
\nametest{#4}{*}%
\ifsamename\else \itemindent #4 \fi
\nametest{#5}{*}%
\ifsamename\else \leftmargin #5 \fi
\nametest{#6}{*}%
\ifsamename\else \rightmargin #6 \fi
\def\m@malabel{\@nameuse{#1}} \let\makelabel\m@malabel}}%
{\endlist}
% \end{macrocode}
% \end{environment}
%
%
% \subsection{Quotation}
%
% \begin{environment}{quotation}
% The quotation environment is defined by making clever use of
% the list environment's parameters. The lines in the environment
% are set smaller than \cs{textwidth}. The first line of a paragraph
% inside this environment is indented.
%
% \begin{macrocode}
\newenvironment{quotation}%
{\list{}{\listparindent 1.5em%
\itemindent \listparindent
\rightmargin \leftmargin
\parsep \z@ \@plus\p@}%
\item[]}%
{\endlist}
% \end{macrocode}
% \end{environment}
%
% \subsection{Quote}
%
%
% \begin{environment}{quote}
% The quote environment is like the quotation environment except
% that paragraphs are not indented.
%
% \begin{macrocode}
\newenvironment{quote}%
{\list{}{\rightmargin\leftmargin}%
\item[]}%
{\endlist}
% \end{macrocode}
% \end{environment}
%
% \subsection{Theorem}
%
% This document class does not define it's own theorem environments,
% the defaults, supplied by \file{latex.dtx} are available.
%
% \subsection{Listing of symbols and abbreviations}
%
% Another element is the listing of symbols
% and abbreviations.
%
% \begin{environment}{symbols}
% \begin{macro}{\symbollabel}
% \begin{macrocode}
\newcommand{\symbollabel}[1]{{#1 \hfill}}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\newenvironment{symbols}{\list{}%
{\itemindent 0em \leftmargin 8em
\labelsep 1em \labelwidth 5em
\let\makelabel\symbollabel}}%
{\endlist}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\symboldef}
% Within a \Lenv{symbols} environment the command
% \cs{symboldef}\marg{symbol}\marg{meaning}
% is used to specify and explain each symbol or abbreviation.
% \begin{macrocode}
\newcommand{\symboldef}[2]{\item[#1] #2}
% \end{macrocode}
% \end{macro}
%
% \section{Abstracts}
%
% Books usually do not have abstracts, but I decided to add in the code
% from the \Lpack{abstract}
% package~\cite{ABSTRACT}.
% \changes{v0.3}{2001/07/09}{Added code for abstracts}
%
%
% We just have the \Lpack{report} or \Lpack{article} style for the
% abstract with no \Lopt{titlepage} option. The original code,
% from \file{classes.dtx} for this is:
% \begin{verbatim}
% \newenvironment{abstract}{%
% \if@twocolumn
% \section*{\abstractname}
% \else
% \small
% \begin{center}%
% {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%%
% \end{center}%
% \quotation
% \fi}%
% {\if@twocolumn\else\endquotation\fi}
% \end{verbatim}
%
%
% The following \cs{if...} commands are for implementing various options.
% \begin{macro}{\if@bsonecol}
% \begin{macro}{\ifadd@bstotoc}
% \begin{macro}{\ifnumber@bs}
% \begin{macro}{\if@bsrunin}
% \begin{macrocode}
\newif\if@bsonecol
\@bsonecoltrue
\newif\ifadd@bstotoc
\add@bstotocfalse
\newif\ifnumber@bs
\number@bsfalse
\newif\if@bsrunin
\@bsruninfalse
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\abstractcol}
% \begin{macro}{\abstractintoc}
% \begin{macro}{\abstractnum}
% \begin{macro}{\abstractrunin}
% These are the use-level commands for setting the options. If
% the abstract is runin, then it must not be numbered otherwise
% adding it to the ToC might result in something peculiar.
% \begin{macrocode}
\newcommand{\abstractcol}{\@bsonecolfalse}
\newcommand{\abstractintoc}{\add@bstotoctrue}
\newcommand{\abstractnum}{\number@bstrue\@bsruninfalse}
\newcommand{\abstractrunin}{\@bsrunintrue\number@bsfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% The next set of macros comprise the
% implementation of the \Lenv{abstract} environment.
%
% \begin{macro}{\abstractnamefont}
% \begin{macro}{\abstracttextfont}
% These two macros are for specifying the fonts for typesetting the
% abstract's title and text. They are initialised for the default case
% (i.e., no class options).
% \begin{macrocode}
\newcommand{\abstractnamefont}{\normalfont\small\bfseries}
\newcommand{\abstracttextfont}{\normalfont\small}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\abscolnamefont}
% \begin{macro}{\abscoltextfont}
% These two macros are for specifying the fonts for typesetting the
% abstract's title and text in a two column document where the abstarct
% is part of a column.
% \changes{v1.61803}{2008/01/30}{Added \cs{abscolnamefont} and
% \cs{abscoltextfont} (mempatch v4.8)}
% \begin{macrocode}
\newcommand{\abscolnamefont}{\normalfont\Large\bfseries}
\newcommand{\abscoltextfont}{\normalfont}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\absnamepos}
% \begin{macro}{\abstitleskip}
% \cs{absnamepos} specifies the environment in which the abstract's title
% name will be typeset, and the length \cs{abstitleskip} is an adjustement
% to the vertical space between the title and the abstract's text. These
% are initialised for the default case.
% \begin{macrocode}
\newcommand{\absnamepos}{center}
\newlength{\abstitleskip} \setlength{\abstitleskip}{-0.5em}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\absleftindent}
% \begin{macro}{\abs@leftindent}
% \begin{macro}{\absrightindent}
% \begin{macro}{\absparindent}
% \begin{macro}{\absparsep}
% The abstract's text is typeset as a single item list, called
% \texttt{@bstr@ctlist}. These lengths set the left and right margin indents, the
% paragraph indentation, and the inter-paragraph vertical space. Their
% initial values are all class option-dependent.
% \changes{v1.618}{2005/09/03}{Added \cs{abs@leftindent} per Lars Madsen (mempatch v3.0)}
% \begin{macrocode}
\newlength{\absleftindent}
\absleftindent=\leftmargin
\newdimen\abs@leftindent
\abs@leftindent=\leftmargin
\newlength{\absrightindent}
\absrightindent=\leftmargin
\newlength{\absparindent}
\newlength{\absparsep}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\abslabeldelim}
% \begin{macro}{\@bslabeldelim}
% The contents of \cs{abslabeldelim} are typeset after a run-in heading.
% \begin{macrocode}
\newcommand{\abslabeldelim}[1]{\def\@bslabeldelim{#1}}
\abslabeldelim{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@bsrunintitle}
% This macro typeset the run-in heading.
% \begin{macrocode}
\newcommand{\@bsrunintitle}{%
\hspace*{\abstitleskip}{\abstractnamefont\abstractname\@bslabeldelim}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setup@bstract}
% Now arrange to set all the class option-dependent values.
% \changes{v1.618}{2005/09/03}{Used \cs{abs@leftindent} in \cs{setup@bstract} (mempatch v3.0)}
% \changes{v1.61803}{2008/01/30}{Changed \cs{setup@bstract} to cater for
% \cs{abscolnamefont}, etc., and don't set
% \cs{absrightindent} to \cs{absleftindent}.}
% \begin{macrocode}
\newcommand{\setup@bstract}{%
\abs@leftindent=\absleftindent
\if@twocolumn
% \end{macrocode}
% Values for the \Lopt{twocolumn} class option.
% \begin{macrocode}
\if@bsonecol
\else
\abs@leftindent=\z@
\absrightindent=\z@
\renewcommand*{\abstractnamefont}{\abscolnamefont}
\renewcommand*{\abstracttextfont}{\abscoltextfont}
\renewcommand*{\absnamepos}{flushleft}
\setlength{\abstitleskip}{-2ex}
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\AtBeginDocument{\setlength{\absparindent}{\parindent}
\setlength{\absparsep}{\parskip}}
% \end{macrocode}
%
% \begin{environment}{@bstr@ctlist}
% The abstract's text is typeset within the \Lenv{@bstr@ctlist} list environment.
% \changes{v1.618}{2005/09/03}{Used \cs{abs@leftindent} in \cs{@bstr@ctlist} (mempatch v3.0)}
% \begin{macrocode}
\newenvironment{@bstr@ctlist}{%
\list{}{%
%%\topsep \z@
\partopsep \z@
\listparindent \absparindent
\itemindent \listparindent
\leftmargin \abs@leftindent
\rightmargin \absrightindent
\parsep \absparsep}%
\item\relax}
{\endlist}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\put@bsintoc}
% This macro adds the abstract's title to the ToC. It does nothing if
% the abstract is being numbered.
% \begin{macrocode}
\newcommand{\put@bsintoc}{%
\ifadd@bstotoc
\ifnumber@bs\else
\phantomsection
\addcontentsline{toc}{chapter}{\abstractname}
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\num@bs}
% This macro generates a numbered abstract heading.
% \begin{macrocode}
\newcommand{\num@bs}{\chapter{\abstractname}}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{abstract}
% At last we are in position to define the \Lenv{abstract} environment. This
% follows very much along the lines of the standard class definitions, but with
% macros inserted at strategic points.
%
% The \Lopt{twocolumn} option and the default case. These use the same code
% as any style differences are embedded in the new macros.
% \begin{macrocode}
\newenvironment{abstract}{%
\setup@bstract
\if@bsrunin\else
\ifnumber@bs \num@bs \else
\begin{\absnamepos}\abstractnamefont\abstractname\end\absnamepos%
\vspace{\abstitleskip}%
\fi
\fi
\put@bsintoc%
\begin{@bstr@ctlist}\if@bsrunin\@bsrunintitle\fi\abstracttextfont}%
{\par\end{@bstr@ctlist}}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{onecolabstract}
% An environment for typesetting a single column abstract,
% particularly as the optional argument to the \cs{twocolumn} command.
% \begin{macrocode}
\newenvironment{onecolabstract}{%
\begin{@twocolumnfalse}\begin{abstract}}{%
\end{abstract}\end{@twocolumnfalse}}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\thanks}
% \begin{macro}{\@bs@thanks}
% We have to keep the contents of the \cs{thanks} commands as normally these
% are emptied by the \cs{maketitle} command. I do this by extending the definition
% of the \cs{thanks} (from \file{ltsect.dtx}) command,
% so that \cs{@bs@thanks} has a copy of the contents
% of \cs{@thanks}.
% \begin{macrocode}
\addtoiargdef{\thanks}{}{%
\protected@xdef\@bs@thanks{\@bs@thanks
\protect\footnotetext[\the\c@footnote]{#1}}%
}
\let\@bs@thanks\@empty
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\saythanks}
% This macro typesets any \cs{thanks} commands \emph{after} using
% \texttt{onecolabstract}.
% \begin{macrocode}
\newcommand{\saythanks}{\begingroup
\renewcommand{\thefootnote}{\fnsymbol{footnote}}\@bs@thanks
\endgroup\global\let\@bs@thanks\@empty}
% \end{macrocode}
% \end{macro}
%
%
% \section{Verse}
%
% The class provides a more flexible \Lenv{verse} environment than the
% standard classes. This is based on the \Lpack{verse}
% package~\cite{VERSE}.
% \changes{v1.0}{2001/10/30}{Complete rewrite of verse typesetting}
%
% \subsection{Environments}
%
% Before proceeding with the main, here are some macros for aspects
% of line numbering.
%
% \begin{macro}{\c@vslineno}
% \begin{macro}{\c@poemline}
% \begin{macro}{\c@modulo@vs}
% \begin{macro}{\c@memfvsline}
% We need counters for stanza and poem lines. The \texttt{memfvsline}
% counter is for adjusting the starting line for verse line numbers.
% \changes{v1.1}{2002/03/10}{Added poemline and modulo@vs counters}
% \changes{v1.61803}{2008/01/30}{Added memfvsline counter (mempatch v4.9)}
% \begin{macrocode}
\newcounter{vslineno}
\newcounter{poemline}
\newcounter{modulo@vs}
\newcounter{memfvsline}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\poemlines}
% \cs{poemlines}\marg{nth} specifies that every \meta{nth} line of
% a poem is to be numbered.
% \changes{v1.1}{2002/03/10}{Added \cs{poemlines}}
% \changes{v1.2}{2002/07/27}{\cs{poemlines} now just calls \cs{linenumberfrequency}}
% \changes{v1.61803}{2008/01/30}{Deleted \cs{poemlines}.}
% \begin{macrocode}
%%%\newcommand{\poemlines}[1]{\linenumberfrequency{#1}%
%%% \@memwarn{Use \string\linenumberfrequency\space
%%% instead of \string\poemlines}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\linenumberfont}
% \begin{macro}{\vlvnumfont}
% Set line numbering font(s).
% \begin{macrocode}
\newcommand{\linenumberfont}[1]{\def\vlvnumfont{#1}}
%%% \linenumberfont{\small\rmfamily}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifbvcountlines}
% \begin{macro}{\bvcountlinestrue}
% \begin{macro}{\bvcountlinesfalse}
% Looking ahead, TRUE for (boxed) verbatim line numbers to be printed. Default
% is not to print them. Not that \cs{linenumberfrequency} twiddles with this.
% \begin{macrocode}
\newif\ifbvcountlines% TRUE to print line numbers of (boxed) verbatim lines
\bvcountlinesfalse
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\linenumberfrequency}
% \begin{macro}{\linemodnum}
% Set numbering intervals (number modulo). Default is modulus 0.
% \begin{macrocode}
\newcommand{\linenumberfrequency}[1]{%
\ifnum #1< \@ne
\def\linemodnum{0\relax}
\bvcountlinesfalse
\else
\def\linemodnum{#1\relax}
\bvcountlinestrue
\fi}
%%%%\linenumberfrequency{0}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setverselinenums}
% \cs{setverselinenums}\marg{firstline}\marg{startnumsat} sets the first line
% number to \meta{firstline} and the first line number to be printed is
% \meta{startnumsat}. Use within the \Lenv{verse} environment before the
% first verse. Note that \\
% \verb?firstline <= startnumsat < firstline + linenumberfrequency?
% \changes{v1.61803}{2008/01/30}{Added \cs{setverselinenums} (mempatch v4.9)}
% \begin{macrocode}
\newcommand*{\setverselinenums}[2]{%
\c@poemline #1\relax \advance\c@poemline \m@ne
\refstepcounter{poemline}%
\ifnum\z@<\linemodnum% we are printing line numbers
\@tempcnta #2\relax
\divide\@tempcnta\linemodnum
\multiply\@tempcnta\linemodnum
\c@memfvsline #2\relax
\advance\c@memfvsline-\@tempcnta
\fi}
% \end{macrocode}
% \end{macro}
%
% \changes{v1.1}{2002/03/24}{Added \cs{getmodulo@vs}}
% \changes{v1.2}{2002/07/27}{Using \cs{getthelinenumber} instead of \cs{getmodulo@vs}}
%
% \begin{macro}{\getthelinenumber}
% \cs{getthelinenumber}\marg{counter}\marg{start} returns \cs{thecounter}
% if it is exactly divisible by \cs{linenumberfrequency}, provided this is
% not zero. \meta{start} is the first number.
% \changes{v1.61802}{2008/01/30}{Generalised \cs{getthelinenumber} to cater
% for set of first line number.}
% \begin{macrocode}
\newcommand{\getthelinenumber}[2]{%
\ifnum\@ne>\linemodnum% no line numbers
\else
\ifnum\@ne=\linemodnum% every line numbered
\@nameuse{the#1}%
\else
\@tempcnta=\@nameuse{c@#1}%
\advance\@tempcnta -\@nameuse{c@#2}%
\divide\@tempcnta \linemodnum
\multiply\@tempcnta \linemodnum
\advance\@tempcnta \@nameuse{c@#2}%
\ifnum\@tempcnta=\@nameuse{c@#1}\@nameuse{the#1}\fi
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifaltindent}
% This should be set TRUE for indenting alternate lines.
% \begin{macrocode}
\newif\ifaltindent
\altindentfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifpattern}
% This should be set TRUE for indenting lines according to a pattern.
% \begin{macrocode}
\newif\ifpattern
\patternfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifstarpattern}
% This should be set TRUE for indenting lines according in a \Lenv{patverse*}
% environment.
% \changes{v1.1}{2002/03/8}{Added \cs{ifstarpattern}}
% \begin{macrocode}
\newif\ifstarpattern
\starpatternfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\vleftskip}
% \begin{macro}{\vrightskip}
% Skips to the left and right of a line of verse.
% \changes{v1.1}{2002/03/24}{Added \cs{vleftskip} and \cs{vrightskip}}
% \changes{v1.2}{2002/07/27}{Changed defaults for \cs{vleftskip} and \cs{vrightskip}}
% \begin{macrocode}
\newlength{\vleftskip}
\setlength{\vleftskip}{3em}
\newlength{\vrightskip}
\setlength{\vrightskip}{1em}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\stanzaskip}
% Skip between stanzas.
% \changes{v1.2}{2002/07/07}{Added \cs{stanzaskip}}
% \begin{macrocode}
\newlength{\stanzaskip}
\setlength{\stanzaskip}{\onelineskip}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\flagverse}
% \cs{flagverse}\marg{flag} inserts \meta{flag} at the left (of a line).
% \changes{v1.1}{2002/03/24}{Added \cs{flagverse}}
% \changes{v1.61803398}{2009/07/17}{Added bidi suport to \cs{flagverse}}
% \begin{macrocode}
\newcommand{\flagverse}[1]{%
%%% \hskip-\vleftskip\llap{#1}\hskip\vleftskip\ignorespaces}
\hskip-\memRTLvleftskip\llap{#1}\hskip\memRTLvleftskip\ignorespaces}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\versewidth}
% The length \cs{versewidth} is a convenience length for the user.
% \begin{macrocode}
\newlength{\versewidth}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\vgap}
% \begin{macro}{\vin}
% \begin{macro}{\vindent}
% The length \cs{vgap} is used as the basis for spacing. \cs{vin} makes
% a horizontal space of \cs{vgap} and \cs{vindent} is the indentation
% of wrapped lines.
% \begin{macrocode}
\newlength{\vgap} \setlength{\vgap}{1.5em}
\newcommand{\vin}{\hspace*{\vgap}}
\newlength{\vindent} \setlength{\vindent}{2\vgap}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\vinphantom}
% Macro to leave blank space coresponding to a string.
% \changes{v1.4}{2003/02/27}{Added \cs{vinphantom} (patch 1.1)}
% \begin{macrocode}
\newcommand{\vinphantom}[1]{\leavevmode\phantom{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\vleftofline}
% Macro to insert something immediately to the left of the start
% of the line.
% \changes{v1.618}{2005/09/14}{Added \cs{vleftofline}}
% \begin{macrocode}
\newcommand*{\vleftofline}[1]{\leavevmode\llap{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\vleftmargin}
% Length to adjust the default left margin within a verse environment.
% \changes{v1.618}{2005/09/18}{Added \cs{vleftmargin}}
% \begin{macrocode}
\newdimen\vleftmargin
\vleftmargin=\leftmargini
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verselinebreak}
% Break a verse line by inserting \cs{newline}.
% \changes{v1.1}{2002/03/28}{Modified \cs{verselinebreak}}
% \changes{v1.61803}{2008/01/30}{Removed extraneous space from \cs{verselinebreak} (mempatch v4.4, Aaron Rendahl)}
% \begin{macrocode}
\newcommand{\verselinebreak}[1][\z@]{\newline\hspace*{#1}\ignorespaces}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\incr@vsline}
% Increment the line counters.
% \changes{v1.1}{2002/03/24}{Added poemline counter to \cs{incr@vsline}}
% \begin{macrocode}
\newcommand{\incr@vsline}{%
\refstepcounter{poemline}%
\stepcounter{vslineno}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@vsifbang}
% Like the kernel \cs{@ifstar} except it looks for an exclamation mark!
% \changes{v1.1}{2002/03/24}{Added \cs{@vsifbang}}
% \begin{macrocode}
\newcommand{\@vsifbang}[1]{\@ifnextchar !{\@firstoftwo{#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@vsifgt}
% Like the kernel \cs{@ifstar} except it looks for a \verb?>? character.
% \changes{v1.1}{2002/03/28}{Added \cs{@vsifgt}}
% \begin{macrocode}
\newcommand{\@vsifgt}[1]{\@ifnextchar >{\@firstoftwo{#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verselinenumbersright}
% \begin{macro}{\verselinenumbersleft}
% \begin{macro}{\@vstypelinenum}
% Declarations for setting line numbers at the right (the default)
% or the left..
% \changes{v1.61803}{2008/01/30}{Added \cs{verselinenumbersright} and
% \cs{verselinenumbersleft} (mempatch v4.4, v4.9)}
% \begin{macrocode}
\newcommand*{\verselinenumbersright}{\def\@vstypelinenum{\@vslnumright}}
\newcommand*{\verselinenumbersleft}{\def\@vstypelinenum{\@vslnumleft}}
\verselinenumbersright
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@vslnumright}
% \begin{macro}{\@vslnumleft}
% Internal code for right/left line numbers.
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{@vslnumright}
% and \cs{@vslnumleft}}
% \changes{v3.7g}{2018/02/28}{Added \cs{nobreak} to both
% \cs{@vslnumright} and \cs{@vslnumleft}, reported on
% \protect\url{https://tex.stackexchange.com/a/415939/3929}, to avoid strange
% double line breaks}
% \begin{macrocode}
\newcommand*{\@vslnumright}{%
\nobreak%
\hfill\rlap{%\kern\vrightskip\kern\rightmargin%
\kern\memRTLvrightskip\kern\rightmargin%
\vlvnumfont\getthelinenumber{poemline}{memfvsline}}}
\newcommand*{\@vslnumleft}{%
\nobreak%
\hfill\rlap{%\kern-\textwidth\kern-\vrightskip%
\kern-\textwidth\kern-\memRTLvrightskip%
\vlvnumfont\getthelinenumber{poemline}{memfvsline}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@vscentercr}
% This puts the poem line number in the margin, increments
% the line numbers, and then deals with the options. It is based
% on the kernel \cs{@centercr}.
% This has to handle various forms of the \verb?\\? command: \verb?\\?,
% \verb?\\*?, \verb?\\!?, and \verb?\\>?, together with an optional length argument.
% \changes{v1.1}{2002/03/28}{Major rewrite of \cs{@vscentercr} and friends}
% \changes{v1.2}{2002/07/27}{Changed \cs{@vscentercr} to use general
% linenumbering}
% \changes{v1.61803}{2008/01/30}{Changed \cs{@vscentercr} for left/right numbers
% (mempatch v4.4)}
% \begin{macrocode}
\newcommand{\@vscentercr}{%
\ifhmode \unskip\else \@nolnerr\fi
\@vstypelinenum%
% \end{macrocode}
% For \verb?>? call \cs{verselinebreak} to process it.
% \begin{macrocode}
\@vsifgt{\verselinebreak}{%
\incr@vsline
% \end{macrocode}
% If the call is \verb?\\*...? call \cs{@vsxcentercr} to handle the \verb?*...?.
% If the call is \verb?\\!?, do nothing.
% If the call is \verb?\\![...]?, call \cs{@vsicentercr} to handle the \verb?[...]?.
% Otherwise, call \cs{@vsxcentercr}.
% \begin{macrocode}
\par\@ifstar{\nobreak\@vsxcentercr}{%
% \end{macrocode}
% \begin{macrocode}
\@vsifbang{\@ifnextchar[ {\@vsicentercr}{}}{\@vsxcentercr}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@vsxcentercr}
% Processes \verb?\\*?, and either calls cs{@vsicentercr} to handle a \verb?[length]?,
% or \cs{start@vsline}.
% \changes{v1.1}{2002/03/24}{Added \cs{@vsxcentercr}}
% \begin{macrocode}
\newcommand{\@vsxcentercr}{\addvspace{-\parskip}%
\@ifnextchar[ {\@vsicentercr}{\start@vsline}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@vsicentercr}
% Processes \verb?(\\...)[length]? and then calls \cs{start@vsline}.
% \changes{v1.1}{2002/03/24}{Added \cs{@vsicentercr}}
% \begin{macrocode}
\def\@vsicentercr[#1]{\vskip #1\ignorespaces \start@vsline}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\start@vsline}
% This is called at the start of every verse line except the first.
% \changes{v1.1}{2002/03/28}{Added \cs{ifstarpattern} to \cs{start@vsline}}
% \changes{v1.61}{2004/03/21}{Used counter for vslineno, not \cs{thevslineno}
% in \cs{start@vsline}}
% \begin{macrocode}
\newcommand{\start@vsline}{%
\ifaltindent\ifodd\c@vslineno\else\vin\fi\fi%
\ifpattern\get@vsindent\fi%
\ifstarpattern\getstar@vsindent\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\theHpoemline}
% For the \Lpack{hyperref} package need a way of distinguishing
% lines of a poem. See the thread \textit{PDFTEX/Hyperef hates memoir verse
% environment?} on \ctt{} October 2002.
% \changes{v1.3}{2002/11/14}{Added verse counter and \cs{theHpoemline}}
% \changes{v3.7.19}{2022/10/25}{Changing \cs{theH...} definitions to
% \cs{def} for better compability with future hyperref}
% \begin{macrocode}
\newcounter{verse}
\setcounter{verse}{0}
\def\theHpoemline{\theverse.\thepoemline}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{verse}
% The extended \Lenv{verse} environment. It sets the verse line counter,
% then defines the particular list environment adjusting the margins
% to center according to the length parameter. If the length parameter
% is at least the \cs{linewidth} then the `centering' defaults to
% the original \Lenv{verse} layout.
% \changes{v1.1}{2001/08/03}{Initialise the line counter to 1, not 0, in
% all cases}
% \changes{v1.1}{2002/03/28}{Changes to verse environment for line numbering}
% \changes{v1.3}{2002/11/14}{Changes to verse environment for hyperref}
% \changes{v1.4}{2002/02/27}{Let verses wider than the \cs{linewidth}
% take the full width (patch(1.1)}
% \changes{v1.618}{2005/09/03}{Fix vertical spacing in the verse environment (mempatch v3.3)}
% \begin{macrocode}
\newenvironment{verse}[1][\linewidth]{%
\refstepcounter{verse}%
\setcounter{poemline}{0}\refstepcounter{poemline}%
\setcounter{vslineno}{1}%
\let\\=\@vscentercr
\list{}{\itemsep \z@
\itemindent -\vindent
\listparindent\itemindent
\leftmargin \vleftmargin
\parsep \stanzaskip
\ifdim #1<\linewidth% %% short line
\rightmargin \z@
\leftmargin \linewidth
\advance\leftmargin -#1\relax
\advance\leftmargin -0.5\leftmargin
\advance\leftmargin \vindent
\else
\ifdim #1>\linewidth% %% long line
\rightmargin \z@
\leftmargin \vindent
\else% %% default
\rightmargin \leftmargin
\advance\leftmargin \vindent
\fi
\fi}
\item[]}{\endlist}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{altverse}
% This sets \cs{altindenttrue} (afterwards false) and initialises the line counter.
% \changes{v1.1}{2002/03/28}{Added \cs{starpatternfalse} to altverse}
% \begin{macrocode}
\newenvironment{altverse}%
{\starpatternfalse\patternfalse\altindenttrue
\setcounter{vslineno}{1}}%
{\altindentfalse}
% \end{macrocode}
% \end{environment}
%
%
% \subsection{Patterns}
%
% The pattern code is based on the idea of converting a string of
% digits to an array of digits, and then being able to access the
% digit at a particular position in the array.
%
%
% \begin{macro}{\ifbounderror}
% A flag set TRUE if an attempt is made to access an array element outside
% the array limits.
% \begin{macrocode}
\newif\ifbounderror
\bounderrorfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifinteger}
% A flag to indicate if a `number' is an integer (TRUE) or not (FALSE).
% \begin{macrocode}
\newif\ifinteger
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@chrsinstr}
% A counter for the number of characters.
% \begin{macrocode}
\newcounter{chrsinstr} % CHARactersINSTRing
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\newarray}
% \cs{newarray}\marg{arrayname}\marg{low}\marg{high} defines
% an array called \meta{arrayname} (no backslash e.g. \verb?MyArray?),
% with low and high limts \meta{low} and \meta{high}.
% \begin{macrocode}
\newcommand{\newarray}[3]{%
\@nameedef{#1-low}{#2}%
\@nameedef{#1-high}{#3}%
\ifnum #3<#2
\@memerror{Limits for array #1 are in reverse order}{\@ehc}%
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\stringtoarray}
% \cs{stringtoarray}\marg{arrayname}\marg{string} puts each character
% from \meta{string} sequentially into the \meta{arrayname} array, starting
% with \meta{low} = 1. It checks for an empty \meta{string} and handles that
% specially.
% \begin{macrocode}
\newcommand{\stringtoarray}[2]{%
\def\@vsarrayname{#1}%
\protected@edef\the@vsstring{#2}%
\newarray{\@vsarrayname}{1}{1}%
\@ifmtarg{#2}{%
\c@chrsinstr \z@
\@namedef{\@vsarrayname-1}{}
}{%
\c@chrsinstr \@ne
\expandafter\@vsstringtoarray \the@vsstring\@vsend
}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@vsstringtoarray}
% Recursively adds characters to the array \cs{@vsarrayname}, incrementing
% the array's high limit.
% \begin{macrocode}
\def\@vsstringtoarray #1#2\@vsend{%
\@namedef{\@vsarrayname-\the\c@chrsinstr}{#1}
\@nameedef{\@vsarrayname-high}{\the\c@chrsinstr}
\@ifmtarg{#2}{%
\def\@vsinext{}%
}{%
\advance\c@chrsinstr \@ne
\def\@vsinext{%
\@vsstringtoarray #2\@vsend%
}%
}
\@vsinext}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\setarrayelement}
% \cs{setarrayelement}\marg{arrayname}\marg{index}\marg{value} sets
% the \meta{arrayname} array's element at \meta{index} to \meta{value}.
% \begin{macrocode}
\newcommand{\setarrayelement}[3]{%
\checkarrayindex{#1}{#2}%
\@nameedef{#1-#2}{#3}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\getarrayelement}
% \cs{getarrayelement}\marg{arrayname}\marg{index}\marg{value}
% defines the parameterless macro \meta{value} (e.g., \cs{result}) to be
% the value at \meta{index} in the \meta{arrayname} array.
% \begin{macrocode}
\newcommand{\getarrayelement}[3]{%
\checkarrayindex{#1}{#2}%
\protected@edef#3{\@nameuse{#1-#2}}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\checkarrayindex}
% \cs{checkarrayindex}\marg{arrayname}\marg{index} checks that
% the \meta{index} of the \meta{arrayname} array is valid. \cs{ifbounderror}
% is set FALSE if everything is OK, otherwise it is set TRUE.
% \begin{macrocode}
\newcommand{\checkarrayindex}[2]{%
\bounderrorfalse
\expandafter\ifx\csname #1-low\endcsname\relax%
\ifpattern\else
\@memerror{No array called #1}{\@ehc}%
\fi
\bounderrortrue
\fi
\ifnum #2<\@nameuse{#1-low}\relax%
\ifpattern\else
\@memerror{Index #2 outside limits for array #1}{\@ehc}%
\fi
\bounderrortrue
\fi
\ifnum #2>\@nameuse{#1-high}\relax%
\ifpattern\else
\@memerror{Index #2 outside limits for array #1}{\@ehc}%
\fi
\bounderrortrue
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\arraytostring}
% \cs{arraytostring}\marg{arrayname}\marg{string} converts the
% characters in the \meta{arrayname} array into the parameterless macro
% \meta{string} (e.g., \cs{MyString}).
% \begin{macrocode}
\newcommand{\arraytostring}[2]{%
\def#2{}%
\c@chrsinstr = \@nameuse{#1-low}%
\@vsarraytostring{#1}{#2}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@vsarraytostring}
% \cs{@vsarraytostring}\marg{arrayname}\marg{string} recursively
% adds the (character) elements from \meta{arrayname} to \meta{string}.
% \begin{macrocode}
\newcommand{\@vsarraytostring}[2]{%
\ifnum\c@chrsinstr>\@nameuse{#1-high}\else
\protected@edef#2{#2\@nameuse{#1-\thechrsinstr}}%
\advance\c@chrsinstr\@ne%
\@vsarraytostring{#1}{#2}%
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\checkifinteger}
% \cs{checkifinteger}\marg{num} checks if \meta{num} is an integer.
% If it is, then \cs{ifinteger} is set TRUE, otherwise it is set FALSE.
% (Code based on Donald Arseneau's \Lpack{cite} package).
% \begin{macrocode}
\newcommand{\checkifinteger}[1]{%
\protected@edef\@vsa{#1}%
\ifcat _\ifnum9<1\gobm{#1} _\else A\fi
\integertrue%
\else
\integerfalse%
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gobm}
% \cs{gobm}\marg{num} is defined as \meta{num}. It could be defined as: \\
% \verb?\newcommand{\gobm}[1]{\ifx-#1\expandafter\gobm\else#1\fi}? \\
% which would remove a leading minus sign (hyphen) from its argument
% (\verb?gobm? = gobble minus sign).
% (Code from a posting to \ctt{} by Donald Arseneau on 1997/07/21).
% \begin{macrocode}
\newcommand{\gobm}[1]{#1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\indentpattern}
% \cs{indentpattern}\marg{digits} stores \meta{digits} for use as
% a verse indentation pattern.
% \begin{macrocode}
\newcommand{\indentpattern}[1]{%
\stringtoarray{Array@vs}{#1}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\get@vsindent}
% \cs{get@vsindent} gets the indent pattern digit for the \cs{thevslineno},
% then uses this to specify the line indentation as \verb?digit*\vgap?.
% \changes{v1.61}{2004/03/21}{Changed \cs{get@vsindent} to use counter
% value number instead of \cs{thevslineno}}
% \begin{macrocode}
\newcommand{\get@vsindent}{%
\getarrayelement{Array@vs}{\number\value{vslineno}}{\@vspat}%
\ifbounderror
\arraytostring{Array@vs}{\@vsp@t}%
\@memwarn{%
Index `\thevslineno' for pattern `\@vsp@t' is out of bounds}%
\def\@vspat{0}%
\else
\checkifinteger{\@vspat}%
\ifinteger\else
\arraytostring{Array@vs}{\@vsp@t}%
\@memwarn{%
`\@vspat' at index `\thevslineno' in pattern `\@vsp@t'
is not a digit}%
\def\@vspat{0}%
\fi
\fi
\ifcase\@vspat\else\hspace*{\@vspat\vgap}\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\getstar@vsindent}
% \cs{getstar@vsindent} gets the indent pattern digit for the \Lenv{patverse*}
% environment,
% then uses this to specify the line indentation as \verb?digit*\vgap?.
% It lets the pattern repeat by resetting the \texttt{vslineno} counter.
% \changes{v1.1}{2002/03/28}{Added \cs{getstar@vsindent}}
% \begin{macrocode}
\newcommand{\getstar@vsindent}{%
\expandafter\ifx\csname Array@vs-high\endcsname\relax
\@memerror{A pattern has not been specified}{\@ehc}
\else
\ifnum\c@vslineno>\@nameuse{Array@vs-high}%
\setcounter{vslineno}{1}%
\fi
\get@vsindent
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{environment}{patverse}
% The environment for setting verse line indents according to a pattern.
% It starts by setting \cs{ifpattern} TRUE, any other flags to FALSE,
% and initialises the line number. It ends by setting \cs{ifpattern} FALSE.
% \changes{v1.1}{2002/03/28}{Added \cs{starpatternfalse} to patverse}
% \begin{macrocode}
\newenvironment{patverse}%
{\starpatternfalse\patterntrue\altindentfalse
\setcounter{vslineno}{1}}%
{\patternfalse}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{patverse*}
% The environment for setting verse line indents according to a repeating
% pattern.
% It starts by setting \cs{ifstarpattern} TRUE, any other flags to FALSE,
% and initialises the line number. It ends by setting \cs{ifstarpattern} FALSE.
% \changes{v1.1}{2002/03/28}{Added patverse* environment}
% \begin{macrocode}
\newenvironment{patverse*}%
{\starpatterntrue\patternfalse\altindentfalse
\setcounter{vslineno}{1}}%
{\starpatternfalse}
% \end{macrocode}
% \end{environment}
%
%
% \subsection{Titles}
%
% \begin{macro}{\poemtitle}
% Typeset a poem title (like \cs{section} or other). The actual work
% is done by \cs{@vsptitle} (plain) or \cs{@vssptitle} (starred).
% \begin{macrocode}
\newcommand{\poemtitle}{\par%
\secdef\@vsptitle\@vssptitle}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\poemtoc}
% The kind of entry \cs{poemtitle} is to make in the ToC.
% \begin{macrocode}
\newcommand{\poemtoc}{section}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mempoeminfo}
% \begin{macro}{\mempoemstarinfo}
% \verb?\mempoeminfo{title}? \\
% \verb?\mempoemstarinfo{title}? \\
% \changes{v1.61803}{2008/01/30}{Made \cs{mempoeminfo} and fiends \cs{long}
% (mempatch v4.9)}
% \begin{macrocode}
\newcommand{\mempoeminfo}[1]{}
\newcommand{\mempoemstarinfo}[1]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@vsptitle}
% Typeset a \cs{poemtitle}.
% \changes{v1.3}{2002/11/14}{Added \cs{phantomsection} to \cs{@vsptitle}}
% \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@vsptitle}}
% \begin{macrocode}
\long\def\@vsptitle[#1]#2{%
\phantomsection
\addcontentsline{toc}{\poemtoc}{#1}%
\M@gettitle{#1}%
\mempoeminfo{#1}%
\poemtitlemark{#1}%
\@vstypeptitle{#2}%
\@afterheading}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@vssptitle}
% Typeset a \cs{poemtitle*}.
% \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@vssptitle}}
% \begin{macrocode}
\long\def\@vssptitle#1{%
\M@gettitle{#1}%
\mempoemstarinfo{#1}%
\@vstypeptitle{#1}%
\@afterheading}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@vstypeptitle}
% This \emph{really} typesets the title.
% \begin{macrocode}
\newcommand{\@vstypeptitle}[1]{%
\vspace{\beforepoemtitleskip}%
{\poemtitlefont #1\par}%
\vspace{\afterpoemtitleskip}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\poemtitlefont}
% \begin{macro}{\poemtitlemark}
% Sets the appearance to the title of a poem, and something for a header.
% \begin{macrocode}
\newcommand{\poemtitlefont}{\normalfont\large\bfseries\centering}
\newcommand{\poemtitlemark}[1]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\beforepoemtitleskip}
% \begin{macro}{\afterpoemtitleskip}
% Lengths before and after a poem title, using approximately \cs{section}
% values.
% \begin{macrocode}
\newlength{\beforepoemtitleskip}
\setlength{\beforepoemtitleskip}{3.5ex \@plus 1ex \@minus .2ex}
\newlength{\afterpoemtitleskip}
\setlength{\afterpoemtitleskip}{2.3ex \@plus.2ex}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\if@numptitle}
% \begin{macro}{\@numptitletrue}
% \begin{macro}{\@numptitlefalse}
% \begin{macro}{\NumberPoemTitle}
% \begin{macro}{\PlainPoemTitle}
% Following the \cs{NumberPoemTitle} declaration \cs{PoemTitle}s are numbered.
% The \cs{PlainPoemTitle} declaration produces unnumbered titles.
% \begin{macrocode}
\newif\if@numptitle
\newcommand*{\NumberPoemTitle}{\@numptitletrue}
\newcommand*{\PlainPoemTitle}{\@numptitlefalse}
\NumberPoemTitle
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@poem}
% \begin{macro}{\thepoem}
% \begin{macro}{\theHpoem}
% Counter for poem titles.
% \begin{macrocode}
\newcounter{poem}\setcounter{poem}{0}
\renewcommand*{\thepoem}{\@arabic\c@poem}
\newcommand*{\theHpoem}{\arabic{poem}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\poemtitlestarmark}
% \begin{macro}{\poemtitlepstyle}
% \begin{macro}{\poemtitlestarpstyle}
% \cs{poemtitlemark}\marg{poemf@rhdr} is used for marks for a \cs{PoemTitle} and
% \cs{poemtitlestarmark}\marg{poemf@hdr} is for marks for \cs{PoemTitle*}.
% The \cs{poemtitlepstyle} and \cs{poemtitlestarpstyle} macros are provided
% as hooks so that, for example, pagestyles can be set for the regular
% and starred versions of \cs{PoemTitle}. By default these macros do nothing.
% \begin{macrocode}
\newcommand*{\poemtitlestarmark}[1]{}
\newcommand*{\poemtitlepstyle}{}
\newcommand*{\poemtitlestarpstyle}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\PoemTitle}
% The command to produce a article style chapter-like (numbered) poem title.
% \changes{v1.618}{2005/09/09}{Added \cs{PoemTitle}}
% \begin{macrocode}
\newcommand\PoemTitle{%
\par
\@afterindentfalse
\@ifstar{\@m@msPoemTitle}{\@m@mPoemTitle}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@m@mPoemTitle}
% \begin{macro}{\poemt@c}
% Intermediate and support macros for the extra optional argument
% to \cs{PoemTitle}. Have to do this long windedly otherwise dear old
% \Lpack{hyperref} barfs.
% \begin{macrocode}
\newcommand{\@m@mPoemTitle}[1][]{%
\def\poemt@c{#1}% capture first optional arg
\@ifnextchar[{\@PoemTitle}{\@PoemTitle[]}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memPoemTitleinfo}
% \begin{macro}{\memPoemTitlestarinfo}
% \verb?\memPoemTitleinfo{num}{toc}{head}{full}? \\
% \verb?\memPoemTitlestarinfo{short}{full}?
% \begin{macrocode}
\newcommand{\memPoemTitleinfo}[4]{}
\newcommand{\memPoemTitlestarinfo}[2]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@PoemTitle}
% \begin{macro}{\poemf@rtoc}
% \begin{macro}{\poemf@rhdr}
% \cs{@PoemTitle}\oarg{tocmark}\marg{title}
% typesets the title of a \cs{PoemTitle}.
% There is a number for \cs{@numptitletrue} and \cs{@mainmattertrue}.
% \begin{macrocode}
\def\@PoemTitle[#1]#2{%
\phantomsection
\ifx\poemt@c\@empty % no optional args
\def\poemf@rtoc{#2}%
\def\poemf@rhdr{#2}%
\else % at least one opt arg
\let\poemf@rtoc\poemt@c
\ifx\@empty#1\@empty
\let\poemf@rhdr\poemt@c
\else
\def\poemf@rhdr{#1}%
\fi
\fi
\m@m@Andfalse
\if@numptitle
\if@mainmatter
\m@m@Andtrue
\fi
\fi
\ifm@m@And
\refstepcounter{poem}%
\fi
% \end{macrocode}
% Store the (short) title via \cs{poemtitlemark} and call
% \cs{\@makePoemTitlehead} to do the typesetting.
% \begin{macrocode}
\@makePoemTitlehead{#2}%
\@afterheading
\poemtitlemark{\poemf@rhdr}%
\poemtitlepstyle
% \end{macrocode}
% Add the title to the ToC.
% \begin{macrocode}
\ifm@m@And
\addcontentsline{toc}{\poemtoc}{%
\protect\numberline{\thepoem}\poemf@rtoc}%
\memPoemTitleinfo{\thepoem}{\poemf@rtoc}{\poemf@rhdr}{#2}%
\else
\addcontentsline{toc}{\poemtoc}{\poemf@rtoc}%
\memPoemTitleinfo{}{\poemf@rtoc}{\poemf@rhdr}{#2}%
\fi
% \end{macrocode}
% Add hook for title referencing.
% \begin{macrocode}
\ifheadnameref\M@gettitle{\poemf@rhdr}\else\M@gettitle{\poemf@rtoc}\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@makePoemTitlehead}
% This \emph{really} typesets a \cs{PoemTitle}. Leave some whitespace.
% \begin{macrocode}
\def\@makePoemTitlehead#1{{%
\PoemTitleheadstart
\parindent \z@ \normalfont
% \end{macrocode}
% If there is a number, typeset it, otherwise call \cs{printPoemTitlenonum}.
% \begin{macrocode}
\ifm@m@And
\printPoemTitlenum
\afterPoemTitlenum
\else
\printPoemTitlenonum
\fi
% \end{macrocode}
% Typeset the title.
% \begin{macrocode}
\interlinepenalty\@M
\printPoemTitletitle{#1}%
\afterPoemTitle}}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\@PTchs@def@ult}
% This sets up all the definitions used in \cs{@makePoemTitlehead}
% and \cs{@makesPoemTitlehead}.
% \begin{macro}{\PoemTitleheadstart}
% \begin{macro}{\printPoemTitlenum}
% \begin{macro}{\afterPoemTitlenum}
% \begin{macro}{\printPoemTitlenonum}
% \begin{macro}{\printPoemTitletitle}
% \begin{macro}{\afterPoemTitle}
% \begin{macrocode}
\newcommand{\@PTchs@def@ult}{%
\def\PoemTitleheadstart{\vspace{\beforePoemTitleskip}}
\def\printPoemTitlenum{\PoemTitlenumfont \thepoem}
\def\afterPoemTitlenum{\par\nobreak\vskip \midPoemTitleskip}
\def\printPoemTitlenonum{}
\def\printPoemTitletitle##1{\PoemTitlefont ##1}
\def\afterPoemTitle{\par\nobreak\vskip \afterPoemTitleskip}}
\@PTchs@def@ult
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\PoemTitlenumfont}
% \begin{macro}{\PoemTitlefont}
% Fonts for setting the Poem Title number and title.
% \begin{macrocode}
\newcommand*{\PoemTitlenumfont}{\normalfont\large\centering}
\newcommand*{\PoemTitlefont}{\normalfont\large\centering}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\beforePoemTitleskip}
% \begin{macro}{\midPoemTitleskip}
% \begin{macro}{\afterPoemTitleskip}
% Lengths separating the various parts of a Poem Title heading.
% \begin{macrocode}
\newlength{\beforePoemTitleskip}
\setlength{\beforePoemTitleskip}{1\onelineskip}
\newlength{\midPoemTitleskip}
\setlength{\midPoemTitleskip}{0pt}
\newlength{\afterPoemTitleskip}
\setlength{\afterPoemTitleskip}{1\onelineskip}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@m@msPoemTitle}
% This deals with the optional argument for starred PoemTitles.
% \begin{macrocode}
\newcommand{\@m@msPoemTitle}[2][\@empty]{%
\@sPoemTitle{#2}%
\ifx \@empty#1
\def\poemf@rhdr{#2}%
\else % opt arg
\def\poemf@rhdr{#1}%
\fi
\poemtitlestarmark{\poemf@rhdr}%
\poemtitlestarpstyle
\memPoemTitlestarinfo{\poemf@rhdr}{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sPoemTitle}
% \cs{@sPoemTitle}\marg{long} typesets the title of a
% \cs{PoemTitle*}. It is easier than the \cs{@PoemTitle} as there is no number
% or ToC entry to worry about.
% \begin{macrocode}
\newcommand{\@sPoemTitle}[1]{%
\@makesPoemTitlehead{#1}%
\@afterheading
\M@gettitle{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makesPoemTitlehead}
% This \emph{really} typesets a \cs{PoemTitle*}, and is similar to
% \cs{@makePoemTitlehead}.
% \begin{macrocode}
\def\@makesPoemTitlehead#1{{%
\PoemTitleheadstart
\parindent \z@ \normalfont
\printPoemTitlenonum
\interlinepenalty\@M
\printPoemTitletitle{#1}
\afterPoemTitle}}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \section{Setting parameters for existing environments}
%
% \subsection{Array and tabular}
%
% \begin{macro}{\arraycolsep}
% The columns in an array environment are separated by
% 2\cs{arraycolsep}.
% \begin{macrocode}
\setlength\arraycolsep{5\p@}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tabcolsep}
% The columns in an tabular environment are separated by
% 2\cs{tabcolsep}.
% \begin{macrocode}
\setlength\tabcolsep{6\p@}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\arrayrulewidth}
% The width of rules in the array and tabular environments is given
% by\\ \cs{arrayrulewidth}.
% \begin{macrocode}
\setlength\arrayrulewidth{.4\p@}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\doublerulesep}
% The space between adjacent rules in the array and tabular
% environments is given by \cs{doublerulesep}.
% \begin{macrocode}
\setlength\doublerulesep{2\p@}
% \end{macrocode}
% \end{macro}
%
% \subsection{Tabbing}
%
% \begin{macro}{\tabbingsep}
% This controls the space that the \verb?\'? command puts in. (See
% \LaTeX{} manual for an explanation.)
% \begin{macrocode}
\setlength\tabbingsep{\labelsep}
% \end{macrocode}
% \end{macro}
%
% \subsection{Minipage}
%
% \begin{macro}{\@minipagerestore}
% The macro \cs{@minipagerestore} is called upon entry to a minipage
% environment to set up things that are to be handled differently
% inside a minipage environment. In the standard styles it does
% nothing, as was the case originally for memoir.
%
% Memoir extends it to support verbatim footnotes (see later) in minipages
% and also for abnormal parskips (see later).
% \changes{v1.61803}{2008/01/30}{Collected \cs{@minipagerestore} modifications together}
% \begin{macrocode}
\newcommand{\@minipagerestore}{%
% \end{macrocode}
% For \cs{verbfootnote} to work in a minipage we have to use
% \cs{@verbmpfootnotetext} instead of \cs{@verbfootnotetext}.
% \begin{macrocode}
\let\@verbfootnotetext\@verbmpfootnotetext
% \end{macrocode}
% The next is for enabling the extended footnotes in a minipage.
% \begin{macrocode}
\m@mdoextrafeetmini
% \end{macrocode}
% And this is for abnormal parskips.
% \begin{macrocode}
\ifm@mnzpskip \parskip=\m@mabparskip\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mpfootins}
% Minipages have their own footnotes; \verb?\skip\@mpfootins? plays
% the same r\^ole for footnotes in a minipage as \verb?\skip\footins? does
% for ordinary footnotes.
%
% \begin{macrocode}
\skip\@mpfootins = \skip\footins
% \end{macrocode}
% \end{macro}
%
% \subsection{Framed boxes}
%
% \begin{macro}{\fboxsep}
% The space left by \cs{fbox} and \cs{framebox} between the box and the
% text in it.
% \begin{macro}{\fboxrule}
% The width of the rules in the box made by \cs{fbox} and \cs{framebox}.
% \begin{macrocode}
\setlength\fboxsep{3\p@}
\setlength\fboxrule{.4\p@}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Equation and eqnarray}
%
% \begin{macro}{\theequation}
% The equation counter will be reset at beginning of a new chapter
% and the equation number will be prefixed by the chapter number.
%
% This code must follow the \cs{chapter} definition, or more exactly
% the definition of the chapter counter.
% \begin{macrocode}
\@addtoreset{equation}{chapter}
\renewcommand{\theequation}{%
\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@equation}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\jot}
% \cs{jot} is the extra space added between lines of an eqnarray
% environment. The default value is used.
% \begin{macrocode}
% \setlength\jot{3pt}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@eqnnum}
% The macro \cs{@eqnnum} defines how equation numbers are to appear in
% equations. Again the default is used.
%
% \begin{macrocode}
% \def\@eqnnum{(\theequation)}
% \end{macrocode}
% \end{macro}
%
%
% \section{Array and tabularx}
%
% \subsection{Array}%
%
% Here ealier versions of the class had an embedded copy of the
% \Lpack{array} package. Now replaced by requiring the packge instead.
% \begin{macrocode}
\RequirePackage{array}[2018/04/30]
% \end{macrocode}
% The embeded copy is outcommented for now and will be removed in a
% later version.
%
% \changes{v3.7h}{2018/09/06}{Outcommented the embedded copy of
% \Lpack{array} and replaced it with requiring the \Lpack{array} package
% instead.}
%
% ^^A % The description and code are essentially copied from the \Lpack{array}
% ^^A package~\cite{ARRAY}.
% ^^A
% \begin{macrocode}
%
% %%%%%%%%%% Array package code %%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%% With acknowledgements to %%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%% Frank Mittelbach & David Carlisle %%%%%%%%%%%%%%%%%%%%%
%
% %%%%%%%%%% Copy corresponds to array.sty 2016/10/06 v2.4d %%%%%%%%%
% \end{macrocode}
% ^^A \changes{v3.7g}{2018/03/05}{Updated the embedded copy of the
% ^^A \Lpack{array} package to version 2.4d, 2016/10/06}
% ^^A \begin{dlf}
% ^^A dlf: The \Lpack{array} package has redundant code (caused by a
% ^^A quick mashing of and earlier \Lpack{array} version and the
% ^^A \Lpack{newaray} package). In thus update (2018/03/05) this
% ^^A redundant code is \emph{not} removed as it makes it very hard to
% ^^A see where there are class changes to the \Lpack{array} code, and
% ^^A when stuff is simply removed. We'll leave it up to the LaTeXteam to
% ^^A clean up the \Lpack{array} code at some point.
% ^^A
% ^^A The following is a carbon copy of the DTX code from
% ^^A \verb|array.dtx|, package specific \cs{changes} lines have been
% ^^A removed, and we have made any error/warning messages class specific,
% ^^A instead of package specific.
% ^^A \end{dlf}
% ^^A
% ^^A
% ^^A \subsubsection{The construction of the preamble}
% ^^A
% ^^A It is obvious that those environments will consist mainly of an
% ^^A \verb=\halign=, because \TeX\ typesets tables using this primitive.
% ^^A That is why we will now take a look at the algorithm which determines
% ^^A a preamble for a \verb=\halign= starting with a given user preamble
% ^^A using the options mentioned above.
% ^^A
% ^^A The most interesting macros of this implementation are without doubt
% ^^A those which are responsible for the construction of the preamble for
% ^^A the \verb=\halign=. The underlying algorithm was developed by
% ^^A \textsc{Lamport} (resp.\ \textsc{Knuth}, see texhax V87\#??), and it
% ^^A has been extended and improved.
% ^^A
% ^^A The user preamble will be read \textsf{token} by \textsf{token}. A
% ^^A \textsf{token} is a single character like \texttt{c} or a block
% ^^A enclosed in \verb={...}=. For example the preamble of
% ^^A \verb=\begin{tabular}=\linebreak[0]\verb={lc||c@{\hspace{1cm}}}= consists of
% ^^A the \textsf{token} \texttt{l}, \texttt{c}, \texttt{|}, \texttt{|},
% ^^A \texttt{@} and \verb=\hspace{1cm}=.
% ^^A
% ^^A The currently used \textsf{token} and the one, used before, are needed
% ^^A to decide on how the construction of the preamble has to be
% ^^A continued.
% ^^A In the example mentioned above the \texttt{l} causes the preamble
% ^^A to begin with \verb=\hskip\tabcolsep=. Furthermore
% ^^A \verb=# \hfil= would be appended to define a flush left column.
% ^^A The next \textsf{token} is a \texttt{c}. Because it was preceded by an
% ^^A \texttt{l} it generates a new column. This is done with
% ^^A \verb=\hskip \tabcolsep & \hskip \tabcolsep=. The column which is to
% ^^A be centered will be appended with \verb=\hfil # \hfil=.
% ^^A The \textsf{token} \texttt{|} would then add a space of
% ^^A \verb=\hskip \tabcolsep=
% ^^A and a vertical line because the last
% ^^A \textsf{tokens} was a \texttt{c}.
% ^^A The following \textsf{token} \texttt{|} would only add a space
% ^^A \verb=\hskip \doublerulesep= because it was preceded by the
% ^^A \textsf{token} \texttt{|}. We will not discuss our example further but
% ^^A rather take a look at the general case of constructing preambles.
% ^^A
% ^^A The example shows that the desired preamble for the
% ^^A \verb=\halign= can be constructed as soon as the action of all
% ^^A combinations
% ^^A of the preamble \textsf{tokens} are specified. There are 18 such
% ^^A \textsf{tokens}
% ^^A so we have $19 \cdot 18 = 342$ combinations if we count the
% ^^A beginning of
% ^^A the preamble as a special \textsf{token}. Fortunately, there are many
% ^^A combinations which generate the same spaces, so we can define
% ^^A \textsf{token} classes. We will identify a
% ^^A \textsf{token} within a class with a number, so we can insert the
% ^^A formatting (for example of a column).
% ^^A Table~\ref{tab:Klassen} lists all \textsf{token} classes and
% ^^A their corresponding numbers.
% ^^A \begin{table}[ht]
% ^^A \begin{center}
% ^^A \begin{tabular}[t]{>{\ttfamily}ccc}
% ^^A \textsf{token} & \verb=\@chclass= & \verb=\@chnum= \\[2mm]
% ^^A c & 0 & 0 \\
% ^^A l & 0 & 1 \\
% ^^A r & 0 & 2 \\
% ^^A p-arg & 0 & 3 \\
% ^^A t-arg & 0 & 4 \\
% ^^A b-arg & 0 & 5 \\
% ^^A | & 1 & 0 \\
% ^^A !-arg & 1 & 1 \\
% ^^A <-arg & 2 & --- \\
% ^^A >-arg & 3 & ---
% ^^A \end{tabular}
% ^^A \kern3mm \vrule \kern3mm%
% ^^A \begin{tabular}[t]{>{\ttfamily}ccc}
% ^^A \textsf{token} & \verb=\@chclass= & \verb=\@chnum= \\[2mm]
% ^^A Start & 4 & --- \\
% ^^A @-arg & 5 & --- \\
% ^^A ! & 6 & --- \\
% ^^A @ & 7 & --- \\
% ^^A < & 8 & --- \\
% ^^A > & 9 & --- \\
% ^^A p & 10 & 3 \\
% ^^A t & 10 & 4 \\
% ^^A b & 10 & 5
% ^^A \end{tabular}
% ^^A \end{center}
% ^^A \caption{Classes of preamble \textsf{tokens}}
% ^^A \label{tab:Klassen}
% ^^A \end{table}
% ^^A
% ^^A
% ^^A \begin{macro}{\@chclass}
% ^^A \begin{macro}{\@chnum}
% ^^A \begin{macro}{\@lastchclass}
% ^^A The class and the number of the current \textsf{token} are saved in
% ^^A the
% ^^A \textsf{count} registers \verb=\@chclass=
% ^^A and \verb=\@chnum=, while the class of the previous
% ^^A \textsf{token} is stored in the
% ^^A \textsf{count} register \verb=\@lastchclass=.
% ^^A All of the mentioned registers are already allocated in
% ^^A \texttt{latex.tex},
% ^^A which is the reason why the following three lines of code are
% ^^A commented out.
% ^^A Later throughout the text I will not mention it again explicitly
% ^^A whenever I use a \verb=%= sign. These parts are already defined in
% ^^A \texttt{latex.tex}.
% \begin{macrocode}
% % \newcount \@chclass
% % \newcount \@chnum
% % \newcount \@lastchclass
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A \begin{macro}{\@addtopreamble}
% ^^A We will save the already constructed preamble for
% ^^A the \verb=\halign=
% ^^A in the global macro \verb=\@preamble=. This will then be
% ^^A enlarged with
% ^^A the command \verb=\@addtopreamble=.
% \begin{macrocode}
% \def\@addtopreamble#1{\xdef\@preamble{\@preamble #1}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A
% ^^A
% ^^A \subsubsection{The character class of a \textsf{token}}
% ^^A
% ^^A \begin{macro}{\@testpach}
% ^^A With the help of \verb=\@lastchclass= we can now define a macro
% ^^A which determines the class and the number of a given preamble
% ^^A \textsf{token}
% ^^A and assigns them to the registers
% ^^A \verb=\@chclass= and \verb=\@chnum=.
% \begin{macrocode}
% \def\@testpach{\@chclass
% \end{macrocode}
% ^^A First we deal with the cases in which the \textsf{token}
% ^^A (\verb=#1=) is the argument of \texttt{!}, \texttt{@}, \texttt{<} or
% ^^A \texttt{>}. We can see this from the value of \verb=\@lastchclass=:
% \begin{macrocode}
% \ifnum \@lastchclass=6 \@ne \@chnum \@ne \else
% \ifnum \@lastchclass=7 5 \else
% \ifnum \@lastchclass=8 \tw@ \else
% \ifnum \@lastchclass=9 \thr@@
% \end{macrocode}
% ^^A Otherwise we will assume that the \textsf{token} belongs to the
% ^^A class $0$
% ^^A and assign the corresponding number to \verb=\@chnum= if our
% ^^A assumption is correct.
% \begin{macrocode}
% \else \z@
% \end{macrocode}
% ^^A If the last \textsf{token} was a \texttt{p}, \texttt{m} or a
% ^^A \texttt{b}, \verb=\@chnum= already has the right value. This is the
% ^^A reason for the somewhat curious choice of the \textsf{token}
% ^^A numbers in class $10$.
% \begin{macrocode}
% \ifnum \@lastchclass = 10 \else
% \end{macrocode}
% ^^A Otherwise we will check if \verb=\@nextchar= is either a \texttt{c},
% ^^A \texttt{l} or an \texttt{r}. Some applications change the
% ^^A catcodes of certain characters like ``\texttt{@}'' in
% ^^A \texttt{amstex.sty}. As a result the tests below would fail since
% ^^A they assume non-active character tokens. Therefore we evaluate
% ^^A \verb=\@nextchar= once thereby turning the first token of its
% ^^A replacement text into a char. At this point here this should have
% ^^A been the only char present in \verb=\@nextchar= which put into via a
% ^^A \verb=\def=.
% \begin{macrocode}
% \edef\@nextchar{\expandafter\string\@nextchar}%
% \@chnum
% \if \@nextchar c\z@ \else
% \if \@nextchar l\@ne \else
% \if \@nextchar r\tw@ \else
% \end{macrocode}
% ^^A If it is a different \textsf{token}, we know that the class was
% ^^A not $0$. We assign the value $0$ to \verb=\@chnum= because this value
% ^^A is needed for the \texttt{|}--\textsf{token}. Now we must check
% ^^A the remaining classes. Note that the value of \verb=\@chnum= is
% ^^A insignificant here for most classes.
% \begin{macrocode}
% \z@ \@chclass
% \if\@nextchar |\@ne \else
% \if \@nextchar !6 \else
% \if \@nextchar @7 \else
% \if \@nextchar <8 \else
% \if \@nextchar >9 \else
% \end{macrocode}
% ^^A The remaining permitted \textsf{tokens} are \texttt{p},
% ^^A \texttt{m} and \texttt{b} (class $10$).
% \begin{macrocode}
% 10
% \@chnum
% \if \@nextchar m\thr@@\else
% \if \@nextchar p4 \else
% \if \@nextchar b5 \else
% \end{macrocode}
% ^^A Now the only remaining possibility is a forbidden \textsf{token},
% ^^A so we choose class $0$ and number $0$ and give an error message.
% ^^A Then we finish the macro by closing all \verb=\if='s.
% \begin{macrocode}
% \z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi
% \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A
% ^^A
% ^^A \subsubsection{Multiple columns ($*$--form)}
% ^^A
% ^^A \begin{macro}{\@xexpast}
% ^^A \begin{macro}{\the@toks}
% ^^A \begin{macro}{\the@toksz}
% ^^A \label{@xexpast} Now we discuss the macro that deletes all forms
% ^^A of type \verb=*{=\textit{N\/}\verb=}{=\textit{String\/}\verb=}= from a user
% ^^A preamble and replaces them with \textit{N} copies of
% ^^A \textit{String}. Nested $*$--expressions are dealt with
% ^^A correctly, that means $*$--expressions are not substituted if
% ^^A they are in explicit braces, as in \verb=@{*}=.
% ^^A
% ^^A This macro is called via
% ^^A \verb=\@xexpast=\meta{preamble}\verb=*0x\@@=.
% ^^A The $*$--expression \verb=*0x= is being used to terminate the
% ^^A recursion,
% ^^A as we shall see later, and \verb=\@@= serves as an argument
% ^^A delimiter. \verb=\@xexpast= has four arguments. The first
% ^^A one is the part of the
% ^^A user preamble before the first $*$--expression while the second
% ^^A and third ones are the arguments of the first $*$--expression
% ^^A (that is \textit{N} and \textit{String} in the notation mentioned
% ^^A above).
% ^^A The fourth argument is the rest of the preamble.
% \begin{macrocode}
% \def\@xexpast#1*#2#3#4\@@{%
% \end{macrocode}
% ^^A The number of copies of \textit{String} (\verb=#2=) that are to be
% ^^A produced will be saved in a \textsf{count} register.
% \begin{macrocode}
% \@tempcnta #2
% \end{macrocode}
% ^^A We save the part of the preamble which does not
% ^^A contain a $*$--form (\verb=#1=)
% ^^A in a \PlainTeX\ \textsf{token} register.
% ^^A We also save \textit{String} (\verb=#3=) using a \LaTeX\
% ^^A \textsf{token} register.
% \begin{macrocode}
% \toks@={#1}\@temptokena={#3}%
% \end{macrocode}
% ^^A Now we have to use a little trick to produce \textit{N} copies of
% ^^A \textit{String}.
% ^^A We could try \verb=\def\@tempa{#1}= and then
% ^^A \textit{N} times \verb=\edef\@tempa{\@tempa#3}=. This would have the
% ^^A undesired effect that all macros within \verb=#1= and \verb=#3=
% ^^A would be expanded, although, for example, constructions like
% ^^A \verb=@{..}= are not supposed to be changed.
% ^^A That is why we \verb=\let= two control sequences to
% ^^A be equivalent to \verb=\relax=.
% \begin{macrocode}
% \let\the@toksz\relax \let\the@toks\relax
% \end{macrocode}
% ^^A Then we ensure that \verb=\@tempa= contains
% ^^A \verb={\the@toksz\the@toks...\the@toks}= (the macro
% ^^A \verb=\the@toks= exactly \textit{N\/} times) as substitution text.
% \begin{macrocode}
% \def\@tempa{\the@toksz}%
% \ifnum\@tempcnta >0 \@whilenum\@tempcnta >0\do
% {\edef\@tempa{\@tempa\the@toks}\advance \@tempcnta \m@ne}%
% \end{macrocode}
% ^^A If \textit{N\/} was greater than zero we prepare for another call
% ^^A of \verb=\@xexpast=. Otherwise we assume we have reached the end of
% ^^A the user preamble, because we had appended \verb=*0x\@@= when we first
% ^^A called \verb=\@xexpast=. In other words: if the user inserts
% ^^A \verb=*{0}{..}= in his preamble, \LaTeX\ ignores the rest of it.
% \begin{macrocode}
% \let \@tempb \@xexpast \else
% \let \@tempb \@xexnoop \fi
% \end{macrocode}
% ^^A Now we will make sure that the part of the user preamble, which
% ^^A was already dealt with, will be saved again in \verb=\@tempa=.
% \begin{macrocode}
% \def\the@toksz{\the\toks@}\def\the@toks{\the\@temptokena}%
% \edef\@tempa{\@tempa}%
% \end{macrocode}
% ^^A We have now evaluated the first $*$--expression, and the user
% ^^A preamble up to this point
% ^^A is saved in \verb=\@tempa=. We will put the contents of
% ^^A \verb=\@tempa= and the rest of the user preamble together and work
% ^^A on the result with \verb=\@tempb=. This macro either corresponds
% ^^A to \verb=\@xexpast=, so that the next
% ^^A $*$--expression is handled, or to the macro \verb=\@xexnoop=,
% ^^A which only ends the recursion by deleting its argument.
% \begin{macrocode}
% \expandafter \@tempb \@tempa #4\@@}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@xexnoop}
% ^^A So the first big problem is solved. Now it is easy to
% ^^A specify \verb=\@xexnoop=.
% ^^A Its argument is delimited by \verb=\@@= and it simply expands to
% ^^A nothing.
% \begin{macrocode}
% % \def\@xexnoop#1\@@{}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A
% ^^A \subsubsection{The insertion of declarations
% ^^A (\texttt{>}, \texttt{<}, \texttt{!}, \texttt{@})}
% ^^A
% ^^A
% ^^A The preamble will be enlarged with the help of \verb=\xdef=, but the
% ^^A arguments of \texttt{>}, \texttt{<},~\texttt{!}\ and \texttt{@} are
% ^^A not supposed to be expanded during the construction (we want an
% ^^A implementation that doesn't need a \verb=\protect=). So we have to find a
% ^^A way to inhibit the expansion of those arguments.
% ^^A
% ^^A We will solve this problem with \textsf{token} registers. We need
% ^^A one register for every \texttt{!}\ and \texttt{@}, while we need two
% ^^A for every \texttt{c}, \texttt{l}, \texttt{r}, \texttt{m}, \texttt{p}
% ^^A or \texttt{b}. This limits the number of columns of a table because
% ^^A there are only 256 \textsf{token} registers. But then, who needs
% ^^A tables with more than 100 columns?
% ^^A
% ^^A One could also find a solution which only needs two or three
% ^^A \textsf{token} registers by proceeding similarly as in the macro
% ^^A \verb=\@xexpast= (see page \pageref{@xexpast}). The advantage of our
% ^^A approach is the fact that we avoid some of the problems that arise
% ^^A with the other method\footnote{Maybe there are also historical
% ^^A reasons.}.
% ^^A
% ^^A So how do we proceed? Let us assume that we had \verb=!{foo}= in the
% ^^A user preamble and say we saved \texttt{foo} in
% ^^A \textsf{token} register $5$. Then we call
% ^^A \verb=\@addtopreamble{\the@toks5}= where
% ^^A \verb=\the@toks= is defined in a way that it does not expand
% ^^A (for example it could be equivalent to \verb=\relax=). Every
% ^^A following call
% ^^A of \verb=\@addtopreamble= leaves \verb=\the@toks5= unchanged in
% ^^A \verb=\@preamble=. If the construction of the preamble is completed
% ^^A we change the definition of \verb=\the@toks= to
% ^^A \verb=\the\toks= and expand \verb=\@preamble= for the last time.
% ^^A During this process all parts of the form
% ^^A \verb=\the@toks=\meta{Number}
% ^^A will be substituted by the contents of the respective \textsf{token}
% ^^A registers.
% ^^A
% ^^A As we can see from this informal discussion the construction of the
% ^^A preamble has to take place within a group, so that the
% ^^A \textsf{token} registers we use will be freed later on. For that
% ^^A reason we keep all assignments to \verb=\@preamble= global; therefore the
% ^^A replacement text of this macro will remain the same after we leave
% ^^A the group.
% ^^A
% ^^A \begin{macro}{\count@}
% ^^A We further need a \textsf{count} register to remember which
% ^^A \textsf{token} register is to be used next. This will be
% ^^A initialized with $-1$ if we want to begin with the \textsf{token}
% ^^A register $0$. We use the \PlainTeX\ scratch register \verb=\count@=
% ^^A because everything takes place locally. All we have to do is
% ^^A insert \verb=\the@toks= \verb=\the= \verb=\count@= into the preamble.
% ^^A \verb=\the@toks= will remain unchanged and \verb=\the\count@= expands into
% ^^A the saved number.
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\prepnext@tok}
% ^^A The macro \verb=\prepnext@tok= is in charge of preparing the next
% ^^A \textsf{token} register. For that purpose we increase
% ^^A \verb=\count@= by $1$:
% \begin{macrocode}
% \def\prepnext@tok{\advance \count@ \@ne
% \end{macrocode}
% ^^A Then we locally delete any contents the
% ^^A \textsf{token} register might have.
% \begin{macrocode}
% \toks\count@{}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\save@decl}
% ^^A During the construction of the preamble the current
% ^^A \textsf{token} is always saved in the macro \verb=\@nextchar= (see the
% ^^A definition of \verb=\@mkpream= on page \pageref{@mkpream}). The macro
% ^^A \verb=\save@decl= saves it into the next free \textsf{token} register,
% ^^A i.e.\ in \verb=\toks\count@=.
% \begin{macrocode}
% \def\save@decl{\toks\count@ \expandafter{\@nextchar}}
% \end{macrocode}
% ^^A The reason for the use of \verb=\relax= is the following
% ^^A hypothetical situation in the preamble:
% ^^A \quad \verb=..\the\toks1\the\toks2..= \quad \TeX\ expands
% ^^A \verb=\the\toks2= first in order to find out if the digit \verb=1=
% ^^A is followed by other digits. E.g.\ a \verb=5= saved in the
% ^^A \textsf{token} register $2$ would lead \TeX\ to insert the contents
% ^^A of \textsf{token} register $15$ instead of $1$ later on.
% ^^A
% ^^A The example above referred to an older version of \verb=\save@decl= which
% ^^A inserted a \verb=\relex= inside the token register. This is now moved to
% ^^A the places where the actual token registers are inserted (look for
% ^^A \verb=\the@toks=) because the old version would still make= @=
% ^^A expressions to moving arguments since after expanding the second
% ^^A register while looking for the end of the number the contents of the
% ^^A token register is added so that later on the whole register will be
% ^^A expanded. This serious bug was found after nearly two years
% ^^A international use of this package by Johannes Braams.
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A How does the situation look like, if we want to add another column
% ^^A to the preamble, i.e.\ if we have found a \texttt{c}, \texttt{l},
% ^^A \texttt{r}, \texttt{p}, \texttt{m} or \texttt{b} in the user
% ^^A preamble? In this case we have the problem of the \textsf{token}
% ^^A register from \verb=>{..}= and \verb=<{..}= having to be inserted at this
% ^^A moment because formatting instructions like \verb=\hfil= have to be set
% ^^A around them. On the other hand it is not known yet, if any \verb=<{..}=
% ^^A instruction will appear in the user preamble at all.
% ^^A
% ^^A We solve this problem by adding two \textsf{token} registers at a
% ^^A time. This explains, why we have freed the \textsf{token} registers
% ^^A in \verb=\prepnext@tok=.
% ^^A
% ^^A \begin{macro}{\insert@column}
% ^^A \begin{macro}{\@sharp}
% ^^A We now define the macro \verb=\insert@column= which will do
% ^^A this work for us.
% \begin{macrocode}
% \def\insert@column{%
% \end{macrocode}
% ^^A Here, we assume that the \textsf{count} register
% ^^A \verb=\@tempcnta= has saved the value $\verb=\count@= - 1$.
% \begin{macrocode}
% \the@toks \the \@tempcnta
% \end{macrocode}
% ^^A Next follows the \verb=#= sign which specifies the place
% ^^A where the text of the column shall be inserted. To avoid
% ^^A errors during the expansions in
% ^^A \verb=\@addtopreamble= we hide this sign in the command
% ^^A \verb=\@sharp= which is temporarily occupied with
% ^^A \verb=\relax= during the build-up of the preamble.
% ^^A To remove unwanted spaces before and after the column text, we set
% ^^A an \verb=\ignorespaces= in front and a \verb=\unskip= afterwards.
% \begin{macrocode}
% \ignorespaces \@sharp \unskip
% \end{macrocode}
% ^^A Then the second \textsf{token} register follows whose number should
% ^^A be saved in \verb=\count@=.
% ^^A We make sure that there will be no further expansion after reading
% ^^A the number, by finishing with \verb=\relax=. The case above is not
% ^^A critical since it is ended by \verb=\ignorespaces=.
% \begin{macrocode}
% \the@toks \the \count@ \relax}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A
% ^^A \subsubsection{The separation of columns}
% ^^A
% ^^A \begin{macro}{\@addamp}
% ^^A In the preamble a \verb=&= has to be inserted between any two columns;
% ^^A before the first column there should not be a \verb=&=. As the user
% ^^A preamble may start with a \texttt{|} we have to remember somehow
% ^^A if we have already inserted a \verb=#= (i.e.\ a column). This is done
% ^^A with the boolean variable \verb=\if@firstamp= that we test in
% ^^A \verb=\@addamp=, the macro that inserts the \verb=&=.
% \begin{macrocode}
% % \newif \@iffirstamp
% % \def\@addamp{\if@firstamp \@firstampfalse
% % \else \@addtopreamble &\fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@acol}
% ^^A \begin{macro}{\@acolampacol}
% ^^A \begin{macro}{\col@sep}
% ^^A We will now define some abbreviations for the extensions,
% ^^A appearing most often in the preamble build-up.
% ^^A Here \verb=\col@sep= is a \textsf{dimen} register which is set
% ^^A equivalent to \verb=\arraycolsep= in an \textsf{array}--environment,
% ^^A otherwise it is set equivalent to \verb=\tabcolsep=.
% \begin{macrocode}
% \newdimen\col@sep
% \def\@acol{\@addtopreamble{\hskip\col@sep}}
% % \def\@acolampacol{\@acol\@addamp\@acol}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \subsubsection{The macro \texttt{\textbackslash @mkpream}}
% ^^A
% ^^A \begin{macro}{\@mkpream}
% ^^A \begin{macro}{\the@toks}
% ^^A \label{@mkpream}
% ^^A Now we can define the macro which builds up the preamble for the
% ^^A \verb=\halign=.
% ^^A First we initialize \verb=\@preamble=, \verb=\@lastchclass=
% ^^A and the boolean variable \verb=\if@firstamp=.
% \begin{macrocode}
% \def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
% \end{macrocode}
% ^^A During the build-up of the preamble we cannot directly use the
% ^^A \verb=#= sign; this would lead to an error message in the next
% ^^A \verb=\@addtopreamble= call.
% ^^A Instead, we use the command \verb=\@sharp= at places where later
% ^^A a \verb=#= will be.
% ^^A This command is at first given the meaning \verb=\relax=;
% ^^A therefore it will not be expanded when the preamble
% ^^A is extended.
% ^^A In the macro \verb=\@array=, shortly before the \verb=\halign=
% ^^A is carried out, \verb=\@sharp= is given its final meaning.
% ^^A
% ^^A In a similar way,
% ^^A we deal with the commands \verb=\@startpbox= and
% ^^A \verb=\@endpbox=, although the reason is different here: these
% ^^A macros expand in many \textsf{tokens} which would delay the
% ^^A build-up of the preamble.
% \begin{macrocode}
% \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
% \end{macrocode}
% ^^A Now we remove possible $*$-forms in the user preamble with the
% ^^A command \verb=\@xexpast=. As we already know, this command saves
% ^^A its result in the macro \verb=\@tempa=.
% \begin{macrocode}
% \@xexpast #1*0x\@@
% \end{macrocode}
% ^^A Afterwards we initialize all registers and macros, that we need
% ^^A for the build-up of the preamble.
% ^^A Since we want to start with the \textsf{token} register $0$,
% ^^A \verb=\count@= has to contain the value $-1$.
% \begin{macrocode}
% \count@\m@ne
% \let\the@toks\relax
% \end{macrocode}
% ^^A Then we call up \verb=\prepnext@tok= in order to prepare the
% ^^A \textsf{token} register $0$ for use.
% \begin{macrocode}
% \prepnext@tok
% \end{macrocode}
% ^^A To evaluate the user preamble (without stars) saved in
% ^^A \verb=\@tempa= we use the \LaTeX--macro \verb=\@tfor=.
% ^^A The strange appearing construction with \verb=\expandafter= is
% ^^A based on the fact that we have to put the replacement text of
% ^^A \verb=\@tempa= and not the macro \verb=\@tempa= to this
% ^^A \LaTeX--macro.
% \begin{macrocode}
% \expandafter \@tfor \expandafter \@nextchar
% \expandafter :\expandafter =\@tempa \do
% \end{macrocode}
% ^^A The body of this loop (the group after the \verb=\do=)
% ^^A is executed for one \textsf{token} at a time, whereas
% ^^A the current \textsf{token} is saved in \verb=\@nextchar=.
% ^^A At first we evaluate the current \textsf{token} with the already
% ^^A defined macro \verb=\@testpach=, i.e.\ we assign to
% ^^A \verb=\@chclass= the character class and to \verb=\@chnum=
% ^^A the character number of this \textsf{token}.
% \begin{macrocode}
% {\@testpach
% \end{macrocode}
% ^^A Then we branch out depending on the value of \verb=\@chclass= into
% ^^A different macros that extend the preamble respectively.
% \begin{macrocode}
% \ifcase \@chclass \@classz \or \@classi \or \@classii
% \or \save@decl \or \or \@classv \or \@classvi
% \or \@classvii \or \@classviii \or \@classix
% \or \@classx \fi
% \end{macrocode}
% ^^A Two cases deserve our special attention: Since the current
% ^^A \textsf{token} cannot have the character class $4$ (start) we
% ^^A have skipped this possibility. If the character class is $3$,
% ^^A only the content of \verb=\@nextchar= has to be saved into the current
% ^^A \textsf{token} register; therefore we call up \verb=\save@decl=
% ^^A directly and save a macro name. After the preamble has been
% ^^A extended we assign the value of \verb=\@chclass= to the counter
% ^^A \verb=\@lastchclass= to assure that this information will be available
% ^^A during the next run of the loop.
% \begin{macrocode}
% \@lastchclass\@chclass}%
% \end{macrocode}
% ^^A After the loop has been finished space must still be added to
% ^^A the created preamble, depending on the last \textsf{token}.
% ^^A Depending on the value of \verb=\@lastchclass= we perform
% ^^A the necessary operations.
% \begin{macrocode}
% \ifcase\@lastchclass
% \end{macrocode}
% ^^A If the last class equals $0$ we add a
% ^^A \verb=\hskip \col@sep=.
% \begin{macrocode}
% \@acol \or
% \end{macrocode}
% ^^A If it equals $1$ we do not add any additional space so that the
% ^^A horizontal lines do not exceed the vertical ones.
% \begin{macrocode}
% \or
% \end{macrocode}
% ^^A Class $2$ is treated like class $0$ because a \verb=<{...}= can
% ^^A only directly follow after class $0$.
% \begin{macrocode}
% \@acol \or
% \end{macrocode}
% ^^A Most of the other possibilities can only appear if the user
% ^^A preamble was defective. Class $3$ is not allowed since after a
% ^^A \verb=>{..}= there must always follow a \texttt{c}, \texttt{l},
% ^^A \texttt{r}, \texttt{p},\texttt{m} or \texttt{b}. We report an
% ^^A error and ignore the declaration given by \verb={..}=.
% \begin{macrocode}
% \@preamerr \thr@@ \or
% \end{macrocode}
% ^^A If \verb=\@lastchclass= is $4$ the user preamble has been empty.
% ^^A To continue, we insert a \verb=#= in the preamble.
% \begin{macrocode}
% \@preamerr \tw@ \@addtopreamble\@sharp \or
% \end{macrocode}
% ^^A Class $5$ is allowed again. In this case
% ^^A (the user preamble ends with \verb=@{..}=) we need not
% ^^A do anything.
% \begin{macrocode}
% \or
% \end{macrocode}
% ^^A Any other case means that the arguments to \verb=@=, \texttt{!},
% ^^A \texttt{<}, \texttt{>}, \texttt{p}, \texttt{m} or \texttt{b} have
% ^^A been forgotten. So we report an error and ignore the last
% ^^A \textsf{token}.
% \begin{macrocode}
% \else \@preamerr \@ne \fi
% \end{macrocode}
% ^^A Now that the build-up of the preamble is almost finished we can
% ^^A insert the \textsf{token} registers and therefore redefine
% ^^A \verb=\the@toks=. The actual insertion, though, is performed
% ^^A later.
% \begin{macrocode}
% \def\the@toks{\the\toks}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A \subsubsection{The macros \texttt{\textbackslash @classz}
% ^^A to \texttt{\textbackslash @classx}}
% ^^A
% ^^A The preamble is extended by the macros \verb=\@classz= to
% ^^A \verb=\@classx= which are called by \verb=\@mkpream=
% ^^A depending on \verb=\@lastchclass=
% ^^A (i.e. the character class of the last \textsf{token}).
% ^^A \begin{macro}{\@classx}
% ^^A First we define =\@classx= because of its important r\^ole.
% ^^A When it is called we find that the current
% ^^A \textsf{token} is \texttt{p}, \texttt{m} or \texttt{b}.
% ^^A That means that a new column has to start.
% \begin{macrocode}
% \def\@classx{%
% \end{macrocode}
% ^^A Depending on the value of \verb=\@lastchclass= different actions
% ^^A must take place:
% \begin{macrocode}
% \ifcase \@lastchclass
% \end{macrocode}
% ^^A If the last character class was $0$ we separate the columns by
% ^^A \verb=\hskip\col@sep= followed by \verb=&= and another
% ^^A \verb=\hskip\col@sep=.
% \begin{macrocode}
% \@acolampacol \or
% \end{macrocode}
% ^^A If the last class was class $1$ --- that means that a vertical
% ^^A line was
% ^^A drawn, --- before this line a \verb=\hskip\col@sep= was inserted.
% ^^A Therefore there has to be only a \verb=&= followed by
% ^^A \verb=\hskip\col@sep=. But this \verb=&= may be inserted only
% ^^A if this is not the first column. This process is controlled
% ^^A by \verb=\if@firstamp= in the macro \verb=\addamp=.
% \begin{macrocode}
% \@addamp \@acol \or
% \end{macrocode}
% ^^A Class $2$ is treated like class $0$ because \verb=<{...}= can only
% ^^A follow after class $0$.
% \begin{macrocode}
% \@acolampacol \or
% \end{macrocode}
% ^^A Class $3$ requires no actions because all things necessary have
% ^^A been done by the preamble \textsf{token} \texttt{>}.
% \begin{macrocode}
% \or
% \end{macrocode}
% ^^A Class $4$ means that we are at the beginning of the preamble.
% ^^A Therefore we start the preamble with \verb=\hskip\col@sep= and
% ^^A then call \verb=\@firstampfalse=. This makes sure that a later
% ^^A \verb=\@addamp= inserts the character
% ^^A \verb=&= into the preamble.
% \begin{macrocode}
% \@acol \@firstampfalse \or
% \end{macrocode}
% ^^A For class $5$ \textsf{tokens} only the character \verb=&= is inserted
% ^^A as a column separator. Therefore we call \verb=\@addamp=.
% \begin{macrocode}
% \@addamp
% \end{macrocode}
% ^^A Other cases are impossible. For an example
% ^^A $\verb=\@lastchclass= = 6$---as it might appear in a
% ^^A preamble of the form \verb=...!p...=---\texttt{p} would have
% ^^A been taken as an argument of \texttt{!}\ by \verb=\@testpach=.
% \begin{macrocode}
% \fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \begin{macro}{\@classz}
% ^^A If the character class of the last \textsf{token} is $0$ we have
% ^^A \texttt{c}, \texttt{l}, \texttt{r} or an argument of \texttt{m},
% ^^A \texttt{b} or\ \texttt{p}. In the first three cases the preamble
% ^^A must be extended the same way as if we had class $10$. The
% ^^A remaining two cases do not require any action because the space
% ^^A needed was generated by the last \textsf{token} (i.e.\
% ^^A \texttt{m}, \texttt{b} or \texttt{p}). Since \verb=\@lastchclass= has
% ^^A the value $10$ at this point nothing happens when \verb=\@classx= is
% ^^A called. So the macro \verb=\@chlassz= may start like this:
% \begin{macrocode}
% \def\@classz{\@classx
% \end{macrocode}
% ^^A According to the definition of \verb=\insert@column= we must store
% ^^A the number of the \textsf{token} register in which a preceding
% ^^A \verb=>{..}= might have stored its argument into
% ^^A \verb=\@tempcnta=.
% \begin{macrocode}
% \@tempcnta \count@
% \end{macrocode}
% ^^A To have $\verb=\count@= = \verb=\@tmpcnta= + 1$ we prepare
% ^^A the next \textsf{token} register.
% \begin{macrocode}
% \prepnext@tok
% \end{macrocode}
% ^^A Now the preamble must be extended with the column whose format
% ^^A can be determined by \verb=\@chnum=.
% \begin{macrocode}
% \@addtopreamble{\ifcase \@chnum
% \end{macrocode}
% ^^A If \verb=\@chnum= has the value $0$ a centered column has to be
% ^^A generated.
% ^^A So we begin with stretchable space.
% \begin{macrocode}
% \hfil
% \end{macrocode}
% ^^A The command \verb=\d@llarbegin= follows expanding into \verb=\begingroup=
% ^^A (in the \textsf{tabular}--environment) or into \verb=$=. Doing this
% ^^A (provided an appropriate setting of \verb=\d@llarbegin=) we achieve
% ^^A that the contents of the columns of an \textsf{array}--environment
% ^^A are set in math mode while those of a \textsf{tabular}--environment
% ^^A are set in LR mode.
% \begin{macrocode}
% \d@llarbegin
% \end{macrocode}
% ^^A Now we insert the contents of the two \textsf{token} registers
% ^^A and the symbol
% ^^A for the column entry (i.e.\ \verb=#= or
% ^^A more precise \verb=\@sharp=) using \verb=\insert@column=.
% \begin{macrocode}
% \insert@column
% \end{macrocode}
% ^^A We end this case with \verb=\d@llarend= and \verb=\hfil= where \verb=\d@llarend=
% ^^A again is either \verb=$= or \verb=\endgroup=.
% \begin{macrocode}
% \d@llarend \hfil \or
% \end{macrocode}
% ^^A The templates for \texttt{l} and \texttt{r} (i.e.\ \verb=\@chnum= $1$
% ^^A or $2$) are generated the same way. Since one \verb=\hfil= is
% ^^A missing the text is moved to the relevant side.
% ^^A The \verb=\kern\z@= is needed in case of an empty column
% ^^A entry. Otherwise
% ^^A the \verb=\unskip= in \verb=\insert@column= removes the
% ^^A \verb=\hfil=. Changed to \verb=\hskip1sp= so that it interacts better with
% ^^A \verb=\@bsphack=.
% \begin{macrocode}
% \hskip1sp\d@llarbegin \insert@column \d@llarend \hfil \or
% \hfil\hskip1sp\d@llarbegin \insert@column \d@llarend \or
% \end{macrocode}
% ^^A The templates for \texttt{p}, \texttt{m} and \texttt{b} mainly
% ^^A consist of a \textsf{box}. In case of \texttt{m} it is generated
% ^^A by \verb=\vcenter=. This command is allowed only in math
% ^^A mode. Therefore we start with a~\verb=$=.
% \begin{macrocode}
% $\vcenter%$ emacs
% \end{macrocode}
% ^^A The part of the templates which is the same in all three cases
% ^^A (\texttt{p}, \texttt{m} and \texttt{b})
% ^^A is built by the macros \verb=\@startpbox= and
% ^^A \verb=\@endpbox=. \verb=\@startpbox= has an argument:
% ^^A the width of the column which is stored in the current
% ^^A \textsf{token} (i.e.\ \verb=\@nextchar=).
% ^^A Between these two macros we find the well known
% ^^A \verb=\insert@column=.
% \begin{macrocode}
% \@startpbox{\@nextchar}\insert@column \@endpbox $\or%$ emacs
% \end{macrocode}
% ^^A The templates for \texttt{p} and \texttt{b} are generated in the
% ^^A same way though we do not need the \verb=$= characters because we use
% ^^A \verb=\vtop= or \verb=\vbox=.
% \begin{macrocode}
% \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
% \vbox \@startpbox{\@nextchar}\insert@column \@endpbox
% \end{macrocode}
% ^^A Other values for \verb=\@chnum= are impossible. Therefore we
% ^^A end the arguments to \verb=\@addtopreamble= and \verb=\ifcase=.
% ^^A Before we come to the end of \verb=\@classz= we have to
% ^^A prepare the next \textsf{token} register.
% \begin{macrocode}
% \fi}\prepnext@tok}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \begin{macro}{\@classix}
% ^^A In case of class $9$ (\texttt{>}--\textsf{token}) we first check
% ^^A if the character class of the last
% ^^A \textsf{token} was $3$. In this case we have a
% ^^A user preamble of the form \verb=..>{...}>{...}..= which
% ^^A is not allowed. We only give an error message and continue.
% ^^A So the declarations defined by the first \verb=>{...}=
% ^^A are ignored.
% \begin{macrocode}
% \def\@classix{\ifnum \@lastchclass = \thr@@
% \@preamerr \thr@@ \fi
% \end{macrocode}
% ^^A Furthermore, we call up \verb=\@class10= because afterwards always a
% ^^A new column is started by \texttt{c}, \texttt{l}, \texttt{r},
% ^^A \texttt{p}, \texttt{m} or \texttt{b}.
% \begin{macrocode}
% \@classx}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A \begin{macro}{\@classviii}
% ^^A If the current \textsf{token} is a \texttt{<} the last character
% ^^A class must be $0$. In this case it is not necessary to extend the
% ^^A preamble. Otherwise we output an error message, set \verb=\@chclass=
% ^^A to $6$ and call \verb=\@classvi=. By doing this we achieve that
% ^^A \texttt{<} is treated like \texttt{!}.
% \begin{macrocode}
% \def\@classviii{\ifnum \@lastchclass >\z@
% \@preamerr 4\@chclass 6 \@classvi \fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@arrayrule}
% ^^A There is only one incompatibility with the original definition:
% ^^A the definition of \verb=\@arrayrule=. In the original a line without
% ^^A width\footnote{So the space between \texttt{cc} and \texttt{c|c}
% ^^A is equal.} is created by multiple insertions of
% ^^A \verb=\hskip .5\arrayrulewidth=.
% ^^A We only insert a vertical line into the
% ^^A preamble. This is done to prevent problems with \TeX's main
% ^^A memory when generating tables with many vertical lines in them
% ^^A (especially in the case of \textsf{floats}).
% \begin{macrocode}
% \def\@arrayrule{\@addtopreamble \vline}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@classvii}
% ^^A As a consequence it follows that in case of class $7$
% ^^A (\verb=@= \textsf{token}) the preamble need not to be extended.
% ^^A In the original definition $\verb=\@lastchclass= = 1$
% ^^A is treated by inserting \verb=\hskip .5\arrayrulewidth=.
% ^^A We only check if the last \textsf{token} was of class $3$ which is
% ^^A forbidden.
% \begin{macrocode}
% \def\@classvii{\ifnum \@lastchclass = \thr@@
% \end{macrocode}
% ^^A If this is true we output an error message and
% ^^A ignore the declarations stored
% ^^A by the last \verb=>{...}=, because these are overwritten
% ^^A by the argument of \texttt{@}.
% \begin{macrocode}
% \@preamerr \thr@@ \fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \begin{macro}{\@classvi}
% ^^A If the current \textsf{token} is a regular \texttt{!}\ and the
% ^^A last class was $0$ or $2$ we extend the preamble with
% ^^A \verb=\hskip\col@sep=. If the last \textsf{token} was of class $1$
% ^^A (for instance \texttt{|}) we extend with \verb=\hskip \doublerulesep=
% ^^A because the construction \verb=!{...}= has to be treated like
% ^^A \texttt{|}.
% \begin{macrocode}
% \def\@classvi{\ifcase \@lastchclass
% \@acol \or
% \@addtopreamble{\hskip \doublerulesep}\or
% \@acol \or
% \end{macrocode}
% ^^A Now \verb=\@preamerr...= should follow because a
% ^^A user preamble of the form \verb=..>{..}!.= is not allowed.
% ^^A To save memory we call \verb=\@classvii= instead which also
% ^^A does what we want.
% \begin{macrocode}
% \@classvii
% \end{macrocode}
% ^^A If \verb=\@lastchclass= is $4$ or $5$ nothing has to be done.
% ^^A Class $6$ to $10$ are not possible.
% ^^A So we finish the macro.
% \begin{macrocode}
% \fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@classii}
% ^^A \begin{macro}{\@classiii}
% ^^A In the case of character classes $2$ and $3$ (i.e.\ the argument
% ^^A of \texttt{<} or \texttt{>}) we only have to store the current
% ^^A \textsf{token} (\verb=\@nextchar=) into the corresponding
% ^^A \textsf{token} register since the preparation and
% ^^A insertion of these registers
% ^^A are done by the macro \verb=\@classz=.
% ^^A This is equivalent to calling \verb=\save@decl= in the case of
% ^^A class $3$. To save command identifiers we do this call up
% ^^A in the macro \verb=\@mkpream=.
% ^^A
% ^^A Class $2$ exhibits a more complicated situation: the
% ^^A \textsf{token} registers have already been inserted by
% ^^A \verb=\@classz=. So the value of \verb=\count@= is too high
% ^^A by one. Therefore we decrease \verb=\count@= by $1$.
% \begin{macrocode}
% \def\@classii{\advance \count@ \m@ne
% \end{macrocode}
% ^^A Next we store the current \textsf{token} into the correct
% ^^A \textsf{token} register by calling \verb=\save@decl= and then
% ^^A increase the value of \verb=\count@= again. At this point we
% ^^A can save memory once more (at the cost of time) if we use the
% ^^A macro \verb=\prepnext@tok=.
% \begin{macrocode}
% \save@decl\prepnext@tok}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \begin{macro}{\@classv}
% ^^A If the current \textsf{token} is of class $5$ then it is an
% ^^A argument of a \texttt{@} \textsf{token}. It must be stored into a
% ^^A \textsf{token} register.
% \begin{macrocode}
% \def\@classv{\save@decl
% \end{macrocode}
% ^^A We extend the preamble with a command which inserts this
% ^^A \textsf{token} register into the preamble when its construction
% ^^A is finished. The user expects that this argument is worked out in
% ^^A math mode if it was used in an
% ^^A \textsf{array}--environment. Therefore we surround it with
% ^^A \verb=\d@llar...='s.
% \begin{macrocode}
% \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}%
% \end{macrocode}
% ^^A Finally we must prepare the next \textsf{token} register.
% \begin{macrocode}
% \prepnext@tok}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@classi}
% ^^A In the case of class $0$ we were able to generate the necessary
% ^^A space between columns by using the macro \verb=\@classx=.
% ^^A Analogously the macro \verb=\@classvi= can be used for class $1$.
% \begin{macrocode}
% \def\@classi{\@classvi
% \end{macrocode}
% ^^A Depending on \verb=\@chnum= a vertical line
% \begin{macrocode}
% \ifcase \@chnum \@arrayrule \or
% \end{macrocode}
% ^^A or (in case of \verb=!{...}=) the current \textsf{token} --- stored
% ^^A in \verb=\@nextchar= --- has to be inserted into the preamble.
% ^^A This corresponds to calling \verb=\@classv=.
% \begin{macrocode}
% \@classv \fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A \begin{macro}{\@startpbox}
% ^^A In \verb=\@classz= the macro \verb=\@startpbox= is used.
% ^^A The width of the \textsf{parbox} is passed as an argument.
% ^^A \verb=\vcenter=, \verb=\vtop= or \verb=\vbox= are already in the
% ^^A preamble. So we start with the braces for the wanted box.
% \begin{macrocode}
% \def\@startpbox#1{\bgroup
% \end{macrocode}
% ^^A The argument is the width of the box. This information has to be
% ^^A assigned to \verb=\hsize=.
% ^^A Then we assign default values to several parameters used in a
% ^^A \textsf{parbox}.
% \begin{macrocode}
% \setlength\hsize{#1}\@arrayparboxrestore
% \end{macrocode}
% ^^A Our main problem is to obtain the same distance between succeeding
% ^^A lines of the \textsf{parbox}.
% ^^A We have to remember that the distance between two \textsf{parboxes}
% ^^A should be defined by \verb=\@arstrut=. That means that it can be
% ^^A greater than the distance in a \textsf{parbox}.
% ^^A Therefore it is not enough to set a \verb=\@arstrut= at the
% ^^A beginning and at the end of the \textsf{parbox}. This would
% ^^A dimension the distance
% ^^A between first and second line and the distance between the two
% ^^A last lines of the \textsf{parbox} wrongly.
% ^^A To prevent this we set an invisible rule of height
% ^^A \verb=\@arstrutbox=
% ^^A at the beginning of the \textsf{parbox}. This has no effect on the
% ^^A depth of the first line. At the end of the \textsf{parbox} we set
% ^^A analogously another invisible rule which only affects the depth
% ^^A of the last line. It is necessary to wait inserting this strut
% ^^A until the paragraph actually starts to allow for things like
% ^^A \verb=\parindent= changes via \verb=>{...}=.
% \begin{macrocode}
% \everypar{%
% \vrule \@height \ht\@arstrutbox \@width \z@
% \everypar{}}%
% }
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@endpbox}
% ^^A If there are any declarations defined by \verb=>{...}=
% ^^A and \verb=<{...}=
% ^^A they now follow in the macro \verb=\@classz= --- the contents
% ^^A of the column in between.
% ^^A So the macro \verb=\@endpbox= must insert the \textsf{specialstrut}
% ^^A mentioned earlier and then close the group opened by
% ^^A \verb=\@startpbox=.
% \begin{macrocode}
% \def\@endpbox{\@finalstrut\@arstrutbox \egroup\hfil}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \subsubsection{Building and calling \texttt{\textbackslash halign}}
% ^^A
% ^^A \begin{macro}{\@array}
% ^^A After we have discussed the macros needed for the evaluation
% ^^A of the user preamble we can define the macro \verb=\@array=
% ^^A which uses these macros to create a \verb=\halign=.
% ^^A It has two arguments. The first one is a position argument
% ^^A which can be \texttt{t}, \texttt{b} or \texttt{c}; the
% ^^A second one describes the wanted preamble,
% ^^A e.g.\ it has the form \verb=|c|c|c|=.
% \begin{macrocode}
% \def\@array[#1]#2{%
% \end{macrocode}
% ^^A First we define a \textsf{strut} whose size basically corresponds
% ^^A to a normal \textsf{strut} multiplied by the factor
% ^^A \verb=\arraystretch=.
% ^^A This \textsf{strut} is then inserted into every row and enforces
% ^^A a minimal distance between two rows.
% ^^A Nevertheless, when using horizontal lines, large letters
% ^^A (like accented capital letters) still collide with such lines.
% ^^A Therefore at first we add to the height of a normal \textsf{strut}
% ^^A the value of the parameter \verb=\extrarowheight=.
% \begin{macrocode}
% \@tempdima \ht \strutbox
% \advance \@tempdima by\extrarowheight
% \setbox \@arstrutbox \hbox{\vrule
% \@height \arraystretch \@tempdima
% \@depth \arraystretch \dp \strutbox
% \@width \z@}%
% \end{macrocode}
% ^^A Then we open a group, in which the user preamble is evaluated by
% ^^A the macro \verb=\@mkpream=. As we know this must happen locally.
% ^^A This macro creates a preamble for a \verb=\halign= and saves
% ^^A its result globally in the control sequence \verb=\@preamble=.
% \begin{macrocode}
% \begingroup
% \@mkpream{#2}%
% \end{macrocode}
% ^^A We again redefine \verb=\@preamble= so that a call up of \verb=\@preamble=
% ^^A now starts the \verb=\halign=. Thus also the arguments of \texttt{>},
% ^^A \texttt{<}, \texttt{@} and \texttt{!}, saved in the
% ^^A \textsf{token} registers are inserted into the preamble. The
% ^^A \verb=\tabskip= at the beginning and end of the preamble is set to
% ^^A \textsf{0pt} (in the beginning by the use of \verb=\ialign=). Also the
% ^^A command \verb=\@arstrut= is build in, which inserts the
% ^^A \verb=\@arstrutbox=, defined above. Of course, the opening brace after
% ^^A \verb=\ialign= has to be implicit as it will be closed in \verb=\endarray=
% ^^A or another macro.
% ^^A
% ^^A The \verb=\noexpand= in front of \verb=\ialign= does no harm in standard \LaTeX{}
% ^^A and was added since some experimental support for using text glyphs in math
% ^^A redefines \verb=\halign= with the result that is becomes expandable with
% ^^A disastrous results in cases like this.
% ^^A In the kernel definition for this macro the problem does
% ^^A not surface because there \verb=\protect= is set (which is not necessary in this
% ^^A implementation as there is no arbitrary user input that can get expanded) and
% ^^A the experimental code made the redefinition robust. Whether this is the right
% ^^A approach is open to question; consider the \verb=\noexpand= a courtesy to allow an
% ^^A unsupported redefinition of a \TeX{} primitive for the moment (as people rely
% ^^A on that experimental code).
% \begin{macrocode}
% \xdef\@preamble{\noexpand \ialign \@halignto
% \bgroup \@arstrut \@preamble
% \tabskip \z@ \cr}%
% \end{macrocode}
% ^^A What we have not explained yet is the macro \verb=\@halignto=
% ^^A that was just used. Depending on its replacement text the
% ^^A \verb=\halign= becomes a \verb=\halign= \texttt{to} \meta{dimen}.
% ^^A Now we close the group again. Thus
% ^^A \verb=\@startpbox= and \verb=\@endpbox= as well as all
% ^^A \textsf{token} registers get their former meaning back.
% \begin{macrocode}
% \endgroup
% \end{macrocode}
% ^^A To support the \texttt{delarray.sty} package we include a hook
% ^^A into this part of the code which is a no-op in the main package.
% \begin{macrocode}
% \@arrayleft
% \end{macrocode}
% ^^A Now we decide depending on the position argument in which
% ^^A \textsf{box} the \verb=\halign= is to be put. (\verb=\vcenter= may be used
% ^^A because we are in math mode.)
% \begin{macrocode}
% \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi
% \end{macrocode}
% ^^A Now another implicit opening brace appears; then definitions
% ^^A which shall stay local follow. While constructing the
% ^^A \verb=\@preamble= in \verb=\@mkpream= the \verb=#= sign must be
% ^^A hidden in the macro \verb=\@sharp= which is \verb=\let= to
% ^^A \verb=\relax= at that moment (see definition of \verb=\@mkpream=
% ^^A on page~\pageref{@mkpream}).
% ^^A All these now get their actual meaning.
% \begin{macrocode}
% \bgroup
% \let \@sharp ##\let \protect \relax
% \end{macrocode}
% ^^A With the above defined \textsf{struts} we fix down the distance
% ^^A between rows by setting \verb=\lineskip= and \verb=\baselineskip=
% ^^A to \textsf{0pt}. Since there have to be set \verb=$='s
% ^^A around every column in the \textsf{array}--environment
% ^^A the parameter \verb=\mathsurround= should
% ^^A also be set to \textsf{0pt}. This prevents additional space between
% ^^A the rows. The
% ^^A \PlainTeX--macro \verb=\m@th= does this.
% \begin{macrocode}
% \lineskip \z@
% \baselineskip \z@
% \m@th
% \end{macrocode}
% ^^A Beside, we have to assign a special meaning (which we still have
% ^^A to specify) to the line separator \verb=\\=. We also have to
% ^^A redefine the command \verb=\par= in such a way that empty lines in
% ^^A \verb=\halign= cannot do any damage. We succeed in doing so
% ^^A by choosing something that will disappear when expanding.
% ^^A After that we only have to call up \verb=\@preamble= to
% ^^A start the wanted \verb=\halign=.
% \begin{macrocode}
% \let\\\@arraycr \let\tabularnewline\\\let\par\@empty \@preamble}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\arraybackslash}
% ^^A Restore \verb=\\= for use in array and tabular environment (after
% ^^A \verb=\raggedright= etc.).
% \begin{macrocode}
% \def\arraybackslash{\let\\\tabularnewline}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\extrarowheight}
% ^^A The \textsf{dimen} parameter used above also needs to be
% ^^A allocated. As a default value we use \textsf{0pt}, to ensure
% ^^A compatibility with standard \LaTeX.
% \begin{macrocode}
% \newdimen \extrarowheight
% \extrarowheight=0pt
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@arstrut}
% ^^A Now the insertion of \verb=\@arstrutbox= through \verb=\@arstut=
% ^^A is easy since we know exactly in which mode \TeX\ is while working
% ^^A on the \verb=\halign= preamble.
% \begin{macrocode}
% \def\@arstrut{\unhcopy\@arstrutbox}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \subsubsection{The line separator \texttt{\textbackslash\textbackslash}}
% ^^A
% ^^A \begin{macro}{\@arraycr}
% ^^A In the macro \verb=\@array= the line separator \verb=\\= is
% ^^A \verb=\let= to the command \verb=\@arraycr=.
% ^^A Its definition starts with a special brace which I have directly
% ^^A copied from the original definition. It is
% ^^A necessary, because the \verb=\futurlet= in \verb=\@ifnextchar=
% ^^A might
% ^^A expand a following \verb=&= \textsf{token} in a construction like
% ^^A \verb=\\ &=. This would otherwise end the alignment template at a
% ^^A wrong time. On the other hand we have to be careful to avoid
% ^^A producing a real group, i.e.\ \verb={}=, because the command will also
% ^^A be used for the array environment, i.e.\ in math mode. In that
% ^^A case an extra \verb={}= would produce an ord atom which could mess up
% ^^A the spacing. For this reason we use a combination that does not
% ^^A really produce a group at all but modifies the master counter so
% ^^A that a \verb=&= will not be considered belonging to the current
% ^^A \verb=\halign= while we are looking for a \verb=*= or \verb=[=.
% ^^A For further information see
% ^^A \cite[Appendix D]{bk:knuth}.
% \begin{macrocode}
% \def\@arraycr{\relax\iffalse{\fi\ifnum 0=`}\fi
% \end{macrocode}
% ^^A Then we test whether the user is using the star form and ignore
% ^^A a possible star (I also disagree with this procedure, because a
% ^^A star does not make any sense here).
% \begin{macrocode}
% \@ifstar \@xarraycr \@xarraycr}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@xarraycr}
% ^^A In the command \verb=\@xarraycr= we test if an optional argument
% ^^A exists.
% \begin{macrocode}
% \def\@xarraycr{\@ifnextchar [%
% \end{macrocode}
% ^^A If it does, we branch out into the macro \verb=\@argarraycr= if
% ^^A not we close the special brace (mentioned above) and end the row
% ^^A of the \verb=\halign= with a \verb=\cr=.
% \begin{macrocode}
% \@argarraycr {\ifnum 0=`{}\fi\cr}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \begin{macro}{\@argarraycr}
% ^^A If additional space is requested by the user this case is treated
% ^^A in the macro \verb=\@argarraycr=. First we close the special brace
% ^^A and then we test if the additional space is positive.
% \begin{macrocode}
% \def\@argarraycr[#1]{\ifnum0=`{}\fi\ifdim #1>\z@
% \end{macrocode}
% ^^A If this is the case we create an invisible vertical rule with
% ^^A depth \verb=\dp\@arstutbox=${}+{}$\meta{wanted\ space}.
% ^^A Thus we achieve that all vertical lines specified
% ^^A in the user preamble by a \texttt{|} are now
% ^^A generally drawn.
% ^^A Then the row ends with a \verb=\cr=.
% ^^A
% ^^A If the space is negative we end the row at once with a \verb=\cr=
% ^^A and move back up with a \verb=\vskip=.
% ^^A
% ^^A While testing these macros I found out that the
% ^^A \verb=\endtemplate=
% ^^A created by \verb=\cr= and \verb=&= is something like an
% ^^A \verb=\outer= primitive and therefore it should not appear in
% ^^A incomplete \verb=\if= statements. Thus the following solution was
% ^^A chosen which hides the \verb=\cr= in other macros when \TeX\
% ^^A is skipping conditional text.
% \begin{macrocode}
% \expandafter\@xargarraycr\else
% \expandafter\@yargarraycr\fi{#1}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@xargarraycr}
% ^^A \begin{macro}{\@yargarraycr}
% ^^A The following macros were already explained above.
% \begin{macrocode}
% \def\@xargarraycr#1{\unskip
% \@tempdima #1\advance\@tempdima \dp\@arstrutbox
% \vrule \@depth\@tempdima \@width\z@ \cr}
% \def\@yargarraycr#1{\cr\noalign{\vskip #1}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A
% ^^A \subsubsection{Spanning several columns}
% ^^A
% ^^A \begin{macro}{\multicolumn}
% ^^A If several columns should be held together with a special format
% ^^A the command \verb=\multicolumn= must be used. It has three
% ^^A arguments: the number of columns to be covered; the format for
% ^^A the result column and the actual column entry.
% \begin{macrocode}
% \long\def\multicolumn#1#2#3{%
% \end{macrocode}
% ^^A First we combine the given number of columns into a single one;
% ^^A then we start a new block so that the following definition is kept
% ^^A local.
% \begin{macrocode}
% \multispan{#1}\begingroup
% \end{macrocode}
% ^^A Since a \verb=\multicolumn= should only describe the format of a
% ^^A result column, we redefine \verb=\@addamp= in such a way that one gets
% ^^A an error message if one uses more than one \texttt{c},
% ^^A \texttt{l}, \texttt{r}, \texttt{p}, \texttt{m} or \texttt{b} in
% ^^A the second argument. One should consider that this definition is
% ^^A local to the build-up of the preamble; an \textsf{array}-- or
% ^^A \textsf{tabular}--environment in the third argument of the
% ^^A \verb=\multicolumn= is therefore worked through correctly as well.
% \begin{macrocode}
% \def\@addamp{\if@firstamp \@firstampfalse \else
% \@preamerr 5\fi}%
% \end{macrocode}
% ^^A Then we evaluate the second argument with the help of
% ^^A \verb=\@mkpream=.
% ^^A Now we still have to insert the contents of the \textsf{token}
% ^^A register into the \verb=\@preamble=, i.e.\ we have to say
% ^^A \verb=\xdef\@preamble{\@preamble}=. This is achieved shorter by
% ^^A writing:
% \begin{macrocode}
% \@mkpream{#2}\@addtopreamble\@empty
% \end{macrocode}
% ^^A After the \verb=\@preamble= is created we forget all local
% ^^A definitions and occupations of the \textsf{token} registers.
% \begin{macrocode}
% \endgroup
% \end{macrocode}
% ^^A In the special situation of \verb=\multicolumn= \verb=\@preamble=
% ^^A is not needed as preamble for a \verb=\halign= but it is directly
% ^^A inserted into our table. Thus instead of \verb=\sharp=
% ^^A there has to be the column entry (\verb=#3=) wanted by the user.
% \begin{macrocode}
% \def\@sharp{#3}%
% \end{macrocode}
% ^^A Now we can pass the \verb=\@preamble= to \TeX\ . For safety
% ^^A we start with an \verb=\@arstrut=. This should usually be in the
% ^^A template for the first column however we do not know if this
% ^^A template was overwritten by our \verb=\multicolumn=.
% ^^A We also add a \verb=\null= at the right end to prevent any following
% ^^A \verb=\unskip= (for example from \verb=\\[..]=) to remove the \verb=\tabcolsep=.
% \begin{macrocode}
% \@arstrut \@preamble
% \null
% \ignorespaces}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A \subsubsection{The Environment Definitions}
% ^^A
% ^^A After these preparations we are able to define the environments. They
% ^^A only differ in the initialisations of \verb=\d@llar...=, \verb=\col@sep=
% ^^A and \verb=\@halignto=.
% ^^A
% ^^A \begin{macro}{\@halignto}
% ^^A \begin{macro}{\d@llarbegin}
% ^^A \begin{macro}{\d@llarend}
% ^^A \verb=\d@llar= has to be
% ^^A locally asigned since otherwise nested \textsf{tabular} and \textsf{array}
% ^^A environments (via \verb=\multicolumn=) are impossible.
% ^^A For 25 years or so \verb=\@halignto= was set globally (to save space on the
% ^^A save stack, but that was a mistake: if there is a tabular in the
% ^^A output routine (e.g., in the running header) then that tabular is
% ^^A able overwrite the \verb=\@halignto=
% ^^A setting of a tabular in the main text resulting in a very weird error.
% ^^A When the new font selection scheme is in force we have to
% ^^A we surround all \verb=\halign= entries
% ^^A with braces. See remarks in TUGboat 10\#2. Actually we are going
% ^^A to use \verb=\begingroup= and \verb=\endgroup=. However, this is only
% ^^A necessary when we are in text mode. In math the surrounding
% ^^A dollar signs will already serve as the necessary extra grouping
% ^^A level. Therefore we switch the settings of \verb=\d@llarbegin= and
% ^^A \verb=\d@llarend= between groups and dollar signs.
% \begin{macrocode}
% \let\d@llarbegin\begingroup
% \let\d@llarend\endgroup
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \begin{macro}{\array}
% ^^A Our new definition of \verb=\array= then reads:
% \begin{macrocode}
% \def\array{\col@sep\arraycolsep
% \def\d@llarbegin{$}\let\d@llarend\d@llarbegin\def\@halignto{}%$ emacs
% \end{macrocode}
% ^^A Since there might be an optional argument we call another
% ^^A macro which is also used by the other environments.
% \begin{macrocode}
% \@tabarray}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@tabarray}
% ^^A This macro tests for a optional bracket and then calls up
% ^^A \verb=\@array= or \verb=\@array[c]= (as default).
% \begin{macrocode}
% \def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \begin{macro}{\tabular}
% ^^A \begin{macro}{\tabular*}
% ^^A The environments \textsf{tabular} and \textsf{tabular$*$} differ
% ^^A only in the initialisation of the command \verb=\@halignto=. Therefore
% ^^A we define
% \begin{macrocode}
% \def\tabular{\def\@halignto{}\@tabular}
% \end{macrocode}
% ^^A and analogously for the star form. We evaluate the argument first
% ^^A using =\setlength= so that users of the \texttt{calc} package can
% ^^A write code like\\ \verb=\begin{tabular*}{(\columnwidth-1cm)/2}...=
% ^^A \begin{macrocode}
% \expandafter\def\csname tabular*\endcsname#1{%
% \setlength\dimen@{#1}%
% \edef\@halignto{to\the\dimen@}\@tabular}
% ^^A \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@tabular}
% ^^A The rest of the job is carried out by the \verb=\@tabular= macro:
% \begin{macrocode}
% \def\@tabular{%
% \end{macrocode}
% ^^A First of all we have to make sure that we start out in
% ^^A \textsf{hmode}. Otherwise we might find our table dangling by
% ^^A itself on a line.
% \begin{macrocode}
% \leavevmode
% \end{macrocode}
% ^^A It should be taken into consideration that the macro \verb=\@array=
% ^^A must be called in math mode. Therefore we open a \textsf{box},
% ^^A insert a \verb=$= and then assign the correct values to \verb=\col@sep= and
% ^^A \verb=\d@llar...=.
% \begin{macrocode}
% \hbox \bgroup $\col@sep\tabcolsep \let\d@llarbegin\begingroup% $ emacs
% \let\d@llarend\endgroup
% \end{macrocode}
% ^^A Now everything \textsf{tabular} specific is done and we are able to
% ^^A call the \verb=\@tabarray= macro.
% \begin{macrocode}
% \@tabarray}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\endarray}
% ^^A When the processing of \textsf{array} is finished we have to
% ^^A close the \verb=\halign=
% ^^A and afterwards the surrounding \textsf{box} selected by
% ^^A \verb=\@array=. To save \textsf{token} space we then redefine
% ^^A \verb=\@preamble=
% ^^A because its replacement text isn't longer needed.
% \begin{macrocode}
% \def\endarray{\crcr \egroup \egroup \gdef\@preamble{}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\endtabular}
% ^^A \begin{macro}{\endtabular*}
% ^^A To end a \textsf{tabular} or \textsf{tabular$*$} environment we
% ^^A call up \verb=\endarray=, close the math mode and then the surrounding
% ^^A \verb=\hbox=.
% \begin{macrocode}
% \def\endtabular{\endarray $\egroup}%$ emacs
% \expandafter\let\csname endtabular*\endcsname=\endtabular
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A \subsubsection{Last minute definitions}
% ^^A
% ^^A
% ^^A If this file is used as a package file we should \verb=\let= all macros
% ^^A to \verb=\relax= that were used in the original but are no longer
% ^^A necessary.
% \begin{macrocode}
% \let\@ampacol=\relax \let\@expast=\relax
% \let\@arrayclassiv=\relax \let\@arrayclassz=\relax
% \let\@tabclassiv=\relax \let\@tabclassz=\relax
% \let\@arrayacol=\relax \let\@tabacol=\relax
% \let\@tabularcr=\relax \let\@@endpbox=\relax
% \let\@argtabularcr=\relax \let\@xtabularcr=\relax
% \end{macrocode}
% ^^A
% ^^A \begin{macro}{\@preamerr}
% ^^A We also have to redefine the error routine \verb=\@preamerr= since
% ^^A new kind of errors are possible.
% ^^A The code for this macro is not perfect yet;
% ^^A it still needs too much memory.
% \begin{macrocode}
% \def\@preamerr#1{\def\@tempd{{..} at wrong position: }%
% %\PackageError{array}{%
% \ClassError{memoir}{% changed in menoir
% \ifcase #1 Illegal pream-token (\@nextchar): `c' used\or %0
% Missing arg: token ignored\or %1
% Empty preamble: `l' used\or %2
% >\@tempd token ignored\or %3
% <\@tempd changed to !{..}\or %4
% Only one column-spec. allowed.\fi}\@ehc} %5
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A
% ^^A \subsubsection
% ^^A [Defining your own column specifiers]
% ^^A {Defining your own column specifiers\footnotemark}
% ^^A
% ^^A \footnotetext{The code and the documentation in this section was
% ^^A written by David. So far only the code from newarray was plugged
% ^^A into array so that some parts of the documentation still claim
% ^^A that this is newarray and even worse, some parts of the code are
% ^^A unnecessarily doubled. This will go away in a future release. For
% ^^A the moment we thought it would be more important to bring both
% ^^A packages together.}
% ^^A
% ^^A \begin{macro}{\newcolumn}
% ^^A In \texttt{newarray.sty} the macro for specifying new columns was
% ^^A named \verb"\newcolumn". When the functionality was added to
% ^^A \texttt{array.sty} the command was renamed \verb"\newcolumntype".
% ^^A Initially both names were supported, but now (In versions of this
% ^^A package distributed for \LaTeXe) the old name is not defined.
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\newcolumntype}
% ^^A As
% ^^A described above, the \verb"\newcolumntype" macro gives users the chance
% ^^A to define letters, to be used in the same way as the primitive
% ^^A column specifiers, `c' `p' etc.
% \begin{macrocode}
% \def\newcolumntype#1{%
% \end{macrocode}
% ^^A \verb"\NC@char" was added in V2.01 so that active characters, like "@" in
% ^^A AMS\LaTeX\ may be used. This trick was stolen from \texttt{array.sty}
% ^^A 2.0h. Note that we need to use the possibly active token,
% ^^A \verb"#1", in several places, as that is the token that actually
% ^^A appears in the preamble argument.
% \begin{macrocode}
% \edef\NC@char{\string#1}%
% \end{macrocode}
% ^^A First we check whether there is already a definition for this column.
% ^^A Unlike \verb"\newcommand" we give a warning rather than an error if it is
% ^^A defined. If it is a new column, add \verb"\NC@do" \meta{column} to
% ^^A the list \verb"\NC@list".
% \begin{macrocode}
% \@ifundefined{NC@find@\NC@char}%
% {\@tfor\next:=<>clrmbp@!|\do{\if\noexpand\next\NC@char
% %\PackageWarning{array}%
% \@memwarn{Redefining primitive column \NC@char}\fi}% memoir change
% \NC@list\expandafter{\the\NC@list\NC@do#1}}%
% {%\PackageWarning{array}
% \@memwarn{Column \NC@char\space is already defined}}% memoir change
% \end{macrocode}
% ^^A Now we define a macro with an argument delimited by the new column
% ^^A specifier, this is used to find occurrences of this specifier in the
% ^^A user preamble.
% \begin{macrocode}
% \@namedef{NC@find@\NC@char}##1#1{\NC@{##1}}%
% \end{macrocode}
% ^^A If an optional argument was not given, give a default argument of 0.
% \begin{macrocode}
% \@ifnextchar[{\newcol@{\NC@char}}{\newcol@{\NC@char}[0]}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\newcol@}
% ^^A We can now define the macro which does the rewriting,
% ^^A \verb"\@reargdef" takes the same arguments as \verb"\newcommand", but
% ^^A does not check that the command is new. For a column, say `D' with
% ^^A one argument, define a command \verb"\NC@rewrite@D" with one
% ^^A argument, which recursively calls \verb"\NC@find" on the user preamble
% ^^A after replacing the first token or group with the replacement text
% ^^A specified in the \verb"\newcolumntype" command. \verb"\NC@find" will find the
% ^^A next occurrence of `D' as it will be \verb"\let" equal to
% ^^A \verb"\NC@find@D" by \verb"\NC@do".
% \begin{macrocode}
% \def\newcol@#1[#2]#3{\expandafter\@reargdef
% \csname NC@rewrite@#1\endcsname[#2]{\NC@find#3}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\NC@}
% ^^A Having found an occurrence of the new column, save the preamble
% ^^A before the column in \verb"\@temptokena", then check to see if we
% ^^A are at the end of the preamble. (A dummy occurrence of the column
% ^^A specifier will be placed at the end of the preamble by \verb"\NC@do".
% \begin{macrocode}
% \def\NC@#1{%
% \@temptokena\expandafter{\the\@temptokena#1}\futurelet\next\NC@ifend}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\NC@ifend}
% ^^A We can tell that we are at the end as \verb"\NC@do" will place a \verb"\relax"
% ^^A after the dummy column.
% \begin{macrocode}
% \def\NC@ifend{%
% \end{macrocode}
% ^^A If we are at the end, do nothing. (The whole preamble will now be in
% ^^A \verb"\@temptokena".)
% \begin{macrocode}
% \ifx\next\relax
% \end{macrocode}
% ^^A Otherwise set the flag \verb"\if@tempswa", and rewrite the column.
% ^^A \verb"\expandafter" introduced 1n V2.01
% \begin{macrocode}
% \else\@tempswatrue\expandafter\NC@rewrite\fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\NC@do}
% ^^A If the user has specified `C' and `L' as new columns, the list of
% ^^A rewrites (in the token register \verb"\NC@list") will look like
% ^^A \verb"\NC@do *" \verb"\NC@do C" \verb"\NC@do L".
% ^^A So we need to define \verb"\NC@do" as a one argument macro which
% ^^A initialises the rewriting of the specified column. Let us assume that
% ^^A `C' is the argument.
% \begin{macrocode}
% \def\NC@do#1{%
% \end{macrocode}
% ^^A First we let \verb"\NC@rewrite" and \verb"\NC@find" be
% ^^A \verb"\NC@rewrite@C" and \verb"\NC@find@C" respectively.
% \begin{macrocode}
% \expandafter\let\expandafter\NC@rewrite
% \csname NC@rewrite@\string#1\endcsname
% \expandafter\let\expandafter\NC@find
% \csname NC@find@\string#1\endcsname
% \end{macrocode}
% ^^A Clear the token register \verb"\@temptokena" after putting the present
% ^^A contents of the register in front of the token \verb"\NC@find". At the
% ^^A end we place the tokens `\verb"C\relax"' which \verb"\NC@ifend" will use
% ^^A to detect the end of the user preamble.
% \begin{macrocode}
% \expandafter\@temptokena\expandafter{\expandafter}%
% \expandafter\NC@find\the\@temptokena#1\relax}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\showcols}
% ^^A This macro is useful for debugging \verb"\newcolumntype" specifications,
% ^^A it is the equivalent of the primitive \verb"\show" command for macro
% ^^A definitions. All we need to do is locally redefine \verb"\NC@do" to take
% ^^A its argument (say `C') and then \verb"\show" the (slightly modified)
% ^^A definition of \verb"\NC@rewrite@C". Actually as the the list always
% ^^A starts off with \verb"\NC@do *" and we do not want to print the
% ^^A definition of the $*$-form, define \verb"\NC@do" to throw away the first
% ^^A item in the list, and then redefine itself to print the rest of the
% ^^A definitions.
% \begin{macrocode}
% \def\showcols{{\def\NC@do##1{\let\NC@do\NC@show}\the\NC@list}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\NC@show}
% ^^A If the column `C' is defined as above, then
% ^^A \verb"\show\NC@rewrite@C" would output\\
% ^^A \verb"\long macro: ->\NC@find >{$}c<{$}".
% ^^A We want to strip the \verb"long macro: ->" and the \verb"\NC@find". So first we
% ^^A use \verb"\meaning" and then apply the macro \verb"\NC@strip" to the tokens so
% ^^A produced and then \verb"\typeout" the required string.
% \begin{macrocode}
% \def\NC@show#1{%
% \typeout{Column #1\expandafter\expandafter\expandafter\NC@strip
% \expandafter\meaning\csname NC@rewrite@#1\endcsname\@@}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\NC@strip}
% ^^A Delimit the arguments to \verb"\NC@strip" with `\texttt{:}', `\texttt{->}',
% ^^A a space, and \verb"\@@" to pull out the required parts of the output from
% ^^A \verb"\meaning".
% \begin{macrocode}
% \def\NC@strip#1:#2->#3 #4\@@{#2 -> #4}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\NC@list}
% ^^A Allocate the token register used for the rewrite list.
% \begin{macrocode}
% \newtoks\NC@list
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \subsubsection{The $*$--form}
% ^^A We view the $*$-form as a slight generalisation of the system
% ^^A described in the previous subsection. The idea is to define a $*$
% ^^A column by a command of the form:
% ^^A \begin{verbatim}
% ^^A \newcolumntype{*}[2]{%
% ^^A \count@=#1\ifnum\count@>0
% ^^A \advance\count@ by -1 #2*{\count@}{#2}\fi}
% ^^A \end{verbatim}
% ^^A \begin{macro}{\NC@rewrite@*}\label{NC@rewrite@*}
% ^^A This does not work however as \verb"\newcolumntype" takes great care not
% ^^A to expand anything in the preamble, and so the \verb"\if" is never
% ^^A expanded. \verb"\newcolumntype" sets up various other parts of the
% ^^A rewrite correctly though so we can define:
% \begin{macrocode}
% \newcolumntype{*}[2]{}
% \end{macrocode}
% ^^A Now we must correct the definition of \verb"\NC@rewrite@*". The
% ^^A following is probably more efficient than a direct translation of
% ^^A the idea sketched above, we do not need to put a $*$ in the preamble
% ^^A and call the rewrite recursively, we can just put \verb"#1" copies of
% ^^A \verb"#2" into \verb"\@temptokena". (Nested $*$ forms will be expanded
% ^^A when the whole rewrite list is expanded again, see \verb"\@mkpream")
% \begin{macrocode}
% \long\@namedef{NC@rewrite@*}#1#2{%
% \end{macrocode}
% ^^A Store the number.
% \begin{macrocode}
% \count@#1\relax
% \end{macrocode}
% ^^A Put \verb"#1" copies of \verb"#2" in the token register.
% \begin{macrocode}
% \loop
% \ifnum\count@>\z@
% \advance\count@\m@ne
% \@temptokena\expandafter{\the\@temptokena#2}%
% \repeat
% \end{macrocode}
% ^^A \verb"\NC@do" will ensure that \verb"\NC@find" is \verb"\let" equal
% ^^A to \verb"\NC@find@*".
% \begin{macrocode}
% \NC@find}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \subsubsection{Modifications to internal macros of \texttt{array.sty}}
% ^^A
% ^^A \begin{macro}{\@xexpast}
% ^^A \begin{macro}{\@xexnoop}
% ^^A These macros are used to expand $*$-forms in
% ^^A \texttt{array.sty}. \verb"\let" them to \verb"\relax" to save space.
% \begin{macrocode}
% \let\@xexpast\relax
% \let\@xexnoop\relax
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\save@decl}
% ^^A We do not assume that the token register is free, we add the new
% ^^A declarations to the front of the register. This is to allow user
% ^^A preambles of the form, \verb">{foo}>{bar}..". Users are not encouraged to
% ^^A enter such expressions directly, but they may result from the
% ^^A rewriting of \verb"\newcolumntype"'s.
% \begin{macrocode}
% \def\save@decl{\toks \count@ = \expandafter\expandafter\expandafter
% {\expandafter\@nextchar\the\toks\count@}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\@mkpream}
% ^^A The main modification to \verb"\@mkpream" is to replace the call to
% ^^A \verb"\@xexpast" (which expanded $*$-forms) by a loop which expands
% ^^A all \verb"\newcolumntype" specifiers.
% \begin{macrocode}
% \def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
% \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
% \end{macrocode}
% ^^A Now we remove possible $*$-forms and user-defined column
% ^^A specifiers in the user preamble by repeatedly executing the list
% ^^A \verb"\NC@list" until the re-writes have no more effect. The
% ^^A expanded preamble will then be in the token register
% ^^A \verb"\@temptokena". Actually we need to know at this point that
% ^^A this is not \verb"\toks0".
% \begin{macrocode}
% \@temptokena{#1}\@tempswatrue
% \@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
% \end{macrocode}
% ^^A Afterwards we initialize all registers and macros, that we need
% ^^A for the build-up of the preamble.
% \begin{macrocode}
% \count@\m@ne
% \let\the@toks\relax
% \prepnext@tok
% \end{macrocode}
% ^^A Having expanded all tokens defined using \verb"\newcolumntype" (including
% ^^A \verb"*"), we evaluate the remaining tokens, which are saved in
% ^^A \verb"\@temptokena". We use the \LaTeX--macro \verb"\@tfor" to inspect each
% ^^A token in turn.
% \begin{macrocode}
% \expandafter \@tfor \expandafter \@nextchar
% \expandafter :\expandafter =\the\@temptokena \do
% \end{macrocode}
% ^^A \verb"\@testpatch" does not take an argument since \texttt{array.sty} 2.0h.
% \begin{macrocode}
% {\@testpach
% \ifcase \@chclass \@classz \or \@classi \or \@classii
% \or \save@decl \or \or \@classv \or \@classvi
% \or \@classvii \or \@classviii
% \end{macrocode}
% ^^A In \texttt{newarray.sty} class 9 is equivalent to class 10.
% \begin{macrocode}
% \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}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@classix}
% ^^A \texttt{array.sty} does not allow repeated \texttt{>}
% ^^A declarations for the same column. This is allowed in
% ^^A \texttt{newarray.sty} as documented in the introduction. Removing
% ^^A the test for this case makes class 9 equivalent to class 10, and
% ^^A so this macro is redundant. It is \verb"\let" to \verb"\relax" to save
% ^^A space.
% \begin{macrocode}
% \let\@classix\relax
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@classviii}
% ^^A In \texttt{newarray.sty} explicitly allow class 2, as repeated
% ^^A \texttt{<} expressions are accepted by this package.
% \begin{macrocode}
% \def\@classviii{\ifnum \@lastchclass >\z@\ifnum\@lastchclass=\tw@\else
% \@preamerr 4\@chclass 6 \@classvi \fi\fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\@classv}
% ^^A Class 5 is \texttt{@}-expressions (and is also called by class 1)
% ^^A This macro was incorrect in Version~1. Now we do not expand the
% ^^A \verb"@"-expression, but instead explicitly replace an
% ^^A \verb"\extracolsep" command by an assignment to \verb"\tabskip" by a
% ^^A method similar to the \verb"\newcolumntype" system described above.
% ^^A \verb"\d@llarbegin" \verb"\d@llarend" were introduced in V2.01 to match
% ^^A \texttt{array.sty} 2.0h.
% \begin{macrocode}
% \def\@classv{\save@decl
% \expandafter\NC@ecs\@nextchar\extracolsep{}\extracolsep\@@@
% \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}%
% \prepnext@tok}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\NC@ecs}
% ^^A Rewrite the first occurrence of \verb"\extracolsep{1in}" to
% ^^A \verb"\tabskip1in\relax". As a side effect discard any tokens after a
% ^^A second \verb"\extracolsep", there is no point in the user entering two of
% ^^A these commands anyway, so this is not really a restriction.
% \begin{macrocode}
% \def\NC@ecs#1\extracolsep#2#3\extracolsep#4\@@@{\def\@tempa{#2}%
% \ifx\@tempa\@empty\else\toks\count@={#1\tabskip#2\relax#3}\fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \subsubsection{Support for the \texttt{delarray.sty}}
% ^^A
% ^^A The \texttt{delarray.sty} package extends the array syntax by
% ^^A supporting the notation of delimiters. To this end we extend the
% ^^A array parsing mechanism to include a hook which can be used by this
% ^^A (or another) package to do some additional parsing.
% ^^A
% ^^A \begin{macro}{\@tabarray}
% ^^A This macro tests for an optional bracket and then calls up
% ^^A \verb"\@@array" or \verb"\@@array[c]" (as default).
% \begin{macrocode}
% \def\@tabarray{\@ifnextchar[{\@@array}{\@@array[c]}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\@@array}
% ^^A This macro tests could then test an optional delimiter before the
% ^^A left brace of the main preamble argument. Here in the main package
% ^^A it simply is let to be \verb"\@array".
% \begin{macrocode}
% \let\@@array\@array
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\endarray}
% ^^A \begin{macro}{\@arrayright}
% ^^A We have to declare the hook we put into \verb"\@array" above.
% ^^A A similar hook `\verb"\@arrayright"' will be inserted into the
% ^^A \verb"\endarray" to gain control. Both defaults to empty.
% \begin{macrocode}
% \def\endarray{\crcr \egroup \egroup \@arrayright \gdef\@preamble{}}
% \let\@arrayleft\@empty
% \let\@arrayright\@empty
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A \subsubsection{Support for \texttt{\textbackslash firsthline} and
% ^^A \texttt{\textbackslash lasthline}}
% ^^A
% ^^A The Companion~\cite[p.137]{GOOSSENS94} suggests two additional
% ^^A commands to control the alignments in case of tabulars with
% ^^A horizontal lines. They are now added to this package.
% ^^A
% ^^A \begin{macro}{\extratabsurround}
% ^^A The extra space around a table when \verb"\firsthline" or \verb"\lasthline"
% ^^A are used.
% \begin{macrocode}
% \newlength{\extratabsurround}
% \setlength{\extratabsurround}{2pt}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\backup@length}
% ^^A This register will be used internally by \verb"\firsthline" and
% ^^A \verb"\lasthline".
% \begin{macrocode}
% \newlength{\backup@length}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\firsthline}
% ^^A This code can probably be improved but for the moment it should
% ^^A serve.
% ^^A
% ^^A We start by producing a single tabular row without any visible
% ^^A content that will produce the external reference point in case
% ^^A \verb"[t]" is used.
% \begin{macrocode}
% \newcommand{\firsthline}{%}} emacs
% \multicolumn1c{%
% \end{macrocode}
% ^^A Within this row we calculate \verb"\backup@length" to be the height
% ^^A plus depth of a standard line. In addition we have to add the
% ^^A width of the \verb"\hline", something that was forgotten in the
% ^^A original definition.
% \begin{macrocode}
% \global\backup@length\ht\@arstrutbox
% \global\advance\backup@length\dp\@arstrutbox
% \global\advance\backup@length\arrayrulewidth
% \end{macrocode}
% ^^A Finally we do want to make the height of this first line be a bit
% ^^A larger than usual, for this we place the standard array strut
% ^^A into it but raised by \verb"\extratabsurround"
% \begin{macrocode}
% \raise\extratabsurround\copy\@arstrutbox
% \end{macrocode}
% ^^A Having done all this we end the line and back up by the value of
% ^^A \verb"\backup@length" and then finally place our \verb"\hline". This should
% ^^A place the line exactly at the right place but keep the reference
% ^^A point of the whole tabular at the baseline of the first row.
% \begin{macrocode}
% }\\[-\backup@length]\hline
% }
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\lasthline}
% ^^A For \verb"\lasthline" the situation is even worse and I got it
% ^^A completely wrong initially.
% ^^A
% ^^A The problem in this case is that if the optional argument \verb"[b]"
% ^^A is used we do want the reference point of the tabular be at the
% ^^A baseline of the last row but at the same time do want the the
% ^^A depth of this last line increased by \verb"\extratabsurround" without
% ^^A changing the placement \verb"\hline".
% ^^A
% ^^A We start by placing the rule followed by an invisible row.
% \begin{macrocode}
% \newcommand{\lasthline}{\hline\multicolumn1c{%}} emacs
% \end{macrocode}
% ^^A We now calculate \verb"\backup@length" to be the height and depth of
% ^^A two lines plus the width of the rule.
% \begin{macrocode}
% \global\backup@length2\ht\@arstrutbox
% \global\advance\backup@length2\dp\@arstrutbox
% \global\advance\backup@length\arrayrulewidth
% \end{macrocode}
% ^^A This will bring us back to the baseline of the second last row:
% \begin{macrocode}
% }\\[-\backup@length]%
% \end{macrocode}
% ^^A Thus if we now add another invisible row the reference point of
% ^^A that row will be at the baseline of the last row (and will be the
% ^^A reference for the whole tabular). Since this row is invisible we
% ^^A can enlarge its depth by the desired amount.
% \begin{macrocode}
% \multicolumn1c{%
% \lower\extratabsurround\copy\@arstrutbox
% }%
% }
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \subsubsection{Getting the spacing around rules right}
% ^^A
% ^^A Beside a larger functionality \texttt{array.sty} has one
% ^^A important difference to the standard \texttt{tabular} and
% ^^A \texttt{array} environments: horizontal and vertical rules make a
% ^^A table larger or wider, e.g., \verb=\doublerulesep= really denotes
% ^^A the space between two rules and isn't measured from the middle of
% ^^A the rules.
% ^^A
% ^^A \begin{macro}{\@xhline}
% ^^A For vertical rules this is implemented by the definitions above,
% ^^A for horizontal rules we have to take out the backspace.
% \begin{macrocode}
% \CheckCommand*\@xhline{\ifx\reserved@a\hline
% \vskip\doublerulesep
% \vskip-\arrayrulewidth
% \fi
% \ifnum0=`{\fi}}
% \renewcommand*\@xhline{\ifx\reserved@a\hline
% \vskip\doublerulesep
% \fi
% \ifnum0=`{\fi}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% \begin{macrocode}
% %%%%%%%%%% end array.sty 2016/10/06 v2.4d %%%%%%%%%
%
% \end{macrocode}
% ^^A
% ^^A
%
% \subsubsection{Class additions to Array}
%
% \begin{macro}{\m@mold@addamp}
% \begin{macro}{\m@m@addamp}
% \begin{macro}{\@addamp}
%
% In the preamble a \verb?&? has to be inserted between any two columns;
% before the first column there should not be a \verb?&?. As the user
% preamble may start with a \verb?|? we have to remember somehow
% if we have already inserted a \verb?#? (i.e.\ a column). This is done
% with the boolean variable \cs{if@firstamp} that we test in
% \cs{@addamp}, the macro that inserts the \verb?&?.
%
% \begin{PW}
% PW: Later on, for horizontal lines in `continuous' tabulars,
% I need to know how many columns there are in a tabular. I need a modified
% kernel's \cs{@addamp} to do this and use the kernel's \cs{@curtab}
% (a counter used in tabbing) to store the number of columns.
%
% \cs{m@mold@addamp} stores the kernel's definition of \cs{@addamp}, and
% \cs{m@m@addamp} is the revised definition.
% \end{PW}
%
% \changes{v3.7r}{2022/06/20}{Fixed sporious spaces}
% \begin{macrocode}
\newif \@iffirstamp
\let\m@mold@addamp\@addamp
\newcommand*{\m@m@addamp}{%
\if@firstamp
\@firstampfalse
\global\@curtab\@ne
\else
\@addtopreamble{&}%
\global\advance\@curtab\@ne
\fi}
\let\@addamp\m@m@addamp
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{D column specifiers} \label{sec:dcolumns}
%
%
% Here ealier versions of the class had an embedded copy of the
% \Lpack{cdolumn} package. Now replaced by requiring the packge instead.
% \begin{macrocode}
\RequirePackage{dcolumn}[2014/10/28]
% \end{macrocode}
% The embeded copy is outcommented for now and will be removed in a
% later version.
%
% \changes{v3.7h}{2018/09/06}{Outcommented the embedded copy of
% \Lpack{dcolumn} and replaced it with requiring the \Lpack{dcolumn} package
% instead.}
%
% ^^A The description and code are essentially copied from the
% ^^A \Lpack{dcolumn} package~\cite{DCOLUMN}.
% ^^A
% \begin{macrocode}
% %%%%%%%%%% Dcolumn package code %%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%% With acknowledgements to David Carlisle %%%%%%%%%%%%%%%%%%%%%
%
% \end{macrocode}
% ^^A
% ^^A
% ^^A The \Lpack{dcolumn} package~\cite{DCOLUMN} defines \texttt{D}
% ^^A to be a column specifier
% ^^A with three arguments.\\
% ^^A \verb?D?\marg{sep.tex}\marg{sep.dvi}\marg{decimal places}
% ^^A for columns which are to be aligned on a `decimal point'.
% ^^A
% ^^A
% ^^A The basic ideas behind these macros have been explained earlier.
% ^^A However they use three
% ^^A tricks which may be useful in other contexts.
% ^^A \begin{itemize}
% ^^A \item The separator is surrounded in extra \verb?{ }?, so that it is set
% ^^A with \cs{mathord} spacing, otherwise, for instance a `,' would have
% ^^A extra space after it.
% ^^A \item The separator is not given its special definition by making it
% ^^A active, as this would not work for an entry such as \verb?& .5 &?, as the
% ^^A first token of an alignment entry is read \emph{before} the preamble
% ^^A part, incase it is an \cs{omit}, in which case the preamble is to be
% ^^A omitted. Instead we switch the mathcode to (hex) 8000, which makes the
% ^^A token act as if it were active.
% ^^A \item Although \verb?\mathcode`.="8000? makes \texttt{.} act as if it
% ^^A were active, it is still not allowed in constructions such as
% ^^A \verb?\def.{}?, even in math-mode, so we have to construct an active
% ^^A version of the separator, this is done by making it the uppercase of
% ^^A \verb?~?, and then using the construct\\
% ^^A \verb?\uppercase{\def~}?\marg{definition}.\\
% ^^A Note that the \meta{definition} is not uppercased, so the definition
% ^^A can refer to the standard, non-active use of the separator.
% ^^A \end{itemize}
% ^^A
% ^^A \begin{macro}{\DC@}
% ^^A Set up uppercase tables as required, and then grab the first part of
% ^^A the numerical argument into \cs{count@}.
% \begin{macrocode}
% \def\DC@#1#2#3{%
% \uccode`\~=`#1\relax
% \m@th
% \afterassignment\DC@x\count@#3\relax{#1}{#2}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\DC@x}
% ^^A If \cs{count@} is negative, centre on the decimal point. If it is
% ^^A positive either \verb?#1? will be empty in which case bad out decimal
% ^^A part to the number of digits specified by \cs{count@} or
% ^^A it is none empty in which case \cs{count@} contains the
% ^^A number of digits to the left of the point, and \verb?#1? contains a junk
% ^^A token (probably \verb?.?) followed by the number of digits to the right
% ^^A of the point. In either of these latter cases, \cs{DC@right} is used.
% \begin{macrocode}
% \def\DC@x#1\relax#2#3{%
% \ifnum\z@>\count@
% \expandafter\DC@centre
% \else
% \expandafter\DC@right
% \fi
% {#2}{#3}{#1}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\DC@centre}
% ^^A If centering on the decimal point, just need to box up the two halves.
% \begin{macrocode}
% \def\DC@centre#1#2#3{%
% \let\DC@end\DC@endcentre
% \uppercase{\def~}{$\egroup\setbox\tw@=\hbox\bgroup${#2}}%$
% \setbox\tw@=\hbox{${\phantom{{#2}}}$}%
% \setbox\z@=\hbox\bgroup$\mathcode`#1="8000 }%$
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\DC@endcentre}
% ^^A and then pad out the smaller of the two boxes so there is the same
% ^^A amount of stuff either side of the point.
% \begin{macrocode}
% \def\DC@endcentre{$\egroup%$
% \ifdim \wd\z@>\wd\tw@
% \setbox\tw@=\hbox to\wd\z@{\unhbox\tw@\hfill}%
% \else
% \setbox\z@=\hbox to\wd\tw@{\hfill\unhbox\z@}\fi
% \box\z@\box\tw@}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\DC@right}
% ^^A This deals with both the cases where a specified number of decimal
% ^^A places is given.
% \begin{macrocode}
% \def\DC@right#1#2#3{%
% \ifx\relax#3\relax
% \end{macrocode}
% ^^A If \verb?#3? is empty, add \cs{hfill} to right align the column, and
% ^^A Just set \cs{DC@rl} to begin a group, so nothing fancy is done with
% ^^A the whole number part.
% \begin{macrocode}
% \hfill
% \let\DC@rl\bgroup
% \else
% \end{macrocode}
% ^^A Otherwise set \cs{DC@rl} so that the whole number part is put in a
% ^^A box \cs{count@} times as wide as a digit.
% ^^A In order to share code with the other branch, then move \verb?#3? (the
% ^^A number of decimal places) into \cs{count@} throwing away the `.' from
% ^^A the user syntax.
% \begin{macrocode}
% \edef\DC@rl{to\the\count@\dimen@ii\bgroup\hss\hfill}%
% \count@\@gobble#3\relax
% \fi
% \end{macrocode}
% ^^A
% \begin{macrocode}
% \let\DC@end\DC@endright
% \end{macrocode}
% ^^A Box 2 contains the decimal part, set to \cs{dimen@} which is
% ^^A calculated below to be \cs{count@} times the width of a digit, plus
% ^^A the width of the `decimal point'.
% \begin{macrocode}
% \uppercase{\def~}{$\egroup\setbox\tw@\hbox to\dimen@\bgroup${#2}}%
% \setbox\z@\hbox{$1$}\dimen@ii\wd\z@
% \dimen@\count@\dimen@ii
% \setbox\z@\hbox{${#2}$}\advance\dimen@\wd\z@
% \setbox\tw@\hbox to\dimen@{}%
% \end{macrocode}
% ^^A Box 0 contains the whole number part, either just at its natural
% ^^A size for right aligned columns, or set to (the old value of)
% ^^A \cs{count@} times the width of a digit. \cs{DC@rl} defined above
% ^^A determines the two cases.
% \begin{macrocode}
% \setbox\z@\hbox\DC@rl$\mathcode`#1="8000 }%$
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\DC@endright}
% ^^A Just finish off the second box, and then put out both boxes.
% \begin{macrocode}
% \def\DC@endright{$\hfil\egroup\box\z@\box\tw@}%$
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{D}
% ^^A The user interface, define the {\tt D} column to take three arguments.
% ^^A For special purposes, you may need to directly access \cs{DC@} rather
% ^^A than the \verb?D? column, eg to get a bold version you could use
% ^^A\begin{verbatim}
% ^^A \newcolumntype{E}[3]{>{\boldmath\DC@{#1}{#2}{#3}}c<{\DC@end}}
% ^^A\end{verbatim}
% \begin{macrocode}
% \newcolumntype{D}[3]{>{\DC@{#1}{#2}{#3}}c<{\DC@end}}
%
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% \begin{macrocode}
% %%%%%%%%%% end Dcolumn package code %%%%%%%%%%%%%%%%%%%%%
%
% \end{macrocode}
% ^^A
%
%
% \subsection{Support for delimeters}
%
% Here ealier versions of the class had an embedded copy of the
% \Lpack{dearray} package. Now replaced by requiring the packge instead.
% \begin{macrocode}
\RequirePackage{delarray}[2014/10/28]
% \end{macrocode}
% The embeded copy is outcommented for now and will be removed in a
% later version.
%
% \changes{v3.7h}{2018/09/06}{Outcommented the embedded copy of
% \Lpack{delarray} and replaced it with requiring the \Lpack{delarray} package
% instead.}
% ^^A
% ^^A The description and code are essentially from the
% ^^A \Lpack{delarray} package~\cite{DELARRAY}, v1.01 1994/03/14.
% ^^A
% \begin{macrocode}
% %%%%%%%%%% Delarray package code %%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%% With acknowledgements to David Carlisle %%%%%%%%%%%%%%%%%%%%%
%
% \end{macrocode}
% ^^A
% ^^A
% ^^A The array syntax is extended by
% ^^A supporting the notation of delimiters. To this end we extend the
% ^^A array parsing mechanism to include a hook which can be used by this
% ^^A (or another) package to do some additional parsing.
% ^^A
% ^^A
% ^^A \begin{macro}{\@@array}
% ^^A This macro tests for an optional delimiter before the left brace
% ^^A of the main preamble argument. If there is no delimiter,
% ^^A \cs{@arrayleft} and \cs{@arrayright} are made a no-ops, and
% ^^A \cs{@array} is called with the positional argument. Otherwise
% ^^A call \cs{@del@array}.
% \begin{macrocode}
% \def\@@array[#1]{\@ifnextchar\bgroup
% {\let\@arrayleft\relax\let\@arrayright\relax\@array[#1]}%
% {\@del@array[#1]}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\@del@array}
% ^^A We now know that we have an {\tt array} (or {\tt tabular}) with
% ^^A delimiters.
% \begin{macrocode}
% \def\@del@array[#1]#2#3#4{%
% \end{macrocode}
% ^^A The following line is completely redundant but it does catch errors
% ^^A involving delimiters before the processing of the alignment begins.
% ^^A A common error is likely to be omiting the `.' in a
% ^^A \cs{cases}-type construction. This causes the first token of the
% ^^A alignment to be gobbled, possibly causing lots of spurious errors
% ^^A before the cause of the error, the missing delimiter, is discovered as
% ^^A \cs{@arrayright} puts the alignment and the delimiters together.
% \begin{macrocode}
% \setbox\z@\hbox{$\left#2\right#4$}%
% \end{macrocode}
% ^^A In the case of a `c' argument we do not need to rebox the alignment,
% ^^A so we can define \cs{@arrayleft} and \cs{@arrayright} just to
% ^^A insert the delimiters.
% \begin{macrocode}
% \if#1c\def\@arrayleft{\left#2}\def\@arrayright{\right#4}%
% \end{macrocode}
% ^^A Otherwise we (should) have a {\tt[t]} or {\tt[b]} argument, so first we
% ^^A store the alignment, without delimiters in box0.
% \begin{macrocode}
% \else\def\@arrayleft{\setbox\z@}%
% \end{macrocode}
% ^^A Then after the alignment is finished:
% \begin{macrocode}
% \def\@arrayright{%
% \end{macrocode}
% ^^A Calculate the amount the box needs to be lowered (this will be
% ^^A negative in the case of \verb?[b]?). A little bit of arithmetic cf.\
% ^^A \theTeXbook, Appendix G, rule 8. We calculate the amount this
% ^^A way, rather than just taking the difference between the depth of box0
% ^^A and the depth of the box defined below, as the depth of that box may
% ^^A be affected by the delimiters if \cs{delimitershortfall} or
% ^^A \cs{delimiterfactor} have non-standard values.
% \begin{macrocode}
% \dimen@=\dp\z@
% \advance\dimen@-\ht\z@
% \divide \dimen@ by \tw@
% \advance\dimen@ by\fontdimen22 \textfont\tw@
% \end{macrocode}
% ^^A Now lower the alignment and the delimiters into place.
% \begin{macrocode}
% \lower\dimen@\hbox{$\left#2\vcenter{\unvbox\z@}\right#4$}}%
% \end{macrocode}
% ^^A End the \verb?\if#1c?
% \begin{macrocode}
% \fi
% \end{macrocode}
% ^^A Now that we have defined \cs{@arrayleft} and \cs{@arrayright}, call
% ^^A \cs{@array}.
% \begin{macrocode}
% \@array[#1]{#3}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% \begin{macrocode}
% %%%%%%%%%% end Delarray package code %%%%%%%%%%%%%%%%%%%%%
%
% \end{macrocode}
% ^^A
%
%
% \subsection{The tabularx environment}
%
% Here ealier versions of the class had an embedded copy of the
% \Lpack{tabularx} package. Now replaced by requiring the packge instead.
% \begin{macrocode}
\RequirePackage{tabularx}[2016/02/03]
% \end{macrocode}
% The embeded copy is outcommented for now and will be removed in a
% later version.
%
% \changes{v3.7h}{2018/09/06}{Outcommented the embedded copy of
% \Lpack{tabularx} and replaced it with requiring the \Lpack{tabularx} package
% instead.}
%
% ^^A The code and description are essentially from David Carlisle's
% ^^A \Lpack{tabularx} package~\cite{TABULARX}, v2.07 1999/01/07.
% ^^A
% \begin{macrocode}
% %%%%%%%%%% Tabularx package code %%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%% With acknowledgements to David Carlisle %%%%%%%%%%%%%%%%%%%%%
%
% %%% This is a carbon copy of the tabularx dtx sources for v2.11,
% %%% 2016/02/03 with two changes: error messages mention the class
% %%% instead of tabularx.
%
% %%%%%%%%%% Tabularx package code v2.11 2016/02/03 %%%%%%%%%%%%%%%%%%%%%
%
% \end{macrocode}
% ^^A
% ^^A
% ^^A
% ^^A The \Lpack{tabularx} package~\cite{TABULARX} implements a version of the \texttt{tabular}
% ^^A environment in which the widths of certain columns are calculated so
% ^^A that the table is is a specified width. The columns that may stretch are
% ^^A marked by an \texttt{X} in the preamble argument.
% ^^A
% ^^A What follows is a carbon copy of the contents of \texttt{tabularx.dtx} with small changes: (1) We make errors/warnings
% ^^A mention the class instead of \texttt{tabularx}, (2) we strip \texttt{tabularx} related \cs{changes} macros, (3) we
% ^^A remove loading the \Lpack{array} package, as we already come with a copy.
% ^^A
% ^^A First some registers etc.\ that we need.
% \begin{macrocode}
% \newdimen\TX@col@width
% \newdimen\TX@old@table
% \newdimen\TX@old@col
% \newdimen\TX@target
% \newdimen\TX@delta
% \newcount\TX@cols
% \newif\ifTX@
% \end{macrocode}
% ^^A
% ^^A Now a trick to get the body of an environment into a token register, without doing any expansion. This does not do any
% ^^A real checking of nested environments, so if you should need to nest one {\ttfamily tabularx} inside another, the inner
% ^^A one must be surrounded by \verb+{ }+.
% ^^A
% ^^A \begin{macro}{\tabularx}
% ^^A Prior to (\texttt{tabularx}) v1.06, this macro took two arguments, which were saved in
% ^^A separate registers before the table body was saved by \verb+\TX@get@body+.
% ^^A Unfortunately this disables the \verb|[t]| optional argument. Now just save
% ^^A the width specification separately, then clear the token register
% ^^A \verb|\toks@|.
% ^^A Finally call \verb|\TX@get@body| to begin saving the body of the table.
% ^^A The \verb|{\ifnum0=`}\fi| was added at (tabularx) v1.03, to allow \Lenv{tabularx} to appear
% ^^A inside a \verb|\halign|.^^A
% ^^A \setbox0=\hbox{\footnotesize"\iffalse{\fi\ifnum0=`}\fi"}^^A
% ^^A \setbox2=\hbox{\footnotesize"\ifnum0=`{}\fi"}^^A
% ^^A \footnote{This adds an extra level of grouping,
% ^^A which is not really needed. Instead, I could use \box0\ here, and
% ^^A \box2\ below, however the code here would then have to be moved after
% ^^A the first line, because of the footnote to page 386 of the \TeX{}Book,
% ^^A and I do not think I should be writing code that is so obscure as to
% ^^A be documented in a footnote in an appendix called ``Dirty Tricks''!}
% ^^A
% ^^A This mechanism of grabbing an environment body does have the
% ^^A disadvantage (shared with the AMS alignment environments) that you
% ^^A can not make extension environments by code such as
% ^^A\begin{verbatim}
% ^^A\newenvironment{foo}{\begin{tabularx}{XX}}{\end{tabularx}}
% ^^A\end{verbatim}
% ^^A as the code is looking for a literal string \verb"\end{tabularx}" to stop
% ^^A scanning. Since version (tabularx) 2.02, one may avoid this problem by using
% ^^A \verb|\tabularx| and \verb|\endtabularx| directly in the definition:
% ^^A\begin{verbatim}
% ^^A\newenvironment{foo}{\tabularx{XX}}{\endtabularx}
% ^^A\end{verbatim}
% ^^A The scanner now looks for the end of the current environment (\verb|foo| in
% ^^A this example.) There are some restrictions on this usage, the
% ^^A principal one being that \verb|\endtabularx| must not be inside any \verb"{ }" pairs
% ^^A ao that the code before \verb"\endtabularx" may be extracted and added to the table body
% ^^A (prior to version (tabularx) 2.09 \verb"\endtabularx" had to be
% ^^A the \emph{first} token of the `end code' of the environment).
% \begin{macrocode}
% \def\tabularx#1{%
% \end{macrocode}
% ^^A Allow \verb"\tabularx" \verb"\endtabularx" (but not \verb"\begin{tabularx}"
% ^^A \verb"\end{tabularx}") to be used in \verb"\newenvironment" definitions.
% \begin{macrocode}
% \edef\TX@{\@currenvir}%
% {\ifnum0=`}\fi
% \end{macrocode}
% ^^A \verb"\relax" added at v1.05 so that non-expandable length tokens, like
% ^^A \verb"\textwidth" do not generate an extra space, and an overfull box.
% ^^A \verb"\relax" removed again at v4.09 in favour of \verb"\setlength" so if you
% ^^A use the calc package you can use a width of \verb"(\textwidth-12pt)/2".
% \begin{macrocode}
% \setlength\TX@target{#1}%
% \TX@typeout{Target width: #1 = \the\TX@target.}%
% \toks@{}\TX@get@body}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \begin{macro}{\endtabularx}
% ^^A This does not do very much\ldots
% \begin{macrocode}
% \let\endtabularx\relax
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@get@body}
% ^^A Place all tokens as far as the first \verb"\end" into a token register.
% ^^A Then call \verb"\TX@find@end" to see if we are at \verb"\end{tabularx}".
% \begin{macrocode}
% \long\def\TX@get@body#1\end
% {\toks@\expandafter{\the\toks@#1}\TX@find@end}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@find@end}
% ^^A If we are at \verb"\end{tabularx}", call \verb"\TX@endtabularx", otherwise
% ^^A add \verb"\end{...}" to the register, and call \verb"\TX@get@body" again.
% \begin{macrocode}
% \def\TX@find@end#1{%
% \def\@tempa{#1}%
% \ifx\@tempa\TX@\expandafter\TX@endtabularx
% \else\toks@\expandafter
% {\the\toks@\end{#1}}\expandafter\TX@get@body\fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@find@endtabularxa}
% ^^A split up the end code, and extract the part that lives in the table body.
% \begin{macrocode}
% \long\def\TX@find@endtabularxa
% #1\endtabularx#2\endtabularx#3\TX@find@endtabularxa{%
% \ifx\TX@#2\relax\else
% \toks@\expandafter{\the\toks@#1}%
% \fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \begin{macro}{\TX@find@endtabularxb}
% ^^A split up the end code, and extract the part that lives outside the table body.
% \begin{macrocode}
% \long\def\TX@find@endtabularxb
% #1\endtabularx#2\endtabularx#3\TX@find@endtabularxb{%
% \ifx\TX@#2%
% \expandafter\@firstoftwo
% \else
% \expandafter\@secondoftwo
% \fi
% {#1}{#2}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@find@endtabularxbb}
% ^^A Helper to avoid needing 15 consecutive \verb"\expandafter"
% \begin{macrocode}
% \def\TX@find@endtabularxbb{%
% \expandafter\expandafter\expandafter
% \TX@find@endtabularxb
% }
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@}
% ^^A The string {\ttfamily tabularx} as a macro for testing with \verb"\ifx".
% \begin{macrocode}
% \def\TX@{tabularx}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A Now that all the parts of the table specification are stored in
% ^^A registers, we can begin the work of setting the table.
% ^^A
% ^^A The algorithm for finding the correct column widths is as follows.
% ^^A Firstly set the table with each {\ttfamily X} column the width of the
% ^^A final table. Assuming that there is at least one {\ttfamily X} column,
% ^^A this will produce a table that is too wide. Divide the excess width by
% ^^A the number of {\ttfamily X} columns, and reduce the column width by
% ^^A this amount. Reset the table. If the table is not now the correct
% ^^A width, a \verb"\multicolumn" entry must be `hiding' one of the {\ttfamily
% ^^A X} columns, and so there is one less {\ttfamily X} column affecting
% ^^A the width of the table. So we reduce by 1 the number of X columns and
% ^^A repeat the process.
% ^^A
% ^^A \begin{macro}{\TX@endtabularx}
% ^^A Although I have tried to make {\ttfamily tabularx} look like an
% ^^A environment, it is in fact a command, all the work is done by this
% ^^A macro.
% \begin{macrocode}
% \def\TX@endtabularx{%
% \expandafter\expandafter\expandafter
% \TX@find@endtabularxa\csname end\TX@\endcsname
% \endtabularx\TX@\endtabularx\TX@find@endtabularxa
% \end{macrocode}
% ^^A Define the {\ttfamily X} column, with an internal version of the
% ^^A \verb"\newcolumntype" command. The \verb"\expandafter" commands enable
% ^^A \verb"\NC@newcol" to get the {\em expansion} of\\
% ^^A \verb"\tabularxcolumn{\TX@col@width}" as its
% ^^A argument. This will be the definition of an {\ttfamily X} column, as
% ^^A discussed in section 4.
% \begin{macrocode}
% \expandafter\TX@newcol\expandafter{\tabularxcolumn{\TX@col@width}}%
% \end{macrocode}
% ^^A Initialise the column width, and the number of {\ttfamily X} columns.
% ^^A The number of {\ttfamily X} columns is set to one, which means that
% ^^A the initial count will be one too high, but this value is decremented
% ^^A before it is used in the main loop.
% ^^A
% ^^A Since v1.02, switch the definition of \verb"\verb".
% \begin{macrocode}
% \let\verb\TX@verb
% \end{macrocode}
% ^^A Since v1.05, save the values of all \LaTeX\ counters, the list
% ^^A \verb"\cl@@ckpt" contains the names of all the \LaTeX\ counters that have
% ^^A been defined so far. We expand \verb"\setcounter" at this point, as it
% ^^A results in fewer tokens being stored in \verb"\TX@ckpt", but the actual
% ^^A resetting of the counters occurs when \verb"\TX@ckpt" is expanded after
% ^^A each trial run.
% ^^A Actually since v1.07, use something equivalent to the expansion of the
% ^^A original definition of \verb"\setcounter", so that \verb"tabularx" works in
% ^^A conjunction with \verb"calc.sty".
% \begin{macrocode}
% \def\@elt##1{\global\value{##1}\the\value{##1}\relax}%
% \edef\TX@ckpt{\cl@@ckpt}%
% \let\@elt\relax
% \TX@old@table\maxdimen
% \TX@col@width\TX@target
% \global\TX@cols\@ne
% \end{macrocode}
% ^^A Typeout some headings (unless this is disabled).
% \begin{macrocode}
% \TX@typeout@
% {\@spaces Table Width\@spaces Column Width\@spaces X Columns}%
% \end{macrocode}%
% ^^A First attempt. Modify the {\ttfamily X} definition to count {\ttfamily
% ^^A X} columns.
% \begin{macrocode}
% \TX@trial{\def\NC@rewrite@X{%
% \global\advance\TX@cols\@ne\NC@find p{\TX@col@width}}}%
% \end{macrocode}
% ^^A Repeatedly decrease column width until table is the correct width,
% ^^A or stops shrinking, or the columns become two narrow.
% ^^A If there are no multicolumn entries, this will only take one attempt.
% \begin{macrocode}
% \loop
% \TX@arith
% \ifTX@
% \TX@trial{}%
% \repeat
% \end{macrocode}
% ^^A One last time, with warnings back on (see appendix D)
% ^^A use {\ttfamily tabular*} to put it in a box of the right size, in case
% ^^A the algorithm failed to find the correct size.
% ^^A
% ^^A Since v1.04, locally make \verb"\footnotetext" save its argument in a token
% ^^A register.
% ^^A Since v1.06, \verb"\toks@" contains the preamble specification,
% ^^A and possible optional argument, as well as the table body.
% \begin{macrocode}
% {\let\@footnotetext\TX@ftntext\let\@xfootnotenext\TX@xftntext
% \csname tabular*\expandafter\endcsname\expandafter\TX@target
% \the\toks@
% \csname endtabular*\endcsname}%
% \end{macrocode}
% ^^A Now the alignment is finished, and the \verb"}" has restored the original
% ^^A meaning of \verb"\@footnotetext" expand the register \verb"\TX@ftn" which will
% ^^A execute a series of\\
% ^^A \verb"\footnotetext["\meta{num}\verb"]{"\meta{note}\verb"}"\\
% ^^A commands. We need to be careful about clearing the register as we may
% ^^A be inside a nested {\ttfamily tabularx}.
% \begin{macrocode}
% \global\TX@ftn\expandafter{\expandafter}\the\TX@ftn
% \end{macrocode}
% ^^A Now finish off the {\ttfamily tabularx} environment. Note that we need
% ^^A \verb"\end{tabularx}" here as the \verb"\end{tabularx}" in the user's
% ^^A file is never expanded. Now use \verb"\TX@" rather than \verb"tabularx".
% ^^A
% ^^A We also need to finish off the group started by \verb"{\ifnum0=`}\fi" in
% ^^A the macro \verb"\tabularx".
% \begin{macrocode}
% \ifnum0=`{\fi}%
% \expandafter\expandafter\expandafter
% \TX@find@endtabularxbb
% \expandafter\end\expandafter{\TX@}%
% \endtabularx\TX@\endtabularx\TX@find@endtabularxb
% }
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A
% ^^A \begin{macro}{\TX@arith}
% ^^A Calculate the column width for the next try, setting the flag
% ^^A \verb"\ifTX@" to false if the loop should be aborted.
% \begin{macrocode}
% \def\TX@arith{%
% \TX@false
% \@tempdimb\maxdimen
% \divide\@tempdimb\TX@cols
% \ifdim\TX@col@width>\@tempdimb
% \TX@typeout@{Don't exceed \maxdimen}%
% \wd\@tempboxa\maxdimen
% \fi
% \ifdim\TX@old@table=\wd\@tempboxa
% \end{macrocode}
% ^^A If we have reduced the column width, but the table width has not
% ^^A changed, we stop the loop, and output the table (which will cause an
% ^^A over-full alignment) with the previous value of \verb"\TX@col@width".
% \begin{macrocode}
% \TX@col@width\TX@old@col
% \TX@typeout@{Reached minimum width, backing up.}%
% \else
% \end{macrocode}
% ^^A Otherwise calculate the amount by which the current table is too wide.
% \begin{macrocode}
% \dimen@\wd\@tempboxa
% \advance\dimen@ -\TX@target
% \ifdim\dimen@<\TX@delta
% \end{macrocode}
% ^^A If this amount is less than \verb"\TX@delta", stop. (\verb"\TX@delta"
% ^^A should be non-zero otherwise we may miss the target due to rounding
% ^^A error.)
% \begin{macrocode}
% \TX@typeout@{Reached target.}%
% \else
% \end{macrocode}
% ^^A Reduce the number of effective {\ttfamily X} columns by one. (Checking
% ^^A that we do not get 0, as this would produce an error later.) Then
% ^^A divide excess width by the number of effective columns, and calculate
% ^^A the new column width. Temporarily store this value (times $-1$) in
% ^^A \verb"\dimen@".
% \begin{macrocode}
% \ifnum\TX@cols>\@ne
% \advance\TX@cols\m@ne
% \fi
% \divide\dimen@\TX@cols
% \advance\dimen@ -\TX@col@width
% \ifdim \dimen@ >\z@
% \end{macrocode}
% ^^A If the new width would be too narrow, abort the loop. At the moment
% ^^A too narrow, means less than 0\,pt!
% ^^A
% ^^A Prior to v2.03, if the loop was aborted here, the X columns were left
% ^^A with the width of the previous run, but this may make the table far
% ^^A too wide as initial guesses are always too big. Now force to
% ^^A \verb"\TX@error@width" which defaults to be 1em. If you want to
% ^^A get the old behaviour stick\\
% ^^A \verb"\renewcommand\TX@error@width{\TX@col@width}"\\
% ^^A in a package file loaded after \textsf{tabularx}.
% \begin{macrocode}
% %\PackageWarning{tabularx}%
% \@memwarn{X Columns too narrow (table too wide)\MessageBreak}% <-- change here
% \TX@col@width\TX@error@width\relax
% \else
% \end{macrocode}
% ^^A Otherwise save the old settings, and set the new column width. Set the
% ^^A flag to true so that the table will be set, and the loop will be
% ^^A executed again.
% \begin{macrocode}
% \TX@old@col\TX@col@width
% \TX@old@table\wd\@tempboxa
% \TX@col@width-\dimen@
% \TX@true
% \fi
% \fi
% \fi}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@error@width}
% ^^A If the calculated width is negative, use this instead.
% \begin{macrocode}
% \def\TX@error@width{1em}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@delta}
% ^^A Accept a table that is within \verb"\hfuzz" of the correct width.
% \begin{macrocode}
% \TX@delta\hfuzz
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A Initialise the {\ttfamily X} column. The definition can be empty here,
% ^^A as it is set for each {\ttfamily tabularx} environment.
% \begin{macrocode}
% \newcolumntype{X}{}
% \end{macrocode}
% ^^A
% ^^A \begin{macro}{\tabularxcolumn}
% ^^A The default definition of {\ttfamily X} is \verb"p{#1}".
% \begin{macrocode}
% \def\tabularxcolumn#1{p{#1}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@newcol}
% ^^A A little macro just used to cut down the number of \verb"\expandafter"
% ^^A commands needed.
% \begin{macrocode}
% \def\TX@newcol{\newcol@{X}[0]}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@trial}
% ^^A Make a test run.
% \begin{macrocode}
% \def\TX@trial#1{%
% \setbox\@tempboxa\hbox{%
% \end{macrocode}
% ^^A Any extra commands. This is used on the first run to count the number
% ^^A of {\ttfamily X} columns.
% \begin{macrocode}
% #1\relax
% \end{macrocode}
% ^^A Since v1.04, make \verb"\footnotetext" gobble its arguments. Also locally
% ^^A clear \verb"\TX@vwarn" so that the warning is generated by the {\ttfamily
% ^^A final} run, and does not appear in the middle of the table if
% ^^A \verb"\tracingtabularx".
% \begin{macrocode}
% \let\@footnotetext\TX@trial@ftn
% \let\TX@vwarn\@empty
% \end{macrocode}
% ^^A Do not nest {\ttfamily tabularx} environments during trial runs. This
% ^^A would waste time, and the global setting of \verb"\TX@cols" would break the
% ^^A algorithm.
% \begin{macrocode}
% \expandafter\let\expandafter\tabularx\csname tabular*\endcsname
% \expandafter\let\expandafter\endtabularx\csname endtabular*\endcsname
% \end{macrocode}
% ^^A Added at v1.05: disable \verb"\write"s during a trial run. This trick is
% ^^A from the \TeX{}Book.\footnote{Actually the \TeX{}Book trick does
% ^^A not work correctly, so changed for v2.05.}
% \begin{macrocode}
% \def\write{\begingroup
% \def\let{\afterassignment\endgroup\toks@}%
% \afterassignment\let\count@}%
% \end{macrocode}
% ^^A Turn off warnings (see appendix D). Also prevent them being turned
% ^^A back on by setting the parameter names to be registers.
% \begin{macrocode}
% \hbadness\@M
% \hfuzz\maxdimen
% \let\hbadness\@tempcnta
% \let\hfuzz\@tempdima
% \end{macrocode}
% ^^A Make the table, and finish the hbox.
% ^^A Since v1.06, \verb"\toks@" contains the preamble specification,
% ^^A and possible optional argument, as well as the table body.
% \begin{macrocode}
% \expandafter\tabular\the\toks@
% \endtabular}%
% \end{macrocode}
% ^^A Since v1.05 reset all \LaTeX\ counters, by executing \verb"\TX@ckpt".
% \begin{macrocode}
% \TX@ckpt
% \end{macrocode}
% ^^A Print some statistics.
% ^^A Added \verb"\TX@align" in v1.05, to line up the columns.
% \begin{macrocode}
% \TX@typeout@{\@spaces
% \expandafter\TX@align
% \the\wd\@tempboxa\space\space\space\space\space\@@
% \expandafter\TX@align
% \the\TX@col@width\space\space\space\space\space\@@
% \@spaces\the\TX@cols}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@align}
% ^^A Macro added at v1.05, to improve the printing of the tracing info.
% \begin{macrocode}
% \def\TX@align#1.#2#3#4#5#6#7#8#9\@@{%
% \ifnum#1<10 \space\fi
% \ifnum#1<100 \space\fi
% \ifnum#1<\@m\space\fi
% \ifnum#1<\@M\space\fi
% #1.#2#3#4#5#6#7#8\space\space}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\arraybackslash}
% ^^A \verb"\\" hack.
% \begin{macrocode}
% \ifx\arraybackslash\@undefined
% \def\arraybackslash{\let\\\tabularnewline}
% \fi
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\tracingtabularx}
% ^^A Print statistics on column and table widths.
% \begin{macrocode}
% \def\tracingtabularx{%
% %\def\TX@typeout{\PackageWarningNoLine{tabularx}}%
% \def\TX@typeout{\ClassWarningNoLine{memoir}}% <--- changed
% \def\TX@typeout@##1{\typeout{(tabularx) ##1}}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@typeout}
% ^^A The default is to be to be quiet
% \begin{macrocode}
% \let\TX@typeout\@gobble
% \let\TX@typeout@\@gobble
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@ftn}
% ^^A A token register for saving footnote texts.
% \begin{macrocode}
% \newtoks\TX@ftn
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@ftntext}
% ^^A \begin{macro}{\TX@xftntext}
% ^^A Inside the alignment just save up the footnote text in a token
% ^^A register.
% \begin{macrocode}
% \long\def\TX@ftntext#1{%
% \edef\@tempa{\the\TX@ftn\noexpand\footnotetext
% [\the\csname c@\@mpfn\endcsname]}%
% \global\TX@ftn\expandafter{\@tempa{#1}}}%
% \long\def\TX@xftntext[#1]#2{%
% \global\TX@ftn\expandafter{\the\TX@ftn\footnotetext[#1]{#2}}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@trial@ftn}
% ^^A On trial runs, gobble footnote texts.
% \begin{macrocode}
% \long\def\TX@trial@ftn#1{}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A This last section was added at Version 1.02. Previous versions
% ^^A documented the fact that \verb"\verb" did not work inside {\ttfamily
% ^^A tabularx}, but that did not stop people using it! This usually put
% ^^A \LaTeX\ into an irrecoverable error position, with error messages that
% ^^A did not mention the cause of the error. The `poor man's \verb"\verb"' (and
% ^^A \verb"\verb*") defined here is based on page 382 of the \TeX{}Book. As
% ^^A explained there, doing verbatim this way means that spaces are not
% ^^A treated correctly, and so \verb"\verb*" may well be useless, however I
% ^^A consider this section of code to be error-recovery, rather than a real
% ^^A implementation of verbatim.
% ^^A
% ^^A The mechanism is quite general, and any macro which wants to allow a
% ^^A form of \verb"\verb" to be used within its argument may
% ^^A \verb"\let\verb=\TX@verb". (Making sure to restore the real definition
% ^^A later!)
% ^^A
% ^^A \verb"\verb" and \verb"\verb*" are subject to the following restrictions:
% ^^A \begin{enumerate}
% ^^A \item Spaces in the argument are not read verbatim, but may be skipped
% ^^A according to \TeX's usual rules.
% ^^A \item Spaces will be added to the output after control words, even if
% ^^A they were not present in the input.
% ^^A \item Unless the argument is a single space, any trailing space,
% ^^A whether in the original argument, or added as in (2),
% ^^A will be omitted.
% ^^A \item The argument must not end with \verb"\", so \verb"\verb|\|" is not
% ^^A allowed, however, because of (3), \verb"\verb|\ |" produces
% ^^A \verb"\".
% ^^A \item The argument must be balanced with respect to \verb"{" and \verb"}". So
% ^^A \verb"\verb|{|" is not allowed.
% ^^A \item A comment character like \verb"%" will not appear verbatim. It will
% ^^A act as usual, commenting out the rest of the input line!
% ^^A \item The combinations \verb"?`" and \verb"!`" will appear as
% ^^A {\ttfamily?`} and {\ttfamily!`} if the {\ttfamily cmtt} font is
% ^^A being used.
% ^^A \end{enumerate}
% ^^A
% ^^A \begin{macro}{\TX@verb}
% ^^A The internal definition of \verb"\verb". Spaces will be replaced by \verb"~", so
% ^^A for the star-form, \verb"\let" \verb"~" be \verb*| |, which we obtain as
% ^^A \verb"\uppercase{*}". Use \verb"{\ifnum0=`}\fi" rather than \verb"\bgroup" to allow
% ^^A \verb"&" to appear in the argument.
% \begin{macrocode}
% {\uccode`\*=`\ %
% \uppercase{\gdef\TX@verb{%
% \leavevmode\null\TX@vwarn
% {\ifnum0=`}\fi\ttfamily\let\\\ignorespaces
% \@ifstar{\let~*\TX@vb}{\TX@vb}}}}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@vb}
% ^^A Get the `almost verbatim' text using \verb"\meaning". The `\verb"!"' is added to
% ^^A the front of the user supplied text, to ensure that the whole argument
% ^^A does not consist of a single \verb"{ }" group. \TeX\ would strip the outer
% ^^A braces from such a group. The `\verb"!"' will be removed later.
% ^^A
% ^^A Originally I followed Knuth, and had \verb"\def\@tempa{##1}", however this
% ^^A did not allow \verb"#" to appear in the argument. So in v1.04, I changed
% ^^A this to to use a token register, and \verb"\edef". This allows \verb"#" appear,
% ^^A but makes each one appear twice!, so later we loop through, replacing
% ^^A \verb"##" by \verb"#".
% \begin{macrocode}
% \def\TX@vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}%
% \expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@v}
% ^^A Strip the initial segment of the \verb"\meaning", including the `\verb"!"'
% ^^A added earlier.
% \begin{macrocode}
% \def\TX@v#1!{\afterassignment\TX@vfirst\let\@tempa= }
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A As explained above we are going to replace \verb"##" pairs by \verb"#". To do
% ^^A this we need non-special \verb"#" tokens. Make \verb"*" into a parameter
% ^^A token so that we can define macros with arguments. The normal meanings
% ^^A will be restored by the \verb"\endgroup" later.
% \begin{macrocode}
% \begingroup
% \catcode`\*=\catcode`\#
% \catcode`\#=12
% \end{macrocode}
% ^^A
% ^^A \begin{macro}{\TX@vfirst}
% ^^A As a special case, prevent the first character from being dropped.
% ^^A This makes \verb"\verb*| |" produce \verb*| |. Then call \verb"\TX@v@".
% ^^A This is slightly tricky since v1.04, as I have to ensure that an
% ^^A actual \verb"#" rather than a command \verb"\let" to \verb"#" is passed on if the
% ^^A first character is \verb"#".
% \begin{macrocode}
% \gdef\TX@vfirst{%
% \if\@tempa#%
% \def\@tempb{\TX@v@#}%
% \else
% \let\@tempb\TX@v@
% \if\@tempa\space~\else\@tempa\fi
% \fi
% \@tempb}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@v@}
% ^^A Loop through the \verb"\meaning", replacing all spaces by \verb"~". If the last
% ^^A character is a space it is dropped, so that \verb"\verb*|\LaTeX|" produces
% ^^A \verb"\LaTeX" not \verb*|\LaTeX |. The rewritten tokens are then further
% ^^A processed to replace \verb"##" pairs.
% \begin{macrocode}
% \gdef\TX@v@*1 *2{%
% \TX@v@hash*1##\relax\if*2\\\else~\expandafter\TX@v@\fi*2}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A \begin{macro}{\TX@v@hash}
% ^^A The inner loop, replacing \verb"##" by \verb"#".
% \begin{macrocode}
% \gdef\TX@v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX@v@hash\fi*2}
% \end{macrocode}
% ^^A \end{macro}
% ^^A
% ^^A As promised, we now restore the normal meanings of \verb"#" and \verb"*".
% \begin{macrocode}
% \endgroup
% \end{macrocode}
% ^^A
% ^^A \begin{macro}{\TX@vwarn}
% ^^A Warn the user the first time this \verb"\verb" is used.
% \begin{macrocode}
% \def\TX@vwarn{%
% \@warning{\noexpand\verb may be unreliable inside tabularx}%
% \global\let\TX@vwarn\@empty}
% \end{macrocode}
% ^^A \end{macro}
% \begin{macrocode}
%
% %%%%%%%%%% end Tabularx package code v2.11 %%%%%%%%%%%%%%%%%%%%%
%
%
%
%
% \end{macrocode}
% ^^A
% ^^A At this point we had better stop anyone trying to load the several
% ^^A tabular-related packages (as effectively they are already loaded).
% \begin{macrocode}
% %%\@memfakeusepackage{array}
% %%\@memfakeusepackage{dcolumn}
% %%\@memfakeusepackage{delarray}
% %%\@memfakeusepackage{tabularx}
%
% \end{macrocode}
% ^^A
% ^^A
%
% \subsection{Fear's rules}
%
% Simon Fear disapproves of the default \LaTeX{} table rules and
% wrote the \Lpack{booktabs} package~\cite{BOOKTABS} to provide
% better horizontal rules. Like many typographers, he abhors vertical rules.
%
%
% \begin{macro}{\bktabrule}
% The rules in this section are based on \verb?\hrule \@height#1? but this
% does not
% work for continuous tabulars. Provide a version of this that
% can be \cs{let} when necessary.
% \begin{macrocode}
\newcommand*{\bktabrule}[1]{%
\hrule \@height#1}
% \end{macrocode}
% \end{macro}
%
% The following is taken almost verbatim from the \Lpack{booktabs} package,
% version~1.618, March 2003.
%
% \begin{macrocode}
%%%%%%%%%% Booktabs package code %%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% slightly modified by PRW %%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% by permission of Simon Fear %%%%%%%%%%%%%%%%%%%%%
% \end{macrocode}
% Danie Els is now (2005) the official maintainer of the \Lpack{booktabs} package. He provided me with
% some updates to synchronize \Lpack{memoir}, \Lpack{booktabs} and support for \Lpack{colortbl} with \Lpack{booktabs}. I made the appropriate changes/extensions
% on 2005/09/03 as part of version 1.618 of \Lpack{memoir}.
%
% \begin{macro}{\CT@arc@}
% This supports the \Lpack{bookhands}/\Lpack{colortbl} package combination.
% \begin{macrocode}
\AtBeginDocument{%
\providecommand*{\CT@arc@}{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\heavyrulewidth}
% \begin{macro}{\lightrulewidth}
% \begin{macro}{\cmidrulewidth}
% \begin{macro}{\belowrulesep}
% \begin{macro}{\belowbottomsep}
% \begin{macro}{\aboverulesep}
% \begin{macro}{\abovetopsep}
% \begin{macro}{\cmidrulesep}
% \begin{macro}{\cmidrulekern}
% \begin{macro}{\defaultaddspace}
% First we set up some new dimensions.
% \begin{macrocode}
\newdimen\heavyrulewidth
\newdimen\lightrulewidth
\newdimen\cmidrulewidth
\newdimen\belowrulesep
\newdimen\belowbottomsep
\newdimen\aboverulesep
\newdimen\abovetopsep
\newdimen\cmidrulesep
\newdimen\cmidrulekern
\newdimen\defaultaddspace
\heavyrulewidth=.08em
\lightrulewidth=.05em
\cmidrulewidth=.03em
\belowrulesep=.65ex
\belowbottomsep=\z@
\aboverulesep=.4ex
\abovetopsep=\z@
\cmidrulesep=\doublerulesep
\cmidrulekern=.5em
\defaultaddspace=.5em
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@cmidla}
% \begin{macro}{\@cmidlb}
% \begin{macro}{\@aboverulesep}
% \begin{macro}{\@belowrulesep}
% \begin{macro}{\@thisruleclass}
% \begin{macro}{\@lastruleclass}
% \begin{macro}{\@thisrulewidth}
% And some internal counters and other things of no interest to the end user:
% \begin{macrocode}
\newcount\@cmidla
\newcount\@cmidlb
\newdimen\@aboverulesep
\newdimen\@belowrulesep
\newcount\@thisruleclass
\newcount\@lastruleclass
\@lastruleclass=0
\newdimen\@thisrulewidth
% \end{macrocode}
% which will be described as needed below.
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\futurenonspacelet}
% \begin{macro}{\@BTfnslone}
% \begin{macro}{\@BTfnsltwo}
% \begin{macro}{\@BTfnslthree}
% Next we define a very useful macro (more-or-less straight from the
% \theTeXbook's Dirty Tricks chapter; documented there). Use
% \cs{futurenonspacelet} instead of \cs{futurelet} when looking for the next
% (non-space) token after a macro that has an argument. (After a macro
% without an argument, space is ignored anyway, so \cs{futurenonspacelet}
% wouldn't be needed.) This hack allows users to type white
% space between successive rule commands.
% \begin{macrocode}
\def\futurenonspacelet#1{\def\@BTcs{#1}%
\afterassignment\@BTfnslone\let\nexttoken= }
\def\@BTfnslone{\expandafter\futurelet\@BTcs\@BTfnsltwo}
\def\@BTfnsltwo{\expandafter\ifx\@BTcs\@sptoken\let\next=\@BTfnslthree
\else\let\next=\nexttoken\fi \next}
\def\@BTfnslthree{\afterassignment\@BTfnslone\let\next= }
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Full width rules}
%
% When we are not in a \texttt{longtable} environment, we can simply
% implement the full width rules as a \cs{hrule} in a \verb?\noalign{}?
% group. But within a \texttt{longtable}, the rule has to be drawn like a
% \verb?\cmidrule{1-\LT@cols}? (the rationale for this is explained in the
% \texttt{longtable} documentation).
% In order to allow for both, all the rule macros have to
% open a \cs{noalign} group immediately, while they work out whether
% they have been called within a \texttt{longtable}; if you don't do this,
% \TeX's underlying \cs{halign} process gets hiccups.
% I use \LaTeX's
% dirty trick (\verb?\ifnum=0`}?) to fool the parser that the bracket
% count is OK. The bracket really gets closed after all the skipping
% at the end of the \cs{@BTendrule} macro.
% The class 1 rules, and \cs{specialrule}, really only differ in the
% defaults for space above and
% below, and the width, passed to a common routine, \cs{@BTrule},
% described below. The spaces, \cs{@aboverulesep} and \cs{@belowrulesep},
% are set within the \cs{noalign} group, so are inherited by
% \cs{@BTrule}. Similarly, \cs{@BTrule} knows as much as it needs to
% about the routine that called it by examining the inherited
% \cs{@thisruleclass}. The optional width argument is parsed by
% \cs{@BTrule} after being set to default if absent.
%
% \begin{macro}{\toprule}
% \begin{macro}{\midrule}
% \begin{macro}{\bottomrule}
% \begin{macro}{\specialrule}
% \begin{macrocode}
\def\toprule{\noalign{\ifnum0=`}\fi
\@aboverulesep=\abovetopsep
\global\@belowrulesep=\belowrulesep
\global\@thisruleclass=\@ne
\@ifnextchar[{\@BTrule}{\@BTrule[\heavyrulewidth]}}
\def\midrule{\noalign{\ifnum0=`}\fi
\@aboverulesep=\aboverulesep
\global\@belowrulesep=\belowrulesep
\global\@thisruleclass=\@ne
\@ifnextchar[{\@BTrule}{\@BTrule[\lightrulewidth]}}
\def\bottomrule{\noalign{\ifnum0=`}\fi
\@aboverulesep=\aboverulesep
\global\@belowrulesep=\belowbottomsep
\global\@thisruleclass=\@ne
\@ifnextchar[{\@BTrule}{\@BTrule[\heavyrulewidth]}}
\def\specialrule#1#2#3{\noalign{\ifnum0=`}\fi
\@aboverulesep=#2\global\@belowrulesep=#3\global\@thisruleclass=\tw@
\@BTrule[#1]}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\addlinespace}
% An \cs{addlinespace} is essentially a zero-width rule with
% zero space above and argument (or default) space below. But because
% the rule is not actually drawn, but is just a \cs{vskip}, there is no
% need to check if we're in a longtable, so we don't need to call
% \cs{@BTrule} as for `real' rules. But we do share the \cs{@BTendrule}
% lookahead and flagsetting code (described below), and the \cs{vskip} is done there.
% \begin{macrocode}
\def\addlinespace{\noalign{\ifnum0=`}\fi
\@ifnextchar[{\@addspace}{\@addspace[\defaultaddspace]}}
\def\@addspace[#1]{\global\@belowrulesep=#1\global\@thisruleclass=\tw@
\futurelet\@tempa\@BTendrule}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@BTrule}
% All the rules (except \cs{addlinespace}) share this code.
% \begin{macrocode}
\def\@BTrule[#1]{%
% \end{macrocode}
% Note (2016/05/16): code rearranged a bit to come back into sync with
% \Lpack{booktabs} v1.618033.
%
% \changes{v3.7f}{2016/05/16}{changed the order so the \cs{ifx} lines
% come first. From booktabs 2016/04/27 v1.618033}
% \changes{v3.7k}{2020/02/06}{changed to be in sync with booktabs
% datad 2020/01/12. The comments are a carbon copy from booktabs.dtx}
% Now we work out, by a very nasty hack, if we're within a
% \verb|longtable|. It's easy if \verb=\longtable= isn't even defined: then we
% can't be. But it is not enough just to check if \verb=longtable= is
% loaded --- we might be within an ordinary table rather than a
% longtable. So we look to see if \verb=\hline= has been re-defined
% from its \LaTeX\ definition to be the same as
% \verb=\LT@hline=. (Longtable currently does this redefinition when it opens a
% \verb=longtable= environment, but not globally, so it is
% cleared it when the environment closes.) Another
% package could potentially do this! And \verb=longtable= might change the
% way it implements this! So, it is not entirely safe, but I have
% found no better way so far.
%
% We set up \verb=\@BTswitch= to call \verb=\@BTnormal= or \verb=\@BLTrule=, as
% appropriate, then call it.
% \begin{macrocode}
\ifx\longtable\undefined
\let\@BTswitch\@BTnormal
\else\ifx\hline\LT@hline
\nobreak
\let\@BTswitch\@BLTrule
\else
\let\@BTswitch\@BTnormal
\fi\fi
% \end{macrocode}
% Call \verb=\@BTswitch= at end of macro
% \begin{macrocode}
\global\@thisrulewidth=#1\relax
% \end{macrocode}
% Save the width argument (if the user didn't give one, then the
% calling routine will have called \cs{@BTrule} with the default) in a global
% variable for later use when drawing the rule.
% \begin{macrocode}
\ifnum\@thisruleclass=\tw@\vskip\@aboverulesep\else
% \end{macrocode}
% Specialrules always insert specified space above. (Note: addlinespaces
% don't come here).
% \begin{macrocode}
\ifnum\@lastruleclass=\z@\vskip\@aboverulesep\else
\ifnum\@lastruleclass=\@ne\vskip\doublerulesep\fi\fi\fi
% \end{macrocode}
% After text (last rule class 0), precede the rule by \cs{aboverulesep};
% but if immediately after a
% previous rule, insert a \cs{doublerulesep}.
%
% \begin{macrocode}
\@BTswitch}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@BTnormal}
% This is when we're \emph{not} within a longtable. We are already in a
% \cs{noalign} group, all we need do is draw an \cs{hrule} and gobble any
% trailing spaces, then call the closing routine with \cs{@tempa} set
% equal to the next token in the document.
% \begin{macrocode}
% \def\@BTnormal{\hrule
% \@height \@thisrulewidth\futurenonspacelet\@tempa\@BTendrule}
\def\@BTnormal{%
%% \bktabrule{\@thisrulewidth}
{\CT@arc@\bktabrule{\@thisrulewidth}}%
\futurenonspacelet\@tempa\@BTendrule}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@BLTrule}
% This is for full width rule within a \texttt{longtable}. First we check if
% a kerning argument has been used; if so let \cs{@@BLTrule} read it,
% else call \cs{@@BLTrule} with an empty string:
% \begin{macrocode}
\def\@BLTrule{\@ifnextchar({\@@BLTrule}{\@@BLTrule()}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@@BLTrule}
% \begin{macrocode}
\def\@@BLTrule(#1){\@setrulekerning{#1}%
\global\@cmidlb\LT@cols
% \end{macrocode}
% The \cs{@setrulekerning} routine parses the kerning argument tokens
% and sets global kerning widths accordingly (or to defaults, if user
% hasn't set them explicitly). The global assignment to \cs{@cmidlb}
% sets up the column count for the \cs{@cmidruleb} macro, which is
% shared with \verb?cmidrules?.
% \begin{macrocode}
\ifnum0=`{\fi}%
% \end{macrocode}
% Close the currently open \cs{noalign} group. Within a \texttt{longtable},
% rules are all to be drawn as leaders within a text box that is
% \cs{LT@cols} columns wide.
% \begin{macrocode}
\@cmidruleb
% \end{macrocode}
% Draw the rule. We share the \cs{@cmidruleb} code with ordinary \cs{cmidrule}s.
% \begin{macrocode}
\noalign{\ifnum0=`}\fi
% \end{macrocode}
% We have to open a new noalign immediately else \TeX{} will start a new
% text box where we don't want one. Then, after gobbling any
% unwanted white space, we call the closing routine.
% \begin{macrocode}
\futurenonspacelet\@tempa\@BTendrule}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@BTendrule}
% We look one step ahead (token is in \cs{@tempa}) to see if another
% rule follows (shame on user!). If so, we set \cs{@lastruleclass} equal
% to \cs{@thisruleclass} (thus setting it up for the following rule). If
% there isn't a following rule, we clear \cs{@lastruleclass} (ie set it
% to zero), which isn't technically true since we have just drawn a
% rule, but sets it up correctly for the next rule encountered, which
% must be following some intervening text.
% \begin{macrocode}
\def\@BTendrule{%
\ifx\@tempa\toprule\global\@lastruleclass=\@thisruleclass
\else\ifx\@tempa\midrule\global\@lastruleclass=\@thisruleclass
\else\ifx\@tempa\bottomrule\global\@lastruleclass=\@thisruleclass
\else\ifx\@tempa\cmidrule\global\@lastruleclass=\@thisruleclass
\else\ifx\@tempa\specialrule\global\@lastruleclass=\@thisruleclass
\else\ifx\@tempa\addlinespace\global\@lastruleclass=\@thisruleclass
\else\global\@lastruleclass=\z@\fi\fi\fi\fi\fi\fi
\ifnum\@lastruleclass=\@ne\relax\else\vskip\@belowrulesep\fi
\ifnum0=`{\fi}}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Special subrules}
%
% \begin{macro}{\@setrulekerning}
% The following code parses the trimming arguments (if there are any)
% for \cs{cmidrule} or a \cs{BLTrule}. The rule
% will be trimmed left and right by \cs{cmrkern@l} and \cs{cmrkern@l},
% which are zero by default, set to \cs{cmidrulekern} by the plain
% \verb?(lr)? arguments, or user set as in \verb?(r{.5em})?. We parse token by
% token through the arguments. The
% tokens \verb?r? and \verb?l? cause \cs{cmrkern@r} or \cs{cmrkern@l} to be set to
% \cs{cmidrulekern}. There is no lookahead to see if a width is the
% next token; this strategy is efficient for the plain commands,
% while inefficient for the qualified commands, but more importantly
% it is much easier to program. Tokens \verb?r? and \verb?l? also set
% \cs{cmrswitch} so that if the next token turns out to be
% \marg{wd} then the kerning will be done on the side
% currently specified. I have been too lazy to program an error
% message should one encounter tokens other than \verb?r?, \verb?l? or
% \marg{wd}.
% \changes{v1.618}{2005/09/03}{Fixed bug in booktabs trim command by improving character comparison code in \cs{@setrulekerning} (mempatch v3.8)}
% \begin{macrocode}
\def\@setrulekerning#1{%
\global\let\cmrkern@l\z@
\global\let\cmrkern@r\z@
\@tfor\@tempa :=#1\do
{\def\@tempb{r}%
\ifx\@tempa\@tempb
\global\let\cmrkern@r\cmidrulekern
\def\cmrsideswitch{\cmrkern@r}%
\else
\def\@tempb{l}%
\ifx\@tempa\@tempb
\global\let\cmrkern@l\cmidrulekern
\def\cmrsideswitch{\cmrkern@l}%
\else
\global\expandafter\let\cmrsideswitch\@tempa
\fi
\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cmidrule}
% \begin{macro}{\@cmidrule}
% \begin{macro}{\@@cmidrule}
% The \cs{cmidrule} re-uses \cs{@lastruleclass} in an entirely different
% way from the full width rules. (Maybe I should have used a
% different flag; it seemed efficient at the time \ldots). This
% is (left) set to one if you are in the middle of a row of
% \cs{cmidrules}, or starting a new one (with \cs{morecmidrules}).
% Otherwise, when \cs{@lastruleclass} is zero, we precede the
% rule with \cs{aboverulesep}.
% \begin{macrocode}
\def\cmidrule{\noalign{\ifnum0=`}\fi
\@ifnextchar[{\@cmidrule}{\@cmidrule[\cmidrulewidth]}}
\def\@cmidrule[#1]{\@ifnextchar({\@@cmidrule[#1]}{\@@cmidrule[#1]()}}
\def\@@cmidrule[#1](#2)#3{\@@@cmidrule[#3]{#1}{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@@cmidrule}
% The above is fiddling around to set defaults for missing optional
% arguments. We also pass to \cs{@@@cmidrule} in a different order,
% namely =[a-b]=\verb?{width required}= \verb?{kerning commands}= (this being
% the order in which the arguments are actually processed):
% \begin{macrocode}
\def\@@@cmidrule[#1-#2]#3#4{\global\@cmidla#1\relax
\global\advance\@cmidla\m@ne
\ifnum\@cmidla>0\global\let\@gtempa\@cmidrulea\else
\global\let\@gtempa\@cmidruleb\fi
\global\@cmidlb#2\relax
\global\advance\@cmidlb-\@cmidla
% \end{macrocode}
% This has set up a switch (\cs{@gtempa}) to call the relevant routine,
% \cs{@cmidrulea} or \cs{@cmidruleb}, depending on whether we start
% from column one or not.
% \begin{macrocode}
\global\@thisrulewidth=#3
% \end{macrocode}
% That is, set per default or given argument. Then parse any trimming
% arguments to set, globally, \cs{cmrkern@r} and \cs{cmrkern@l} accordingly:
% \begin{macrocode}
\@setrulekerning{#4}
% \end{macrocode}
% Now insert space above if needed, close the \cs{noalign},
% then switch to appropriate rule drawing routine as determined
% above (\cs{let} to \cs{@gtempa}):
% \begin{macrocode}
\ifnum\@lastruleclass=\z@\vskip \aboverulesep\fi
\ifnum0=`{\fi}\@gtempa
% \end{macrocode}
% Having now drawn the rule,
% open another \cs{noalign}, and call the closing routine:
% \begin{macrocode}
\noalign{\ifnum0=`}\fi\futurenonspacelet\@tempa\@xcmidrule}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xcmidrule}
% In this closing routine, see if another \cs{cmidrule} follows;
% if so, backspace
% vertical so it will line up with the one you just drew,
% and setting \cs{@lastruleclass} to 1 will suppress
% adding space above the next. If a \cs{morecimdrules} follows,
% we add (positive) \cs{cmidrulesep} (and again set \cs{@lastruleclass}
% to one). Otherwise this is the last rule of the current group
% and we can just add \cs{belowrulesep}. Finally, we close the \cs{noalign}.
% \begin{macrocode}
\def\@xcmidrule{\ifx\@tempa\cmidrule\vskip-\@thisrulewidth
\global\@lastruleclass=\@ne\else
\ifx\@tempa\morecmidrules\vskip \cmidrulesep
\global\@lastruleclass=\@ne\else
\vskip \belowrulesep\global\@lastruleclass=\z@\fi\fi
\ifnum0=`{\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cmidrulea}
% \begin{macro}{\@cmidruleb}
% This code (called below) actually draws the rules. They are drawn
% as boxes in text, rather than in a \cs{noalign} group, which permits
% the left and right kerning.
% \changes{v3.7f}{2016/05/16}{Added \cs{kern}\cs{z@} to comply to
% latest booktabs updates. In Booktabs they were added to protect
% against unskips.}
% \begin{macrocode}
\def\@cmidrulea{%
\multispan\@cmidla&\multispan\@cmidlb
%% \unskip\hskip \cmrkern@l\leaders\bktabrule{\@thisrulewidth}\hfill
\unskip\hskip \cmrkern@l{%
\CT@arc@\leaders\bktabrule{\@thisrulewidth}\hfill\kern\z@}%
\hskip \cmrkern@r\cr}
\def\@cmidruleb{%
\multispan\@cmidlb
%% \unskip\hskip \cmrkern@l\leaders\bktabrule{\@thisrulewidth}\hfill
\unskip\hskip \cmrkern@l{%
\CT@arc@\leaders\bktabrule{\@thisrulewidth}\hfill\kern\z@}%
\hskip \cmrkern@r\cr}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\morecmidrules}
% This is really a dummy command; all the work is done above
% within the \cs{cmidrule} routine. We look one step ahead there
% to see if a \cs{morecmidrules} follows the current \cs{cmidrule},
% and if so set the flag. Otherwise, \cs{morecmidrules} itself
% does nothing.
% \begin{macrocode}
\def\morecmidrules{\noalign{\relax}}
%%%%%%%%%% end of Booktabs package code %%%%%%%%%%%%%%%%%%%%%
% \end{macrocode}
% \end{macro}
%
% Ensure that the real \Lpack{booktabs} package can't get called.
% \changes{v1.618}{2005/09/03}{Killed use of real booktabs package (mempatch v3.12)}
% \begin{macrocode}
%%\@memfakeusepackage{booktabs}
% \end{macrocode}
%
%
%
% \subsection{Continuous tabulars}
%
% The standard \texttt{tabular} environment is wrapped inside a box
% (see \verb?\@tabular?),
% which means that it cannot break across pages. Equivalent environments
% are provided which are not boxed and so can continue across page
% boundaries.
%
% \begin{macro}{\ctableftskip}
% \begin{macro}{\ctabrightskip}
% These skips are inserted at the left and right of continuous tabulars
% so that their horizontal location can be specified.
% \begin{macrocode}
\newskip\ctableftskip \ctableftskip=\fill
\newskip\ctabrightskip \ctabrightskip=\fill
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\ctabular*}
% \begin{macro}{\@ctabularstar}
% This starts off the \texttt{ctabular*} continuous tabular environment.
% The default location is centered. NOTE: This is not for release.
% \begin{macrocode}
\expandafter\def\csname ctabular*\endcsname{%
\@ifnextchar[ {\@ctabularstar}{\@ctabularstar[c]}}
\def\@ctabularstar[#1]#2{\global\@curtab\@ne
\ctableftskip\fill
\ctabrightskip\fill
\if l#1% left
\ctableftskip\z@
\else
\if r#1% right
\ctabrightskip\z@
\fi
\fi
\setlength\dimen@{#2}%
\xdef\@halignto{to\the\dimen@}\NC@tabular}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ctabular}
% \verb?\ctabular? is similar to \verb?\ctabular*? except that the
% width is known to be \verb?\hsize?.
% \begin{macrocode}
\newcommand*{\ctabular}[1][c]{\global\@curtab\@ne
\ctableftskip\fill
\ctabrightskip\fill
\if l#1% left
\ctableftskip\z@
\else
\if r#1% right
\ctabrightskip\z@
\fi
\fi
\gdef\@halignto{to\hsize}\NC@tabular}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NC@tabular}
% \verb?\NC@tabular?
% \begin{macrocode}
\newcommand*{\NC@tabular}{%
\par
\addvspace{\topsep}
\col@sep\tabcolsep
\let\d@llarbegin\begingroup
\let\d@llarend\endgroup
\@NCtabarray}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@NCialign}
% \begin{macrocode}
\newcommand*{\@NCialign}{\everycr{}\tabskip\ctableftskip\halign}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@NCtabarray}
% Effectively a modified version of \verb?\@array?
% \begin{macrocode}
\newcommand*{\@NCtabarray}[1]{%
\@tempdima \ht\strutbox
\advance\@tempdima\extrarowheight
\setbox \@arstrutbox \hbox{\vrule
\@height \arraystretch \@tempdima
\@depth \arraystretch \dp\strutbox
\@width\z@}%
\begingroup
%% \@mkpream{@{\hspace{\@totalleftmargin}}#1@{}}%
\@mkpream{#1}%
\xdef\@preamble{\@NCialign \@halignto
\bgroup & \tabskip\z@
\@arstrut
\@preamble
\tabskip\ctabrightskip
\cr}%
\endgroup
\let\@sharp ##\let\protect\relax
\lineskip\z@
\baselineskip\z@
\let\\\@arraycr
\let\tabularnewline\\%
\let\par\@empty
\ctabsetlines
\@preamble
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endctabular}
% \begin{macro}{\endctabular*}
% End the environments.
% \begin{macrocode}
\def\endctabular{%
\crcr \egroup
\gdef\@preamble{}%
\addvspace{\topsep}
\noindent}
\expandafter\let\csname endctabular*\endcsname=\endctabular
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% \subsubsection{Horizontal lines}
%
% The standard \cs{hline} can produce odd results when used with
% continuous tabulars, but \cs{hhline} or \cs{cline} are OK.
% I want a version of \cs{hline}
% that works with continuous tabulars and has an adjustable width
% (i.e., thickness). This will be based on a modified \cs{cline}
%
% For reference, here are the essentials of the kernel's definitions.
% \begin{verbatim}
% \def\hline{%
% \noalign{\ifnum0=`}\fi\hrule \@height \arrayrulewidth \futurelet
% \reserved@a\@xhline}
% \def\@xhline{%
% \ifx\reserved@a\hline
% \vskip\doublerulesep
% \vskip-\arrayrulewidth
% \fi
% \ifnum0=`{\fi}}
% \def\cline#1{\@cline#1\@nil}
% \def\@cline#1-#2\@nil{%
% \omit
% \@multicnt#1%
% \advance\@multispan\m@ne
% \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
% \@multicnt#2%
% \advance\@multicnt-#1%
% \advance\@multispan\@ne
% \leaders\hrule\@height\arrayrulewidth\hfill
% \cr
% \noalign{\vskip-\arrayrulewidth}}
% \end{verbatim}
%
% \begin{macro}{\memcline}
% \begin{macro}{\m@m@cline}
% This is a version of the kernel \cs{cline} code that provides
% a variable width.
% \begin{macrocode}
\newcommand*{\memcline}[2]{\m@m@cline[#1]#2\@nil}
\def\m@m@cline[#1]#2-#3\@nil{%
\omit
\@multicnt#2%
\advance\@multispan\m@ne
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#3%
\advance\@multicnt-#2%
\advance\@multispan\@ne
\leaders\hrule\@height #1\hfill % <- variable \@height value
\cr
\noalign{\vskip- #1}} % <- variable \@height value
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memhline}
% \begin{macro}{\m@mhline}
% A version of \cs{hline}, based on \cs{memcline}, taking a
% rule width as argument. It draws a \cs{memcline} from the
% first to the last (\cs{@curtab}) column.
% \begin{macrocode}
\newcommand*{\memhline}[1][\arrayrulewidth]{\memcline{#1}{1-\@curtab}}
\newcommand*{\m@mhline}{\cline{1-\@curtab}}
% \end{macrocode}
%\end{macro}
%\end{macro}
%
% Fear's rules also do not play well within continuous tabulars.
%
% \begin{macro}{\m@m@BTnormal}
% Special version of \cs{@BTnormal}
% \begin{macrocode}
\def\m@m@BTnormal{%
\ifnum0=`{\fi} % closes the \noalign
\multispan{\@curtab} \leaders\bktabrule{\@thisrulewidth}\hfill\cr
\noalign{\ifnum0=`}\fi
\futurenonspacelet\@tempa\@BTendrule}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\ctabsetlines}
% Continuous tabulars cannot use the standard horizontal lines.
% \begin{macrocode}
\def\ctabsetlines{%
\let\hline\m@mhline
\let\@BTnormal\m@m@BTnormal}
% \end{macrocode}
% \end{macro}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% \subsection{Automated tabulations}
%
%
% It can be convenient, especially while drafting a document, to have
% a list of items put into a tabular without having to mark the ends
% of the rows.
%
% The following is based on plain \TeX{} code given on pages 307--308 of
% \textit{TeX for the Impatient}~\cite{bk:Impatient}, which provides
% code for typesetting in columns.
%
%
% \begin{macro}{\abovecolumnspenalty}
% \begin{macro}{\@linestogo}
% \begin{macro}{\@cellstogo}
% \begin{macro}{\@cellsincolumn}
% \begin{macro}{\crtok}
% Counters and such.
% \begin{macrocode}
\newcount\abovecolumnspenalty
\abovecolumnspenalty=10000
\newcount\@linestogo % lines remaining to be procesed
\newcount\@cellstogo % cells remaining in column or row
\newcount\@cellsincolumn % number of lines per column
\newtoks\crtok
\crtok = {\cr}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mincolumnwidth}
% \begin{macro}{\c@lleftskip}
% \begin{macro}{\c@lrightskip}
% More things
% \begin{macrocode}
\newdimen\@mincolumnwidth
\let\c@lleftskip\hfil % left skip within a column
\let\c@lrightskip\hfil % right skip within a column
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\preautotab}
% \begin{macro}{\postautotab}
% Hooks into the auto tabulations.
% \begin{macrocode}
\let\preautotab\relax
\let\postautotab\relax
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\autocols}
% \cs{autocols}\oarg{width}\marg{pos}\marg{num}\marg{style}\marg{comma separated list}
% arranges the elements in the \meta{comma separated list} into \meta{num}
% columns, the elements filling each column before moving to the next.
% That is, the elements are ordered top to bottom and left to right.
% \begin{macrocode}
\newcommand{\autocols}[5][0pt]{\par\begingroup
\ctabsetlines
% \end{macrocode}
% Set the table position
% \begin{macrocode}
\if l#2
\raggedright
\else
\if r#2
\raggedleft
\else
\centering
\fi
\fi
% \end{macrocode}
% Set the column position style
% \begin{macrocode}
\let\c@lleftskip\hfil
\let\c@lrightskip\hfil
\if l#4
\let\c@lleftskip\relax
\else
\if r#4
\let\c@lrightskip\relax
\fi
\fi
% \end{macrocode}
% Count the number of entries and the minimum width (max entry width)
% for the columns.
% \begin{macrocode}
\@mincolumnwidth\z@
\TX@cols=#3
\@curtab=#3
\@linestogo\z@
\@for\@tempa:=#5\do{
\advance\@linestogo\@ne
\settowidth{\@tempdima}{\@tempa}
\ifdim\@tempdima>\@mincolumnwidth
\@mincolumnwidth=\@tempdima
\fi
}
\advance\@mincolumnwidth\tabcolsep
\linespercol
% \end{macrocode}
% Specify what is to be done after every entry
% \begin{macrocode}
\def\@endcolumnactions{%
\global\advance\@linestogo\m@ne
\ifnum\@cellstogo<\tw@
\global\advance\TX@cols\m@ne
\ifnum\TX@cols>\z@\linespercol\fi
\the\crtok
\else
&\global\advance\@cellstogo\m@ne
\fi}%
% \end{macrocode}
% Calculate the width of the columns
% \begin{macrocode}
\ifdim #1 > \z@
\TX@col@width=#1
\divide\TX@col@width \TX@cols
\else
\TX@col@width=\@mincolumnwidth
\fi
\penalty\abovecolumnspenalty
\noindent% usually not a paragraph
% \end{macrocode}
% Create most of the preamble by looping to add \cs{@cellsincolumn}-1 slots,
% then the last one which is different.
% \begin{macrocode}
\def\@preamble{}%
\begingroup
\let\@sharp\relax
\ifnum\@cellsincolumn>\@ne
\loop
\g@addto@macro{\@preamble}{%
\hb@xt@ \TX@col@width{%
\c@lleftskip\strut\@sharp\c@lrightskip} &}%
\advance\@cellsincolumn\m@ne
\ifnum\@cellsincolumn>\@ne
\repeat
\fi
\g@addto@macro{\@preamble}{%
\hb@xt@ \TX@col@width{\c@lleftskip\strut\@sharp\c@lrightskip}}%
\endgroup
\let\@sharp ##
% \end{macrocode}
% Start the \cs{valign}
% \begin{macrocode}
\tabskip\ctableftskip
%% \tabskip\z@
\valign \bgroup
\tabskip\z@
\@preamble
\tabskip\ctabrightskip\cr
% \end{macrocode}
% Add all the entries then finish off.
% \begin{macrocode}
\@for\@tempa:=#5\do{
\@tempa\unskip\space\@endcolumnactions}%
\the\crtok \egroup \par \endgroup}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\linespercol}
% \cs{linespercol} calculates the maximum number of lines that go into
% a column, where there are \cs{TX@cols} columns and \cs{@linestogo}
% lines, so that the columns are balanced as well as possible. The result
% is \cs{@cellstogo}
% \begin{macrocode}
\newcommand*{\linespercol}{%
\@cellsincolumn=\@linestogo
\divide\@cellsincolumn \TX@cols
\@cellstogo=\@cellsincolumn
\multiply\@cellstogo \TX@cols
\@tempcnta=\@linestogo
\advance\@tempcnta -\@cellstogo
\ifnum \@tempcnta>\z@
\advance\@cellsincolumn \@ne
\fi
\global\@cellstogo=\@cellsincolumn}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\autorows}
% \cs{autorows}\oarg{width}\marg{pos}\marg{num}\marg{style}\marg{comma separated list}
% arranges the elements in the \meta{comma separated list} into \meta{num}
% columns, the elements filling each row before moving to the next.
% That is, the elements are ordered left to right and top to bottom.
% By default, each column is the same width, enough for the widest entry.
% If \meta{width} is a negative length (e.g., -1pt) the columns are set
% to their natural
% widths. If \meta{width} is positive (e.g., \cs{textwidth}), column widths
% are equal widths so that the overal width is \meta{width}.
% The sideways location of thre tabular is \meta{pos} (l, c, or r), and
% the column style id \meta{style} (l, c, or r).
% \begin{macrocode}
\newcommand{\autorows}[5][0pt]{\par\begingroup
\ctabsetlines
% \end{macrocode}
% Set the table position
% \begin{macrocode}
\ctableftskip\fill
\ctabrightskip\fill
\if l#2
\ctableftskip\z@
\else
\if r#2
\ctabrightskip\z@
\fi
\fi
% \end{macrocode}
% Set the column position style
% \begin{macrocode}
\let\c@lleftskip\hfil
\let\c@lrightskip\hfil
\if l#4
\let\c@lleftskip\relax
\else
\if r#4
\let\c@lrightskip\relax
\fi
\fi
% \end{macrocode}
% Count the number of entries and the minimum width (max entry width)
% for the columns.
% \begin{macrocode}
\TX@cols=#3\relax
\@curtab=#3\relax
\@cellstogo = \TX@cols
\@mincolumnwidth\z@
\@linestogo\z@
\@for\@tempa:=#5\do{%
\advance\@linestogo\@ne
\settowidth{\@tempdima}{\@tempa}
\ifdim\@tempdima>\@mincolumnwidth
\@mincolumnwidth=\@tempdima
\fi}%
\advance\@mincolumnwidth\tabcolsep
% \end{macrocode}
% Specify what is to be done after every entry
% \begin{macrocode}
\def\@endcolumnactions{%
\global\advance\@linestogo\m@ne
\global\advance\@cellstogo\m@ne
\ifnum\@cellstogo<\@ne
\global\@cellstogo=\TX@cols
\the\crtok
\else
&
\fi}%
% \end{macrocode}
% Calculate the width of the columns
% \begin{macrocode}
\ifdim #1>\z@
\TX@col@width=#1
\else
\TX@col@width=\hsize
\fi
\divide\TX@col@width \TX@cols
\ifdim #1=\z@
\TX@col@width=\@mincolumnwidth
\fi
\penalty\abovecolumnspenalty
\noindent % usually not a paragraph
\vskip -\z@ % don't know why we need this, but looks bad without it
% \end{macrocode}
% Create most of the preamble by looping to add \cs{@cellsincolumn}-1 slots,
% then the last one which is different.
% \begin{macrocode}
\def\@preamble{}%
\begingroup
\let\@sharp\relax
\ifnum\TX@cols>\@ne
\loop
\ifdim #1<\z@
\g@addto@macro{\@preamble}{%
\strut\c@lleftskip\@sharp\c@lrightskip &}%
\else
\g@addto@macro{\@preamble}{%
\hb@xt@ \TX@col@width{%
\strut\c@lleftskip\@sharp\c@lrightskip} &}%
\fi
\advance\TX@cols\m@ne
\ifnum\TX@cols>\@ne
\repeat
\fi
\ifdim #1<\z@
\g@addto@macro{\@preamble}{%
\strut\c@lleftskip\@sharp\c@lrightskip}%
\else
\g@addto@macro{\@preamble}{%
\hb@xt@ \TX@col@width{\strut\c@lleftskip\@sharp\c@lrightskip}}%
\fi
\endgroup
\let\@sharp ##
% \end{macrocode}
% Start the \verb?\halign?
% \begin{macrocode}
\tabskip\ctableftskip
\halign to \hsize \bgroup
\tabskip\z@
\@preamble
%% \tabskip\ctabrightskip\cr \preautotab
\tabskip\ctabrightskip\cr
% \end{macrocode}
% Add all the entries then finish off.
% \begin{macrocode}
\@for\@tempa:=#5\do{%
\@tempa\unskip\space\@endcolumnactions}%
%% \the\crtok \postautotab \the\crtok \egroup \endgroup \par
\the\crtok \egroup \endgroup \par}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \section{Floating objects}
%
% The file \file{latex.dtx} only defines a number of tools with
% which floating objects can be defined. This is done in the
% document class. It needs to define the following macros for each
% floating object of type \texttt{TYPE} (e.g., \texttt{TYPE} =
% figure).
%
% \begin{description}
% \item[\texttt{\bslash fps@TYPE}]
% The default placement specifier for floats of type
% \texttt{TYPE}.
%
% \item[\texttt{\bslash ftype@TYPE}]
% The type number for floats of type \texttt{TYPE}. Each
% \texttt{TYPE} has associated a unique positive \texttt
% {TYPE} number, which is a power of two. E.g., figures might
% have type number 1, tables type number 2, programs type
% number 4, etc.
%
% \item[\texttt{\bslash ext@TYPE}]
% The file extension indicating the file on which the contents
% list for float type \texttt{TYPE} is stored. For example,
% \cs{ext@figure} = `lof'.
%
% \item[\texttt{\bslash fnum@TYPE}]
% A macro to generate the figure number for a caption. For
% example, \cs{fnum@TYPE} == `Figure \cs{thefigure}'.
%
% \item[\texttt{\bslash @makecaption}{\meta{num}}{\meta{text}}]
% A macro to make a caption, with \meta{num} the value produced
% by \cs{fnum@...} and \meta{text} the text of the caption. It
% can assume it's in a \cs{parbox} of the appropriate width.
% This will be used for \emph{all} floating objects.
%
% \end{description}
%
% The actual environment that implements a floating object such as
% a figure is defined using the macros \cs{@float} and \cs{end@float},
% which are defined in \file{latex.dtx}.
%
% An environment that implements a single column floating object is
% started with \verb?\@float{TYPE}?\oarg{placement} of type
% \texttt{TYPE} with \meta{placement} as the placement specifier.
% The default value of \meta{PLACEMENT} is defined by \cs{fps@TYPE}.
%
% The environment is ended by \cs{end@float}. E.g., \cs{figure} ==
% \verb?\@float{figure}?, \cs{endfigure} == \cs{end@float}.
%
%
% \subsection{Floats}
%
% To define a float environment, say \Lenv{fenv}, the following macros must be defined:
% \begin{itemize}
% \item \cs{fps@fenv} The default placement specifier (normally \verb?tbp?).
% \item \cs{ftype@fenv} The type number which is an integer and a power of 2.
% \item \cs{ext@fenv} The file extension for the contents list.
% \item \cs{c@fenv} A counter for the environment (for caption numbering).
% \item \cs{fnum@fenv} A macro to generate the caption `number'.
% \item \cs{l@fenv} A macro to produce an entry in a list of\ldots.
% \item \cs{flegtocfenv} A macro to write a \cs{namedlegend} title to a listof file.
% \item \cs{flegfenv} A macro to typeset the name of a \cs{namedlegend}.
% \item \cs{toclevel@fenv} Holding a bookmark level (required if the
% \Lpack{hyperref} package will be used).
% \end{itemize}
%
% \begin{macro}{newflo@tctr}
% A counter for the type number of a new float. Normally
% figures are of type 1, tables type 2, and the next float type is then 4, and so
% on.
% \begin{macrocode}
\newcounter{newflo@tctr}
\setcounter{newflo@tctr}{1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newfloat}
% \cs{newfloat}oarg{within}\marg{fenv}\marg{ext}\marg{capname}
% creates the commands for a new float environment, \meta{fenv} (aka \texttt{X}),
% using \meta{ext} (aka \texttt{Z}) as the
% file extension and \meta{capname} for the caption name.
% \changes{v1.61803}{2008/01/30}{Changed setting of \cs{ftype@X} in
% \cs{newfloat} to correctly assign float numbers, courtesy Flavian
% Lambert (mempatch v4.9)}
% \begin{macrocode}
\newcommand{\newfloat}[4][\@empty]{%
% \end{macrocode}
% \begin{macro}{\ftype@X}
% Define the float type, set it to the float counter, and double
% the counter afterwards.
% \begin{macrocode}
%%% \@namedef{ftype@#2}{\value{newflo@tctr}}
%%% \addtocounter{newflo@tctr}{\value{newflo@tctr}}
\expandafter\edef\csname ftype@#2\endcsname{\the\c@newflo@tctr}%
\advance\c@newflo@tctr \c@newflo@tctr
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@X}
% Create the counter for the caption, which must not have been previously
% defined.
% \begin{macrocode}
\@ifundefined{c@#2}{% counter is not defined
\ifx \@empty#1\relax
\newcounter{#2}
\else
\newcounter{#2}[#1]
\expandafter\edef\csname the#2\endcsname{%
\expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}}
\fi}{}
\setcounter{#2}{0}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ext@X}
% \begin{macro}{\c@Zdepth}
% Define \cs{ext@X} for the file extension and set the new \verb?Zdepth?
% depth counter to 1.
% \begin{macrocode}
\@namedef{ext@#2}{#3}% file extension
\@ifundefined{c@#3depth}{\newcounter{#3depth}}{}
\setcounter{#3depth}{1}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\fps@X}
% \begin{macro}{\fnum@X}
% \begin{macro}{\flegX}
% \begin{macro}{\flegtocX}
% \cs{fps@X} is the default float placement specification, \cs{fnum@X}
% typesets the caption name and number, and \cs{flegX} and \cs{flegtocX} are for
% named legends.
% \begin{macrocode}
\@namedef{fps@#2}{tbp} % position
\@namedef{fnum@#2}{#4~\@nameuse{the#2}} % caption naming
\@namedef{fleg#2}{#4} % legend naming
\@namedef{flegtoc#2}##1{} % legend name in ToC
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{environment}{X}
% \begin{environment}{X*}
% Finally define the new float environment, in both normal and starred
% forms. We also al an internal macro that can be used to globally
% adjust floats, e.g. making all tables in small size.
% We would like to be able to insert adjustments inside the
% floats. But the manner in which \cs{@float} works makes it
% impossible for us to simple insert this into the definitions of the
% floats.
% \begin{macrocode}
\newenvironment{#2}{\@float{#2}}{\end@float}
\newenvironment{#2*}{\@dblfloat{#2}}{\end@dblfloat}
% \end{macrocode}
% \end{environment}
% \end{environment}
%
% This ends the definition of \cs{newfloat}.
% \begin{macrocode}
} % end \newfloat
% \end{macrocode}
% \end{macro}
%
% \changes{v3.6i}{2011/02/18}{Added this instead of inserting the
% adjustment code directly into the environment definitions}
% \changes{v3.7g}{2017/05/08}{Moved into delayed \cs{@xfloat} redef as
% we need it to run after \cs{normalsize}}
% \begin{macro}{\@xfloat}
% In order to inject adjustment code into the core of the floats we
% will need to patch the code float macros a little.
% \begin{macrocode}
%\let\mem@old@xfloat\@xfloat
%\def\@xfloat#1[#2]{\mem@old@xfloat{#1}[#2]\@nameuse{#1adjustment}}
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\setfloatlocations}
% \cs{setfloatlocations}\marg{float}\marg{locs} sets the defualt locations
% for the \meta{float} class of floats (e.g., \texttt{figure}) to \meta{locs}
% (initially \texttt{tbp}). For tables you might want to use: \\
% \verb?\setfloatlocations{table}{htbp}?
% \changes{v1.61803}{2008/01/30}{Added \cs{setfloatlocations} (mempatch v4.9)}
% \begin{macrocode}
\newcommand*{\setfloatlocations}[2]{\@namedef{fps@#1}{#2}}
% \end{macrocode}
% \end{macro}
% \changes{v3.6h}{2011/02/01}{Added \cs{setfloatadjustment}}
% \begin{macro}{\setfloatadjustment}
% \cs{setfloatadjustment}\marg{float}\marg{code} can be used to
% globally add internal adjustments to all floats of a certain
% type. For example to typeset the contents of all tables in
% \cs{small} use \verb|\setfloatadjustment{table}{\small}|.
% \begin{macrocode}
\newcommand*\setfloatadjustment[2]{\@namedef{#1adjustment}{#2}}
% \end{macrocode}
%
% \end{macro}
%
%
% To define subcaptions for use in a new float environment, say \texttt{fenv}, the
% following macros must be defined~\cite{SUBFIGURE}:
% \begin{itemize}
% \item A new counter \texttt{subfenv} for subcaption numbering.
% \item A new counter \texttt{extdepth}, where \texttt{ext} is the file extension
% for the contents list of \texttt{fenv}, for setting the contents depth.
% \item \cs{thesubfenv} for the formatting of the subcaption number.
% \item \cs{@thesubfenv} for typesetting the number.
% \item \cs{@@thesubfenv} for alternative label reference.
% \item \cs{p@subfenv} for prepending to the subcaption number when it is referenced.
% \item \cs{ext@subfenv} the file extension for the contents list.
% \item \cs{l@subfenv} for formatting the contents list entry.
% \item \cs{@makesubfloatcaption} for typesetting the subcaption.
% \item \cs{toclevel@subfenv} for hyperref bookmarks
% \end{itemize}
%
% \begin{macro}{\newsubfloat}
% \cs{newsubfloat}\marg{fenv} creates the commands for a new
% subfloat for \meta{fenv} (aka \texttt{X}).
% \begin{macrocode}
\newcommand{\newsubfloat}[1]{%
% \end{macrocode}
% Call \verb?\newlistentry[X]{subX}{extX}{1}? to get most of the work done.
% \begin{macrocode}
\newlistentry[#1]{sub#1}{\@nameuse{ext@#1}}{1}
% \end{macrocode}
%
% \begin{macro}{\ext@subX}
% \begin{macro}{\thesubX}
% \begin{macro}{\@thesubX}
% \begin{macro}{\@@thesubX}
% \begin{macro}{\p@subX}
% \begin{macro}{\toclevel@subX}
% And now for the rest of the commands for subcaptions.
% \changes{v1.1}{2002/03/10}{Added \cs{@namedef} of \cs{@@thesubenv}
% to \cs{newsubfloat}}
% \changes{v1.1}{2002/03/10}{Added \cs{@namedef} of \cs{toclevel@subenv}
% to \cs{newsubfloat}}
% \begin{macrocode}
\@namedef{ext@sub#1}{\csname ext@#1\endcsname}
\@namedef{thesub#1}{(\alph{sub#1})}
\@namedef{@thesub#1}{\@nameuse{thesub#1}%
\if@tightsubcap\hskip\subfloatlabelskip\else\space\fi}
\@namedef{@@thesub#1}{\@nameuse{thesub#1}}
\@namedef{p@sub#1}{\csname the#1\endcsname}
\@namedef{toclevel@sub#1}{1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% By permission of Steven Douglas Cochran the class provides similar
% functionality as the \Lpack{subfigure} package~\cite{SUBFIGURE}.
% This requires some changes to be made to \cs{@float} and \cs{end@float}.
%
% \begin{macro}{\ifdonemaincaption}
% This is set TRUE after the \cs{(cont)caption} has been called in a float.
% \changes{v1.1}{2002/03/10}{Changed \cs{if@contmaincaption} to
% \cs{ifdonemaincaption}}
% \begin{macrocode}
\newif\ifdonemaincaption
\donemaincaptionfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@float}
% \begin{macro}{\@dbfloat}
% \begin{macro}{\@memresetsubcounter}
% The kernel \cs{@float} and \cs{@dblfloat} macros are redefined to
% set \cs{ifdonemaincaption} to FALSE, and also to zero the subfloat
% counter, if it is defined. Ignasi Furi\`{o}
% reported\footnote{Private email from \texttt{ignasi.furio@uib.es},
% 2003/10/17} that floats embedded in text created an extra
% space. This was caused by a missing \verb?%?.
% \changes{v1.4}{2003/11/22}{Deleted spaces from \cs{@float} and
% \cs{@dblfloat} (from patch v1.9)}
% Axel Sommerfeldt\footnote{Private email, from axel.sommerfeldt@f-m.fm,
% 2013/05/10} asked for the subcounter reset to be factored out into
% a macro and provided the code.
% \begin{macrocode}
\let\@memoldfloat\@float
\renewcommand{\@float}[1]{\donemaincaptionfalse
\@memresetsubcounter{#1}%
\@memoldfloat{#1}}
\let\@memolddblfloat\@dblfloat
\renewcommand{\@dblfloat}[1]{\donemaincaptionfalse
\@memresetsubcounter{#1}%
\@memolddblfloat{#1}}
\newcommand{\@memresetsubcounter}[1]{%
\@ifundefined{c@sub#1}{}{\csname c@sub#1\endcsname = 0\relax}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\end@float}
% \begin{macro}{\end@dblfloat}
% The kernel \cs{end@float} and \cs{end@dblfloat} macros are redefined to
% dump out any subcaptions that have not yet been processed.
% \begin{macrocode}
\let\@memoldefloat\end@float
\def\end@float{%
\@memlistsubcaptions{\@captype}\@memoldefloat}
\let\@memoldedblfloat\end@dblfloat
\def\end@dblfloat{%
\@memlistsubcaptions{\@captype}\@memoldedblfloat}
% \end{macrocode}
% Unfortunately the \Lpack{fixltx2e} package, version 1.1h (current as
% of 2005/09/03) makes assumptions about \cs{end@float} which do not
% hold for memoir. The code has to be reverted back to that in version
% 1.0b of \Lpack{fixltx2e}.
% \changes{v1.618}{2005/09/03}{Dealt with incompatibilities between
% fixltx2e and memoir's \cs{end@dblfloat} (mempatch v3.7)}
%
% \changes{v3.7c}{2015/03/05}{Note quite sure why this fix is needed,
% so we add a trick (\cs{MEMOIROVERRIDE}) so that it can be deleted by
% defining a macro before \cs{documentclass}, that makes it easier to
% test}
%
% Update 2015: The problematic code from \Lpack{fixltx2e} is no
% longer present from version 1.1s and on. This version is to be
% build into the LaTeX2e kernel for the TeX Live 2015 release. We
% change the code reversion so it only happens if older \Lpack{fixltx2e}
% versions are being used.
% \changes{v3.7d}{2015/03/17}{Adding check for older \Lpack{fixltx2e}
% and removing \cs{MEMOIROVERRIDE}}
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{fixltx2e}{%
\@ifpackagelater{fixltx2e}{2014/01/01}{}{% package older than 2014/01/01
\def\end@dblfloat{%
\if@twocolumn
\@endfloatbox
\ifnum\@floatpenalty<\z@
\@largefloatcheck
\global\dp\@currbox1sp %
\@cons\@deferlist\@currbox
\fi
\ifnum\@floatpenalty=-\@Mii \@Esphack\fi
\else
\end@float
\fi}%
}
}{}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{v3.6h}{2011/02/01}{Added \cs{FloatBlock}}
% \subsubsection{Float blockage}
%
% This is basically a slightly modified copy of \cs{FloatBarrier} from
% the \Lpack{placeins} package by Donald Arseneau, renamed such that
% both can be used in the same document. We could have emulated the
% \Lpack{placeins} package, but people might use it with options, so,
% since the code is so short we just copy it. Kudos to Donald Arseneau.
% For more defaults see
% \cite{PLACEINS}.
% \begin{macro}{\FloatBlock}
% \begin{macro}{\FloatBlockAllowAbove}
% \begin{macro}{\FloatBlockAllowBelow}
% The two \cs{XAllowY} macros is our way of supporting the
% \Lpack{placeins} package options.
% \begin{macrocode}
\def\mem@fb@botlist{\@botlist}
\def\mem@fb@topblock{\suppressfloats[t]}
% \end{macrocode}
% \changes{v3.7d}{2015/03/12}{\cs{\@dbldeferlist} may be removed in a
% comming LaTeX kernel update}
% \begin{macrocode}
\def\FloatBlock{\par\begingroup \let\@elt\relax
\edef\@tempa{\mem@fb@botlist\@deferlist\@dbldeferlist}%
\ifx\@tempa\@empty
\else
\ifx\@fltovf\relax % my indicator of recursion
\if@firstcolumn
\clearpage
\else
\null\newpage\FloatBlock
\fi
\else
\newpage \let\@fltovf\relax
\FloatBlock % recurse once only
\fi\fi \endgroup
\mem@fb@topblock}
\newcommand*\FloatBlockAllowAbove{\def\mem@fb@topblock{}}
\newcommand*\FloatBlockAllowBelow{\def\mem@fb@botlist{}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\setFloatBlockFor}
% This can be used to add \cs{FloatBLock} into various sectional
% macros. Supported: \cs{chapter} (when in article mode) and all
% sectional macros made using \cs{@startsection}.
% \begin{macrocode}
\newcommand\setFloatBlockFor[1]{%
\@namedef{#1block}{\FloatBlock}}
% \end{macrocode}
%
% \end{macro}
%
% \subsubsection{Margin floats}
%
% The next two constructions are inspired by \texttt{tufte-common.def}
% by Bil Kleb, Bill Wood, and Kevin Godby and provide a manner to
% insert figures or tables into the margin. Note that the
% \cs{setfloatadjustment} also applies here.
% \begin{macro}{\mem@margin@floatbox}
% Box to save the contents of a margin float in.
% \begin{macrocode}
\newsavebox{\mem@margin@floatbox}
% \end{macrocode}
% \end{macro}
% % \begin{environment}{mem@margin@float}
% \begin{environment}{marginfigure}
% \begin{environment}{margintable}
% \begin{macro}{\marginfloatmarginmacro}
% Since the two environments only differ in `name' a constructor is used.
% Since these margin floats are wrapped inside another type of float
% (\cs{marginpar}) they may cause problems when used combined with
% regular floats (the float order may be wrong). For that reason the
% margin float throws a \cs{FloatBlock} before issuing the \cs{marginpar}.
% \begin{macrocode}
\newcommand\marginfloatmarginmacro{\marginpar}
\newenvironment{mem@margin@float}[2][-1.2ex]%
{\FloatBlock%
\begin{lrbox}{\mem@margin@floatbox}%
\begin{minipage}{\marginparwidth}%
\def\@captype{#2}%
\hbox{}\vspace*{#1}%
\@nameuse{margin#2adjustment}%
\@nameuse{margin#2captionadjustment}%
\noindent%
}
{\end{minipage}%
\end{lrbox}%
\marginfloatmarginmacro{\usebox{\mem@margin@floatbox}}%
}
% \end{macrocode}
% The two environment is then just two applications of the
% constructor. The option can be used to move the margins float up and down.
% \begin{macrocode}
\newenvironment{marginfigure}[1][-1.2ex]{%
\begin{mem@margin@float}[#1]{figure}}
{\end{mem@margin@float}}
\newenvironment{margintable}[1][-1.2ex]{%
\begin{mem@margin@float}[#1]{table}}
{\end{mem@margin@float}}
\setfloatadjustment{marginfigure}{\centering}
\setfloatadjustment{margintable}{\centering}
% \end{macrocode}
% \end{macro}
% \end{environment}
% \end{environment}
% \end{environment}
% \begin{macro}{\setmarginfloatcaptionadjustment}
% Because of the very narrow margin area, it may be fruitful to
% reconfigure the caption style when used in a margin float. This can
% be done globally for all captions (e.g. if all floats are margin
% floats, or just for margin floats.
% \begin{macrocode}
\newcommand*\setmarginfloatcaptionadjustment[2]{%
\@namedef{margin#1captionadjustment}{#2}}
% \end{macrocode}
% \end{macro}
% \changes{v3.6h}{2011/02/06}{Added these two macros}
% \begin{macro}{\setmpjustification}
% \begin{macro}{\mpjustification}
% Can be just to use and configure a specialized justification. It
% follows the \verb?\marginpar? placement, and make use of the first
% argument when at the left of the text block and the other when at
% the right. It makes use of an internal setting from within
% \verb?\marginparmargin?, thus that need to have been executed.
% \begin{macrocode}
\newcommand\setmpjustification[2]{%
\@namedef{mem@mp@justification}{%
\ifm@msetmp\else\@memerror{In order to use
\string\marginCmdAdjust,^^J%
please make sure to specify into which margin the^^J%
\string\marginpar\space should go, using \string\marginparmargin}{}\fi
\m@mwhich@margin{\m@mmpar@margin}%
\ifmemtortm #2 \else #1\fi}%
}
% \end{macrocode}
% Default value
% \begin{macrocode}
\newcommand\mpjustification{%
\@nameuse{mem@mp@justification}}
\setmpjustification{\raggedleft}{\raggedright}
% \end{macrocode}
%
% \end{macro}
% \end{macro}
%
% \subsection{Captions}
%
% The caption styling
% is accomplished by redefining the \cs{@makecaption}
% command. First, though, define and initialise the user-level commands.
%
% \begin{macro}{\if@contcw}
% \begin{macro}{\if@conthang}
% \begin{macro}{\if@contindent}
% For use when checking caption width and captioning styles styles.
% \begin{macrocode}
\newif\if@contcw
\newif\if@conthang
\newif\if@contindent
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\captiondelim}
% \begin{macro}{\@contdelim}
% For the caption delimiter.
% \begin{macrocode}
\newcommand{\captiondelim}[1]{\def\@contdelim{#1}}
\captiondelim{: }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\captionnamefont}
% \begin{macro}{\@contnfont}
% The font for the caption name.
% \begin{macrocode}
\newcommand{\captionnamefont}[1]{\def\@contnfont{#1}}
\captionnamefont{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\captiontitlefont}
% \begin{macro}{\@conttfont}
% The font for the caption title.
% \begin{macrocode}
\newcommand{\captiontitlefont}[1]{\def\@conttfont{#1}}
\captiontitlefont{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\captionstyle}
% \begin{macro}{\@contcstyle}
% The paragraphing style for the caption.
% \begin{macrocode}
\newcommand*{\captionstyle}[1]{\def\@contcstyle{#1}}
\captionstyle{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\captionstyle}
% \begin{macro}{\@memcshort}
% \begin{macro}{\@memcnom}
% \begin{macro}{\@contcshortstyle}
% \begin{macro}{\@contcstyle}
% The paragraphing style for the caption.
%
% I had email from J{\o}rgen Larsen (\url{jl@dirac.ruc.dk}), 2003/04/09,
% asking for separate controls for the short and long captions. \\
% \cs{captionstyle}\oarg{short}\marg{normal}.
% \changes{v1.4}{2003/11/22}{Extended \cs{captionstyle} (from patch v1.5)}
% \changes{v3.6h}{2011/01/16}{Removed sporadic spaces}
% \begin{macrocode}
\renewcommand{\captionstyle}{%
\@ifnextchar[{\@memcshort}{\@memcnorm}}
\def\@memcshort[#1]#2{%
\def\@contcshortstyle{#1}%
\def\@contcstyle{#2}}
\def\@memcnorm#1{%
\def\@contcshortstyle{#1}%
\def\@contcstyle{#1}}
\captionstyle{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@contcwidth}
% \begin{macro}{\captionwidth}
% \begin{macro}{\changecaptionwidth}
% \begin{macro}{\normalcaptionwidth}
% The macros for dealing with the caption width.
% \begin{macrocode}
\newlength{\@contcwidth}
\newcommand{\captionwidth}[1]{\setlength{\@contcwidth}{#1}}
\captionwidth{\linewidth}
\newcommand{\changecaptionwidth}{\@contcwtrue}
\newcommand{\normalcaptionwidth}{\@contcwfalse}
\normalcaptionwidth
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@contindw}
% \begin{macro}{\hangcaption}
% \begin{macro}{\indentcaption}
% \begin{macro}{\normalcaption}
% The macros for hanging and indented captions.
% \begin{macrocode}
\newlength{\@contindw}
\newcommand{\hangcaption}{\@conthangtrue\@contindentfalse}
\newcommand{\indentcaption}[1]{\setlength{\@contindw}{#1}%
\@conthangfalse\@contindenttrue}
\newcommand{\normalcaption}{\@conthangfalse\@contindentfalse}
\normalcaption
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\precaption}
% \begin{macro}{\@contpre}
% \begin{macro}{\postcaption}
% \begin{macro}{\@contpost}
% \begin{macro}{\midbicaption}
% \begin{macro}{\@contmidbi}
% The macros for the pre- and post-caption text/commands, and
% for the mid-caption command for bilingual captions.
% \begin{macrocode}
\newcommand{\precaption}[1]{\def\@contpre{#1}}
\precaption{}
\newcommand{\postcaption}[1]{\def\@contpost{#1}}
\postcaption{}
\newcommand{\midbicaption}[1]{\def\@contmidbi{#1}}
\midbicaption{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\captiontitlefinal}
% \cs{captiontitlefinal}\marg{stuff} will put \meta{stuff} immediately
% at the end of a \cs{caption}'s title text but it will not appear
% in the LoF/LoT/etc. For example \\
% \verb?\captiontitlefinal{.}? \\
% The code was supplied by Frederic Connes.
% \changes{v1.61803}{2008/01/30}{Added \cs{captiontitlefinal} (mempatch v4.4)}
% \begin{macrocode}
\newcommand*{\captiontitlefinal}[1]{\def\@contfinal{#1}}
\captiontitlefinal{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\abovecaptionskip}
% \begin{macro}{\belowcaptionskip}
% Vertical space above and below a caption. Make them sum to an
% integral number of lines.
% \begin{macrocode}
\newlength{\abovecaptionskip}
\setlength{\abovecaptionskip}{0.5\onelineskip}
\newlength{\belowcaptionskip}
\setlength{\belowcaptionskip}{0.5\onelineskip}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\caption}
% For subfloat support, the (kernel) \cs{caption} macro needs to note that it
% has been called.
% \begin{macrocode}
\let\@memoldcaption\caption
\def\caption{\donemaincaptiontrue\@memoldcaption}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\memcaptioninfo}
% \verb?\memcaptioninfo{type}{\thetypenum}{short}{long}?
% \changes{v1.618}{2005/09/10}{Added \cs{memcaptioninfo}}
% \begin{macrocode}
\newcommand{\memcaptioninfo}[4]{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@caption}
% For title referencing support, the (kernel) \cs{@caption} macro needs
% to store the title.
% \changes{v1.618}{2005/09/03}{Added braces around second argument of \cs{@memold@caption} (per Dan Luecking, mempatch v3.0)}
% \begin{macrocode}
\let\@memold@caption\@caption
\long\def\@caption#1[#2]#3{%
\M@gettitle{#2}%
\memcaptioninfo{#1}{\csname the#1\endcsname}{#2}{#3}%
\@memold@caption{#1}[{#2}]{#3}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makecaption}
% This is a reimplementation of the kernel \cs{@makecaption} command.
% As well as including the caption typesetting commands it enables
% captions that include forced newlines (e.g., by \verb?\\?).
%
% The first part is due to
% Donald Arseneau\footnote{Email: \texttt{asnd@triumf.ca}} from postings
% to the \ctt{} newsgroup and Email discussions. The \cs{topskip} strut is
% used whenever the caption is the first part of the float. This means,
% among other things, that if a caption comes at the
% top of a page, then the first line of the caption will be aligned with
% the normal first line of a page. The \cs{abovecaptionskip} is only used
% when there is something above the caption in the current float.
% \changes{v0.31}{2001/07/24}{Changed \cs{@tempa} to \cs{@memtempa} in \cs{@makecaption}}
% \changes{v1.0a}{2002/02/12}{Added extra centering code in \cs{@makecaption}}
% \changes{v1.4}{2003/11/22}{Added separate short/long styles in \cs{@makecaption}
% (from patch v1.5)}
% \changes{v1.61803}{2008/01/30}{Added \cs{@contfinal} to \cs{@makecaption}
% (mempatch v4.4)}
%
% Axel Sommerfelt\footnote{Private email discussion} suggested to
% split \cs{@makecaption} into two macros, such that the caption
% formatting and the space above and below are separate. This enables
% us to use the formatting macro (\cs{@@makecaption}) to format, say,
% \Lpack{longtable} captions.
% \changes{v3.6k}{2013/05/13}{Split \cs{@makecaption} into
% \cs{@makecaption} and \cs{@@makecaption}}
% \begin{macrocode}
\long\def\@makecaption#1#2{\let\@memtempa\relax
\ifdim\prevdepth>-99\p@ \vskip\abovecaptionskip
\else \def\@memtempa{\vbox to\topskip{}}\fi
% \end{macrocode}
% Inserting \cs{@@makecaption} to format the actual caption.
% \begin{macrocode}
\@@makecaption{#1}{#2}%
% \end{macrocode}
% Then add the below caption spacing.
% \begin{macrocode}
\vskip\belowcaptionskip}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@makecaption}
% Next the rest of the caption code as \cs{@@makecaption}.
% \begin{macrocode}
\long\def\@@makecaption#1#2{%
% \end{macrocode}
% \begin{macro}{\@contfnote}
% \begin{macro}{\@contfmark}
% The caption title will be typeset twice, firstly to measure its width
% and secondly to actually typeset it. To avoid problems caused by
% a footnote in the caption getting processed twice, we temporarily
% disable the expected relevant commands.
% \changes{v3.6h}{2011/01/20}{Provided the same for \cs{pagentote}}
% \begin{macrocode}
\let\@contfnote\footnote \renewcommand{\footnote}[2][]{}
\let\@contfmark\footnotemark \renewcommand{\footnotemark}[1][]{}
\let\@contpnote\pagenote\renewcommand\pagenote[2][]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% Now measure the width of the total caption, not forgetting to take account
% of the font specifications, and then restore the footnoting.
% \changes{v3.6k}{2013/05/13}{Font grouping, suggested by Axel Sommerfelt}
% \begin{macrocode}
\sbox\@tempboxa{{\@contnfont #1\@contdelim}\@conttfont #2\@contfinal}
\let\footnote\@contfnote
\let\footnotemark\@contfmark
\let\pagenote\@contpnote
% \end{macrocode}
% If the caption is less than one
% line, then the whole caption needs to be centered on the page (otherwise
% the short caption may be typeset flushleft).
% \begin{macrocode}
\ifdim\wd\@tempboxa<\linewidth \centering \fi
\if@contcw
% \end{macrocode}
% For typesetting at anything other than the normal width, put the caption
% into a \cs{parbox} of the specified width. This must be centered.
% \changes{v3.6h}{2010/12/06}{Align inner parbox at top
% line. Vertically centered parbox cause different spacing when
% \cs{changecaptionwidth} compared when it is not used.}
% \begin{macrocode}
\centering
\parbox[t]{\@contcwidth}{%
% \end{macrocode}
% Henrik Holm\footnote{Email from \texttt{henrik@tele.ntnu.no} on
% 2002/02/10.} proposed adding the next line to center short, narrow captions.
% \begin{macrocode}
\ifdim\wd\@tempboxa<\@contcwidth \centering \fi
\fi
% \end{macrocode}
% Hanging and indenting doesn't apply to short captions, so do these
% now.
% \changes{v1.6180339f}{2009/06/25}{Short captions no longer hang or indent}
% \begin{macrocode}
\ifdim\wd\@tempboxa<\linewidth
\@contpre
{\@contnfont #1\@contdelim}\@memtempa
{\@contcshortstyle \@conttfont #2\@contfinal\par}
\else
\if@conthang
% \end{macrocode}
% For a hanging caption we have to measure the width of the caption name,
% then typeset the whole caption in a hanging paragraph.
% \changes{v1.1}{2002/03/10}{Changed code for hangcaption in \cs{@makecaption}}
% \begin{macrocode}
\sbox\@tempboxa{\@contnfont #1\@contdelim}
\@contpre%
{\@contcstyle\hangindent=\wd\@tempboxa
\noindent\box\@tempboxa\@memtempa \@conttfont #2\@contfinal\par}
\else
\if@contindent
% \end{macrocode}
% An indented caption is similar, except the amount of indentation is
% kept in \cs{@contindw}.
% \begin{macrocode}
\@contpre%
{\@contnfont #1\@contdelim}\@memtempa
{\@contcstyle\hangindent=\@contindw
\hangafter=\@ne\@conttfont #2\@contfinal\par}% <- v1.4
\else
% \end{macrocode}
% For the normal style, just typeset the caption.
% \begin{macrocode}
\@contpre%
{\@contnfont #1\@contdelim}\@memtempa
{\@contcstyle \@conttfont #2\@contfinal\par}
\fi
\fi
\fi
% \end{macrocode}
% Finish off the typesetting by processing the post-text, and if not using
% the normal width then close off the \cs{parbox}, and lastly put in some
% vertical space.
% \changes{v3.6k}{2013/05/13}{Removed the below vertical skip}
% \begin{macrocode}
\@contpost
\if@contcw
\par
} % end of the \parbox
\fi
}
% \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Continuation captions and legends}
%
% \begin{macro}{\contcaption}
% \cs{contcaption}\marg{text} is a user-level command.
% It is a simplified
% version of the normal \cs{caption} command as it doesn't have to deal
% with numbering or list of \dots entries.
%
% However,
% Brent Lievers\footnote{ (\texttt{lieversb@post.queensu.ca})
% in \ctt{} thread \textit{Figures}, 2003/11/14.} requested that \cs{label}
% should pick up the correct caption number after a \cs{contcaption}.
% \changes{v1.4}{2003/11/22}{Extended \cs{contcaption} (from patch v1.9)}
% \begin{macrocode}
\newcommand{\contcaption}{%
\addtocounter{\@captype}{\m@ne}\refstepcounter{\@captype}%
\@contcaption\@captype}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@@contcaption}
% \begin{macro}{\@contcaption}
% \cs{@contcaption} is the workhorse for the \cs{contcaption} command. In turn,
% it uses the \cs{@makecaption} command (defined in the usual classes)
% to do most of its work. It
% uses the number of the previous \cs{caption} command in the same
% type of float and its implementation includes much of the code
% used in the \LaTeX{} \cs{@caption} command.
%
% First specify \cs{@@contcaption}\marg{type}\marg{title}
% to save some repetitive code.
% \begin{macrocode}
\long\def\@@contcaption#1#2{%
\par
\begingroup
\@parboxrestore
\if@minipage
\@setminipage
\fi
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #2}\par
\endgroup}
% \end{macrocode}
% \end{macro}
%
% Now for \cs{@contcaption}\marg{type}\marg{title}.
% It has to flush out any subcaptions at the
% appropriate time, as well as typesetting the caption.
% \begin{macrocode}
\long\def\@contcaption#1#2{%
\if@contbotsub
\@memlistsubcaptions{#1}%
\@@contcaption{#1}{#2}%
\else
\@@contcaption{#1}{#2}%
\@memlistsubcaptions{#1}%
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\memlegendinfo}
% \begin{macro}{\legend}
% The macro \cs{legend}\marg{text}is intended
% to be used in a float environment for an `anonymous' caption, but can be
% used anywhere.
%
% The implementation is similar to the \cs{caption} command but we have
% to eliminate printing of a delimeter.
% \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{legend}}
% \changes{v1.618}{2005/09/10}{Added \cs{memlegendinfo}}
% \begin{macrocode}
\newcommand{\memlegendinfo}[1]{}
\newcommand{\legend}[1]{%
\M@gettitle{#1}%
\memlegendinfo{#1}%
\par
\begingroup
\@parboxrestore
\if@minipage
\@setminipage
\fi
\normalsize
\captiondelim{\mbox{}}
\@makecaption{}{\ignorespaces #1}\par
\endgroup}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\namedlegend}
% \begin{macro}{\memnamedlegendinfo}
% \cs{namedlegend}\oarg{short-title}\marg{long-title} is like the
% \cs{caption} command except that it does not number the caption.
%
% \cs{memnamedlegendinfo}\marg{type}\marg{short-title}\marg{long-title}
% \changes{v1.618}{2005/09/10}{Added \cs{memnamedlegendinfo}}
% \begin{macrocode}
\newcommand{\namedlegend}{\@dblarg{\@legend\@captype}}
\newcommand{\memnamedlegendinfo}[3]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@legend}
% \cs{@legend}\marg{type}\oarg{short-title}\marg{long-title}
% is the workhorse for the \cs{namedlegend} command. In turn, it calls
% \cs{@makelegend}. It requires two commands to have been defined, namely
% \cs{flegtoctype} and \cs{flegtype}. The command \cs{flegtoctype}\marg{text}
% is responsible for writing a title text to the appropriate listof file.
% \cs{flegtype} is responsible for typeseting the name of the legend.
% \changes{v1.4}{2003/11/16}{Added \cs{M@gettitle} to \cs{@legend}}
% \begin{macrocode}
\long\def\@legend#1[#2]#3{%
\M@gettitle{#2}%
\memnamedlegendinfo{#1}{#2}{#3}%
\par
\csname flegtoc#1\endcsname{#2}%
\begingroup
\@parboxrestore
\if@minipage
\@setminipage
\fi
\normalsize
\@makecaption{\csname fleg#1\endcsname}{\ignorespaces #3}\par
\endgroup}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Non-float captions}
%
% \begin{macro}{\newfixedcaption}
% \begin{macro}{\renewfixedcaption}
% \begin{macro}{\providefixedcaption}
% These commands are defined in terms of their \verb?\...command? counterparts.\\
% Call as \verb?\...fixedcaption?\oarg{capcommand}\marg{command}\marg{env}
% \begin{macrocode}
\newcommand{\newfixedcaption}[3][\caption]{%
\newcommand{#2}{\def\@captype{#3}#1}}
\newcommand{\renewfixedcaption}[3][\caption]{%
\renewcommand{#2}{\def\@captype{#3}#1}}
\newcommand{\providefixedcaption}[3][\caption]{%
\providecommand{#2}{\def\@captype{#3}#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Bilingual captions}
%
% The bilingual caption commands all use internal grouping so
% that any changes are kept local. This has the unfortunate side-effect
% that any \cs{label} command must be within the grouping otherwise the
% wrong number is picked up. To make the coding, if not necessarily the
% use, of the commands simpler, I have not used the traditional style
% of square brackets for optional caption text arguments. Instead, empty
% `required' arguments are used as the implementation means.
%
% \begin{macro}{\membitwonumcaptioninfo}
% \begin{macro}{\membionenumcaptioninfo}
% \begin{macro}{\membicaptioninfo}
% \verb?\membitwonumcaptioninfo{type}{\thetypenum}?\marg{short1}\marg{long1}\\
% \hspace*{2in} \marg{name2}\marg{short2}\marg{long2} \\
% \verb?\membionenumcaptioninfo{type}{\thetypenum}?\marg{short1}\marg{long1}\\
% \hspace*{2in} \marg{name2}\marg{short2}\marg{long2} \\
% \verb?\membicaptioninfo{type}{\thetypenum}?\marg{short1}\marg{long1}\\
% \hspace{2in} \marg{name2}\marg{long2} \\
% \changes{v1.618}{2005/09/10}{Added \cs{membitwonumcaptioninfo},
% \cs{membitwonumcaptioninfo} and \cs{membicaptioninfo}}
% \begin{macrocode}
\newcommand{\membitwonumcaptioninfo}[7]{}
\newcommand{\membionenumcaptioninfo}[7]{}
\newcommand{\membicaptioninfo}[6]{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bitwonumcaption}
% The 6 arguments are: optional label, short and long in language 1,
% name in
% language 2, and short and long in language 2. Both texts are put
% into the List of as numbered entries.
% \begin{macrocode}
\newcommand{\bitwonumcaption}[6][\@empty]{%
\begingroup
\let\memcaptioninfo\@gobblefour
% \end{macrocode}
% Check if the first language argument is vacuous, then call
% the normal \cs{caption} for language 1.
% \begin{macrocode}
\@ifmtarg{#2}{\def\m@mscapi{#3}\caption{#3}}%
{\def\m@mscapi{#2}\caption[#2]{#3}}%
% \end{macrocode}
% Do the optional labeling.
% \begin{macrocode}
\ifx \@empty #1\else
\label{#1}%
\fi
% \end{macrocode}
% Remove any extra spacing between the captions, and set the
% NAME for the second caption. Use a command to transfer
% the NAME to the renewal code to avoid circularity if
% for example, we are trying to redefine \cs{tablename} as
% \cs{tablename}. Decrement the caption counter.
% \begin{macrocode}
\setlength{\abovecaptionskip}{0pt}%
\setlength{\belowcaptionskip}{0pt}%
\edef\@memtempc{#4}%
\expandafter\renewcommand\csname \@captype name\endcsname{\@memtempc}%
\addtocounter{\@captype}{-1}%
% \end{macrocode}
% Now repeat for the second language caption.
% \begin{macrocode}
\@contmidbi
\@ifmtarg{#5}{\def\m@mscapii{#6}\caption{#6}}%
{\def\m@mscapii{#5}\caption[#5]{#6}}%
\membitwonumcaptioninfo{\@captype}{\@nameuse{the\@captype}}%
{\m@mscapi}{#3}{#4}{\m@mscapii}{#6}%
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bionenumcaption}
% The 6 arguments are: optional labelling,
% short and long in language 1, name in
% language 2, and short and long in language 2. Both texts are put
% into the List of, but only the first is numbered.
% \begin{macrocode}
\newcommand{\bionenumcaption}[6][\@empty]{%
\begingroup
\let\memcaptioninfo\@gobblefour
% \end{macrocode}
% Check if the first language argument is vacuous, then call
% the normal \cs{caption} for language 1.
% \begin{macrocode}
\@ifmtarg{#2}{\def\m@mscapi{#3}\caption{#3}}%
{\def\m@mscapi{#2}\caption[#2]{#3}}%
% \end{macrocode}
% Do the optional labeling.
% \begin{macrocode}
\ifx \@empty #1\else
\label{#1}%
\fi
% \end{macrocode}
% Do the between captions code.
% \begin{macrocode}
\setlength{\abovecaptionskip}{0pt}%
\setlength{\belowcaptionskip}{0pt}%
\edef\@memtempc{#4}%
\expandafter\renewcommand\csname \@captype name\endcsname{\@memtempc}
% \end{macrocode}
% Use a continuation caption for the second language, not forgetting
% to add the appropriate unnumbered text to the List.
% \begin{macrocode}
\@contmidbi
\contcaption{#6}%
\@ifmtarg{#5}{%
\def\m@mscapii{#6}%
\addcontentsline{\csname ext@\@captype\endcsname}{\@captype}%
{\protect\numberline{}{\ignorespaces #6}}}{%
\def\m@mscapii{#5}%
\addcontentsline{\csname ext@\@captype\endcsname}{\@captype}%
{\protect\numberline{}{\ignorespaces #5}}}%
\membionenumcaptioninfo{\@captype}{\@nameuse{the\@captype}}%
{\m@mscapi}{#3}{#4}{\m@mscapii}{#6}%
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bicaption}
% The 5 arguments are: optional labelling,
% short and long in language 1, name in
% language 2, and long in language 2.
% Only the first text is put into the List.
% \begin{macrocode}
\newcommand{\bicaption}[5][\@empty]{%
\begingroup
\let\memcaptioninfo\@gobblefour
% \end{macrocode}
% Check if the first language argument is vacuous, then call
% the normal \cs{caption} for language 1.
% \begin{macrocode}
\@ifmtarg{#2}{\def\m@mscapi{#3}\caption{#3}}%
{\def\m@mscapi{#2}\caption[#2]{#3}}%
% \end{macrocode}
% Do the optional labeling.
% \begin{macrocode}
\ifx \@empty #1\else
\label{#1}%
\fi
% \end{macrocode}
% Do the between captions code and
% finally just use \cs{contcaption} for the
% second language.
% \begin{macrocode}
\setlength{\abovecaptionskip}{0pt}%
\setlength{\belowcaptionskip}{0pt}%
\edef\@memtempc{#4}
\expandafter\renewcommand\csname \@captype name\endcsname{\@memtempc}%
\@contmidbi
\contcaption{#5}%
\membicaptioninfo{\@captype}{\@nameuse{the\@captype}}%
{\m@mscapi}{#3}{#4}{#5}%
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bicontcaption}
% The 3 arguments are long in language 1, name in
% language 2, and long in language 2.
% \begin{macrocode}
\newcommand{\bicontcaption}[3]{%
\begingroup
% \end{macrocode}
% Call \cs{contcaption} for language 1.
% \begin{macrocode}
\contcaption{#1}%
% \end{macrocode}
% Do the between captions code and use \cs{contcaption} for the second
% language.
% \begin{macrocode}
\setlength{\abovecaptionskip}{0pt}%
\setlength{\belowcaptionskip}{0pt}%
\edef\@memtempc{#2}%
\expandafter\renewcommand\csname \@captype name\endcsname{\@memtempc}%
\@contmidbi
\contcaption{#3}%
\endgroup}
% \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Support for the \Lopt{subfigure} package functionality}
%
% Much of the code in this section is based on the \Lpack{subfigure}
% package code, by kind permission of its author, Steven Douglas Cochran.
% To try and avoid clashes with the real \Lpack{subfigure} code I have
% used different macro names, especially when I have copied the code.
%
% \begin{macro}{\subcaptionstyle}
% \begin{macro}{\@contsubcstyle}
% The paragraphing style for subcaptions.
% \begin{macrocode}
\newcommand{\subcaptionstyle}[1]{\def\@contsubcstyle{#1}}
\subcaptionstyle{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@shortsubcap}
% \begin{macro}{\if@hangsubcap}
% \begin{macro}{\shortsubcaption}
% \begin{macro}{\hangsubcaption}
% \begin{macro}{\normalsubcaption}
% For dealing with short and hanging subcaptions.
% Analagous to the \Lpack{subfigure} \texttt{nooneline} and \texttt{hang} options.
% The default is normal subcaptions.
% \begin{macrocode}
\newif\if@shortsubcap
\newif\if@hangsubcap
\newcommand*{\shortsubcaption}{\@shortsubcaptrue}
\newcommand*{\hangsubcaption}{\@hangsubcaptrue}
\newcommand*{\normalsubcaption}{\@shortsubcapfalse\@hangsubcapfalse}
\normalsubcaption
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\subfloattopskip}
% \begin{macro}{\subfloatcapskip}
% \begin{macro}{\subfloatcaptopadj}
% \begin{macro}{\subfloatbottomskip}
% \begin{macro}{\subfloatlabelskip}
% \begin{macro}{\subfloatcapmargin}
% These \cs{subfloat...} lengths are analagous to the \Lpack{subfigure}
% \cs{subfig...} lengths.
% \begin{macrocode}
\newskip\subfloattopskip
\newskip\subfloatcapskip
\newskip\subfloatcaptopadj
\newskip\subfloatbottomskip
\newskip\subfloatlabelskip
\newdimen\subfloatcapmargin
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@tightsubcap}
% \begin{macro}{\loosesubcaptions}
% \begin{macro}{\tightsubcaptions}
% Unlike the \Lpack{subfigure} package the class provides no options for
% subcaptions. These macros provide the \Lpack{subfigure} loose/tight
% option functions. Set the default to tight.
% \begin{macrocode}
\newif\if@tightsubcap
\newcommand{\loosesubcaptions}{%
\subfloattopskip = 10\p@
\subfloatcapskip = 10\p@
\subfloatcaptopadj = \z@
\subfloatbottomskip = 10\p@
\subfloatlabelskip = 0.33em
\subfloatcapmargin = 10\p@
\@tightsubcapfalse
}
\newcommand{\tightsubcaptions}{%
\subfloattopskip = 5\p@
\subfloatcapskip = \z@
\subfloatcaptopadj = 3\p@
\subfloatbottomskip = 5\p@
\subfloatlabelskip = 0.33em \@plus 0.07em \@minus 0.03em
\subfloatcapmargin = \z@
\@tightsubcaptrue
}
\tightsubcaptions
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\subcaptionsize}
% \begin{macro}{\@subcapsize}
% \begin{macro}{\subcaptionlabelfont}
% \begin{macro}{\@subcaplabelfont}
% \begin{macro}{\subcaptionfont}
% \begin{macro}{\@subcapfont}
% These macros set the size and fonts for the subcaptions. Set the defaults
% to \cs{footnotesize}, and the normal roman font.
% \begin{macrocode}
\newcommand*{\subcaptionsize}[1]{\def\@subcapsize{#1}}
\newcommand*{\subcaptionlabelfont}[1]{\def\@subcaplabelfont{#1}}
\newcommand*{\subcaptionfont}[1]{\def\@subcapfont{#1}}
\subcaptionsize{\footnotesize}
\subcaptionlabelfont{\normalfont}
\subcaptionfont{\normalfont}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@contkeep}
% \begin{macro}{\@contset}
% \begin{macro}{\subconcluded}
% \cs{@contkeep} stores
% the current subfloat number in counter \verb?@contsubnum? and
% \cs{@contset} sets the subfloat number to the value of \verb?@contsubnum?.
% \cs{subconcluded} sets the subfloat number to zero.
% \begin{macrocode}
\newcounter{@contsubnum}
\newcommand{\@contkeep}{%
\setcounter{@contsubnum}{\value{sub\@captype}}}
\newcommand{\@contset}{%
\setcounter{sub\@captype}{\value{@contsubnum}}}
\newcommand{\subconcluded}{%
\setcounter{sub\@captype}{0}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \begin{macro}{\if@contbotsub}
% A flag indicating whether the subcaption is to be at the bottom or
% top of the subfloat; TRUE for the subcaption at the bottom.
% \begin{macrocode}
\newif\if@contbotsub
\@contbotsubtrue
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subcaption}
% \cs{subcaption}\oarg{list-entry}\marg{caption} is a generic
% subcaption. There is no \Lpack{subfigure} equivalent.
%
% \changes{v3.7i}{2019/10/24}{Added a \cs{par} to the start. This can
% get rid of sporadic spaces caused by hyperref changing \cs{refstepcounter}}
% \begin{macrocode}
\newcommand{\subcaption}{%
\par
\bgroup
\let\label=\memsub@label
\ifdonemaincaption\else
\advance\csname c@\@captype\endcsname\@ne
\fi
\refstepcounter{sub\@captype}\@contkeep
\@ifnextchar [%
{\@memsubcap{sub\@captype}}%
{\@memsubcap{sub\@captype}[\@empty]}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@memsubcap}
% This handles the optional argument to \cs{subcaption}. It sets \cs{@tempdima}
% to \cs{hsize} as later on \cs{@makesubfloatcaption} uses this.
% \changes{v1.1a}{2002/04/28}{Added \cs{@tempdima} to \cs{@memsubcap}}
% \begin{macrocode}
\long\def\@memsubcap#1[#2]#3{%
\@tempdima=\hsize
\vskip\subfloatcapskip
\ifx \@empty #2
\@memsubcaption{#1}{#3}{#3}%
\else
\@memsubcaption{#1}{#2}{#3}%
\fi
\vskip\subfloatcapskip
\egroup}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@memsubcaption}
% \cs{@memsubcaption}\marg{type}\marg{list-entry}\marg{caption}
% typesets a subcaption. This is a copy of the \Lpack{subfigure}
% \cs{@subcaption} macro.
% \begin{macrocode}
\newcommand{\@memsubcaption}[3]{%
\ifx \relax#2\relax \else
\bgroup
\let\label\@gobble
\let\protect\string
\def\@memsubcaplabel{\@nameuse{@@the#1}}%
\xdef\@memsubfigcaptionlist{%
\@memsubfigcaptionlist,%
{\protect\numberline{\@memsubcaplabel}\noexpand{\ignorespaces #2}}}%
\egroup
\fi
\@makesubfloatcaption{\@nameuse{@the#1}}{#3}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\contsubcaption}
% \cs{contsubcaption}\oarg{caption} is the continued version of
% \cs{subcaption}.
% \begin{macrocode}
\newcommand{\contsubcaption}{%
\bgroup
\let\label=\memsub@label
\@contset
\refstepcounter{sub\@captype}\@contkeep
\@ifnextchar [%
{\@memsubcap{sub\@captype}}%
{\@memsubcap{sub\@captype}[\@empty]}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{environment}{subfloat}
% The \Lpack{subfigure} documentation suggests a way of defining a \Lenv{subfloat}
% environment. This is a trivial implementation because the \cs{subcaption}
% and \cs{contsubcaption} commands are provided by the class, and can be used
% within a \Lenv{subfloat}.
% \begin{macrocode}
\newenvironment{subfloat}{}{}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\mem@step@subcounter}
% \changes{v3.7i}{2019/10/24}{Added}
% Utility macro to save some typing.
% \begin{macrocode}
\newcommand\mem@step@subcounter{%
\refstepcounter{sub\@captype}\@contkeep%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subbottom}
% \begin{macro}{\@memsubbody}
% \cs{subbottom}\oarg{list-entry}\oarg{subcaption}\marg{text}
% typesets a subcaption below the \meta{text}. Most of the work is
% performed by the \cs{@memsubbody} macro.
% \begin{macrocode}
\newcommand{\subbottom}{%
\@contbotsubtrue
\@memsubbody}
\newcommand{\@memsubbody}{%
\bgroup
\let\label=\memsub@label
\ifdonemaincaption\else
\advance\csname c@\@captype\endcsname\@ne
\fi
% \end{macrocode}
% To help with hyperref target placement (hyperref usually uses
% \cs{refstepcounter} to make the anchors) we move the counter
% business into \cs{@memsubfloat} instead. This way they come right at
% the top.
% \begin{macrocode}
% \changes{v3.7i}{2019/10/24}{Moved \cs{refstepcounter}}
% \refstepcounter{sub\@captype}\@contkeep%
\leavevmode
\@ifnextchar [%
{\@memsubfig}%
{\@memsubfig[\@empty]}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\contsubbottom}
% \begin{macro}{\@memcontsubbody}
% These are the continued versions of \cs{subbottom} and \cs{@memsubbody}.
% \begin{macrocode}
\newcommand{\contsubbottom}{%
\@contbotsubtrue
\@memcontsubbody}
\newcommand{\@memcontsubbody}{%
\bgroup
\let\label=\memsub@label
\@contset
% To help with hyperref target placement (hyperref usually uses
% \cs{refstepcounter} to make the anchors) we move the counter
% business into \cs{@memsubfloat} instead. This way they come right at
% the top.
% \begin{macrocode}
% \changes{v3.7i}{2019/10/24}{Moved \cs{refstepcounter}}
% \refstepcounter{sub\@captype}\@contkeep%
\leavevmode
\@ifnextchar [%
{\@memsubfig}%
{\@memsubfig[\@empty]}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\subtop}
% \begin{macro}{\contsubtop}
% These are similar to \cs{subbottom} and \cs{contsubbottom} except that they
% put the subcaption on top of the \meta{text}.
% \begin{macrocode}
\newcommand{\subtop}{%
\@contbotsubfalse
\@memsubbody}
\newcommand{\contsubtop}{%
\@contbotsubfalse
\@memcontsubbody}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{v1.1a}{2002/04/28}{Deleted \cs{@contsubfloat} as it was not used}
%
% \begin{macro}{\@memsubfig}
% This is a revised version of the \Lpack{subfigure} \cs{@subfigure} command
% --- just the called macro names are changed.
% \begin{macrocode}
\def\@memsubfig[#1]{%
\@ifnextchar [%
{\@memsubfloat{sub\@captype}[#1]}%
{\@memsubfloat{sub\@captype}[\@empty #1][#1]}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@memsubfloat}
% This is a modified version of the \Lpack{subfigure} \cs{@subfloat}
% command Essentially the \verb?\csname if#1topcap\endcsname? constructs are
% replaced by \cs{if@contbotsub}.
% \changes{v3.6k}{2011/05/16}{This ought to be long}
% \begin{macrocode}
\long\def\@memsubfloat#1[#2][#3]#4{%
\@tempcnta=\@ne
\if@tightsubcap
\if@minipage
\@tempcnta=\z@
\else
\ifdim\lastskip=\z@
\@tempcnta=\@ne
\else
\@tempcnta=\tw@
\fi
\fi
\fi
\if@contbotsub
\def\subfig@top{\subfloattopskip}%
\def\subfig@bottom{\subfloatbottomskip}%
\else
\def\subfig@top{\subfloatbottomskip}%
\def\subfig@bottom{\subfloattopskip}%
\fi
\setbox\@tempboxa \hbox{#4}%
\@tempdima=\wd\@tempboxa
% \end{macrocode}
% We move the refstep business here to help \Lpack{hyperref} get
% better anchors.
% \changes{v3.7i}{2019/10/24}{moved counter stepping, additionally
% changed \cs{vtop} to \cs{vbox}, otherwise we align the images at the
% top}
% \begin{macrocode}
\vbox\bgroup%
\mem@step@subcounter%
\vbox\bgroup
\ifcase\@tempcnta
\@minipagefalse
\or
\vspace{\subfig@top}
\or
\ifdim \lastskip=\z@ \else
\@tempskipb\subfig@top\@xaddvskip
\fi
\fi
\if@contbotsub
\box\@tempboxa\egroup
\ifx \@empty#3\relax \else
\vskip\subfloatcapskip
\@memsubcaption{#1}{#2}{#3}%
\fi
\else
\ifx \@empty#3\relax \else
\@memsubcaption{#1}{#2}{#3}%
\vskip\subfloatcapskip
\vskip\subfloatcaptopadj
\fi\egroup
\box\@tempboxa
\fi
\vspace{\subfig@bottom}
\egroup
\egroup}
% \end{macrocode}
% \end{macro}
%
%
% The following series of macros, from \Lpack{subfigure}, control the
% typesetting of the subcaptions.
%
% \begin{macro}{\@memsubfigcaptionlist}
% A copy of \cs{@subfigcaptionlist}.
% \begin{macrocode}
\newcommand*{\@memsubfigcaptionlist}{}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\memlistsubcaptions}
% A copy of \cs{listsubcaptions}.
% \begin{macrocode}
\newcommand*{\memlistsubcaptions}{%
\@ifstar
{\gdef\@memsubfigcaptionlist{}}%
{\@memlistsubcaptions{\@captype}}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@memlistsubcaptions}
% A copy of \cs{@listsubcaptions}.
% \begin{macrocode}
\newcommand*{\@memlistsubcaptions}[1]{%
\@ifundefined{@captype}{}{%
\@ifundefined{ext@sub#1}{}{%
\@for \@tempa:=\@memsubfigcaptionlist \do {%
\ifx \@empty\@tempa\relax \else
\addcontentsline{\@nameuse{ext@sub#1}}{sub#1}{\@tempa}%
\fi}}}%
\gdef\@memsubfigcaptionlist{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makesubfloatcaption}
% This is a copy of \cs{@makesubfigurecaption}.
% \changes{v3.6k}{2011/07/21}{Added a \cs{unskip} to remove a space if
% the text is empty}
% \begin{macrocode}
\newcommand{\@makesubfloatcaption}[2]{%
\setbox\@tempboxa\hbox{%
\@subcapsize
{\@subcaplabelfont #1}{\@subcapfont\ignorespaces #2}\unskip}%
\@tempdimb=-\subfloatcapmargin
\multiply\@tempdimb\tw@
\advance\@tempdimb\@tempdima
\hb@xt@\@tempdima{%
\hss
\ifdim \wd\@tempboxa >\@tempdimb
\memsubfig@caption{#1}{#2}%
\else
\if@shortsubcap
\memsubfig@caption{#1}{#2}%
\else
\box\@tempboxa
\fi
\fi
\hss}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\memsubfig@caption}
% This is a copy of \cs{subfig@caption}.
% \changes{v3.6k}{2011/07/21}{Added a \cs{unskip} to remove a space if
% the text is empty}
% \begin{macrocode}
\newcommand{\memsubfig@caption}[2]{%
\if@hangsubcap
\sbox{\@tempboxa}{\@subcapsize\@subcaplabelfont #1}%
\addtolength{\@tempdimb}{-\wd\@tempboxa}%
\usebox{\@tempboxa}%
\memsubfig@captionpar{\@tempdimb}{%
{\@subcapfont\ignorespaces #2}\unskip}%
\else
\memsubfig@captionpar{\@tempdimb}{{\@subcaplabelfont #1}%
{\@subcapfont\ignorespaces #2}\unskip}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\memsubfig@captionpar}
% This replaces \cs{subfig@captionpar}.
% \begin{macrocode}
\newcommand{\memsubfig@captionpar}[2]{%
\parbox[t]{#1}{\@subcapsize\@contsubcstyle #2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\memsub@label}
% These are copies of \cs{sub@label} and \cs{subref}.
% \begin{macrocode}
\newcommand{\memsub@label}{%
\@ifnextchar (%
{\sf@memsub@label}%
{\sf@memsub@label(Sub\@captype\space
\@nameuse{p@sub\@captype}%
\@nameuse{thesub\@captype})}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sf@memsub@label}
% This is a copy of \cs{sf@sub@label}.
% \begin{macrocode}
\def\sf@memsub@label(#1)#2{%
\protected@edef\mem@currentlabelname{#1}%
\sf@@memsub@label{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sf@@memsub@label}
% This is an expanded copy of \cs{sf@@sub@label} processed after any packages may
% have been loaded.
% An added complexity here is when \Lpack{showkeys} is used. It
% redefines \cs{label} to write it in the margins. But the
% \cs{sf@@memsub@label} writes the label to aux directly. So in order
% to support \Lpack{showkeys}, we add a hook, and define this hook if
% \Lpack{showkeys} is loaded.
% \changes{v3.7g}{2018/02/28}{Added hook into \cs{sf@@memsub@label},
% issue reported via \texttt{https://tex.stackexchange.com/q/374301/3929}}
% \begin{macrocode}
\newcommand\sf@@memsub@label@hook[1]{}
\AtBeginDocument{%
\@ifpackageloaded{nameref}{%
% \end{macrocode}
% The \Lpack{nameref} package is loaded.
% \begin{macrocode}
\newcommand*{\sf@@memsub@label}[1]{%
\@bsphack
\sf@@memsub@label@hook{#1}%
\protected@write\@auxout{}{%
\string\newlabel{#1}%
{{\@nameuse{p@sub\@captype}\@nameuse{@@thesub\@captype}}%
{\thepage}%
{\mem@currentlabelname\relax}%
{\@currentHref}{}}}%
\protected@write\@auxout{}{%
\string\newlabel{sub@#1}%
{{\@nameuse{@@thesub\@captype}}%
{\thepage}%
{\mem@currentlabelname\relax}%
{\@currentHref}{}}}%
\@esphack}
}{% no nameref
\@ifpackageloaded{hyperref}{%
% \end{macrocode}
% The \Lpack{hyperref} package is loaded, but not \Lpack{nameref}.
% \begin{macrocode}
\newcommand*{\sf@@memsub@label}[1]{%
\@bsphack
\sf@@memsub@label@hook{#1}%
\protected@write\@auxout{}{%
\string\newlabel{#1}%
{{\@nameuse{p@sub\@captype}\@nameuse{@@thesub\@captype}}%
{\thepage}%
{\mem@currentlabelname\relax}%
{\@currentHref}{}}}%
\protected@write\@auxout{}{%
\string\newlabel{sub@#1}%
{{\@nameuse{@@thesub\@captype}}%
{\thepage}%
{\mem@currentlabelname\relax}%
{\@currentHref}{}}}%
\@esphack}
}{% no hyperref
% \end{macrocode}
% Neither the \Lpack{hyperref} nor the \Lpack{nameref}
% package is loaded.
% \begin{macrocode}
\let\@memoldlabel\label
\newcommand*{\sf@@memsub@label}[1]{%
\@bsphack
\sf@@memsub@label@hook{#1}%
\@memoldlabel{#1}%
\protected@write\@auxout{}{%
\string\newlabel{sub@#1}%
{{\@nameuse{@@thesub\@captype}}%
{\thepage}}}%
\@esphack}
}{}%
}% end no nameref
% \end{macrocode}
% Next add the hook redefinition if \Lpack{showkeys} is loaded. Please
% note that the placement of the \Lpack{showkeys} label, might be a
% little strange.
% \changes{v3.7g}{2018/02/28}{added}
% \changes{v3.7k}{2020/02/06}{Added a check on \cs{SK@}, if not
% defined showkeys is running under final mode}
% \begin{macrocode}
\@ifpackageloaded{showkeys}{%
\ifdefined\SK@\relax
\renewcommand\sf@@memsub@label@hook[1]{%
\SK@\SK@@label{#1}%
}
\fi
}{}
} % end AtBeginDocument
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subcaptionref}
% This is a copy of the \cs{subref} macro.
% \begin{macrocode}
\DeclareRobustCommand{\subcaptionref}{%
\@ifstar{\ssc@ref}{\sc@ref}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ssc@ref}
% \begin{macro}{\sc@ref}
% The implementation of the starred and unstarred forms of \cs{subcaptionref}.
% \begin{macrocode}
\newcommand*{\ssc@ref}[1]{\ref{sub@#1}}
\newcommand*{\sc@ref}[1]{{\@subcaplabelfont\ref{sub@#1}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Side captions}
% \changes{v1.61803}{2008/01/30}{Added all the code for side captions
% (mempatch v4.1)}
%
% \begin{macro}{\m@mscap@capbox}
% \begin{macro}{\m@mscap@fbox}
% We need two save boxes, one to hold the caption and the other
% for the float material.
% \begin{macrocode}
\newsavebox{\m@mscap@capbox}
\newsavebox{\m@mscap@fbox}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sidecapsep}
% \begin{macro}{\sidecapwidth}
% \cs{sidecapsep} is the space between the text and the caption, which
% is set in a box \cs{sidecapwidth} wide. These are initialized to
% the \cs{marginpar...} values.
% \begin{macrocode}
\newdimen\sidecapsep
\sidecapsep=\marginparsep
\newdimen\sidecapwidth
\sidecapwidth=\marginparwidth
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setsidecaps}
% \cs{setsidecaps}\marg{sep}\marg{width} sets the \cs{sidecapsep} and
% \cs{sidecapwidth} (Ivars Finvers noted that the initial values don't change
% if the \cs{marginpar...} values change, such as at \cs{checkandfixthelayout}).
% \changes{v1.61803}{2008/01/30}{Added \cs{setsidecaps} (mempatch v4.6)}
% \begin{macrocode}
\newcommand*{\setsidecaps}[2]{%
\setlength{\sidecapsep}{#1}\@memznegtest{\sidecapsep}%
\setlength{\sidecapwidth}{#2}\@memznegtest{\sidecapwidth}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@m@tempdima}
% \begin{macro}{\m@mscapraise}
% Lengths for internal use. \cs{m@m@tempdima} is meant for general
% temporary use.
% \begin{macrocode}
\newdimen\m@m@tempdima
\newdimen\m@mscapraise
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sidecapraise}
% Length to make (small) adjustments to the position of the caption wrt the float.
% \begin{macrocode}
\newdimen\sidecapraise
\sidecapraise \z@
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setsidecappos}
% \begin{macro}{\m@mscappos}
% \cs{setsidecappos}\marg{pos}, where \meta{pos} is one of \texttt{t},
% \texttt{c}, or \texttt{b}, sets the vertical position of the caption
% in relation to the float and the result is saved as \cs{m@mscappos}.
% The default is \texttt{c}.
% \begin{macrocode}
\newcommand*{\setsidecappos}[1]{%
\def\m@mscappos{#1}\def\@tempb{t}%
\ifx\@tempb\m@mscappos
\else
\def\@tempb{b}%
\ifx\@tempb\m@mscappos
\else
\def\@tempb{c}%
\ifx\@tempb\m@mscappos
\else
\@memerror{Argument to \string\setsidecappos\space is not t or c or b.
\MessageBreak Set to c}{\@ehc}%
\def\m@mscappos{c}%
\fi
\fi
\fi}
\setsidecappos{c}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sidecapmargin}
% \begin{macro}{\m@mscapmarg}
% \cs{sidecapmargin}\marg{margin}, where \meta{marg} is one of
% \texttt{left}, \texttt{right}, \texttt{inner}, or \texttt{outer},
% controls the margin where the caption will be put. The result
% is saved as \cs{m@mscapmarg} as a number. The default
% is \texttt{left}.
% \begin{macrocode}
\newcommand{\sidecapmargin}[1]{%
\def\@tempa{#1}\def\@tempb{left}%
\ifx\@tempb\@tempa
\def\m@mscapmarg{0}% left
\else
\def\@tempb{right}%
\ifx\@tempb\@tempa
\def\m@mscapmarg{1}% right
\else
\def\@tempb{outer}%
\ifx\@tempb\@tempa
\def\m@mscapmarg{2}% outer
\else
\def\@tempb{inner}%
\ifx\@tempb\@tempa
\def\m@mscapmarg{3}% inner
\else
\@memerror{Unrecognized argument for \string\sidecapmargin}%
{\@ehc}%
\def\m@mscapmarg{-1}% error
\fi
\fi
\fi
\fi}
\sidecapmargin{left}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifscapmargleft}
% \begin{macro}{\scapmarglefttrue}
% \begin{macro}{\scapmargleftfalse}
% \cs{ifscapmargleft} is TRUE the caption should be in the left hand margin,
% otherwise in the right hand margin.
% \begin{macrocode}
\newif\ifscapmargleft
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sidecapfloatwidth}
% \begin{macro}{\m@mscapmainwidth}
% \cs{sidecapfloatwidth} is the width of the box holding the float.
% Note that this is a macro,
% not a length, so must be changed using \cs{renewcommand*}.
% The default is \cs{linewidth}. Later, \cs{m@mscapmainwidth} will be set
% to the current length specification from \cs{sidecapfloatwidth}.
% \begin{macrocode}
\def\sidecapfloatwidth{\linewidth}
\newdimen\m@mscapmainwidth
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mscaplkern}
% \begin{macro}{\setm@mscaplkern}
% \cs{setm@mscaplkern} is a utility macro to calculate the kern
% (\cs{m@mscaplkern}) required when the caption is in the left margin.
% \begin{macrocode}
\newdimen\m@mscaplkern
\newcommand*{\setm@mscaplkern}{%
\m@mscaplkern=\sidecapwidth
\advance\m@mscaplkern \sidecapsep
\advance\m@mscaplkern \m@mscapmainwidth}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sidecapstyle}
% \cs{sidecapstyle} is called just before the caption is set. It can
% be redefined to set different caption style parameters. The default
% is raggedleft for left margin captions and raggedright for right
% margin captions.
% \begin{macrocode}
\newcommand*{\sidecapstyle}{%
\ifscapmargleft
\captionstyle{\raggedleft}%
\else
\captionstyle{\raggedright}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidecaption}
% The whole shebang is in the \texttt{sidecaption} environment but
% it is more convenient to specify this via macros rather than
% directly as an environment.
%
% \cs{sidecaption}\oarg{fortoc}\marg{title}\oarg{label} is what it
% looks like to the user, but internally further macros handle
% all the arguments.
% \begin{macrocode}
\newcommand*{\sidecaption}{%
\@ifnextchar [{\@sidecaption}{\@sidecaption[]}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sidecaption}
% \cs{@sidecaption}\oarg{fortoc}\marg{title} grabs the first
% two arguments.
% \begin{macrocode}
\def\@sidecaption[#1]#2{%
\@ifnextchar [{\@@sidecaption{#1}{#2}}{\@@sidecaption{#1}{#2}[]}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mem@scap@beforehook}
% \begin{macro}{\@mem@scap@afterhook}
% Two hooks into the 'scap' internals. By default they do nothing, but
% can be used make say sidecaption align towards the spine in twosided
% documents. This is done by redefining \emph{before} to
% \verb+\checkoddpage\ifoddpage\else\raggedleft\fi+ and redefining
% \emph{after} to \verb+\par+. Note that since 'sidecontcaption',
% 'sidenamedlegend' and 'sidelegend' all share the same basic
% internals redefining the two hooks will affect those as well. The
% user might want to create their own special environment, say, like this:
% \begin{verbatim}
% \makeatletter
% \newenvironment{sidecaption*}{
% \renewcommand\@mem@scap@beforehook{\checkoddpage\ifoddpage\else\raggedleft\fi}
% \renewcommand\@mem@scap@afterhook{\par}
% \begin{sidecaption}}
% {\end{sidecaption}}
% \makeatother
% \end{verbatim}
% \changes{v1.6180339c}{2009/01/21}{Added 'before' and 'after' hooks
% to shared sidecaption internals}
% \begin{macrocode}
\newcommand\@mem@scap@beforehook{}
\newcommand\@mem@scap@afterhook{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@sidecaption}
% \cs{@@sidecaption}\marg{fortoc}\marg{title}\oarg{label} is the
% last macro in the chain and handles all three arguments.
% This does all the work for \verb?\begin{sidecaption}?
% \begin{macro}{\m@mscap@fortoc}
% \begin{macro}{\m@mscap@forcap}
% \begin{macro}{\m@mscaplabel}
% First, save all the arguments as macros.
% \begin{macrocode}
\def\@@sidecaption#1#2[#3]{%
\ifx\@empty#1\@empty
\def\m@mscap@fortoc{#2}%
\else
\def\m@mscap@fortoc{#1}%
\fi
\def\m@mscap@forcap{#2}%
\ifx\@empty#3\@empty
\def\m@mscaplabel{}%
\else
\def\m@mscaplabel{\@bsphack\label{#3}\@esphack}%
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% Set the float width, calculate the left margin kern, and start
% a \texttt{minipage} to hold the float, saving it in box
% \cs{m@mscap@fbox}.
% \begin{macrocode}
\m@mscapstart@fbox}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mscapstart@fbox}
% \begin{macro}{\m@mscapend@fbox}
% \cs{m@mscapstart@fbox} is the macro that actually sets the float width,
% calculates the left margin kern, and starts the float's \texttt{minipage}.
% The macro \cs{m@mscapend@fbox} ends the box.
% \begin{macrocode}
\newcommand*{\m@mscapstart@fbox}{%
% \end{macrocode}
% \changes{v1.6180339c}{2009/01/21}{Added \cs{@mem@scap@beforehook}}
% \begin{macrocode}
\@mem@scap@beforehook%
\setlength{\m@mscapmainwidth}{\sidecapfloatwidth}%
\setm@mscaplkern
\begin{lrbox}{\m@mscap@fbox}%
\begin{minipage}[c]{\m@mscapmainwidth}}
\newcommand*{\m@mscapend@fbox}{%
\end{minipage}%
\end{lrbox}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\endsidecaption}
% \cs{endsidecaption} does the work for \verb?\end{sidecaption}?.
%
% Finish the float minipage, then increment the caption counter and
% call \cs{label} via \cs{m@mscaplabel}.
% \begin{macrocode}
\def\endsidecaption{%
\m@mscapend@fbox
\refstepcounter\@captype
\m@mscaplabel
% \end{macrocode}
% \changes{v3.6k}{2012/08/19}{We need to move \cs{m@mscapcheckside}
% here or the \cs{sidecapstyle} inside the box, will never work correctly.}
% \begin{macrocode}
\m@mscapcheckside %<--- added 2012/08/19
% \end{macrocode}
% Set the caption inside a minipage, saving it in box \cs{m@mscap@capbox}.
% \begin{macrocode}
\begin{lrbox}{\m@mscap@capbox}%
\begin{minipage}[c]{\sidecapwidth}%
\sidecapstyle
\@caption\@captype[\m@mscap@fortoc]{\m@mscap@forcap}
\end{minipage}%
\end{lrbox}%
% \end{macrocode}
% Output the float and caption.
% \begin{macrocode}
\m@mscapopboxes}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mscapopboxes}
% Having determined how high the caption box must be raised with
% respect to the float box, output the boxes.
% \begin{macrocode}
\newcommand*{\m@mscapopboxes}{%
\m@mcalcscapraise
% \end{macrocode}
% Set the float (from box \cs{m@mscap@fbox}) then the caption (from
% box \cs{m@mscap@capbox}) kerning it to the left or right as
% appropriate.
% \changes{v3.6k}{2012/08/19}{Moved \cs{m@mscapcheckside} into
% \cs{endsidecaption}, otherwise \cs{sidecapstyle} never see the side check}
% \begin{macrocode}
\usebox{\m@mscap@fbox}%\m@mscapcheckside
\ifscapmargleft%
\rlap{\kern-\m@mscaplkern
\raisebox{\m@mscapraise}{\usebox{\m@mscap@capbox}}}%
\else%
\rlap{\kern\sidecapsep
\raisebox{\m@mscapraise}{\usebox{\m@mscap@capbox}}}%
\fi
% \end{macrocode}
% Finally, make \cs{m@mscapthisside} a no-op.
% \begin{macrocode}
\gdef\m@mscapthisside{}%
% \end{macrocode}
% \changes{v1.6180339c}{2009/01/21}{Added \cs{@mem@scap@afterhook}}
% \begin{macrocode}
\@mem@scap@afterhook%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mcalcscapraise}
% Calculate the amount the caption might have to be raised wrt the
% float. This depends on the position: \\
% \texttt{t:} raise by the difference in heights \\
% \texttt{c:} shouldn't have to do anything as the minipages are meant
% to center aligned \\
% \texttt{b:} lower by the difference in depths \\
%
% However, experiments showed that a little bit of tweaking might
% help. The final adjustment, \cs{sidecapraise} is controlled by
% the user.
% \begin{macrocode}
\newcommand*{\m@mcalcscapraise}{%
\def\@tempb{t}%
\ifx\m@mscappos\@tempb
\settoheight{\m@m@tempdima}{\strut\usebox{\m@mscap@capbox}}%
\settoheight{\m@mscapraise}{\usebox{\m@mscap@fbox}}%
\advance\m@mscapraise -\m@m@tempdima
\advance\m@mscapraise 0.5ex
\else
\def\@tempb{b}%
\ifx\m@mscappos\@tempb
\settodepth{\m@m@tempdima}{\usebox{\m@mscap@fbox}}%
\settodepth{\m@mscapraise}{\strut\usebox{\m@mscap@capbox}}%
\advance\m@mscapraise -\m@m@tempdima
\else
\m@mscapraise=\z@
\advance\m@mscapraise 0.25ex
\fi
\fi
\advance\m@mscapraise \sidecapraise}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mscapcheckside}
% This macro determines whether the caption should be set in the
% left or right margin. In twocolumn documents the caption for a single
% column float is always set in the adjacent margin. Starred floats
% are treated as regular floats as in a onecolumn document.
% \begin{macrocode}
\newcommand*{\m@mscapcheckside}{%
\if@twocolumn
\ifdim\hsize=\textwidth% float*
\m@mscapcheckregside
\else
\if@firstcolumn
\scapmarglefttrue
\else
\scapmargleftfalse
\fi
\fi
\else
\m@mscapcheckregside
\fi
% \end{macrocode}
% Finally apply any user's override.
% \begin{macrocode}
\m@mscapthisside}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mscapcheckregside}
% This performs the margin calculation for onecolumn documents.
% \begin{macrocode}
\newcommand*{\m@mscapcheckregside}{%
\if@twoside
\checkoddpage
\ifnum\m@mscapmarg<\@ne% % left
\scapmarglefttrue
\else
\ifnum\m@mscapmarg=\@ne% % right
\scapmargleftfalse
\else
\ifnum\m@mscapmarg=\tw@% % outer
\scapmarglefttrue
\ifoddpage
\scapmargleftfalse
\fi
\else% % inner
\scapmargleftfalse
\ifoddpage
\scapmarglefttrue
\fi
\fi
\fi
\fi
\else% oneside
% \end{macrocode}
% In oneside documents, inner and outer is the same as left and right.
% \changes{v3.7f}{2015/08/10}{Side caption placement bugfix for
% onesided docs. Related to \protect\url{http://tex.stackexchange.com/q/259324/3929}.
% }
% \begin{macrocode}
% \scapmarglefttrue% 0 and 3
% \ifnum\m@mscapmarg>\@ne
% \ifnum\m@mscapmarg<\thr@@
% \scapmargleftfalse
% \fi
% \fi
\ifcase\m@mscapmarg\relax% 0
\scapmarglefttrue%
\or% 1
\scapmargleftfalse%
\or% 2
\scapmargleftfalse%
\or% 3
\scapmarglefttrue%
\fi%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\overridescapmargin}
% \begin{macro}{\m@mscapthisside}
% User macro to override the calculated caption margin. Call as either:\\
% \verb?\overridescapmargin{left}? or \verb?\overridescapmargin{right}? \\
% \begin{macrocode}
\newcommand*{\overridescapmargin}[1]{%
\def\@tempb{#1}\def\@tempa{left}%
\ifx\@tempa\@tempb
\def\m@mscapthisside{\scapmarglefttrue}%
\else
\def\@tempa{right}%
\ifx\@tempa\@tempb
\def\m@mscapthisside{\scapmargleftfalse}%
\else
\@memerror{Argument to \string\overridescapmargin\space neither
left nor right}{\@ehc}%
\def\m@mscapthisside{}%
\fi
\fi}
\newcommand*{\m@mscapthisside}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Now for the other kinds of captions.
%
% \begin{macro}{\sidecontcaption}
% \cs{sidecontcaption}\marg{title}\oarg{label} is for
% a continuation sidecaption.
% \begin{macrocode}
\newcommand*{\sidecontcaption}{%
\@sidecontcaption}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sidecontcaption}
% \cs{@sidecontcaption}\marg{title} grabs the first
% argument.
% \begin{macrocode}
\def\@sidecontcaption#1{%
\@ifnextchar [{\@@sidecontcaption{#1}}{\@@sidecontcaption{#1}[]}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@sidecontcaption}
% \cs{@@sidecontcaption}\marg{title}\oarg{label} is the
% last macro in the chain and handles all two arguments.
% This does all the work for \verb?\begin{sidecontcaption}?
% \begin{macrocode}
\def\@@sidecontcaption#1[#2]{%
\def\m@mscap@forcap{#1}%
\ifx\@empty#2\@empty
\def\m@mscaplabel{}%
\else
\def\m@mscaplabel{\@bsphack\label{#2}\@esphack}%
\fi
\m@mscapstart@fbox}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endsidecontcaption}
% \cs{endsidecontcaption} does the work for \verb?\end{sidecontcaption}?.
%
% \begin{macrocode}
\def\endsidecontcaption{%
\m@mscapend@fbox
\addtocounter{\@captype}{\m@ne}\refstepcounter\@captype
\m@mscaplabel
% \end{macrocode}
% \changes{v3.7b}{2013/05/30}{Forgot the side check}
% \begin{macrocode}
\m@mscapcheckside %<--- added 2013/05/30
\begin{lrbox}{\m@mscap@capbox}%
\begin{minipage}[c]{\sidecapwidth}%
\sidecapstyle
\@contcaption\@captype{\m@mscap@forcap}
\end{minipage}%
\end{lrbox}%
\m@mscapopboxes}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\sidenamedlegend}
% \begin{macro}{\@sidenamedlegend}
% \cs{sidenamedlegend}\oarg{fortoc}\marg{title} is for
% a namedlegend sidecaption.
% \begin{macrocode}
\newcommand*{\sidenamedlegend}{%
\@ifnextchar [{\@sidenamedlegend}{\@sidenamedlegend[]}}
\def\@sidenamedlegend[#1]#2{%
\@@sidenamedlegend{#1}{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@sidenamedlegend}
% \cs{@@sidenamedlegend}\marg{fortoc}\marg{title} is the
% last macro in the chain and handles all arguments.
% This does all the work for \verb?\begin{sidenamedlegend}?
% \begin{macrocode}
\def\@@sidenamedlegend#1#2{%
\ifx\@empty#1\@empty
\def\m@mscap@fortoc{#2}%
\else
\def\m@mscap@fortoc{#1}%
\fi
\def\m@mscap@forcap{#2}%
\def\m@mscaplabel{}%
\m@mscapstart@fbox}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endsidenamedlegend}
% \cs{endsidenamedlegend} does the work for \verb?\end{sidenamedlegend}?.
% \begin{macrocode}
\def\endsidenamedlegend{%
\m@mscapend@fbox
\begin{lrbox}{\m@mscap@capbox}%
\begin{minipage}[c]{\sidecapwidth}%
\sidecapstyle
\@legend\@captype[\m@mscap@fortoc]{\m@mscap@forcap}
\end{minipage}%
\end{lrbox}%
\m@mscapopboxes}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\sidelegend}
% \cs{sidelegend}\marg{title} is for
% a legend sidecaption.
% \begin{macrocode}
\newcommand*{\sidelegend}{%
\@@sidelegend}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@sidelegend}
% \cs{@@sidelegend}\marg{title} is the
% last macro in the chain and handles all arguments.
% This does all the work for \verb?\begin{sidelegend}?
% \begin{macrocode}
\def\@@sidelegend#1{%
\def\m@mscap@forcap{#1}%
\m@mscapstart@fbox}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endsidelegend}
% \cs{endsidelegend} does the work for \verb?\end{sidelegend}?.
% \begin{macrocode}
\def\endsidelegend{%
\m@mscapend@fbox
\begin{lrbox}{\m@mscap@capbox}%
\begin{minipage}[c]{\sidecapwidth}%
\sidecapstyle
\legend{\m@mscap@forcap}
\end{minipage}%
\end{lrbox}%
\m@mscapopboxes}
% \end{macrocode}
% \end{macro}
%
% \changes{v3.6k}{2013/015/13}{Added \Lpack{longtable} caption
% support}
%
% \subsubsection{Handling \Lpack{longtable} captions}
%
% In \Lpack{longtable} the caption ends up as a special row in the
% table. In order to use our caption formatting we need to redefine
% \cs{LT@makecaption} to use our formatting macro plus
% \cs{belowcaptionskip}. It needs to be
% done after \Lpack{longtable} is loaded, and \emph{not} if the
% \Lpack{ltcaption} package is loaded. The later is used by the
% \Lpack{caption} package to aid caption formatting i
% \Lpack{longtable}. Special thanks to Axel Sommerfelt.
% \begin{macro}{\LT@makecaption}
% \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{longtable}{
\@ifpackageloaded{ltcaption}{}{%
\def\LT@makecaption#1#2#3{%
\LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
\let\@memtempa\relax%
% starred form -> #1 = \@gobble
\ifx#1\@gobble%
\let\@contnfont\@empty%
\let\@contdelim\@empty%
\@@makecaption{}{#3}%
\else%
\@@makecaption{#2}{#3}%
\fi%
\endgraf\vskip\belowcaptionskip}%
\hss}}}
}
}{}
}
% \end{macrocode}
% At a later point, we will supplement with a \cs{legend} for
% \Lpack{longtable} as well.
% \end{macro}
%
% \section{Epigraphs}
%
% This code comes from the \Lpack{epigraph} package~\cite{EPIGRAPH}.
%
% \begin{macro}{\beforeepigraphskip}
% \begin{macro}{\afterepigraphskip}
% \begin{macro}{\epigraphwidth}
% \begin{macro}{\epigraphrule}
% The several length commands, which can be changed by the user with
% \cs{setlength}.
% \begin{macrocode}
\newlength{\beforeepigraphskip}
\setlength{\beforeepigraphskip}{.5\baselineskip}
\newlength{\afterepigraphskip}
\setlength{\afterepigraphskip}{.5\baselineskip}
\newlength{\epigraphwidth}
\setlength{\epigraphwidth}{.4\textwidth}
\newlength{\epigraphrule}
\setlength{\epigraphrule}{.4\p@}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\epigraphsize}
% The size of the font to be used.
% \begin{macrocode}
\newcommand{\epigraphsize}{\small}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\epigraphflush}
% \begin{macro}{\textflush}
% \begin{macro}{\sourceflush}
% The three commands to position epigraphs in the textblock and to position
% the components of the epigraph.
% \begin{macrocode}
\newcommand{\epigraphflush}{flushright}
\newcommand{\textflush}{flushleft}
\newcommand{\sourceflush}{flushright}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\epigraphfontsize}
% \begin{macro}{\epigraphposition}
% \begin{macro}{\epigraphtextposition}
% \begin{macro}{\epigraphsourceposition}
% These are declarative forms of the above. It's a bit late now, but
% the previous macros should have been internal.
% \changes{v1.2}{2002/08/10}{Added some declarations for epigraphs.}
% \begin{macrocode}
\newcommand{\epigraphfontsize}[1]{\def\epigraphsize{#1}}
\newcommand{\epigraphposition}[1]{\long\def\epigraphflush{#1}}
\newcommand{\epigraphtextposition}[1]{\def\textflush{#1}}
\newcommand{\epigraphsourceposition}[1]{\def\sourceflush{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
%
% \begin{macro}{\@epirule}
% The internal command to draw a rule between text and source.
% \begin{macrocode}
\newcommand{\@epirule}{\rule[.5ex]{\epigraphwidth}{\epigraphrule}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@epitext}
% The internal command to typeset the \meta{text}. Put it into a minipage of the
% right size and typeset per \cs{textflush}.
% \changes{v1.61803}{2008/01/30}{Added \cs{par} to \cs{@epitext} and
% \cs{@episource} (mempatch v4.7)}
% \begin{macrocode}
\newcommand{\@epitext}[1]{%
\begin{minipage}{\epigraphwidth}\begin{\textflush} #1\par
% \end{macrocode}
% Draw a rule if it will be visible, otherwise add some extra vertical space.
% \begin{macrocode}
\ifdim\epigraphrule>\z@ \@epirule \else \vspace*{1ex} \fi
\end{\textflush}\end{minipage}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@episource}
% The internal command for typesetting the \meta{source}, which is put
% into a minipage and typeset according to \cs{sourceflush}.
% \begin{macrocode}
\newcommand{\@episource}[1]{%
\begin{minipage}{\epigraphwidth}
\begin{\sourceflush} #1\par
\end{\sourceflush}\end{minipage}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\epigraph}
% Having got the preliminaries out of the way, here's the user command
% for a single epigraph. This is set in a minipage to prevent breaking
% across a page. Position it according to \cs{epigraphflush}.
% \begin{macrocode}
\newcommand{\epigraph}[2]{\vspace{\beforeepigraphskip}
{\epigraphsize\begin{\epigraphflush}\begin{minipage}{\epigraphwidth}
\@epitext{#1}\\ \@episource{#2}
\end{minipage}\end{\epigraphflush}
\vspace{\afterepigraphskip}}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\qitem}
% \begin{macro}{\qitemlabel}
% \cs{qitem} is the epigraph list version of \cs{item}.
% Set everything inside a minipage.
% \begin{macrocode}
\newcommand{\qitem}[2]{{%
\raggedright\item \begin{minipage}{\epigraphwidth}
\@epitext{#1}\\ \@episource{#2}
\end{minipage}}}
% \end{macrocode}
% \cs{qitemlabel} is needed for a list as well. It is not going to
% typeset anything.
% \begin{macrocode}
\newcommand{\qitemlabel}[1]{\hfill}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{environment}{epigraphs}
% Now for the epigraph list. This is defined in terms of a \Lenv{list}
% environment.
% \begin{macrocode}
\newenvironment{epigraphs}{%
% \end{macrocode}
% Do the vertical space, set the font size, position according to
% \cs{epigraphflush}, and put everything into a minipage.
% \begin{macrocode}
\vspace{\beforeepigraphskip}\begin{\epigraphflush}
\epigraphsize
\begin{minipage}{\epigraphwidth}
\list{}%
% \end{macrocode}
% Make the list just fit the minipage (i.e., no indents).
% \begin{macrocode}
{\itemindent\z@ \labelwidth\z@ \labelsep\z@
\leftmargin\z@ \rightmargin\z@
\let\makelabel\qitemlabel}}%
{\endlist\end{minipage}\end{\epigraphflush}
\vspace{\afterepigraphskip}}
% \end{macrocode}
% \end{environment}
%
% \subsection{Epigraphs before a chapter title}
%
%
% \begin{macro}{\@epichapapp}
% \begin{macro}{\dropchapter}
% \begin{macro}{\undodrop}
% Commands to drop and restore positions of chapter titles. Dropping is
% accomplished by inserting vertical space before the \cs{@chapapp} command.
% \begin{macrocode}
\newcommand{\dropchapter}[1]{%
\let\@epichapapp\@chapapp
\renewcommand{\@chapapp}{\vspace*{#1}\@epichapapp}}
\newcommand{\undodrop}{\let\@chapapp\@epichapapp}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Placing an epigraph before a chapter title uses the scheme outlined
% by Piet van Oostrum~\cite{FANCYHDR}. This is to put a zero sized
% picture into the page header.
%
% \begin{macro}{\if@epirhs}
% \begin{macro}{\if@epicenter}
% Two booleans for testing whether an epigraph is to be at the RH margin,
% centered, or at the LH margin. The default is RH margin.
% \begin{macrocode}
\newif\if@epirhs \@epirhstrue
\newif\if@epicenter \@epicentertrue
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@epipos}
% This routine sets the \cs{if@epi...} booleans according to the value of
% \cs{epigraphflush}. If \cs{epigraphflush} is neither \texttt{center} nor
% \texttt{flushleft}
% then it defaults to \texttt{flushright}. We have to use this to be upward
% compatible with \cs{epigraphflush} being set by the user with \cs{renewcommand}.
% \begin{macrocode}
\newcommand{\@epipos}{
\long\def\@ept{flushleft}
\ifx\epigraphflush\@ept
\@epirhsfalse \@epicenterfalse
\else
\long\def\@ept{center}
\ifx\epigraphflush\@ept
\@epirhsfalse \@epicentertrue
\else
\@epirhstrue \@epicenterfalse
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\epigraphhead}
% \cs{epigraphhead}\oarg{distance}\marg{text} puts \meta{text} at
% \meta{distance} (a number, not a length) below the header at the
% page position specified by \cs{epigraphflush}.
% \begin{macrocode}
\newcommand{\epigraphhead}[2][95]{%
% \end{macrocode}
% We have to use \cs{def} instead of the normal \LaTeX{} definition commands
% as we will keep on
% (re)defining things. For reasons that are not fully clear to me \LaTeX{}
% doesn't seem to like me using a \cs{savebox} for storing the epigraph text,
% so I'll use a command instead.
% \begin{macrocode}
\def\@epitemp{\begin{minipage}{\epigraphwidth}#2\end{minipage}}
% \end{macrocode}
% Define an \texttt{epigraph} page style.
% \begin{macrocode}
\def\ps@epigraph{\let\@mkboth\@gobbletwo
% \end{macrocode}
% There are three possible definitions for \cs{@oddhead} depending on the
% value of \cs{epigraphflush}. We call \cs{@epipos} to decide which one to do.
% \begin{macrocode}
\@epipos
\if@epirhs
\def\@oddhead{\hfil\begin{picture}(0,0)
\put(0,-#1){\makebox(0,0)[r]{\@epitemp}}
\end{picture}}
\else
\if@epicenter
\def\@oddhead{\hfil\begin{picture}(0,0)
\put(0,-#1){\makebox(0,0)[b]{\@epitemp}}
\end{picture}\hfil}
\else
\def\@oddhead{\begin{picture}(0,0)
\put(0,-#1){\makebox(0,0)[l]{\@epitemp}}
\end{picture}\hfil}
\fi
\fi
\let\@evenhead\@oddhead
\def\@oddfoot{\reset@font\hfil\thepage\hfil}
\let\@evenfoot\@oddfoot}
% \end{macrocode}
% Make \texttt{epigraph} be the page style for this page.
% \begin{macrocode}
\thispagestyle{epigraph}}
% \end{macrocode}
% \end{macro}
%
% The above produces a \texttt{plain} pagestyle with the epigraph. Life is
% more complex if someone wants a fancy style with the epigraph. They
% will have to do some work, though.
%
% \begin{macro}{\the@epigraph}
% \begin{macro}{\@epidrop}
% \begin{macro}{\epigraphforheader}
% \cs{the@pigraph} is a macro to store the contents of an epigraph, and \cs{@pidrop}
% stores the \meta{distance} number.
% \cs{epigraphforheader}\oarg{distance}\marg{text} defines the internal macros
% appropriately.
% \changes{v1.2}{2002/08/10}{Added \cs{the@epigraph}, \cs{@epidrop}}
% \changes{v1.2}{2002/08/10}{Added \cs{epigraphforheader}}
% \begin{macrocode}
\newcommand{\the@epigraph}{}
\newcommand{\@epidrop}{95}
\newcommand{\epigraphforheader}[2][95]{%
\def\@epidrop{#1}\long\def\the@epigraph{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\epigraphpicture}
% \cs{epigraphpicture} puts \cs{the@epigraph} into a zero-sized picture at location
% \verb?(0,-\@epidrop)?. This can then be used as part of a fancy chapter header.
% The coding is similar to \cs{epigraphhead}.
% \changes{v1.2}{2002/08/10}{Added \cs{epigraphpicture}}
% \begin{macrocode}
\newcommand{\epigraphpicture}{%
\def\@epitemp{%
\begin{minipage}{\epigraphwidth}\the@epigraph\end{minipage}}%
\@epipos
\if@epirhs
\begin{picture}(0,0)%
\put(0,-\@epidrop){\makebox(0,0)[r]{\@epitemp}}%
\end{picture}%
\else
\if@epicenter
\begin{picture}(0,0)%
\put(0,-\@epidrop){\makebox(0,0)[b]{\@epitemp}}%
\end{picture}%
\else
\begin{picture}(0,0)%
\put(0,-\@epidrop){\makebox(0,0)[l]{\@epitemp}}%
\end{picture}%
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
%
%
% \section{The deprecated font commands}
%
% The class does not support the old font changing commands unless the
% \Lopt{oldfontcommands} option is used.
%
% \begin{macro}{\@memoldfonterr}
% \begin{macro}{\@memoldfontwarn}
% Macros for old font class error and warning. E.g., \\
% \verb?\@memoldfonterr{\tt}{\ttfamily}{\texttt}?
% \changes{v1.4}{2003/02/27}{Added \cs{@memoldfonterr} and \cs{@memoldfontwarn}}
% \changes{v1.618}{2005/09/03}{Fiddled with the braces in \cs{@memoldfontwarn} (mempatch v3.0)}
% \begin{macrocode}
\newcommand*{\@memoldfonterr}[3]{%
\@memerror{Font command \protect#1\space is not supported}{%
Use \protect#2, or \protect#3{...}, or the oldfontcommands option}}
\newcommand*{\@memoldfontwarn}[3]{%
\@memwarn{The \protect#1\space font command is deprecated.
\MessageBreak Use \protect#2{...} or {\protect#3... } instead}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Just give a single warning when an old font command is used following the
% \Lopt{oldfontcommands} option.
% \changes{v1.4}{2003/11/22}{Just issue a single warning for an old font
% (from patch v1.9)}
%
% \begin{macro}{\@mem@rmwarn}
% \begin{macro}{\rm}
% The old command for roman font.
% \changes{v1.0a}{2002/01/29}{Changed definition of \cs{rm}}
% \changes{v1.4}{2003/02/27}{More efficient coding of all the old font commands}
% \begin{macrocode}
\if@memoldfont
\def\@mem@rmwarn{\@memoldfontwarn{\rm}{\textrm}{\rmfamily}}
\DeclareOldFontCommand{\rm}{\@mem@rmwarn\gdef\@mem@rmwarn{}%
\normalfont\rmfamily}{\mathrm}
\else
\def\rm{\@memoldfonterr{\rm}{\textrm}{\rmfamily}}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mem@sfwarn}
% \begin{macro}{\sf}
% The old sans font command.
% \changes{v1.0a}{2002/01/29}{Changed definition of \cs{sf}}
% \begin{macrocode}
\if@memoldfont
\def\@mem@sfwarn{\@memoldfontwarn{\sf}{\textsf}{\sffamily}}
\DeclareOldFontCommand{\sf}{\@mem@sfwarn\gdef\@mem@sfwarn{}%
\normalfont\sffamily}{\mathsf}
\else
\def\sf{\@memoldfonterr{\sf}{\textsf}{\sffamily}}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mem@ttwarn}
% \begin{macro}{\tt}
% The old typewriter font command.
% \changes{v1.0a}{2002/01/29}{Changed definition of \cs{tt}}
% \begin{macrocode}
\if@memoldfont
\def\@mem@ttwarn{\@memoldfontwarn{\tt}{\texttt}{\ttfamily}}
\DeclareOldFontCommand{\tt}{\@mem@ttwarn\gdef\@mem@ttwarn{}%
\normalfont\ttfamily}{\mathtt}
\else
\def\tt{\@memoldfonterr{\tt}{\texttt}{\ttfamily}}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mem@bfwarn}
% \begin{macro}{\bf}
% The old bold font command.
% \changes{v1.0a}{2002/01/29}{Changed definition of \cs{bf}}
% \begin{macrocode}
\if@memoldfont
\def\@mem@bfwarn{\@memoldfontwarn{\bf}{\textbf}{\bfseries}}
\DeclareOldFontCommand{\bf}{\@mem@bfwarn\gdef\@mem@bfwarn{}%
\normalfont\bfseries}{\mathbf}
\else
\def\bf{\@memoldfonterr{\bf}{\textbf}{\bfseries}}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mem@itwarn}
% \begin{macro}{\it}
% The old italic font command.
% \changes{v1.0a}{2002/01/29}{Changed definition of \cs{it}}
% \begin{macrocode}
\if@memoldfont
\def\@mem@itwarn{\@memoldfontwarn{\it}{\textit}{\itshape}}
\DeclareOldFontCommand{\it}{\@mem@itwarn\gdef\@mem@itwarn{}%
\normalfont\itshape}{\mathit}
\else
\def\it{\@memoldfonterr{\it}{\textit}{\itshape}}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mem@slwarn}
% \begin{macro}{\sl}
% The old slanted font command.
% \changes{v1.0a}{2002/01/29}{Changed definition of \cs{sl}}
% \begin{macrocode}
\if@memoldfont
\def\@mem@slwarn{\@memoldfontwarn{\sl}{\textsl}{\slshape}}
\DeclareOldFontCommand{\sl}{\@mem@slwarn\gdef\@mem@slwarn{}%
\normalfont\slshape}{\@nomath\sl}
\else
\def\sl{\@memoldfonterr{\sl}{\textsl}{\slshape}}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mem@scwarn}
% \begin{macro}{\sc}
% The old small caps font command.
% \changes{v1.0a}{2002/01/29}{Changed definition of \cs{sc}}
% \begin{macrocode}
\if@memoldfont
\def\@mem@scwarn{\@memoldfontwarn{\sc}{\textsc}{\scshape}}
\DeclareOldFontCommand{\sc}{\@mem@scwarn\gdef\@mem@scwarn{}%
\normalfont\scshape}{\@nomath\sc}
\else
\def\sc{\@memoldfonterr{\sc}{\textsc}{\scshape}}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mem@calwarn}
% \begin{macro}{\cal}
% The old calligraphic font command.
% \changes{v1.0a}{2002/01/29}{Added definition of \cs{cal}}
% \begin{macrocode}
\if@memoldfont
\def\@mem@calwarn{%
\@memwarn{The \protect\cal\space font command is deprecated.
\MessageBreak Try to use \protect\mathcal\space instead}}
\DeclareRobustCommand*\cal{\@mem@calwarn\gdef\@mem@calwarn{}%
\@fontswitch\relax\mathcal}
\else
\def\cal{%
\@memerror{Font command \protect\cal\space is not supported}{%
Use \protect\mathcal, or the oldfontcommands option}}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mem@mitwarn}
% \begin{macro}{\mit}
% The old math italic font command.
% \changes{v1.0a}{2002/01/29}{Added definition of \cs{mit}}
% \begin{macrocode}
\if@memoldfont
\def\@mem@mitwarn{%
\@memwarn{The \protect\mit\space font command is deprecated.
\MessageBreak Try to use \protect\mathnormal\space instead}}
\DeclareRobustCommand*\mit{\@mem@mitwarn\gdef\@mem@mitwarn{}%
\@fontswitch\relax\mathnormal}
\else
\def\mit{%
\@memerror{Font command \protect\mit\space is not supported}{%
Use \protect\mathnormal, or the oldfontcommands option}}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\em}
% \begin{macro}{\eminnershape}
% \begin{macro}{\emph}
% The old emphasis font command (the original \cs{em} is defined in the
% kernel file \file{ltfssini.dtx}, coded here as \cs{@m@m@m}).
% \changes{v0.2}{2001/06/03}{Redid coding for \cs{emph} and \cs{em}}
% \changes{v1.618}{2005/09/03}{Dont' deprecate \cs{em} and deleted \cs{@mem@emwarn} (mempatch v3.0)}
% \changes{v1.618}{2005/09/03}{Completely redid \cs{em} and \cs{emph}, matching latest fixltx2e package (mempatch v3.3)}
% \begin{macrocode}
\DeclareRobustCommand{\em}{%
\@nomath\em
\ifdim\fontdimen\@ne\font > \z@
\eminnershape
\else
\itshape
\fi}
\providecommand{\eminnershape}{\upshape}
\DeclareTextFontCommand{\emph}{\em}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
%
% \section{Cross Referencing} \label{sec:xref}
%
% \subsection{Label referencing}
%
% \begin{macro}{\fref}
% \begin{macro}{\tref}
% \begin{macro}{\pref}
% These are named references to labeled figures, tables and pages.
% I find these
% useful to ensure consistency throughout the document --- I don't have
% to remember whether it is `see Figure ...' or `figure' or `Fig.' or \ldots.
% \begin{macrocode}
\newcommand*{\fref}[1]{\figurerefname~\ref{#1}}
\newcommand*{\tref}[1]{\tablerefname~\ref{#1}}
\newcommand*{\pref}[1]{\pagerefname~\pageref{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Aref}
% \begin{macro}{\Bref}
% \begin{macro}{\Pref}
% \begin{macro}{\Cref}
% \begin{macro}{\Sref}
% These are named references to labeled Part, Chapter and Sectional
% divisions.
% \changes{v1.2}{2002/07/27}{Added \cs{Pref}, \cs{Cref} and \cs{Sref}}
% \changes{v1.61803}{2008/01/30}{Added \cs{Bref} (mempatch v4.9+)}
% \changes{v1.61803}{2008/05/17}{Added \cs{Aref}}
% \begin{macrocode}
\newcommand*{\Aref}[1]{\appendixrefname\ref{#1}}
\newcommand*{\Bref}[1]{\bookrefname\ref{#1}}
\newcommand*{\Pref}[1]{\partrefname\ref{#1}}
\newcommand*{\Cref}[1]{\chapterrefname\ref{#1}}
\newcommand*{\Sref}[1]{\sectionrefname\ref{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Title referencing}
%
% This is based on DA's \Lpack{titleref} package~\cite{TITLEREF}.
% The following
% remarks are taken from that package.
%
%
% Titles for numbered sectioning units and for floats with captions are
% the same as the respective TOC, LOF, or LOT entry (even when no TOC is
% printed). When a short title is provided (\verb?\section[short]{long}?)
% it will be used for the \cs{titleref}. This is especially useful for
% figure captions. Unnumbered sections take their title reference from
% the printed title. Beware! This turns the title into a moving argument
% when it normally is not, and will cause weird errors if there are
% `fragile' commands present.
%
% Enumerated lists do not have titles and simply inherit the title of
% their section.
%
% The format of the title reference is controlled by the command
% \cs{theTitleReference}, which can be redefined with \cs{renewcommand}.
% It takes two parameters: the number and the title. The number is
% just the regular \cs{ref} and it is WRONG in unnumbered sections.
% Beware! The default definition is the unadorned title. You could
% do, for example, \\
% \verb?\renewcommand{\theTitleReference}[2]{#1\ \emph{#2}}?.
%
% The title of the current section is also available without \cs{label}:
% Use the command \cs{currenttitle} to generate a \cs{titleref} to the current
% section. If you have redefined \cs{theTitleReference} to print the number
% with the title, be aware that the two may not correspond: In a numbered
% list the number will show the current item but the title will show the
% current section, but in an unnumbered section the number will show
% some previous section number.
%
% The big problem with the \verb?[usetoc]? method is that \cs{titleref} will
% not refer to a \cs{label} which was given in the title or caption itself;
% the label must be placed after the sectioning command or the caption.
% If you make a title-reference to a label given in a title, you will get
% a warning message.
%
% \changes{v1.4}{2003/11/16}{Added title referencing (from patch v1.4)}
%
% \begin{macro}{\ifheadnameref}
% \begin{macro}{\headnameref}
% \begin{macro}{\tocnameref}
% \cs{ifheadnameref}: FALSE use ToC entry, TRUE use header entry
% \changes{v1.61803}{2008/01/30}{Added \cs{headnameref} and \cs{tocnameref}}
% \begin{macrocode}
\newif\ifheadnameref
\newcommand*{\headnameref}{\headnamereftrue}
\newcommand*{\tocnameref}{\headnamereffalse}
\tocnameref
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\theTitleReference}
% \cs{theTitleReference}\marg{num}\marg{title} is the style for typesetting
% a referenced (number and) title.
% \begin{macrocode}
\newcommand{\theTitleReference}[2]{#2}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\label}
% This redefinition of \cs{label} is intended to work with other redirections
% of \cs{label}, if they record extra information in a similar way.
% \begin{macrocode}
\let\@mem@old@label\label
\def\label#1{\@bsphack\begingroup
\protected@edef\@currentlabel{\protect\M@TitleReference
{\@currentlabel}{\M@currentTitle}}%
\@mem@old@label{#1}%
\endgroup \@esphack}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mem@@gettitle}
% \cs{@mem@@gettitle}\marg{title} grabs a title text.
% \begin{macrocode}
\def\@mem@@gettitle#1{\begingroup \let\protect\@unexpandable@protect
\let\label\@mem@nestwarn
\let\index\@gobble \let\glossary\@gobble
\let\markboth\@gobbletwo \let\@mkboth\@gobbletwo
\let\markright\@gobble
\edef\@tempa{\noexpand\def\noexpand\M@currentTitle{#1}}%
\expandafter\endgroup\@tempa}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mem@nestwarn}
% \begin{macro}{\M@TitleReference}
% \begin{macrocode}
\let\@mem@nestwarn\@gobble
\let\M@TitleReference\@firstoftwo
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\titleref}
% \begin{macro}{\currenttitle}
% \begin{macro}{\@mem@titleref}
% \begin{macro}{\@mem@titlerefnolink}
% \cs{titleref}\marg{key} prints the title corresponding to
% \verb?\label{key}?. \cs{currenttitle} prints the latest title.
% \cs{titleref} extended to support a starred version that will not
% provide hyperlinks when using \Lpack{hyperref}. The
% \Lpack{hyperref} definition of \cs{@mem@titlerefnolink} is found
% in \Lpack{memhfixc}.
% \changes{v1.6180339c}{2009/01/18}{Extended \cs{titleref}, suggestion
% on ctt by martin@helios.de}
% \begin{macrocode}
\newcommand*\@mem@titleref[1]{\begingroup
\let\numberline\@gobble
\let\M@TitleReference\@mem@theTR % interrupt recursion of \ref
\ref{#1}\endgroup}
\let\@mem@titlerefnolink\@mem@titleref
\DeclareRobustCommand\titleref{\@ifstar{\@mem@titlerefnolink}{\@mem@titleref}}
\DeclareRobustCommand{\currenttitle}{\begingroup
\let\numberline\@gobble
\theTitleReference\@currentlabel\M@currentTitle\endgroup}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{verbatim}
% % \DeclareRobustCommand\@mem@nestwarn[1]{\@memwarn%
% % {Label \string"#1\string" was put in a title,\MessageBreak
% % so the \noexpand\titleref is incorrect}}
% \end{verbatim}
%
% \begin{macro}{\M@currentTitle}
% \begin{macrocode}
\let\M@currentTitle\@empty
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mem@theTR}
% proper definition:
% \begin{macrocode}
\def\@mem@theTR{\let\M@TitleReference\@firstoftwo \theTitleReference}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\namerefon}
% \begin{macro}{\namerefoff}
% Named references has turned some arguments (e.g., \verb?\legend{text}?) into
% moving ones (Sven.Hartrumpf@FernUni-Hagen.de reported a problem but
% not a cause, March 2003). Not everyone needs named references.
% \begin{macrocode}
\newcommand*{\namerefon}{\let\M@gettitle\@mem@@gettitle}
\newcommand*{\namerefoff}{\let\M@gettitle\@gobble}
\namerefon
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \section{Table of Contents, etc.}
%
% A \cs{section} command writes a
% \verb?\contentsline{section}?\marg{title}\marg{page} command
% on the \file{.toc} file, where \meta{title} contains the
% contents of the entry and \meta{page} is the page number. If
% sections are being numbered, then \meta{title} will be of the
% form \cs{numberline}\marg{num}\marg{heading} where
% \meta{num} is the number produced by \cs{thesection}. Other
% sectioning commands work similarly.
%
% A \cs{caption} command in a `figure' environment writes \\
% \verb?\contentsline{figure}{?\cs{numberline}\marg{num}\marg{caption}\verb?}?\marg{page} \\
% on the \file{.lof} file, where \meta{num} is the number produced
% by \cs{thefigure} and \meta{caption} is the figure caption. It
% works similarly for a `table' environment.
%
% The command \cs{contentsline}\marg{name} expands to
% \cs{l@}\meta{name}. So, to specify the table of contents, we must
% define \cs{l@chapter}, \cs{l@section}, \cs{l@subsection}, \ldots ; to
% specify the list of figures, we must define \cs{l@figure}; and so
% on. Most of these can be defined with the \cs{@dottedtocline}
% command, which works as follows. \\
% \cs{@dottedtocline}\marg{level}\marg{indent}\marg{numwidth}\marg{title}\marg{page}
%
% \begin{description}
% \item[\meta{level}] An entry is produced only if\meta{level}
% $<=$ value of the \Lcount{tocdepth} counter. Note,
% \cs{chapter} is level 0, \cs{section} is level 1, etc.
% \item[\meta{indent}] The indentation from the outer left margin
% of the start of the contents line.
% \item[\meta{numwidth}] The width of a box in which the section
% number is to go, if \meta{title} includes a \cs{numberline}
% command.
% \end{description}
%
% \begin{macro}{\@pnumwidth}
% \begin{macro}{\@tocrmarg}
% \begin{macro}{\@dotsep}
% This command uses the following three parameters, which are set
% with a \cs{newcommand} (so em's can be used to make them depend upon
% the font).
% \begin{description}
% \item[\texttt{\bslash @pnumwidth}] The width of a box in which the
% page number is put.
% \item[\texttt{\bslash @tocrmarg}] The right margin for multiple
% line entries. One wants \cs{@tocrmarg} $\ge$ \cs{@pnumwidth}
% \item[\texttt{\bslash @dotsep}] Separation between dots, in mu
% units. Should be defined as a number like 2 or 1.7
% \end{description}
%
% \begin{macrocode}
\newcommand{\@pnumwidth}{1.55em}
\newcommand{\@tocrmarg} {2.55em}
\newcommand{\@dotsep}{4.5}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocentryskip}
% \begin{macro}{\tocbaseline}
% \begin{macro}{\tocskip}
% We define two lengths and a utility command.
% \begin{macrocode}
\newlength{\tocentryskip} \setlength{\tocentryskip}{1em}
\newlength{\tocbaseline} \setlength{\tocbaseline}{20pt}
\newcommand{\tocskip}[1]{%
\addtocontents{toc}{\protect\vspace{#1}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{New List of \ldots}
%
% It is apparent that users want to do at least two things that are not
% readily provided by the standard classes: (a) change the appearance
% of the Table of Contents, etc., headings, and (b) create new List of\ldots.
% This class provides a means of creating new Lists whose headings are
% parameterized, thereby killing two birds with one stone.
%
% In the standard classes the tables of contents, figures etc. are always
% set in single-column style. In this class you can choose one- or two-column
% ToCs, etc.
% The titles are added to the ToC, unless the starred versions of the
% commands are used.
% \changes{v1.6180339f}{2009/03/16}{Enabled two-column ToC, etc}
%
% \begin{macro}{\ensureonecol}
% \begin{macro}{\restorefromonecol}
% These two
% macros cooperate to switch from two-columns to one column, and back again.
% \changes{v1.0a}{2002/01/24}{Deleted \cs{ensuretwocol} and
% \cs{restorefromtwocol} as they were unused. BUT later reinstated them.}
% \begin{macro}{\onecoltocetc}
% \begin{macro}{\twocoltocetc}
% \begin{macro}{\doccoltocetc}
% These macros define \cs{ensureonecol} and \cs{restorefromonecol} such that
% \begin{itemize}
% \item \cs{onecoltocetc} ToCs, etc., will be set in one column (the default)
% \item \cs{twocoltocetc} ToCs, etc., will be set in two columns
% \item \cs{doccoltocetc} ToCs, etc., will be set in column(s) corresponding
% to the document's (onecolumn/twocolumn) option.
% \end{itemize}
% \changes{v1.6180339f}{2009/03/16}{Added \cs{onecoltocetc}, \cs{twocoltocetc}
% and \cs{doccoltocetc}}
% \begin{macrocode}
\newcommand*{\onecoltocetc}{%
\def\ensureonecol{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi}%
\def\restorefromonecol{\if@restonecol\twocolumn\fi}}
\newcommand*{\twocoltocetc}{%
\def\ensureonecol{%
\if@twocolumn
\@restonecoltrue
\else
\@restonecolfalse\twocolumn
\fi}%
\def\restorefromonecol{\if@restonecol\else\onecolumn\fi}}
\newcommand*{\doccoltocetc}{%
\let\ensureonecol\relax
\let\restorefromonecol\relax}
% \end{macrocode}
% Set the default
% \begin{macrocode}
\onecoltocetc
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\cftparskip}
% The \cs{parskip} local to the ToC, etc, is set to the length \cs{cftparskip}.
% \begin{macrocode}
\newlength{\cftparskip}
\setlength{\cftparskip}{0pt}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newlistof}
% \cs{newlistof}\marg{listofcmmd}\marg{ext}\marg{listofname}
% creates the command \cs{listofcmmd} to typeset a new List of, where the
% external file has the extension \file{.ext} and the heading title is
% \meta{listofname}. The code for this is a heavily modified part
% of the \Lpack{tocloft} package.
%
% \begin{macrocode}
\newcommand{\newlistof}[3]{%
% \end{macrocode}
%
% In the following, \texttt{X} stands for the value of \meta{listofcmmd} and
% \texttt{Z} stands for the value of \meta{ext}.
%
% \begin{macro}{\ext@Z}
% \begin{macro}{\Zdepth}
% The file extension and listing depth, which is set to level~1.
% \begin{macrocode}
\@namedef{ext@#2}{#2}
\@ifundefined{c@#2depth}{\newcounter{#2depth}}{}
\setcounter{#2depth}{1}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Zmark}
% The heading marks for the listing.
% \changes{v1.1}{2002/03/10}{Changed \cs{@mkboth} to \cs{markboth} in \cs{Zmark}}
% \begin{macrocode}
\@namedef{#2mark}{\markboth{#3}{#3}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\X}
% Typeset the listing title and entries,
% with both a normal and starred version.
% \changes{v1.61803398}{2009/08/08}{changed such that it only use one
% internal macro}
% \changes{v1.61803398}{2009/08/09}{chose a better name for the
% internal macro}
% \begin{macrocode}
\@namedef{#1}{\@ifstar{\@nameuse{mem@#1}{01}}{\@nameuse{mem@#1}{00}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@X}
% \begin{macro}{\cftZbeforelisthook}
% \begin{macro}{\cftZafterlisthook}
% \changes{v1.61803398}{2009/08/08}{introduced \cs{mem@X} to replace
% \cs{@starZ} and \cs{@plainZ}}
% In earlier version of the class, we used two macros \cs{@starZ}
% and \cs{@plainZ}, to reduce code we now only use one, the argument
% of it takes care of differentiating between the stuff that are
% different. Two hooks is added just before and after importing the
% list file contents. Additionally we have added a hook before the
% title is being executed, it comes after \cs{phantomsection} but
% before any \cs{addcontentsline}
% \changes{v1.61803398d}{2010/02/14}{added the before and after hooks}
% \changes{v3.7i}{2019/10/25}{moved the @\#2maketitle until after the
% \cs{addcontentsline}, that way the hyperref anchor is above the
% title, not below it. }
% \begin{macrocode}
\@namedef{cft#2beforelisthook}{}%
\@namedef{cft#2afterlisthook}{}%
\@namedef{mem@#1}##1{%
\ensureonecol
\par
\begingroup
\phantomsection
\if##1
\ifmem@em@starred@listof\else
\addcontentsline{toc}{chapter}{#3}
\fi
\fi
\@nameuse{@#2maketitle}
\parskip\cftparskip
\@nameuse{cft#2beforelisthook}%
\@starttoc{#2}%
\@nameuse{cft#2afterlisthook}%
\endgroup
\restorefromonecol}
% \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@Zmaketitle}
% This macro typesets the title.
% \changes{v1.3}{2002/10/10}{Added \cs{printZnonum} to \cs{@Zmaketitle}}
% \changes{v1.61803}{2008/01/30}{Slight changes to \cs{@Zmaketitle}
% (mempatch v4.6)}
% \changes{v3.6j}{2011/03/01}{Made sure \cs{parskip} is zero in the
% title, otherwise a non-zero \cs{parskip} might cause it to be placed
% incorrectly}
% \begin{macrocode}
\@namedef{@#2maketitle}{%
\@nameuse{#2headstart}
{\parindent\z@
\parskip\z@
%%%% \parskip\cftparskip
\interlinepenalty\@M
% \end{macrocode}
% \changes{v1.3}{2002/11/14}{Added printZnonum to \cs{newlistof}}
% \begin{macrocode}
\@nameuse{print#2nonum}%
\@nameuse{print#2title}{#3}%
\@nameuse{#2mark}%
\thispagestyle{chapter}%
\@nameuse{after#2title}
}
\@afterheading}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Zheadstart}
% \begin{macro}{\afterZtitle}
% The macros \cs{Zheadstart} and \cs{afterZtitle}
% control what goes before and after the title. They
% default to the corresponding macros for chapters.
% \begin{macrocode}
\@namedef{#2headstart}{\chapterheadstart}
\@namedef{after#2title}{\afterchaptertitle}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\printZnonum}
% This typesets something before the title and defaults
% to \cs{printchapternonum}.
% \changes{v1.3}{2002/10/10}{Added \cs{printZnonum} macro}
% \begin{macrocode}
\@namedef{print#2nonum}{\printchapternonum}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\printZtitle}
% The title is typeset by the macro \cs{printZtitle}\marg{title}
% which defaults to \cs{printchaptertitle}.
% \begin{macrocode}
\@namedef{print#2title}##1{\printchaptertitle{##1}}
% \end{macrocode}
% \end{macro}
%
% This is the end of the definition of \cs{newlistof}.
% \begin{macrocode}
} % end \newlistof
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifmem@em@starred@listof}
% \begin{macro}{\KeepFromToc}
% The class handles the created `new lists' a little different than
% other classes. We automatically add it to the main table of
% contents. This us usually what one wants. If not, one can always
% use the starred version. But in some cases other packages will use
% \cs{tableofcontents} to typeset their own `list of\dots', in which
% case it becomes a little hard to add a star. Therefore we add a
% switch that can be used to emulate the starred list of. After the
% macro \cs{KeepFromToc} the memoir created (non-starred) `list of'
% will behave as their starred counterpart.
% \changes{v1.61803398}{2009/08/08}{LM: added \cs{KeepFromToc}}
% \begin{macrocode}
\newif\ifmem@em@starred@listof
\newcommand\KeepFromToc{\mem@em@starred@listoftrue}
% \end{macrocode}
% Tip: use \cs{KeepFromToc} as an environment, i.e.
% \begin{verbatim}
% \begin{KeepFromToc}
% \listoffigures
% \end{KeepFromToc}
% \end{verbatim}
% to locally remove a list from the TOC.
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@starttoc}
% A list of macro calls \cs{@starttoc} to read the appropriate file. I have
% changed the kernel definition to allow a file to be read multiple times
% by delaying killing the file until the end of the document.
% \changes{v1.3}{2002/11/14}{Changed \cs{@starttoc}}
% \changes{v1.61803398d}{2009/11/23}{Removed infelicity in \cs{@starttoc}}
% \begin{macrocode}
\renewcommand{\@starttoc}[1]{%
\begingroup\makeatletter
\@input{\jobname.#1}%
\if@filesw
\AtEndDocument{%
% \end{macrocode}
% If a ToC, or other ListOf, is called more than once then we have to stop
% opening yet another, redundant, output file. The check against \cs{relax}
% seems to meet the requirement.
% \begin{macrocode}
\expandafter\ifx\csname tf@#1\endcsname\relax
\expandafter\newwrite\csname tf@#1\endcsname
\immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
\fi
}%
\fi
\@nobreakfalse
\endgroup}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Table of Contents}
%
% \begin{macro}{\tableofcontents}
% \begin{macro}{\tableofcontents*}
% These macros request that \LaTeX{} produces a table of
% contents. The ToC heading is added to the ToC unless the starred
% version is used.
%
% \begin{macrocode}
\newlistof{tableofcontents}{toc}{\contentsname}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% The List of Figures and List of Tables are defined later.
%
%
%
% \subsection{List entries}
%
% Each command in the body of the text that makes an entry in the ToC,
% or LoF or LoT needs an addtional macro to format the entry, as described
% above. Users often want to change the formatting of the entries but
% it is not immediately obvious how to do that.
%
% I have borrowed and modified more of the code from the \Lpack{tocloft}
% package to enable easy creation and modification the formatting of the
% entries.
%
%
% \begin{macro}{\setpnumwidth}
% \begin{macro}{\setrmarg}
% User commands for setting \cs{@pnumwidth} and \cs{@tocrmarg}.
% \begin{macrocode}
\newcommand*{\setpnumwidth}[1]{\renewcommand{\@pnumwidth}{#1}}
\newcommand*{\setrmarg}[1]{\renewcommand{\@tocrmarg}{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftdot}
% \begin{macro}{\cftdotfill}
% In the default ToC, a dotted line can be used to provide a leader between
% a title and the page number. The definition of this leader is buried
% in the \cs{@dottedtocline} command. The \cs{cftdotfill}\marg{sep}
% command provides a parameterised version of the leader code, where
% \meta{sep} is the separation between the dots in mu units.
% The symbol used for the `dots' in the leader is given by the value
% of \cs{cftdot}.
% \begin{macrocode}
\providecommand{\cftdot}{.}
\providecommand{\cftdotfill}[1]{%
\leaders\hbox{$\m@th\mkern #1 mu\hbox{\cftdot}\mkern #1 mu$}\hfill}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftdotsep}
% \begin{macro}{\cftnodots}
% \cs{cftdotsep} holds the default dot separation.
% If the kerns in \cs{cftdotfill} are large enough, then no dots will
% be printed. \cs{cftnodots} should be `large enough'.
% \changes{v1.2}{2002/07/07}{Changed \cs{cftnodots} from 10,000 to 2,000 for
% 17pt option and pdflatex}
% \begin{macrocode}
\providecommand{\cftdotsep}{4.5}
\newcommand{\cftnodots}{2000}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Now for the trickier bits regarding the typesetting of the ToC
% entries.
%
% A \file{.toc} (also \file{.lof} and \file{.lot}) file consists
% of a list of \\
% \cs{contentsline}\marg{kind}\marg{title}\marg{page} \\
% commands, where \meta{kind} is the kind of heading (e.g., \texttt{part} or
% \texttt{section} or \texttt{figure}), \meta{title} is the title text
% (including the number),
% and \meta{page} is the page number. The entries are inserted into the
% file by calling the \\
% \cs{addcontentsline}\marg{file}\marg{kind}\marg{title} \\
% command, where \meta{file} is the file extension (e.g., \texttt{toc}, \texttt{lot})
% and the other arguments are the same as for the \cs{contentsline}
% command. (Arbitrary stuff may also be put into the file via the
% \cs{addtocontents}\marg{file}\marg{text} command).
% The typesetting of the \cs{contentsline} entries is performed by
% commands of the form \cs{l@kind}. The sectioning and captioning commands
% call \cs{addcontentsline} to insert their titles into the \file{.toc}
% etc., files.
%
% For the purposes at hand it is generally impossible to treat
% the typesetting
% of a title and its number separately, as both are bundled into the
% \meta{title} argument within \cs{contentsline}. They could be handled
% separately if the \cs{contentsline} command was suitably modified. If
% this was done, then the \cs{addtocontentsline} command would also need
% to be changed which would then require the sectioning and captioning
% commands to be modified as well. This is certainly possible, but would
% cause problems if any other package also modified the sectioning or
% captioning commands, and there are several packages which do this.
%
% I provide modified versions of the \cs{l@kind} commands.
% Essentially, my new definitions
% consist of inlined versions of the code for \cs{@dottedtocline}.
%
%
% \begin{macro}{\cftparfillskip}
% The \cs{l@kind} commands modify (locally) the value of \cs{parfillskip}.
% \cs{cftparfillskip} is a copy of the default \theTeXbook{}
% \cs{parfillskip} definition.
% \begin{macrocode}
\newcommand*{\cftparfillskip}{\parfillskip=0pt plus1fil}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftn@me}
% Lars Madsen suggested that macros like \cs{cftfigurename} be added
% to entries in the LoF, and so on.
% \changes{v1.61803}{2008/01/30}{Added \cs{@cftn@me} (Lars Madsen mempatch v4.5)}
% \begin{macrocode}
\newcommand*{\@cftn@me}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@cft@hb@xt@}
% \begin{macro}{\numberlinebox}
% \begin{macro}{\partnumberlinebox}
% \begin{macro}{\chapternumberlinebox}
% \begin{macro}{\booknumberlinebox}
% \changes{v3.6k}{2012/07/22}{Added four \cs{Xnumberlinebox} macros}
% Each of the four \cs{Xnumberline} macros (part, chapter, book and
% regular) typeset their contents inside a box of a certain width. In
% order to make this a little more flexible we provide a default box
% macro. Note that the box left aligned by default. The default
% \cs{Xnumberlinebox} macros are then let equal to this default.
% \begin{macrocode}
\newcommand\mem@cft@hb@xt@[2]{\hb@xt@#1{#2\hfil}}
\let\numberlinebox\mem@cft@hb@xt@
\let\partnumberlinebox\mem@cft@hb@xt@
\let\chapternumberlinebox\mem@cft@hb@xt@
\let\booknumberlinebox\mem@cft@hb@xt@
% \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\numberline}
% \begin{macro}{\numberlinehook}
% The purpose of the \cs{numberline}\marg{secnum} command is to typeset
% \meta{secnum} left justified in a box of width \cs{@tempdima}. I redefine
% it to add three additional parameters, namely \cs{@cftbsnum},
% \cs{@cftasnum} and \cs{@cftasnumb}
% (see \file{ltsect.dtx} for the original
% definition).
% \changes{v1.61803398d}{2010/02/13}{added \cs{numberlinehook}}
% We also add a hook, that initially does nothing, but
% might be redefined to record say withs of \meta{secnum}s. In order
% to tell the owner of the \cs{numberline}'s apart, check the value of
% \cs{cftwhatismyname}.
% \changes{v3.6k}{2012/07/22}{Factored out the box part into a
% separate macro}
% \begin{macrocode}
\newcommand*\numberlinehook[1]{}
\renewcommand*{\numberline}[1]{%
\numberlinehook{#1}%
%\hb@xt@\@tempdima{\@cftn@me\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}
\numberlinebox\@tempdima{\@cftn@me\@cftbsnum #1\@cftasnum}\@cftasnumb}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@cftbsnum}
% \begin{macro}{\@cftasnum}
% \begin{macro}{\@cftasnumb}
% \begin{macrocode}
\newcommand{\@cftbsnum}{}
\newcommand{\@cftasnum}{}
\newcommand{\@cftasnumb}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\newlistentry}
% \cs{newlistentry}\oarg{within}\marg{counter}\marg{ext}\marg{level-1}
% creates a set of commands for typesetting a new kind of entry in a List of.
% \meta{counter} is the name of the counter for the entry and must be
% the same as the name
% of the entry (e.g., \texttt{subsection}). The optional \meta{within} is the
% name of a counter within which \texttt{counter} is defined. The file extension
% for the List of is \meta{ext} and \meta{level-1} is one less than the
% level of the entry in the List of.
% \changes{v1.61803}{2008/01/30}{Added \cs{cftXname} to \cs{newlistentry}
% (mempatch v4.5)}
% \changes{v1.61803398}{2009/07/17}{Added bidi support to \cs{newlistentry}}
% \begin{macrocode}
\newcommand{\newlistentry}[4][\@empty]{%
% \end{macrocode}
%
% In the following, \texttt{X} is used as the value of \meta{counter} and
% \texttt{Z} as the value of \meta{ext}.
%
% \begin{macro}{\c@X}
% \begin{macro}{\theX}
% Check if \meta{within} and \meta{counter} have been defined. It is
% an error if \meta{within} has not been defined. \meta{counter}
% will be created if it has not been previously defined.
% Set the default counter values.
% \begin{macrocode}
\@ifundefined{c@#2}{% check & set the counter
\ifx \@empty#1\relax
\newcounter{#2}
\else
\newcounter{#2}[#1]%
\expandafter\edef\csname the#2\endcsname{%
\expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}}
\fi}{}
\setcounter{#2}{0}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% That finishes off the error checking. No matter what the result, the
% rest of the new commands are defined.
%
% \begin{macro}{\l@X}
% \cs{l@X}\marg{title}\marg{page} typesets the entry.
% \begin{macrocode}
\@namedef{l@#2}##1##2{%
% \end{macrocode}
% Only typeset if the \cs{Zdepth} is greater than \meta{level-1}.
% \begin{macrocode}
\ifnum \@nameuse{c@#3depth} > #4\relax
% \end{macrocode}
% Add some vertical space.
% \begin{macrocode}
\vskip \@nameuse{cftbefore#2skip}
% \end{macrocode}
% Start a group to keep paragraphing changes local. Set the \cs{leftskip}
% to the entry's indentation.
% \begin{macro}{\cftwhatismyname}
% \changes{v1.61803398d}{2010/02/13}{added \cs{cftwhatismyname}}
% \cs{cftwhatismyname} locally stores the type of toc entry. Useful
% for hooks into general macros like \verb?\numberline?.
% \begin{macrocode}
{%\leftskip \@nameuse{cft#2indent}\relax
\newcommand*\cftwhatismyname{#2}%
\memRTLleftskip \@nameuse{cft#2indent}\relax
% \end{macrocode}
% \end{macro}
% Set the \cs{rightskip} to \cs{@tocrmarg} to leave room for the page number.
% \begin{macrocode}
%%% \rightskip \@tocrmarg
\memRTLrightskip \@tocrmarg
% \end{macrocode}
% Ensure that the last line of an entry will be filled. Setting \cs{parfillskip}
% to a negative value prevents `overfull box' messages.
% \begin{macrocode}
%%% \parfillskip -\rightskip
\parfillskip -\memRTLrightskip
% \end{macrocode}
% Set the paragraph's indentation to the entry's indentation.
% \begin{macrocode}
\parindent \@nameuse{cft#2indent}\relax\@afterindenttrue
% \end{macrocode}
% Try and prevent breaks between lines in a multiline entry.
% \begin{macrocode}
\interlinepenalty\@M
% \end{macrocode}
% Make sure we have left vertical mode.
% \begin{macrocode}
\leavevmode
% \end{macrocode}
% Our version of \cs{numberline} expects that the width of the number box
% is in \cs{@tempdima}, and that the three macros \cs{@cftbsnum},
% \cs{@cftaqsnum}, and \cs{@cftasnumb} are defined. We set all these to
% the values for this entry.
% \changes{v3.6k}{2012/07/30}{Added brace pair around
% \cs{nameuse\{cft#2name\}}, then
% \cs{cftXfont} can end with say \cs{MakeUppercase}}
% \begin{macrocode}
\settowidth{\@tempdima}{\@nameuse{cft#2font}{\@nameuse{cft#2name}}}%
\addtolength{\@tempdima}{\@nameuse{cft#2numwidth}}%
\expandafter\let\expandafter\@cftbsnum\csname cft#2presnum\endcsname
\expandafter\let\expandafter\@cftasnum\csname cft#2aftersnum\endcsname
\expandafter\let\expandafter\@cftasnumb\csname cft#2aftersnumb\endcsname
\expandafter\let\expandafter\@cftn@me\csname cft#2name\endcsname
% \end{macrocode}
% Arrange that the (entry number and) first line of the title is set at
% the current indent, and that any subsequent lines will be further
% indented.
% \begin{macrocode}
%%% \advance\leftskip\@tempdima \null\nobreak\hskip -\leftskip
\advance\memRTLleftskip\@tempdima \null\nobreak\hskip -\memRTLleftskip
% \end{macrocode}
% Print the (number and) title, prohibiting any breaking.
% \changes{v3.6k}{2012/07/29}{Added brace pair around \#\#1, then
% \cs{cftXfont} can end with say \cs{MakeUppercase}}
% \begin{macrocode}
{\@nameuse{cft#2font}{##1}}\nobreak
% \end{macrocode}
% Print the leader and the page number, and then close the group.
% \begin{macrocode}
\@nameuse{cft#2fillnum}{##2}}
\fi
}% end of \l@#2
% \end{macrocode}
% \end{macro}
%
% Now define all the layout commands used by \cs{l@X}. The default
% values of these print the entry in a normal font with a dotted
% line between the title and the page number.
% \begin{macro}{\cftbeforeXskip}
% The skip before the title.
% \begin{macrocode}
\expandafter\newlength\csname cftbefore#2skip\endcsname
\setlength{\@nameuse{cftbefore#2skip}}{\z@ \@plus .2\p@}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\cftXindent}
% \begin{macro}{\cftXnumwidth}
% The indent and width for the number.
% \begin{macrocode}
\expandafter\newlength\csname cft#2indent\endcsname
\expandafter\newlength\csname cft#2numwidth\endcsname
% \end{macrocode}
% Set the default values for the indent and numwidth depending on
% the entry's level. A level of 1 corresponds to a figure entry
% (no indent, and space for a number like N.N).
% \begin{macrocode}
\ifcase #4\relax % 0 (level 1)
\setlength{\@nameuse{cft#2indent}}{0em}
\setlength{\@nameuse{cft#2numwidth}}{2.3em}
\or % 1 (level 2)
\setlength{\@nameuse{cft#2indent}}{2.3em}
\setlength{\@nameuse{cft#2numwidth}}{3.2em}
\or % 2 (level 3)
\setlength{\@nameuse{cft#2indent}}{5.5em}
\setlength{\@nameuse{cft#2numwidth}}{4.1em}
\or % 3 (level 4)
\setlength{\@nameuse{cft#2indent}}{8.5em}
\setlength{\@nameuse{cft#2numwidth}}{5.0em}
\else % anything else
\setlength{\@nameuse{cft#2indent}}{10.5em}
\setlength{\@nameuse{cft#2numwidth}}{6.0em}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\cftXfont}
% \begin{macro}{\cftXname}
% \begin{macro}{\cftXpresnum}
% \begin{macro}{\cftXaftersnum}
% \begin{macro}{\cftXaftersnumb}
% \begin{macro}{\cftXdotsep}
% \begin{macro}{\cftXleader}
% \begin{macro}{\cftXpagefont}
% \begin{macro}{\cftXafterpnum}
% And the remaining commands; the only ones that are not null are for the
% dotsep, the font and the leader
% \begin{macrocode}
\@namedef{cft#2font}{\normalfont}
\@namedef{cft#2name}{}
\@namedef{cft#2presnum}{}
\@namedef{cft#2aftersnum}{}
\@namedef{cft#2aftersnumb}{}
\@namedef{cft#2dotsep}{\cftdotsep}
\@namedef{cft#2leader}{\normalfont\cftdotfill{\@nameuse{cft#2dotsep}}}
\@namedef{cft#2pagefont}{\normalfont}
\@namedef{cft#2afterpnum}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\toclevel@X}
% The hyperref package needs a command \cs{toclevel@X}, holding
% the \meta{level-1} value.
% \begin{macrocode}
\@namedef{toclevel@#2}{#4}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftXformatpnum}
% \begin{macro}{\cftXformatpnumhook}
% \begin{macro}{\cftXfillnum}
% Typeset the leader and page number. We add a hook into the formating
% of the page number. This might later be used to record the widths of
% the numbers used. It will be given the page number as its
% argument. Does nothing by default.
% \changes{v1.61803}{2008/01/30}{Added \cs{cftXformatpnum} (Dan Leucking
% mempatch v4.9)}
% \changes{v1.61803398d}{2010/02/13}{added hook into page number formatter}
% \begin{macrocode}
\@namedef{cft#2formatpnumhook}##1{}
\@namedef{cft#2formatpnum}##1{%
\@nameuse{cft#2formatpnumhook}{##1}%
\hb@xt@\@pnumwidth{\hfil\@nameuse{cft#2pagefont}##1}}
\@namedef{cft#2fillnum}##1{%
{\@nameuse{cft#2leader}}\nobreak
%%% \hb@xt@\@pnumwidth{%
%%% \hfil\@nameuse{cft#2pagefont}##1}
\@nameuse{cft#2formatpnum}{##1}%
\@nameuse{cft#2afterpnum}\par}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% This ends the definition of \cs{newlistentry}.
% \begin{macrocode}
} % end \newlistentry
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\cftsetindents}
% \cs{cftsetindents}\marg{entry}\marg{indent}\marg{numwidth} sets
% the \textit{indent} and \textit{numwidth} for entry \meta{entry}.
% \begin{macrocode}
\newcommand*{\cftsetindents}[3]{%
\setlength{\@nameuse{cft#1indent}}{#2}
\setlength{\@nameuse{cft#1numwidth}}{#3}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbookname}
% If you want a book entry in the ToC like: \\
% BOOK I Title ... \\
% then \verb?\renewcommand*{\cftbookname}{BOOK~}? \\
% \begin{macrocode}
\newcommand*{\cftbookname}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbookbreak}
% \begin{macro}{\l@book}
% \begin{macro}{\booknumberline}
% \begin{macro}{\booknumberlinehook}
% Now for the ToC entry.
% \changes{v1.61803}{2008/01/30}{Added \cs{l@book} and supports (mempatch v4.4)}
% \changes{v1.6180339}{2008/07/23}{Deleted \cs{space} from \cs{booknumberline}
% and \cs{partnumberline}
% (per Lars Henrik Gam Madsen mempatch v5.1)}
% \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{l@book}}
% \changes{v1.61803398d}{2010/02/13}{added hook into the book numberline}
% \changes{v3.6k}{2012/07/22}{Factored the general box out of \cs{booknumberline}}
% \begin{macrocode}
\newcommand*{\cftbookbreak}{\addpenalty{-\@highpenalty}%
\addvspace{\cftbeforebookskip}}
\newcommand*{\l@book}[2]{%
\ifnum\c@tocdepth >-3\relax
\cftbookbreak
\begingroup
{%\leftskip \cftbookindent\relax
\memRTLleftskip \cftbookindent\relax
%%% \rightskip \@tocrmarg
\memRTLrightskip \@tocrmarg
%%% \parfillskip -\rightskip
\parfillskip -\memRTLrightskip
\parindent \cftbookindent\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\settowidth{\@tempdima}{\cftbookfont\cftbookname}%
\addtolength{\@tempdima}{\cftbooknumwidth}%
\let\@cftbsnum \cftbookpresnum
\let\@cftasnum \cftbookaftersnum
\let\@cftasnumb \cftbookaftersnumb
%%% \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
\advance\memRTLleftskip \@tempdima \null\nobreak\hskip -\memRTLleftskip
% \end{macrocode}
% \changes{v3.6k}{2012/07/29}{Added brace pair around \#1, then
% \cs{cftbookfont} can end with say \cs{MakeUppercase}}
% \begin{macrocode}
{\cftbookfont {#1}}%
\cftbookfillnum{#2}}
\nobreak
\global\@nobreaktrue
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
\newcommand*\booknumberlinehook[1]{}
\newcommand{\booknumberline}[1]{%
\booknumberlinehook{#1}%
% \hb@xt@\@tempdima{%
% \cftbookname\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}%%\space}
\booknumberlinebox\@tempdima{%
\cftbookname\@cftbsnum #1\@cftasnum}\@cftasnumb}%%\space}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftbeforebookskip}
% \begin{macro}{\cftbookindent}
% \begin{macro}{\cftbooknumwidth}
% \begin{macro}{\cftbookfont}
% \begin{macro}{\cftbookpresnum}
% \begin{macro}{\cftbookaftersnum}
% \begin{macro}{\cftbookaftersnumb}
% \begin{macro}{\cftbookleader}
% \begin{macro}{\cftbookdotsep}
% \begin{macro}{\cftbookpagefont}
% \begin{macro}{\cftbookafterpnum}
% \begin{macro}{\cftbookfillnum}
% \begin{macro}{\cftbookformatpnum}
% \begin{macro}{\cftbookformatpnumhook}
% \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftbookformatpnum}}
% \begin{macrocode}
\newlength{\cftbeforebookskip}
\setlength{\cftbeforebookskip}{2.25em \@plus\p@}
\newdimen\cftbookindent
\setlength{\cftbookindent}{0em}
\newdimen\cftbooknumwidth
\setlength{\cftbooknumwidth}{1.5em}
\newcommand*{\cftbookfont}{\large\bfseries}
\newcommand*{\cftbookpresnum}{}
\newcommand*{\cftbookaftersnum}{}
\newcommand*{\cftbookaftersnumb}{}
\newcommand*{\cftbookleader}{%
\large\bfseries\cftdotfill{\cftbookdotsep}}
\newcommand*{\cftbookdotsep}{\cftnodots}
\newcommand*{\cftbookpagefont}{\large\bfseries}
\newcommand{\cftbookafterpnum}{}
\newcommand{\cftbookfillnum}[1]{%
{\cftbookleader}%
%%%% {\hb@xt@\@pnumwidth{\hss {\cftbookpagefont #1}}}%
\cftbookformatpnum{#1}%
\cftbookafterpnum\par}
\newcommand{\cftbookformatpnumhook}[1]{}
\newcommand{\cftbookformatpnum}[1]{%
\cftbookformatpnumhook{#1}%
\hb@xt@\@pnumwidth{\hss {\cftbookpagefont #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}
%
%
%
% \begin{macro}{\cftpartname}
% If you want a part entry in the ToC like: \\
% PART I Title ... \\
% then \verb?\renewcommand*{\cftpartname}{PART~}? \\
% \changes{v1.618}{2005/09/03}{Added \cs{cftpartname}, courtesy Danie Els (mempatch v3.12)}
% \begin{macrocode}
\newcommand*{\cftpartname}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftpartbreak}
% \begin{macro}{\l@part}
% Can't use \cs{newlistentry} for \cs{l@part} because of the initial penalty
% and the final \cs{nobreak} code.
% \changes{v1.61803}{2008/01/30}{Added \cs{cftpartbreak}}
% \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{l@part}}
% \begin{macrocode}
\newcommand*{\cftpartbreak}{\addpenalty{-\@highpenalty}%
\addvspace{\cftbeforepartskip}}
\newcommand*{\l@part}[2]{%
\ifnum \c@tocdepth >-2\relax
\cftpartbreak
\begingroup
{%\leftskip \cftpartindent\relax
\memRTLleftskip \cftpartindent\relax
%%% \rightskip \@tocrmarg
\memRTLrightskip \@tocrmarg
%%% \parfillskip -\rightskip
\parfillskip -\memRTLrightskip
\parindent \cftpartindent\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\settowidth{\@tempdima}{\cftpartfont\cftpartname}%
\addtolength{\@tempdima}{\cftpartnumwidth}%
\let\@cftbsnum \cftpartpresnum
\let\@cftasnum \cftpartaftersnum
\let\@cftasnumb \cftpartaftersnumb
%%% \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
\advance\memRTLleftskip \@tempdima \null\nobreak\hskip -\memRTLleftskip
% \end{macrocode}
% \changes{v3.6k}{2012/07/29}{Added brace pair around \#1, then
% \cs{cftpartkfont} can end with say \cs{MakeUppercase}}
% \begin{macrocode}
{\cftpartfont {#1}}%
\cftpartfillnum{#2}}
\nobreak
\global\@nobreaktrue
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\toclevel@part}
% Needed if the \Lpack{hyperref} package is used.
% \changes{v1.61803}{2008/01/30}{Added \cs{toclevel@part} (mempatch v4.9)}
% \changes{v3.7.19}{2022/10/25}{Changing \cs{toclevel@part} definition to
% \cs{def} for better compability with future hyperref}
% \begin{macrocode}
\newcommand*{\toclevel@part}{-1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\partnumberline}
% \begin{macro}{\partnumberlinehook}
% \cs{partnumberline} is a special version of \cs{numberline} output by \cs{part}.
% Its default definition is identical to \cs{numberline}.
% \changes{v1.3}{2002/11/14}{Added \cs{partnumberline}}
% \changes{v1.61803}{2008/01/30}{Added a space after the number in
% \cs{partnumberline} (mempatch v4.4)}
% \changes{v1.61803398d}{2010/02/13}{added hook into part numberline}
% \changes{v3.6k}{2012/07/22}{Factored out the box command}
% \begin{macrocode}
\newcommand*\partnumberlinehook[1]{}
\newcommand{\partnumberline}[1]{%
\partnumberlinehook{#1}%
% \hb@xt@\@tempdima{%
% \cftpartname\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}%%\space}
\partnumberlinebox\@tempdima{%
\cftpartname\@cftbsnum #1\@cftasnum}\@cftasnumb}%%\space}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftbeforepartskip}
% \begin{macro}{\cftpartnumwidth}
% \begin{macro}{\cftpartfont}
% \begin{macro}{\cftpartpresnum}
% \begin{macro}{\cftpartaftersnum}
% \begin{macro}{\cftpartaftersnumb}
% \begin{macro}{\cftpartleader}
% \begin{macro}{\cftpartdotsep}
% \begin{macro}{\cftpartpagefont}
% \begin{macro}{\cftpartafterpnum}
% \begin{macro}{\cftpartindent}
% \begin{macro}{\cftpartformatpnum}
% \begin{macro}{\cftpartformatpnumhook}
% \begin{macro}{\cftpartfillnum}
% These are the user commands to control the typesetting of Part entries.
% They are initialised to give the standard appearance.
% \changes{v1.3}{2002/10/10}{Changed \cs{cftpartnumwidth} to cater for
% use of \cs{numberline} in the ToC}
% \changes{v1.61803}{2008/01/30}{Added \cs{cftpartformatpnum} (mempatch v4.9)}
% \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftpartformatpnum}}
% \begin{macrocode}
\newlength{\cftbeforepartskip}
\setlength{\cftbeforepartskip}{2.25em \@plus\p@}
\newlength{\cftpartindent}
\setlength{\cftpartindent}{0em}
\newlength{\cftpartnumwidth}
\setlength{\cftpartnumwidth}{1.5em}
\newcommand{\cftpartfont}{\large\bfseries}
\newcommand{\cftpartpresnum}{}
\newcommand{\cftpartaftersnum}{}
\newcommand{\cftpartaftersnumb}{}
\newcommand{\cftpartleader}{%
\large\bfseries\cftdotfill{\cftpartdotsep}}
\newcommand{\cftpartdotsep}{\cftnodots}
\newcommand{\cftpartpagefont}{\large\bfseries}
\newcommand{\cftpartafterpnum}{}
\newcommand{\cftpartformatpnumhook}[1]{}
\newcommand*{\cftpartformatpnum}[1]{%
\cftpartformatpnumhook{#1}%
\hb@xt@\@pnumwidth{\hss {\cftpartpagefont #1}}}
\newcommand{\cftpartfillnum}[1]{%
{\cftpartleader}%
{\cftpartformatpnum{#1}}%
\cftpartafterpnum\par}
% \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}
%
%
% \begin{macro}{\cftchaptername}
% If you want a chapter entry in the ToC like: \\
% Chapter 1. A title ... \\
% then \verb?\renewcommand*{\cftchaptername}{\chaptername~}? \\
% \verb?\renewcommand*{\cftchapteraftersnum}{.}? \\
%
% \changes{v1.618}{2005/09/03}{Added \cs{cftchaptername}, courtesy Danie Els (mempatch v3.12)}
% \begin{macrocode}
\newcommand*{\cftchaptername}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@chapapp}
% Generic chapter/appendix ToC entry typesetting.
% \changes{v1.618}{2005/09/03}{Added \cs{l@chapapp}, courtesy Danie Els (mempatch v3.12)}
% \changes{v1.61803398}{2009/07/18}{ADded bidi support to \cs{l@chapapp}}
% \begin{macrocode}
\newcommand*{\l@chapapp}[3]{%
\ifnum \c@tocdepth >\m@ne
\cftchapterbreak
\vskip \cftbeforechapterskip
{%\leftskip \cftchapterindent\relax
\memRTLleftskip \cftchapterindent\relax
%%% \rightskip \@tocrmarg
\memRTLrightskip \@tocrmarg
%%% \parfillskip -\rightskip
\parfillskip -\memRTLrightskip
\parindent \cftchapterindent\relax
\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\let\@cftbsnum \cftchapterpresnum
\let\@cftasnum \cftchapteraftersnum
\let\@cftasnumb \cftchapteraftersnumb
\def\@chapapp@head{#3}%
\settowidth{\@tempdima}{\cftchapterfont\@chapapp@head}%
\addtolength{\@tempdima}{\cftchapternumwidth}%
%%% \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
\advance\memRTLleftskip \@tempdima \null\nobreak\hskip -\memRTLleftskip
% \end{macrocode}
% \changes{v3.6k}{2012/07/29}{Added brace pair around \#1, then
% \cs{cftchapterfont} can end with say \cs{MakeUppercase}}
% \begin{macrocode}
{\cftchapterfont {#1}}\nobreak
\cftchapterfillnum{#2}}
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@chapter}
% \cs{l@chapter}\marg{title}\marg{page} typesets the ToC entry for
% a \texttt{chapter} heading. It is a parameterised copy of the default
% \cs{l@chapter}
% (see \file{classes.dtx} for the original definition). Can't use
% \cs{newlistentry} for this because of the intial penalty.
% \changes{v1.3}{2002/11/14}{Added \cs{cftchapterbreak} to \cs{l@chapter}}
% \changes{v1.618}{2005/09/03}{Defined \cs{l@chapter} in terms of \cs{l@chapapp} (mempatch v3.12)}
% \begin{macrocode}
\newcommand*{\l@chapter}[2]{%
\l@chapapp{#1}{#2}{\cftchaptername}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\toclevel@chapter}
% Needed if the \Lpack{hyperref} package is used.
% \changes{v1.61803}{2008/01/30}{Added \cs{toclevel@chapter} (mempatch v4.9)}
% \changes{v3.7.19}{2022/10/25}{Changing \cs{toclevel@chapter} definitions to
% \cs{def} for better compability with future hyperref}
% \begin{macrocode}
\def\toclevel@chapter{0}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftappendixname}
% If you want a appendixed chapter entry in the ToC like: \\
% Appendix A A title ... \\
% then \verb?\renewcommand*{\cftappendixname}{\appendixname~}? \\
%
% \changes{v1.618}{2005/09/03}{Added \cs{cftappendixname}, courtesy Danie Els (mempatch v3.12)}
% \begin{macrocode}
\newcommand*{\cftappendixname}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@appendix}
% \begin{macro}{\toclevel@appendix}
% Similar to \cs{l@chapter} but for an appendix.
% \changes{v1.618}{2005/09/03}{Added \cs{l@apendix} (mempatch v3.12)}
% \changes{v3.7.19}{2022/10/25}{Changing \cs{toclevel@appendix} definitions to
% \cs{def} for better compability with future hyperref}
% \begin{macrocode}
\newcommand*{\l@appendix}[2]{%
\l@chapapp{#1}{#2}{\cftappendixname}}
\def\toclevel@appendix{0}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\chapternumberline}
% \begin{macro}{\chapternumberlinehook}
% \cs{chapternumberline} is a special version of \cs{numberline} output by
% \cs{chapter}.
% It's default definition is identical to \cs{numberline}.
% \changes{v1.3}{2002/11/14}{Added \cs{chapternumberline}}
% \changes{v1.618}{2005/09/03}{Added \cs{@chapapp@head} to \cs{chapternumberline} (mempatch v3.12)}
% \changes{v1.61803398d}{2010/02/13}{added hook into chapter numberline}
% changes{v3.6k}{2012/07/22}{Factored out the box command}
% \begin{macrocode}
\newcommand*\chapternumberlinehook[1]{}
\newcommand{\chapternumberline}[1]{%
\chapternumberlinehook{#1}%
% \hb@xt@\@tempdima{\@chapapp@head\@cftbsnum #1\@cftasnum\hfil}%
% \@cftasnumb}
\chapternumberlinebox\@tempdima{\@chapapp@head\@cftbsnum #1\@cftasnum}%
\@cftasnumb}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftbeforechapterskip}
% \begin{macro}{\cftchapterindent}
% \begin{macro}{\cftchapternumwidth}
% \begin{macro}{\cftchapterfont}
% \begin{macro}{\cftchapterpresnum}
% \begin{macro}{\cftchapteraftersnum}
% \begin{macro}{\cftchapteraftersnumb}
% \begin{macro}{\cftchapterleader}
% \begin{macro}{\cftchapterdotsep}
% \begin{macro}{\cftchapterpagefont}
% \begin{macro}{\cftchapterafterpnum}
% \begin{macro}{\cftchapterformatpnum}
% \begin{macro}{\cftchapterformatpnumhook}
% \begin{macro}{\cftchapterfillnum}
% These are the user commands to control the typesetting of Chapter entries.
% They are initialised to give the standard appearance.
% \changes{v1.61803}{2008/01/30}{Added \cs{cftchapterformatpnum} (mempatch v4.9)}
% \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftchapterformatpnum}}
% \begin{macrocode}
\newlength{\cftbeforechapterskip}
\setlength{\cftbeforechapterskip}{1.0em \@plus\p@}
\newlength{\cftchapterindent}
\setlength{\cftchapterindent}{0em}
\newlength{\cftchapternumwidth}
\setlength{\cftchapternumwidth}{1.5em}
\newcommand{\cftchapterfont}{\bfseries}
\newcommand{\cftchapterpresnum}{}
\newcommand{\cftchapteraftersnum}{}
\newcommand{\cftchapteraftersnumb}{}
\newcommand{\cftchapterleader}{%
\bfseries\cftdotfill{\cftchapterdotsep}}
\newcommand{\cftchapterdotsep}{\cftnodots}
\newcommand{\cftchapterpagefont}{\bfseries}
\newcommand{\cftchapterafterpnum}{}
\newcommand{\cftchapterformatpnumhook}[1]{}
\newcommand*{\cftchapterformatpnum}[1]{%
\cftchapterformatpnumhook{#1}%
\hb@xt@\@pnumwidth{\hfil\cftchapterpagefont #1}}
\newcommand*{\cftchapterfillnum}[1]{%
{\cftchapterleader}\nobreak
\cftchapterformatpnum{#1}%
\cftchapterafterpnum\par}
% \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}
%
% \begin{macro}{\cftchapterbreak}
% Another parameter for \cs{l@chapter}.
% \changes{v1.3}{2002/11/14}{Added \cs{cftchapterbreak}}
% \begin{macrocode}
\newcommand{\cftchapterbreak}{\addpenalty{-\@highpenalty}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@section}
% \begin{macro}{\l@subsection}
% \begin{macro}{\l@subsubsection}
% \begin{macro}{\l@paragraph}
% \begin{macro}{\l@subparagraph}
% \cs{l@section}\marg{title}\marg{page} typesets the ToC entry for
% a \cs{section} heading. Similarly \cs{l@subsection} and \cs{l@subsubsection}
% for \cs{subsection} and \cs{subsubsection} entries, and so on.
% \changes{v1.4}{2003/11/22}{Used \cs{newlistentry} for pararaph and
% subparagraph (from patch v1.7)}
% \changes{v1.618}{2005/09/02}{Corrected (sub)paragraph ToC indents (mempatch v2.3)}
% \begin{macrocode}
\newlistentry[chapter]{section}{toc}{0}
\cftsetindents{section}{1.5em}{2.3em}
\newlistentry[section]{subsection}{toc}{1}
\cftsetindents{subsection}{3.8em}{3.2em}
\newlistentry[subsection]{subsubsection}{toc}{2}
\cftsetindents{subsubsection}{7.0em}{4.1em}
\newlistentry[subsubsection]{paragraph}{toc}{3}
\cftsetindents{paragraph}{10.0em}{5.0em}
\newlistentry[paragraph]{subparagraph}{toc}{4}
\cftsetindents{subparagraph}{12.0em}{6.0em}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% The typesetting for Figures and Tables is defined later.
%
%
%
% \subsection{Support for the \Lpack{subfigure} package}
%
% The code for supporting the \Lpack{subfigure} package is, in all
% essentials, the same as that for the figure and table captions; only the
% names are changed. However, the code need only be executed if the
% \Lpack{subfigure} package is actually loaded.
%
% \begin{macro}{\@cftl@subfigtab}
% This command redefines the \cs{l@subfigure} and \cs{l@subtable} commands.
% \changes{v1.61803}{2008/01/30}{Made \cs{@cftl@subfigtab} a no-op (mempatch v4.6)}
% \begin{macrocode}
\newcommand*{\@cftl@subfigtab}{
% \end{macrocode}
% \begin{macro}{\l@subfigure}
% \begin{macro}{\l@subtable}
% \cs{l@subfigure}\marg{title}\marg{page} typesets the LoF entry for
% a subfigure caption heading, and \cs{l@subtable} does the same for subtables.
% \begin{macrocode}
\newlistentry[figure]{subfigure}{lof}{1}
\cftsetindents{subfigure}{2.3em}{2.5em}
\newlistentry[table]{subtable}{lot}{1}
\cftsetindents{subtable}{2.3em}{2.5em}}
\renewcommand*{\@cftl@subfigtab}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% Call the \Lpack{subfigure} package setup code only if the
% \Lopt{subfigure} package has been used.
% \begin{macrocode}
\AtBeginDocument{\@ifpackageloaded{subfigure}{\@cftl@subfigtab}{}}
% \end{macrocode}
%
%
% \subsection{Switching page numbering}
%
% It can, at times, be useful to be able to have ToC entries that have
% no printed page numbers.
%
% \begin{macro}{\cftpagenumbersoff}
% The user level command for switching off page numbers is
% \cs{cftpagenumbersoff}\marg{entry} where \meta{entry} is the
% name of the entry.
% The macro redefines the \cs{cftXfillnum} command so that there is no leader
% and the page number is ignored.
% \begin{macrocode}
\DeclareRobustCommand{\cftpagenumbersoff}[1]{%
\@namedef{cft#1fillnum}##1{%
\cftparfillskip\@nameuse{cft#1afterpnum}\par}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftpagenumberson}
% \cs{cftpagenumberson}\marg{entry} is the user level command for
% reversing the corresponding \cs{cftpagenumbersoff}.
% The macro defines the \cs{cftXfillnum} command to correspond to
% the default definition.
% \changes{v1.61803}{2008/01/30}{Modified \cs{cftpagenumberson} to use \cs{cftXformatpnum}
% (mempatch v4.9)}
% \begin{macrocode}
\DeclareRobustCommand{\cftpagenumberson}[1]{%
\@namedef{cft#1fillnum}##1{%
\@nameuse{cft#1leader}\nobreak
\@nameuse{cft#1formatpnum}{##1}%
\@nameuse{cft#1afterpnum}\par}}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Chapter precis}
%
% \begin{macro}{\chapterprecis}
% The command \cs{chapterprecis}\marg{text} typesets
% \meta{text} at the point where it is called, and also adds \meta{text}
% to the \file{.toc} file. It is expects to be called immediately after
% a \cs{chapter} command.
% \begin{macrocode}
\newcommand{\chapterprecis}[1]{%
\chapterprecishere{#1}
\chapterprecistoc{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chapterprecishere}
% \cs{chapterprecishere}\marg{text} typesets \meta{text}. It expects
% to be called immediately after a \cs{chapter} command.
% \changes{v1.3}{2002/11/14}{Parameterised \cs{chapterprecishere}}
% \begin{macrocode}
\newcommand{\chapterprecishere}[1]{%
\prechapterprecis #1\postchapterprecis}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\prechapterprecis}
% \begin{macro}{\prechapterprecisshift}
% \begin{macro}{\precisfont}
% \begin{macro}{\postchapterprecis}
% The \cs{pre...} and \cs{post...} macros put code before and after
% \cs{chapterprecishere} text. By
% default \cs{prechapterprecis} adds some (negative) space (defined by
% \cs{prechapterprecisshift} whose value depends on whether or not the
% \Lopt{article} option is used, as discovered by Lars Madsen) and starts a
% quote environment using the \cs{precisfont}. \cs{postchapterprecis} ends
% the quote environment.
% \changes{v1.3}{2002/11/14}{Added \cs{prechapterprecis} and
% \cs{postchapterprecis}}
% \changes{v1.61803}{2008/01/30}{Added \cs{prechapterprecisshift} and
% \cs{precisfont} (mempatch v4.9)}
% \begin{macrocode}
\newdimen\prechapterprecisshift
\ifartopt
\prechapterprecisshift=0pt
\else
\prechapterprecisshift=-2\baselineskip
\fi
\newcommand*{\precisfont}{\normalfont\itshape}
\newcommand{\prechapterprecis}{%
\vspace*{\prechapterprecisshift}%
\begin{quote}\precisfont}
% \end{macrocode}
% \changes{v3.6k}{2013/04/24}{We are missing the after heading
% stuff. Otherwise text will indent after \cs{chapterprecis}}
% \begin{macrocode}
\newcommand*{\postchapterprecis}{%
\end{quote}%
\par\m@mindentafterchapter%
\@afterheading}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\precistocfont}
% Font for typesetting chapter precis in the ToC.
% \changes{v1.3}{2002/11/14}{Added \cs{precistocfont}}
% \begin{macrocode}
\newcommand{\precistocfont}{\normalfont\itshape}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\precistocformat}
% Macro for adding extra formatting to the precis toc text, formatting
% that has nothiing to do with font. The default is \cs{noindent}.
% \changes{v3.6d}{2010/06/09}{Added \cs{precistocformat}}
% \begin{macrocode}
\newcommand{\precistocformat}{\noindent}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chapterprecistoc}
% \begin{macro}{\precistoctext}
% \cs{chapterprecistoc}\marg{text} effectively adds \meta{text} to
% the \file{.toc}
% file. The \meta{text} will be typeset within the same margins as the
% the title text of a \cs{chapter} heading, using the \cs{precistocfont} font.
% \changes{v1.3}{2002/11/14}{Added \cs{precistoctext}}
% \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{precistoctext}}
% \begin{macrocode}
\newcommand{\chapterprecistoc}[1]{%
\addtocontents{toc}{\precistoctext{#1}}}
\DeclareRobustCommand{\precistoctext}[1]{%
% \end{macrocode}
% Start a group to localize changes to the paragraphing. Set the
% left margin to the chapter indent plus the chapter number width.
% \changes{v1.6180339c}{2009/01/20}{Added a \cs{nopagebreak}, though
% this only disencourage a page break}
% \begin{macrocode}
{%\nopagebreak\leftskip \cftchapterindent\relax
\nopagebreak\memRTLleftskip \cftchapterindent\relax
%%% \advance\leftskip \cftchapternumwidth\relax
\advance\memRTLleftskip \cftchapternumwidth\relax
% \end{macrocode}
% Set the right hand margin to \cs{@tocrmarg}.
% \begin{macrocode}
%%% \rightskip \@tocrmarg\relax
\memRTLrightskip \@tocrmarg\relax
% \end{macrocode}
% Typeset \meta{text} using an italic font, then ensure that the paragraph
% is finished (to use the local skips). Finally close the group and we
% are done.
% \changes{v3.6d}{2010/06/09}{Added \cs{precistocformat}}
% \begin{macrocode}
\precistocformat\precistocfont #1\par}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Adding things to the ToC}
%
% \begin{macro}{\cftlocalchange}
% \cs{cftmakelocalchange}\marg{file}\marg{pnumwidth}\marg{tocrmarg}
% makes an entry into \meta{file} to change the \cs{@pnumwidth} and
% the \cs{@tocrmarg} values.
% \begin{macrocode}
\newcommand{\cftlocalchange}[3]{%
\addtocontents{#1}{\protect\setpnumwidth{#2} \protect\setrmarg{#3}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftaddtitleline}
% \cs{cftaddtitleline}\marg{file}\marg{kind}\marg{title}\marg{page}
% adds a \cs{contentsline} entry to \meta{file} with the given information.
% \begin{macrocode}
\newcommand{\cftaddtitleline}[4]{%
\addtocontents{#1}{\protect\contentsline{#2}{#3}{#4}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftaddnumtitleline}
% \cs{cftaddnumtitleline}\marg{file}\marg{kind}\marg{num}\marg{title}\marg{page}
% adds a \cs{contentsline} entry to \meta{file} with the given information.
% \begin{macrocode}
\newcommand{\cftaddnumtitleline}[5]{%
\addtocontents{#1}%
{\protect\contentsline{#2}{\protect\numberline{#3}%
{\protect\ignorespaces #4}}{#5}}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\cftinsertcode}
% \begin{macro}{\cftinserthook}
% \begin{macro}{\cftinsert}
% This is a generalisation of a suggestion by Lars Madsen (private email,
% 2007/12/14).
%
% \cs{cftinsertcode}\marg{id}\marg{code} creates a hook to be executed in
% a `List of'. Since we use \cs{@nameuse} it does not matter if the hook
% does not exist
%
% \cs{cftinserthook}\marg{list}\marg{id} inserts the hook \meta{id} into the
% \meta{list} `List of' file (in the form of \cs{cftinsert}\marg{id}).
%
% Use like this:
% \begin{verbatim}
% \cftinsertcode{A}{%
% \renewcommand*{\cftchapterfont}{\normalfont\scshape}
% ...
% }
% \cftinsertcode{F}{...}
% \cftinsertcode{G}{...}
% ...
% \frontmatter
% \tableofcontents
% \cftinserthook{lof}{G}
% \listoffigures
% \chapter{...}
% ...
% \mainmatter
% \cftinserthook{lof}{F}
% \cftinserthook{toc}{A}
% \chapter{...}
% ...
% \end{verbatim}
%
% \changes{v1.61803}{2008/01/30}{Added \cs{cftinsert} and friends (mempatch v4.9)}
% \begin{macrocode}
\newcommand*{\cftinsert}[1]{\@nameuse{cftinsert#1}}
\newcommand{\cftinsertcode}[2]{\@namedef{cftinsert#1}{#2}}
\newcommand*{\cftinserthook}[2]{%
\addtocontents{#1}{\protect\cftinsert\protect{#2\protect}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{ToC and divisional numbering}
%
% Commands are provided, based on the \Lpack{tocvsec2} package, for changing
% the section numbering level and the ToC entry level.
%
% \begin{macro}{\@setclcnt}
% Helper macro to set a sectioning-related counter. Use as
% \cs{@setclcnt}\marg{sec}\marg{counter} to set \Lcount{counter}
% to the level of \meta{sec}.
% \changes{v1.61803}{2008/01/30}{Added book to \cs{@setclcnt} and friends
% (mempatch v4.4)}
% \changes{v1.61803398}{2009/07/29}{PW: Replaced \cs{if@tempswa} with
% \cs{@setclcntok} in \cs{@setclcnt} to avoid bad clashes with other uses}
% \begin{macrocode}
\newcommand*{\@setclcnt}[2]{%
\def\@setclcntok{0}% = false
\nametest{#1}{none}%
\ifsamename
\setcounter{#2}{-10}%
\def\@setclcntok{1}% = true
\fi
\nametest{#1}{book}%
\ifsamename
\setcounter{#2}{-2}%
\def\@setclcntok{1}%
\fi
\nametest{#1}{part}%
\ifsamename
\setcounter{#2}{-1}%
\def\@setclcntok{1}%
\fi
\nametest{#1}{chapter}%
\ifsamename
\setcounter{#2}{0}%
\def\@setclcntok{1}%
\fi
\nametest{#1}{section}%
\ifsamename
\setcounter{#2}{1}%
\def\@setclcntok{1}%
\fi
\nametest{#1}{subsection}%
\ifsamename
\setcounter{#2}{2}%
\def\@setclcntok{1}%
\fi
\nametest{#1}{subsubsection}%
\ifsamename
\setcounter{#2}{3}%
\def\@setclcntok{1}%
\fi
\nametest{#1}{paragraph}%
\ifsamename
\setcounter{#2}{4}%
\def\@setclcntok{1}%
\fi
\nametest{#1}{subparagraph}%
\ifsamename
\setcounter{#2}{5}%
\def\@setclcntok{1}%
\fi
\nametest{#1}{all}%
\ifsamename
\setcounter{#2}{50}%
\def\@setclcntok{1}%
\fi
%% \if@tempswa\else
\ifnum \@setclcntok = 0\relax
\@memerror{%
Unknown document division name (#1)
}{%
I'll ignore it.
Type \space <return> and I'll continue.\MessageBreak
If you haven't mistyped the name then use
\protect\setcounter\space instead.}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\settocdepth}
% \cs{settocdepth}\marg{sec} is the user command for setting
% \Lcount{tocdepth} in the \file{.toc} file to the value corresponding to
% \meta{sec}.
% \changes{v1.3}{2002/11/14}{Changed \cs{settocdepth} to use \cs{changetocdepth}}
% \changes{v1.61803}{2008/01/30}{Added book to ToC depth setting (mempatch v4.4)}.
% \changes{v1.61803398}{2009/07/29}{PW: Replaced \cs{if@tempswa} with
% \cs{@chtocdok} in \cs{settocdepth} to avoid bad clashes with other uses}
% \begin{macrocode}
\newcommand*{\settocdepth}[1]{%
\def\@chtodok{0}% false
\nametest{#1}{none}%
\ifsamename
\addtocontents{toc}{\changetocdepth{-10}}%
\def\@chtodok{1}% true
\fi
\nametest{#1}{book}%
\ifsamename
\addtocontents{toc}{\changetocdepth{-2}}%
\def\@chtodok{1}%
\fi
\nametest{#1}{part}%
\ifsamename
\addtocontents{toc}{\changetocdepth{-1}}%
\def\@chtocdok{1}%
\fi
\nametest{#1}{chapter}%
\ifsamename
\addtocontents{toc}{\changetocdepth{0}}%
\def\@chtocdok{1}%
\fi
\nametest{#1}{section}%
\ifsamename
\addtocontents{toc}{\changetocdepth{1}}%
\def\@chtocdok{1}%
\fi
\nametest{#1}{subsection}%
\ifsamename
\addtocontents{toc}{\changetocdepth{2}}%
\def\@chtocdok{1}%
\fi
\nametest{#1}{subsubsection}%
\ifsamename
\addtocontents{toc}{\changetocdepth{3}}%
\def\@chtocdok{1}%
\fi
\nametest{#1}{paragraph}%
\ifsamename
\addtocontents{toc}{\changetocdepth{4}}%
\def\@chtocdok{1}%
\fi
\nametest{#1}{subparagraph}%
\ifsamename
\addtocontents{toc}{\changetocdepth{5}}%
\def\@chtocdok{1}%
\fi
\nametest{#1}{all}%
\ifsamename
\addtocontents{toc}{\changetocdepth{50}}%
\def\@chtocdok{1}%
\fi
% \if@tempswa
\ifnum\@chtocdok=1\relax
% \end{macrocode}
% The next bit is from Heiko Oberdiek (CTT {\itshape Re: Memoir, \verb?\settocdepth?
% and pdflatex \verb?=>? problem with PDF bookmarks}, 2006/07/21) as
% \Lpack{hyperref} needs \verb?\tocdepth? set in the body not just in the ToC.
% \begin{macrocode}
\@ifundefined{toclevel@#1}{%
\@memwarn{Unknown toclevel for #1}%
}{%
\setcounter{tocdepth}{\@nameuse{toclevel@#1}}%
}
\else
\@memerror{%
Unknown document division name (#1)
}{%
I'll ignore it.
Type \space <return> and I'll continue.}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\toclevel@none}
% \begin{macro}{\toclevel@all}
% Couple of extras for hypperef to cater for \texttt{all} and \texttt{none}
% as `division levels'.
% \changes{v1.61803}{2008/01/30}{Added \cs{toclevel@none} and \cs{toclevel@all}
% (mempatch v4.4)}
% \changes{v3.7.19}{2022/10/25}{Changing \cs{toclevel@...} definitions to
% \cs{def} for better compability with future hyperref}
% \begin{macrocode}
\def\toclevel@none{-10}
\def\toclevel@all{50}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\changetocdepth}
% Changes the \texttt{tocdepth} counter. Make it robust as it will be written
% to the *.toc file.
% \changes{v1.3}{2002/11/14}{Added \cs{changetocdepth}}
% \begin{macrocode}
\DeclareRobustCommand{\changetocdepth}[1]{\setcounter{tocdepth}{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\maxtocdepth}
% \cs{maxtocdepth}\marg{sec} can be used to initialise \Lcount{tocdepth}
% to the value corresponding to \meta{sec}. This can only be used
% between the end of the preamble and the \cs{tableofcontents} command.
% \begin{macrocode}
\newcommand{\maxtocdepth}[1]{%
\@setclcnt{#1}{tocdepth}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\maxsecnumdepth}
% \cs{maxsecnumdepth}\marg{sec} can be used to initialise
% \Lcount{secnumdepth}
% to the value corresponding to \meta{sec}.
% \changes{v1.1}{2002/03/10}{Added maxsecnumdepth counter and modified \cs{maxsecnumdepth}}
% \begin{macrocode}
\newcounter{maxsecnumdepth}
\newcommand{\maxsecnumdepth}[1]{%
\@setclcnt{#1}{secnumdepth}\@setclcnt{#1}{maxsecnumdepth}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setsecnumdepth}
% \cs{setsecnumdepth}\marg{sec} is the user command for setting
% \Lcount{secnumdepth} to the value for \meta{sec}. In the preamble it sets
% both the \Lcount{secnumdepth} and \Lcount{maxsecnumdepth} to \meta{sec}
% while in the body it only sets \Lcount{secnumdepth}.
% \changes{v1.61803}{2008/01/30}{Extended \cs{setsecnumdepth} to make it more
% intuitive (mempatch v4.9)}
% \begin{macrocode}
\newcommand{\setsecnumdepth}[1]{%
\ifx\@nodocument\relax% after the preamble
\@setclcnt{#1}{secnumdepth}%
\else
\@setclcnt{#1}{secnumdepth}%
\@setclcnt{#1}{maxsecnumdepth}%
\fi}
\setsecnumdepth{section}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \section{Bibliography}
%
%
% \begin{macro}{\bibindent}
% The \Lopt{open} bibliography uses an indentation of \cs{bibindent}.
% \begin{macrocode}
\newdimen\bibindent
\setlength\bibindent{1.5em}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bibitemsep}
% The vertical separation between items in the bibliography list.
% \changes{v1.4}{2003/11/22}{Added \cs{bibitemsep} (from patch v1.7)}
% \begin{macrocode}
\newlength{\bibitemsep}
\setlength{\bibitemsep}{\itemsep}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\biblistextra}
% A hook into the \texttt{bibitemlist}.
% \changes{v1.4}{2003/11/22}{Added \cs{biblistextra} (from patch v1.7)}
% \begin{macrocode}
\newcommand{\biblistextra}{\itemsep=\bibitemsep}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{bibitemlist}
% The \texttt{thebibliography} environment starts a new document division.
% Internally it tweaks some typesetting aspects; principally it
% uses \cs{sloppy} because good linebreaking is hard in a bibliography,
% and \verb?\sfcode`\.=1000\relax? causes a full stop not to produce an
% end-of-sentence space. The implementation of the environment is
% based on the generic \texttt{list} environment, and uses the \cs{c@enumiv}
% count for the labels. The following code is extracted from the
% \Lpack{book} class, plus some additions.
% \changes{v1.4}{2003/11/22}{Added \cs{biblistextra} to bibitemlist (from patch v1.7)}
% \begin{macrocode}
\newenvironment{bibitemlist}[1]{%
\typeout{bibitemlist}
\list{\@biblabel{\@arabic\c@enumiv}}%
{\settowidth\labelwidth{\@biblabel{#1}}%
\leftmargin\labelwidth
\advance\leftmargin\labelsep
\@openbib@code
\usecounter{enumiv}%
\let\p@enumiv\@empty
\renewcommand\theenumiv{\@arabic\c@enumiv}%
\biblistextra}%
\sloppy
\clubpenalty4000
\@clubpenalty \clubpenalty
\widowpenalty4000%
\sfcode`\.\@m}%
{\def\@noitemerr
{\@latex@warning{Empty `thebibliography' environment}}%
\endlist}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\newblock}
% The default is for \cs{newblock} to provide a small space.
% \begin{macrocode}
\newcommand{\newblock}{\hskip .11em\@plus.33em\@minus.07em}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@openbib@code}
% This a an empty hook. It will be modified if the \Lopt{openbib}
% option is used.
% \begin{macrocode}
\let\@openbib@code\@empty
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setbiblabel}
% \begin{macro}{\@biblabel}
% This is the user command for setting the label for a \cs{bibitem}.
% The following sets the default definition.
% \begin{macrocode}
\newcommand*{\setbiblabel}[1]{%
\renewcommand*{\@biblabel}[1]{#1}}
\setbiblabel{[#1]\hfill}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@memb@bchap}
% \begin{macro}{\@memb@bsec}
% In a \ctt{} thread \textit{memoir, natbib, and chapterbib} in January 2003
% there was a discussion on how to get all three to work together.
% Donald Arseneau suggested that \cs{bibsection} be used as a `standard'
% way of controlling the sectioning command of a bibliography. Here is
% an implementation of that idea.
%
% \cs{@memb@bchap} is a copy of memoir's original code for the start
% of the \texttt{thebibliography} environment which used a \cs{chapter*}
% title. \cs{@memb@bsec} is the much simpler version for a \cs{section} title.
% \changes{v1.4}{2003/02/27}{Added support code for implementing \cs{bibsection}
% (patch 1.3)}
% \changes{v3.7g}{2018/02/28}{Removeded \cs{phantomsection} before
% \cs{addcontentsline} as it is no longer needed, and causes the
% hyperlink target to the bibligraphy to be below the title, reported
% via \texttt{https://tex.stackexchange.com/a/396303/3929}}
% \begin{macrocode}
\newcommand{\@memb@bchap}{%
\chapter*{\bibname}%
\bibmark
\ifnobibintoc\else
% \phantomsection
\addcontentsline{toc}{chapter}{\bibname}%
\fi
\prebibhook}
\newcommand{\@memb@bsec}{\section{\bibname}\prebibhook}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibsection}
% Normally treat the bibliography heading as a chapter.
% \changes{v1.4}{2003/02/27}{Added \cs{bibsection} to replace memoir's
% original code for the bibliography (patch 1.3)}
% \begin{macrocode}
\newcommand{\bibsection}{\@memb@bchap}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{thebibliography}
% The definition of the \texttt{thebibliography} environment in this class is not
% quite the same as in the standard classes!
%
% \changes{v0.2}{2001/06/03}{Deleted starred version of thebibliography}
% \changes{v1.4}{2003/02/27}{Replaced initial code in the bibliography
% environment by \cs{bibsection} (patch 1.3)}
% \begin{macrocode}
\newenvironment{thebibliography}[1]{%
\bibsection
\begin{bibitemlist}{#1}}{\end{bibitemlist}\postbibhook}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\ifnobibintoc}
% \begin{macro}{\bibintoc}
% \begin{macro}{\nobibintoc}
% Flag to control whether or not to add the bibliography title to the ToC,
% and declarations to set the flag.
% Default is to put the title into the ToC.
% \changes{v0.2}{2001/06/03}{Added \cs{ifnobibintoc}, etc.}
% \begin{macrocode}
\newif\ifnobibintoc
\newcommand*{\bibintoc}{\nobibintocfalse}
\newcommand*{\nobibintoc}{\nobibintoctrue}
\bibintoc
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\prebibhook}
% \begin{macro}{\postbibhook}
% These two macros are called just before starting the bib items and just
% after finishing them. By default they do nothing but can be changed
% by the user to give, say, some introductory information.
% \begin{macrocode}
\newcommand{\prebibhook}{}
\newcommand{\postbibhook}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@cite}
% The output of the \cs{cite} command is produced by this macro. The default
% is used. The \Lpack{cite} package is a good way of changing this.
% \begin{macrocode}
% \renewcommand*{\@cite}[1]{[#1]}
% \end{macrocode}
% \end{macro}
%
% \subsection{Use with the \Lpack{natbib} and \Lpack{chapterbib} packages}
%
% The \Lpack{natbib} package~\cite{NATBIB} uses its own definition for
% the \texttt{thebibliography} environment, which knows nothing about adding
% the Bibliography to the ToC. The following makes appropriate changes
% to \Lpack{natbib} code to support the class.
%
% The \Lpack{chapterbib} package by Donald Arseneau also may make changes
% to the \texttt{thebibliography} environment --- perhaps memoir's version
% or natbib's version.
%
% As packages get loaded after classes, I have to try and patch any
% non-memoir modifications at begin document time.
% The fixes have to be firstly for \Lpack{natbib}
% and only after those can \Lpack{chapterbib} be considered.
%
% \changes{v1.1}{2002/03/10}{Added internal support for the natbib package}
% \changes{v1.4}{2003/02/27}{Changed code supporting natbib (patch 1.3)}
% \changes{v1.4}{2003/02/27}{Added code supporting chapterbib (patch 1.3)}
% \begin{macro}{\bibsection}
% \begin{macro}{\endthebibliography}
% Natbib provides \cs{bibsection} for titling the bibliography. I also have
% to extend the end of the \texttt{thebibliography} environment to cater for
% \cs{postbibhook}.
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{natbib}{% natbib is loaded
% \end{macrocode}
% As \Lpack{natbib} is used, change \cs{endthebibliography} to the class
% definition.
% \begin{macrocode}
\addtodef{\endthebibliography}{}{\vskip-\lastskip\postbibhook}
\@ifpackagewith{natbib}{sectionbib}{% with sectionbib option
% \end{macrocode}
% \Lpack{natbib}'s \Lopt{sectionbib} option is used,
% \begin{macrocode}
\renewcommand{\bibsection}{\@memb@bsec}}%
% \end{macrocode}
% The \Lopt{sectionbib} option is not used, so we have a chapter title.
% \begin{macrocode}
{\renewcommand{\bibsection}{\@memb@bchap}}}%
% \end{macrocode}
% Finished with any \Lpack{natbib} related changes.
% \begin{macrocode}
{}
% \end{macrocode}
%
% Now deal with \Lpack{chapterbib} if necessary.
% \begin{macrocode}
\@ifpackagewith{chapterbib}{sectionbib}{%
% \end{macrocode}
% \Lpack{chapterbib} is used with its \Lopt{sectionbib} option. This is the
% only case to worry about. Kill \Lpack{chapterbib}'s \cs{sectionbib} macro
% which it calls at begin document to do its patch, then make sure
% the class definition is used.
% \begin{macrocode}
\renewcommand{\sectionbib}[2]{}
\renewcommand{\bibsection}{\@memb@bsec}}{}
% \end{macrocode}
% And we've finished with this bunch of \cs{AtBeginDocument} code.
% \begin{macrocode}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \section{The index}
%
% I allow for a single column index as well as the default double column.
%
% \begin{macro}{\ifonecolindex}
% TRUE for a one column index.
% \changes{v1.3}{2002/10/10}{Added one column index}
% \begin{macrocode}
\newif\ifonecolindex
\onecolindexfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\onecolindex}
% \begin{macro}{\twocolindex}
% \changes{v1.61803}{2008/01/30}{Added \cs{onecolindex} and \cs{twocolindex}}
% \begin{macrocode}
\newcommand*{\onecolindex}{\onecolindextrue}
\newcommand*{\twocolindex}{\onecolindexfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{environment}{theindex}
% The environment \texttt{theindex} can be used for indices. It makes an
% index with two columns, with each entry a separate paragraph. At
% the user level the commands \cs{item}, \cs{subitem} and \cs{subsubitem}
% are used to produce index entries of various levels. When a new
% letter of the alphabet is encountered an amount of \cs{indexspace}
% white space can be added.
%
%
% \changes{v0.2}{2001/06/03}{Deleted starred version of theindex}
% \changes{v0.2}{2001/06/03}{Changed Index pagestyle to chapter}
% \changes{v1.618}{2005/09/03}{Make \cs{indexcolsep} work, courtesy of hazydirk (mempatch v3.11)}
% \changes{v1.61803}{2008/01/30}{Added \cs{clearforchapter} to theindex
% environment (Erik Quaeghebeur, mempatch v4.4)}
% \changes{v1.61803}{2008/01/30}{Added an indextitlepagestyle (Lars Madsen
% mempatch v4.6)}
% \begin{macrocode}
\newenvironment{theindex}{%
\clearforchapter
\if@twocolumn
\@restonecolfalse
\else
\@restonecoltrue
\fi
\ifonecolindex
\onecolumn
\chapter*{\indexname}
\preindexhook
\else
\setlength{\columnseprule}{\indexrule}%
\setlength{\columnsep}{\indexcolsep}%
\twocolumn[\@makeschapterhead{\indexname}
\preindexhook]%
\fi
\indexmark
\ifnoindexintoc\else
\phantomsection
\addcontentsline{toc}{chapter}{\indexname}%
\fi
\thispagestyle{indextitlepagestyle}\parindent\z@
\parskip\z@ \@plus .3\p@\relax
\let\item\@idxitem}%
{\if@restonecol\onecolumn\else\twocolumn\fi}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\ps@indextitlepagestyle}
% \begin{macrocode}
\aliaspagestyle{indextitlepagestyle}{chapter}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifnoindexintoc}
% \begin{macro}{\indexintoc}
% \begin{macro}{\noindexintoc}
% Flag to control whether or not to add the index title to the ToC,
% and declarations to set the flag.
% Default is to put the title into the ToC.
% \changes{v0.2}{2001/06/03}{Added \cs{ifnoindexintoc}, etc.}
% \begin{macrocode}
\newif\ifnoindexintoc
\newcommand*{\indexintoc}{\noindexintocfalse}
\newcommand*{\noindexintoc}{\noindexintoctrue}
\indexintoc
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\indexcolsep}
% \begin{macro}{\indexrule}
% These two lengths control the column separation and the thickness
% of the inter-column rule.
% \changes{v0.2}{2001/06/03}{Added \cs{indexcolsep} and \cs{indexrule}}
% \begin{macrocode}
\newlength{\indexcolsep} \setlength{\indexcolsep}{35pt}
\newlength{\indexrule} \setlength{\indexrule}{0pt}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\preindexhook}
% A macro that is called between the index heading and the start of the
% two columns. The user can modify it to add something.
% \begin{macrocode}
\newcommand{\preindexhook}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@index}
% Format the index entry in the table of contents.
% \begin{macrocode}
\newcommand{\l@index}{\@dottedtocline{1}{0em}{0pt}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@idxitem}
% \begin{macro}{\subitem}
% \begin{macro}{\subsubitem}
% Thsee macros are used to format the entries in the index.
% \begin{macrocode}
\newcommand{\@idxitem} {\par\hangindent 40\p@}
\newcommand{\subitem} {\par\hangindent 40\p@ \hspace*{20\p@}}
\newcommand{\subsubitem}{\par\hangindent 40\p@ \hspace*{30\p@}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\indexspace}
% The amount of white space that is inserted between `letter
% blocks' in the index.
% \begin{macrocode}
\newcommand{\indexspace}{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makeindex}
% \begin{macro}{\index}
% \begin{macro}{\specialindex}
% \begin{macro}{\makememindexhook}
% This is a modified version of the kernel \cs{makeindex} to allow for
% multiple indexes. It also defines \cs{index} (which is a modified version
% of the standard \cs{index}) and \cs{specialindex}.
%
% \cs{makememindexhook} is a null op but can be redefined to add extra code
% into \cs{makeindex}. For example, to incorporate \Lpack{ledmac}'s
% \cs{edindex} into the scheme:
% \begin{verbatim}
% \renewcommand*{\makememindexhook}{%
% \def\edindex{\@bsphack%
% \@ifnextchar [{\l@d@index}{\l@d@index[\jobname]}}}
% \end{verbatim}
% \changes{v1.3}{2002/11/14}{Indexing macros completely redone and extended}
% \changes{v1.61}{2004/03/12}{Added the \cs{makememindexhook} to \cs{makeindex}}
% \changes{v1.618}{2005/09/02}{Modified \cs{makeindex} for \cs{nofiles}}
% \begin{macrocode}
\newcommand*{\makememindexhook}{}
% \end{macrocode}
% \begin{macrocode}
\providecommand*{\makeindex}{}
\renewcommand*{\makeindex}[1][\jobname]{%
\if@filesw
\def\index{\@bsphack%
\@ifnextchar [{\@index}{\@index[\jobname]}}
\def\specialindex{\@bsphack\@spindex}%
\makememindexhook
\expandafter\newwrite\csname #1@idxfile\endcsname
\expandafter\immediate\openout \csname #1@idxfile\endcsname #1.idx\relax
\typeout{Writing index file #1.idx }%
\fi}
% \end{macrocode}
% Initially define, but emasculate, \cs{index} and \cs{specialindex} which are
% defined properly by the user calling \cs{makeindex}.
% \begin{macrocode}
\renewcommand{\index}[2][\jobname]{\@bsphack\@esphack}
\newcommand{\specialindex}[3]{\@bsphack\@esphack}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\printindex}
% The command to read an \file{ind} file.
% \begin{macrocode}
\newcommand{\printindex}[1][\jobname]{\@input@{#1.ind}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifreportnoidxfile}
% \begin{macro}{\reportnoidxfile}
% \begin{macro}{\ignorenoidxfile}
% \begin{macro}{\ifshowindexmark}
% \begin{macro}{\showindexmarks}
% \begin{macro}{\hideindexmarks}
% Two booleans to control reporting on unknown \file{idx} files and
% displaying indexed items in the margin.
% \begin{macrocode}
\newif\ifreportnoidxfile
\newcommand*{\reportnoidxfile}{\reportnoidxfiletrue}
\newcommand*{\ignorenoidxfile}{\reportnoidxfilefalse}
\ignorenoidxfile
\newif\ifshowindexmark
\newcommand*{\showindexmarks}{\showindexmarktrue}
\newcommand*{\hideindexmarks}{\showindexmarkfalse}
\hideindexmarks
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@index}
% \verb?\@index[file]? is first stage of \cs{index}, handling the \file{idx} file.
% \begin{macrocode}
\def\@index[#1]{%
\@ifundefined{#1@idxfile}%
{\ifreportnoidxfile
\@memwarn{Undefined index file #1}%
\fi
\begingroup
\@sanitize
\@nowrindex}%
{\def\@idxfile{#1}%
\begingroup
\@sanitize
\@wrindexm@m}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@nowrindex}
% Called when there is no \file{idx} file to throw away the indexed item.
% \begin{macrocode}
\newcommand{\@nowrindex}[1]{%
\ifshowindexmark\@showidx{#1}\fi\endgroup\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@wrindexm@m}
% \begin{macro}{\@@wrindexhyp}
% The next stage in index processing is \verb?\@wrindexm@m{item}?,
% which writes the \file{idx} file name
% and indexed item to the \file{aux} file. The \cs{@@wrindexhyp} macro
% provides hyperlinks in case the \Lpack{hyperref} package is used.
% \begin{macrocode}
\newcommand{\@wrindexm@m}[1]{\@@wrindexhyp#1||\\}
\def\@@wrindexhyp#1|#2|#3\\{%
\ifshowindexmark\@showidx{#1}\fi
\ifx\\#2\\%
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}{#1|hyperpage}{\thepage}}%
\else
\def\Hy@temp@A{#2}%
\ifx\Hy@temp@A\HyInd@ParenLeft
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}{#1|#2hyperpage}{\thepage}}%
\else
% \end{macrocode}
% Add a corresponding test on \verb+|)+ to add \verb|hyperpage|. This
% is needed by the \verb|xindy| indexing programme. The standard
% \verb|makeindex| programme does not seem to mind.
% \changes{v3.7g}{2018/04/04}{Added test for \texttt{|)} and adding
% \texttt{hyperpage} accordingly.}
% \begin{macrocode}
\ifx\Hy@temp@A\HyInd@ParenRight
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}{#1|#2hyperpage}{\thepage}}%
\else
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}{#1|#2}{\thepage}}%
\fi
\fi
\fi
\endgroup
\@esphack}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyperpage}
% \begin{macro}{\hyperlink}
% These are defined in the \Lpack{hyperref} package but we need them.
% Other hyperstuff is only used if the package itself is used.
% \begin{macrocode}
\newcommand{\hyperpage}[1]{#1}
\newcommand{\hyperlink}[2]{#2}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@wrindexm@m}
% The macro \verb?\@@wrindexm@m{file}{item}{page}? has been written into
% the \file{aux} file. It is normally defined so that it calls
% \verb?\@@@wrindexm@m{item}{page}? to finally write to the \file{idx} file.
% \begin{macrocode}
\newcommand{\@@wrindexm@m}[1]{\begingroup
\def\@idxfile{\@nameuse{#1@idxfile}}
\@sanitize
\@@@wrindexm@m}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@@wrindexm@m}
% \cs{@@@wrindexm@m}\marg{item}\marg{page} writes the \cs{indexentry} to
% the \file{idx} file. This file is read both at the beginning and end of
% a document so \cs{@@@wrindexm@m} must be disabled for one of these reads
% otherwise the index entries will be doubled up. Initially I disabled it
% after the first read. It eventually dawned on me that this meant two
% LaTeX runs to update the \file{idx}. Enabling it for the second read
% means that the \file{idx} file is updated at the end of each run.
% \changes{v1.618}{2005/09/02}{Made \cs{@@@wrindexm@m} obey \cs{nofiles}}
% \changes{v1.618}{2005/09/25}{\cs{@@@wrindexm@m} now reads the aux
% file at the end of the document}
% \changes{v3.7i}{2019/11/15}{Changed the writing to protected}
% \begin{macrocode}
\newcommand{\@@@wrindexm@m}[2]{\endgroup}
\AtBeginDocument{%
\def\@@@wrindexm@m#1#2{%
\if@filesw
%\immediate\write \@idxfile{\string\indexentry{#1}{#2}}%
\immediate@protected@write\@idxfile{}{\string\indexentry{#1}{#2}}%
\fi
\endgroup}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@spindex}
% Now do similar things for \cs{specialindex}.
% \begin{macrocode}
\newcommand{\@spindex}[2]{%
\@ifundefined{#1@idxfile}%
{\ifreportnoidxfile
\@memwarn{Undefined index file #1}%
\fi
\begingroup
\@sanitize
\@nowrindex}%
{\def\@idxfile{#1}%
\def\@sptheidx{#2}%
\begingroup
\@sanitize
\@wrspindex}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@wrspindex}
% \begin{macro}{\@@wrspindexhyp}
% \begin{macrocode}
\newcommand{\@wrspindex}[1]{\@@wrspindexhyp#1||\\}
\def\@@wrspindexhyp#1|#2|#3\\{%
\ifshowindexmark\@showidx{#1}\fi
\ifx\\#2\\%
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}%
{#1|hyperspindexpage(\thepage)}%
{\@nameuse{the\@sptheidx}}}%
\else
\def\Hy@temp@A{#2}%
\ifx\Hy@temp@A\HyInd@ParenLeft
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}%
{#1|#2hyperspindexpage(\thepage)}%
{\@nameuse{the\@sptheidx}}}%
\else
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}{#1|#2}%
{\@nameuse{the\@sptheidx}}}%
\fi
\fi
\endgroup
\@esphack}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyperspindexpage}
% \begin{macrocode}
\def\hyperspindexpage(#1)#2{\hyperlink{page.#1}{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifmemhyperindex}
% \begin{macro}{\memhyperindextrue}
% \begin{macro}{\memhyperindexfalse}
% Flag to turn off \cs{hyperindexfalse} hyperrefing the index (apparently
% \Lpack{xindy} can't cope with this. Email from Frederic Connes, 2005/07/13:
% \begin{verbatim}
% ...You use |hyperspindex(\thepage) which xindy doesn't
% recognise as a valid markup-locref. And I don't know how
% to add it because xindy only accepts one argument in
% markup-locref (if the number is not a page number, it will
% still point to a page with that number) so replacing it
% with |hyperpage won't work. ...
% \end{verbatim}
%
%
% The default is \cs{memhyperindextrue}. Setting \cs{memhyperindexfalse}
% prohibits a hyper index --- setting whatever option in \Lpack{hyperref}
% to disable hyper indexing will (probably) not work as far as \Lpack{xindy}
% is concerned.
% \changes{v1.618}{2005/09/04}{Added \cs{ifmemhyperindex}}
% \begin{macrocode}
\newif\ifmemhyperindex
\memhyperindextrue
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifm@mxindy}
% \begin{macro}{\m@mxindytrue}
% \begin{macro}{\m@mxindyfalse}
% \begin{macro}{\xindyindex}
% \begin{macro}{\@@wrspindexhyp}
% Use \cs{xindyindex} when you are going to use the xindy program rather
% than makeindex. hyperrefed entries won't work with xindy.
% The code was supplied by Frederic
% Connes\footnote{\texttt{frederic@connes.org}} in an email to me on
% 2006/01/08.
% \changes{v1.61803}{2008/01/30}{Added \cs{xindyindex} (Frederic Connes
% mempatch v4.4)}
% \begin{macrocode}
\newif\ifm@mxindy
\m@mxindyfalse
\newcommand*{\xindyindex}{\m@mxindytrue}
\def\@@wrspindexhyp#1|#2|#3\\{%
\ifshowindexmark\@showidx{#1}\fi
\ifx\\#2\\%
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}%
\ifm@mxindy{#1}\else{#1|hyperspindexpage(\thepage)}\fi
{\@nameuse{the\@sptheidx}}}%
\else
\def\Hy@temp@A{#2}%
\ifx\Hy@temp@A\HyInd@ParenLeft
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}%
\ifm@mxindy{#1|#2}\else{#1|#2hyperspindexpage(\thepage)}\fi
{\@nameuse{the\@sptheidx}}}%
\else
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}{#1|#2}%
{\@nameuse{the\@sptheidx}}}%
\fi
\fi
\endgroup
\@esphack}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \begin{macro}{\@@wrindexhyp}
% \begin{macro}{\@@wrspindexhyp}
% If the \Lpack{hyperref} package is not being used, or \cs{ifmemhyperindex}
% is false, there is no need
% to clutter up the index files.
% \changes{v1.61}{2004/03/28}{Declutter index files if hyperref is not used}
% \changes{v1.618}{2005/09/02}{Fixed spaces in non-hyperref index files (mempatch v2.3).
% Reported by Michael W. Daniels.}
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{hyperref}{}{\memhyperindexfalse}%
% \end{macrocode}
% If the \Lpack{hyperref} package is not being used, or a hyperindex
% is not required, simplify!
% \begin{macrocode}
\ifmemhyperindex\else
\def\@@wrindexhyp#1||\\{%
\ifshowindexmark\@showidx{#1}\fi
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}{#1}{\thepage}}%
\endgroup
\@esphack}%
\def\@@wrspindexhyp#1||\\{%
\ifshowindexmark\@showidx{#1}\fi
\protected@write\@auxout{}%
{\string\@@wrindexm@m{\@idxfile}{#1}{\@nameuse{the\@sptheidx}}}%
\endgroup
\@esphack}%
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\see}
% \begin{macro}{\seename}
% \begin{macro}{\seealso}
% \begin{macro}{\alsoname}
% These definitions are taken from the \Lpack{makeidx} package.
% \begin{macrocode}
\newcommand*{\see}[2]{\emph{\seename} #1}
\newcommand*{\seename}{see}
\newcommand*{\seealso}[2]{\emph{\alsoname} #1}
\newcommand*{\alsoname}{see also}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\citeindexfile}
% For the \Lpack{natbib} package, and possibly other packages that do
% some special indexing.
% \begin{macrocode}
\newcommand{\citeindexfile}{\jobname}
\AtBeginDocument{\@ifpackageloaded{natbib}{%
\def\NAT@index{\index[\citeindexfile]{\NAT@idxtxt}}}{}}
% \end{macrocode}
% \end{macro}
%
% The next part of the code is essentially the \Lpack{showidx} package.
% I tried putting index entries into marginpars but too many on a page
% led to the `too many floats' problem.
%
% \begin{macro}{\indexmarkstyle}
% \begin{macro}{\@indexbox}
% \begin{macrocode}
\newtoks\indexmarkstyle
\indexmarkstyle{\normalfont\footnotesize\ttfamily}
\newinsert\@indexbox
\dimen\@indexbox\maxdimen
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
\begingroup
\catcode`\@\active
\expandafter\gdef\csname\string @sanitizeat\endcsname
{\def @{\char`\@}}
\endgroup
% \end{macrocode}
%
% \begin{macro}{\@showidx}
% \begin{macrocode}
\newcommand{\@showidx}[1]{%
\insert\@indexbox{%
\@sanitizeat
\the\indexmarkstyle
\hsize\marginparwidth
\hangindent\marginparsep \parindent\z@
\everypar{}\let\par\@@par \parfillskip\@flushglue
\lineskip\normallineskip
\baselineskip .8\normalbaselineskip\sloppy
\raggedright \leavevmode
\vrule \@height .7\normalbaselineskip \@width \z@\relax
#1\relax
\vrule \@height \z@ \@depth .3\normalbaselineskip \@width \z@\relax
}%
\ifhmode\penalty\@M \hskip\z@skip\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@leftidx}
% \begin{macro}{\@rightidx}
% \begin{macrocode}
\newcommand{\@leftidx}{\hskip-\marginparsep \hskip-\marginparwidth}
\newcommand{\@rightidx}{\hskip\columnwidth \hskip\marginparsep}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@mkidx}
% \begin{macrocode}
\newcommand{\@mkidx}{\vbox to \z@{%
\rlap{%
\if@twocolumn
\if@firstcolumn \@leftidx \else \@rightidx \fi
\else
\if@twoside
\ifodd\c@page \@rightidx \else \@leftidx \fi
\else
\@rightidx
\fi
\fi
\box\@indexbox
}%
\vss}}
% \end{macrocode}
% \end{macro}
%
% \section{Page bottom}
%
% \begin{macro}{\raggedbottom}
% \begin{macro}{\flushbottom}
% \begin{macro}{\@texttop}
% \begin{macro}{\mem@flshbot}
% These kernel macros need changing because of the new \cs{@indexbox}
% marginal insert.
% \changes{v3.7d}{2015/04/21}{It makes more sense to explicitly call
% \cs{flushbottom} than just let \cs{@texttop}. We also add a switch
% macro to see if \cs{flushbottom} is active. \cs{raggedbottom} and
% \cs{sloppybottom} sets the switch to false}
% \begin{macrocode}
\renewcommand{\raggedbottom}{%
\def\mem@flshbot{01}%
\def\@textbottom{\vskip\z@ plus.0001fil}%
\let\@texttop\@mkidx}
\renewcommand{\flushbottom}{%
\def\mem@flshbot{00}%
\let\@textbottom\relax
\let\@texttop\@mkidx}
\let\@texttop\@mkidx
\flushbottom
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Widows and sloppybottom}
%
% There was a discussion \textit{widow handling?} on CTT in
% May 2006. \texttt{ivowel@gmail.com} wrote
% \begin{quote}
% in experimenting with raggedbottom, widowpenalty, and clubpenalty,
% I think that I have not found a solution that strikes me as
% particularly desirable. I think what I would really like is that
% widows (i.e., left-over single lines that begin on the following
% page) are resolved not by pushing one extra line from the same
% paragraph also onto the next page, but by stretching the
% \cs{textheight} to allow this one extra at the bottom of the
% same page.
% \end{quote}
% Donald Arseneau, as he so often does, came up with a solution he
% termed \cs{sloppybottom}. Here is a generalised version.
%
% \begin{macro}{\sloppybottom}
% \cs{sloppybottom} allows an extra line on a page to save a widow.
% You must increase the \cs{topskip} (by 60 percent is reasonable) and this
% will push the text lower on the page. Run \cs{checkandfixthelayout}
% after the change. For example:
% \begin{verbatim}
% \setlength{\topskip}{1.6\topskip}
% \checkandfixthelayout
% \sloppybottom
% ...
% \end{verbatim}
% \changes{v1.61803}{2008/01/30}{Added \cs{sloppybottom} (mempatch v4.6)}
% \changes{v3.7d}{2015/04/21}{Added flush bottom switch}
% \begin{macrocode}
\newcommand*{\sloppybottom}{%
\def\mem@flshbot{01}%
\def\@textbottom{\vskip \z@ \@plus.0001fil \@minus .95\topskip}%
\topskip=1\topskip \@plus 0.625\topskip \@minus .95\topskip
\def\@texttop{\vskip \z@ \@plus -0.625\topskip \@minus -0.95\topskip}}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \section{Glossaries}
%
% Standard LaTeX provides little and insufficient support for
% glossaries, just a \cs{makeglossary} and \cs{glossary} commands.
% This class does somewhat better. The code follows along the lines
% of that for indexes.
% \changes{v1.618}{2005/09/25}{Added glossary code}
%
%
% \begin{macro}{\ifonecolglossary}
% \begin{macro}{\onecolglossarytrue}
% \begin{macro}{\onecolglossaryfalse}
% TRUE for a one column glossary, otherwise its two column.
% \begin{macrocode}
\newif\ifonecolglossary
\onecolglossarytrue
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\onecolglossary}
% \begin{macro}{\twocolglossary}
% \changes{v1.61803}{2008/01/30}{Added \cs{onecolglossary} and \cs{twocolglossary}}
% \begin{macrocode}
\newcommand*{\onecolglossary}{\onecolglossarytrue}
\newcommand*{\twocolglossary}{\onecolglossaryfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{environment}{theglossary}
% The environment \texttt{theglossary} is used for glossaries.
% It makes a glossary with one or two columns, headed by a chapter-like
% title.
% \begin{macrocode}
\newenvironment{theglossary}{%
\if@twocolumn
\@restonecolfalse
\else
\@restonecoltrue
\fi
\ifonecolglossary
\onecolumn
\chapter*{\glossaryname}
\preglossaryhook
\else
\setlength{\columnseprule}{\glossaryrule}
\setlength{\columnsep}{\glossarycolsep}
\twocolumn[\@makeschapterhead{\glossaryname}
\preglossaryhook]%
\fi
\glossarymark
\ifnoglossaryintoc\else
\phantomsection
\addcontentsline{toc}{chapter}{\glossaryname}
\fi
\thispagestyle{chapter}\parindent\z@
\parskip\z@ \@plus .3\p@\relax
\begintheglossaryhook}%
{\atendtheglossaryhook\if@restonecol\onecolumn\else\twocolumn\fi}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\begintheglossaryhook}
% \begin{macro}{\atendtheglossaryhook}
% Two vacuous macros called as the last thing by \verb?\begin{theglossary}?
% and the first thing by \verb?\end{theglossary}? These could be used,
% for example, to insert another kind of environment.
% \begin{macrocode}
\newcommand*{\begintheglossaryhook}{}
\newcommand*{\atendtheglossaryhook}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\preglossaryhook}
% A vacuous macro called after the title is set and before the listing
% starts. The user can modify it to, for example, add some explanatory
% text.
% \begin{macrocode}
\newcommand*{\preglossaryhook}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifnoglossaryintoc}
% \begin{macro}{\glossaryintoc}
% \begin{macro}{\noglossaryintoc}
% Flag and declarations to control whether or not the glossary
% title is added to the ToC. Default is to put the title
% in the ToC.
% \begin{macrocode}
\newif\ifnoglossaryintoc
\newcommand*{\glossaryintoc}{\noglossaryintocfalse}
\newcommand*{\noglossaryintoc}{\noglossaryintoctrue}
\glossaryintoc
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\glossarycolsep}
% \begin{macro}{\glossaryrule}
% When the glossary is two column these lengths control the
% column separation and the width of a rule between the columns.
% \begin{macrocode}
\newdimen\glossarycolsep \glossarycolsep=35\p@
\newdimen\glossaryrule \glossaryrule=0\p@
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\glossaryspace}
% Vertical space between `letter blocks' in the glossary.
% Note that this is a macro, not a length.
% \begin{macrocode}
\newcommand*{\glossaryspace}{%
\par \vskip 1.0\onelineskip \@plus 5\p@ \@minus3\p@\relax}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\makeglossary}
% The preamble command to set up a glossary. Output is to the
% \file{\#1.glo} file. We need the \cs{providecommand} in case \cs{nofiles}
% has been called before the class. \cs{makeglossary} sets up several
% file-specific macros.
% \begin{macrocode}
\providecommand*{\makeglossary}{}
\renewcommand*{\makeglossary}[1][\jobname]{%
\makememglossaryhook
\@namedef{memglsact#1}{@}% actual
\@namedef{memglsnx#1}{}% no ref
\@namedef{memglsn#1}{\thepage}% num by page
\@namedef{memglsnf#1}{|memjustarg}% no special number format | emacs
\if@filesw \expandafter\newwrite\csname #1memglofile\endcsname
\expandafter\immediate\openout \csname #1memglofile\endcsname #1.glo\relax
\typeout{Writing glossary file #1.glo }%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makememglossaryhook}
% A vacuous macro called at the start of the \cs{makeglossary} code.
% It is redefinable to do something useful.
% \begin{macrocode}
\newcommand*{\makememglossaryhook}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\glossary}
% The user command for a raw glossary item. The full calling
% sequence looks like: \\
% \cs{glossary}\oarg{file}\parg{key}\marg{term}\marg{desc} \\
% but most is accomplished by lower level macros. It calls
% \cs{@glossary} to handle the first optional argument.
% \begin{macrocode}
\def\glossary{\@bsphack%
\@ifnextchar [{\@glossary}{\@glossary[\jobname]}}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@glossary}
% \cs{@glossary}\oarg{file} handles the first of the \cs{glossary} optional
% arguments, even though the calling sequence looks like: \\
% \cs{@glossary}\oarg{file}\parg{key}\marg{term}\marg{desc}. \\
% It calls \cs{@@glossary} to handle the second optional argument
% and the rest.
% \begin{macrocode}
\def\@glossary[#1]{%
\@ifnextchar ({\@@glossary[#1]}{\@@glossary[#1]()}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@glossary}
% The base macro for \cs{glossary}. Its real calling sequence is: \\
% \cs{@@glossary}\oarg{file}\parg{key}\marg{term}\marg{desc}. \\
% Provided the glossary output file has been set up it calls
% \cs{@wrglom@m} to write the data, otherwise it throws away its
% arguments.
% \begin{macrocode}
\def\@@glossary[#1](#2)#3#4{%
\@ifundefined{#1memglofile}{%
\begingroup
\@sanitize
\endgroup
\@esphack%
}{%
\def\memglofile{#1}%
\begingroup
\@sanitize
% \end{macrocode}
% Use the correct key, \meta{key} if given, otherwise \meta{term}.
% \begin{macrocode}
\ifx\@empty#2\@empty
\@wrglom@m{#3}{#3}{#4}%
\else
\@wrglom@m{#2}{#3}{#4}%
\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@wrglom@m}
% \cs{@wrglom@m}\marg{key}\marg{term}\marg{desc} writes its three arguments,
% plus the \meta{ref} and the \meta{num} to the \file{aux} file as the
% arguments to the \cs{@@wrglom@m} macro.
% \begin{macrocode}
\newcommand{\@wrglom@m}[3]{%
\protected@write\@auxout{}%
{\string\@@wrglom@m{\memglofile}{#1}{#2}{#3}{\@nameuse{memglsnx\memglofile}}{\@nameuse{memglsn\memglofile}}}%
\endgroup
\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@wrglom@m}
% The calling sequence looks like: \\
% \cs{@@wrglom@m}\marg{file}\marg{key}\marg{term}\marg{desc}\marg{ref}\marg{num} \\
% but is actually really only \\
% \cs{@@wrglom@m}\marg{file} \\
% It saves the output file identifier in \cs{memglofile} and
% \meta{file} as \cs{m@mgf}, then calls \cs{memwritetoglo}
% to handle the remaining `arguments'.
% \begin{macrocode}
\newcommand{\@@wrglom@m}[1]{\begingroup
\def\memglofile{\@nameuse{#1memglofile}}%
\def\m@mgf{#1}%
\@sanitize
\memwritetoglo}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\memwritetoglo}
% \begin{macro}{\@ctualm@mwritetoglo}
% \cs{memwritetoglo}\marg{key}\marg{name}\marg{desc}\marg{ref}\marg{num}
% will, at an appropriate time write the raw glossary data to the
% appropriate \file{glo} file.
%
% The \file{aux} file is read twice, once as one of the initial
% actions at the start of the \texttt{document} environment, and again
% at the end of the \texttt{document} environment. The raw glossary
% data must only be written once from the \file{aux} to the \file{glo} file.
% Initially \cs{memwritetoglo} is defined to do nothing, then, after the
% \file{aux} file has been read at the beginning is redefined to do
% its writing.
%
% The Makeindex program expects its input to be like: \\
% \verb?\glosaryentry{key@data}{num}?
% Very cunningly the raw data is fed to the \file{glo}
% file looking like: \\
% \verb?\glossaryentry{key@{\memgloterm{term} \memglodesc{desc} \memgloref{ref}}{num}? \\
% which as far as Makeindex is concerned is simply: \\
% \verb?\glosaryentry{key@{data}}{num}? \\
% (note where all the braces are).
%
%
% \changes{v3.7k}{2020/02/24}{Rewritten to use
% \cs{immediate@protected@write} instead, otherwise UTF8 may get
% written as latin1}
% \begin{macrocode}
\newcommand{\memwritetoglo}[5]{\endgroup}
\newcommand{\@ctualm@mwritetoglo}[5]{%
%\immediate\write \memglofile%
\immediate@protected@write\memglofile{}%
{\string\glossaryentry{#1\@nameuse{memglsact\m@mgf}
{\string\memgloterm{#2}}{\string\memglodesc{#3}}
{\string\memgloref{#4}}\@nameuse{memglsnf\m@mgf}}{#5}}%
\endgroup}
\AtBeginDocument{%
\let\memwritetoglo\@ctualm@mwritetoglo}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\changeglossactual}
% \begin{macro}{\changeglossref}
% \begin{macro}{\changeglossnum}
% \begin{macro}{\changeglossnumformat}
% There are internal macros that are file-dependant, their names
% being constructed from the file name plus a fixed name. The
% \cs{makeglossary} command initializes these but the user may well need
% to change them. In the macros below, \texttt{...actual} refers to the
% actual character in a Makeindex configuration file (default \texttt{@}),
% \texttt{...ref} to the \meta{ref} glossary argument, \texttt{...num}
% to the meta{num} argument (default \cs{thepage}) and \texttt{...numformat}
% to the Makeindex encapsulating command. Example uses are:
% \begin{verbatim}
% \changeglossactual[file]{?}
% \changeglossref[file]{\thepage}
% \changeglossnum[file]{\thesection}
% \changeglossnumref[file]{|textbf}
% \end{verbatim}
% \begin{macrocode}
\newcommand*{\changeglossactual}[2][\jobname]{%
\@namedef{memglsact#1}{#2}}
\newcommand*{\changeglossref}[2][\jobname]{%
\@namedef{memglsnx#1}{#2}}
\newcommand*{\changeglossnum}[2][\jobname]{%
\@namedef{memglsn#1}{#2}}
\newcommand*{\changeglossnumformat}[2][\jobname]{%
\@namedef{memglsnf#1}{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\glossitem}
% The final sorted glossary data is in the form: \\
% \cs{glossitem}\marg{term}\marg{desc}\marg{ref}\marg{num} \\
% The definition here does little.
% \begin{macrocode}
\newcommand{\glossitem}[4]{#1 #2 #3 #4\par}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\memgloterm}
% \begin{macro}{\memglodesc}
% \begin{macro}{\memgloref}
% \begin{macro}{\memglonum}
% These are wrappers round the \meta{term}, \meta{desc}, \meta{ref} and
% \meta{num} elements in the final data. They are vacuous to start with.
% \begin{macrocode}
\newcommand*{\memgloterm}[1]{#1}
\newcommand*{\memglodesc}[1]{#1}
\newcommand*{\memgloref}[1]{#1}
\newcommand*{\memglonum}[1]{#1}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\printglossary}
% \cs{printglossary}\oarg{file} inputs the glossary \file{gst} file.
% \begin{macrocode}
\newcommand*{\printglossary}[1][\jobname]{\@input@{#1.gls}}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \section{Notes/Marginalia}
%
%
% \subsection{A simple interface for specifying locations}
%
% \changes{v1.61803398d}{2010/01/25}{added}
%
% The \Lpack{memoir} class as of December 2009 supports \cs{marginpar},
% \cs{sidepar}, and \cs{sidebar} for placing information in a margin.
% The means of specifying in which margin the information should be put
% is different for each of these. Here a consistent location interface
% is provided for all marginalia.
%
%
% \begin{macro}{\m@msetm@argin}
% \begin{macro}{\m@mm@argin}
% A workhorse macro for setting a margin placement code. The argument
% may be one of: left, right, outer, or inner, with \cs{m@mm@argin} defined
% as the corresponding codes of 0, 1, 2, or 3. An unkown argument is coded
% as a negative number.
% \begin{macrocode}
\newcommand*{\m@msetm@argin}[1]{%
\def\@tempa{#1}\def\@tempb{left}%
\ifx\@tempa\@tempb
\def\m@mm@argin{0}%
\else
\def\@tempb{right}%
\ifx\@tempa\@tempb
\def\m@mm@argin{1}%
\else
\def\@tempb{outer}%
\ifx\@tempa\@tempb
\def\m@mm@argin{2}%
\else
\def\@tempb{inner}%
\ifx\@tempa\@tempb
\def\m@mm@argin{3}%
\else
\def\m@mm@argin{-1}%
\fi
\fi
\fi
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifmemtortm}
% \begin{macro}{\memtortmtrue}
% \begin{macro}{\memtortmfalse}
% A flag set TRUE if the marginalia is to be moved to the right of the text
% and FALSE if it is to be moved to the left of the text.
% \begin{macrocode}
% MEM-TO-RighT-Margin
\newif\ifmemtortm
\memtortmtrue
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mwhich@margin}
% \cs{m@mwhich@margin}\marg{code} sets \cs{ifmemtortm} TRUE or FALSE depending
% on the value of \meta{code} (0 to 3), and other factors.
% \begin{description}
% \item[Two column document] If the first column, to the left, otherwise
% to the right, irrespective the document being
% one- or two-side.
% \item[One sided document] If code = 0 (left), to the left, otherwise
% (code = 1 (right), 2 (outer), 3 (inner)) to the right.
% \item[Two sided document] depends on whether a recto or verso page:
% \begin{description}
% \item[Recto (odd) page] right if code = 1 (right) or 2 (outer), otherwise
% left.
% \item[Verso (even) page] left if code = 0 (left) or 2 (outer), otherwise
% right.
% \end{description}
% \end{description}
%
%
% \begin{macrocode}
\newcommand*{\m@mwhich@margin}[1]{%
\memtortmtrue
\if@twocolumn
\if@firstcolumn% left
\memtortmfalse
\else% right
\memtortmtrue
\fi
\else
\if@twoside
\checkoddpage
\ifcase #1\relax% 0 left
\memtortmfalse
\or% 1 right
\memtortmtrue
\or% 2 outer
\ifoddpage
\memtortmtrue
\else
\memtortmfalse
\fi
\or% 3 inner
\ifoddpage
\memtortmfalse
\else
\memtortmtrue
\fi
\fi% end ifcase
\else% oneside
\ifnum #1=\z@% 0 left, all else right
\memtortmfalse
\else
\memtortmtrue
\fi
\fi% end if@twoside
\fi}
% \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Marginpars}
%
% A \cs{marginpar} is a kind of floating object --- you can't control
% exactly where it will go. There is one problem with the kernel
% definition of \cs{marginpar} in that sometimes a \cs{marginpar} may
% end up on the wrong side of the page. The following is an attempt
% to fix that using the odd/even page check provided as part of
% the class.
%
% \begin{macro}{\@addmarginpar}
% The part of the code for \cs{marginpar} that deals with deciding which
% side of the page it should be printed on is \cs{@addmarginpar}, buried
% away in the kernel's \texttt{output} routine. A couple of minor changes are made
% to the kernel code. The first is at the beginning where I have added
% the \cs{checkoddpage} page checking code.
% \changes{v1.618033988d}{2010/02/26}{fixed twoside -> left marrgin
% bug, reported by Frank Wikstr\"om, on private email}
% In the new margin placement syntax, there is a new syntax: always
% left, in twoside mode. This cannot be implemented using the normal
% marginpar placement controls, so we have to add our own.
% \begin{macrocode}
\def\@addmarginpar{%
\checkoddpage
% \end{macrocode}
% Continue with the kernel code. The twocolumn stuff in the new syntax
% scheme is the same as in the kernel.
% \begin{macrocode}
\@next\@marbox\@currlist{\@cons\@freelist\@marbox
\@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne
\if@twocolumn
\if@firstcolumn \@tempcnta\m@ne \fi
\else
% \end{macrocode}
% \changes{v1.618033988d}{2010/02/26}{added as a part of the above
% mentioned fix}
% Here we add the new stuff. We make use of the fact that we have
% hidden all the page checking in \verb?\m@mwhich@margin?, and we only
% fire it of if we know \verb?\marginparmargin? have been used (via
% \verb?\ifm@msetmp?).
% \begin{macrocode}
\ifm@msetmp%
% \@tempcnta > 0 => right side of page
% \@tempcnta < 0 => left side of page
\m@mwhich@margin{\m@mmpar@margin}% set left or right margin
\ifmemtortm%
\@tempcnta\@ne\relax%
\else%
\@tempcnta\m@ne\relax%
\fi%
\else%
\if@mparswitch
% \end{macrocode}
% The next line, reading \\
% \verb?\ifodd\c@page \else\@tempcnta\m@ne \fi? \\
% is where the odd/even page checking is done in the kernel code. I
% replace it with my code, and then continue with the kernel.
% \begin{macrocode}
\ifoddpage \else \@tempcnta\m@ne \fi%
\fi%
\if@reversemargin \@tempcnta -\@tempcnta \fi%
\fi%
\fi%
\ifnum\@tempcnta <\z@ \global\setbox\@marbox\box\@currbox \fi
\@tempdima\@mparbottom
\advance\@tempdima -\@pageht
\advance\@tempdima\ht\@marbox
\ifdim\@tempdima >\z@
% \end{macrocode}
% The next line in the kernel reads: \\
% \verb?\@latex@warning@no@line {Marginpar on page \thepage\space moved}? \\
% I have changed the warning message to give the user an indication
% of the severity of the move. Then follow the kernel on to the end.
% \begin{macrocode}
\@latex@warning@no@line {Marginpar on page
\thepage\space moved by \the\@tempdima}%
\else
\@tempdima\z@
\fi
\global\@mparbottom\@pageht
\global\advance\@mparbottom\@tempdima
\global\advance\@mparbottom\dp\@marbox
\global\advance\@mparbottom\marginparpush
\advance\@tempdima -\ht\@marbox
\global\setbox \@marbox
\vbox {\vskip \@tempdima
\box \@marbox}%
\global \ht\@marbox \z@
\global \dp\@marbox \z@
\kern -\@pagedp
\nointerlineskip
\hb@xt@\columnwidth
{\ifnum \@tempcnta >\z@
\hskip\columnwidth \hskip\marginparsep
\else
\hskip -\marginparsep \hskip -\marginparwidth
\fi
\box\@marbox \hss}%
\nointerlineskip
\hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}%
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Marginpar -- margin interface}
%
% The `standard' method of specifying the desired margin for a \cs{marginpar}
% consists of the two macros \cs{normalmarginpar} and \cs{reversemarginpar},
% whose effects depend on whether the document is one- or two-sided, whether
% the page is recto or verso, and if it is set in one- or two-columns.
%
% \begin{macro}{\ifm@msetmp}
% \begin{macro}{m@msetmptrue}
% \begin{macro}{m@msetmpfalse}
% TRUE if the macro \cs{marginparmargin} has been called.
% \begin{macrocode}
\newif\ifm@msetmp
\m@msetmpfalse
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\marginparmargin}
% \begin{macro}{\m@mmpar@margin}
% The user command for specifying the desired margin for \cs{marginpar}s.
% The code is stored as \cs{m@mmpar@margin}, and \cs{setmpbools} is called to
% convert to the regular \cs{marginpar} booleans.
% \begin{macrocode}
\newcommand*{\marginparmargin}[1]{%
\m@msetmptrue
\m@msetm@argin{#1}%
\ifnum\m@mm@argin<\z@
\@memwarn{Bad \string\marginparmargin\space argument `#1'\MessageBreak
set to `outer'}%
\gdef\m@mmpar@margin{2}% set as outer
\else
\global\let\m@mmpar@margin\m@mm@argin
\fi
\setmpbools}
% \end{macrocode}
% \changes{v3.6k}{2013/05/14}{Added default \cs{m@mmpar@margin}}
% \begin{macrocode}
\if@twocolumn\else
\if@twoside
\def\m@mmpar@margin{2}
\else
\def\m@mmpar@margin{1}
\fi
\fi
% \end{macrocode}
%
%
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setmpbools}
% Given \cs{m@mmpar@margin}, \cs{setmpbools} sets the corresponding
% \cs{marginpar} location booleans.
% \begin{macrocode}
\newcommand*{\setmpbools}{%
\if@twoside
\@mparswitchtrue
\else
\@mparswitchfalse
\fi
\ifcase\m@mmpar@margin\relax% 0 left
\@reversemargintrue% \sideparswitchfalse \reversesidepartrue
\or% 1 right
\@reversemarginfalse% \sideparswitchfalse \reversesideparfalse
\or% 2 outer
\@reversemarginfalse% \sideparswitchtrue \reversesideparfalse
\or% 3 inner
\@reversemargintrue% \sideparswitchtrue \reversesidepartrue
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\newcommand*{\m@msetmpcodes}{%
\if@mparswitch% 2 sided
\if@reversemargin% inner
\def\m@mmpar@margin{3}%
\else% outer
\def\m@mmpar@margin{2}%
\fi
\else% 1 sided
\if@reversemargin% left
\def\m@mmpar@margin{0}%
\else% right
\def\m@mmpar@margin{1}%
\fi
\fi}
% \end{macrocode}
%
% \subsection{A fixed marginpar}
%
%
% Introduce a non-floating marginpar.
% \changes{v1.4}{2003/11/22}{Added \cs{sidepar} and supports for a fixed
% marginpar (from patch v1.8)}
%
% \begin{macro}{\parnopar}
% From \theTeXbook{} Exercise 14.15. It creates an `invisible' end/start paragraph,
% and may be used for getting \TeX{} to try a pagebreak.
%
% Roman Eisle (email 2008/09/05) found a problem with the original
% definition as its effects continued on: \\
% \verb?\newcommand{\parnopar}{\parfillskip=0pt\par\parskip=0pt\noindent}? \\
% and he supplied the fix used below.
%
% \changes{v1.6180339c}{2008/12/24}{Changed \cs{parnopar} to limit its effect
% to a single instance}
% \changes{v3.6e}{2010/08/17}{made \cs{parnopar} sit inside a group}
% \begin{macrocode}
\newcommand*{\parnopar}{{\parfillskip=0pt\par\parskip=0pt\noindent}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\ifreversesidepar}
% \begin{macro}{\ifsideparswitch}
% \changes{v1.61803398d}{2010/01/25}{Added footnote explaining the default}
% Analogues of \cs{marginpar} controls.\footnote{Note that for some
% now forgotten reason the default placement of the \cs{sidepar} is
% reversed in comparison to say \cs{marginpar}. As not to change
% existing documents, we have left the default like this.}
% \begin{macrocode}
\newif\ifreversesidepar
% \reversesideparfalse
\reversesidepartrue
\newif\ifsideparswitch
\sideparswitchfalse
\if@twoside \sideparswitchtrue \fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{v1.61803398d}{2010/01/25}{Added}
% \begin{macro}{\ifm@msetsp}
% \begin{macro}{\m@msetsptrue}
% \begin{macro}{\m@msetspfalse}
% \begin{macrocode}
%% true if \sideparmargin used
\newif\ifm@msetsp
\m@msetspfalse
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \changes{v1.61803398d}{2010/01/25}{Added}
% \begin{macro}{\sideparmargin}
% \begin{macro}{\m@mspar@margin}
% User command for specifing the margin for \cs{sidepar}s.
% The numeric code is stored in \cs{m@mspar@margin}.
% \begin{macrocode}
\newcommand*{\sideparmargin}[1]{%
\m@msetsptrue
\m@msetm@argin{#1}%
\ifnum\m@mm@argin<\z@
\@memwarn{Bad \string\sideparmargin\space argument `#1'\MessageBreak
set to `outer'}%
\gdef\m@mspar@margin{2}% set as outer
\else
\global\let\m@mspar@margin\m@mm@argin
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \changes{v1.61803398d}{2010/01/25}{Added}
% \begin{macro}{\m@msidepar@left}
% \begin{macro}{\m@msidepar@right}
% Move a \cs{sidepar} into the left/right margin.
% \begin{macrocode}
\newcommand*{\m@msidepar@left}{%
\@tempdimc\marginparwidth
\advance\@tempdimc\marginparsep
\kern-\@tempdimc}
\newcommand*{\m@msidepar@right}{%
\@tempdimc\columnwidth
\advance\@tempdimc\marginparsep
\kern\@tempdimc}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \changes{v1.61803398d}{2010/01/25}{Added}
% \begin{macro}{\setspbools}
% Given the \cs{m@mspar@margin} code, calculates the corresponding
% \cs{sidepar} location booleans.
% \begin{macrocode}
\newcommand*{\setspbools}{%
\ifcase\m@mspar@margin\relax% 0 left
\sideparswitchfalse \reversesidepartrue
\or% 1 right
\sideparswitchfalse \reversesideparfalse
\or% 2 outer
\sideparswitchtrue \reversesideparfalse
\or% 3 inner
\sideparswitchtrue \reversesidepartrue
\fi}
% \end{macrocode}
% \end{macro}
% \changes{v1.61803398d}{2010/01/25}{Added}
% \begin{macro}{\setspcode}
% Given the \cs{sidepar} location booleans, sets up the corresponding
% \cs{m@mspar@margin} numeric codes.
% \begin{macrocode}
\newcommand*{\setspcode}{%
\ifsideparswitch
\ifreversesidepar
\def\m@mspar@margin{3}% inner
\else
\def\m@mspar@margin{2}% outer
\fi
\else
\ifreversesidepar
\def\m@mspar@margin{0}% left
\else
\def\m@mspar@margin{1}% right
\fi
\fi}
% \end{macrocode}
% \end{macro}
% \changes{v1.61803398d}{2010/01/25}{Added}
% \begin{macro}{\sideparfont}
% \begin{macro}{\sideparform}
% The font to be used for \cs{sidepar}s and the alignment for it.
% \changes{v1.61803398d}{2010/02/04}{Changed default font}
% \changes{v1.61803398d}{2010/02/05}{added \cs{sideparform}}
% The \cs{sideparform} holds code that will set the text flush against
% the edge of the text.\footnote{One might consider redefining this
% using the \cs{RaggedRight} and \cs{RaggedLeft} macros from the
% ragged2e package.}
% \begin{macrocode}
\newcommand*{\sideparfont}{\normalfont\normalsize}
\newcommand*{\sideparform}{\ifmemtortm\raggedright\else\raggedleft\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sidepar}
% \begin{macro}{\@sidepar}
% \begin{macro}{\sideparvshift}
% \cs{sidepar}\oarg{left}\marg{right} (per \cs{marginpar}).
% Sidepars had a nasty habit of moving up or down depending on whether
% characters in the sidepar and the main text line have ascenders and/or
% descenders. The length \cs{sideparvshift} was provided to
% enable adjustments. This is Dan Luecking's modified version of my
% original code
% (CTT \textit{Re: sidepars drift up a point}, 2006/04/11) which does a much
% better job,
% and the default for \cs{sideparvshift} is now 0pt.
% \changes{v1.61803}{2008/01/30}{Fixed \cs{sidepars} from moving up and down
% (mempatch v4.5)}
% \changes{v1.61803}{2008/01/30}{Normalised font in \cs{@sidepar}
% (mempatch v4.9)}
% \changes{v1.61803398d}{2010/01/25}{\cs{@sidepar} changed to fit the
% interface just added}
% \changes{v1.61803398d}{2010/02/05}{added \cs{sideparform}}
% \changes{v3.6h}{2010/10/29}{The inserted text should have the same
% baseline stretch as the rest of the page notes.}
% \begin{macrocode}
\newcommand{\sidepar}{\@dblarg{\@sidepar}}
\long\def\@sidepar[#1]#2{\leavevmode\@bsphack\strut\vadjust{%
\checkoddpage
\ifm@msetsp% \sideparmargin used
%%%% \setspbools
\else% \sideparmargin not used, set the \m@mspar@margin code
\setspcode
\fi
\rlap{\kern-\parindent
\m@mwhich@margin{\m@mspar@margin}% set left or right margin
\ifmemtortm
\m@msidepar@right
\else
\m@msidepar@left
\fi
\setbox0=\vtop to 0pt{%
\begin{minipage}[t]{\marginparwidth}%
\def\baselinestretch{\m@m@footnote@spacing}%
\sideparform\sideparfont%
\ifmemtortm #2\else #1\fi
\end{minipage}%
\vss}%
\vtop to 0pt{\kern\sideparvshift% default should be 0pt
\kern-\dp\strutbox
\kern-\ht0
\box0 \vss}}}%
\@esphack}
% \end{macrocode}
% \end{macro}
% \end{macro}
% Vertical shift for sidepar to align with text line
% \begin{macrocode}
\newlength{\sideparvshift}
\setlength{\sideparvshift}{0pt}
%%%% \setlength{\sideparvshift}{-2.08ex}% seems to work for all font sizes
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Sidebars}
%
% \changes{v1.1}{2002/03/19}{Added experimental code for sidebars}
%
% On 2002/10/22 Donald Arseneau posted the following code to \ctt{} for adding
% sidebars to plain TeX.
% \begin{verbatim}
% \newinsert\sideins
% \skip\sideins=0pt
% \count\sideins=0
% \dimen\sideins=2in
%
% \def\sidebarvsep{25pt}
% \def\sidebarhsep{15pt}
%
% \let\mainpagecontents\pagecontents
%
% \def\sidecontents{%
% \ifvoid\sideins\else
% {\advance\hsize\sidebarhsep
% \moveright\hsize \vtop to0pt{%
% \vskip-\sidebarvsep \vskip\topskip % offset by difference
% \unvbox\sideins \vss}%
% }\fi}
% \def\pagecontents{\sidecontents\mainpagecontents}
% \long\def\sidebar#1{
% \insert\sideins{%
% \splittopskip\sidebarvsep\relax
% \hsize 1.5in \rightskip=0pt plus 20pt \it
% \noindent \vbox to \sidebarvsep{}\ignorespaces #1%
% \ifhmode \unskip\strut\fi \par
% }%
% }
%
% \end{verbatim}
%
% The following started off (2002/03/19) as my attempt to rewrite the above
% into a form suitable for LaTeX, and this class in particular.
%
% Donald Arseneau came up with some improvements to my sidebar code.
% The impetus
% for this came from a CTT thread, \textit{whitespace after my command},
% 2006/11/30 and earlier. In email to me on 2006/11/30 he said:
% \begin{quotation}
% For \Lpack{memoir} \cs{sidebar}, it seems the rules are expanding
% to fill the space for the sidebar, so here is my suggested change
% to \cs{sidecontents}.
%
% It occurs to me that a separate \cs{sidetsep} (or \cs{sidetopsep})
% would be more valuable than having an explicit 1\cs{onelineskip}.
%
% I grouped common code into two macros, and altered \cs{sidebarform} too.
% \end{quotation}
%
% Since then we have been going back and forth, with the result that
% practically all the complex code is Donald's.
% \changes{v1.61803}{2008/01/30}{Major rewrite of \cs{sidebar} code
% (mempatch v4.6 and v4.9)}
%
%
% \begin{macro}{\sideins}
% Create a new insert called \cs{sideins}, which also creates a corresponding
% skip, count, dimen, and box. \\
% \verb?\skip\sideins? is the extra vertical space to allow on the page for
% the insert, \\
% \verb?\count\sideins? is the magnification factor for page breaking, \\
% \verb?\dimen\sideins? is the maximum insertion size (height) per page, \\
% and the inserted material will be in \verb?\box\sideins? when a page is output.
% \begin{macrocode}
\newinsert\sideins
\skip\sideins=0pt
\count\sideins=0
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidebartopsep}
% Separation at the top of a sidebar.
% \begin{macrocode}
\newlength{\sidebartopsep}
\setlength{\sidebartopsep}{0pt}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\setsidebarheight}
% The macro \cs{setsidebarheight}\marg{length} sets the total
% height of sidebars on a page to \meta{length}.
% This is an interface for controlling \verb?\dimen\sideins? properly,
% taking account of \cs{topskip} and the sidebar font size (and therefore
% should be invoked \emph{after} declaring \cs{sidebarfont}).
%
% Note that \cs{sidebartopsep} is \emph{not} included as part of the
% allocated height.
% \begin{macrocode}
\newcommand{\setsidebarheight}[1]{%
\setlength{\dimen\sideins}{#1}%
\advance\dimen\sideins-\topskip
\advance\dimen\sideins\ht\strutbox}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidebarhsep}
% \begin{macro}{\sidebarvsep}
% \begin{macro}{\sidebarwidth}
% The length \cs{sidebarhsep} is the gap between the typeblock and the sidebar.
% \cs{sidebarvsep} is the vertical gap between sidebars on a page.
% The maximum number of sidebar lines on a page is
% \verb?1 + (\dimen\sideins - \sidebarvsep)?, assuming \verb?\dimen\sideins?
% is defined in terms of \cs{onelineskip}.
% The width of the sidebar is \cs{sidebarwidth}.
% \begin{macrocode}
\newlength{\sidebarhsep}
\newlength{\sidebarvsep}
\newlength{\sidebarwidth}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sidebarfont}
% The font for typesetting the contents of a sidebar.
% \changes{v1.61803398d}{2010/02/05}{Added a default for \cs{sidebarfont}}
% \begin{macrocode}
\newcommand{\sidebarfont}{\normalfont\normalsize}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setsidebars}
% \cs{setsidebars}\marg{hsep}\marg{width}\marg{vsep}\marg{topsep}\marg{font}\marg{height}
% sets the main \cs{sidebar} parameters. A \verb?*? argument means leave the
% setting as is.
% \changes{v1.61803}{2008/01/30}{Added \cs{setsidebars} (mempatch v4.6)}
% \begin{macrocode}
\newcommand*{\setsidebars}[6]{%
\nametest{#1}{*}\ifsamename\else
\setlength{\sidebarhsep}{#1}\@memznegtest{\sidebarhsep}%
\fi
\nametest{#2}{*}\ifsamename\else
\setlength{\sidebarwidth}{#2}\@memznegtest{\sidebarwidth}%
\fi
\nametest{#3}{*}\ifsamename\else
\setlength{\sidebarvsep}{#3}\@memnegtest{\sidebarvsep}%
\fi
\nametest{#4}{*}\ifsamename\else
\setlength{\sidebartopsep}{#4}%
\fi
\nametest{#5}{*}\ifsamename\else
\def\sidebarfont{#5}%
\fi
\nametest{#6}{*}\ifsamename\else
\setsidebarheight{#6}%
\ifdim\dimen\sideins>\z@\else
%%%% \@memerror{\protect\sidebarheight\space is zero or negative}{\@ehd}%
\@memwarn{\protect\sidebarheight\space is zero or negative}%
\fi
\fi}
\setsidebars{\marginparsep}% sidebarhsep
{\marginparwidth}% sidebarwidth
{\onelineskip}% sidebarvsep
{0pt}% sidebartopsep
{\normalsize\normalfont}% sidebarfont
{\textheight}% sidebarheight
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\sidebarform}
% \cs{sidebarform} sets the `raggedness' in a sidebar. The current definition
% is less ragged than \cs{raggedright}. Examples:
% \begin{verbatim}
% for flushleftright \renewcommand{\sidebarform}{}
% for raggedleft \renewcommand{\sidebarform}{\raggedleft}
% \end{verbatim}
% \changes{v1.4}{2003/11/22}{Added \cs{sidebarform} (from patch v1.5)}
% \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{sidebarform}}
% \changes{v1.61803398d}{2010/02/05}{changed to make the text flush
% against the text}
% \begin{macrocode}
\newcommand{\sidebarform}{%\rightskip=\z@ \@plus 2em}
%\memRTLrightskip=\z@ \@plus 2em
\ifmemtortm\raggedright\else\raggedleft\fi%
% \ifmemtortm\memRTLrightskip=\z@ \@plus 2em\else\memRTLleftskip=\z@ \@plus 2em\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifsidebaroneside}
% Flag for oneside.
% \changes{v1.61}{2004/04/05}{Added \cs{ifsidebaroneside}}
% \changes{v1.61803398d}{2010/02/07}{flaged as deprecated, the macro
% is not used at all, kept just to ensure that documents does not
% crash, TO BE DELETED}
% \begin{macrocode}
\newif\ifsidebaroneside
\if@twoside\sidebaronesidefalse\else\sidebaronesidetrue\fi
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidebarmargin}
% \begin{macro}{\m@msidebar@margin}
% \changes{v1.61803398d}{2010/02/07}{removed the mention of
% \cs{sidebaroneside}, as it is deprecated}
% \cs{sidebarmargin}\marg{side} sets the side where sidebars will be printed.
% Valid arguments are: left, right, outer, or inner.
%
% \changes{v1.618}{2005/09/03}{Added \cs{sidebarmargin} (mempatch v3.2)}
% \changes{v1.61803398d}{2010/01/25}{Changed to match new general interface}
% \begin{macrocode}
\newcommand*{\sidebarmargin}[1]{%
\m@msetm@argin{#1}%
\ifnum\m@mm@argin<\z@
\@memwarn{Bad \string\sidebarmargin\space argument `#1'\MessageBreak
set to `outer'}%
\gdef\m@msidebar@margin{2}% set as outer
\else
\global\let\m@msidebar@margin\m@mm@argin
\fi}
%%%% default outer
\gdef\m@msidebar@margin{2}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@sideb@left}
% \begin{macro}{\m@sideb@right}
% Code used later to put sidebars into the desired margin.
% \changes{v1.61803}{2008/01/30}{Added \cs{m@sideb@left} and \cs{m@sideb@right}
% (mempatch v4.6)}
% \begin{macrocode}
\newcommand*{\m@sideb@left}{%
\@tempdimc \sidebarwidth
\advance\@tempdimc\sidebarhsep
\kern-\@tempdimc}
\newcommand*{\m@sideb@right}{%
\@tempdimc \columnwidth% or \hsize
\advance\@tempdimc\sidebarhsep
\kern\@tempdimc}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sidecontents}
% This locates the horizontal position of a sidebar. On two column
% pages it is put in the margin next to the column where \cs{sidebar}
% is called, otherwise it is put in the outer (foredge) margin, except
% for the oneside option when it is put into the right hand margin.
% This can be separately controlled via \cs{ifsidebaroneside}.
% Emanuele Vicentini\footnote{\texttt{emanuelevicentini@yahoo.it},
% private email, 2004/04/05}
% suggested to code for the oneside option.
% \changes{v1.61}{2004/04/05}{Changed \cs{sidecontents} for oneside option}
% \changes{v1.618}{2005/09/03}{Changed \cs{sidecontents} for \cs{sidebarmargin}}
% \changes{v1.61803}{2008/01/30}{Modified \cs{sidecontents} (mempatch v4.6)}
% \changes{v1.61803398d}{2010/01/15}{changed to use
% \cs{m@mwhich@margin} for determining wheter to move right ot left}
% \begin{macrocode}
\newcommand{\sidecontents}{\hbox to \z@{%
\m@mwhich@margin{\m@msidebar@margin}%
\ifmemtortm
\m@sideb@right
\else
\m@sideb@left
\fi
% \end{macrocode}
% DA and I have gone to and fro on the next bit of code trying to get
% the top alignment correct.
% \begin{verbatim}
% \vtop to0pt{%
% \vskip\onelineskip
% \unvbox\sideins \vss}%
% \end{verbatim}
% DA has the last word.
% \begin{macrocode}
\vtop to0pt{%
\normalsize\normalfont\sidebarfont% select font so we know the strut size
\vskip\topskip \vskip-\ht\strutbox
\vskip\sidebartopsep% extra vertical shift
\unvbox\sideins \vss}%
\hss}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidebar}
% \cs{sidebar}\marg{text} puts \meta{text} into a sidebar.
%
% Florence Henry (\texttt{florence.henry@obspm.fr}) in the thread
% \textit{Of memoir, sidebar, and justification}, 2003/04/02, pointed
% out that \texttt{itemize} in a \cs{sidebar} could overflow. DA gave the
% solution hint.
%
% DA says that having stacked insertions position properly is difficult.
% Here he uses the size of the strut to regulate both the height and the
% depth of each insertion (much as for footnotes). The following is his
% code and commentary.
% \changes{v1.4}{2003/11/22}{Revised \cs{sidebar}}
% \changes{v1.61803}{2008/01/30}{DA's rewrite of \cs{sidebar} (mempatch v4.6)}
% \begin{macrocode}
\newcommand{\sidebar}[1]{%
\insert\sideins{%
% \end{macrocode}
% Begin the insertion with settings. The height of the strut box
% (dependant on the font) will determine the top alignment both initially
% and after a page break. The setting for maximum depth does not control
% anything; see the code further on instead.
% \changes{v1.61803398d}{2010/02/05}{removed
% \cs{normalfont}\cs{normalsize}, as these are now in the \cs{sidebarfont}}
% \changes{v3.6h}{2010/10/29}{the text should have the same baseline
% stretch as the rest of the page notes.}
% \begin{macrocode}
\hsize\sidebarwidth
\@parboxrestore
\def\baselinestretch{\m@m@footnote@spacing}%
% \end{macrocode}
% \changes{v1.61803398d}{2010/02/05}{Added margin placement check
% inside \cs{sidebar}}
% Even though the margin placement is handled inside
% \cs{sidecontents}, there are some timming issues such that
% \cs{ifmemtortm} is executed too late for \cs{sidebar}s internals to
% make use of it. Fixed by adding the margin check to \cs{sidebar} as well.
% \begin{macrocode}
\m@mwhich@margin{\m@msidebar@margin}%
\sidebarform\sidebarfont
\splittopskip=\ht\strutbox
\splitmaxdepth=\dp\strutbox % doesn't do anything useful
% \end{macrocode}
% Allow a free split at the top (so this whole insertion moves
% to the next page if it does not fit).
% \begin{macrocode}
\allowbreak
% \end{macrocode}
% Control the (vertical) positioning of non-split entries. Footnotes (and
% previous versions of \cs{sidebar}) us a strut at the beginning of the text,
% but we will allow a baseline-skip to perform the same function. This
% method also introduces a \cs{parskip} when the paragraph begins, so we
% counteract that. (The problem with an initial strut is that it messes'
% up entries that begin with vertical space.)
% \begin{macrocode}
\prevdepth=\dp\strutbox % supersedes a "top-strut"
\vskip-\parskip
% \end{macrocode}
% Now the user's sidebar entry:
% \begin{macrocode}
#1%
% \end{macrocode}
% If the entry ended still in a paragraph, take the chance to insert a
% final strut; then end the paragraph.
% \begin{macrocode}
\ifvmode\else
\unskip\@finalstrut\strutbox
\fi\par
% \end{macrocode}
% Explicitly force the effect of \cs{maxdepth} (\cs{splitmaxdepth}),
% but using the depth of the strut in the r\^{o}le of \cs{maxdepth}.
% \begin{macrocode}
\ifdim\prevdepth>\dp\strutbox \prevdepth=\dp\strutbox \fi
% \end{macrocode}
% Now control how adjacent entries abut (whether or not a final strut got
% inserted) and how an entry fits at the bottom of the page. Use \cs{vskip}s
% to move from the text bottom to where a strut would bottom out,
% but insert an allowed breakpoint at the baseline position
% (so that the entry baseline may match the page's baseline). Finally
% insert the extra separation between entries.
% \begin{macrocode}
\ifdim\prevdepth>99\p@
\nobreak
\vskip-\prevdepth
\allowbreak
\vskip\dp\strutbox
\fi
\vskip\sidebarvsep}}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Footnotes}
%
% For my reference, in case I want to fiddle with it even more
% than I have already done so, here is the kernel code (from \file{ltfloat.dtx})
% for footnotes.
% \DescribeMacro{\footins}
% The insert for footnotes.
% \begin{verbatim}
% \newinsert\footins
% \skip\footins=\bigskipamount
% \count\footins=1000
% \dimen\footins=8in
% \end{verbatim}
%
% \DescribeMacro{\footnoterule}
% Draws the rule separating footnotes from the main text. It is executed
% after a \cs{vspace} of \verb?\skip\footins? and should take no vertical
% space.
% \begin{verbatim}
% \def\footnoterule{\kern-3\p@ \hrule \@width 2in \kern 2.6\p@}
%
% \@definecounter{footnote}
% \def\thefootnote{\@arabic\c@footnote}
% \@definecounter{mpfootnote}
% \def\thempfootnote{\itshape\@alph\c@mpfootnote}
% \end{verbatim}
%
% \DescribeMacro{\@makefnmark}
% Generates the footnote marker from \cs{@thefnmark}.
% \begin{verbatim}
% \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\@thefnmark}}}
%
% \DeclareRobustCommand*\textsuperscript[1]{%
% \@textsuperscript{\selectfont#1}}
% \def\@textsuperscript#1{%
% {\m@th\ensuremath{^{\mbox{\fontsize\sf@size\z@#1}}}}}
%
% \newdimen\footnotesep
% \end{verbatim}
%
% \DescribeMacro{\footnote}
% \cs{footnote}\oarg{num}\marg{text} is what the user uses for footnoting.
% It defines \cs{@thefnmark} and calls \cs{@footnotemark} and
% \cs{@footnotetext} to do the work.
% \begin{verbatim}
% \def\footnote{\@ifnextchar[\@xfootnote{\stepcounter\@mpfn
% \protected@xdef\@thefnmark{\thempfn}%
% \@footnotemark\@footnotetext}}
% \end{verbatim}
%
% \DescribeMacro{\@xfootnote}
% Handles the optional \meta{num} argument to \cs{footnote}.
% It defines \cs{@thefnmark} and calls \cs{@footnotemark} and
% \cs{@footnotetext} to do the work.
% \begin{verbatim}
% \def\@xfootnote[#1]{%
% \begingroup
% \csname c@\@mpfn\endcsname #1\relax
% \unrestored@protected@xdef\@thefnmark{\thempfn}%
% \endgroup
% \@footnotemark\@footnotetext}
% \end{verbatim}
%
% \DescribeMacro{\@footnotetext}
% \cs{@footnotetext}\marg{text} sets up for typeseting the footnote
% (at the bottom of the page). It calls \cs{@makefntext}\marg{text}
% to actually do the typesetting (\cs{@makefntext} has to be supplied
% by a class or package).
% \begin{verbatim}
% \long\def\@footnotetext#1{%
% \insert\footins{%
% \reset@font\footnotesize
% \interlinepenalty\interfootnotelinepenalty
% \splittopskip\footnotesep
% \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
% \hsize\columnwidth \@parboxrestore
% \protected@edef\@currentlabel{%
% \csname p@footnote\endcsname\@thefnmark}%
% \color@begingroup
% \@makefntext{%
% \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
% \color@endgroup}}
% \end{verbatim}
%
% \DescribeMacro{\footnotemark}
% \cs{footnotemark}\oarg{num} the user uses this to produce just a
% footnote mark in the text.
% \begin{verbatim}
% \def\footnotemark{%
% \@ifnextchar[\@xfootnotemark
% {\stepcounter{footnote}%
% \protected@xdef\@thefnmark{\thefootnote}%
% \@footnotemark}}
% \end{verbatim}
%
% \DescribeMacro{\@xfootnotemark}
% Handles the optional \meta{num} argument to \cs{footnotemark}.
% \begin{verbatim}
% \def\@xfootnotemark[#1]{%
% \begingroup
% \c@footnote #1\relax
% \unrestored@protected@xdef\@thefnmark{\thefootnote}%
% \endgroup
% \@footnotemark}
% \end{verbatim}
%
% \DescribeMacro{\@footnotemark}
% Typesets the mark in the main text, via \cs{@makefnmark}.
% \begin{verbatim}
% \def\@footnotemark{%
% \leavevmode
% \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
% \@makefnmark
% \ifhmode\spacefactor\@x@sf\fi
% \relax}
% \end{verbatim}
%
% \DescribeMacro{\footnotetext}
% \cs{footnotetext}\oarg{num}\marg{text} is user view for creating a footnote
% without a marker in the main text.
% \begin{verbatim}
% \def\footnotetext{%
% \@ifnextchar [\@xfootnotenext
% {\protected@xdef\@thefnmark{\thempfn}%
% \@footnotetext}}
% \end{verbatim}
%
% \DescribeMacro{\@xfootnotetext}
% Handles the optional \meta{num} argument to \cs{footnotetext}.
% \begin{verbatim}
% \def\@xfootnotenext[#1]{%
% \begingroup
% \csname c@\@mpfn\endcsname #1\relax
% \unrestored@protected@xdef\@thefnmark{\thempfn}%
% \endgroup
% \@footnotetext}
% \end{verbatim}
%
% \DescribeMacro{\@mpfn}
% \DescribeMacro{\thempfn}
% \begin{verbatim}
% \def\@mpfn{footnote}
% \def\thempfn{\thefootnote}
% \end{verbatim}
%
% And from \file{ltboxes.dtx} for the \texttt{minipage} environment.
%
% \DescribeMacro{\@mpfn}
% \DescribeMacro{\thempfn}
% \DescribeMacro{\@footnotetext}
% When setting up
% the environment, it includes:
% \begin{verbatim}
% \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
% \let\@footnotetext\@mpfootnotetext
% \end{verbatim}
%
% \DescribeMacro{\@mpfootnotetext}
% Later it defines \cs{@mpfootnotetext}\marg{text} as the minipage version
% of \cs{@footnotetext}.
% \begin{verbatim}
% \long\def\@mpfootnotetext#1{%
% \global\setbox\@mpfootins\vbox{%
% \unvbox\@mpfootins
% \reset@font\footnotesize
% \hsize\columnwidth
% \@parboxrestore
% \protected@edef\@currentlabel{%
% \csname p@mpfootnote\endcsname\@thefnmark}%
% \color@begingroup
% \@makefntext{%
% \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
% \color@endgroup}}
% \end{verbatim}
%
% That completes the kernel extracts.
%
% \begin{macro}{\footnoterule}
% Usually, footnotes are separated from the main body of the text
% by a small rule. This rule is drawn by the macro \cs{footnoterule}.
% We have to make sure that the rule takes no vertical space (see
% \file{plain.tex}) so we compensate for the natural heigth of the
% rule of 0.4pt by adding the right amount of vertical skip.
%
% To prevent the rule from colliding with the footnote we first add
% a little negative vertical skip, then we put the rule and make
% sure we end up at the same point where we begun this operation.
% \changes{v3.6k}{2013/05/08}{Added \cs{normalcolor}, this seems to
% fix a color leak into paragraph footnotes.}
% \begin{macrocode}
\renewcommand{\footnoterule}{%
\kern-3\p@
\normalcolor% added 2013/05/08
\hrule width .4\columnwidth
\kern 2.6\p@}
% \end{macrocode}
% And just to make sure that we are using memoir's font-dependent
% skips:
% \begin{macrocode}
\skip\footins=\bigskipamount
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@footnote}
% Footnotes are numbered per chapter. The counter is predefined.
% \begin{macrocode}
\@addtoreset{footnote}{chapter}
% \end{macrocode}
% \end{macro}
%
% The footnote mechanism of \LaTeX{} calls the macro \cs{@makefntext}
% to produce the actual footnote. The macro gets the text of the
% footnote as its argument and should use \cs{@thefnmark} as the mark
% of the footnote. The macro \cs{@makefntext} is called when
% effectively inside a \cs{parbox} of width \cs{columnwidth} (i.e.,
% with \cs{hsize} = \cs{columnwidth}).
%
% An example of what can be achieved is given by the following piece
% of \TeX{} code.
% \begin{verbatim}
% \long\def\@makefntext#1{%
% \@setpar{\@@par
% \@tempdima = \hsize
% \advance\@tempdima-10pt
% \parshape \@ne 10pt \@tempdima}%
% \par
% \parindent 1em\noindent
% \hbox to \z@{\hss\@makefnmark}#1}
% \end{verbatim}
% The effect of this definition is that all lines of the footnote
% are indented by 10pt, while the first line of a new paragraph is
% indented by 1em. To change these dimensions, just substitute the
% desired value for `10pt' (in both places) or `1em'. The mark is
% flushright against the footnote.
%
% The standard classes use a simpler macro, in which the
% footnote text is set like an ordinary text paragraph, with no
% indentation except on the first line of a paragraph, and the
% first line of the footnote. Thus, all the macro must do is set
% \cs{parindent} to the appropriate value for succeeding paragraphs
% and put the proper indentation before the mark.
% \begin{verbatim}
% \newcommand{\@makefntext}[1]{%
% \parindent 1em%
% \noindent
% \hb@xt@1.8em{\hss\@makefnmark}#1}
% \end{verbatim}
%
% This class provides a configurable specification.
%
% Normally, if two or more footnotes are sequentially applied: \\
% \verb?...text\footnote{first}\footnote{second}...? \\
% the markers in the text run together
% (e.g., \ldots text\textsuperscript{12}).
% The class provides a separator between the markers
% (e.g., \ldots text\textsuperscript{1,2}).
% The underlying ideas for this are from the \Lpack{ledmac}
% package~\cite{LEDMAC},
% which in turn got them from the \Lpack{footmisc} package~\cite{FOOTMISC}.
% \changes{v1.4}{2003/11/22}{Added footnote separator (from patch v1.5)}
%
% \begin{macro}{\multfootsep}
% The separator between multiple footnote markers.
% \begin{macrocode}
\newcommand*{\multfootsep}{\textsuperscript{\normalfont,}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\multiplefootnotemarker}
% \begin{macro}{\m@mmf@prepare}
% \cs{m@mmf@prepare} is a pair of self-cancelling kerns.
% \begin{macrocode}
\newcommand*{\multiplefootnotemarker}{3sp}
\newcommand*{\m@mmf@prepare}{%
\kern-\multiplefootnotemarker
\kern\multiplefootnotemarker\relax}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mmf@check}
% If \cs{m@mmf@check} recognises the last kern as \cs{multiplefootnotemarker}
% it typesets \cs{multfootsep}.
% \begin{macrocode}
\newcommand*{\m@mmf@check}{%
\ifdim\lastkern=\multiplefootnotemarker\relax
\edef\@x@sf{\the\spacefactor}%
\unkern
\multfootsep
\spacefactor\@x@sf\relax
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@footnotemark}
% We have to modify the kernel's % \cs{@footnotetext} and
% \cs{@footnotemark}
% to implement the separator.
% \changes{v1.618}{2005/09/03}{Stop body font changes leaking into footnotes (mempatch v3.7)}
% \changes{v1.61803}{2008/01/30}{Keep single spacing in footnotes (mempatch v4.6)}
% \changes{v3.6g}{2010/09/19}{Made the 'single spacing' configurable.}
% \changes{v3.6h}{2010/20/22}{\cs{@footnotetext} is redefined later
% on, so the \cs{m@mold@footnotetext} needs to be moved, we also
% remove this version of \cs{@footnotetext} such that people do
% not mistake this for the `real' \cs{@footnotetext}}.
% \begin{macrocode}
\renewcommand*{\@footnotemark}{%
\leavevmode
\ifhmode
\edef\@x@sf{\the\spacefactor}%
\m@mmf@check
\nobreak
\fi
\@makefnmark
\m@mmf@prepare
\ifhmode\spacefactor\@x@sf\fi
\relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@pn@multiple@marker}
% This controls the multiple marker handling for successive page
% notes, i.e., adding a comma between them.
% \changes{v3.6k}{2013/05/16}{Added hooks, they are not intended for users}
% \begin{macrocode}
\newcommand{\mem@pn@multiple@marker}[1]{%
\leavevmode
\ifhmode
\edef\@x@sf{\the\spacefactor}%
\m@mmf@check
\nobreak
\fi
\@nameuse{mem@pnmm@start@hook}%
#1%
\@nameuse{mem@pnmm@end@hook}%
\m@mmf@prepare
\ifhmode\spacefactor\@x@sf\fi
\relax}
% \end{macrocode}
%
% \end{macro}
% %
% \begin{macro}{\footmarkwidth}
% \begin{macro}{\footmarksep}
% \begin{macro}{\footparindent}
% The mark is typset right justified in a box with width \cs{footmarkwidth}.
% Second and later lines of the text are offset \cs{footmarksep} from the
% end of the box. Paragraphs in footnotes are indented by \cs{parindent}.
% \begin{macrocode}
\newlength{\footmarkwidth}
\newlength{\footmarksep}
\newlength{\footparindent}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\footmarkstyle}
% \begin{macro}{\footscript}
% The marker is typeset according to \cs{footscript}\marg{marker}. This
% can be specified by the user via \cs{footmarkstyle}.
% \begin{macrocode}
\newcommand*{\footmarkstyle}[1]{\def\footscript##1{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\makefootmarkhook}
% A vacuous macro that the user can redefine to do something useful?
% \begin{macrocode}
\newcommand{\makefootmarkhook}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\footfootmark}
% This macro typesets the footnote marker.
% \begin{macrocode}
\newcommand{\footfootmark}{%
\ifdim\footmarkwidth < \z@
% \end{macrocode}
% Negative width, mark is in the margin.
% \begin{macrocode}
\llap{\hb@xt@ -\footmarkwidth{%
\hss\normalfont\footscript{\@thefnmark}}%
\hspace*{-\footmarkwidth}}%
\else
\ifdim\footmarkwidth = \z@
% \end{macrocode}
% Zero width, mark is at (inside) the margin.
% \begin{macrocode}
{\normalfont\footscript{\@thefnmark}}%
\else
% \end{macrocode}
% Positive width.
% \begin{macrocode}
\hb@xt@\footmarkwidth{\hss\normalfont\footscript{\@thefnmark}}%
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makefootmark}
% \begin{macro}{\@makefntext}
% The class version of \cs{@makefntext}.
% \begin{macrocode}
\newcommand{\makefootmark}[1]{%
\leavevmode
\parindent \footparindent\noindent
\leftskip\footmarksep\relax
\advance\leftskip \footmarkwidth \null\nobreak\hskip -\leftskip\relax
\makefootmarkhook\relax
\footfootmark #1}
% \end{macrocode}
% In the thread \textit{memoir and footnote.sty trouble}, 2003/04/02,
% Patrik Nyman (\texttt{patrik.nyman@orient.su.se}) noted that in order
% to stop \file{footnote.sty} (from \texttt{mdwtools}) barfing my original \\
% \verb?\newcommand{\@makefntext}[1]{\makefootmark{#1}}? \\
% had to be changed.
% \changes{v1.4}{2004/11/22}{Revised \cs{@makefntext}}
% \begin{macrocode}
\newcommand{\@makefntext}[1]{\makefootmark #1}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% All that now remains for the footer part is to set the defaults.
% \begin{macrocode}
\footmarkstyle{\textsuperscript{#1}}
\setlength{\footmarkwidth}{1.8em}
\setlength{\footmarksep}{-1.8em}
\setlength{\footparindent}{1em}
% \end{macrocode}
%
% \begin{macro}{\@makefnmark}
% The footnote markers that are printed in the text to point to the
% footnotes should be produced by the macro \cs{@makefnmark}. We use
% the default definition for it.
% \begin{macrocode}
%\renewcommand\@makefnmark{\hbox{\@textsuperscript{%
% \normalfont\@thefnmark}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\footref}
% Sometimes it is desireable to reference a footnote more than
% once.
% If a footnote is labelled (e.g., \verb?\footnote{text\label{fn}}?) then
% the macro \cs{footref}\marg{fn} will print the footnote marker.
% The code is essentially a much simplified version of \cs{footnotemark}
% from \file{ltfloat.dtx}.
% \changes{v1.0}{2001/10/30}{Added \cs{footref}}
% \begin{macrocode}
% \changes{v3.7o}{2021/02/24}{in 2021/05 \cs{footref} will be in the
% kernel, thus we make it provide}
\providecommand{\footref}[1]{%
\begingroup
\unrestored@protected@xdef\@thefnmark{\ref{#1}}%
\endgroup
\@footnotemark}
% \end{macrocode}
% \end{macro}
%
% The following code for footnotes that can include verbatims is based
% on Jeremy Gibbons \textit{`Footnotes with verbatim material'}
% in the column \textit{`Hey --- it works'} (edited by Jeremy Gibbons),
% TeX and TUG NEWS, vol 2 no. 4, p 9, October 1993. I have updated
% the basic code so that it works for LaTeX2e.
%
% \begin{macro}{\verbfootnote}
% \begin{macro}{\@xverbfootnote}
% \cs{verbfootnote} is just like \cs{footnote} except that it can contain
% verbatim material.
% \begin{macrocode}
\def\verbfootnote{\@ifnextchar[\@xverbfootnote{\stepcounter\@mpfn
\protected@xdef\@thefnmark{\thempfn}%
\@footnotemark\@verbfootnotetext}}
\def\@xverbfootnote[#1]{%
\begingroup
\csname c@\@mpfn\endcsname #1\relax
\unrestored@protected@xdef\@thefnmark{\thempfn}%
\endgroup
\@footnotemark\@verbfootnotetext}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@verbfootnotetext}
% This is the secret ingredient. It is based on the \cs{footnote} macro
% in \theTeXbook{} page 363, which somehow manages to read an argument
% with verbatims. As Knuth says that it is subtle and involves trickery,
% don't expect me to even try to explain anything.
%
% I'm not at all sure about the color bits, though!
% \changes{v1.618}{2005/09/02}{Fixed colors in \cs{verbfootnote} (mempatch v2.3)}
% \begin{macrocode}
\long\def\@verbfootnotetext{%
\insert\footins\bgroup
\footnotesize
\interlinepenalty\interfootnotelinepenalty
\splittopskip\footnotesep
\splitmaxdepth \dp\strutbox \floatingpenalty \@MM
\hsize\columnwidth \@parboxrestore
\edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
%%%% \color@begingroup
\@makefntext{\rule{\z@}{\footnotesep}\ignorespaces}%
\futurelet\next\fo@t
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fo@t}
% \begin{macro}{\f@@t}
% \begin{macro}{\f@t}
% \begin{macro}{\@foot}
% Guess what these do.
% \changes{v1.61803}{2008/01/30}{Added \cs{m@mmf@prepare} to \cs{@foot} to
% implement the multifootnotemark separator (noted by zarko, CTT 2005/01/15)}
% \begin{macrocode}
\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
\else \let\next\f@t\fi \next}
\def\f@@t{\bgroup\aftergroup\@foot\let\next}
\def\f@t#1{%
\color@begingroup
#1\@foot
\color@endgroup}
\def\@foot{%
\strut\egroup
%%%% \color@endgroup
\m@mmf@prepare
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@verbmpfootnotetext}
% Footnotes in minipages are a little different, so another
% version of \cs{...footnotetext}.
% \begin{macrocode}
\long\def\@verbmpfootnotetext{%
\global\setbox\@mpfootins\vbox{%
\reset@font\footnotesize
\unvbox\@mpfootins
\bgroup
\hsize\columnwidth
\@parboxrestore
\edef\@currentlabel{\csname p@mpfootnote\endcsname\@thefnmark}%
\color@begingroup
\@makefntext{\rule{\z@}{\footnotesep}\ignorespaces}%
}
\futurelet\next\fo@t
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@minipagerestore}
% To get the \cs{verbfootnote} to work in a \texttt{minipage} we have to use
% \cs{@verbmpfootnotetext} instead of \cs{@verbfootnotetext}. There is
% a nice hook in the kernel \texttt{minipage} code for this.
%
% As of version 1.61803 the following code is placed earlier. \\
% \verb?\def\@minipagerestore{\let\@verbfootnotetext\@verbmpfootnotetext}?
% \end{macro}
%
%
% \subsection{Major extensions for footnotes}
%
% \begin{macrocode}
%%%%%%%%%%%%%% major extension to footnoting
% \end{macrocode}
%
% This all requires modifications to the output routine's \cs{@makecol},
% which will be done later.
%
% \begin{macro}{\setfootnoterule}
% Per Starb\"{a}ck found (CTT \textit{feetbelowfloat in memoir}, 2006/11/24)
% that \cs{feetbelowfloat} did not affect anything when \cs{raggedbottom}
% is in effect.
%
% \cs{setfootnoterule}\oarg{vfill}\marg{uplift}\marg{width}\marg{thickness}
% defines the \cs{footnoterule}. Memoir's default setting is \\
% \verb?\setfootnoterule{3pt}{0.4\columnwidth}{\normalrulethickness}? \\
% To force footnotes to the bottom after a \cs{raggedbottom} use \\
% \verb?\setfootnoterule[\vfill]{3pt}{0.4\columnwidth}{\normalrulethickness}?
% \changes{v1.61803}{2008/01/30}{Added \cs{setfootnoterule} (memptatch v4.6)}
% \changes{v3.6k}{2013/05/08}{Added \cs{normalcolor}, this seems to
% fix a color leak into paragraph footnotes.}
% \begin{macrocode}
\newcommand*{\setfootnoterule}[4][]{%
\def\footnoterule{\kern -#2\relax #1\relax
\normalcolor% added 2013/05/08
\hrule width #3\relax
\kern #2\kern-#4}}
\setfootnoterule{3pt}{0.4\columnwidth}{\normalrulethickness}
% \end{macrocode}
% \end{macro}
%
% All sorts of extra kinds of footnotes.
%
% \begin{macro}{\m@mdoextrafeet}
% \begin{macro}{\extrafeetins}
% \begin{macro}{\extrafeetinshook}
% These macros are hooks into \cs{@makecol}.
% \changes{v1.618}{2005/09/02}{Fixed memoir/listings spacing problem (from Cartsten Heinz, mempatch v2.3)}
% \changes{v1.618}{2005/09/03}{Set \cs{boxmaxdepth} in \cs{extrafeetins} (mmempatch v3.1)}
% \begin{macrocode}
\newcommand{\m@mdoextrafeet}{\extrafeetins}
\newcommand*{\extrafeetins}{%
\setbox\@outputbox \vbox{%
\boxmaxdepth \@maxdepth
\unvbox\@outputbox
\ifvoid\footinsv@r\else\@footstartv@r\@footgroupv@r\fi
\extrafeetinshook}}
\newcommand{\extrafeetinshook}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mdodoreinextrafeet}
% \begin{macro}{\extrafeetreinshook}
% Hooks into \cs{@reinserts} for multiple footnote kinds.
% \begin{macrocode}
\newcommand{\m@mdodoreinextrafeet}{%
\ifvoid\footinsv@r\else\insert\footinsv@r{\unvbox\footinsv@r}\fi
\extrafeetreinshook}
\newcommand{\extrafeetreinshook}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \begin{macro}{\foottextfont}
% \begin{macro}{\footinsdim}
% \begin{macro}{\@preamfntext}
% General macros.
% \begin{macrocode}
\newcommand{\foottextfont}{\footnotesize}
\newlength{\footinsdim}
\setlength{\footinsdim}{8in} % standard for \dimen\footins
\newcommand{\@preamfntext}{%
\interlinepenalty\interfootnotelinepenalty
\floatingpenalty \@MM
\splittopskip=\footnotesep
\splitmaxdepth=\dp\strutbox
\@parboxrestore}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% We are going to change some of the kernel footnote macros
%
% \begin{macro}{\@mpfootnotetext}
% \begin{macro}{\@plainmpfootnotetext}
% \changes{v1.6180}{2006/06/12}{Stop font changes leaking into footnotes.
% The v1.618 change was too early}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable'}
% \begin{macrocode}
\renewcommand{\@mpfootnotetext}[1]{%
\global\setbox\@mpfootins\vbox{%
\unvbox\@mpfootins
\def\baselinestretch{\m@m@footnote@spacing}%
\foottextfont \hsize\columnwidth \@parboxrestore
\protected@edef\@currentlabel{%
\csname p@mpfootnote\endcsname\@thefnmark}%
\color@begingroup
\reset@font%
\@makefntext{%
\rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
\@finalstrut\strutbox}%
\color@endgroup}}
% \end{macrocode}
% Save our revised version of \cs{@mpfootnotetext}
% \changes{v3.6h}{2010/10/22}{\cs{m@mold@mpfootnotetext} renamed to \cs{@plainmpfootnotetext}}
% \begin{macrocode}
\let\@plainmpfootnotetext\@mpfootnotetext
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% We also to patch the minipage environment. We can use
% \cs{@minipagerestore} for the \texttt{begin} part (done earlier),
% but have to
% modify \cs{endminipage}
%
% \begin{macro}{\m@mdoextrafeetmini}
% \begin{macro}{\extrafeetminihook}
% \begin{macro}{\@minipagerestore}
% \begin{macrocode}
\newcommand{\m@mdoextrafeetmini}{%
\extrafeetminihook}
\newcommand{\extrafeetminihook}{}
%%%%\renewcommand{\@minipagerestore}{\m@mdoextrafeetmini}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\extrafeetendmini}
% \begin{macro}{\extrafeetendminihook}
% \begin{macrocode}
\newcommand{\extrafeetendmini}{%
\ifvoid\@mpfootinsv@r\else
\vskip\skip\@mpfootins
\normalcolor\footnoterule\mp@footgroupv@r
\fi
\extrafeetendminihook}
\newcommand{\extrafeetendminihook}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mdoextrafeetendmini}
% \begin{macro}{\endminipage}
% This is our patched version of \cs{endminipage}.
% \begin{macrocode}
\newcommand{\m@mdoextrafeetendmini}{\extrafeetendmini}
\def\endminipage{%
\par
\unskip
\ifvoid\@mpfootins\else
\vskip\skip\@mpfootins
\normalcolor
\footnoterule
\unvbox\@mpfootins
\fi
\m@mdoextrafeetendmini
\@minipagefalse
\color@endgroup
\egroup
\expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\plainfootnotes}
% The declaration for standard footnotes; easy, just use the saved
% versions of \cs{@footnotetext} and \cs{@mpfootnotetext}.
% \changes{v3.6h}{2010/10/22}{\cs{m@mold@footnotetext} renamed
% \cs{@plainfootnotetext} and \cs{m@mold@mpfootnotetext} as \cs{@plainmpfootnotetext}}
% \begin{macrocode}
\newcommand{\plainfootnotes}{%
\let\@footnotetext\@plainfootnotetext
\let\@mpfootnotetext\@plainmpfootnotetext}
% \end{macrocode}
% \end{macro}
%
% Now for lots of somewhat tedious code, interspersed with complex
% `Dirty Tricks' type things.
%
% Robert Schlicht~\footnote{Private email, 2004/03/12,
% (\texttt{w.m.l@gmx.net})} [RS] has provided valuable help in tuning
% up the code.
%
%
% \begin{macro}{\newfootnoteseries}
% \cs{newfootnoteseries}\marg{series} creates the set of macros required
% for footnote code (see the kernel code presented earlier).
% The created macros have \meta{series} appended to their name.
% \changes{v1.61}{2004/03/14}{Added skip setup to \cs{newfootnoteseries}}
% \changes{v1.61}{2004/03/24}{Use \cs{newcounter} instead of \cs{newcount}
% in \cs{newfootnoteseries}}
% \begin{macrocode}
\newcommand{\newfootnoteseries}[1]{%
\expandafter\newinsert\csname footins#1\endcsname% -> \footins#1
\expandafter\skip\csname footins#1\endcsname \bigskipamount%
%%% - > \skip\footins#1 % [RS]
\newcounter{footnote#1}% -> \c@footnote#1
\@nameuse{c@footnote#1} \z@% -> \c@footnote#1=0
\global\@namelet{p@footnote#1} \@empty% -> \p@footnote#1
\@namedef{thefootnote#1}{\arabic{footnote#1}}% -> \thefootnote#1
\@namedef{foottextfont#1}{\foottextfont}% -> \foottextfont#1
\m@makefootnote{#1}% -> \footnote#1
\m@make@xfootnote{#1}% -> \@xfootnote#1
\m@make@footnotetext{#1}% -> \@footnotetext#1
\m@makefootnotemark{#1}% -> \footnotemark#1
\m@make@xfootnotemark{#1}% -> \@xfootnotemark#1
\m@make@footnotemark{#1}% -> \@footnotemark#1
\m@makefootnotetext{#1}% -> \footnotetext#1
\m@make@xfootnotenext{#1}% -> \@xfootnotenext#1
\m@make@mpfn{#1}% -> \@mpfn#1
\m@makethempfn{#1}% -> \thempfn#1
\m@make@makefnmark{#1}% -> \@makefnmark#1
\m@makefootref{#1}% -> \footref#1
\m@makefootfootmark{#1}% -> \footfootmark#1
\m@makemakefootmark{#1}% -> \makefootmark#1
\m@makefootmarkstyle{#1}% -> \footmarkstyle#1
% \end{macrocode}
% \changes{3.7i}{2019/05/24}{@makefntext\#1 should of course be
% long. Reported on TSE by meide, https://tex.stackexchange.com/q/491303/3929}
% \begin{macrocode}
\@namelongdef{@makefntext#1}##1{\@nameuse{makefootmark#1} ##1}%
\m@make@footstart{#1}% -> \@footstart#1
\m@make@footgroup{#1}% -> \@footgroup#1
\expandafter\newinsert\csname @mpfootins#1\endcsname% -> \@mpfootins#1
\newcounter{mpfootnote#1}% -> \c@mpfootnote#1
\global\@namelet{p@mpfootnote#1}\@empty
\@namedef{thempfootnote#1}{\itshape\alph{mpfootnote#1}}%
\m@make@mpfootnotetext{#1}% -> \@mpfootnotetext#1
% \end{macrocode}
% Reset the counter per chapter, except for articles.
% \changes{v1.6}{2004/03/14}{Added chapter reset for footnote series [RS]}
% \begin{macrocode}
\ifartopt\else% [RS]
\expandafter\@cons\csname cl@chapter\endcsname {{footnote#1}}%
\fi
% \end{macrocode}
% Add the footnote to the (re)insert hooks.
% \begin{macrocode}
\g@addto@macro{\extrafeetinshook}{%
\ifvoid\@nameuse{footins#1}\else
\@nameuse{@footstart#1}\@nameuse{@footgroup#1}\fi}
\g@addto@macro{\extrafeetreinshook}{%
\ifvoid\@nameuse{footins#1}\else
\insert\@nameuse{footins#1}{\unvbox\@nameuse{footins#1}}\fi}
\g@addto@macro{\extrafeetendminihook}{%
\ifvoid\@nameuse{@mpfootins#1}\else
\vskip\skip\@mpfootins
\normalcolor\footnoterule\@nameuse{mp@footgroup#1}\fi}
\g@addto@macro{\extrafeetminihook}{%
\@namedef{@mpfn#1}{mpfootnote#1}
\@namedef{thempfn#1}{\@nameuse{thempfootnote#1}}
\csname c@mpfootnote#1\endcsname\z@
\expandafter\let\expandafter\@t@mp \csname @mpfootnotetext#1\endcsname
\expandafter\let \csname @footnotetext#1\endcsname \@t@mp}
\g@addto@macro{\@mem@extranofeet}{% % [RS]
\ifvoid\@nameuse{footins#1}\else\@mem@nofootfalse\fi}
\plainfootstyle{#1}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@makefootnote}
% \cs{m@makefootnote}\marg{series} creates \cs{footnote<series>}
% \changes{v1.4}{2004/01/21}{In \cs{m@makefootnote} changed \cs{advance}
% to \cs{stepcounter} to make change global}
% \begin{macrocode}
\newcommand{\m@makefootnote}[1]{
\@namedef{footnote#1}{\@ifnextchar[
{\@nameuse{@xfootnote#1}}{%\advance \@nameuse{c@\@mpfn#1} by \@ne
\stepcounter{\@mpfn#1}%
\@name@p@xdef{@thefnmark#1}{\@nameuse{thempfn#1}}%
\@nameuse{@footnotemark#1}\@nameuse{@footnotetext#1}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@xfootnote}
% \cs{m@make@xfootnote}\marg{series} creates \cs{@xfootnote<series>}
% \begin{macrocode}
\newcommand{\m@make@xfootnote}[1]{
\@namedef{@xfootnote#1}[##1]{%
\begingroup
\csname c@\@mpfn#1\endcsname ##1\relax
\@name@unresp@xdef{@thefnmark#1}{\@nameuse{thempfn#1}}%
\endgroup
\@nameuse{@footnotemark#1}\@nameuse{@footnotetext#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@footnotetext}
% \cs{m@make@footnotetext}\marg{series} creates \cs{@footnotetext<series>}
% \changes{v1.6180339a}{2008/08/07}{Removed a space from
% \cs{m@make@footnotetext} and \cs{m@make@mpfootnotetext}
% (courtesy David Wilson)}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\m@make@footnotetext}[1]{%
\@namelongdef{@footnotetext#1}##1{%
\insert\@nameuse{footins#1}{%
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\@nameuse{foottextfont#1}%
\@preamfntext
\hsize\columnwidth
\protected@edef\@currentlabel{%
\csname p@footnote#1\endcsname\@nameuse{@thefnmark#1}}%
\color@begingroup
\@nameuse{@makefntext#1}{%
\rule\z@\footnotesep\ignorespaces{\@nameuse{foottextfont#1}##1}% <- v1.6180339a
\@finalstrut\strutbox}%
\color@endgroup}%
\m@mmf@prepare}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@mpfootnotetext}
% \cs{m@make@mpfootnotetext}\marg{series} creates \cs{@mpfootnotetext<series>}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\m@make@mpfootnotetext}[1]{%
\@namelongdef{@mpfootnotetext#1}##1{%
\global\setbox\@nameuse{@mpfootins#1}\vbox{%
\unvbox\@nameuse{@mpfootins#1}%
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\@nameuse{foottextfont#1}%
\hsize\columnwidth \@parboxrestore
\protected@edef\@currentlabel{%
\csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
\color@begingroup
\@nameuse{@makefntext#1}{%
\rule\z@\footnotesep\ignorespaces{\@nameuse{foottextfont#1}##1}% <- v1.6180339a
\@finalstrut\strutbox}%
\color@endgroup}%
\m@mmf@prepare}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@makefootnotemark}
% \changes{v1.61}{2004/03/24}{Changed \cs{advance} to \cs{stepcounter}
% in \cs{m@makefootnotemark}}
% \cs{m@makefootnotemark}\marg{series} creates \cs{footnotemark<series>}
% \begin{macrocode}
\newcommand{\m@makefootnotemark}[1]{
\@namedef{footnotemark#1}{%
\@ifnextchar[ {\@nameuse{@xfootnotemark#1}}
{%\advance\@nameuse{c@footnote#1} by \@ne%
\stepcounter{footnote#1}%
\@name@p@xdef{@thefnmark#1}{\@nameuse{thefootnote#1}}%
\@nameuse{@footnotemark#1}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@xfootnotemark}
% \cs{m@make@xfootnotemark}\marg{series} creates \cs{@xfootnotemark<series>}
% \begin{macrocode}
\newcommand{\m@make@xfootnotemark}[1]{%
\@namedef{@xfootnotemark#1}[##1]{%
\begingroup
\@nameuse{c@footnote#1} ##1\relax
\@name@unresp@xdef{@thefnmark#1}{\@nameuse{thefootnote#1}}%
\endgroup
\@nameuse{@footnotemark#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@footnotemark}
% \cs{m@make@footnotemark}\marg{series} creates \cs{@footnotemark<series>}
% \begin{macrocode}
\newcommand{\m@make@footnotemark}[1]{%
\@namedef{@footnotemark#1}{%
\leavevmode
\ifhmode
\edef\@x@sf{\the\spacefactor}%
\m@mmf@check
\nobreak
\fi
\@nameuse{@makefnmark#1}%
\m@mmf@prepare
\ifhmode\spacefactor\@x@sf\fi
\relax}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@makefootmarkstyle}
% \cs{m@makefootmarkstyle}\marg{series} creates \cs{footmarkstyle<series>}
% \begin{macrocode}
\newcommand{\m@makefootmarkstyle}[1]{%
\@namedef{footmarkstyle#1}##1{%
\@namedef{footscript#1}####1{##1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@makefootnotetext}
% \cs{m@makefootnotetext}\marg{series} creates \cs{footnotetext<series>}
% \begin{macrocode}
\newcommand{\m@makefootnotetext}[1]{%
\@namedef{footnotetext#1}{%
\@ifnextchar[ {\@nameuse{@xfootnotenext#1}}%
{\@name@p@xdef{@thefnmark#1}{\@nameuse{thempfn#1}}%
\@nameuse{@footnotetext#1}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@xfootnotenext}
% \cs{m@make@xfootnotenext}\marg{series} creates \cs{@xfootnotenext<series>}
% \begin{macrocode}
\newcommand{\m@make@xfootnotenext}[1]{
\@namedef{@xfootnotenext#1}[##1]{%
\begingroup
\csname c@\@mpfn#1\endcsname ##1\relax
\@name@unresp@xdef{@thefnmark#1}{\@nameuse{thempfn#1}}%
\endgroup
\@nameuse{@footnotetext#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@mpfn}
% \cs{m@make@mpfn}\marg{series} creates \cs{@mpfn<series>}
% \begin{macrocode}
\newcommand{\m@make@mpfn}[1]{%
\@namedef{@mpfn#1}{\@nameuse{footnote#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@makethempfn}
% \cs{m@makethempfn}\marg{series} creates \cs{thempfn<series>}
% \begin{macrocode}
\newcommand{\m@makethempfn}[1]{%
\@namedef{thempfn#1}{\@nameuse{thefootnote#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@makefnmark}
% \cs{m@make@makefnmark}\marg{series} creates \cs{@makefnmark<series>}
% \begin{macrocode}
\newcommand{\m@make@makefnmark}[1]{%
\@namedef{@makefnmark#1}{%
\hbox{\@textsuperscript{\normalfont\@nameuse{@thefnmark#1}}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@makefootref}
% \cs{m@makefootref}\marg{series} creates \cs{footref<series>}
% \begin{macrocode}
\newcommand{\m@makefootref}[1]{%
\@namedef{footref#1}##1{%
\begingroup
\@name@unresp@xdef{@thefnmark#1}{\ref{##1}}%
\endgroup
\@nameuse{@footnotemark#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@makefootfootmark}
% \cs{m@makefootfootmark}\marg{series} creates \cs{footfootmark<series>}
% \begin{macrocode}
\newcommand{\m@makefootfootmark}[1]{%
\@namedef{footfootmark#1}{%
\ifdim\footmarkwidth < \z@
\llap{\hb@xt@ -\footmarkwidth{%
\hss\normalfont\@nameuse{footscript#1}%
{\@nameuse{@thefnmark#1}}}%
\hspace*{-\footmarkwidth}}%
\else
\ifdim\footmarkwidth = \z@
{\normalfont\@nameuse{footscript#1}{\@nameuse{@thefnmark#1}}}%
\else
\hb@xt@\footmarkwidth{%
\hss\normalfont\@nameuse{footscript#1}%
{\@nameuse{@thefnmark#1}}}%
\fi
\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@makemakefootmark}
% \changes{v1.61}{2004/03/23}{Removed extraneous space from \cs{m@makemakefootmark}}
% \cs{m@makemakefootmark}\marg{series} creates \cs{makefootmark<series>}
% \begin{macrocode}
\newcommand{\m@makemakefootmark}[1]{%
\@namedef{makefootmark#1}##1{%
\leavevmode
\parindent \footparindent\noindent
\leftskip\footmarksep\relax
\advance\leftskip \footmarkwidth
\null\nobreak\hskip -\leftskip\relax
\makefootmarkhook\relax
\@nameuse{footfootmark#1}##1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@footgroup}
% \cs{m@make@footgroup}\marg{series} creates \cs{@footgroup<series>}
% \begin{macrocode}
\newcommand{\m@make@footgroup}[1]{%
\@namedef{@footgroup#1}{\unvbox\@nameuse{footins#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@makemp@footgroup}
% \cs{m@makemp@footgroup}\marg{series} creates \cs{mp@footgroup<series>}
% \begin{macrocode}
\newcommand{\m@makemp@footgroup}[1]{%
\@namedef{mp@footgroup#1}{\unvbox\@nameuse{@mpfootins#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@footstart}
% \cs{m@make@footstart}\marg{series} creates \cs{@footstart<series>}.
%
% The footnote series should of course use
% the skip associated with that series not just
% \cs{vskip}\cs{bigskipamount}.
% \changes{v3.7d}{2015/04/22}{Changed the \cs{vskip}}
% \changes{v3.7d}{2015/04/22}{Added the feet at bottom part}
% \begin{macrocode}
\newcommand{\m@make@footstart}[1]{%
\@namedef{@footstart#1}{%
%\vskip\bigskipamount
\mem@if@flushbottomF\m@mopfn@bottom
\vskip\skip\csname footins#1\endcsname
\leftskip=\z@
\rightskip=\z@
\footnoterule}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\plainfootstyle}
% \cs{plainfootstyle}\marg{series} specifies a plain (normal) footnote
% style for \meta{series}.
% \begin{macrocode}
\newcommand{\plainfootstyle}[1]{%
\m@make@footnotetext{#1}%
\m@make@footgroup{#1}%
\m@make@footstart{#1}%
\m@make@mpfootnotetext{#1}%
\m@makemp@footgroup{#1}%
\@nameuse{footmarkstyle#1}{\textsuperscript{##1}}
\expandafter\dimen\csname footins#1\endcsname=\footinsdim
\expandafter\count\csname footins#1\endcsname=1000\relax}
% \end{macrocode}
% \end{macro}
%
% Now the basic code for footnote declarations (we will be
% using \texttt{footnotev@r} instead of the regular \texttt{footnote}).
%
% \begin{macro}{\footinsv@r}
% Define the new \cs{footinsv@r} insert.
% \begin{macrocode}
\newinsert\footinsv@r
\skip\footinsv@r\bigskipamount
\count\footinsv@r=1000 % no magnifcation
\dimen\footinsv@r=\footinsdim
% \end{macrocode}
% \end{macro}
% Create a new \verb?v@r? footnote series.
% \begin{macrocode}
\m@make@footstart{v@r}
% \end{macrocode}
%
% \begin{macro}{\@footgroupv@r}
% Initialise the \texttt{footgroup} for the series to do nothing.
% \begin{macrocode}
\newcommand{\@footgroupv@r}{}
% \end{macrocode}
% \end{macro}
%
% And also for minipages:
% \begin{macro}{\@mpfootinsv@r}
% \begin{macro}{\mp@footgroupv@r}
% \begin{macrocode}
\newinsert\@mpfootinsv@r
\newcommand{\mp@footgroupv@r}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \Lpack{ledmac} package style footnotes (see \file{ledmac.dtx} for
% more detailed explanations).
%
% The two- and three-column notes use a macro \cs{m@mrigidbalance}
% to split text into a number of columns. This is based on \theTeXbook,
% page 397.
% \begin{macro}{\m@m@k}
% \begin{macro}{\m@m@h}
% \begin{macrocode}
\newcount\m@m@k \newdimen\m@m@h
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mrigidbalance}
% \begin{macro}{\m@mdosplits}
% \begin{macro}{\m@msplitoff}
% \cs{m@mrigidbalance}\marg{box}\marg{num}\marg{length} splits a
% \meta{box} (of text) into \meta{num} columns with \meta{length}
% space between the top baseline and the top of the \cs{vbox}.
% \begin{macrocode}
\newcommand*{\m@mrigidbalance}[3]{\setbox0=\box#1 \m@m@k=#2 \m@m@h=#3
\@@line{\splittopskip=\m@m@h \vbadness=\@M \hfilneg
\valign{##\vfill\cr\m@mdosplits}}}
\newcommand*{\m@mdosplits}{\ifnum\m@m@k>0 \noalign{\hfil}\m@msplitoff
\global\advance\m@m@k-1\cr\m@mdosplits\fi}
\newcommand*{\m@msplitoff}{\dimen0=\ht0
\divide\dimen0 by\m@m@k \advance\dimen0 by\m@m@h
\setbox2 \vsplit0 to \dimen0
\unvbox2 }
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Two column footnotes}
%
% \begin{macro}{\twocolumnfootnotes}
% Declaration for two column footnotes. This causes the standard
% \cs{footnote} and friends to internally use the \verb?v@r? series,
% which here produces two column footnotes.
% \changes{v1.61}{2004/03/14}{Made [RS] change to \cs{twocolumnfootnotes}}
% \begin{macrocode}
\newcommand{\twocolumnfootnotes}{%
\@namedef{foottextfontv@r}{\foottextfont}% % [RS]
\let\@footnotetext\@twocolfootnotetext
\dimen\footinsv@r=2\footinsdim
\count\footinsv@r=500\relax
\m@make@twocol@footgroup{v@r}%
\let\@footgroupv@r\@twocol@footgroupv@r
\let\@mpfootnotetext\@mptwocolfootnotetext
\m@make@mptwocol@footgroup{v@r}%
\let\mp@footgroupv@r\@mptwocol@footgroupv@r}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@twocolfootnotetext}
% \cs{@twocolfootnotetext}\marg{text} is the two column version of
% \cs{@footnotetext} for the \verb?v@r? series.
% \changes{v1.618}{2005/09/03}{Added missing percent to \cs{@twocolfootnotetext} (mempatch v3.1)}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\@twocolfootnotetext}[1]{\insert\footinsv@r{%
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\foottextfont
\@preamfntext
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark}%
\color@begingroup
\@twocolfootfmt{#1}%
\color@endgroup}%
\m@mmf@prepare}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@preamtwofmt}
% Give each column 0.45 of the textwidth.
% \begin{macrocode}
\newcommand{\@preamtwofmt}{%
\hsize .45\hsize
\parindent=\z@
\tolerance=5000\relax
\raggedright
\leavevmode}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@twocolfootfmt}
% \cs{@twocolfootfmt}
% \begin{macrocode}
\newcommand{\@twocolfootfmt}[1]{%
\@preamtwofmt
{\footfootmark\strut {\foottextfont #1}\strut\par}\allowbreak}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mptwocolfootnotetext}
% \cs{@mptwocolfootnotetext}\marg{text} is the two column version
% of \cs{@mpfootnotetext} for the \verb?v@r? series for minipages.
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\@mptwocolfootnotetext}[1]{%
\global\setbox\@mpfootinsv@r\vbox{%
\unvbox\@mpfootinsv@r
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\foottextfont
\hsize\columnwidth \@parboxrestore
\protected@edef\@currentlabel{%
\csname p@mpfootnote\endcsname\@thefnmark}%
\color@begingroup
\@twocolfootfmt{#1}%
\color@endgroup}%
\m@mmf@prepare}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\twocolumnfootstyle}
% \cs{twocolumnfootstyle}\marg{series} specifies a two column footnote
% style for \meta{series}.
% \begin{macrocode}
\newcommand{\twocolumnfootstyle}[1]{%
\m@make@twocolfootnotetext{#1}%
\m@make@mptwocolfootnotetext{#1}%
\m@make@twocolfootfmt{#1}%
\m@make@twocol@footgroup{#1}%
\m@make@mptwocol@footgroup{#1}%
\m@make@footstart{#1}%
\@namelongdef{@footnotetext#1}##1{%
\@nameuse{@twocolfootnotetext#1}{##1}}%
\@namelongdef{@mpfootnotetext#1}##1{%
\@nameuse{@mptwocolfootnotetext#1}{##1}}%
\@namedef{@footgroup#1}{\@nameuse{@twocol@footgroup#1}}%
\@namedef{mp@footgroup#1}{\@nameuse{@mptwocol@footgroup#1}}%
\expandafter\dimen\csname footins#1\endcsname=2\footinsdim
\expandafter\count\csname footins#1\endcsname=500\relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@twocolfootnotetext}
% \cs{m@make@twocolfootnotetext}\marg{series} creates
% \cs{@twocolfootnotetext}\meta{series}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\m@make@twocolfootnotetext}[1]{%
\@namelongdef{@twocolfootnotetext#1}##1{%
\insert\@nameuse{footins#1}{%
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\@nameuse{foottextfont#1}%
\@preamfntext
\protected@edef\@currentlabel{%
\csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
\color@begingroup
\@nameuse{@twocolfootfmt#1}{##1}%
\color@endgroup}%
\m@mmf@prepare}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@mptwocolfootnotetext}
% \cs{m@make@mptwocolfootnotetext}\marg{series} creates
% \cs{@mptwocolfootnotetext}\meta{series}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\m@make@mptwocolfootnotetext}[1]{%
\@namelongdef{@mptwocolfootnotetext#1}##1{%
\global\setbox\@nameuse{@mpfootins#1}\vbox{%
\unvbox\@nameuse{@mpfootins#1}
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\@nameuse{foottextfont#1}%
\hsize\columnwidth \@parboxrestore
\protected@edef\@currentlabel{%
\csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
\color@begingroup
\@nameuse{@twocolfootfmt#1}{##1}%
\color@endgroup}\m@mmf@prepare}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@twocolfootfmt}
% \cs{m@make@twocolfootfmt}\marg{series} creates
% \cs{@twocolfootfmt}\meta{series}
% \changes{v1.61}{2004/03/14}{Removed space from \cs{m@make@twocolfootfmt} [RS]}
% \begin{macrocode}
\newcommand{\m@make@twocolfootfmt}[1]{%
\@namedef{@twocolfootfmt#1}##1{%
\@preamtwofmt
{\@nameuse{footfootmark#1}\strut
{\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@twocol@footgroup}
% \cs{m@make@twocol@footgroup}\marg{series} creates
% \cs{@twocol@footgroup}\meta{series}
% \begin{macrocode}
\newcommand{\m@make@twocol@footgroup}[1]{%
\@namedef{@twocol@footgroup#1}{{%
\@nameuse{foottextfont#1} \splittopskip=\ht\strutbox
\m@mrigidbalance{\@nameuse{footins#1}}{\tw@}{\splittopskip}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@mptwocol@footgroup}
% \cs{m@make@mptwocol@footgroup}\marg{series} creates
% \cs{@mptwocol@footgroup}\meta{series}
% \begin{macrocode}
\newcommand{\m@make@mptwocol@footgroup}[1]{%
\@namedef{@mptwocol@footgroup#1}{{%
\@nameuse{foottextfont#1} \splittopskip=\ht\strutbox
\m@mrigidbalance{\@nameuse{@mpfootins#1}}{\tw@}{\splittopskip}}}}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Three column footnotes}
%
% \begin{macro}{\threecolumnfootnotes}
% Declaration for three column footnotres.
% \changes{v1.61}{2004/03/14}{Made [RS] change to \cs{threecolumnfootnotes}}
% \begin{macrocode}
\newcommand{\threecolumnfootnotes}{%
\@namedef{foottextfontv@r}{\foottextfont}% % [RS]
\let\@footnotetext\@threecolfootnotetext
\dimen\footinsv@r=3\footinsdim
\count\footinsv@r=333\relax
\m@make@threecol@footgroup{v@r}%
\let\@footgroupv@r\@threecol@footgroupv@r
\let\@mpfootnotetext\@mpthreecolfootnotetext
\m@make@mpthreecol@footgroup{v@r}%
\let\mp@footgroupv@r\@mpthreecol@footgroupv@r}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@threecolfootnotetext}
% \cs{@threecolfootnotetext}\marg{text} is the three column version of
% \cs{@footnotetext}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\@threecolfootnotetext}[1]{\insert\footinsv@r{%
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\foottextfont
\@preamfntext
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark}%
\color@begingroup
\@threecolfootfmt{#1}%
\color@endgroup}\m@mmf@prepare}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@preamthreefmt}
% Give each column 0.3 of the text width.
% \begin{macrocode}
\newcommand{\@preamthreefmt}{%
\hsize .3\hsize
\parindent=\z@
\tolerance=5000\relax
\raggedright
\leavevmode}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@threecolfootfmt}
%
% \begin{macrocode}
\newcommand{\@threecolfootfmt}[1]{%
\@preamthreefmt
{\footfootmark\strut {\foottextfont #1}\strut\par}\allowbreak}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mpthreecolfootnotetext}
% \cs{@mpthreecolfootnotetext}\marg{text} is the three column version of
% \cs{@mpfootnotetext}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\@mpthreecolfootnotetext}[1]{%
\global\setbox\@mpfootinsv@r\vbox{%
\unvbox\@mpfootinsv@r
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\foottextfont
\hsize\columnwidth \@parboxrestore
\protected@edef\@currentlabel{%
\csname p@mpfootnote\endcsname\@thefnmark}%
\color@begingroup
\@threecolfootfmt{#1}%
\color@endgroup}\m@mmf@prepare}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\threecolumnfootstyle}
% \cs{threecolumnfootstyle}\marg{series} specifies three column footnote style
% for \meta{series}
% \begin{macrocode}
\newcommand{\threecolumnfootstyle}[1]{%
\m@make@threecolfootnotetext{#1}%
\m@make@mpthreecolfootnotetext{#1}%
\m@make@threecolfootfmt{#1}%
\m@make@threecol@footgroup{#1}%
\m@make@mpthreecol@footgroup{#1}%
\m@make@footstart{#1}%
\@namelongdef{@footnotetext#1}##1{%
\@nameuse{@threecolfootnotetext#1}{##1}}%
\@namelongdef{@mpfootnotetext#1}##1{%
\@nameuse{@mpthreecolfootnotetext#1}{##1}}%
\@namedef{@footgroup#1}{\@nameuse{@threecol@footgroup#1}}%
\@namedef{mp@footgroup#1}{\@nameuse{@mpthreecol@footgroup#1}}%
\expandafter\dimen\csname footins#1\endcsname=3\footinsdim
\expandafter\count\csname footins#1\endcsname=333\relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@threecolfootnotetext}
% \cs{m@make@threecolfootnotetext}\marg{series} creates
% \cs{@threecolfootnotetext}\meta{series}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\m@make@threecolfootnotetext}[1]{%
\@namelongdef{@threecolfootnotetext#1}##1{%
\insert\@nameuse{footins#1}{%
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\@nameuse{foottextfont#1}%
\@preamfntext
\protected@edef\@currentlabel{%
\csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
\color@begingroup
\@nameuse{@threecolfootfmt#1}{##1}%
\color@endgroup}\m@mmf@prepare}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@mpthreecolfootnotetext}
% \cs{m@make@mpthreecolfootnotetext}\marg{series} creates
% \cs{@mpthreecolfootnotetext}\meta{series}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\m@make@mpthreecolfootnotetext}[1]{%
\@namelongdef{@mpthreecolfootnotetext#1}##1{%
\global\setbox\@nameuse{@mpfootins#1}\vbox{%
\unvbox\@nameuse{@mpfootins#1}
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\@nameuse{foottextfont#1}%
\hsize\columnwidth \@parboxrestore
\protected@edef\@currentlabel{%
\csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
\color@begingroup
\@nameuse{@threecolfootfmt#1}{##1}%
\color@endgroup}\m@mmf@prepare}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@threecolfootfmt}
% \cs{m@make@threecolfootfmt}\marg{series} creates
% \cs{@threecolfootfmt}\meta{series}
% \changes{v1.61}{2004/03/14}{Removed space from \cs{m@make@threecolfootfmt} [RS]}
% \begin{macrocode}
\newcommand{\m@make@threecolfootfmt}[1]{%
\@namelongdef{@threecolfootfmt#1}##1{%
\@preamthreefmt
{\@nameuse{footfootmark#1}\strut
{\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@threecol@footgroup}
% \cs{m@make@threecol@footgroup}\marg{series} creates
% \cs{@threecol@footgroup}\meta{series}
% \begin{macrocode}
\newcommand{\m@make@threecol@footgroup}[1]{%
\@namedef{@threecol@footgroup#1}{{%
\@nameuse{foottextfont#1} \splittopskip=\ht\strutbox
\m@mrigidbalance{\@nameuse{footins#1}}{\thr@@}{\splittopskip}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@mpthreecol@footgroup}
% \cs{m@make@mpthreecol@footgroup}\marg{series} creates
% \cs{@mpthreecol@footgroup}\meta{series}
% \begin{macrocode}
\newcommand{\m@make@mpthreecol@footgroup}[1]{%
\@namedef{@mpthreecol@footgroup#1}{{%
\@nameuse{foottextfont#1} \splittopskip=\ht\strutbox
\m@mrigidbalance{\@nameuse{@mpfootins#1}}{\thr@@}{\splittopskip}}}}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Paragraphed footnotes}
%
% Paragraphed footnotes are based on \theTeXbook, page 398ff, in the
% Dirty Tricks appendix. It does a lot of box manipulations.
%
% \begin{macro}{\m@munvxh}
% \cs{m@munvxh}\marg{vbox}: unvbox, extract the last line, and unhbox it.
% \begin{macrocode}
\newcommand{\m@munvxh}[1]{%
\setbox0=\vbox{\unvbox#1%
\global\setbox1=\lastbox}%
\unhbox1
\unskip
\unskip
\unpenalty
\hskip\m@mipn@skip}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mungebox}
%
% \begin{macrocode}
\newcommand{\m@mungebox}{%
\setbox0=\hbox{\m@munvxh0}%
\dp0=\z@
\ht0=\footfudgefactor\wd0
\box0
\penalty0}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mipn@skip}
% \begin{macro}{\m@minterparanoteglue}
% These are `inter-para-note-skip' and `inter-parafootnote' glue, for
% paragraphed footnotes.
% \begin{macrocode}
\newskip\m@mipn@skip
\newcommand*{\m@minterparanoteglue}[1]{%
{\foottextfont\global\m@mipn@skip=#1\relax}}
\m@minterparanoteglue{1em plus.4em minus.4em}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mmakehboxofhboxes}
% Make an hbox of hboxes.
% \begin{macrocode}
\newcommand*{\m@mmakehboxofhboxes}{\setbox0=\hbox{}%
\loop
\unpenalty
\setbox2=\lastbox
\ifhbox2
\setbox0=\hbox{\box2\unhbox0}
\repeat}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mremovehboxes}
% \begin{macrocode}
\newcommand*{\m@mremovehboxes}{\setbox0=\lastbox
\ifhbox0{\m@mremovehboxes}\unhbox0 \fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\footfudgefiddle}
% TeX uses \verb?\footfufgefactor? to estimate the space required for
% paragraphed footnotes. If it underestimates then the notes approach,
% or cover, the footer. \verb?\footfudgefiddle? can be changed (upward) from
% its default to improve matters.
% \begin{macrocode}
\newcommand*{\footfudgefiddle}{64}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\paragraphfootnotes}
% Declaration for paragraphed footnotes.
% \changes{v1.61}{2004/03/14}{Made [RS] change to \cs{paragraphfootnotes}}
% \begin{macrocode}
\newcommand{\paragraphfootnotes}{%
\@namedef{foottextfontv@r}{\foottextfont}% % [RS]
\let\@footnotetext\@parafootnotetext
\dimen\footinsv@r=\footinsdim
\count\footinsv@r=1000\relax
\m@make@para@footgroup{v@r}%
\let\@footgroupv@r\@para@footgroupv@r
\let\@mpfootnotetext\@mpparafootnotetext
\m@make@mppara@footgroup{v@r}%
\let\mp@footgroupv@r\@mppara@footgroupv@r
{\foottextfont
\dimen0=\baselineskip
% \end{macrocode}
% Multiplying \cs{dimen0} by 1024 can lead to arithmetic overflow if
% \cs{baselineskip} is too large, for example under
% \cs{DoubleSpacing}. Instead we only multiply by 256 and then
% multiply again by 4 after the division by \cs{hsize}.
% \changes{v3.7r}{2022/07/28}{Changed calculation}
% \begin{macrocode}
%\multiply\dimen0 by 1024
\multiply\dimen0 by 256
\divide\dimen0 by \hsize
\multiply\dimen0 by 4
\multiply\dimen0 by \footfudgefiddle
\xdef\footfudgefactor{\expandafter\strip@pt\dimen0 }}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@parafootnotetext}
% \cs{@parafootnotetext}\marg{text} is a paragraph version of
% \cs{@footnotetext}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\@parafootnotetext}[1]{\insert\footinsv@r{
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\foottextfont
\@preamfntext
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark}%
\setbox0=\vbox{\hsize=\maxdimen
\color@begingroup
\noindent \@parafootfmt{#1}%
\color@endgroup}%
\m@mungebox}\m@mmf@prepare}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@parafootfmt}
% \cs{@parafootfmt}\marg{text} is a paragraph version of
% \cs{@footfmt}
% \begin{macrocode}
\newcommand{\@parafootfmt}[1]{%
\parindent=\z@
\parfillskip=0pt \@plus 1fil
{\footfootmark\strut {\foottextfont #1}\penalty-10}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mpparafootnotetext}
% \cs{@mpparafootnotetext}\marg{text} is a paragraph version of
% \cs{@mpfootnotetext}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\@mpparafootnotetext}[1]{%
\global\setbox\@mpfootinsv@r\vbox{%
\unvbox\@mpfootinsv@r
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\foottextfont
\hsize\columnwidth \@parboxrestore
\protected@edef\@currentlabel{%
\csname p@mpfootnote\endcsname\@thefnmark}%
\setbox0=\vbox{\hsize=\maxdimen
\color@begingroup
\noindent \@parafootfmt{#1}%
\color@endgroup}%
\m@mungebox}\m@mmf@prepare}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\paragraphfootstyle}
% \cs{paragraphfootstyle}\marg{series} specifies paragraphed footnote style
% for \meta{series}.
% \begin{macrocode}
\newcommand{\paragraphfootstyle}[1]{%
\m@make@parafootnotetext{#1}%
\m@make@mpparafootnotetext{#1}%
\m@make@parafootfmt{#1}%
\m@make@para@footgroup{#1}%
\m@make@mppara@footgroup{#1}%
\m@make@para@footstart{#1}%
\@namelongdef{@footnotetext#1}##1{%
\@nameuse{@parafootnotetext#1}{##1}}%
\@namelongdef{@mpfootnotetext#1}##1{%
\@nameuse{@mpparafootnotetext#1}{##1}}%
\@namedef{@footgroup#1}{\@nameuse{@para@footgroup#1}}%
\@namedef{mp@footgroup#1}{\@nameuse{@mppara@footgroup#1}}%
\@namedef{@footstart#1}{\@nameuse{@para@footstart#1}}%
\expandafter\dimen\csname footins#1\endcsname=\footinsdim
\expandafter\count\csname footins#1\endcsname=1000\relax
{\@nameuse{foottextfont#1}%
\dimen0=\baselineskip
% \end{macrocode}
% Similar issue with arithmetic overflow as mentioned with \cs{paragraphfootnotes}.
% \changes{v3.7r}{2022/07/28}{Changed calculation}
% \begin{macrocode}
%\multiply\dimen0 by 1024
\multiply\dimen0 by 256
\divide\dimen0 by \hsize
\multiply\dimen0 by 4
% \end{macrocode}
% \changes{v3.7r}{2022/07/28}{Changed 64 to \cs{footfudgefiddle}}
% \begin{macrocode}
\multiply\dimen0 by \footfudgefiddle
\xdef\footfudgefactor{\expandafter\strip@pt\dimen0 }}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@parafootnotetext}
% \cs{m@make@parafootnotetext}\marg{series} creates
% \cs{@parafootnotetext}\meta{series}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\m@make@parafootnotetext}[1]{%
\@namelongdef{@parafootnotetext#1}##1{%
\insert\@nameuse{footins#1}{
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\@nameuse{foottextfont#1}%
\@preamfntext
\protected@edef\@currentlabel{%
\csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
\setbox0=\vbox{\hsize=\maxdimen
\color@begingroup
\noindent \@nameuse{@parafootfmt#1}{##1}%
\color@endgroup}%
\m@mungebox}\m@mmf@prepare}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@mpparafootnotetext}
% \cs{m@make@mpparafootnotetext}\marg{series} creates
% \cs{@mpparafootnotetext}\meta{series}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\m@make@mpparafootnotetext}[1]{%
\@namelongdef{@mpparafootnotetext#1}##1{%
\global\setbox\@nameuse{@mpfootins#1}\vbox{%
\unvbox\@nameuse{@mpfootins#1}
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font\@nameuse{foottextfont#1}%
\hsize\columnwidth \@parboxrestore
\protected@edef\@currentlabel{%
\csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
\setbox0=\vbox{\hsize=\maxdimen
\color@begingroup
\noindent \@nameuse{@parafootfmt#1}{##1}%
\color@endgroup}%
\m@mungebox}\m@mmf@prepare}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@parafootfmt}
% \cs{m@make@parafootfmt}\marg{series} creates
% \cs{@parafootfmt}\meta{series}
% \changes{v1.61}{2004/03/14}{Removed space from \cs{m@make@parafootfmt} [RS]}
% \begin{macrocode}
\newcommand{\m@make@parafootfmt}[1]{%
\@namelongdef{@parafootfmt#1}##1{%
\parindent=\z@
\parfillskip=0pt \@plus 1fil
{\@nameuse{footfootmark#1}\strut
{\@nameuse{foottextfont#1}##1}\penalty-10}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@para@footgroup}\marg{series} creates
% \cs{@para@footgroup}\meta{series}
% \begin{macrocode}
\newcommand{\m@make@para@footgroup}[1]{%
\@namedef{@para@footgroup#1}{%
\unvbox\@nameuse{footins#1}
\m@mmakehboxofhboxes
\setbox0=\hbox{\unhbox0 \m@mremovehboxes}%
\@nameuse{foottextfont#1}%
\noindent\unhbox0\par}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@mppara@footgroup}
% \cs{m@make@mppara@footgroup}\marg{series} creates
% \cs{@mppara@footgroup}\meta{series}
% \begin{macrocode}
\newcommand{\m@make@mppara@footgroup}[1]{%
\@namedef{@mppara@footgroup#1}{%
\unvbox\@nameuse{@mpfootins#1}
\m@mmakehboxofhboxes
\setbox0=\hbox{\unhbox0 \m@mremovehboxes}%
\@nameuse{foottextfont#1}%
\noindent\unhbox0\par}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@make@para@footstart}
% \cs{m@make@para@footstart}\marg{series} creates
% \cs{@para@footstart}\meta{series}
% \begin{macrocode}
\newcommand{\m@make@para@footstart}[1]{%
\@namedef{@para@footstart#1}{%
\vskip\bigskipamount
\leftskip=\z@
\rightskip=\z@
\parindent=\z@
\vskip\skip\@nameuse{footins#1}%
\footnoterule}}
% \end{macrocode}
% \end{macro}
%
% \subsection{Nasty insert bits}
% \changes{v1.61803}{2008/01/30}{Put \cs{@makecol} and associated code
% into new section `Nasty insert bits' (mempatch various)}
%
% \cs{sidebar} is implemented as a new kind of \cs{insert} and the
% extended footnotes are also implemented via new kinds of \cs{insert}s.
% New \cs{insert}s mean that the kernel's \cs{@makecol} must be revised
% to cater for them. As this is part of the output process it is nasty to
% do.
%
% Before v1.61803 \cs{@makecol} got (re)defined at several points in the
% code. Here is what I hope is the final version od \cs{@makecol} and
% associated code after having resolved and combined all the changes.
%
%
% \begin{macro}{\if@mem@nofoot}
% \begin{macro}{\@mem@testifnofoot}
% \begin{macro}{\@mem@extranofoot}
% These are from [RS] as \cs{@doclearpage} should check for more than
% just \cs{footins} being void. Note that this covers all current
% class defined inserts, including sidebars.
% \changes{v1.61}{2004/03/14}{Added \cs{if@mem@nofoot},
% \cs{@mem@testifnofoot}, and
% \cs{@mem@extranofoot}}
% \begin{macrocode}
\newif\if@mem@nofoot
\newcommand*{\@mem@testifnofoot}{%
\@mem@nofoottrue
\ifvoid\footins\else\@mem@nofootfalse\fi
\ifvoid\footinsv@r\else\@mem@nofootfalse\fi
\ifvoid\sideins\else\@mem@nofootfalse\fi
\@mem@extranofeet}
\newcommand*{\@mem@extranofeet}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memold@doclearpage}
% \begin{macro}{\mem@doclearpage}
% \begin{macro}{\@doclearpage}
% I thought that I could get away with using the kernel's
% \cs{@doclearpage} but [RS] discovered that I couldn't.
% \changes{v1.62}{2004/03/14}{Redid \cs{@doclearpage} using [RS] code}
% \changes{v3.7d}{2015/04/23}{Opdated \cs{mem@doclearpage} to match
% \Lpack{fixltx2e} v1.1s (which will be the base of the ltx kernel for
% TL15)}
% \begin{macrocode}
\let\memold@doclearpage\@doclearpage
\newcommand{\mem@doclearpage}{%
\@mem@testifnofoot
\if@mem@nofoot
\setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
\setbox\@tempboxa\box\@cclv
\xdef\@deferlist{\@toplist\@botlist\@deferlist}%
\global \let \@toplist \@empty
\global \let \@botlist \@empty
\global \@colroom \@colht
\ifx \@currlist\@empty
\else
\@latexerr{Float(s) lost}\@ehb
\global \let \@currlist \@empty
\fi
\@makefcolumn\@deferlist
\@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
\if@twocolumn
\if@firstcolumn
\xdef\@deferlist{\@dbltoplist\@deferlist}%
\global \let \@dbltoplist \@empty
\global \@colht \textheight
\begingroup
\@dblfloatplacement
\@makefcolumn\@deferlist
\@whilesw\if@fcolmade \fi{\@outputpage
\@makefcolumn\@deferlist}%
\endgroup
\else
\vbox{}\clearpage
\fi
\fi
\ifx\@deferlist\@empty \else\clearpage \fi
\else
\setbox\@cclv\vbox{\box\@cclv\vfil}%
\@makecol\@opcol
\clearpage
\fi
% older version
% \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
% \setbox\@tempboxa\box\@cclv
% \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
% \global\let\@toplist\@empty
% \global\let\@botlist\@empty
% \global\@colroom\@colht
% \ifx \@currlist\@empty
% \else
% \@latexerr{Float(s) lost}\@ehb
% \global\let\@currlist\@empty
% \fi
% \@makefcolumn\@deferlist
% \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
% \if@twocolumn
% \if@firstcolumn
% \xdef\@dbldeferlist{\@dbltoplist\@dbldeferlist}%
% \global\let\@dbltoplist\@empty
% \global\@colht\textheight
% \begingroup
% \@dblfloatplacement
% \@makefcolumn\@dbldeferlist
% \@whilesw\if@fcolmade \fi{\@outputpage
% \@makefcolumn\@dbldeferlist}%
% \endgroup
% \else
% \vbox{}\clearpage
% \fi
% \fi
% \else
% \setbox\@cclv\vbox{\box\@cclv\vfil}%
% \@makecol\@opcol
% \clearpage
% \fi
}
% \end{macrocode}
% Replace the kernel's \cs{@doclearpage}.
% \begin{macrocode}
\gdef\@doclearpage{\mem@doclearpage}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\m@m@makecolfloats}
% \begin{macro}{\m@m@makecoltext}
% These two macros contain code common to versions of \cs{@makecol}
% \changes{v3.7q}{2022/02/20}{Added the \cs{@elt} line from the kernel}
% \begin{macrocode}
\newcommand*{\m@m@makecolfloats}{%
\let\@elt\relax%
\xdef\@freelist{\@freelist\@midlist}%
\global\let\@midlist\@empty
\@combinefloats}
\newcommand*{\m@m@makecoltext}{%
\ifvbox\@kludgeins
\@makespecialcolbox
\else
\setbox\@outputbox \vbox to\@colht{%
\@texttop
\dimen@ \dp\@outputbox
\unvbox \@outputbox
\vskip -\dimen@
\@textbottom}%
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@m@makecolintro}
% A hook into the revised \cs{@makecol}
% \begin{macrocode}
\newcommand*{\m@m@makecolintro}{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mopfootnote}
% (footnote) code for possible use in \cs{@makecol}.
% \changes{v3.7d}{2015/04/21}{Added feature to force footnotes to the
% bottom of the page in a ragged context}
% \begin{macrocode}
\newcommand*{\m@mopfootnote}{\setbox\@outputbox \vbox{%
\boxmaxdepth\@maxdepth
\@tempdima\dp\@cclv
\unvbox\@cclv
\vskip-\@tempdima
% \end{macrocode}
% We then add a macro call that is only activated if we are not using
% \cs{flushbottom}. If \cs{feetatbottom} is active, then a
% \cs{vfill} is added. Solution inspired by \Lpack{footmisc}.
% \begin{macrocode}
\mem@if@flushbottomF\m@mopfn@bottom
\vskip \skip\footins
\color@begingroup
\normalcolor
\footnoterule
\unvbox \footins
\color@endgroup}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mopfootnotebf}
% (footnote) code in support of footnotes below floats.
% Problem with original code noted by J{\o}rgen Larsen (\url{jl@ruc.dk})
% on 2008/05/24. Updated 2015.
% \changes{v1.618033}{2008/06/02}{Added \cs{m@mopfootnotebf}}
% \changes{v3.7d}{2015/04/21}{Added feature to force footnotes to the
% bottom of the page in a ragged context}
% \begin{macrocode}
\newcommand*{\m@mopfootnotebf}{%
\setbox\@outputbox \vbox{%
\boxmaxdepth\@maxdepth
\unvbox\@outputbox
% \end{macrocode}
% We then add a macro call as above.
% \begin{macrocode}
\mem@if@flushbottomF\m@mopfn@bottom
\vskip\skip\footins
\color@begingroup
\normalcolor
\footnoterule
\unvbox \footins
\color@endgroup}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mopsidebar}
% (sidebar) code for possible use in \cs{@makecol}.
% From DA's latest sidebar fixes.
% \begin{macrocode}
\newcommand*{\m@mopsidebar}{%
\ifvoid\sideins\else
\setbox\@outputbox \vbox{%
\sidecontents
\unvbox\@outputbox}
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@makecol}
% DA's latest version of \cs{@makecol} (giving the standard
% footnote order (bottom floats after footnotes)) putting the sidebar
% insert after the others (from mempatch v4.9). The code is renewed on
% page~\pageref{makecol} onwards.
% \begin{macrocode}
% \gdef\mem@makecol{%
% \m@m@makecolintro
% \ifvoid\footins
% \setbox\@outputbox \box\@cclv
% \else
% \m@mopfootnote
% \fi
% \m@mdoextrafeet
% \m@m@makecolfloats
% \m@mopsidebar
% \m@m@makecoltext
% \global \maxdepth \@maxdepth}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@makecolbf}
% A version of \cs{@makecol} which puts footnotes at the bottom of the page
% (after any bottom floats). The code is renewed on
% page~\pageref{makecol} onwards.
% \changes{v1.618033}{2008/06/02}{Used \cs{m@mopfootnotebf} instead of
% \cs{m@mopfootnote} in \cs{mem@makecolbf}}
% \begin{macrocode}
% \gdef\mem@makecolbf{%
% \m@m@makecolintro
% \setbox\@outputbox \box\@cclv
% \m@m@makecolfloats
% \ifvoid\footins\else
% \m@mopfootnotebf
% \fi
% \m@mdoextrafeet
% \m@mopsidebar
% \m@m@makecoltext
% \global\maxdepth \@maxdepth}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@makecoldblf}
% A version of \cs{@makecol} which is a placeholder to fix the doublefloat
% problem.
% TODO: remove this code it is not used
% \begin{macrocode}
\gdef\mem@makecoldblf{%
\m@m@makecolintro
\setbox\@outputbox \box\@cclv
\m@m@makecolfloats
\m@mopsidebar% <- added
\ifvoid\footins
\else
\m@mopfootnote
\fi
\m@mdoextrafeet
\m@m@makecoltext
\global \maxdepth \@maxdepth}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\feetabovefloat}
% \begin{macro}{\feetbelowfloat}
% \begin{macro}{\@makecol}
% declarations to put footnotes above bottom floats (standard \LaTeX)
% or at the bottom of the page
% \begin{macrocode}
\newcommand{\feetabovefloat}{\gdef\@makecol{\mem@makecol}}
\newcommand{\feetbelowfloat}{\gdef\@makecol{\mem@makecolbf}}
\feetabovefloat
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\feetatbottom}
% \begin{macro}{\feetbelowragged}
% \begin{macro}{\m@mopfn@bottom}
% \begin{macro}{\mem@if@flushbottomF}
% If a page is typeset with a ragged bottom then any footnotes are
% added directly under the text. It may look better if the footnotes
% are added to the text block from the bottom up.
% \begin{macrocode}
\newcommand\feetatbottom{\def\m@mopfn@bottom{\vfill\relax}}
\newcommand\feetbelowragged{\let\m@mopfn@bottom\relax}
\feetbelowragged
% \end{macrocode}
% Next we add a test to see if \cs{flushbottom} is active. This macro
% is used within \cs{m@mopfootnote} and \cs{m@mopfootnotebf} to
% force the footnotes to the bottom \emph{only} when \cs{flushbottom}
% is \emph{not} active, hince the \texttt{F} in the name.
% \begin{macrocode}
\newcommand\mem@if@flushbottomF[1]{%
\if\mem@flshbot\else#1\fi%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@reinserts}
% DA's final version from last patch.
% \changes{v3.6d}{2010/06/30}{THere is a newer version further down
% the code}
% \begin{macrocode}
% \gdef\@reinserts{%
% \ifvoid\footins\else\insert\footins{\unvbox\footins}\fi
% \m@mdodoreinextrafeet
% \ifvbox\@kludgeins\insert\@kludgeins{\unvbox\@kludgeins}\fi
% \ifvoid\sideins\else\insert\sideins{\unvbox\sideins}\fi}
% \end{macrocode}
% \end{macro}
%
% \changes{v1.61803398d}{2010/01/25}{Added section about side footnotes}
% \subsection{Side footnotes} \label{sec:sidefootnotes}
%
%
% \subsubsection{Extension to the regular footnote}
%
% The code here enables the regular \cs{footnote} to be set in the
% margin. It is based on Robin Fairbairns' \Lpack{footmisc} package.
%
% \begin{macro}{\ifm@mfnmargin}
% \begin{macro}{\footnotesatfoot}
% \begin{macro}{\footnotesinmargin}
% Declarations for regular footnotes to be set as normal at the foot
% of the page, or in the margin.
% \begin{macrocode}
\newif\ifm@mfnmargin
\newcommand*{\footnotesatfoot}{\m@mfnmarginfalse}
\newcommand*{\footnotesinmargin}{\m@mfnmargintrue}
\footnotesatfoot
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \changes{v1.61803398d}{2010/01/25}{Remember that we actually have
% several \cs{@footnotetext} in memoir, might be an idea to clean this
% up at some point/daleif}
% \begin{macro}{\@footnotetext}
% \begin{macro}{\m@mold@footnotetext}
% Change \cs{@footnotetext} to enable footnotes to be put into the margin
% by using \cs{marginpar}.
% \begin{macrocode}
\renewcommand{\@footnotetext}[1]{%
\ifm@mfnmargin% use marginpar
% \end{macrocode}
% Use \cs{marginpar} for placing the footnote.
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\marginpar{%
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font
\foottextfont
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark}%
\color@begingroup
\@makefntext{\ignorespaces#1}%
\color@endgroup}%
\else% regular feet
% \end{macrocode}
% This is the original code for \cs{@footnotetext}.
% \changes{v1.618033988c}{2010/02/20}{sporadic spaces removed, error
% reported on texlive mailinglist}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\insert\footins{%
\def\baselinestretch{\m@m@footnote@spacing}%
\reset@font
\foottextfont
\@preamfntext
\hsize\columnwidth
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark}%
\color@begingroup
\@makefntext{%
\rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
\@finalstrut\strutbox}%
\color@endgroup}%
\fi%
\m@mmf@prepare}
% \end{macrocode}
% Need to save this version of \cs{@footnotetext}, it is
% used within \cs{plainfootnotes}.
% \changes{v3.6h}{2010/10/22}{Moved \cs{m@mold@footnotetext} to this
% location, and renamed it to \cs{@plainfootnotetext}}
% \begin{macrocode}
\let\@plainfootnotetext\@footnotetext
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Bottom aligned side footnotes}
%
% The code for the bottom aligned marginal footnotes is based partly on
% the \cs{sidebar} code and code from David Salomon, 'Output Routines:
% Examples and Techniques. Part III: Insertions', \textit{TUGboat},
% 11, 4, pp 588--605, Nov 1990.
%
% \begin{macro}{\sidefootmargin}
% \begin{macro}{\m@msidefoot@margin}
% \cs{sidefootmargin} is the user command for setting the side for
% side footnotes (stored as \cs{m@msidefoot@margin}). The default
% is \texttt{outer}.
% \begin{macrocode}
\newcommand*{\sidefootmargin}[1]{%
\m@msetm@argin{#1}%
\ifnum\m@mm@argin<\z@
\@memwarn{Bad \string\sidefootmargin\space argument `#1'\MessageBreak
set to `outer'}%
\gdef\m@msidefoot@margin{2}% set as outer
\else
\global\let\m@msidefoot@margin\m@mm@argin
\fi}
\sidefootmargin{outer}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\sidefootins}
% As for any non-main text matter we need an insert.
% \begin{macrocode}
\newinsert\sidefootins
\skip\sidefootins=0pt
\count\sidefootins=0\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidefootadjust}
% \begin{macro}{\sidefootheight}
% \begin{macro}{\setsidefootheight}
% The length \cs{sidefootadjust} can be used for fine control over the
% vertivcal position of the base of the column of side footnotes.
% The length \cs{sidefootheight}
% is the height of the column and is best set by the \cs{setsidefootheight}
% macro, which takes the desired height as its argument and sets the height
% of the \cs{sidefootins} \cs{insert}. The height is
% initially set to the \cs{textheight}.
% \begin{macrocode}
\newlength{\sidefootadjust}
\setlength{\sidefootadjust}{0pt}
\newlength{\sidefootheight}
\newcommand*{\setsidefootheight}[1]{%
\setlength{\dimen\sidefootins}{#1}%
\advance\dimen\sidefootins -\topskip
\advance\dimen\sidefootins \ht\strutbox
\setlength{\sidefootheight}{\dimen\sidefootins}}
\setsidefootheight{\textheight}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sidefoothsep}
% \begin{macro}{\sidefootwidth}
% \begin{macro}{\sidefootvsep}
% The horizontal space between the text block and side footnotes
% (\cs{sidefoothsep}),
% the width of the column of notes (\cs{sidefootwidth}),
% and the vertical space between consecutive side footnotes
% (\cs{sidefootvsep}).
% \changes{v1.61803398d}{2010/02/05}{removed \cs{sidefootfont}}
% \begin{macrocode}
\newlength{\sidefoothsep}
\newlength{\sidefootvsep}
\newlength{\sidefootwidth}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setsidefeet}
% The macro \cs{setsidefeet}\marg{hsep}\marg{width}\marg{vsep}\marg{adj}\marg{font}\marg{height}
% sets the specifications for the side footnotes. An `*' means `use
% the current
% value'.
% \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont} to
% \cs{sidefoottextfont}}
%
% \begin{macrocode}
\newcommand*{\setsidefeet}[6]{%
\nametest{#1}{*}\ifsamename\else
\setlength{\sidefoothsep}{#1}\@memznegtest{\sidefoothsep}%
\fi
\nametest{#2}{*}\ifsamename\else
\setlength{\sidefootwidth}{#2}\@memznegtest{\sidefootwidth}%
\fi
\nametest{#3}{*}\ifsamename\else
\setlength{\sidefootvsep}{#3}\@memznegtest{\sidefootvsep}%
\fi
\nametest{#4}{*}\ifsamename\else
\setlength{\sidefootadjust}{#4}%
\fi
\nametest{#5}{*}\ifsamename\else
\def\sidefoottextfont{#5}%
\fi
\nametest{#6}{*}\ifsamename\else
\setsidefootheight{#6}%
\ifdim\dimen\sidefootins>\z@\else
\@memerror{\protect\sidefootheight\space is zero or negative}{\@ehd}%
\fi
\fi}
\setsidefeet{\marginparsep}{\marginparwidth}%
{\onelineskip}{0pt}%
{\normalfont\footnotesize}{\textheight}%
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\sidefootform}
% Set the sidefootnotes raggedy right
% \begin{macrocode}
\newcommand*{\sidefootform}{\rightskip=\z@ \@plus 2em}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\m@sideft@left}
% \begin{macro}{\m@sideft@right}
% Macros placing the sidefootnotes at the left and the right respectively.
% \begin{macrocode}
\newcommand*{\m@sideft@left}{%
\@tempdimc \sidefootwidth
\advance\@tempdimc\sidefoothsep
\kern-\@tempdimc}
\newcommand*{\m@sideft@right}{%
\@tempdimc \columnwidth% or \hsize
\advance\@tempdimc\sidefoothsep
\kern\@tempdimc}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mdownsf}
% A length used in the vertical positioning of sidefootnotes.
% (Perhaps one of the \cs{@tempdim} lengths could be used instead?)
% \begin{macrocode}
\newlength{\m@mdownsf}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidefootcontents}
% The essence of the sidefootnote task. This first positions the column
% to the left or the right and then tries to make the bottom of the
% column align with the bottom of the textblock.
% \begin{macrocode}
\newcommand*{\sidefootcontents}{\hbox to \z@{%
\m@mwhich@margin{\m@msidefoot@margin}%
\ifmemtortm
\m@sideft@right
\else
\m@sideft@left
\fi
% \end{macrocode}
% Now the fun part. The general idea is to measure the height of the insert's
% contents, subtract this from the specified height of the insert,
% and move the contents down by that amount.
% The code below seems to work except when sidefootnotes
% spill over to the following page; also, like \cs{sidebar},
% they are out of vertical alignment when on a \cs{chapter} page.
% I haven't found a way to automatically
% adjust for these, which is why the \cs{sidefootadjust} length is
% there to enable manual adjustment.
% \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont}
% to \cs{sidefoottextfont}}
% \begin{macrocode}
\vtop to 0pt{% original
\normalsize\normalfont\sidefoottextfont
\vskip\topskip \vskip-\ht\strutbox
\vskip\sidefootadjust% use this for minor vertical adjustment
\m@mdownsf=\dimen\sidefootins
\advance\m@mdownsf-\ht\sidefootins
\advance\m@mdownsf-\dp\sidefootins
% \end{macrocode}
% Here's where the fiddling occurs, arrived at by a mixture of theory and
% experiment.
% \begin{macrocode}
\ifdim\m@mdownsf>\sidefootvsep
\advance\m@mdownsf\sidefootvsep
\advance\m@mdownsf 0.5\ht\strutbox
\fi
\vskip\m@mdownsf% --- basically works
\unvbox\sidefootins%
\vss}%
\hss}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mopsidefoot}
% If there are any sidefeet then add them to the output.
% \begin{macrocode}
\newcommand*{\m@mopsidefoot}{%
\ifvoid\sidefootins\else
\setbox\@outputbox \vbox{%
\sidefootcontents
\unvbox\@outputbox}
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@makecol}
% \begin{macro}{\mem@makecolbf}
% \begin{macro}{\@reinserts}
% \begin{macro}{\@mem@extranofeet}
% \begin{macro}{@mem@testifnofoot}
% Revise these to cater for the new sidefoot insert.\label{makecol}
% \changes{v3.7c}{2013/11/28}{Spurious space}
% \begin{macrocode}
\gdef\mem@makecol{%
\m@m@makecolintro
\ifvoid\footins
\setbox\@outputbox \box\@cclv
\else
\m@mopfootnote
\fi
\m@mdoextrafeet
\m@m@makecolfloats
\m@mopsidebar
\m@mopsidefoot
\m@m@makecoltext
\global \maxdepth \@maxdepth}
% \end{macrocode}
%
% If the \Lpack{footmisc} package is loaded all of our additions of
% extra footnotes, side footnotes, sidebar are lost. So we add them to
% their collection macro. This is especially important when
% \Lpack{footmisc} \emph{and} \Lpack{reledmac} are loaded with
% memoir. To play nice, we use the command hooks introduced in june 2021.
% \changes{v3.7q}{2022/02/17}{Added this fix for \Lpack{footmisc}}
% \begin{macrocode}
\IfFormatAtLeastTF{2021-06-01}{
% adding to "hook" in footmisc
\AddToHook{cmd/@makecol@appendblocks/after}{\m@mdoextrafeet\m@mopsidefoot\m@mopsidebar}
}{
\AtBeginDocument{
\@ifpackagelater{footmisc}{2011/06/07}{
\@memerror{You seem to have manually updated both memoir and^^J
footmisc on an older LaTeX kernel. Memoir is not compatible with
footmisc^^J version 2022/02/14 v6.0b on LaTeX kernels from before
2021/06/01. Please^^J update your LaTeX installation instead of
manually updating classes^^J or packages}{Update your LaTeX installation}
}{}
}
}
% \end{macrocode}
%
% \changes{v1.618033988b}{2010/02/17}{a bf was missing in \cs{m@mopfootnotebf}}
% \changes{v3.7c}{2013/11/28}{Spurious space}
% \begin{macrocode}
\gdef\mem@makecolbf{%
\m@m@makecolintro
\setbox\@outputbox \box\@cclv
\m@m@makecolfloats
\ifvoid\footins
\else
\m@mopfootnotebf
\fi
\m@mdoextrafeet
\m@mopsidebar
\m@mopsidefoot
\m@m@makecoltext
\global \maxdepth \@maxdepth}
% \end{macrocode}
% \changes{v3.6d}{2010/06/30}{There should not be an \cs{else} on the
% kludge line}
% \changes{v3.6f}{2010/08/22}{There should not be an \cs{else} on the
% kludge line, then remember to remove it}
% \begin{macrocode}
\gdef\@reinserts{%
\ifvoid\footins\else\insert\footins{\unvbox\footins}\fi
\m@mdodoreinextrafeet
\ifvbox\@kludgeins\insert\@kludgeins{\unvbox\@kludgeins}\fi
\ifvoid\sideins\else\insert\sideins{\unvbox\sideins}\fi
\ifvoid\sidefootins\else\insert\sidefootins{\unvbox\sidefootins}\fi}
% \end{macrocode}
%
% The easy way of extending the \cs{clearpage} code is by:
% \begin{verbatim}
% \renewcommand*{\@mem@extranofeet}{%
% \ifvoid\sidefootins\else\@mem@nofootfalse\fi}
% \end{verbatim}
% but as so many other changes have to be made it's probably better to
% leave that alone and change \cs{@mem@testifnofoot} directly.
% \begin{macrocode}
\renewcommand*{\@mem@testifnofoot}{%
\@mem@nofoottrue
\ifvoid\footins\else\@mem@nofootfalse\fi
\ifvoid\footinsv@r\else\@mem@nofootfalse\fi
\ifvoid\sideins\else\@mem@nofootfalse\fi
\ifvoid\sidefootins\else\@mem@nofootfalse\fi
\@mem@extranofeet}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{The sidefootnote macros}
%
% The macros here are essentially a copy of the ones for \cs{footnote}.
% I have not done anything about sidefootnotes in minipages, as I can't
% imagine a use for them while simultaneously making the final appearance
% looking good.
%
% The usual counter.
% \begin{macrocode}
\newcounter{sidefootnote}
\renewcommand{\thesidefootnote}{\@arabic\c@sidefootnote}
\@addtoreset{sidefootnote}{chapter}
% \end{macrocode}
%
% By using: \\
% \verb?\letcountercounter{sidefootnote}{footnote}? \\
% the same counter will be used for both footnotes and sidefootnotes.
% This can be reverted to separate counters by; \\
% \verb?\unletcounter{sidefootnote}?
%
% \begin{macro}{\sidefoottextfont}
% The font for the sidefootnotes.
% \changes{v1.61803398d}{2010/02/06}{\cs{sidefoottextfont} is already
% defined by the initial issuing of \cs{setsidefeet}}
% \begin{macrocode}
%\newcommand*{\sidefoottextfont}{\normalfont\footnotesize}
% \end{macrocode}
% \end{macro}
%
% The remainder of the code is a copied from that for \cs{footnote}
% but with the appropriate variables for \cs{sidefootnote}s
%
% \begin{macro}{\@sidempfn}
% \begin{macro}{\thesidempfn}
% \begin{macrocode}
\newcommand*{\@sidempfn}{sidefootnote}
\newcommand*{\thesidempfn}{\thesidefootnote}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@makesidefnmark}
% \begin{macrocode}
\newcommand*{\@makesidefnmark}{\hbox{\@textsuperscript{%
\normalfont\@thesidefnmark}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@preamsidefntext}
% \begin{macrocode}
\newcommand{\@preamsidefntext}{%
\interlinepenalty\interfootnotelinepenalty
\floatingpenalty \@MM
\splittopskip=\footnotesep
\splitmaxdepth=\dp\strutbox
\@parboxrestore}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sidefootnotetext}
% \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont}
% to \cs{sidefoottextfont}}
% \changes{v3.6g}{2010/09/19}{made 'single spacing' configurable}
% \begin{macrocode}
\newcommand{\@sidefootnotetext}[1]{\insert\sidefootins{%
\hsize\sidefootwidth
\@parboxrestore
\def\baselinestretch{\m@m@footnote@spacing}%
\sidefootform \normalsize\normalfont\sidefoottextfont
\splittopskip=\ht\strutbox
\splitmaxdepth=\dp\strutbox
\allowbreak
\prevdepth=\dp\strutbox
\vskip-\parskip
\protected@edef\@currentlabel{%
\csname p@sidefootnote\endcsname\@thesidefnmark}%
\color@begingroup
\@makesidefntext{{\sidefoottextfont #1}}%
\color@endgroup
\ifvmode\else
\unskip\@finalstrut\strutbox
\fi
\par
\ifdim\prevdepth>\dp\strutbox \prevdepth=\dp\strutbox\fi
\ifdim\prevdepth>99\p@
\nobreak
\vskip-\prevdepth
\allowbreak
\vskip\dp\strutbox
\fi
\vskip\sidefootvsep}%
\m@mmf@prepare}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sidefootnotemark}
% \begin{macrocode}
\newcommand*{\@sidefootnotemark}{%
\leavevmode
\ifhmode
\edef\@x@sf{\the\spacefactor}%
\m@mmf@check
\nobreak
\fi
\@makesidefnmark
\m@mmf@prepare
\ifhmode\spacefactor\@x@sf\fi
\relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidefootnote}
% \begin{macrocode}
\newcommand*{\sidefootnote}{\@ifnextchar[
\@xsidefootnote{\stepcounter\@sidempfn
\protected@xdef\@thesidefnmark{\thesidempfn}%
\@sidefootnotemark\@sidefootnotetext}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xsidefootnote}
% \begin{macrocode}
\def\@xsidefootnote[#1]{%
\begingroup
\csname c@\@sidempfn\endcsname #1\relax
\unrestored@protected@xdef\@thesidefnmark{\thesidempfn}%
\endgroup
\@sidefootnotemark\@sidefootnotetext}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidefootnotemark}
% \begin{macrocode}
\newcommand{\sidefootnotemark}{%
\@ifnextchar[
\@xsidefootnotemark
{\stepcounter{sidefootnote}%
\protected@xdef\@thesidefnmark{\thesidefootnote}%
\@sidefootnotemark}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xsidefootnotemark}
% \begin{macrocode}
\def\@xsidefootnotemark[#1]{%
\begingroup
\c@sidefootnote #1\relax
\unrestored@protected@xdef\@thesidefnmark{\thesidefootnote}%
\endgroup
\@sidefootnotemark}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidefootnotetext}
% \begin{macrocode}
\newcommand*{\sidefootnotetext}{%
\@ifnextchar[
\@xsidefootnotetext
{\protected@xdef\@thesidefnmark{\thesidempfn}%
\@sidefootnotetext}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xsidefootnotetext}
% \begin{macrocode}
\def\@xsidefootnotetext[#1]{%
\begingroup
\csname c@\@sidempfn\endcsname #1\relax
\unrestored@protected@xdef\@thesidefnmark{\thesidempfn}%
\endgroup
\@sidefootnotetext}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sidefootmarkstyle}
% \begin{macro}{\sidefootscript}
% \begin{macro}{\makesidefootmarkhook}
% \begin{macro}{\sidefootfootmark}
% \begin{macrocode}
\newcommand*{\sidefootmarkstyle}[1]{\def\sidefootscript##1{#1}}
\newcommand*{\makesidefootmarkhook}{}
\newcommand*{\sidefootfootmark}{%
\ifdim\sidefootmarkwidth < \z@
\llap{\hb@xt@ -\sidefootmarkwidth{%
\hss\normalfont\sidefootscript{\@thesidefnmark}}%
\hspace*{-\sidefootmarkwidth}}%
\else
\ifdim\sidefootmarkwidth = \z@
{\normalfont\sidefootscript{\@thesidefnmark}}%
\else
\hb@xt@\sidefootmarkwidth{\hss\normalfont\sidefootscript{\@thesidefnmark}}%
\fi
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\makesidefootmark}
% \changes{v1.61803398d}{2010/02/04}{Made \cs{makesidefootmark} long
% as the similar \cs{footnote} command, otherwise one cannot make side
% footnotes containign several paragraphs}
% \begin{macrocode}
\newcommand{\makesidefootmark}[1]{%
\leavevmode
\parindent \sidefootparindent\noindent
\leftskip\sidefootmarksep\relax
\advance\leftskip \sidefootmarkwidth \null\nobreak\hskip -\leftskip\relax
\makesidefootmarkhook\relax
\sidefootfootmark #1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makesidefntext}
% \begin{macrocode}
\newcommand{\@makesidefntext}[1]{\makesidefootmark #1}
% \end{macrocode}
% \end{macro}
%
% Final layout.
% \begin{macro}{\sidefootmarkwidth}
% \begin{macro}{\sidefootmarksep}
% \begin{macro}{\sidefootparindent}
% \changes{v1.61803398d}{2010/02/04}{changed the defaults for
% \cs{sidefootmarkwidth} and \cs{sidefootmarksep} to zero, from 1em
% and -1em, looks better with the narrow margins}
% \begin{macrocode}
\newlength{\sidefootmarkwidth}
\setlength{\sidefootmarkwidth}{0em}
\newlength{\sidefootmarksep}
\setlength{\sidefootmarksep}{0em}
\newlength{\sidefootparindent}
\setlength{\sidefootparindent}{1em}
\sidefootmarkstyle{\textsuperscript{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{End notes}
%
% \changes{v3.6h}{2011/01/19+}{Reimplemented page notes}
% This used to be a copy of the \Lpack{pagenote} package, with minor
% amendments. But it turned out that the implementation used by
% \Lpack{pagenote} at that time, had a few serious flaws. In this
% implementation we will instead turn to the trick used by the
% \Lpack{endnotes} package to overcome the same problem.
% For the sake of history, let us summarise what the actual problem
% was. Basically the command \cs{pagenote}\marg{text} would write an
% entry to an external file in the following format
% \begin{verbatim}
% \noteentry{nom}{id}{text}{pagenum}
% \end{verbatim}
% and when typesetting the page notes, this file would be read into
% the document and \cs{noteentry} would typeset each page note. The
% main problem here is \verb|{text}| which is written verbatimly to
% the external file, but it is written on a single line!, thus an
% input like this
% \begin{verbatim}
% \pagenote{Test%
% test}
% \end{verbatim}
% would give us the entry
% \begin{verbatim}
% \noteentry{num}{id}{Test%test}{pagenum}
% \end{verbatim}
% oops! This is what we will solve using inspiration from
% \Lpack{endnotes}, kudos to John Lavagnino.
%
%
% \begin{macro}{\ifm@mpnpageopt}
% \begin{macro}{\ifm@mpncontopt}
% We need two flags for the options.
% \cs{m@mpnpageoptfalse} means that page numbers are not available and
% \cs{m@mpncontopt} means that note numbers are reset at each \cs{chapter}.
% \begin{macrocode}
\newif\ifm@mpnpageopt
\m@mpnpageoptfalse
\newif\ifm@mpncontopt
\m@mpncontoptfalse
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@pagenote}
% \begin{macro}{\thepagenote}
% We need a counter for the notes. This is the default definition.
% \begin{macrocode}
\newcounter{pagenote}[chapter]
\renewcommand{\thepagenote}{\arabic{pagenote}}
\setcounter{pagenote}{0}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\notepageref}
% \begin{macro}{\continuousnotenums}
% \changes{v3.6h}{2011/01/19}{Removed references to pagenote package}
% Let the user change the default options. \cs{notepageref} makes
% page numbers available in the typeset list of page note and
% \cs{continuousnotenums} means that notes will be numbered
% continuously throughout the document.
% \begin{macrocode}
\newcommand*{\notepageref}{\m@mpnpageopttrue}
\@onlypreamble\notepageref
\newcommand*{\continuousnotenums}{%
\counterwithout{pagenote}{chapter}
\renewcommand{\thepagenote}{\arabic{pagenote}}}
\@onlypreamble\continuousnotenums
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\ifmempagenotes}
% Need to check if notes are required.
% \begin{macrocode}
\newif\ifmempagenotes
\mempagenotesfalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makepagenote}
% This sets up the note file. At the end it emasculates itself so it can only
% be used once.
% \begin{macrocode}
\newcommand*{\makepagenote}{%
\newwrite\@notefile
\immediate\openout\@notefile=\jobname.ent
\mempagenotestrue
% \end{macrocode}
% \begin{macro}{\pagenote}
% Make sure that this has a useful definition.
% \changes{v3.6h}{2011/01/19}{Made \cs{pagenote} robust}
% \changes{v3.6j}{2011/03/01}{Removed \cs{@sanitize}}
% \changes{v3.6k}{2011/03/08}{Actually need \cs{@sanitize} for the
% optional argument. But we need to remove spaces from this}
% \begin{macrocode}
\DeclareRobustCommand\pagenote{\@bsphack\begingroup
\rem@special{\ }% <--- added
\@sanitize
\m@m@wrpnote}%
% \end{macrocode}
% \end{macro}
% \changes{v3.6h}{2011/01/19}{Added the redefinition of \cs{mem@footto@pagenote}}
% \begin{macro}{\mem@footto@pagenote}
% The same as for \cs{pagenote} but here we use a special version of
% the writing macro that will ignore the optional argument. This will
% internally be used when the user ask for foot notes to be turned
% into page notes.
% \changes{v3.6j}{2011/03/01}{Removed \cs{@sanitize}}
% \changes{v3.6k}{2011/03/08}{Actually need \cs{@sanitize} for the
% optional argument. But we need to remove spaces from this}
% \begin{macrocode}
\DeclareRobustCommand\mem@footto@pagenote{\@bsphack\begingroup
\rem@special{\ }% <--- added
\@sanitize
\def\mem@pn@step{01}%
\m@m@wrpnote}%
% \end{macrocode}
% \end{macro}
% At the end we make sure \cs{makepagenote} can only do something once.
% \begin{macrocode}
\typeout{Writing note file \jobname.ent}%
\let\makepagenote\@empty}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\immediate@protected@write}
% We might have to do some immediate writes. This is an immediate
% version of the kernel \cs{protected@write}.
% \changes{v3.7i}{2019/11/15}{changed to \cs{providecommand} and
% removed the \cs{if@nobreak} line, also removed the edef part,
% suggested by Davis Carlisle}
% \begin{macrocode}
\providecommand{\immediate@protected@write}[3]{%
\begingroup
#2%
\let\protect\@unexpandable@protect
%\edef\reserved@a{\immediate\write#1{#3}}%
%\reserved@a
\immediate\write#1{#3}%
\endgroup
%\if@nobreak\ifvmode\nobreak\fi\fi%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@m@pnwrite}
% \begin{macro}{\m@m@pnwrited}
% In the old implementation we used \cs{immediate@protected@write}
% unless the user asked for page numbers in the notes, the new
% implementation use the same writing method for all cases, for easy
% of notation we collect it in a macro. Seems UTF8 is an interesting
% beast, \cs{immediate@protected@write} can write it to disk, but
% \cs{m@m@pnwrite} cannot. To get past this we also include a version
% that has an embedded \cs{detokenize} (thanks to Heiko Oberdiek for
% that hint). We also add a \% at the end of the \cs{m@m@pnwrited}
% process (don't think \cs{m@m@pnwrite} needs it). This is handy in
% those cases where the user is using a design which rely on there not
% being any spaces after the note text.
% \changes{v3.6k}{2011/04/06}{Added the version with \cs{detokenize}}
% \begin{macrocode}
% \changes{v3.7i}{2019/06/07}{Added \cs{@percentchar} to
% \cs{m@m@pnwrited}}
\newcommand{\m@m@pnwrite}[3]{\immediate\write#1{#3}}
\newcommand{\m@m@pnwrited}[3]{\immediate\write#1{\detokenize{#3}\@percentchar}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pnchap}
% \begin{macro}{\pnschap}
% Redefine these for different subheadings in the notes list.
% \begin{macrocode}
\newcommand*{\pnchap}{\f@rtoc}
\newcommand*{\pnschap}{\f@rbdy}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\c@pagenoteshadow}
% \begin{macro}{\mem@pn@step}
% \begin{macro}{\mem@pn@lastkern}
% Utilities, a counter to provide us with a unique name for each page
% note, a toggle macro and a length to hold a lastkern (because
% someone may hide it from us).
% \begin{macrocode}
\newcounter{pagenoteshadow}
\setcounter{pagenoteshadow}{0}
\newcommand\mem@pn@step{00} % i.e. true
\newlength\mem@pn@lastkern
% \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@m@wrpnote}
% This writes the note information to the note file. If the optional argument
% is empty it increments the
% note counter and calls \cs{notenumintext} to handle its appearance in
% the body text. We write an entry of the following design
% \begin{verbatim}
% \startnoteentry{notenumber}{id}{auto label key}{hyperref}
% macro:->text
% \endnoteentry
% \end{verbatim}
%
% \begin{macro}{\m@m@pnwrite@fourtharg}
% \begin{macro}{\m@m@pnwrite@fourtharg@hyperref}
% In order for us to add \Lpack{hyperref} support we will need to
% record the hyperref anchor label into the page note data. We do this
% though \verb|\m@m@pnwrite@fourtharg|, which by default just adds
% \verb|{}| to the page note data. \Lpack{memhfixc} makes it point
% toward \verb|\m@m@pnwrite@fourtharg@hyperref| instead. We make sure
% to pass it the optional argument from \verb?\pagenote?, if this is
% precent a hyper anchor is not passed on.
% \changes{v3.6k}{2013/05/17}{Macro needs to test an argument}
% \begin{macrocode}
\newcommand\m@m@pnwrite@fourtharg[1]{\m@m@pnwrited\@notefile{}{{}}}
\newcommand\m@m@pnwrite@fourtharg@hyperref[1]{%
\@ifmtarg{#1}{%
\m@m@pnwrite\@notefile{}{{\Hy@pagenote@currentHref}}%
}{%
\m@m@pnwrited\@notefile{}{{}}%
}}
% \end{macrocode}
% \end{macro}
% % \end{macro}
%
% \changes{v1.61803}{2008/05/25}{Made \cs{m@m@wrpnote} match the effect
% described in memman regarding the optional argument.}
% \changes{v3.6h}{2011/01/19}{Changed the internal implementation}
% \begin{macrocode}
\newcommand{\m@m@wrpnote}[2][]{%
% \end{macrocode}
% If \Lpack{hyperref} is loaded it issues a whatisit and thus
% hide/reset the last kern, which is needed for the algorithm used for
% the multiple notes in a row feature (adding commas). So we start by
% storing the last kern, and refstep a shadow counter such that we
% can generate more or less unique label keys.
% \begin{macrocode}
\mem@pn@lastkern=\lastkern%
\refstepcounter{pagenoteshadow}%
% \end{macrocode}
% If the user asks for it enable page back refs, we use labels and
% references for this (bonus: automatic support for hyperlinks if
% \Lpack{hyperref} is available).
% \begin{macrocode}
\ifm@mpnpageopt%
\phantomsection%
\label{pagenote\thepagenoteshadow-\thesheetsequence}%
\fi%
% \end{macrocode}
% Next we want to be able to reuse this macro just for writing the
% entry to disk, no writing a marker in the text (think replacement
% for \cs{footnotetext}), we use the toggle for this and also remember
% to re-insert the code needed for comma separated multiple markers
% \begin{macrocode}
\if\mem@pn@step%
\@ifmtarg{#1}{\refstepcounter{pagenote}%
% this enables the ^{1,2} feature
\ifdim\mem@pn@lastkern=\multiplefootnotemarker%
\m@mmf@prepare% rerun
\fi%
\mem@pn@multiple@marker{\notenumintext{\thepagenote}}%
% \end{macrocode}
% \changes{3.7i}{2019/05/28}{Added the special kern also if the
% optional arg is empty. Otherwise the multiple marker might not work
% under hyperref. Reported in private email}
% \begin{macrocode}
}{\m@mmf@prepare}%
\fi%
% \end{macrocode}
% Check if this is the first note in a division, and if so indicate this
% in the file.
% \changes{v3.6h}{2011/01/25}{Added \cs{pagenotesubheadstarred}}
% \begin{macrocode}
\ifm@mpn@new@chap%
\global\m@mpn@new@chapfalse%
\addtonotes{\string\pagenotesubhead{\@chapapp}{\thechapter}{\pnchap}}%
\fi%
\ifm@mpn@new@schap%
\global\m@mpn@new@schapfalse%
\addtonotes{\string\pagenotesubheadstarred{\@chapapp}{}{\pnschap}}%
\fi%
% \end{macrocode}
% Next we write to the notes file. Instead of writing everything as a
% macro with arguments, we will use three writes. One to start a new
% entry with a few (non-text) arguments, then the text itself, and
% finally an end of entry marker macro. There is a slight complication
% here. The \verb|#1| may be UTF8 so it has to be written unexpanded
% to disk, but macros like \verb|\thepagenote| need to be
% expanded. Luckily \TeX\ eats up spaces when reading arguments, so we
% simply writte several lines using two different writing methods.
% \changes{v3.6k}{2011/04/06}{Rewritten to use a different writing method}
% \begin{macrocode}
\m@m@pnwrite\@notefile{}%
{\string\startnoteentry{\thepagenote}}%
\m@m@pnwrited\@notefile{}{{#1}}%
\m@m@pnwrite\@notefile{}%
{{pagenote\thepagenoteshadow-\thesheetsequence}}%
% \end{macrocode}
% Add the fourth argument.
% \changes{v3.6k}{2013/05/16}{Added fourth argument for the note data}
% \changes{v3.6k}{2013/05/17}{Fourth arg, should depend on \#1}
% \begin{macrocode}
\m@m@pnwrite@fourtharg{#1}%
% \end{macrocode}
% Getting the newline stuff to work require
% \verb|\immediate\write| which we defined earlier. We then write the
% text `verbatimly' using the detokenized macro.
% \changes{v3.6k}{2011/04/06}{No longer any need for the \cs{meaning} construction.}
% \begin{macrocode}
\begingroup%
\newlinechar='40%
\m@m@pnwrited\@notefile{}{#2}%
\endgroup%
% \end{macrocode}
% Remember to also write a marker that ends the entry.
% \begin{macrocode}
\m@m@pnwrite\@notefile{}%
{\string\endnoteentry}%
\endgroup%
\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pagenote}
% \begin{macro}{\mem@footto@pagenote}
% The user command to generate a note. It is given substance
% by \cs{makepagenote}. Supplied with a special version used if the
% user asks for all footnotes to be turned into page notes.
% \changes{v3.6h}{2011/01/19}{Added \cs{mem@footto@pagenote}}
% \begin{macrocode}
\def\pagenote{\@bsphack\begingroup \@sanitize\m@m@pagenote}
\let\mem@footto@pagenote\pagenote
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@m@pagenote}
% \begin{macrocode}
\newcommand{\m@m@pagenote}[2][]{\endgroup\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pagetofootnote}
% \begin{macro}{\foottopagenote}
% \begin{macro}{\memsavefootnote}
% \begin{macro}{\memsavepagenote}
% Let the user change pagenotes to footnotes, or vice-versa. In either
% case the optional argument is ignored.
% \changes{v3.6h}{2010/12/07}{\cs{footnote} should be long}
% \changes{v3.6h}{2010/12/09}{because of the way
% \cs{pagenote} is defined, we cannot redefine \cs{footnote} to have
% any arguments, we need to go another route}
% \changes{v3.6h}{2010/12/09}{Added a check for the race condition}
% We have a race condition, if both \cs{pagetofootnote} and
% \cs{makepagenote} is issued in the same document,
% \cs{pagetofootnote} need to come last.
% \begin{macrocode}
\newcommand*{\pagetofootnote}{%
\let\memsavepagenote\pagenote
\renewcommand{\pagenote}[2][]{\footnote{##2}}
% \end{macrocode}
% Basic idea is, if pagenotes mode is on when \cs{pagetofootnote} is
% issued, everything is fine. Else we test at end document (because
% \cs{makepagenote} can go anywhere).
% \begin{macrocode}
\ifmempagenotes\else%
\AtEndDocument{%
\ifmempagenotes%
\@memerror{The use of \string\pagetofootnote\space before
\string\makepagenote\space^^Jdoes not make
sense. \string\makepagenote\space make some redefinitions that
are not picked up if \string\pagetofootnote\space is issued
before \string\makepagenote
}{}
\fi
}
\fi
}
% \end{macrocode}
% Next the more challenging one. We make the footnote counter act as
% the page note counter, this ensure that \cs{footnotemark} still work
% when the user ask to have footnotes converted into page
% notes. \cs{footnotetext} is the same as the page note writer macro,
% but without writing the marker, here we use the special page note macro.
% \begin{macrocode}
\newcommand*{\foottopagenote}{%
\let\memsavefootnote\footnote
% \end{macrocode}
% \changes{v3.6k}{2013/05/02}{Remember to remove footnote counter from
% chapter reset}
% Since we alias the footnote counter to the pagenote counter, we need
% to rewmove the footnote counter from the chapter reset, otherwise
% \cs{continuousnotenums} will be wrong.
% \begin{macrocode}
\counterwithout{footnote}{chapter}
\letcountercounter{footnote}{pagenote}
\renewcommand\footnotetext[2][]{\mem@footto@pagenote{##2}}
\renewcommand{\footnote}[2][]{\pagenote{##2}}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\addtonotes}
% \cs{addtonotes}\marg{text} puts \meta{text} into the notes file.
% \changes{v3.6i}{2011/02/18}{\cs{addtonotes} need \cs{immediate@protected@write}}
% \begin{macrocode}
\newcommand{\addtonotes}[1]{\ifmempagenotes
\IfFileExists{\jobname.ent}{\immediate@protected@write\@notefile{}{#1}}{\mempnofilewarn}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\notenumintext}
% \begin{macro}{\notenuminnotes}
% \cs{notenumintext}\marg{notenum} typesets \meta{notenum} (in the
% body text).
% \begin{macrocode}
\newcommand{\notenumintext}[1]{%
\textsuperscript{#1}}
% \end{macrocode}
% \cs{notenuminnotes}\marg{notenum} typesets \meta{notenum} (i.e. the
% very first item when typesetting a note).
% \begin{macrocode}
\newcommand{\notenuminnotes}[1]{%
{\normalfont #1.}\space}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\noteentry}
% \changes{v3.6}{2010/12/14}{explanation was wrong}
% \changes{v3.6h}{2011/01/19}{removed}
% \cs{noteentry}\marg{notenum}\marg{id}\marg{text}\marg{pagenum}
% typesets a note. This macro is not used anymore.
% \begin{macrocode}
%\newcommand{\noteentry}[4]{} % not used any more!
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\idtextinnotes}
% \cs{idtextinnotes}\marg{id text} typesets the note's \meta{id text}.
% \begin{macrocode}
\newcommand{\idtextinnotes}[1]{%
[#1]\space}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\noteidinnotes}
% \cs{noteidinnotes}\marg{notenum}\marg{id} is used to typeset the note
% identification (in the note listing). It is set so that it typesets the
% \meta{id} if it is not empty, otherwise it sets the \meta{notenum}.
% \begin{macrocode}
\newcommand{\noteidinnotes}[2]{%
\@ifmtarg{#2}{%
\notenuminnotes{#1}}{\idtextinnotes{#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pageinnotes}
% \begin{macro}{\printpageinnotes}
% \begin{macro}{\printpageinnoteshyperref}
% \changes{v3.6h}{2011/01/19}{Changed to match new implementation}
% \cs{pageinnotes}\marg{key} calls
% \cs{printpageinnotes}\marg{key} to typeset the originating
% page number (in the note), but only if the \cs{notepageref} declaration
% has been used. Remember we provide an automatically generated label
% key, thus we use \cs{pageref} to get the page number. We provide a
% \Lpack{hyperref} version which is automatically used whenever
% \Lpack{hyperref} is loaded.
% \begin{macrocode}
\newcommand{\pageinnotes}[1]{%
\ifm@mpnpageopt \printpageinnotes{#1}\fi}
\newcommand*{\printpageinnotes}[1]{%
(\pagerefname\ \pageref{#1})\space}
\newcommand\printpageinnoteshyperref[1]{%
(\hyperref[#1]{\pagerefname\ \pageref*{#1}})\space}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\noteinnotes}
% \cs{noteinnotes}\marg{text} is used to typeset the note's text
% (in the note list). This macro is not used any more, but doesn't do
% any harm to leave it here.
% \begin{macrocode}
\newcommand{\noteinnotes}[1]{#1} % not used anymore!
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\prenoteinnotes}
% \begin{macro}{\postnoteinnotes}
% These are called immediately before and after the note information is
% typeset.
% \begin{macrocode}
\newcommand{\prenoteinnotes}{\par\noindent}
\newcommand{\postnoteinnotes}{\par}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\prenotetext}
% \begin{macro}{\postnotetext}
% Thise two macros are executed just before and just after the note
% text. Does nothing by default.
% \begin{macrocode}
\newcommand\prenotetext{}
\newcommand\postnotetext{}
% \end{macrocode}
%
% \end{macro}
% \end{macro}
%
% \begin{macro}{\notesname}
% \begin{macro}{\notedivision}
% Heading for note list.
% \begin{macrocode}
\providecommand*{\notesname}{Notes}
\newcommand*{\notedivision}{\chapter{\notesname}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{v3.6h}{2010/12/14}{typo}
% \changes{v3.6h}{2011/01/19}{There is no reason to use two macros to
% implement a starred and non starred version in this case.}
% \begin{macro}{\printpagenotes}
% \begin{macro}{\printpagenotes*}
% User commands to print the note file.
% \begin{macrocode}
\newcommand*{\printpagenotes}{\@ifstar{\mem@printpagenotes{00}}{\mem@printpagenotes{01}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\mempnofilewarn}
% Warning when the notes file does not exist.
% \begin{macrocode}
\newcommand*{\mempnofilewarn}{%
\ClassWarning{memoir}{There is no .ent file}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\startnoteentrystart}
% \begin{macro}{\endnoteentryend}
% \begin{macro}{\pagenoteanchor}
% \begin{macro}{\pagenotebyanchor}
% Utility macros to handle page note formating and hyperlinks.
% \changes{v3.6k}{2013/05/16}{altered to use four arguments instead of three}
% \changes{v3.6k}{2013/05/16}{Added page note anchor}
% \changes{v3.6k}{2013/05/17}{Forgot about labels in the note text.}
% \changes{v3.7g}{2018/01/03}{Added \cs{phantomsection}, otherwise
% \cs{label} does not work correctly. Reported in \texttt{https://tex.stackexchange.com/q/408448/3929}}
% \begin{macrocode}
\newcommand\startnoteentrystart[4]{%
\prenoteinnotes%
\noteidinnotes{#1}{#2}%
\@ifmtarg{#2}{\phantomsection\def\@currentlabel{#1}}{}%
\pagenoteanchor{#4}%
\pageinnotes{#3}%
\prenotetext%
}
\def\endnoteentryend{\postnotetext\postnoteinnotes}
\let\pagenoteanchor\@gobble
% \end{macrocode}
% The page note hyper anchor should of course only be added when there
% is an anchor.
% \changes{v3.6k}{2013/05/17}{Forgot to test the argument}
% \begin{macrocode}
\newcommand\pagenotehyperanchor[1]{%
\expandafter\@ifmtarg\expandafter{#1}{}{%
\Hy@raisedlink{\hyper@@anchor{#1}{\relax}}}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\mem@printpagenotes}
% \begin{macro}{\startnoteentry}
% \begin{macro}{\ednoteentry}
% The internal macro for printing the list of page notes. The two
% macros \cs{startnoteentry} and \cs{endnoteentry} are also defined here.
% \changes{v3.6k}{2011/03/09}{Start and end entry better be long}
% \changes{v3.6k}{2011/04/06}{We no longer use \cs{meaning} when
% writing the data to disk, so no need to remove \texttt{>} any
% more. Also removed the safe GT stuff}
% \begin{macrocode}
% \changes{v3.6k}{2013/05/16}{\cs{startnoteentry} should expect four args}
\newcommand\mem@printpagenotes[1]{%
\ifmempagenotes
\notedivision
\IfFileExists{\jobname.ent}{%
\begingroup
\long\def\startnoteentry####1####2####3####4{%
\begingroup
\startnoteentrystart{####1}{####2}{####3}{####4}%
}
\long\def\endnoteentry{\endnoteentryend\endgroup}
\immediate\closeout\@notefile
\input{\jobname.ent}%
\if#1\immediate\openout\@notefile=\jobname.ent\fi%
\endgroup
}{%
\mempnofilewarn
}%
\fi%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@sprintpagenotes}
% Macro implementing \cs{printpagenotes*}. Removed
% \changes{v3.6h}{2011/01/20}{Removed}
% \begin{macrocode}
% \newcommand*{\@sprintpagenotes}{%
% \ifmempagenotes
% \notedivision
% \IfFileExists{\jobname.ent}{%
% \immediate\closeout\@notefile
% \input{\jobname.ent}%
% \immediate\openout\@notefile=\jobname.ent%
% }{%
% \mempnofilewarn
% }%
% \fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@printpagenotes}
% Macro implementing \cs{printpagenotes}. Removed
% \changes{v3.6h}{2011/01/20}{Removed}
% \begin{macrocode}
% \newcommand*{\@printpagenotes}{%
% \ifmempagenotes
% \notedivision
% \IfFileExists{\jobname.ent}{%
% \immediate\closeout\@notefile
% \input{\jobname.ent}%
% }{%
% \mempnofilewarn
% }
% \fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pagenotesubhead}
% \begin{macro}{\pagenotesubheadstarred}
% \changes{v3.6h}{2011/01/25}{Added \cs{pagenotesubheadstarred}}
% The section heading before each set of notes. \\
% \cs{pagenotesubhead}\marg{chaptername}\marg{number}\marg{title}
% The \cs{pagenotesubheadstarred} macro is used for unnumbered
% devisions. By default it is the same as \cs{pagenotesubhead}, but
% the user can change this. For example it may look odd with an title
% like this: >>Chapter Title<< when there is no number.
% \begin{macrocode}
\newcommand*{\pagenotesubhead}[3]{%
\section*{#1 #2 #3}}
\newcommand\pagenotesubheadstarred{\pagenotesubhead}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{Change marks} \label{sec:vct}
%
% When preparing a manuscript it normally goes through
% several iterations. The commands provided may be used to identify
% changes made to a document during its life cycle.
%
% The code for this part of the class is based on the version
% controls in the \Lpack{iso} class~\cite{ISOCLASS}.
%
% \subsection{Print control}
%
% Members of the development group often need to see the changes
% between document versions, while the general public does not.
% \begin{macro}{\ifchangemarks}
% This controls the appearence of the version controls defined
% below.
% \begin{macrocode}
\newif\ifchangemarks\changemarksfalse
% \end{macrocode}
% The marks only work properly when the \Lopt{draft} option
% is in effect. Also, the command \cs{changemarkstrue} must be
% put in the document preamble.
% \end{macro}
%
% \begin{macro}{\changemarks}
% \begin{macro}{\nochangemarks}
% More user friendly version of \cs{changemarks(true/false)}.
% \changes{v1.61803}{2008/01/30}{Added \cs{changemarks} and \cs{nochangemarks}}
% \begin{macrocode}
\newcommand*{\changemarks}{\changemarkstrue}
\newcommand*{\nochangemarks}{\changemarksfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\v@rid}
% This acts as an alias for \cs{marginpar} when both \cs{ifchangemarks} is
% true and the \Lopt{draft} option is in effect, otherwise it throws
% away its two arguments.
% \changes{v1.2}{2002/07/27}{Added \cs{@bsphack} and \cs{@esphack} to \cs{v@rid}}
% \begin{macrocode}
\newcommand{\v@rid}[2]{%
\@bsphack
\ifchangemarks
\ifdraftdoc
\marginpar[#1]{#2}%
\fi\fi
\@esphack}
% \end{macrocode}
% \end{macro}
%
% \subsection{Change marking}
%
% The following commands flag changes in the typeset document. Each of
% the commands takes one parameter which is intended to be a
% `change number' or comment for tracking purposes. A symbol and
% the \meta{change-id} is put into the margin near where the command
% is given. The marking commands should be attached to some word or
% punctuation mark in the text otherwise extraneous spaces may creep
% into the final document.
% \changes{v1.2}{2002/07/27}{Added \cs{@bsphack} and \cs{@esphack} to changemarks}
% \begin{macro}{\added}
% \cs{added}\marg{change-id}
% Flags, with the symbol $\oplus$, that something has been added
% to the manuscript.
% \begin{macrocode}
\newcommand{\added}[1]{%
\@bsphack
\ifchangemarks
\v@rid{\small$\oplus$ #1}{\small$\oplus$ #1}%
\fi
\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\deleted}
% \cs{deleted}\marg{change-id}
% Flags, with the symbol $\neq$, that something has been deleted
% from the manuscript.
% \begin{macrocode}
\newcommand{\deleted}[1]{%
\@bsphack
\ifchangemarks
\v@rid{\small$\neq$ #1}{\small$\neq$ #1}%
\fi
\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\changed}
% \cs{changed}\marg{change-id}
% Flags, with the symbol $\Leftrightarrow$, that something
% has been changed in the text.
% \begin{macrocode}
\newcommand{\changed}[1]{%
\@bsphack
\ifchangemarks
\v@rid{\small$\Leftrightarrow$ #1}{\small$\Leftrightarrow$ #1}%
\fi
\@esphack}
% \end{macrocode}
% \end{macro}
%
% \section{Trimming marks}
%
% The \Lopt{showtrims} options prints trimming marks at the corners
% of the logical page. The code for this comes from ideas gleaned
% from Martin Schr\"{o}der's \Lpack{everyshi} package~\cite{EVERYSHI}
% and Melchior Franz's \Lpack{crop} package~\cite{CROP}.
% The implementation and any errors are mine.
%
% The implementation up to October 2002 was limited to putting a cross
% at the page corners. The manual directed users to the \Lpack{crop}
% packge if they wanted anything more. In October 2002 the implementation
% was substantially extended. The background to this is below.
%
% Before the release of version 1.7 of \Lpack{crop} in May 2002 its
% author asked me to make some changes to \Lpack{memoir} that would be
% helpful to him, and I did so. Later he told me that the changes were
% unnecessary and I reverted to the original \Lpack{memoir} code.
%
% On 2002/10/06 Peter Heslin (\url{peter.heslin@ucd.ie}) started a
% thread on \url{comp.text.tex} titled `Incompatibility of memoir.cls
% and crop.sty' in which he said that \Lpack{memoir} and \Lpack{crop}
% did not seem to work together. The following are some snippets from
% that thread, identified by the various proponents.
% \begin{description}
% \item[crop] Ah, yes. It cannot work with all those \cs{settrims} etc.
% crop.sty does only respect \verb?\stock{width,height}?,
% but none of the other memoir specific trim marks stuff \ldots
%
% \item[crop] \ldots I'm not a memoir expert. crop.sty respects all the
% usual LaTeX paper dimensions and simply puts the marks around the
% page. It works with all standard classes and the KOMA classes. memoir
% seems to do things completely differently \ldots
%
% Sorry, but I'm afraid I have to pass the problem to the memoir
% author. \ldots
%
% \item[memoir] I will try and take a look at the problem but I'm
% not a crop expert --- I've never used it. However it seems odd to
% me that crop doesn't work with memoir. Memoir provides a different
% interface for specifying the page layout but then translates everything
% to the standard length variables. \ldots
%
% \item[crop] You've just taken code from it \verb?...:->?
%
% crop doesn't have its own idea at all. It just uses that of DEK
% and LaTeX, which says, that the reference point of the output box
% in the output routine is assumed 1 inch to the left [later corrected
% to right] and 1 inch down
% from the upper left (virtual) paper corner.
%
% \item[crop] With other words: crop changes \cs{hoffset} and \cs{voffset},
% in order to center the logical (virtual) page on the physical sheet
% of paper, in the middle of the crop marks. The length macros
% \cs{evensidemargin} and \cs{oddsidemargin} are unchanged and refer still
% to the logical page (modulo 1 inch).
%
% The memoir class, in contrast (mis)uses the LaTeX margins
% \cs{even(odd)sidemargin} for that purpose.
%
% Thus, the meaning of \cs{even(odd)sidemargin} is different
% in both packages.
% \end{description}
%
% Given all the above I concluded that \Lpack{crop} would remain
% as it was, and that in order to satisfy Peter Heslin I would have
% to extend the trimming marks. The following was originally limited to
% extensions
% asked for by Peter Heslin.
%
% \begin{macro}{\showtrimsoff}
% \begin{macro}{\showtrimson}
% Switch trimming marksoff and on. Requested by James Hunt on CTT
% \textit{Are crop marks needed on every page?}, February 2006.
% \changes{v1.61803}{2008/01/30}{Added \cs{showtrimsoff} and \cs{showtrimson}
% (mempatch v4.5)}
% \begin{macrocode}
\newcommand*{\showtrimsoff}{\showtrimsfalse}
\newcommand*{\showtrimson}{\showtrimstrue}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\trimmark}
% This is a cross
% in a zero sized picture for marking the corner of a logical page. Up to
% version 1.0 the macro used \cs{setlength} for adjusting the \cs{unitlength}
% but Henrik Holm\footnote{Message to \ctt{} on 2002/01/04
% (\texttt{h.holm@spray.no})} discovered that if the \Lpack{calc} package
% is used then LaTeX complains about a missing number.
% \changes{v1.0a}{2002/01/04}{Removed \cs{setlength} from \cs{trimmark}. Stops
% problem with the calc package.}
% \begin{macrocode}
\newcommand*{\trimmark}{%
\begin{picture}(0,0)
\unitlength 1cm
\thinlines
\put(-2,0){\line(1,0){4}}
\put(0,-2){\line(0,1){4}}
\end{picture}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Ltrimpictl}
% \begin{macro}{\Ltrimpictr}
% \begin{macro}{\Ltrimpicbl}
% \begin{macro}{\Ltrimpicbr}
% `L' shaped trim marks for four corners.
% \changes{v1.3}{2002/10/10}{Added \cs{Ltrimpictl}, \cs{Ltrimpictr}, \cs{Ltrimpicbl}
% and \cs{Ltrimpicbr}}
% \begin{macrocode}
\newcommand*{\Ltrimpictl}{%
\begin{picture}(0,0)
\unitlength 1mm
\thinlines
\put(-2,0){\line(-1,0){18}}
\put(0,2){\line(0,1){18}}
\end{picture}}
\newcommand*{\Ltrimpictr}{%
\begin{picture}(0,0)
\unitlength 1mm
\thinlines
\put(2,0){\line(1,0){18}}
\put(0,2){\line(0,1){18}}
\end{picture}}
\newcommand*{\Ltrimpicbl}{%
\begin{picture}(0,0)
\unitlength 1mm
\thinlines
\put(-2,0){\line(-1,0){18}}
\put(0,-2){\line(0,-1){18}}
\end{picture}}
\newcommand*{\Ltrimpicbr}{%
\begin{picture}(0,0)
\unitlength 1mm
\thinlines
\put(2,0){\line(1,0){18}}
\put(0,-2){\line(0,-1){18}}
\end{picture}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Ftrimpicbl}
% Frame the page.
% \changes{v1.3}{2002/10/10}{Added \cs{Ftrimpictl}}
% \begin{macrocode}
\newcommand*{\Ftrimpicbl}{%
\begin{picture}(0,0)
\unitlength 1pt
\thinlines
\put(0,0){\framebox(\strip@pt\paperwidth,\strip@pt\paperheight){}}
\end{picture}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tmarktl}
% \begin{macro}{\tmarktr}
% \begin{macro}{\tmarkbl}
% \begin{macro}{\tmarkbr}
% The trimming marks used for corner display.
% \changes{v1.3}{2002/10/10}{Added \cs{tmarktl}, \cs{tmarktr}, \cs{tmarkbl}
% and \cs{tmarkbr}}
% \begin{macrocode}
\newcommand*{\tmarktl}{\trimmark}
\newcommand*{\tmarktr}{\trimmark}
\newcommand*{\tmarkbl}{\trimmark}
\newcommand*{\tmarkbr}{\trimmark}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tmarktm}
% \begin{macro}{\tmarkml}
% \begin{macro}{\tmarkmr}
% \begin{macro}{\tmarkbm}
% The trimming marks used for mid-side display.
% \changes{v1.3}{2002/10/10}{Added \cs{tmarktm}, \cs{tmarkml}, \cs{tmarkmr}
% and \cs{tmarkbm}}
% \changes{v1.6180339c}{2009/11/13}{Fill in these four macros. Easier
% for users to define them to do nothing, than coming up with the code}
% \begin{macrocode}
\newcommand*{\tmarktm}{%
\begin{picture}(0,0)%
\unitlength 1mm
\thinlines
\put(0,2){\line(0,1){10}}
\end{picture}}
\newcommand*{\tmarkml}{%
\begin{picture}(0,0)%
\unitlength 1mm
\thinlines
\put(-2,0){\line(-1,0){10}}
\end{picture}}
\newcommand*{\tmarkmr}{%
\begin{picture}(0,0)%
\unitlength 1mm
\thinlines
\put(2,0){\line(1,0){10}}
\end{picture}}
\newcommand*{\tmarkbm}{%
\begin{picture}(0,0)%
\unitlength 1mm
\thinlines
\put(0,-12){\line(0,1){10}}
\end{picture}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\trimXmarks}
% \begin{macro}{\trimLmarks}
% \begin{macro}{\trimFrame}
% \begin{macro}{\trimNone}
% These are declarations for the different kinds of trimming marks.
% \changes{v1.3}{2002/10/10}{Added \cs{trimXmarks}, \cs{trimLmarks},
% \cs{trimFrame} and \cs{trimNone}}
% \begin{macrocode}
\newcommand*{\trimXmarks}{%
\let\tmarktl\trimmark
\let\tmarktr\trimmark
\let\tmarkbl\trimmark
\let\tmarkbr\trimmark}
\newcommand*{\trimLmarks}{%
\let\tmarktl\Ltrimpictl
\let\tmarktr\Ltrimpictr
\let\tmarkbl\Ltrimpicbl
\let\tmarkbr\Ltrimpicbr}
\newcommand*{\trimFrame}{%
\let\tmarktl\null
\let\tmarktr\null
\let\tmarkbl\Ftrimpicbl
\let\tmarkbr\null}
\newcommand*{\trimNone}{%
\let\tmarktl\relax
\let\tmarktr\relax
\let\tmarkbl\relax
\let\tmarkbr\relax
\let\tmarktm\relax
\let\tmarkml\relax
\let\tmarkmr\relax
\let\tmarkbm\relax}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\trimmarks}
% \begin{macro}{\trimmarkscolor}
% This positions four marks (\cs{trimmark}) at the corners of a
% logical page. It is basically a \cs{vbox} with zero height and width.
%
% Bastiaan Niels Veelo reported (2003/07/11) odd things (e.g., some
% macros ignored) when changing trim marks. Turns out to be related
% to the use of \cs{protect}. The macro \cs{trimmarkscolor} can be
% used to change the color of the trimmarks. Despite its name, it is
% not a color but just an empty macro.
% \changes{v1.1}{2002/03/10}{Changed \cs{trimmarks} to work properly with the oneside option}
% \changes{v1.3}{2002/10/10}{Changed \cs{trimmarks} to use \cs{tmarktl}, etc.,
% instead of four \cs{trimmark}s}
% \changes{v1.4}{2003/11/22}{Fiddled \cs{protect} in \cs{trimmaks}
% (from patch v1.7)}
% \changes{v3.6h}{2010/12/05}{Added \cs{trimmarkscolor}}
% \changes{v3.7m}{2020/08/05}{From the 2020/10/01 format, we don't
% need the \cs{vskip}\texttt{-1in} and \cs{hskip}\texttt{-1in} as the
% trimmarks are added in a different manner}
% \begin{macrocode}
\newcommand*\trimmarkscolor{}
% \end{macrocode}
% \changes{v3.7m}{2020/08/05}{Factored out two skips}
% Factoring out two skips to make it easy to remove them in the
% 2020/10/01 onwards.
% \begin{macrocode}
\newcommand\mem@trimmarks@initial@vskip{\vskip-1in}
\newcommand\mem@trimmarks@initial@hskip{\hskip-1in}
\newcommand*{\trimmarks}{%
\vbox to \z@{%
\mem@trimmarks@initial@vskip%
\vskip\trimtop % top of logical page
\hb@xt@\z@{%
\mem@trimmarks@initial@hskip%
\ifodd\c@page
\hskip\stockwidth
\hskip-\trimedge
\hskip-\paperwidth
\else
\if@twoside
\hskip\trimedge % left of logical page
\else
\hskip\stockwidth
\hskip-\trimedge
\hskip-\paperwidth
\fi
\fi
\vbox to \paperheight{%
\let\protect\relax % <- v1.4 addition
\hb@xt@\paperwidth{\trimmarkscolor\tmarktl\hfil\tmarktm\hfil\tmarktr}%
\vfil
\hb@xt@\paperwidth{\trimmarkscolor\tmarkml\hfil\tmarkmr}%
\vfil
\hb@xt@\paperwidth{\trimmarkscolor\tmarkbl\hfil\tmarkbm\hfil\tmarkbr}}%
\hss}%
\vss}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Quark marks}
%
% William Adams (2006/08/28) supplied the following code to use trim marks
% along the style of Quark Xpress.
%
% \begin{macro}{\registrationColour}
% \begin{macro}{\quarkmarks}
% Trim marks on the style of Quark Express.
% \changes{v1.61803}{2008/01/30}{Added \cs{quarkmarks} (mempatch v4.6)}
% \changes{v3.6h}{2010/12/05}{Added \cs{normalfont} such that font
% changes going over a page break does not effect the quarks
% text. Reported by Rasmus Villemoes.}
% \changes{v3.6j}{2011/02/28}{Typo hsip -> hskip, reported by Alex Ball}
% \begin{macrocode}
\newcommand*{\registrationColour}[1]{#1}
\newcommand*{\quarkmarks}{%
\renewcommand*{\tmarktl}{\registrationColour{%
\begin{picture}(0,0)
\setlength{\unitlength}{1bp}\thicklines
\put(-36,0){\line(1,0){24}}
\put(0,12){\line(0,1){24}}
\put(3,27){\normalfont\ttfamily\fontsize{8bp}{10bp}\selectfont\jobname\ \
\today\ \ \printtime\ \ Page \thepage}
\end{picture}}}
\renewcommand*{\tmarktm}{\registrationColour{%
\begin{picture}(0,0)
\setlength{\unitlength}{1bp}\thicklines
\put(-24,24){\line(1,0){48}}
\put(0,12){\line(0,1){24}}
\put(0,24){\oval(12,12)}
\end{picture}}}
\renewcommand*{\tmarktr}{\registrationColour{%
\begin{picture}(0,0)
\setlength{\unitlength}{1bp}\thicklines
\put(12,0){\line(1,0){24}}
\put(0,12){\line(0,1){24}}
\end{picture}}}
\renewcommand*{\tmarkmr}{\registrationColour{%
\begin{picture}(0,0)
\setlength{\unitlength}{1bp}\thicklines
\put(12,0){\line(1,0){24}}
\put(24,-24){\line(0,1){48}}
\put(24,0){\oval(12,12)}
\end{picture}}}
\renewcommand*{\tmarkbr}{\registrationColour{%
\begin{picture}(0,0)
\setlength{\unitlength}{1bp}\thicklines
\put(12,0){\line(1,0){24}}
\put(0,-36){\line(0,1){24}}
\end{picture}}}
\renewcommand*{\tmarkbm}{\registrationColour{%
\begin{picture}(0,0)
\setlength{\unitlength}{1bp}\thicklines
\put(-24,-24){\line(1,0){48}}
\put(0,-36){\line(0,1){24}}
\put(0,-24){\oval(12,12)}
\end{picture}}}
\renewcommand*{\tmarkbl}{\registrationColour{%
\begin{picture}(0,0)
\setlength{\unitlength}{1bp}\thicklines
\put(-36,0){\line(1,0){24}}
\put(0,-36){\line(0,1){24}}
\end{picture}}}
\renewcommand*{\tmarkml}{\registrationColour{%
\begin{picture}(0,0)
\setlength{\unitlength}{1bp}\thicklines
\put(-36,0){\line(1,0){24}}
\put(-24,-24){\line(0,1){48}}
\put(-24,0){\oval(12,12)}
\end{picture}}}
% \end{macrocode}
%
% \changes{v3.7m}{2020/08/05}{Removed redefinition of \cs{trimmarks}
% inside \cs{quarkmarks}, it only adds an extra group compared to the
% normal \cs{trimmarks}}
% Removed redefintion of \cmd{\trimmarks}, seemingly no need for it.
% \begin{macrocode}
%% \renewcommand*{\trimmarks}{%
%% %% \special{papersize=\the\stockwidth,\the\stockheight}
%% {%
%% \vbox to \z@{\vskip-1in \vskip\trimtop % top of logical page
%% \hb@xt@\z@{\hskip-1in
%% \ifodd\c@page
%% \hskip\stockwidth \hskip-\trimedge \hskip-\paperwidth
%% \else
%% \if@twoside
%% \hskip\trimedge % left of logical page
%% \else
%% \hskip\stockwidth \hskip-\trimedge \hskip-\paperwidth
%% \fi
%% \fi
%% \vbox to \paperheight{%
%% \let\protect\relax % <- v1.4 addition
% \end{macrocode}
% We remember to add \cs{trimmarkscolor}
% \changes{v3.6h}{2010/12.05}{added \cs{trimmarkscolor}}
% \begin{macrocode}
%% \hb@xt@\paperwidth{\trimmarkscolor\tmarktl\hfil\tmarktm\hfil\tmarktr}%
%% \vfil
%% \hb@xt@\paperwidth{\trimmarkscolor\tmarkml\hfil\tmarkmr}%
%% \vfil
%% \hb@xt@\paperwidth{\trimmarkscolor\tmarkbl\hfil\tmarkbm\hfil\tmarkbr}}%
%% \hss}%
%% \vss}}%
%% }
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% As of the format update 2020/10/01 a hooking mechanism was added
% to the kernel. One of these provides a hook into the background of
% the shipped out pages, ideal for adding trimmarks. This hooking
% system saves us from messing with \cmd{\shipout} direction (in
% potentially incompatible ways).
%
% \changes{v3.7m}{2020/08/05}{Applying a format check and adding
% trimmarks via hook if available}
%
% Note that the hook will be named \texttt{memoir/trimmarks} of easy
% reference if one ever need to do some order readjustments. See
% \cite{LTHOOKS,LTSHIPOUT} for more details on the hooking system. The
% extra \cmd{\ifshowtrims} inside the hook is to accommodate for the
% \cmd{\showtrimson}/\cmd{\showtrimsoff} commands.
% \begin{macrocode}
\IfFormatAtLeastTF{2020/10/01}{
\renewcommand\mem@trimmarks@initial@vskip{}
\renewcommand\mem@trimmarks@initial@hskip{}
\ifshowtrims
\AddToHook{shipout/background}[./trimmarks]{\ifshowtrims\put(0,0){\trimmarks}\fi}
\fi
}{
% \end{macrocode}
% Here follows then the old code where Any marks are put onto the pages by adding to the \cs{shipout}
% routine.
%
% \begin{macro}{\mem@oldshipout}
% Keep a copy of the current version of \cs{shipout} in \cs{mem@oldshipout}.
% \begin{macrocode}
\let\mem@oldshipout\shipout
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mem@shipi}
% \begin{macro}{\mem@shipii}
% Effectively these will add the \cs{trimmarks} to the box holding
% the contents of the page. Note that any \cs{makeindex} must come
% \emph{before} \Lpack{pagesel} (and \Lpack{selectp}) package.
% \changes{v1.618}{2005/09/03}{Changed \cs{mem@shipii} for the pagesel package,
% courtesy James Szinger (mempatch v311)}
% \changes{v1.61803}{2008/01/30}{Added \cs{ifshowtrims} to \cs{mem@shipii}
% (mempatch v4.5)}
% \changes{v1.6180339f}{2009/06/24}{Added Dan Luecking's fix to
% \cs{mem@shippii} to cater for another merry hyperref change!}
% \changes{v1.6180339c}{2009/11/13}{Replaced Dans fix with a fix from
% Heiko Oberdiek}
% \begin{macrocode}
\newcommand*{\mem@shipi}{%
\ifvoid\@cclv\expandafter\aftergroup\fi\mem@shipii}
\newcommand*\mem@shipii{%
\ifvoid\@cclv
\mem@oldshipout\box\@cclv
\else
\ifshowtrims
% \end{macrocode}
% Heiko Oberdiek responded to a problem reported by Rolf
% Niepraschk. The earlier implementation might cause the output box to
% be shifted. Heikos explanation (in response to the line
% \verb?\mem@oldshipout\vbox{\trimmarks\ifvbox\@cclv\unvbox\else\box\fi\@cclv}?) :
% \begin{verbatim}
% In vertical mode (\mem@oldshipout\vbox{...}) TeX puts
% interline skip between two boxes (\trimmarks and \@cclv),
% here \linekskip (1pt) is put inbetween causing the
% shift downwards.
% \end{verbatim}
% Heiko also provided the fix used below. Actually Heikos fix also
% fixes a problem that might cause glue settings to disappear.
% \begin{macrocode}
\mem@oldshipout\vbox{%
\trimmarks
\nointerlineskip
\box\@cclv
}%
\else
\mem@oldshipout\box\@cclv
\fi
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\shipout}
% Our new version of \cs{shipout}, which is only needed for the
% \Lopt{showtrims} option. This adds \cs{mem@shipi} to the page box
% which then calls the original version of \cs{shipout}.
% \begin{macrocode}
\ifshowtrims
\renewcommand*{\shipout}{\afterassignment\mem@shipi\setbox\@cclv=}
\fi
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
} % end format check, else part
% \end{macrocode}
%
% \section{Verbatims, boxes, and files}
%
% All the code in this section was added for version 1.2 of the class.
% \changes{v1.2}{2002/07/27}{Section `Verbatims, boxes and files' added}
%
% \subsection{Modified version of the verbatim package}
%
% Much of this is from the \Lpack{verbatim} package code~\cite{VERBATIM}.
% Unless indicated otherwise, the code and commentary is from that
% package.
%
%
% \subsubsection{Preliminaries}
%
% \begin{macro}{\every@verbatim}
% \begin{macro}{\afterevery@verbatim}
% The hook (i.e., token register) \cs{every@verbatim}
% is initialized to \meta{empty}.
%
% PW added the \cs{afterevery@verbatim} hook.
% \begin{macrocode}
\newtoks\every@verbatim
\every@verbatim={}
\newtoks\afterevery@verbatim
\afterevery@verbatim={}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@makeother}
% \cs{@makeother} takes as argument a character and changes
% its category code to $12$ (other).
% \begin{macrocode}
\def\@makeother#1{\catcode`#112\relax}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@vobeyspaces}
% The macro \cs{@vobeyspaces} causes spaces in the input
% to be printed as spaces in the output.
% \begin{macrocode}
\begingroup
\catcode`\ =\active%
\def\x{\def\@vobeyspaces{\catcode`\ \active\let \@xobeysp}}
\expandafter\endgroup\x
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@xobeysp}
% The macro \cs{@xobeysp} produces exactly one space in
% the output, protected against breaking just before it.
% (\cs{@M} is an abbreviation for the number $10000$.)
% \begin{macrocode}
\def\@xobeysp{\leavevmode\penalty\@M\ }
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\verbatim@line}
% We use a newly defined token register called \cs{verbatim@line}
% that will be used as the character buffer.
% \begin{macrocode}
\newtoks\verbatim@line
% \end{macrocode}
% \end{macro}
%
% PW. I have extended the original \Lpack{verbatim} package code to handle
% TABs within verbatims. Normally TeX replaces a TAB by either a single space or
% ignores it altogether. For this purpose I have bits of code from the \Lpack{moreverb}
% package~\cite{MOREVERB} for handling TABs.
%
% \textit{Code and commentary from moreverb.}
%
% We define a few auxiliary macros and counters for expanding tabs.
% \begin{macrocode}
\newcount\tab@position
% \end{macrocode}
%
% \begin{macro}{\@xobeytab}
% \cs{@xobeytab} puts enough spaces in to get to the next nominal
% tab stop
% \begin{macrocode}
\def\@xobeytab{%
\loop
\toks@\expandafter{\the\toks@\@xobeysp}%
\advance\tab@position-1
\ifnum\tab@position>0 \repeat
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@vobeytabs}
% \cs{@vobeytabs} initialises use of \cs{@xobeytab}. Needs to be
% executed within a group, as mustn't be allowed to leak out into the
% wide world.
%
% \begin{macrocode}
\begingroup
\catcode`\^^I=\active
\gdef\@vobeytabs{\catcode`\^^I\active\let^^I\@xobeytab}%
\endgroup
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@tabexpand}
% \cs{verbatim@tabexpand}\marg{body of line}\cs{@nil} processes every
% character of a line by tail recursion, counting the characters and
% juggling things when a tab is encountered.
% \begin{macrocode}
\def\verbatim@tabexpand#1{%
\ifx#1\@nil
\the\toks@
\expandafter\par
\else
\ifx#1\@xobeytab
\@xobeytab
\else
% \end{macrocode}
%
% We can safely put \cs{@xobeysp} into the token register, since it
% does precisely what we need
% \begin{macrocode}
\toks@\expandafter{\the\toks@#1}%
\advance\tab@position\m@ne
\fi
\ifnum\tab@position=0 \tab@position\tab@size \fi
\expandafter\verbatim@tabexpand
\fi
}
% \end{macrocode}
% \end{macro}
%
% \textit{End of code and commentary from moreverb.}
%
% PW. Some macros for turning tabbing on and off.
%
% \begin{macro}{\tabson}
% \begin{macro}{\tabsoff}
% \begin{macro}{\@maybeobeytabs}
% \cs{tabson} turns tabbing on, and \cs{tabsoff} turns it off. Default
% is no tabbing.
% \begin{macrocode}
\newif\ift@bs
\newcommand{\tabson}[1][4]{%
\ifnum\@ne > #1\relax
\tabsoff
\else
\t@bstrue
\def\tab@size{#1\relax}%
\def\@maybeobeytabs{\@vobeytabs}%
\fi
}
\newcommand{\tabsoff}{%
\t@bsfalse
\def\tab@size{\z@}%
\def\@maybeobeytabs{}%
}
\tabsoff
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tabverbatim@processline}
% Process a line with TABs (extracted from \Lpack{moreverb}).
% \begin{macrocode}
\def\tabverbatim@processline{\tab@position\tab@size
\toks@{}%
\expandafter\verbatim@tabexpand\the\verbatim@line\@nil}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\notabverbatim@processline}
% Processes a line ignoring TABs (this is the original \Lpack{verbatim}
% package definition of \cs{verbatim@processline}).
% \begin{macrocode}
\def\notabverbatim@processline{\the\verbatim@line\par}
% \end{macrocode}
% \end{macro}
%
% \textit{We are now back to the \Lpack{verbatim} code.}
%
% The following four macros are defined globally in a way suitable for
% the \texttt{verbatim} and \texttt{verbatim*} environments.
% \begin{macro}{\verbatim@startline}
% \begin{macro}{\verbatim@addtoline}
% \begin{macro}{\verbatim@processline}
% \cs{verbatim@startline} initializes processing of a line
% by emptying the character buffer (\cs{verbatim@line}).
% \begin{macrocode}
\def\verbatim@startline{\verbatim@line{}}
% \end{macrocode}
% \cs{verbatim@addtoline} adds the tokens in its argument
% to our buffer register \cs{verbatim@line} without expanding
% them.
% \begin{macrocode}
\def\verbatim@addtoline#1{%
\verbatim@line\expandafter{\the\verbatim@line#1}}
% \end{macrocode}
% Processing a line inside a \texttt{verbatim} or \texttt{verbatim*}
% environment means printing it.
% Ending the line means that we have to begin a new paragraph.
% We use \cs{par} for this purpose. Note that \cs{par}
% is redefined in \cs{@verbatim} to force \TeX{} into horizontal
% mode and to insert an empty box so that empty lines in the input
% do appear in the output.
% (PW changed next line from \\
% \verb?\def\verbatim@processline{\the\verbatim@line\par}?
% \begin{macrocode}
\def\verbatim@processline{\notabverbatim@processline}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\verbatim@finish}
% As a default, \cs{verbatim@finish} processes the remaining
% characters.
% When this macro is called we are facing the following problem:
% when the \verb?\end{verbatim}?
% command is encountered \cs{verbatim@processline} is called
% to process the characters preceding the command on the same
% line. If there are none, an empty line would be output if we
% did not check for this case.
%
% If the line is empty \verb?\the\verbatim@line? expands to
% nothing. To test this we use a trick similar to that on p.\ 376
% of the \TeX{}book, but with \verb?$?\ldots\verb?|$? instead of
% the \verb?!? tokens. These \verb?$? tokens can never have the same
% category code as a \verb?$? token that might possibly appear in the
% token register \cs{verbatim@line}, as such a token will always have
% been read with category code $12$ (other).
% Note that \cs{ifcat} expands the following tokens so that
% \verb?\the\verbatim@line? is replaced by the accumulated
% characters
% \begin{macrocode}
\def\verbatim@finish{\ifcat$\the\verbatim@line$\else
\verbatim@processline\fi}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{The \texttt{verbatim} and \texttt{verbatim*} environments}
%
% \begin{macro}{\verbatim@font}
% We start by defining the macro \cs{verbatim@font} that is
% to select the font and to set font-dependent parameters.
% Then we go through \cs{verbatim@nolig@list} to avoid
% certain ligatures.
% \cs{verbatim@nolig@list} is a macro defined in the \LaTeXe{} kernel
% to expand to
% \begin{verbatim}
% \do\`\do\<\do\>\do\,\do\'\do\-
% \end{verbatim}
% All the characters in this list can be part of a ligature in some
% font or other.
%
% PW. This is the original version which I'm going to replace.
% \begin{verbatim}
% \def\verbatim@font{\normalfont\ttfamily
% \hyphenchar\font\m@ne
% \let\do\do@noligs
% \verbatim@nolig@list}
% \end{verbatim}
% Actually the kernel defines the macro \verb+\@noligs+ which just
% runs the last two lines of the \verb+\verbatim@font+ above. As other
% package may add stuff to \verb+\@noligs+, we will use that instead.
% \end{macro}
%
% \begin{macro}{\setverbatimfont}
% \begin{macro}{\m@mverbfont}
% \begin{macro}{\verbatim@font}
% User level handle for changing the font used for verbatim text.
% \changes{v1.61803398}{2009/09/10}{Changed the last two lines of
% \cs{verbatim@font} into using \cs{@noligs} instead. This fixes
% problem with upquote.}
% \begin{macrocode}
\newcommand{\setverbatimfont}[1]{\def\m@mverbfont{#1}}
\setverbatimfont{\normalfont\ttfamily}
\def\verbatim@font{\m@mverbfont
\hyphenchar\font\m@ne
\@noligs}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@verbatim}
% The macro \cs{@verbatim} sets up things properly.
% First of all, the tokens of the \cs{every@verbatim} hook
% are inserted.
% Then a \texttt{trivlist} environment is started and its first
% \cs{item} command inserted.
% Each line of the \texttt{verbatim} or \texttt{verbatim*}
% environment will be treated as a separate paragraph.
% \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{@verbatim}}
% \begin{macrocode}
\def\@verbatim{\the\every@verbatim
\trivlist \item \relax
% \end{macrocode}
% The following extra vertical space is for compatibility with the
% \LaTeX kernel: otherwise, using the \Lpack{verbatim} package changes
% the vertical spacing of a \texttt{verbatim} environment nested within a
% \texttt{quote} environment.
% \begin{macrocode}
\if@minipage\else\vskip\parskip\fi
% \end{macrocode}
% The paragraph parameters are set appropriately:
% the penalty at the beginning of the environment,
% left and right margins, paragraph indentation, the glue to
% fill the last line, and the vertical space between paragraphs.
% The latter space has to be zero since we do not want to add
% extra space between lines.
% \begin{macrocode}
\@beginparpenalty \predisplaypenalty
%%% \leftskip\@totalleftmargin\rightskip\z@
\memRTLleftskip\@totalleftmargin\memRTLrightskip\z@
\parindent\z@\parfillskip\@flushglue\parskip\z@
% \end{macrocode}
% There's one point to make here:
% the \texttt{list} environment uses \TeX's \cs{parshape}
% primitive to get a special indentation for the first line
% of the list.
% If the list begins with a \texttt{verbatim} environment
% this \cs{parshape} is still in effect.
% Therefore we have to reset this internal parameter explicitly.
% We could do this by assigning $0$ to \cs{parshape}.
% However, there is a simpler way to achieve this:
% we simply tell \TeX{} to start a new paragraph.
% As is explained on p.~103 of the \TeX{}book, this resets
% \cs{parshape} to zero.
% \begin{macrocode}
\@@par
% \end{macrocode}
% We now ensure that \cs{par} has the correct definition,
% namely to force \TeX{} into horizontal mode
% and to include an empty box.
% This is to ensure that empty lines do appear in the output.
% Afterwards, we insert the \cs{interlinepenalty} since \TeX{}
% does not add a penalty between paragraphs (here: lines)
% by its own initiative. Otherwise a \texttt{verbatim} environment
% could be broken across pages even if a \cs{samepage}
% declaration were present.
%
% However, in a top-aligned minipage, this will result in an extra
% empty line added at the top. Therefore, a slightly more
% complicated construct is necessary.
% One of the important things here is the inclusion of
% \cs{leavevmode} as the first macro in the first line, for example,
% a blank verbatim line is the first thing in a list item.
% \begin{macrocode}
\def\par{%
\if@tempswa
\leavevmode\null\@@par\penalty\interlinepenalty
\else
\@tempswatrue
\ifhmode\@@par\penalty\interlinepenalty\fi
\fi}%
% \end{macrocode}
% But to avoid an error message when the environment
% doesn't contain any text, we redefine \cs{@noitemerr}
% which will in this case be called by \cs{endtrivlist}.
% \begin{macrocode}
\def\@noitemerr{\@warning{No verbatim text}}%
% \end{macrocode}
% Now we call \cs{obeylines} to make the end of line character
% active,
% \begin{macrocode}
\obeylines
% \end{macrocode}
% change the category code of all special characters,
% to $12$ (other).
% \begin{macrocode}
\let\do\@makeother \dospecials
% \end{macrocode}
% and switch to the font to be used.
% \begin{macrocode}
\verbatim@font
% \end{macrocode}
% To avoid a breakpoint after the labels box, we remove the penalty
% put there by the list macros: another use of \cs{unpenalty}!
% \begin{macrocode}
\everypar \expandafter{\the\everypar \unpenalty}%
% \end{macrocode}
% PW added next code at end of \cs{@verbatim}.
% \begin{macrocode}
\wrapright\the\afterevery@verbatim}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\verbatim}
% \begin{macro}{\verbatim*}
% Now we define the toplevel macros.
% \cs{verbatim} is slightly changed:
% after setting up things properly it calls
% \cs{verbatim@start}.
% This is done inside a group, so that \cs{verbatim} can be used
% directly, without \cs{begin}.
%
% PW. The following is the original code, but I want a version of
% \texttt{verbatim} that recognises TABs.
% \begin{verbatim}
% \begin{macrocode}
% \def\verbatim{%
% \begingroup\@verbatim \frenchspacing\@vobeyspaces
% \verbatim@start}
% \end{macrocode}
% \cs{verbatim*} is defined accordingly.
% \begin{macrocode}
% \@namedef{verbatim*}{\begingroup\@verbatim\verbatim@start}
% \def\endverbatim{\endtrivlist\endgroup}
% \expandafter\let\csname endverbatim*\endcsname=\endverbatim
% \end{macrocode}
% \end{verbatim}
%
% PW. My code for these is a modified version of the original \Lpack{verbatim}
% code.
% \begin{macrocode}
\def\verbatim{\begingroup
\ift@bs
\def\verbatim@processline{\tabverbatim@processline}%
\fi
\@verbatim \frenchspacing\@vobeyspaces\@maybeobeytabs\verbatim@start}
\@namedef{verbatim*}{\begingroup
\ift@bs
\def\verbatim@processline{\tabverbatim@processline}%
\fi
\@verbatim\@maybeobeytabs\verbatim@start}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\endverbatim}
% \begin{macro}{\endverbatim*}
% To end the \texttt{verbatim} and \texttt{verbatim*}
% environments it is only necessary to finish the
% \texttt{trivlist} environment started in \cs{@verbatim} and
% close the corresponding group, and handle\footnote{Noted by
% Zarko Cucej (\url{zarko.cucej@uni-mb.si}).} following (non-) paragraph,
% by using \cs{@doendpe}.
% \changes{v1.4}{2003/11/22}{Added \cs{@doendpe} to \cs{endverbatim}
% (from patch v1.8)}
% \changes{v2.0a}{2004/03/01}{Refixed \cs{endverbatim}}
% \begin{macrocode}
\def\endverbatim{\endtrivlist\endgroup\@doendpe}
\@namelet{endverbatim*}\endverbatim
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% For abnormal \cs{parskip}s the NTG class included the following, but I'm
% not sure if it is relevant here, but if it is just how it should be included.
% \begin{verbatim}
% From NTG, where it is a \cs{def}
% \providecommand*{\verbatim}{%
% \topsep=-0.5\parskip
% \@verbatim
% \frenchspacing\@vobeyspaces \@xverbatim}
% \end{verbatim}
%
%
% \subsubsection{The \texttt{comment} environment}
%
% The \cs{comment} macro is similar to \cs{verbatim*}.
% However, we do not need to switch fonts or set special
% formatting parameters such as \cs{parindent} or \cs{parskip}.
% We need only set the category code of all special characters
% to $12$ (other) and that of \verb?^^M? (the end of line character)
% to $13$ (active).
% The latter is needed for macro parameter delimiter matching in
% the internal macros defined below.
% In contrast to the default definitions used by the
% \cs{verbatim} and \cs{verbatim*} macros,
% we define \cs{verbatim@addtoline} to throw away its argument
% and \cs{verbatim@processline}, \cs{verbatim@startline},
% and \cs{verbatim@finish} to act as no-ops.
% Then we call \cs{verbatim@}.
% But the first thing we do is to call \cs{@bsphack} so that
% this environment has no influence whatsoever upon the spacing.
%
% PW: This is the original code for the \texttt{comment} environment,
% which I'm going to change.
% \begin{verbatim}
% \def\comment{\@bsphack
% \let\do\@makeother\dospecials\catcode`\^^M\active
% \let\verbatim@startline\relax
% \let\verbatim@addtoline\@gobble
% \let\verbatim@processline\relax
% \let\verbatim@finish\relax
% \verbatim@}
% \end{verbatim}
% \cs{endcomment} is very simple: it only calls
% \cs{@esphack} to take care of the spacing.
% The \cs{end} macro closes the group and therefore takes care
% of restoring everything we changed.
% \begin{verbatim}
% \let\endcomment=\@esphack
% \end{verbatim}
%
% PW: The remainder of this section is my code.
%
% \begin{macro}{\setupcomment}
% \cs{setupcomment} does all the \cs{let}s in the original \cs{comment} code.
% \begin{macrocode}
\newcommand{\setupcomment}{%
\let\do\@makeother\dospecials\catcode`\^^M\active
\let\verbatim@startline\relax
\let\verbatim@addtoline\@gobble
\let\verbatim@processline\relax
\let\verbatim@finish\relax}
% \end{macrocode}
% \end{macro}
%
% The macros below do no checking to see if something has (not) been defined
% previously. It's `user beware' time.
%
% \begin{macro}{\newcomment}
% \cs{newcomment}\marg{name} creates a new comment environment called
% \meta{name}. This is a generalisation of the original comment code.
% \begin{macrocode}
\newcommand{\newcomment}[1]{%
\expandafter\def\csname #1\endcsname{\@bsphack\setupcomment\verbatim@}%
\expandafter\let\csname end#1\endcsname=\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\commentsoff}
% \cs{commentsoff}\marg{name} switches off the \meta{name} comment
% environment by defining the relevent macros to do nothing.
% \begin{macrocode}
\newcommand{\commentsoff}[1]{%
\expandafter\def\csname #1\endcsname{}%
\expandafter\def\csname end#1\endcsname{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\commentson}
% \cs{commentson}\marg{name} switches on the \meta{name} comment
% environment. It has to do the same things as \cs{newcomment} does,
% so let \cs{newcomment} do the work.
% \begin{macrocode}
\newcommand{\commentson}[1]{\newcomment{#1}}
% \end{macrocode}
% \end{macro}
%
% We had better supply the \texttt{comment} environment, as promised.
% \begin{macrocode}
\newcomment{comment}
% \end{macrocode}
%
% PW: That is the end of my changes and extensions to the original
% \texttt{comment} environment code.
%
%
% \subsubsection{The main loop}
%
% Here comes the tricky part:
% During the definition of the macros we need to use the special
% characters \verb?\?, \verb?{?, and \verb?}? not only with their
% normal category codes,
% but also with category code $12$ (other).
% We achieve this by the following trick:
% first we tell \TeX{} that \verb?\?, \verb?{?, and \verb?}?
% are the lowercase versions of \verb?!?, \verb?[?, and \verb?]?.
% Then we replace every occurrence of \verb?\?, \verb?{?, and \verb?}?
% that should be read with category code $12$ by \verb?!?, \verb?[?,
% and \verb?]?, respectively,
% and give the whole list of tokens to \cs{lowercase},
% knowing that category codes are not altered by this primitive!
%
% But first we have ensure that
% \verb?!?, \verb?[?, and \verb?]? themselves have
% the correct category code!
% To allow special settings of these codes we hide their setting in
% the macro \cs{vrb@catcodes}. If it is already defined our new
% definition is skipped.
% \begin{macrocode}
\@ifundefined{vrb@catcodes}%
{\def\vrb@catcodes{%
\catcode`\!12\catcode`\[12\catcode`\]12}}{}
% \end{macrocode}
% This trick allows us to use this code for applications where other
% category codes are in effect.
%
% We start a group to keep the category code changes local.
% \begin{macrocode}
\begingroup
\vrb@catcodes
\lccode`\!=`\\ \lccode`\[=`\{ \lccode`\]=`\}
% \end{macrocode}
% We also need the end-of-line character \verb?^^M?,
% as an active character.
% If we were to simply write \verb?\catcode`\^^M=\active?
% then we would get an unwanted active end of line character
% at the end of every line of the following macro definitions.
% Therefore we use the same trick as above:
% we write a tilde \verb?~? instead of \verb?^^M? and
% pretend that the
% latter is the lowercase variant of the former.
% Thus we have to ensure now that the tilde character has
% category code $13$ (active).
% \begin{macrocode}
\catcode`\~=\active \lccode`\~=`\^^M
% \end{macrocode}
% The use of the \cs{lowercase} primitive leads to one problem:
% the uppercase character `\texttt{C}' needs to be used in the
% code below and its case must be preserved.
% So we add the command:
% \begin{macrocode}
\lccode`\C=`\C
% \end{macrocode}
% Now we start the token list passed to \cs{lowercase}.
% We use the following little trick (proposed by Bernd Raichle):
% The very first token in the token list we give to \cs{lowercase} is
% the \cs{endgroup} primitive. This means that it is processed by
% \TeX{} immediately after \cs{lowercase} has finished its operation,
% thus ending the group started by \cs{begingroup} above. This avoids
% the global definition of all macros.
% \begin{macrocode}
\lowercase{\endgroup
% \end{macrocode}
% \begin{macro}{\verbatim@start}
% The purpose of \cs{verbatim@start} is to check whether there
% are any characters on the same line as the \verb?\begin{verbatim}?
% and to pretend that they were on a line by themselves.
% On the other hand, if there are no characters remaining
% on the current line we shall just find an end of line character.
% \cs{verbatim@start} performs its task by first grabbing the
% following character (its argument).
% This argument is then compared to an active \verb?^^M?,
% the end of line character.
% \begin{macrocode}
\def\verbatim@start#1{%
\verbatim@startline
\if\noexpand#1\noexpand~%
% \end{macrocode}
% If this is true we transfer control to \cs{verbatim@}
% to process the next line. We use
% \cs{next} as the macro which will continue the work.
% \begin{macrocode}
\let\next\verbatim@
% \end{macrocode}
% Otherwise, we define \cs{next} to expand to a call
% to \cs{verbatim@} followed by the character just
% read so that it is reinserted into the text.
% This means that those characters remaining on this line
% are handled as if they formed a line by themselves.
% \begin{macrocode}
\else \def\next{\verbatim@#1}\fi
% \end{macrocode}
% Finally we call \cs{next}.
% \begin{macrocode}
\next}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@}
% The three macros \cs{verbatim@}, \cs{verbatim@@},
% and \cs{verbatim@@@} form the ``main loop'' of the
% \texttt{verbatim} environment.
% The purpose of \cs{verbatim@} is to read exactly one line
% of input.
% \cs{verbatim@@} and \cs{verbatim@@@} work together to
% find out whether the four characters
% \cs{end} (all with category code $12$ (other)) occur in that
% line.
% If so, \cs{verbatim@@@} will call
% \cs{verbatim@test} to check whether this \cs{end} is
% part of \verb?\end{verbatim}? and will terminate the environment
% if this is the case.
% Otherwise we continue as if nothing had happened.
% So let's have a look at the definition of \cs{verbatim@}:
% \begin{macrocode}
\def\verbatim@#1~{\verbatim@@#1!end\@nil}%
% \end{macrocode}
% Note that the \verb?!? character will have been replaced by a
% \verb?\? with category code $12$ (other) by the \cs{lowercase}
% primitive governing this code before the definition of this
% macro actually takes place.
% That means that
% it takes the line, puts \cs{end} (four character tokens)
% and \cs{@nil} (one control sequence token) as a
% delimiter behind it, and
% then calls \cs{verbatim@@}.
% \end{macro}
%
% \begin{macro}{\verbatim@@}
% \cs{verbatim@@} takes everything up to the next occurrence of
% the four characters \cs{end} as its argument.
% \begin{macrocode}
\def\verbatim@@#1!end{%
% \end{macrocode}
% That means: if they do not occur in the original line, then
% argument \verb?#1? is the
% whole input line, and \cs{@nil} is the next token
% to be processed.
% However, if the four characters \cs{end} are part of the
% original line, then
% \verb?#1? consists of the characters in front of \cs{end},
% and the next token is the following character (always remember
% that the line was lengthened by five tokens).
% Whatever \verb?#1? may be, it is verbatim text,
% so \verb?#1? is added to the line currently built.
% \begin{macrocode}
\verbatim@addtoline{#1}%
% \end{macrocode}
% The next token in the input stream
% is of special interest to us.
% Therefore \cs{futurelet} defines \cs{next} to be equal
% to it before calling \cs{verbatim@@@}.
% \begin{macrocode}
\futurelet\next\verbatim@@@}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@@@}
% \cs{verbatim@@@} will now read the rest of the tokens on
% the current line,
% up to the final \cs{@nil} token.
% \begin{macrocode}
\def\verbatim@@@#1\@nil{%
% \end{macrocode}
% If the first of the above two cases occurred, i.e.\ no
% \cs{end} characters were on that line, \verb?#1? is empty
% and \cs{next} is equal to \cs{@nil}.
% This is easily checked.
% \begin{macrocode}
\ifx\next\@nil
% \end{macrocode}
% If so, this was a simple line.
% We finish it by processing the line we accumulated so far.
% Then we prepare to read the next line.
% \begin{macrocode}
\verbatim@processline
\verbatim@startline
\let\next\verbatim@
% \end{macrocode}
% Otherwise we have to check what follows these \cs{end}
% tokens.
% \begin{macrocode}
\else
% \end{macrocode}
% Before we continue, it's a good idea to stop for a moment
% and remember where we are:
% We have just read the four character tokens \cs{end}
% and must now check whether the name of the environment (surrounded
% by braces) follows.
% To this end we define a macro called \cs{@tempa}
% that reads exactly one character and decides what to do next.
% This macro should do the following: skip spaces until
% it encounters either a left brace or the end of the line.
% But it is important to remember which characters are skipped.
% The \cs{end}\meta{optional spaces}\verb?{? characters
% may be part of the verbatim text, i.e.\ these characters
% must be printed.
%
% Assume for example that the current line contains
% \begin{verbatim*}
% \end {AVeryLongEnvironmentName}
%\end{verbatim*}
% As we shall soon see, the scanning mechanism implemented here
% will not find out that this is text to be printed until
% it has read the right brace.
% Therefore we need a way to accumulate the characters read
% so that we can reinsert them if necessary.
% The token register \cs{@temptokena} is used for this purpose.
%
% Before we do this we have to get rid of the superfluous
% \cs{end} tokens at the end of the line.
% To this end we define a temporary macro whose argument
% is delimited by \verb?\end\@nil? (four character tokens
% and one control sequence token) to be used below
% on the rest of the line, after appending a \cs{@nil} token to it.
% (Note that this token can never appear in \verb?#1?.)
% We use the following definition of
% \cs{@tempa} to get the rest of the line (after the first
% \cs{end}).
% \begin{macrocode}
\def\@tempa##1!end\@nil{##1}%
% \end{macrocode}
% We mentioned already that we use token register
% \cs{@temptokena}
% to remember the characters we skip, in case we need them again.
% We initialize this with the \cs{end} we have thrown away
% in the call to \cs{@tempa}.
% \begin{macrocode}
\@temptokena{!end}%
% \end{macrocode}
% We shall now call \cs{verbatim@test}
% to process the characters
% remaining on the current line.
% But wait a moment: we cannot simply call this macro
% since we have already read the whole line.
% Therefore we have to first expand the macro \cs{@tempa} to insert
% them again after the \cs{verbatim@test} token.
% A \verb?^^M? character is appended to denote the end of the line.
% (Remember that this character comes disguised as a tilde.)
% \begin{macrocode}
\def\next{\expandafter\verbatim@test\@tempa#1\@nil~}%
% \end{macrocode}
% That's almost all, but we still have to
% now call \cs{next} to do the work.
% \begin{macrocode}
\fi \next}%
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\verbatim@test}
% We define \cs{verbatim@test} to investigate every token
% in turn.
% \begin{macrocode}
\def\verbatim@test#1{%
% \end{macrocode}
% First of all we set \cs{next} equal to \cs{verbatim@test}
% in case this macro must call itself recursively in order to
% skip spaces.
% \begin{macrocode}
\let\next\verbatim@test
% \end{macrocode}
% We have to distinguish four cases:
% \begin{enumerate}
% \item The next token is a \verb?^^M?, i.e.\ we reached
% the end of the line. That means that nothing
% special was found.
% Note that we use \cs{if} for the following
% comparisons so that the category code of the
% characters is irrelevant.
% \begin{macrocode}
\if\noexpand#1\noexpand~%
% \end{macrocode}
% We add the characters accumulated in token register
% \cs{@temptokena} to the current line. Since
% \cs{verbatim@addtoline} does not expand its argument,
% we have to do the expansion at this point. Then we
% \cs{let} \cs{next} equal to \cs{verbatim@}
% to prepare to read the next line.
% \begin{macrocode}
\expandafter\verbatim@addtoline
\expandafter{\the\@temptokena}%
\verbatim@processline
\verbatim@startline
\let\next\verbatim@
% \end{macrocode}
% \item A space character follows.
% This is allowed, so we add it to \cs{@temptokena}
% and continue.
% \begin{macrocode}
\else \if\noexpand#1
\@temptokena\expandafter{\the\@temptokena#1}%
% \end{macrocode}
% \item An open brace follows.
% This is the most interesting case.
% We must now collect characters until we read the closing
% brace and check whether they form the environment name.
% This will be done by \cs{verbatim@testend}, so here
% we let \cs{next} equal this macro.
% Again we will process the rest of the line, character
% by character.
% The characters forming the name of the environment will
% be accumulated in \cs{@tempc}.
% We initialize this macro to expand to nothing.
% \begin{macrocode}
\else \if\noexpand#1\noexpand[%
\let\@tempc\@empty
\let\next\verbatim@testend
% \end{macrocode}
% Note that the \verb?[? character will be a \verb?{? when
% this macro is defined.
% \item Any other character means that the \cs{end} was part
% of the verbatim text.
% Add the characters to the current line and prepare to call
% \cs{verbatim@} to process the rest of the line.
% \begin{macrocode}
\else
\expandafter\verbatim@addtoline
\expandafter{\the\@temptokena}%
\def\next{\verbatim@#1}%
\fi\fi\fi
% \end{macrocode}
% \end{enumerate}
% The last thing this macro does is to call \cs{next}
% to continue processing.
% \begin{macrocode}
\next}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@testend}
% \cs{verbatim@testend} is called when
% \cs{end}\meta{optional spaces}\verb?{? was seen.
% Its task is to scan everything up to the next \verb?}?
% and to call \cs{verbatim@@testend}.
% If no \verb?}? is found it must reinsert the characters it read
% and return to \cs{verbatim@}.
% The following definition is similar to that of
% \cs{verbatim@test}:
% it takes the next character and decides what to do.
% \begin{macrocode}
\def\verbatim@testend#1{%
% \end{macrocode}
% Again, we have four cases:
% \begin{enumerate}
% \item \verb?^^M?: As no \verb?}? is found in the current line,
% add the characters to the buffer. To avoid a
% complicated construction for expanding
% \cs{@temptokena}
% and \cs{@tempc} we do it in two steps. Then we
% continue with \cs{verbatim@} to process the
% next line.
% \begin{macrocode}
\if\noexpand#1\noexpand~%
\expandafter\verbatim@addtoline
\expandafter{\the\@temptokena[}%
\expandafter\verbatim@addtoline
\expandafter{\@tempc}%
\verbatim@processline
\verbatim@startline
\let\next\verbatim@
% \end{macrocode}
% \item \verb?}?: Call \cs{verbatim@@testend} to check
% if this is the right environment name.
% \begin{macrocode}
\else\if\noexpand#1\noexpand]%
\let\next\verbatim@@testend
% \end{macrocode}
% \item \verb?\?: This character must not occur in the name of
% an environment. Thus we stop collecting characters.
% In principle, the same argument would apply to other
% characters as well, e.g., \verb?{?.
% However, \verb?\? is a special case, since it may be
% the first character of \cs{end}. This means that
% we have to look again for
% \cs{end}\marg{environment name}
% Note that we prefixed the \verb?!? by a \cs{noexpand}
% primitive, to protect ourselves against it being an
% active character.
% \begin{macrocode}
\else\if\noexpand#1\noexpand!%
\expandafter\verbatim@addtoline
\expandafter{\the\@temptokena[}%
\expandafter\verbatim@addtoline
\expandafter{\@tempc}%
\def\next{\verbatim@!}%
% \end{macrocode}
% \item Any other character: collect it and continue.
% We cannot use \cs{edef} to define \cs{@tempc}
% since its replacement text might contain active
% character tokens.
% \begin{macrocode}
\else \expandafter\def\expandafter\@tempc\expandafter
{\@tempc#1}\fi\fi\fi
% \end{macrocode}
% \end{enumerate}
% As before, the macro ends by calling itself, to
% process the next character if appropriate.
% \begin{macrocode}
\next}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@@testend}
% Unlike the previous macros \cs{verbatim@@testend} is simple:
% it has only to check if the \cs{end}\marg{...}
% matches the corresponding \cs{begin}\marg{...}
% \begin{macrocode}
\def\verbatim@@testend{%
% \end{macrocode}
% We use \cs{next} again to define the things that are
% to be done.
% Remember that the name of the current environment is
% held in \cs{@currenvir}, the characters accumulated
% by \cs{verbatim@testend} are in \cs{@tempc}.
% So we simply compare these and prepare to execute
% \cs{end}\marg{current environment}
% macro if they match.
% Before we do this we call \cs{verbatim@finish} to process
% the last line.
% We define \cs{next} via \cs{edef} so that
% \cs{@currenvir} is replaced by its expansion.
% Therefore we need \cs{noexpand} to inhibit the expansion
% of \cs{end} at this point.
% \begin{macrocode}
\ifx\@tempc\@currenvir
\verbatim@finish
\edef\next{\noexpand\end{\@currenvir}%
% \end{macrocode}
% Without this trick the \cs{end} command would not be able
% to correctly check whether its argument matches the name of
% the current environment and you'd get an
% interesting \LaTeX{} error message such as:
% \begin{verbatim}
%! \begin{verbatim*} ended by \end{verbatim*}.
%\end{verbatim}
% But what do we do with the rest of the characters, those
% that remain on that line?
% We call \cs{verbatim@rescan} to take care of that.
% Its first argument is the name of the environment just
% ended, in case we need it again.
% \cs{verbatim@rescan} takes the list of characters to be
% reprocessed as its second argument.
% (This token list was inserted after the current macro
% by \cs{verbatim@@@}.)
% Since we are still in an \cs{edef} we protect it
% by means of\cs{noexpand}.
% \begin{macrocode}
\noexpand\verbatim@rescan{\@currenvir}}%
% \end{macrocode}
% If the names do not match, we reinsert everything read up
% to now and prepare to call \cs{verbatim@} to process
% the rest of the line.
% \begin{macrocode}
\else
\expandafter\verbatim@addtoline
\expandafter{\the\@temptokena[}%
\expandafter\verbatim@addtoline
\expandafter{\@tempc]}%
\let\next\verbatim@
\fi
% \end{macrocode}
% Finally we call \cs{next}.
% \begin{macrocode}
\next}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@rescan}
% In principle \cs{verbatim@rescan} could be used to
% analyse the characters remaining after the \verb?\end{...}?
% command and pretend that these were read
% ``properly'', assuming ``standard'' category codes are in
% force.\footnote{Remember that they were all read with
% category codes $11$ (letter) and $12$ (other) so
% that control sequences are not recognized as such.}
% But this is not always possible (when there are unmatched
% curly braces in the rest of the line).
% Besides, we think that this is not worth the effort:
% After a \texttt{verbatim} or \texttt{verbatim*} environment
% a new line in the output is begun anyway,
% and an \verb?\end{comment}? can easily be put on a line by itself.
% So there is no reason why there should be any text here.
% For the benefit of the user who did put something there
% (a comment, perhaps)
% we simply issue a warning and drop them.
% The method of testing is explained in Appendix~D, p.\ 376 of
% the \TeX{}book. We use \verb?^^M? instead of the \verb?!?
% character used there
% since this is a character that cannot appear in \verb?#1?.
% The two \cs{noexpand} primitives are necessary to avoid
% expansion of active characters and macros.
%
% One extra subtlety should be noted here: remember that
% the token list we are currently building will first be
% processed by the \cs{lowercase} primitive before \TeX{}
% carries out the definitions.
% This means that the `\texttt{C}' character in the
% argument to the \cs{@warning} macro must be protected against
% being changed to `\texttt{c}'. That's the reason why we added the
% \verb?\lccode`\C=`\C? assignment above.
% We can now finish the argument to \cs{lowercase} as well as the
% group in which the category codes were changed.
% \begin{macrocode}
\def\verbatim@rescan#1#2~{\if\noexpand~\noexpand#2~\else
\@warning{Characters dropped after `\string\end{#1}'}\fi}}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{The \cs{verbatiminput} command}
%
% \begin{macro}{\verbatim@in@stream}
% We begin by allocating an input stream (out of the 16 available
% input streams).
% \begin{macrocode}
\newread\verbatim@in@stream
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@readfile}
% The macro \cs{verbatim@readfile} encloses the main loop by calls to
% the macros \cs{verbatim@startline} and \cs{verbatim@finish},
% respectively. This makes sure
% that the user can initialize and finish the command when the file
% is empty or doesn't exist. The \texttt{verbatim} environment has a
% similar behaviour when called with an empty text.
% \begin{macrocode}
\def\verbatim@readfile#1{%
\verbatim@startline
% \end{macrocode}
% When the file is not found we issue a warning.
% \begin{macrocode}
\openin\verbatim@in@stream #1\relax
\ifeof\verbatim@in@stream
\typeout{No file #1.}%
\else
% \end{macrocode}
% At this point we pass the name of the file to \cs{@addtofilelist}
% so that its appears appears in the output of a \cs{listfiles}
% command.
% In addition, we use \cs{ProvidesFile} to make a log entry in the
% transcript file and to distinguish files read in via
% \cs{verbatiminput} from others.
% \begin{macrocode}
\@addtofilelist{#1}%
\ProvidesFile{#1}[(verbatim)]%
% \end{macrocode}
% While reading from the file it is useful to switch off the
% recognition of the end-of-line character. This saves us stripping
% off spaces from the contents of the line.
% \begin{macrocode}
\expandafter\endlinechar\expandafter\m@ne
\expandafter\verbatim@read@file
\expandafter\endlinechar\the\endlinechar\relax
\closein\verbatim@in@stream
\fi
\verbatim@finish
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@read@file}
% All the work is done in \cs{verbatim@read@file}. It reads the input
% file line by line and recursively calls itself until the end of
% the file.
% \begin{macrocode}
\def\verbatim@read@file{%
\read\verbatim@in@stream to\next
\ifeof\verbatim@in@stream
\else
% \end{macrocode}
% For each line we call \cs{verbatim@addtoline} with the contents of
% the line. \hskip0pt plus 3cm\penalty0\hskip0pt plus -3cm
% \cs{verbatim@processline} is called next.
% \begin{macrocode}
\expandafter\verbatim@addtoline\expandafter{\next}%
\verbatim@processline
% \end{macrocode}
% After processing the line we call \cs{verbatim@startline} to
% initialize all before we read the next line.
% \begin{macrocode}
\verbatim@startline
% \end{macrocode}
% Without \cs{expandafter} each call of \cs{verbatim@read@file} uses
% space in \TeX's input stack.\footnote{A standard \TeX\ would
% report an overflow error if you try to read a file with more than
% ca.\ 200~lines. The same error occurs if the first line of code
% in \S 390 of \textsl{``TeX: The Program''\/} is missing.}
% \begin{macrocode}
\expandafter\verbatim@read@file
\fi
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\verbatiminput}
% \cs{verbatiminput} first starts a group to keep font and category
% changes local.
% Then it calls the macro \cs{verbatim@input} with additional
% arguments, depending on whether an asterisk follows.
%
% PW. I added the TAB checking code.
% \begin{macrocode}
\def\verbatiminput{\begingroup
\ift@bs
\def\verbatim@processline{\tabverbatim@processline}%
\fi
\@ifstar{\verbatim@input{\@maybeobeytabs}}%
{\verbatim@input{\frenchspacing\@vobeyspaces\@maybeobeytabs}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@input}
% \cs{verbatim@input} first checks whether the file exists, using
% the standard macro cs{IfFileExists} which leaves the name of the
% file found in \cs{@filef@und}.
% Then everything is set up as in the \cs{verbatim} macro.
% \begin{macrocode}
\def\verbatim@input#1#2{%
\IfFileExists {#2}{\@verbatim #1\relax
% \end{macrocode}
% Then it reads in the file, finishes off the \texttt{trivlist}
% environment started by \cs{@verbatim} and closes the group.
% This restores everything to its normal settings.
% \begin{macrocode}
\verbatim@readfile{\@filef@und}\endtrivlist\endgroup\@doendpe}%
% \end{macrocode}
% If the file is not found a more or less helpful message is
% printed. The final \cs{endgroup} is needed to close the group
% started in \cs{verbatiminput} above.
% \begin{macrocode}
{\typeout {No file #2.}\endgroup}}
% \end{macrocode}
% \end{macro}
%
% \textit{That completes my borrowings from \Lpack{verbatim}.}
%
% The next bunch of code implements wrapping verbatim lines so they, hopefully,
% stay within the typeblock.
%
% \begin{macro}{\verbatimindent}
% \begin{macro}{\verbatimbreakchar}
% \begin{macro}{\setverbatimbreak}
% The length \cs{verbatimindent} is the distance continuation lines are indented
% from the left margin. \cs{verbatimbreakchar} is the character to indicate
% a wrapped line.
% \begin{macrocode}
\newlength{\verbatimindent}
\setlength{\verbatimindent}{3em}
\newcommand*{\verbatimbreakchar}{\char`\%}
\newcommand*{\setverbatimbreak}{%
\vspace*{-\baselineskip}%
\def\@xobeysp{~\discretionary{\verbatimbreakchar}%
{\kern\verbatimindent}{}}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\raggedwrap}
% \begin{macro}{\wrappingon}
% \begin{macro}{\wrapright}
% \begin{macro}{\wrappingoff}
% \cs{wrappingon} and \cs{wrappingoff} enable/prohibit wrapping. The
% default is \cs{wrappingoff}.
%
% The macro
% \cs{wrapright} is used to set paragraph skips; without raggedright the
% lines
% may break at the first space \emph{outside} the text area. However,
% Paul (\url{paulaugust2003@yahoo.com}) found that wrapped verbatims
% in a list (e.g., \texttt{itemize}) were not indented although regular
% verbatims were indented. \cs{raggedwrap} is a variation on \cs{raggedright}
% (\cs{leftskip} is set to \cs{@totalleftmargin} instead of 0pt), and seems
% to have fixed the problem with the original code which used
% \cs{raggedright}.
% \changes{v1.61803}{2008/01/30}{Added \cs{raggedwrap} (mempatch v4.4)}
% \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{raggedwrap}}
% \begin{macrocode}
\newcommand*{\raggedwrap}{%
\@rightskip\@flushglue
%%% \rightskip\@rightskip
\memRTLrightskip\@rightskip
%%% \leftskip\@totalleftmargin
\memRTLleftskip\@totalleftmargin
\parindent\ragrparindent}
\newcommand*{\wrappingon}{%
\def\@xobeysp{~\discretionary{\verbatimbreakchar}%
{\kern\verbatimindent}{}}%
\def\wrapright{\raggedwrap}}
\newcommand*{\wrappingoff}{%
\def\@xobeysp{\leavevmode\penalty\@M\ }%
\def\wrapright{}}
\wrappingoff
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Writing and boxing verbatim}
%
% This bunch of code is from the \Lpack{moreverb} package.
%
% \begin{environment}{verbatimoutput}
% \verb?\begin{verbatimoutput}?\marg{filename} writes all text in its body to a
% file, the name of which it is given as an argument. (The code was
% written by Rainer Sch\"opf but the environment was called
% \verb?verbatimwrite?). In the code below, uncommenting \\
% \verb?\catcode`\^^I=12? \\
% will result in TABs being written as \verb?^^I?.
% \changes{v1.3}{2002/09/27}{Changed name verbatimwrite to
% verbatimoutput (but neither were mentioned in the manual)}
% \begin{macrocode}
\newwrite \verbatim@out
\def\verbatimoutput#1{%
\@bsphack
\immediate\openout \verbatim@out #1
\let\do\@makeother\dospecials
\catcode`\^^M\active %% \catcode`\^^I=12
\def\verbatim@processline{%
\immediate\write\verbatim@out
{\the\verbatim@line}}%
\verbatim@start}
% \end{macrocode}
% \begin{macrocode}
\def\endverbatimoutput{%
\immediate\closeout\verbatim@out
\@esphack}
% \end{macrocode}
% \end{environment}
%
%
%
% \begin{environment}{fboxverbatim}
% \texttt{fboxverbatim} puts the contents of a verbatim environment
% in a framing box. (PW: This was originally called \texttt{boxedverbatim}).
%
% (Written by Victor Eijkhout.)
%
% Bug fix (supplied by David Carlisle) 1995/12/28, marked
% \verb+%%%DPC%%%+
%
% First, redefine `processline' to produce only a line as wide
% as the natural width of the line
%
% \begin{macrocode}
\def\fboxverbatim{\begingroup%
\tabsoff %% PW otherwise box fills the width
\def\verbatim@processline{%
{\setbox0=\hbox{\the\verbatim@line}%
\hsize=\wd0 \the\verbatim@line\par}}%
% \end{macrocode}
%
% Now save the verbatim code in a box
%
% \begin{macrocode}
\@minipagetrue%%%DPC%%%
\@tempswatrue%%%DPC%%%
\setbox0=\vbox\bgroup \verbatim
}
% \end{macrocode}
%
% At the end of the environment, we (umm) simply have to stick the
% results into a frame.
%
% \begin{macrocode}
\def\endfboxverbatim{%
\endverbatim
\unskip\setbox0=\lastbox %%%DPC%%%
% \end{macrocode}
%
% Now everything's in the box, so we can close it\dots
%
% \begin{macrocode}
\egroup
% \end{macrocode}
%
% To change the code for centering, the next line needs a spot of
% hacking.
%
% \begin{macrocode}
\fbox{\box0}% <<<=== change here for centering,...
\endgroup}
% \end{macrocode}
% \end{environment}
%
%
%
% \subsection{The shortvrb package}
%
% The following is the \Lpack{shortvrb} package code (from \texttt{doc.dtx}
% by Frank Mittelbach). It has been so useful to me that I wanted
% to include it in the class.
%
% CODE AND COMMENTARY IS BY FRANK MITTELBACH
%
% \begin{macro}{\MakeShortVerb}
% \begin{macrocode}
\def\MakeShortVerb#1{%
\expandafter\ifx\csname cc\string#1\endcsname\relax
% \end{macrocode}
% \begin{macrocode}
\@shortvrbinfo{Made }{#1}%
\add@special{#1}%
% \end{macrocode}
% Then the character's current catcode is stored in \verb?\cc\?\meta{c}.
% \begin{macrocode}
\expandafter
\xdef\csname cc\string#1\endcsname{\the\catcode`#1}%
% \end{macrocode}
% The character is spliced into the definition using the same trick as
% used in \cs{verb} (for instance), having activated \verb?~? in a group.
% \begin{macrocode}
\begingroup
\catcode`\~\active \lccode`\~`#1%
\lowercase{%
% \end{macrocode}
% The character's old meaning is recorded in \verb?\ac\?\meta{c} prior to
% assigning it a new one.
% \begin{macrocode}
\global\expandafter\let
\csname ac\string#1\endcsname~%
\gdef~{\verb~}}%
\endgroup
% \end{macrocode}
% Finally the character is made active.
% \begin{macrocode}
\global\catcode`#1\active
% \end{macrocode}
% If we suspect that \meta{c} is already a short reference, we tell
% the user. Now he or she is responsible if anything goes wrong\,\dots
% \begin{macrocode}
\else
% \end{macrocode}
% \begin{macrocode}
\@shortvrbinfo\@empty{#1 already}%
\fi}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\DeleteShortVerb}
% Here's the means of undoing a \cs{MakeShortVerb}, for instance in a
% region where you need to use the character outside a verbatim
% environment. It arranges for \cs{dospecials} and \cs{@sanitize} to be
% altered appropriately, restores the saved catcode and, if necessary,
% the character's meaning (as stored by
% \cs{MakeShortVerb}). If the catcode wasn't stored in
% \verb?\cc\?\meta{c} (by \cs{MakeShortVerb}) the command is silently
% ignored.
% \begin{macrocode}
\def\DeleteShortVerb#1{%
\expandafter\ifx\csname cc\string#1\endcsname\relax
\else
% \end{macrocode}
% \begin{macrocode}
\@shortvrbinfo{Deleted }{#1 as}%
\rem@special{#1}%
\global\catcode`#1\csname cc\string#1\endcsname
% \end{macrocode}
% We must not forget to reset \verb?\cc\?\meta{c}, otherwise the check in
% \cs{MakeShortVerb} for a repeated definition will not work.
% \begin{macrocode}
\global \expandafter\let \csname cc\string#1\endcsname \relax
\ifnum\catcode`#1=\active
\begingroup
\catcode`\~\active \lccode`\~`#1%
\lowercase{%
\global\expandafter\let\expandafter~%
\csname ac\string#1\endcsname}%
\endgroup \fi \fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@shortvrbinfo}
% Helper function for info messages.
% \begin{macrocode}
\def\@shortvrbinfo#1#2{%
\ClassInfo{memoir}{%
#1\expandafter\@gobble\string#2 a short reference
for \string\verb}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\add@special}
% This helper macro adds its argument to the
% \cs{dospecials} macro which is conventionally used by verbatim macros
% to alter the catcodes of the currently active characters. We need
% to add \verb?\do\?\meta{c} to the expansion of \cs{dospecials} after
% removing the character if it was already there to avoid multiple
% copies building up should \cs{MakeShortVerb} not be balanced by
% \cs{DeleteShortVerb} (in case anything that uses \cs{dospecials} cares
% about repetitions).
% \begin{macrocode}
\def\add@special#1{%
\rem@special{#1}%
\expandafter\gdef\expandafter\dospecials\expandafter
{\dospecials \do #1}%
% \end{macrocode}
% Similarly we have to add \verb?\@makeother\?\meta{c} to \cs{@sanitize}
% (which is used in things like \cs{index} to re-catcode all special
% characters except braces).
% \begin{macrocode}
\expandafter\gdef\expandafter\@sanitize\expandafter
{\@sanitize \@makeother #1}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\rem@special}
% The inverse of cs{add@special} is slightly trickier. \cs{do} is
% re-defined to expand to nothing if its argument is the character of
% interest, otherwise to expand simply to the argument. We can then
% re-define \cs{dospecials} to be the expansion of itself. The space
% after \verb?=`##1? prevents an expansion to \cs{relax}!
% \begin{macrocode}
\def\rem@special#1{%
\def\do##1{%
\ifnum`#1=`##1 \else \noexpand\do\noexpand##1\fi}%
\xdef\dospecials{\dospecials}%
% \end{macrocode}
% Fixing \cs{@sanitize} is the same except that we need to re-define
% \cs{@makeother} which obviously needs to be done in a group.
% \begin{macrocode}
\begingroup
\def\@makeother##1{%
\ifnum`#1=`##1 \else \noexpand\@makeother\noexpand##1\fi}%
\xdef\@sanitize{\@sanitize}%
\endgroup}
% \end{macrocode}
% \end{macro}
%
% END OF MITTELBACH CODE AND COMMENTARY.
%
% \subsection{General verbatim boxing and line numbering}
%
% A while ago I wrote a package that I never released. Here it is
% now, updated and improved. The package was based on code originally
% posted to \ctt{} by Donald Arseneau on 13 July 2000.
%
% This is DA's posted code.
% \begin{verbatim}
% \RequirePackage{verbatim}
% \def\boxverbflag{14 }
%
% \def\boxedverbatim{%
% \fboxsep=1em
% \def\verbatim@processline{\leavevmode
% \vrule\vbox{\advance\hsize-.8p@ \@@line
% {\strut\kern\fboxsep\the\verbatim@line\hss}%
% \kern\fbozsep}\vrule\par}%
% \@verbatim % but make some replacement settings
% % \ifdim\@totalleftmargin>\fboxsep \fboxsep\@totalleftmargin \fi
% \leftskip\x@skip \rightskip\z@skip
% \interlinepenalty\boxverbflag
% \parfillskip\z@ plus\p@ minus\p@
% \lineskip-\fboxsep \baselineskip\z@skip
% \frenchspacing\@vobeyspaces
% \boxverb@toprule
% \verbatim@start}
%
% \def\endboxedverbatim{\hrule\endtrivlist}
%
% \@namefdef{boxedverbatim*}{\let\frenchspacing\@gobble \boxedverbatim}
% \@namefdef{endboxedverbatim*}{\hrule\endtrivlist}
%
% \output=\expandafter{\expandafter\boxverb@split \the\output}
%
% \def\boxverb@toprule{\hrule \nobreak \vskip-.1\p@
% \@@line{\vrule height2\fboxsep \hss \vrule}}
%
% \def\boxverb@split{\ifnum\outputpenalty=\boxverbflag
% \ifdim\dp\@cclv=\z@
% \setbox\@cclv\vbox{\unvbox\@cclv\hrule\kern-.4pt}%
% \null \kern-.7\topskip \boxverb@toprule
% \fi\fi}
% \end{verbatim}
% That's the end of DA's posted code
%
% I have extended this to provide:
% \begin{itemize}
% \item A (multipage) boxed verbatim
% \item A (multipage) boxed verbatim input
% \item Normally each `page' is boxed, but start/end rules can be switched off
% at page boundaries
% \item A heading can be put at the start of `continuation' pages
% \item Lines of verbatim text can be numbered
% \item Can be `downgraded' to normal verbatim environment
% \end{itemize}
%
% OK, on to the main code.
%
% \begin{macro}{\boxverbflag}
% \begin{macro}{\bvboxsep}
% \begin{macrocode}
\def\boxverbflag{14 }
\newlength{\bvboxsep} % user can change this
\setlength{\bvboxsep}{1em}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
\newif\ifbvperpage % start/end lines on every page of multipage verbatim
\bvperpagetrue
% \end{macrocode}
%
% \begin{macro}{\bvtopofpage}
% \begin{macro}{\b@vtop}
% Can use \cs{bvtopofpage} to put a heading above continued verbatims.
% For example \\
% \verb?\bvtopofpage{\begin{center}\normalfont (Continued)\end{center}}? \\
% It only works for \cs{bvperpagetrue}.
% \begin{macrocode}
\newcommand{\bvtopofpage}[1]{%
\long\def\b@vtop{#1}}
\def\b@vtop{} % used in \boxverb@split for heading
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@memfbvline}
% \begin{macro}{\c@bvlinectr}
% Counter for adjusting the starting line number for boxed verbatims
% and for the line number itself..
% \begin{macrocode}
\newcounter{memfbvline}
\c@memfbvline=\z@
\newcounter{bvlinectr}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setbvlinenums}
% \cs{setbvlinenums}\marg{firstline}\marg{startnumsat} sets the first line
% number to \meta{firstline} and the first line number to be printed is
% \meta{startnumsat}.
% \changes{v1.61803}{2008/01/30}{Added \cs{setbvlinenums} (mempatch v4.9)}
% \begin{macrocode}
\newcommand*{\setbvlinenums}[2]{%
\c@bvlinectr #1\relax \advance\c@bvlinectr \m@ne
\ifnum\z@<\linemodnum% we are printing line numbers
\@tempcnta #2\relax
\divide\@tempcnta\linemodnum
\multiply\@tempcnta\linemodnum
\c@memfbvline #2\relax
\advance\c@memfbvline-\@tempcnta
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\theb@vlinenumber}
% \begin{macro}{\resetbvlinenumber}
% \cs{resetbvlinenumber} reinitializes the line numbering.
% \changes{v1.61803}{2008/01/30}{Changed \cs{theb@vlinenumber} (mempatch v4.9)}
% \begin{macrocode}
\def\theb@vlinenumber{\getthelinenumber{bvlinectr}{memfbvline}}
\newcommand*{\resetbvlinenumber}{\setcounter{bvlinectr}{0}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\b@vdocount}
% \begin{macro}{\bvnumlength}
% Increment line number if counting. A line number is printed in
% a space width \cs{bvnumlength}, which is given a temporary value here.
% \begin{macrocode}
\def\b@vdocount{\ifbvcountlines\stepcounter{bvlinectr}\fi}
\newlength{\bvnumlength}
%% \settowidth{\bvnumlength}{\vlvnumfont 9999}
\settowidth{\bvnumlength}{\normalfont 999}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifbvcountinside}
% \begin{macro}{\bvnumbersinside}
% \begin{macro}{\bvnumbersoutside}
% Flag and commands for positioning the numbers. Default is to print
% them inside the box.
% \begin{macrocode}
\newif\ifbvcountinside % TRUE if line numbers inside box
\bvcountinsidetrue
\newcommand*{\bvnumbersinside}{\bvcountinsidetrue}
\newcommand*{\bvnumbersoutside}{\bvcountinsidefalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\b@vdoinside}
% \begin{macro}{\b@vdooutside}
% Print numbers inside (outside) the box.
% \begin{macrocode}
\def\b@vdoinside{%
\ifbvcountlines\ifbvcountinside%
\makebox[\bvnumlength][r]{%
\vlvnumfont \theb@vlinenumber\space}%
\fi\fi}
\def\b@vdooutside{%
\ifbvcountlines\ifbvcountinside\else%
\llap{\makebox[\bvnumlength][r]{%
\vlvnumfont \theb@vlinenumber\space}}%
\fi\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@m@mline}
% \cs{@@line} is defined as \verb?\def\@@line{\hb@xt@\hsize}? and I need
% an equivalent for \cs{linewidth} instead of \cs{hsize} for use in
% \cs{setupboxverb@line}.
% \changes{v1.61803}{2008/01/30}{Added \cs{@@m@mline} (mempatch v4.9)}
% \begin{macrocode}
\newcommand*{\@@m@mline}{\hb@xt@\linewidth}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setupboxverb@line}
% Use a macro for the first main part of DA's code for \cs{boxedverbatim},
% adding lots of hooks.
%
% Per Starb\"{a}ck had problems with the combination of \texttt{adjustwidth}
% with \texttt{boxedverbatim} (see CTT \textit{Re: [memoir] adjustwidth +
% boxedverbatim}, 2007/02/10) and Lars Madsen came up with a suggestion to
% use \cs{linewidth} instead of \cs{hsize}.
% \changes{v1.61803}{2008/01/30}{Changed \cs{hsize} to \cs{linewidth} in
% \cs{setupboxverb@line} (mempatch v4.9)}
% \begin{macrocode}
\newcommand{\setupboxverb@line}{%
\par
\ifbvperpage
\output=\expandafter{\expandafter\boxverb@split \the\output}
\fi
% \end{macrocode}
% \begin{macro}{\verbatim@processline}
% \begin{macrocode}
\def\verbatim@processline{\leavevmode
\b@vdocount%
\bvleftsidehook\vbox{\advance% \hsize-.8\p@ \@@line % changed to \linewidth
\linewidth-.8\p@ \@@line
{\b@vdooutside\strut\kern\bvboxsep%
\b@vdoinside%
\ift@bs
\tabverbatim@processline
\else
\the\verbatim@line
\fi
\hss}%
\kern\bvboxsep}\bvrightsidehook\par}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\setupbox@verb}
% Use a macro for the second main part of DA's code, and integrate it
% with the other verbatim codes (e.g., include \cs{@maybeobeytags}).
% \begin{macrocode}
\newcommand{\setupbox@verb}{%
\leftskip\z@skip \rightskip\z@skip
\interlinepenalty\boxverbflag
\parfillskip\z@ plus\p@ minus\p@
\lineskip-\bvboxsep \baselineskip\z@skip
\frenchspacing\@vobeyspaces\@maybeobeytabs
\boxverb@toprule}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\boxedverbatim}
% \begin{macro}{\endboxedverbatim}
% \begin{macro}{\boxedverbatim*}
% \begin{macro}{\endboxedverbatim*}
% Given the two macros above, we can write a briefer version of DA's
% \cs{boxedverbatim(*)}.
% As noted by Zarko Cucej\footnote{\url{zarko.cucej@uni-mb.si}}, have to handle
% a following (no-) paragraph.
% \changes{v1.4}{2003/11/22}{Added \cs{@doendpe} to \cs{endboxedverbatim}
% (from patch v1.8)}
% \begin{macrocode}
\def\boxedverbatim{\begingroup
\let\@@line\@@m@mline% new from mempatch v4.9
\setupboxverb@line
\@verbatim
\setupbox@verb
\verbatim@start}
\def\endboxedverbatim{\bvendrulehook\endtrivlist\endgroup\@doendpe}
\@namedef{boxedverbatim*}{\let\frenchspacing\@gobble \boxedverbatim}
\@namelet{endboxedverbatim*}\endboxverbatim
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
\def\boxverb@toprule{\bvtoprulehook
\@@line{\bvleftsidehook \bvtopmidhook \bvrightsidehook}}
% \end{macrocode}
%
% \begin{macro}{\bvendofpage}
% \cs{bvendofpage}\marg{spec} sets the boxed verbatim `end of page' to \meta{spec}.
% \changes{v1.618}{2005/09/02}{Added \cs{bvendofpage} (mempatch v2.3d)}
% \changes{v1.61803}{2008/01/30}{Changed \cs{bvendofpage} to include width}
% \begin{macrocode}
\newcommand*{\bvendofpage}[1]{%
\def\boxverb@botpage{#1}}
%%%%\bvendofpage{\hrule\kern-.4pt}
\bvendofpage{\hrule width\linewidth\kern-.4pt}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\boxverb@split}
% \begin{macrocode}
\def\boxverb@split{\ifnum\outputpenalty=\boxverbflag
\ifdim\dp\@cclv=\z@
%%%% \setbox\@cclv\vbox{\unvbox\@cclv\hrule\kern-.4pt}%
\setbox\@cclv\vbox{\unvbox\@cclv\boxverb@botpage}%
\null \kern-.7\topskip \b@vtop \boxverb@toprule
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bvtoprulehook}
% \begin{macro}{\bvendrulehook}
% \begin{macro}{\bvleftsidehook}
% \begin{macro}{\bvrightsidehook}
% \begin{macro}{\bvtopmidhook}
% The new hooks, for the top, bottom, left and right of the box.
% \changes{v1.61803}{2008/01/30}{Added \cs{linewidth} to \cs{bvtoprulehook} and
% \cs{bvendrulehook} (mempatch v4.9)}
% \begin{macrocode}
\def\bvtoprulehook{\hrule width\linewidth \nobreak\vskip-.1\p@}
\def\bvendrulehook{\hrule width\linewidth}
\def\bvleftsidehook{\vrule}
\def\bvrightsidehook{\vrule}
\def\bvtopmidhook{\rule{0\p@}{2\bvboxsep} \hss}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\boxedverbatiminput}
% \begin{macro}{\boxedverbatim@input}
% \cs{boxedverbatiminput}\marg{filename} read in filename contents as verbatim
% \begin{macrocode}
\newcommand{\boxedverbatiminput}{\begingroup
\@ifstar{\let\frenchspacing\@gobble
\boxedverbatim@input\relax}%
{\boxedverbatim@input{\frenchspacing\@vobeyspaces}}}
% \end{macrocode}
%
% \begin{macrocode}
\def\boxedverbatim@input#1#2{%
\setupboxverb@line
\IfFileExists{#2}{\@verbatim #1\relax
\setupbox@verb
\verbatim@readfile{\@filef@und}%
\bvendrulehook\endtrivlist\endgroup\@doendpe}%
{\typeout {No file #2.}\endgroup}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Some prepackaged boxing styles.
%
% \begin{macro}{\bvbox}
% Original (default) boxing.
% \begin{macrocode}
\newcommand{\bvbox}{%
\bvperpagetrue%
\renewcommand{\bvtoprulehook}{\hrule \nobreak \vskip-.1\p@}%
\renewcommand{\bvleftsidehook}{\vrule}%
\renewcommand{\bvrightsidehook}{\vrule}%
\renewcommand{\bvendrulehook}{\hrule}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\nobvbox}
% No boxing
% \begin{macrocode}
\newcommand{\nobvbox}{%
\bvperpagefalse%
\renewcommand{\bvtoprulehook}{}%
\renewcommand{\bvleftsidehook}{}%
\renewcommand{\bvrightsidehook}{}%
\renewcommand{\bvendrulehook}{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bvtopandtail}
% Head and foot horizontal lines only
% \begin{macrocode}
\newcommand{\bvtopandtail}{%
\bvperpagefalse%
\renewcommand{\bvtoprulehook}{\hrule \nobreak \vskip-.1\p@}%
\renewcommand{\bvleftsidehook}{}%
\renewcommand{\bvrightsidehook}{}%
\renewcommand{\bvendrulehook}{\hrule}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bvsides}
% Side vertical lines only
% \begin{macrocode}
\newcommand{\bvsides}{%
\bvperpagefalse%
\renewcommand{\bvtoprulehook}{\vskip 3ex}%
\renewcommand{\bvleftsidehook}{\vrule}%
\renewcommand{\bvrightsidehook}{\vrule}%
\renewcommand{\bvendrulehook}{}}
% \end{macrocode}
% \end{macro}
%
%
%
% \subsection{The framed package}
%
% The following code is the \Lpack{framed} package~\cite{FRAMED}
% by Donald Arseneau.
% \changes{v1.4}{2003/11/22}{Updated framed code to v0.8a of the package}
% \changes{v1.61803}{2008/01/30}{Updated framed code to v0.95 of the package}
%
% \begin{macro}{\framed}
% \begin{macro}{\endframed}
% \begin{macro}{\shaded}
% \begin{macro}{\endshaded}
% \begin{macrocode}
\let\framed\relax \let\endframed\relax
\let\shaded\relax \let\endshaded\relax
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Way back when DA sent me a pre-release copy of v0.6 of his \Lpack{framed}
% package~\cite{FRAMED}.
% We also discussed good ways of embedding it into the class. One result
% being that I defined some some items \cs{AtBeginDocument}, but this is
% no longer required as DA has changed \Lpack{framed} to cooperate
% with memoir. We continue to have sporadic email conversations about the
% interaction of \Lpack{memoir} and \Lpack{framed}.
%
% Here is a modified version of \file{framed.sty}. In particular
% I moved some of DA's description of the code into the general commentary
% instead of comments within the code.
%
% \begin{verbatim}
% framed.sty v 0.95 2007/10/04
% Copyright (C) 1992-2007 by Donald Arseneau (asnd@triumf.ca)
% These macros may be freely transmitted, reproduced, or modified
% provided that this notice is left intact.
%
%====================== Begin Instructions =======================
%
% framed.sty
% ~~~~~~~~~~
% Create framed, shaded, or differently highlighted regions that can
% break across pages. The environments defined are
% framed -- ordinary frame box (\fbox) with edge at margin
% shaded -- shaded background (\colorbox) bleeding into margin
% snugshade -- similar
% leftbar -- thick vertical line in left margin
% to be used like
% \begin{framed}
% copious text
% \end{framed}
%
% But the more general purpose of this package is to facilitate the
% creation of environments that enable page breaking
% within arbitrary decorations using a simple new-environment definition
% incorporating \FrameCommand and
% \begin{MakeFramed}{settings} ... \end{MakeFramed}
%
% The "framed" environment uses "\fbox" as its "\FrameCommand" with
% the additional settings \fboxrule=\FrameRule and \fboxsep=\FrameSep.
% You can change these lengths (using \setlength) and you can change
% the definition of \FrameCommand to use much fancier boxes.
%
% In fact, the "shaded" environment just redefines \FrameCommand to be
% \colorbox{shadecolor} (and you have to define the color "shadecolor":
% \definecolor{shadecolor}...).
%
% A page break is allowed, and even encouraged, before the framed
% environment. If you want to attach some text (a box title) to the
% frame, then the text should be inserted by \FrameCommand.
%
% The contents of the framed regions are restricted:
% Floats, footnotes, marginpars and head-line entries will be lost.
% (Some of these may be handled in a later version.)
% This package will not work with the page breaking of multicol.sty,
% or other systems that perform column-balancing.
%
% The MakeFramed environment does the work. Its "settings" argument
% should contain any adjustments to the text width (applied to \hsize,
% and using the "\width" of the frame itself) as well as a "restore"
% command -- \@parboxrestore or \FrameRestore or something similar;
% as an example, the snugshade environment shows how to suppress excess
% spacing within the box, copying the code from minipage.
%
% Expert commands:
% \MakeFramed, \endMakeFramed: the "MakeFramed" environment
% \FrameCommand: command to draw the frame around its argument
% \FrameRestore: restore some text settings, but fewer than \@parboxrestore
% \FrameRule: length register; \fboxrule for default "framed".
% \FrameSep: length register; \fboxsep for default "framed".
% \FrameHeightAdjust: macro; height of frame above baseline at top of page
%
% This is still a `pre-production' version because I can think of many
% features/improvements that should be made. Nevertheless, starting
% with version 0.5 it should be bug-free.
%
% ToDo:
% Test more varieties of list
% Improve and correct documentation
% Propagation of \marks
% Handle footnotes (how??) floats (?) and marginpars.
% Stretchability modification.
%======================== End Instructions ========================
%
% \ProvidesPackage{framed}[2007/10/04 v 0.95:
% framed or shaded text with page breaks]
%
% \newenvironment{framed}% using default \FrameCommand
% {\MakeFramed {\advance\hsize-\width \FrameRestore}}%
% {\endMakeFramed}
%
% \newenvironment{shaded}{%
% \def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}%
% \MakeFramed {\FrameRestore}}%
% {\endMakeFramed}
%
% \newenvironment{leftbar}{%
% \def\FrameCommand{\vrule width 3pt \hspace{10pt}}%
% \MakeFramed {\advance\hsize-\width \FrameRestore}}%
% {\endMakeFramed}
%
% \newenvironment{snugshade}{%
% \def\FrameCommand{\colorbox{shadecolor}}%
% \MakeFramed {\FrameRestore\@setminipage}}%
% {\par\unskip\endMakeFramed}
%
% \end{verbatim}
%
% Now for the package code.
%
% \begin{macrocode}
\chardef\FrameRestore=\catcode`\| % for debug
\catcode`\|=\catcode`\% % (debug: insert space after backslash)
% \end{macrocode}
%
% \begin{macro}{\MakeFramed}
% \begin{macrocode}
\def\MakeFramed#1{\par
% \end{macrocode}
% measure added width and height; call result \cs{width} and \cs{height}
% \begin{macrocode}
\fb@sizeofframe\FrameCommand
\let\width\fb@frw \let\height\fb@frh
% \end{macrocode}
% insert pre-penalties and skips
% \begin{macrocode}
\begingroup
\skip@\lastskip
\if@nobreak\else
\penalty9999 % updates \page parameters
\ifdim\pagefilstretch=\z@ \ifdim\pagefillstretch=\z@
% \end{macrocode}
% not infinitely stretchable, so encourage a page break here
% \begin{macrocode}
\edef\@tempa{\the\skip@}%
\ifx\@tempa\zero@glue \penalty-30
\else \vskip-\skip@ \penalty-30 \vskip\skip@
\fi\fi\fi
\penalty\z@
% \end{macrocode}
% Give a stretchy breakpoint that will always be taken in preference
% to the \cs{penalty} 9999 used to update page parameters. The cube root
% of 10000/100 indicates a multiplier of 0.21545, but the maximum
% calculated badness is really 8192, not 10000, so the multiplier
% is 0.2301.
% \begin{macrocode}
\advance\skip@ \z@ plus-.5\baselineskip
\advance\skip@ \z@ plus-.231\height
\advance\skip@ \z@ plus-.231\skip@
\advance\skip@ \z@ plus-.231\topsep
\vskip-\skip@ \penalty 1800 \vskip\skip@
\fi
\addvspace{\topsep}%
\endgroup
% \end{macrocode}
% clear out pending page break
% \begin{macrocode}
\penalty\@M \vskip 2\baselineskip \vskip\height
\penalty9999 \vskip -2\baselineskip \vskip-\height
\penalty9999 % updates \pagetotal
|\message{After clearout, \pagetotal=\the\pagetotal,
| \pagegoal=\the\pagegoal. }%
\fb@adjheight
\setbox\@tempboxa\vbox\bgroup
#1% Modifications to \hsize (can use \width and \height)
\textwidth\hsize \columnwidth\hsize}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endMakeFramed}
% \begin{macrocode}
\def\endMakeFramed{\par
\kern\z@
\hrule\@width\hsize\@height\z@
\penalty-100 % put depth into height
\egroup
% {\showoutput\showbox\@tempboxa}%
\begingroup
\fb@put@frame\FrameCommand\FirstFrameCommand
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fb@put@frame}
% \cs{fb@put@frame}\marg{nosplit}\marg{split}
% takes the contents of \cs{@tempboxa} and puts all,
% or a piece,
% of it on the page with a frame (\cs{FrameCommand}, \cs{FirstFrameCommand},
% \cs{MidFrameCommand}, or \cs{LastFrameCommand}). It recurses until all of
% \cs{@tempboxa} has been used up. (\cs{@tempboxa} must have zero depth.) \\
% \meta{nosplit} = attempted framing command, if no split \\
% \meta{split} = framing command if split.
%
% First iteration: Try to fit with \cs{FrameCommand}. If it does not fit,
% split for \cs{FirstFrameCommand}.
%
% Later iteration: Try to fit with \cs{LastFrameCommand}. If it does not
% fit, split for \cs{MidFrameCommand}.
% \begin{macrocode}
\def\fb@put@frame#1#2{\relax
\ifdim\pagegoal=\maxdimen \pagegoal\vsize \fi
\ifinner
\fb@putboxa#1%
\fb@afterframe
\else
\dimen@\pagegoal \advance\dimen@-\pagetotal % natural space left on page
\ifdim\dimen@<2\baselineskip % Too little room on page
| \message{Page has only \the\dimen@\space room left; eject. }%
\eject \fb@adjheight \fb@put@frame#1#2%
\else % there's appreciable room left on the page
\fb@sizeofframe#1%
| \message{\string\pagetotal=\the\pagetotal,
| \string\pagegoal=\the\pagegoal,
| \string\pagestretch=\the\pagestretch,
| \string\pageshrink=\the\pageshrink,
| \string\fb@frh=\fb@frh. \space}
| \message{Box of size \the\ht\@tempboxa\space + \fb@frh}%
\begingroup % temporarily set \dimen@ to be...
\advance\dimen@.8\pageshrink % maximum space available on page
\advance\dimen@-\fb@frh\relax % space available for frame's contents
\expandafter\endgroup
% \end{macrocode}
% expand \cs{ifdim}, then restore \cs{dimen@} to real room left on page
% \begin{macrocode}
\ifdim\dimen@>\ht\@tempboxa % whole box does fit
| \message{fits in \the\dimen@. }%
% \end{macrocode}
% Use vsplit anyway to capture the marks \\
% !!!???!!! MERGE THIS WITH THE else CLAUSE!!!
% \begin{macrocode}
\fb@putboxa#1%
\fb@afterframe
\else % box must be split
| \message{must be split to fit in \the\dimen@. }%
% \end{macrocode}
% update frame measurement to use \cs{FirstFrameCommand}
% or \cs{MidFrameCommand}
% \begin{macrocode}
\fb@sizeofframe#2%
\setbox\@tempboxa\vbox{% simulate frame and flexiblity of the page:
\vskip \fb@frh \@plus\pagestretch \@minus.8\pageshrink
\kern137sp\kern-137sp\penalty-30
\unvbox\@tempboxa}%
\edef\fb@resto@set{\boxmaxdepth\the\boxmaxdepth
\splittopskip\the\splittopskip}%
\boxmaxdepth\z@ \splittopskip\z@
| \message{Padded box of size \the\ht\@tempboxa\space split
| to \the\dimen@}%
% \end{macrocode}
% Split box here
% \begin{macrocode}
\setbox\tw@\vsplit\@tempboxa to\dimen@
| \toks99\expandafter{\splitfirstmark}%
| \toks98\expandafter{\splitbotmark}%
| \message{Marks are: \the\toks99, \the\toks98. }%
\setbox\tw@\vbox{\unvbox\tw@}% natural-sized
| \message{Natural height of split box is \the\ht\tw@, leaving
| \the\ht\@tempboxa\space remainder. }%
% \end{macrocode}
% If the split-to size $>$ (\cs{vsize}-\cs{topskip}), then set box to full size
% \begin{macrocode}
\begingroup
\advance\dimen@\topskip
\expandafter\endgroup
\ifdim\dimen@>\pagegoal
| \message{Frame is big -- Use up the full column. }%
\dimen@ii\pagegoal
\advance\dimen@ii -\topskip
\advance\dimen@ii \FrameHeightAdjust\relax
\else % suspect this is wrong:
% \end{macrocode}
% If the split-to size $>$ feasible room-on-page, rebox it smaller.
% \begin{macrocode}
\advance\dimen@.8\pageshrink
\ifdim\ht\tw@>\dimen@
| \message{Box too tall; rebox it to \the\dimen@. }%
\dimen@ii\dimen@
\else % use natural size
\dimen@ii\ht\tw@
\fi
\fi
% \end{macrocode}
% Re-box contents to desired size \cs{dimen@ii}
% \begin{macrocode}
\advance\dimen@ii -\fb@frh
\setbox\tw@\vbox to\dimen@ii \bgroup
% \end{macrocode}
% remove simulated frame and page flexibility:
% \begin{macrocode}
\vskip -\fb@frh \@plus-\pagestretch \@minus-.8\pageshrink
\unvbox\tw@ \unpenalty\unpenalty
\ifdim\lastkern=-137sp % whole box went to next page
| \message{box split at beginning! }%
% need work here???
\egroup \fb@resto@set \eject % (\vskip for frame size was discarded)
\fb@adjheight
\fb@put@frame#1#2% INSERTED ???
\else % Got material split off at the head
\egroup \fb@resto@set
\ifvoid\@tempboxa % it all fit after all
| \message{box split at end! }%
\setbox\@tempboxa\box\tw@
\fb@putboxa#1%
\fb@afterframe
\else % it really did split
| \message{box split as expected. Its reboxed height
| is \the\ht\tw@. }%
\ifdim\wd\tw@>\z@
\wd\tw@\wd\@tempboxa
% \end{macrocode}
% PW: the next line was: \\
% \verb!\centerline{#2{\box\tw@}}% ??? \centerline bad idea?! \\
% but I have changed it as follows so that \cs{centerline} can be changed
% from elsewhere if useful.
% \begin{macrocode}
\memfblineboxtwo{#2{\box\tw@}}% ??? \centerline bad idea? \\
\else
| \message{Zero width means likely blank.
| Don't frame it (guess)}%
\box\tw@
\fi
\hrule \@height\z@ \@width\hsize
\eject
\fb@adjheight
\fb@put@frame\LastFrameCommand\MidFrameCommand
\fi\fi\fi\fi\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\memfblineboxtwo}
% \begin{macro}{\memfblineboxa}
% PW: this is an addition of mine. There is a question mark against the
% use of \cs{centerline} within the \Lenv{framed} code. I have
% created these two macros which are used in the code instead of
% \cs{centerline}, so that those parts of the code can be easily altered.
% are used instead
% \begin{macrocode}
\newcommand{\memfblineboxtwo}[1]{\centerline{#1}}
\newcommand{\memfblineboxa}[1]{\centerline{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fb@putboxa}
% \begin{macrocode}
\def\fb@putboxa#1{%
\ifvoid\@tempboxa
%%%% PackageWarning{framed}{Boxa is void -- discard it. }%
\@memwarn{Boxa is void -- discard it. }%
\else
| \message{Frame and place boxa. }%
| %{\showoutput\showbox\@tempboxa}%
%%%%%%% \centerline{#1{\box\@tempboxa}}%
\memfblineboxa{#1{\box\@tempboxa}}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fb@afterframe}
% \begin{macrocode}
\def\fb@afterframe{%
\nointerlineskip \null %{\showoutput \showlists}
\penalty-30 \vskip\topsep \relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fb@frw}
% \begin{macro}{\fb@frh}
% \begin{macro}{\fb@sizeofframe}
% \cs{fb@sizeofframe}\marg{framecommand} measures width and height added by
% frame (\meta{framecommand}) and call the results \cs{fb@frw} and \cs{fb@frh}.
% \begin{macrocode}
\newdimen\fb@frw
\newdimen\fb@frh
\def\fb@sizeofframe#1{\begingroup
\setbox\z@\vbox{\vskip-5in \hbox{\hskip-5in
#1{\hbox{\vrule \@height 4.7in \@depth.3in \@width 5in}}}%
\vskip\z@skip}%
| \message{Measuring frame addition for \string#1 in \@currenvir\space
| gives ht \the\ht\z@\space and wd \the\wd\z@. }%
%{\showoutput\showbox\z@}%
\global\fb@frw\wd\z@ \global\fb@frh\ht\z@
\endgroup}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fb@adjheight}
% \begin{macrocode}
\def\fb@adjheight{%
\vbox to\FrameHeightAdjust{}% get proper baseline skip from above.
\penalty\@M \nointerlineskip
\vskip-\FrameHeightAdjust
\penalty\@M} % useful for tops of pages
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zero@glue}
% \begin{macrocode}
\edef\zero@glue{\the\z@skip}
\catcode`\|=\FrameRestore
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FrameCommand}
% \begin{macro}{\FrameRule}
% \begin{macro}{\FrameSep}
% \begin{macro}{\FirstFrameCommand}
% \begin{macro}{\MidFrameCommand}
% \begin{macro}{\LastFrameCommand}
% Provide configuration commands:
% \begin{macrocode}
\providecommand\FrameCommand{%
\setlength\fboxrule{\FrameRule}\setlength\fboxsep{\FrameSep}%
\fbox}
\@ifundefined{FrameRule}{\newdimen\FrameRule \FrameRule=\fboxrule}{}
\@ifundefined{FrameSep} {\newdimen\FrameSep \FrameSep =3\fboxsep}{}
\providecommand\FirstFrameCommand{\FrameCommand}
\providecommand\MidFrameCommand{\FrameCommand}
\providecommand\LastFrameCommand{\FrameCommand}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\FrameHeightAdjust}
% Height of frame above first baseline when frame starts a page:
% \begin{macrocode}
\providecommand\FrameHeightAdjust{6pt}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FrameRestore}
% \cs{FrameRestore} has parts of \cs{@parboxrestore}, performing a similar but
% less complete restoration of a default layout. See how it is used in the
% "settings" argument of \cs{MakeFrame}. Though not a parameter, \cs{hsize}
% should be set to the desired total line width available inside the
% frame before invoking \cs{FrameRestore}.
% \begin{macrocode}
\def\FrameRestore{%
\let\if@nobreak\iffalse
\let\if@noskipsec\iffalse
\let\-\@dischyph
\let\'\@acci\let\`\@accii\let\=\@acciii
% \message{FrameRestore:
% \@totalleftmargin=\the \@totalleftmargin,
% \rightmargin=\the\rightmargin,
% \@listdepth=\the\@listdepth. }%
% \end{macrocode}
% Test if we are in a list (or list-like paragraph)
% \begin{macrocode}
\ifnum \ifdim\@totalleftmargin>\z@ 1\fi
\ifdim\rightmargin>\z@ 1\fi
\ifnum\@listdepth>0 1\fi 0>\z@
% \message{In a list: \linewidth=\the\linewidth,
% \@totalleftmargin=\the\@totalleftmargin,
% \parshape=\the\parshape, \columnwidth=\the\columnwidth,
% \hsize=\the\hsize,
% \labelwidth=\the\labelwidth. }%
% \end{macrocode}
% Now try to propagate changes of width from \cs{hsize} to list parameters.
% This is deficient, but a more advanced way to indicate modification to text
% dimensions is not (yet) provided; in particular, no separate left/right
% adjustment. (PW. I have provided a macro for the next few lines as I think
% that I may have a reason to allow them to be easily changed).
% \begin{macrocode}
%%% \@setminipage % snug fit around the item
%%% \advance\linewidth-\columnwidth \advance\linewidth\hsize
%%% \parshape\@ne \@totalleftmargin \linewidth
\memfblistfixparams
\else % Not in list
\linewidth=\hsize
%\message{No list, set \string\linewidth=\the\hsize. }%
\fi
\sloppy}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\memfblistfixparams}
% An extract of some code from \cs{FrameRestore}.
% Try to propagate changes of width from \cs{hsize} to list parameters.
% This is deficient, but a more advanced way to indicate modification to text
% dimensions is not (yet) provided; in particular, no separate left/right
% adjustment.
% \begin{macrocode}
\newcommand*{\memfblistfixparams}{%
\@setminipage % snug fit around the item
\advance\linewidth-\columnwidth \advance\linewidth\hsize
\parshape\@ne \@totalleftmargin \linewidth}
% \end{macrocode}
% \end{macro}
%
% I have moved the following from the start of the \Lpack{framed}
% package to here.
%
% \begin{environment}{framed}
% \begin{environment}{shaded}
% \begin{environment}{leftbar}
% \begin{environment}{snugshade}
% \begin{macrocode}
\newenvironment{framed}% using default \FrameCommand
{\MakeFramed {\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
\newenvironment{shaded}{%
\def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}%
\MakeFramed {\FrameRestore}}%
{\endMakeFramed}
\newenvironment{leftbar}{%
\def\FrameCommand{\vrule width 3pt \hspace{10pt}}%
\MakeFramed {\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
\newenvironment{snugshade}{%
\def\FrameCommand{\colorbox{shadecolor}}%
\MakeFramed {\FrameRestore\@setminipage}}%
{\par\unskip\endMakeFramed}
% \end{macrocode}
% \end{environment}
% \end{environment}
% \end{environment}
% \end{environment}
%
% As the package used \cs{newenvironment} it will
% burp if it is used with the class. There are two options: either
% prevent \Lpack{framed} from being loaded, or kill the environments
% if it is loaded. I'm going for the latter as Donald will be updating
% his package at some point and author's may want to use it before it's
% updated here.
%
% \begin{macrocode}
\AtBeginPackage{framed}{%
\let\framed\relax \let\endframed\relax
\let\shaded\relax \let\endshaded\relax
\let\leftbar\relax \let\endleftbar\relax
\let\snugshade\relax \let\endsnugshade\relax}
% \end{macrocode}
%
%
% \begin{environment}{qframe}
% This is from an email to me from DA shortly after he released \Lpack{framed}
% v 0.95.
% \begin{quote}
% A frame more like a simple parbox.
% Notably useful for use
% inside a single list item --- the frame matches the text of the other
% items.
% \end{quote}
% He actually called it \Lenv{pframe} and said that something similar
% could be in a later version of \Lpack{framed}.
%
% I have found it useful for framing \Lenv{quote} or \Lenv{adjustwidth}
% environments, or similar. Hence the name, from
% `\textit{q}uote \textit{frame}'.
% \changes{v1.61803}{2008/01/30}{Added the qframe environment}
% \begin{macrocode}
\newenvironment{qframe}{%
\def\FrameCommand##1{\fboxrule=\FrameRule\fboxsep=\FrameSep
\hskip\@totalleftmargin\fbox{##1}% There is no \@totalrightmargin, so...
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
\MakeFramed{\advance\hsize-\width
\advance\hsize \FrameSep
\@totalleftmargin\z@ \linewidth=\hsize}}%
{\endMakeFramed}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{qshade}
% And here is my corresponding version for \Lenv{shaded}.
% \changes{v1.61803}{2008/01/30}{Added the qshade environment}
% \begin{macrocode}
\newenvironment{qshade}{%
\def\FrameCommand##1{\fboxsep=\FrameSep
\hskip\@totalleftmargin
\hskip -1\FrameSep
\colorbox{shadecolor}{##1}%
\hskip-\linewidth \hskip-\@totalleftmargin
\hskip -1\FrameSep
\hskip\columnwidth}%
\MakeFramed{\advance\hsize-\width
\advance\hsize 3\FrameSep
\@totalleftmargin\z@ \linewidth=\hsize}}%
{\endMakeFramed}
% \end{macrocode}
% \end{environment}
%
%
% \subsection{The newfile package}
%
% The following code is from the \Lpack{newfile} package.
% To try and avoid name clashes with other packages, each internal macro
% in this package includes the character string `\verb?stre@m?'.
%
% \begin{macro}{\newoutputstream}
% \cs{newoutputstream}\marg{stream} creates a new output stream called \meta{stream}.
% Different files may be associated with the \meta{stream}. Note that
% TeX permits no more than 16 output streams.
% \begin{macrocode}
\newcommand*{\newoutputstream}[1]{%
\@ifundefined{#1outstre@m}%
{\expandafter\newwrite\csname #1outstre@m\endcsname
\csname newif\expandafter\endcsname
\csname ifstre@m#1open\endcsname
\global\csname stre@m#1openfalse\endcsname
\expandafter\ifx\csname atstreamopen#1\endcsname\relax
\global\@namedef{atstreamopen#1}{}%
\fi
\expandafter\ifx\csname atstreamclose#1\endcsname\relax
\global\@namedef{atstreamclose#1}{}%
\fi
}%
{\@memwarn{Output stream #1\space is already defined}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newinputstream}
% \cs{newinputstream}\marg{stream} creates a new input stream called \meta{stream}.
% Different files may be associated with the \meta{stream}. Note that
% TeX permits no more than 16 input streams.
% \begin{macrocode}
\newcommand*{\newinputstream}[1]{%
\@ifundefined{#1instre@m}%
{\expandafter\newread\csname #1instre@m\endcsname
\csname newif\expandafter\endcsname
\csname ifstre@m#1open\endcsname
\global\csname stre@m#1openfalse\endcsname
\expandafter\ifx\csname atstreamopen#1\endcsname\relax
\global\@namedef{atstreamopen#1}{}%
\fi
\expandafter\ifx\csname atstreamclose#1\endcsname\relax
\global\@namedef{atstreamclose#1}{}%
\fi
}%
{\@memwarn{Input stream #1\space is already defined}}}
% \end{macrocode}
% \end{macro}
%
% Some checking macros will be useful as some of the checks occur in
% multiple places.
%
% \begin{macro}{\IfStreamOpen}
% \cs{IfStreamOpen}\marg{stream}\marg{TRUE code}\marg{FALSE code}
% checks if stream \meta{stream} is currently open.
% \begin{macrocode}
\newcommand{\IfStreamOpen}[3]{%
\csname ifstre@m#1open\endcsname#2\else#3\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\instre@mandopen}
% \cs{instre@mandopen}\marg{stream}\marg{TRUE code} checks if \meta{stream}
% is an input stream and is open. If so, it executes \meta{TRUE code}.
% \begin{macrocode}
\newcommand{\instre@mandopen}[2]{%
\@ifundefined{#1instre@m}{%
\@memwarn{#1\space is not an input stream}}%
{\IfStreamOpen{#1}{#2}{%
\@memwarn{Input stream #1\space is not open}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\instre@mandclosed}
% \cs{instre@mandclosed}\marg{stream}\marg{TRUE code} checks if \meta{stream}
% is an input stream and is closed (not open).
% If so, it executes \meta{TRUE code}.
% \begin{macrocode}
\newcommand{\instre@mandclosed}[2]{%
\@ifundefined{#1instre@m}{%
\@memwarn{#1\space is not an input stream}}%
{\IfStreamOpen{#1}{%
\@memwarn{Input stream #1\space is open}}{#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\outstre@mandopen}
% \cs{outstre@mandopen}\marg{stream}\marg{TRUE code} checks if \meta{stream}
% is an output stream and is open. If so, it executes \meta{TRUE code}.
% \begin{macrocode}
\newcommand{\outstre@mandopen}[2]{%
\@ifundefined{#1outstre@m}{%
\@memwarn{#1\space is not an output stream}}%
{\IfStreamOpen{#1}{#2}{%
\@memwarn{Output stream #1\space is not open}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\outstre@mandclosed}
% \cs{outstre@mandclosed}\marg{stream}\marg{TRUE code} checks if \meta{stream}
% is an output stream and is closed (not open).
% If so, it executes \meta{TRUE code}.
% \begin{macrocode}
\newcommand{\outstre@mandclosed}[2]{%
\@ifundefined{#1outstre@m}{%
\@memwarn{#1\space is not an output stream}}%
{\IfStreamOpen{#1}{%
\@memwarn{Output stream #1\space is open}}{#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\openoutputfile}
% \cs{openoutputfile}\marg{filename}\marg{stream} opens the file called
% \meta{filename} and attaches it to the stream \meta{stream} for
% writing. However, if the \cs{nofiles} command has been given the
% file is \emph{not} attached to the stream. No more than one file can be
% attached to a stream at any given time.
% \begin{macrocode}
\newcommand*{\openoutputfile}[2]{%
\outstre@mandclosed{#2}{%
\global\@namedef{#1@filename}{#1}%
\if@filesw
\immediate\openout\@nameuse{#2outstre@m}=\@nameuse{#1@filename}%
\fi
\global\csname stre@m#2opentrue\endcsname%
\@nameuse{atstreamopen#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\closeoutputstream}
% \cs{closeoutputstream}\marg{stream} closes the stream \meta{stream}.
% \begin{macrocode}
\newcommand*{\closeoutputstream}[1]{%
\outstre@mandopen{#1}{%
\@nameuse{atstreamclose#1}%
\immediate\closeout\@nameuse{#1outstre@m}%
\global\csname stre@m#1openfalse\endcsname}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\openinputfile}
% \cs{openinputfile}\marg{filename}\marg{stream} opens the file called
% \meta{filename} and attaches it to the stream \meta{stream} for
% reading. The file is added to the list of files.
% No more than one file can be attached to a stream at
% any given time.
% \begin{macrocode}
\newcommand{\openinputfile}[2]{%
\IfFileExists{#1}{% file exists
\instre@mandclosed{#2}{%
\@addtofilelist{#1}%
\global\@namedef{#1@filename}{#1}%
\immediate\openin\@nameuse{#2instre@m}=\@nameuse{#1@filename}%
\global\csname stre@m#2opentrue\endcsname%
\@nameuse{atstreamopen#2}}}%
{% file not found
\typeout{No file #1.}
}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\closeinputstream}
% \cs{closeinputstream}\marg{stream} closes the stream \meta{stream}.
% \begin{macrocode}
\newcommand{\closeinputstream}[1]{%
\instre@mandopen{#1}{%
\@nameuse{atstreamclose#1}%
\immediate\closein\@nameuse{#1instre@m}%
\global\csname stre@m#1openfalse\endcsname}}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{writeverbatim}
% \verb?\begin{writeverbatim}?\marg{stream} writes the contents of
% the environment as verbatim text to the given \meta{stream}.
% \begin{macrocode}
\def\writeverbatim#1{%
\@bsphack
\let\do\@makeother\dospecials
\catcode`\^^M\active
\def\verbatim@processline{%
\immediate\write\@nameuse{#1outstre@m}{\the\verbatim@line}}%
\verbatim@start}
\def\endwriteverbatim{\@esphack}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\addtostream}
% \cs{addtostream}\marg{stream}\marg{text} writes \meta{text} to the
% given \meta{stream}.
% \begin{macrocode}
\newcommand{\addtostream}[2]{%
\@bsphack
\outstre@mandopen{#1}{%
{\let\protect\string
\immediate\write\@nameuse{#1outstre@m}{#2}%
}}%
\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifstre@mnoteof}
% \begin{macro}{\checkstre@mnoteof}
% \cs{checkstre@mnoteof}\marg{stream} sets \cs{ifstre@mnoteof} to TRUE if
% \meta{stream} is not at the end of the file (i.e., it is the opposite
% of \cs{ifeof}).
% \begin{macrocode}
\newif\ifstre@mnoteof
\newcommand{\checkstre@meof}[1]{%
\stre@mnoteoftrue\ifeof\@nameuse{#1instre@m}\stre@mnoteoffalse\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\readstream}
% \cs{readstream}\marg{stream} reads the contents of
% the given \meta{stream} as \cs{input} text.
% \begin{macrocode}
\def\readstream#1{
\instre@mandopen{#1}{%
\loop \checkstre@meof{#1} \ifstre@mnoteof
\read\@nameuse{#1instre@m} to\temptokstre@m
\temptokstre@m
\repeat
}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\readaline}
% \cs{readaline}\marg{stream} reads what TeX considers to be one line
% from the given \meta{stream} as \cs{input} text.
% \begin{macrocode}
\def\readaline#1{
\instre@mandopen{#1}{%
\ifeof\@nameuse{#1instre@m}
\@memwarn{No more to read from stream #1}
\else
\read\@nameuse{#1instre@m} to\temptokstre@m
\temptokstre@m
\fi}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\readverbatim}
% \cs{readverbatim}\marg{stream} reads the contents of
% the given \meta{stream} as verbatim text.
%
% The read verbatim code is a slight variation on code from the
% \Lpack{verbatim} package. Most of the setup is done by the macros
% \cs{stre@mverb@input}\marg{setup}\marg{stream} and
% \cs{verbatim@readstre@m}\marg{stream}. Finally, \cs{verbatim@read@file}
% is a \Lpack{verbatim} package macro.
% \begin{macrocode}
\def\readverbatim{\begingroup
\ift@bs
\def\verbatim@processline{\tabverbatim@processline}%
\fi
\@ifstar{\stre@mverb@input{\@maybeobeytabs}}%
{\stre@mverb@input{\frenchspacing\@vobeyspaces\@maybeobeytabs}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\stre@mverb@input}
% \begin{macro}{\@verbinstre@m}
% \cs{stre@mverb@input}\marg{setup}\marg{stream} is a stream
% version of \cs{verbatim@input}. It defines \cs{@verbinstre@m}
% to be \meta{stream}.
%
% \begin{macrocode}
\newcommand{\stre@mverb@input}[2]{%
\IfStreamOpen{#2}%
{\@verbatim #1\relax
\def\@verbinstre@m{\@nameuse{#2instre@m}}
\verb@readstre@m\endtrivlist\endgroup\@doendpe}%
{\@memwarn{Stream #2\space is not open}\endgroup}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\verb@readstre@m}
% \cs{verb@readstre@m} is the stream analogue to \cs{verbatim@readfile}.
% \begin{macrocode}
\newcommand{\verb@readstre@m}{%
\verbatim@startline
\expandafter\endlinechar\expandafter\m@ne
\expandafter\verbatim@read@stre@m
\expandafter\endlinechar\the\endlinechar\relax
\verbatim@finish}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\verbatim@read@stre@m}
% \cs{verbatim@read@stre@m} is the analogue to \cs{verbatim@readfile}.
% It gets its input from the stream \cs{@verbinstre@m}, which is defined
% in the \cs{stre@mverb@input} macro.
% \begin{macrocode}
\newcommand{\verbatim@read@stre@m}{%
\read\@verbinstre@m to\next
\ifeof\@verbinstre@m
\else
\expandafter\verbatim@addtoline\expandafter{\next}%
\verbatim@processline
\verbatim@startline
\expandafter\verbatim@read@stre@m
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\readboxedverbatim}
% \cs{readboxedverbatim}\marg{stream} is the equivalent of
% \cs{readverbtim} except that it generates a boxed verbatim.
% \begin{macrocode}
\newcommand{\readboxedverbatim}{\begingroup
\@ifstar{\stre@mbvin\relax}%
{\stre@mbvin{\frenchspacing\@vobeyspaces}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\stre@mbvin}
% \cs{stre@mbvin}\marg{setup}\marg{stream} is the workhorse for
% \cs{readboxedverbatim}, and in its turn it uses \cs{verb@readstre@m}.
% \begin{macrocode}
\newcommand{\stre@mbvin}[2]{%
\IfStreamOpen{#2}%
{\setupboxverb@line
\@verbatim #1\relax
\def\@verbinstre@m{\@nameuse{#2instre@m}}%
\setupbox@verb
\verb@readstre@m\bvendrulehook\endtrivlist\endgroup\@doendpe}%
{\@memwarn{Stream #2\space is not open}\endgroup}}
% \end{macrocode}
% \end{macro}
%
%
%
% \section{Utilities}
%
%
% \subsection{Extra `provide' commands}
%
% \begin{macro}{\provideenvironment}
% Works like \cs{providecommand} but for environments.
% \changes{v1.2}{2002/08/04}{Added \cs{provideenvironment} and supports}
% \begin{macrocode}
\newcommand{\provideenvironment}{\@star@or@long\m@mprovenv}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mprovenv}
% This checks if the environment has been defined. If not it calls
% the kernel code for \cs{newenvironment} otherwise it calls code to
% discard arguments.
% \begin{macrocode}
\newcommand{\m@mprovenv}[1]{\@ifundefined{#1}%
{\new@environment{#1}}% % create new environment
{\@memwarn{Environment `#1' already defined}%
\m@mgobbleoptsandtwo}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\m@mgobbleoptsandtwo}
% \begin{macro}{\m@mgobbleoptandtwo}
% \cs{m@mgobbleoptsandtwo} gobbles the \verb?[opt][opt]{begin}{end}? arguments to
% \cs{provideenvironment}. It is actually more general than that as it will
% gobble any sequence of any number of optional arguments followed by
% two required arguments. If there are no optional arguments it disposes
% of the two required ones, otherwise it calls a recursive procedure to
% discard any number of optionals, then two required ones.
%
% \cs{m@mgobbleoptandtwo} recursively discards optional arguments, then finally
% two required arguments.
% \begin{macrocode}
\newcommand{\m@mgobbleoptsandtwo}{%
\@ifnextchar [{\m@mgobbleoptandtwo}{\@gobbletwo}}
\def\m@mgobbleoptandtwo[#1]{%
\@ifnextchar [{\m@mgobbleoptandtwo}{\@gobbletwo}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\providecounter}
% Works like the other \cs{provide...} commands, but for counters.
% Code is based on \cs{newcounter} in \file{ltcounts.dtx}.
% \changes{v1.2}{2002/07/17}{Added \cs{providecounter}}
% \begin{macrocode}
\newcommand*{\providecounter}[1]{%
\@ifundefined{c@#1}%
{\newcounter{#1}}%
{\@memwarn{Counter `#1' already defined}%
\@ifnextchar[{\m@mgobbleopt}{}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mgobbleopt}
% Gobble an optional argument.
% \changes{v1.2}{2002/07/07}{Added \cs{m@mgobbleopt}}
% \begin{macrocode}
\def\m@mgobbleopt[#1]{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\providelength}
% Works like the other \cs{provide...} commands, but for lengths.
% Code is based on \cs{provide@command} in \file{ltdefns.dtx}.
% \changes{v1.2}{2002/07/17}{Added \cs{providelength}}
% \begin{macrocode}
\newcommand*{\providelength}[1]{%
\begingroup
\escapechar\m@ne\xdef\@gtempa{{\string#1}}%
\endgroup
\expandafter\@ifundefined\@gtempa
{\newlength{#1}}%
{\@memwarn{Length #1 already defined}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newloglike}
% \begin{macro}{\m@mnewlog}
% \begin{macro}{\m@mnewlogs}
% For defining a new log-like math function.
% \verb?\newloglike{\fun}{string}? or \verb?\newloglike*{\fun}{string}?.
% The starred version is for functions with limits (like an integral sign).
% \changes{v1.6}{2004/01/28}{Added \cs{newloglike}}
% \begin{macrocode}
\newcommand*{\newloglike}{\@ifstar{\m@mnewlogs}{\m@mnewlog}}
\newcommand*{\m@mnewlogs}[2]{%
\newcommand*{#1}{\mathop{\operator@font #2}}}
\newcommand*{\m@mnewlog}[2]{%
\newcommand*{#1}{\mathop{\operator@font #2}\nolimits}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\provideloglike}
% \begin{macro}{\m@mprovlogs}
% \begin{macro}{\m@mprovlog}
% The provide version of \cs{newloglike}.
% \changes{v1.6}{2004/01/28}{Added \cs{provideloglike}}
% \begin{macrocode}
\newcommand*{\provideloglike}{\@ifstar{\m@mprovlogs}{\m@mprovlog}}
\newcommand*{\m@mprovlogs}[2]{%
\providecommand*{#1}{\mathop{\operator@font #2}}}
\newcommand*{\m@mprovlog}[2]{%
\providecommand*{#1}{\mathop{\operator@font #2}\nolimits}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Changing counters}
%
% In LaTeX, a new counter called, say `ctr', is created by the command
% \verb?\newcounter{ctr}[within]?. If the optional within argument is given
% the the counter `ctr' is reset to zero each time the counter `within'
% changes. The command \cs{thectr} typesets the value of the counter ctr.
% This is automatically defined by \cs{newcounter} and is initialised
% to typeset arabic numerals. Sometimes it may be desireable to change
% the counter definitions.
%
% The following code is based on the \Lpack{chngcntr} package~\cite{CHNGCNTR}.
%
% \begin{macro}{\@removefromreset}
% This code uses David Carlisle's \cs{@removefromreset} command as
% specified in the remreset package~\cite{REMRESET}.
% It is provided here as a convenience to the user, and with
% David Carlisle's permission.
%
% START OF DAVID CARLISLE'S CODE
% \begin{macrocode}
\providecommand{\@removefromreset}[2]{{%
\expandafter\let\csname c@#1\endcsname\@removefromreset
\def\@elt##1{%
\expandafter\ifx\csname c@##1\endcsname\@removefromreset
\else
\noexpand\@elt{##1}%
\fi}%
\expandafter\xdef\csname cl@#2\endcsname{%
\csname cl@#2\endcsname}}}
% \end{macrocode}
% END OF DAVID CARLISLE'S CODE
% \end{macro}
%
% \begin{macro}{\@ifbothcntrs}
% This is called as \\
% \cs{@ifbothcntrs}\marg{cntr}\marg{within}\marg{code when both are counters}.
% This tests if both \meta{cntr} and \meta{within} are counters.
% \begin{macrocode}
\newcommand{\@ifbothcntrs}[3]{%
\@ifundefined{c@#1}{% counter undefined
\@memerror{#1 is not a counter}{\@eha}}%
{% else counter is defined
\@ifundefined{c@#2}{% within undefined
\@memerror{#2 is not a counter}{\@eha}}%
{% else both counter and within are defined
#3}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\counterwithin}
% \begin{macro}{\counterwithin*}
% \begin{macro}{\@csinstar}
% \begin{macro}{\@csin}
% It is sometimes desireable to change a counter that has been defined
% by \verb?\newcounter{ctr}? to act as though it had been defined as
% \verb?\newcounter{ctr}[within]?. The command
% \verb?\counterwithin{ctr}{within}? accomplishes this. By default,
% it also redefines the \cs{thectr} command so that it typesets values
% in the style \verb?\thewithin.\arabic{ctr}?. The starred version of the
% command suppresses the redefinition of \cs{thectr}.
% \changes{v3.7g}{2018/03/09}{As of TeXLive 2018 \cs{counterwithin}
% and \cs{counterwithout} will be moved into the kernel. We therefore
% change to using \cs{providecommand} instead of \cs{newcommand} to
% avoid colisions}
% \begin{macrocode}
\providecommand{\counterwithin}{\@ifstar{\@csinstar}{\@csin}}
\providecommand{\@csinstar}[2]{%
\@ifbothcntrs{#1}{#2}{\@addtoreset{#1}{#2}}}
\providecommand{\@csin}[2]{%
\@ifbothcntrs{#1}{#2}{\@addtoreset{#1}{#2}%
\@namedef{the#1}{\@nameuse{the#2}.\arabic{#1}}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\counterwithout}
% \begin{macro}{\counterwithout*}
% \begin{macro}{\@csoutstar}
% \begin{macro}{\@csout}
% Likewise, the command \verb?\counterwithout{ctr}{within}? changes a
% counter that has been created by \verb?\newcounter{ctr}[within]? to act
% as though it had been created by \verb?\newcounter{ctr}?. By default it
% also redefines the \cs{thectr} command so that it just typesets an arabic
% numeral. The starred version of the command suppresses the redefinition
% of \cs{thectr}.
% \changes{v1.618}{2005/09/03}{Deleted chngctr from \cs{@csoutstar} (mempatch v3.4)}
% \changes{v3.7g}{2018/03/09}{As of TeXLive 2018 \cs{counterwithin}
% and \cs{counterwithout} will be moved into the kernel. We therefore
% change to using \cs{providecommand} instead of \cs{newcommand} to
% avoid colisions}
% \begin{macrocode}
\providecommand{\counterwithout}{\@ifstar{\@csoutstar}{\@csout}}
\providecommand{\@csoutstar}[2]{%
\@ifbothcntrs{#1}{#2}{\@removefromreset{#1}{#2}}}
\providecommand{\@csout}[2]{%
\@ifbothcntrs{#1}{#2}{\@removefromreset{#1}{#2}%
\@namedef{the#1}{\arabic{#1}}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Any number of \verb?\counterwithin{ctr}{...}? and \verb?\counterwithout{ctr}{...}?
% commands can be issued for a given counter, ctr, if you wish to toggle
% between the two styles. The current value of ctr is unaffected by
% \cs{counterwithin} and \cs{counterwithout}. If you want to change the value
% after one of these commands, use \verb?\setcounter{ctr}{...}?, and to change
% the typeseting style use \verb?\renewcommand{\thectr}{...}?.
%
%
% \begin{macro}{\letcountercounter}
% \begin{macro}{\c@m@morig@ctr}
% \begin{macro}{\unletcounter}
% At times it is handy to `let' one counter act as if it was a
% different counter. Say you have two constructions, each with their
% own counter A and B, now you want them to cooperate, counting in
% unison. This can be done using the \verb?\letcountercounter?.
%
% \medskip
%
% \cs{letcountercounter}\marg{counterA}\marg{counterB} \cs{let}s
% (make the same) \meta{counterA} to \meta{counterB}. The
% original of \meta{counterA} is kept in \cs{c@m@morig@ctr}\meta{counterA}.
%
% \cs{unletcounter}\marg{counterA} restores \meta{counterA} to its un\cs{let}
% condition.
%
% The code is based on Donald Arseneau's `Re: \cs{let}, \cs{csname} and
% \cs{endcsname}', CTT, 2004/12/08. The long version, where \cs{xp}
% is actually \cs{expandafter} is along the lines of:
% \begin{verbatim}
% \xp\xp\xp\let\xp\csname\xp c@#1\xp\endcsname\csname c@#2\endcsname
% \end{verbatim}
% which employs 6 \cs{expandafter}s. DA's version uses only 2. The technique
% can be applied to other kinds of \cs{let}s.
%
% \begin{macrocode}
\newcommand*{\letcountercounter}[2]{%
\expandafter\let\csname c@m@morig@ctr#1\expandafter\endcsname%
\csname c@#1\endcsname
\expandafter\let\csname c@#1\expandafter\endcsname%
\csname c@#2\endcsname}
\newcommand*{\unletcounter}[1]{%
\expandafter\let\csname c@#1\expandafter\endcsname%
\csname c@m@morig@ctr#1\endcsname}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Odd/even page checking}
%
% It is difficult to check robustly if the current page is odd or even.
% This code, which is based on the \Lpack{chngpage} package~\cite{CHNGPAGE},
% provides a method that has proved (so far) to be robust.
% It works by writing out a label and on the next LaTeX run checks
% the page reference for the label.
%
% \begin{macro}{\ifoddpage}
% \begin{macro}{\oddpagetrue}
% \begin{macro}{\oddpagefalse}
% \begin{macro}{\ifstrictpagecheck}
% \begin{macro}{\strictpagechecktrue}
% \begin{macro}{\strictpagecheckfalse}
% \begin{macro}{\strictpagecheck}
% \begin{macro}{\easypagecheck}
% The boolean \cs{ifoddpage} is TRUE if the checked page is odd. The
% boolean \cs{ifstrictpagecheck} is for turning on (TRUE) and off (FALSE)
% the strictest method of page checking.
% \changes{v1.61803}{2008/01/30}{Added \cs{strictpagecheck} and \cs{easypagecheck}}
% \begin{macrocode}
\newif\ifoddpage
\newif\ifstrictpagecheck
\strictpagecheckfalse
\newcommand*{\strictpagecheck}{\strictpagechecktrue}
\newcommand*{\easypagecheck}{\strictpagecheckfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@cp@cntr}
% \begin{macro}{\cplabel}
% The counter \verb?cp@cntr? is used to make unique labels, which start
% with \cs{cplabel}.
% \begin{macrocode}
\newcounter{cp@cntr}
\newcommand{\cplabel}{^_}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\checkoddpage}
% This is the user level command to check for odd/even page. It does
% a robust check for \cs{strictpagecheck} otherwise the simple minded
% check. It sets \cs{ifoddpage} to TRUE if the page is odd, otherwise
% it sets it to FALSE.
%
% This is now fixed so that it should work for non-arabic page numbering.
% It uses a new label/pageref variant based on the page counter value, not
% its printed representation. This also gets rid of worrying about hyperref!!
% The problem was discovered by Bastiaan Niels Veelo
%
% \changes{v1.4}{2003/11/22}{Complete rewrite of odd page checking
% (from patch v1.6)}
% \begin{macrocode}
\DeclareRobustCommand{\checkoddpage}{%
\oddpagefalse%
\ifstrictpagecheck%
\stepcounter{cp@cntr}\pmemlabel{\cplabel\thecp@cntr}%
\@memcnta=\pmemlabelref{\cplabel\thecp@cntr}\relax
\ifodd\@memcnta\oddpagetrue\fi
\else
\ifodd\c@page\oddpagetrue\fi
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\thepmemc@@page}
% The value of the page counter.
% \begin{macrocode}
\gdef\thepmemc@@page{\the\c@page}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pmemprotected@write}
% \cs{pmemprotected@write} is a modified version of the kernel's
% \cs{protected@write}.
%
% This version of the macro was provided by Romano Giannetti
% (\url{romano@dea.icai.upco.es}) on 15 July 2003.
% \begin{macrocode}
\long\def\pmemprotected@write#1#2#3{%
\begingroup
\let\thepmemc@@page\relax
#2%
\let\protect\@unexpandable@protect
\edef\reserved@a{\write#1{#3}}%
\reserved@a
\endgroup
\if@nobreak\ifvmode\nobreak\fi\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pmemlabel}
% A version of \cs{label} that uses \cs{pmemprotected@write}.
% \begin{macrocode}
\newcommand{\pmemlabel}[1]{\@bsphack
\pmemprotected@write\@auxout{}%
{\string\newpmemlabel{#1}{\thepmemc@@page}}%
\@esphack}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newpmemlabel}
% \begin{macro}{\pmemlabelref}
% We have to be able to cope with a particular label
% not (yet) being in the the \file{.aux} file when we come to check
% the page number.
% \begin{macrocode}
\newcommand{\newpmemlabel}[2]{{\global\@namedef{m@#1}{#2}}}
\newcommand{\pmemlabelref}[1]{%
\expandafter\ifx\csname m@#1\endcsname\relax
0%
\else
\csname m@#1\endcsname
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Checking for empty arguments}
%
% Like page checking, testing for an empty macro argument is more
% difficult than it might appear at first sight.
%
% The following code is from the \Lpack{ifmtarg} package~\cite{IFMTARG}.
%
% \begin{macro}{\@ifmtarg}
% \begin{macro}{\@ifnotmtarg}
% \cs{@ifmtarg}\marg{arg}\marg{code when empty}\marg{code when arg not empty} \\
% \cs{@ifnotmtarg}\marg{arg}\marg{code when arg not empty} \\
% \begin{macrocode}
\begingroup
\catcode`\Q=3
\long\gdef\@ifmtarg#1{\@xifmtarg#1QQ\@secondoftwo\@firstoftwo\@nil}
\long\gdef\@xifmtarg#1#2Q#3#4#5\@nil{#4}
\long\gdef\@ifnotmtarg#1{\@xifmtarg#1QQ\@firstofone\@gobble\@nil}
\endgroup
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Some example uses:
% \begin{verbatim}
% \newcommand{\isempty}[1]{%
% \@ifmtarg{#1}{\typeout{YES}}{\typeout{NO}}}
% \newcommand{\isnotempty}[1]{%
% \@ifnotmtarg{#1}{\typeout{YES}}}
%
% \isempty{} -> YES \isnotempty{} ->
% \isempty{ } -> YES \isnotempty{ } ->
% \isempty{A} -> NO \isnotempty{A} -> YES
% \isempty{ A } -> NO \isnotempty{ A } -> YES
% \end{verbatim}
%
%
% \subsection{Changing the page layout in the document}
%
% You should not do this, but\ldots
%
% The following code is essentially from the \Lpack{chngpage}
% package~\cite{CHNGPAGE}.
%
% \begin{macro}{\ch@ngetext}
% This macro sets the page output parameters.
% \begin{macrocode}
\DeclareRobustCommand{\ch@ngetext}{%
\setlength{\@colht}{\textheight}\setlength{\@colroom}{\textheight}%
\setlength{\vsize}{\textheight}\setlength{\columnwidth}{\textwidth}%
\if@twocolumn%
\advance\columnwidth-\columnsep \divide\columnwidth\tw@%
\@firstcolumntrue%
\fi%
\setlength{\hsize}{\columnwidth}%
\setlength{\linewidth}{\hsize}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\changetext}
% \cs{changetext}\marg{H}\marg{W}\marg{E}\marg{O}\marg{G}
% adds the given lengths to 5 main bits of the page layout. An empty
% argument means `no change'.
% \begin{macrocode}
\DeclareRobustCommand{\changetext}[5]{%
\@ifmtarg{#1}{}{\addtolength{\textheight}{#1}}%
\@ifmtarg{#2}{}{\addtolength{\textwidth}{#2}}%
\@ifmtarg{#3}{}{\addtolength{\evensidemargin}{#3}}%
\@ifmtarg{#4}{}{\addtolength{\oddsidemargin}{#4}}%
\@ifmtarg{#5}{}{\addtolength{\columnsep}{#5}}%
\ch@ngetext}
% \end{macrocode}
% \end{macro}
%
% Any given change lasts until another \cs{changetext} command is given.
% A \cs{changetext} command should only be issued between two paragraphs.
%
% \cs{changetext} should not be used by anyone unless they really
% know what they are doing. If you really know what you are doing
% then you should know enough not to use it.
%
% \begin{macro}{\changepage}
% Change the page layout, but DON'T.
% \changes{v1.61803}{2008/01/30}{Added \cs{changepage} to match chngpage.sty}
% \begin{macrocode}
\DeclareRobustCommand{\changepage}[9]{%
\@ifmtarg{#1}{}{\addtolength{\textheight}{#1}}%
\@ifmtarg{#2}{}{\addtolength{\textwidth}{#2}}%
\@ifmtarg{#3}{}{\addtolength{\evensidemargin}{#3}}%
\@ifmtarg{#4}{}{\addtolength{\oddsidemargin}{#4}}%
\@ifmtarg{#5}{}{\addtolength{\columnsep}{#5}}%
\ch@ngetext
\@ifmtarg{#6}{}{\addtolength{\topmargin}{#6}}%
\@ifmtarg{#7}{}{\addtolength{\headheight}{#7}}%
\@ifmtarg{#8}{}{\addtolength{\headsep}{#8}}%
\@ifmtarg{#9}{}{\addtolength{\footskip}{#9}}}
% \end{macrocode}
% \end{macro}
%
% \subsection{Temporarily changing the text width}
%
%
% \begin{environment}{adjustwidth}
% \begin{environment}{adjustwidth*}
% \verb?\begin{adjustwidth}?\marg{left}\marg{right}
% adds the given lengths to the left and right hand margins. A positive
% value will shorten the text and a negative value will widen it. The
% starred version of the environment will cause the
% margin changes to switch between odd and even pages.
%
% This code is based on the \Lpack{chngpage} package.
% \changes{v0.2}{2001/06/03}{Replaced optional arg of adjustwidth by adjustwidth*}
% \begin{macrocode}
\newenvironment{adjustwidth}[2]{%
\begin{list}{}{%
\topsep\z@%
\listparindent\parindent%
\parsep\parskip%
\@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}%
{\setlength{\leftmargin}{#1}}%
\@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}%
{\setlength{\rightmargin}{#2}}%
}
\item[]}{\end{list}}
% \end{macrocode}
%
% \begin{macrocode}
\newenvironment{adjustwidth*}[2]{%
\begin{list}{}{%
\topsep\z@%
\listparindent\parindent%
\parsep\parskip%
\checkoddpage
\ifoddpage % odd numbered page
\@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}%
{\setlength{\leftmargin}{#1}}%
\@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}%
{\setlength{\rightmargin}{#2}}%
\else % even numbered page
\@ifmtarg{#2}{\setlength{\leftmargin}{\z@}}%
{\setlength{\leftmargin}{#2}}%
\@ifmtarg{#1}{\setlength{\rightmargin}{\z@}}%
{\setlength{\rightmargin}{#1}}%
\fi
}
\item[]}{\end{list}}
% \end{macrocode}
% \end{environment}
% \end{environment}
%
% The environments only work for complete paragraphs.
%
% \subsection{Centering text}
%
% \begin{macro}{\calccentering}
% This macro calculates the amount to be added to the spine margin
% (and subtracted from the foredge margin)
% in order to center the textblock. Call as \\
% \verb?\calccentering{\length}? and it sets \cs{length}
% to the required value. Then use as \\
% \verb?\begin{adjustwidth*}{\length}{-\length}...?
% \begin{macrocode}
\newcommand{\calccentering}[1]{
#1 = \paperwidth
\advance #1 by -\textwidth
\divide #1 by \tw@
\advance #1 by -\spinemargin}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{vplace}
% \verb?\begin{vplace}?\oarg{decimal number} centers its body vertically. The
% optional argument \meta{decimal number} increases ($>1.0$) or decreases
% ($<1.0$) the space above the body with respect to the space below.
% This is more robust than the method proposed in the manual.
% \changes{v1.61803}{2008/01/30}{Added vplace environment (mempatch v4.4)}
% \changes{v3.6g}{2010/08/27}{Both should be \cs{vspace*}}
% \begin{macrocode}
\newenvironment{vplace}[1][1]{%
\par\vspace*{\stretch{#1}}%
}{%
\vspace*{\stretch{1}}%
\par}
% \end{macrocode}
% \end{environment}
%
%
% \subsection{Moving from the current page}
%
% Much of this code is taken from the \Lpack{nextpage} package~\cite{NEXTPAGE}.
%
% Clear to next page is \cs{clearpage}.
%
% \begin{macro}{\cleartoevenpage}
% \cs{cleartoevenpage}\oarg{text} clears to the next even
% numbered page,
% putting the optional \meta{text} on the skipped page, if any.
% \begin{macrocode}
\newcommand{\cleartoevenpage}[1][\@empty]{%
\clearpage%
\ifodd\c@page\hbox{}#1\clearpage\fi}
% \end{macrocode}
% \end{macro}
%
% Move to the next page without flushing floats is \cs{newpage}.
%
% \begin{macro}{\movetoevenpage}
% \cs{movetoevenpage}\oarg{text} moves to the next even
% numbered page without flushing floats,
% putting the optional \meta{text} on the skipped page, if any.
% \begin{macrocode}
\newcommand{\movetoevenpage}[1][\@empty]{%
\newpage%
\ifodd\c@page\hbox{}#1\newpage\fi}
% \end{macrocode}
% \end{macro}
%
% Clear to next odd numbered page is \cs{cleardoublepage}.
%
% \begin{macro}{\cleartooddpage}
% \cs{cleartooddpage}\oarg{text} clears to the next odd
% numbered page,
% putting the optional \meta{text} on the skipped page, if any.
% \begin{macrocode}
\newcommand{\cleartooddpage}[1][\@empty]{%
\clearpage%
\ifodd\c@page\else\hbox{}#1\clearpage\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\movetooddpage}
% \cs{movetooddpage}\oarg{text} moves to the next odd
% numbered page without flushing floats,
% putting the optional \meta{text} on the skipped page, if any.
% \begin{macrocode}
\newcommand{\movetooddpage}[1][\@empty]{%
\newpage%
\ifodd\c@page\else\hbox{}#1\newpage\fi}
% \end{macrocode}
% \end{macro}
%
% Example uses: \\
% \begin{verbatim}
% \cleartooddpage % same as \cleardouble page
% \cleartooddpage[\thispagestyle{empty}] % No headings on the skipped page
% \cleartoevenpage % go to next even numbered page
% Next example puts text on a skipped page
% \cleartoevenpage[\vspace*{\hfill}THIS PAGE LEFT BLANK\vspace*{\hfill}]
% \end{verbatim}
%
%
%
% \subsection{Needing space at the bottom of a page}
%
% \begin{macro}{\needspace}
% \cs{needspace}\marg{length} checks if the is \meta{length} amount
% of vertical space left on the page. If there is not it will start
% a new page. The code is a variant of code thought of for the
% \Lpack{needspace} package~\cite{NEEDSPACE}.
% \changes{v1.4}{2003/11/16}{Added patch v1.4 versions of needspace macros}
% \changes{v3.6g}{2010/09/09}{Added a \cs{vskip0pt} at the end to make
% it work better with \cs{section} and friends}
% \begin{macrocode}
\newcommand{\needspace}[1]{\begingroup\setlength{\dimen@}{#1}%
\vskip\z@\@plus\dimen@\penalty -100\vskip\z@\@plus-\dimen@
\vskip\dimen@\penalty 9999\vskip-\dimen@\vskip\z@skip\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Needspace}
% \begin{macro}{\Needspace*}
% \cs{Needspace} and \cs{Needspace*} are more robust versions of \cs{needspace},
% which depends on penalties. If either \cs{needspace} or \cs{Needspace}
% produce a short page it will be ragged bottom, even if \cs{flushbottom}
% is in effect. The \cs{Needspace*} version honours the \cs{...bottom}
% declaration.
% \begin{macrocode}
\newcommand{\Needspace}{\@ifstar{\M@sneedsp@}{\M@needsp@}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\M@sneedsp@}
% \begin{macro}{\M@needsp@}
% These implement \cs{Needspace*} and \cs{needspace} respectively.
% \begin{macrocode}
\newcommand{\M@sneedsp@}[1]{\par \penalty-100\begingroup
\setlength{\dimen@}{#1}%
\dimen@ii\pagegoal \advance\dimen@ii-\pagetotal
\ifdim \dimen@>\dimen@ii
\break
\fi\endgroup}
\newcommand{\M@needsp@}[1]{\par \penalty-100\begingroup
\setlength{\dimen@}{#1}%
\dimen@ii\pagegoal \advance\dimen@ii-\pagetotal
\ifdim \dimen@>\dimen@ii
\ifdim \dimen@ii>\z@
\vfil
\fi
\break
\fi\endgroup}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Overlong lines}
%
% LaTeX provides \cs{fussy} and \cs{sloppy} to control the amount of slack
% in a line while trying to make justified lines. Their definitions are:
% \begin{verbatim}
% \def\fussy{%
% \emergencystretch\z@
% \tolerance 200%
% \hfuzz .1\p@
% \vfuzz\hfuzz}
% \def\sloppy{%
% \tolerance 9999%
% \emergencystretch 3em%
% \hfuzz .5\p@
% \vfuzz\hfuzz}
% \end{verbatim}
%
% \begin{macro}{\midsloppy}
% Somewhere between \cs{fussy} and \cs{sloppy}.
% \changes{v1.61803}{2008/01/30}{Added \cs{midsloppy} and midsloppypar
% (mempatch v4.5)}
% \begin{macrocode}
\newcommand*{\midsloppy}{%
\tolerance 5000%
\hbadness 4000%
\emergencystretch 1.5em%
\hfuzz .1\p@
\vfuzz\hfuzz}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{midsloppypar}
% A paragraph form of \cs{midsloppy}; equivalent to \verb?\par \midsloppy ... \par}?
% \begin{macrocode}
\newenvironment{midsloppypar}{\par\midsloppy}{\par}
% \end{macrocode}
% \end{environment}
%
% \subsection{Text spacing commands}
%
% While we're at it, new text spacing commands to supplement
% the kernel's \\
% \verb?\, (\thinspace) = 3/18 em?
% \changes{v1.4}{2003/11/16}{Extra text spacing macros from patch v1.4}
% \changes{v3.7l}{2020/06/02}{Added kernel wrapper}
% As of the kernel/format update for october 2020, these will be moved
% to the kernel, so we remove them of you are using that kernel.
% \begin{macrocode}
\@ifl@t@r\fmtversion{2020-10-01}{
% nothing to do with newer kernel
}{%
% \end{macrocode}
% \begin{macro}{\medspace}
% \begin{macro}{\:}
% Medium space \verb?\: (\medspace) = 4/18 em?
% \changes{v3.7q}{2022/02/17}{use \cs{providecommand} on \cs{medspace}}
% \begin{macrocode}
\providecommand{\medspace}{\kern .22222em }
\DeclareRobustCommand{\:}{%
\relax\ifmmode\mskip\medmuskip\else\medspace\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\!}
% Negative thin space (- 3/18 em).
% Patrik Nyman (private email 2003/10/06) pointed out I had missed
% the final \verb?\fi? !!!!.
% \begin{macrocode}
\DeclareRobustCommand{\!}{%
\relax\ifmmode\mskip-\thinmuskip\else\negthinspace\fi}
} % end kernel version wrapper
% \end{macrocode}
% \end{macro}
%
% \subsection{Fractions and subscripts}
%
%
% Styles for fractions like 3/4.
%
% \begin{macro}{\slashfracstyle}
% \cs{slashfracstyle} based on the kernel \cs{textsuperscript} macro
% \changes{v1.4}{2003/11/16}{Added \cs{slashfrac} and supports (from patch v1.4)}
% \begin{macrocode}
\DeclareRobustCommand*{\slashfracstyle}[1]{%
{\m@th\ensuremath{\mbox{\fontsize\sf@size\z@\selectfont #1}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\slashfrac}
% \cs{slashfrac} based on TeXbook exercise 11.6
% \begin{macrocode}
\DeclareRobustCommand*{\slashfrac}[2]{\leavevmode
\raise.5ex\hbox{\slashfracstyle{#1}}\kern-.13em/%
\kern-.15em\lower.25ex\hbox{\slashfracstyle{#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\textsubscript}
% \begin{macro}{\@textsubscript}
% \cs{textsubscript}, for text subscripts, based on the kernel
% \cs{textsuperscript} macro.
% \changes{v1.4}{2003/11/16}{Added \cs{textsubscript} and supports
% (from patch v1.5)}
% \changes{v3.7d}{2014/07/28}{\cs{@textsubscript} should be provided,
% not newcommaded, otherwise one cannot load \Lpack{fixltx2e} before
% \cs{documentclass}, reported by Ulrike Fischer}
% \changes{v3.7d}{2015/03/05}{Requested by the LTX3 team as they are
% updating the LaTeX kernel with the \Lpack{fixltx2e} fixes. Added
% \cs{@ifundefined} wapper}
% \begin{macrocode}
\@ifundefined{textsubscript}{%
\DeclareRobustCommand*{\textsubscript}[1]{%
\@textsubscript{\selectfont#1}}
\providecommand*{\@textsubscript}[1]{%
{\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Numbers to names}
%
% \begin{macrocode}
%%%%%%%%%%%%%%%%%%%% number formatting
% \end{macrocode}
%
% The macros here convert an integer number in the range 0--2147483647
% (TeX's maximum) into
% the natural language name of the number.
% \changes{v1.4}{2003/11/16}{Much extended numbers to names (patch v1.2)}
%
% \begin{macro}{\iflowernumtoname}
% A flag for lowercasing the initial letters.
% \begin{macrocode}
\newif\iflowernumtoname
\lowernumtonamefalse
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifpriornum}
% \begin{macro}{\ifminusnumber}
% \begin{macro}{\ifnotnumtonameallcaps}
% \begin{macro}{\ifmakeordinal}
% Some new booleans
% \begin{macrocode}
\newif\ifpriornum
\newif\ifminusnumber
\newif\ifnotnumtonameallcaps
\newif\ifmakeordinal
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\namenumberand}
% \begin{macro}{\namenumbercomma}
% \begin{macro}{\lcminusname}
% \begin{macro}{\ucminusname}
% \begin{macro}{\minusname}
% Some macros representing characters/words for number formatting.
% \begin{macrocode}
\newcommand*{\namenumberand}{ and }
\newcommand*{\namenumbercomma}{, }
\newcommand*{\lcminusname}{minus }
\newcommand*{\ucminusname}{Minus }
\let\minusname\lcminusname
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fnumbersep}
% \begin{macro}{\tensunitsep}
% \begin{macro}{\nthstring}
% \begin{macro}{\iststring}
% \begin{macro}{\iindstring}
% \begin{macro}{\iiirdstring}
% \begin{macro}{\tiethstring}
% \begin{macro}{\teenstring}
% More characters/words for formatting
% \begin{macrocode}
\newcommand*{\fnumbersep}{,}
\newcommand*\tensunitsep{-}
\newcommand*{\nthstring}{th} % nth
\newcommand*{\iststring}{st} % 1st
\newcommand*{\iindstring}{nd} % 2nd
\newcommand*{\iiirdstring}{rd} % 3rd
\newcommand*{\tiethstring}{tieth} % tieth
\newcommand*{\teenstring}{teen} % teen
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ordscript}
% How to format the ordinal string
% \begin{macrocode}
\newcommand{\ordscript}[1]{#1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mten}
% An internal shorthand for 10
% \begin{macrocode}
\chardef\m@mten=10 % shorthand for 10
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@ism@mctr}
% \begin{macro}{\c@xsm@mctr}
% \begin{macro}{\c@csm@mctr}
% \begin{macro}{\c@ksm@mctr}
% \begin{macro}{\c@xksm@mctr}
% Counters for digits (units to ten thousands) in a number
% \begin{macrocode}
\newcounter{ism@mctr} % units
\newcounter{xsm@mctr} % tens
\newcounter{csm@mctr} % hundreds
\newcounter{ksm@mctr} % thousands
\newcounter{xksm@mctr} % ten thousands
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@cksm@mctr}
% \begin{macro}{\c@msm@mctr}
% \begin{macro}{\c@xmsm@mctr}
% \begin{macro}{\c@cmsm@mctr}
% \begin{macro}{\c@bsm@mctr}
% Counters for digits (hundred thousands to billions) in a number
% \begin{macrocode}
\newcounter{cksm@mctr} % hundred thousands
\newcounter{msm@mctr} % millions
\newcounter{xmsm@mctr} % ten millions
\newcounter{cmsm@mctr} % hundred millions
\newcounter{bsm@mctr} % billions
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@workm@mctr}
% A `work' counter.
% \begin{macrocode}
\newcounter{workm@mctr}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\numdigits}
% \cs{numdigits}\marg{number} splits the \meta{number} into individual digits.
% It sets \cs{minusnumbertrue} if the number is negative, otherwise it is false.
% \begin{macrocode}
\newcommand*{\numdigits}[1]{%
\setcounter{ism@mctr}{0}%
\setcounter{xsm@mctr}{0}%
\setcounter{csm@mctr}{0}%
\setcounter{ksm@mctr}{0}%
\setcounter{xksm@mctr}{0}%
\setcounter{cksm@mctr}{0}%
\setcounter{msm@mctr}{0}%
\setcounter{xmsm@mctr}{0}%
\setcounter{cmsm@mctr}{0}%
\setcounter{bsm@mctr}{0}%
\setcounter{workm@mctr}{#1}%
\minusnumberfalse
\ifnum \c@workm@mctr < \z@ % negative
\minusnumbertrue
\c@workm@mctr = -\c@workm@mctr
\fi
\ifnum \c@workm@mctr > \m@ne % units
\c@ism@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@ism@mctr by -\c@workm@mctr
\divide \c@workm@mctr by \m@mten
\fi
\ifnum \c@workm@mctr > \z@ % tens
\c@xsm@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@xsm@mctr by -\c@workm@mctr
\divide \c@workm@mctr by \m@mten
\fi
\ifnum \c@workm@mctr > \z@ % hundreds
\c@csm@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@csm@mctr by -\c@workm@mctr
\divide \c@workm@mctr by \m@mten
\fi
\ifnum \c@workm@mctr > \z@ % thousands
\c@ksm@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@ksm@mctr by -\c@workm@mctr
\divide \c@workm@mctr by \m@mten
\fi
\ifnum \c@workm@mctr > \z@ % ten thousands
\c@xksm@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@xksm@mctr by -\c@workm@mctr
\divide \c@workm@mctr by \m@mten
\fi
\ifnum \c@workm@mctr > \z@ % hundred thousands
\c@cksm@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@cksm@mctr by -\c@workm@mctr
\divide \c@workm@mctr by \m@mten
\fi
\ifnum \c@workm@mctr > \z@ % millions
\c@msm@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@msm@mctr by -\c@workm@mctr
\divide \c@workm@mctr by \m@mten
\fi
\ifnum \c@workm@mctr > \z@ % ten millions
\c@xmsm@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@xmsm@mctr by -\c@workm@mctr
\divide \c@workm@mctr by \m@mten
\fi
\ifnum \c@workm@mctr > \z@ % hundred millions
\c@cmsm@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@cmsm@mctr by -\c@workm@mctr
\divide \c@workm@mctr by \m@mten
\fi
\ifnum \c@workm@mctr > \z@% billions
\c@bsm@mctr = \c@workm@mctr
\divide \c@workm@mctr by \m@mten
\multiply \c@workm@mctr by \m@mten
\advance \c@bsm@mctr by -\c@workm@mctr
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\form@tnumber}
% \cs{form@tnumber}\marg{number} formats \meta{number} as digits.
% \begin{macrocode}
\newcommand*{\form@tnumber}[1]{%
\numdigits{#1}%
\ifminusnumber-\fi
\priornumfalse
\ifnum \c@bsm@mctr > \z@ % billions
\priornumtrue
\thebsm@mctr\fnumbersep
\fi
\ifpriornum % hundred millions
\thecmsm@mctr
\else
\ifnum \c@cmsm@mctr > \z@
\priornumtrue
\thecmsm@mctr
\fi
\fi
\ifpriornum % ten millions
\thexmsm@mctr
\else
\ifnum \c@xmsm@mctr > \z@
\priornumtrue
\thexmsm@mctr
\fi
\fi
\ifpriornum % millions
\themsm@mctr\fnumbersep
\else
\ifnum \c@msm@mctr > \z@
\priornumtrue
\themsm@mctr\fnumbersep
\fi
\fi
\ifpriornum % hundred thousands
\thecksm@mctr
\else
\ifnum \c@cksm@mctr > \z@
\priornumtrue
\thecksm@mctr
\fi
\fi
\ifpriornum % ten thousands
\thexksm@mctr
\else
\ifnum \c@xksm@mctr > \z@
\priornumtrue
\thexksm@mctr
\fi
\fi
\ifpriornum % thousands
\theksm@mctr\fnumbersep
\else
\ifnum \c@ksm@mctr > \z@
\priornumtrue
\theksm@mctr\fnumbersep
\fi
\fi
\ifpriornum % hundreds
\thecsm@mctr
\else
\ifnum \c@csm@mctr > \z@
\priornumtrue
\thecsm@mctr
\fi
\fi
\ifpriornum % tens
\thexsm@mctr
\else
\ifnum \c@xsm@mctr > \z@
\priornumtrue
\thexsm@mctr
\fi
\fi
\theism@mctr} % units
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cardinal}
% \cs{cardinal}\marg{number} prints \meta{number} unformatted.
% \begin{macrocode}
\newcommand*{\cardinal}[1]{%
\begingroup
\let\fnumbersep\relax
\form@tnumber{#1}%
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fcardinal}
% \cs{fcardinal}\marg{number} prints \meta{number} formatted.
% \begin{macrocode}
\newcommand*{\fcardinal}[1]{%
\begingroup
\form@tnumber{#1}%
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ordinal}
% \cs{ordinal}\marg{number} prints \meta{number} as an unformatted ordinal.
% \begin{macrocode}
\newcommand*{\ordinal}[1]{%
\begingroup
\let\fnumbersep\relax
\form@tnumber{#1}%
\let\ordstring\nthstring
\ifnum \c@xsm@mctr=\@ne\else
\ifcase \c@ism@mctr
\or \let\ordstring\iststring% 1st
\or \let\ordstring\iindstring% 2nd
\or \let\ordstring\iiirdstring% 3rd
\fi
\fi
\ordscript{\ordstring}%
\endgroup
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fordinal}
% \cs{fordinal}\marg{number} prints \meta{number} as a formatted ordinal.
% \begin{macrocode}
\newcommand*{\fordinal}[1]{%
\begingroup
\form@tnumber{#1}%
\let\ordstring\nthstring
\ifnum \c@xsm@mctr=\@ne\else
\ifcase \c@ism@mctr
\or \let\ordstring\iststring% 1st
\or \let\ordstring\iindstring% 2nd
\or \let\ordstring\iiirdstring% 3rd
\fi
\fi
\ordscript{\ordstring}%
\endgroup
}
% \end{macrocode}
% \end{macro}
%
% The next, tedious, code is for translating numbers into names.
%
% \begin{macro}{\nNameo}
% \begin{macro}{\nNamec}
% \begin{macro}{\nNamem}
% \begin{macro}{\nNamemm}
% \begin{macro}{\nNamemmm}
% Names of major numbers: $0$, $10^{2}$, $10^{3}$, $10^{6}$, and $10^{9}$.
% \begin{macrocode}
\newcommand*\nNameo{\iflowernumtoname z\else Z\fi ero}
\newcommand*\nNamec{\iflowernumtoname h\else H\fi undred}
\newcommand*\nNamem{\iflowernumtoname t\else T\fi housand}
\newcommand*\nNamemm{\iflowernumtoname m\else M\fi illion}
\newcommand*\nNamemmm{\iflowernumtoname b\else B\fi illion}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\nNamei}
% \begin{macro}{\nNameii}
% \begin{macro}{\nNameiii}
% \begin{macro}{\nNameiv}
% \begin{macro}{\nNamev}
% These are the names for numbers 1 to 5.
% \begin{macrocode}
\newcommand*\nNamei{\iflowernumtoname o\else O\fi ne}
\newcommand*\nNameii{\iflowernumtoname t\else T\fi wo}
\newcommand*\nNameiii{\iflowernumtoname t\else T\fi hree}
\newcommand*\nNameiv{\iflowernumtoname f\else F\fi our}
\newcommand*\nNamev{\iflowernumtoname f\else F\fi ive}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\nNamevi}
% \begin{macro}{\nNamevii}
% \begin{macro}{\nNameviii}
% \begin{macro}{\nNameix}
% \begin{macro}{\nNamex}
% These are the names for numbers 6 to 10.
% \begin{macrocode}
\newcommand*\nNamevi{\iflowernumtoname s\else S\fi ix}
\newcommand*\nNamevii{\iflowernumtoname s\else S\fi even}
\newcommand*\nNameviii{\iflowernumtoname e\else E\fi ight}
\newcommand*\nNameix{\iflowernumtoname n\else N\fi ine}
\newcommand*\nNamex{\iflowernumtoname t\else T\fi en}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\nNamexi}
% \begin{macro}{\nNamexii}
% \begin{macro}{\nNamexiii}
% \begin{macro}{\nNamexiv}
% \begin{macro}{\nNamexv}
% These are the names for numbers 11 to 15.
% \begin{macrocode}
\newcommand*\nNamexi{\iflowernumtoname e\else E\fi leven}
\newcommand*\nNamexii{\iflowernumtoname t\else T\fi welve}
\newcommand*\nNamexiii{\iflowernumtoname t\else T\fi hir\teenstring}
\newcommand*\nNamexiv{\iflowernumtoname f\else F\fi our\teenstring}
\newcommand*\nNamexv{\iflowernumtoname f\else F\fi if\teenstring}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\nNamexvi}
% \begin{macro}{\nNamexvii}
% \begin{macro}{\nNamexviii}
% \begin{macro}{\nNamexix}
% \begin{macro}{\nNamexx}
% These are the names for numbers 16 to 20.
% \begin{macrocode}
\newcommand*\nNamexvi{\iflowernumtoname s\else S\fi ix\teenstring}
\newcommand*\nNamexvii{\iflowernumtoname s\else S\fi even\teenstring}
\newcommand*\nNamexviii{\iflowernumtoname e\else E\fi igh\teenstring}
\newcommand*\nNamexix{\iflowernumtoname n\else N\fi ine\teenstring}
\newcommand*\nNamexx{\iflowernumtoname t\else T\fi wenty}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\nNamexxx}
% \begin{macro}{\nNamexl}
% \begin{macro}{\nNamel}
% \begin{macro}{\nNamelx}
% \begin{macro}{\nNamelxx}
% These are the names for numbers 30 to 70.
% \begin{macrocode}
\newcommand*\nNamexxx{\iflowernumtoname t\else T\fi hirty}
\newcommand*\nNamexl{\iflowernumtoname f\else F\fi orty}
\newcommand*\nNamel{\iflowernumtoname f\else F\fi ifty}
\newcommand*\nNamelx{\iflowernumtoname s\else S\fi ixty}
\newcommand*\nNamelxx{\iflowernumtoname s\else S\fi eventy}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\nNamelxxx}
% \begin{macro}{\nNamexc}
% These are the names for numbers 80 to 90.
% \begin{macrocode}
\newcommand*\nNamelxxx{\iflowernumtoname e\else E\fi ighty}
\newcommand*\nNamexc{\iflowernumtoname n\else N\fi inety}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \begin{macro}{\unitnumbername}
% Get the name of a unit (0 -- 9).
% \begin{macrocode}
\newcommand*{\unitnumbername}[1]{%
\ifcase #1 \nNameo\or
\nNamei\or
\nNameii\or
\nNameiii\or
\nNameiv\or
\nNamev\or
\nNamevi\or
\nNamevii\or
\nNameviii\or
\nNameix\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\teennumbername}
% Get the name of a 'teen number (10 -- 19)
% \begin{macrocode}
\newcommand*{\teennumbername}[1]{%
\ifcase #1 \nNamex\or
\nNamexi\or
\nNamexii\or
\nNamexiii\or
\nNamexiv\or
\nNamexv\or
\nNamexvi\or
\nNamexvii\or
\nNamexviii\or
\nNamexix\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tensnumbername}
% Get the name of a tens number (20 -- 90)
% \begin{macrocode}
\newcommand*{\tensnumbername}[2]{%
\ifnum #1=\@ne
\teennumbername{#2}\ifnotnumtonameallcaps\lowernumtonametrue\fi
\else
\ifcase #1
\or
\or \nNamexx
\or \nNamexxx
\or \nNamexl
\or \nNamel
\or \nNamelx
\or \nNamelxx
\or \nNamelxxx
\or \nNamexc
\fi
\ifnotnumtonameallcaps\lowernumtonametrue\fi
\ifnum #2 > \z@ \tensunitsep\unitnumbername{#2}\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% Names of small ordinals. The use of \cs{nthstring} instead of `th' saves
% some tokens.
% \begin{macrocode}
\newcommand*\nthNameo{\nNameo\nthstring}
\newcommand*\nthNamei{\iflowernumtoname f\else F\fi irst}
\newcommand*\nthNameii{\iflowernumtoname s\else S\fi econd}
\newcommand*\nthNameiii{\iflowernumtoname t\else T\fi hird}
\newcommand*\nthNameiv{\nNameiv\nthstring}
\newcommand*\nthNamev{\iflowernumtoname f\else F\fi if\nthstring}
\newcommand*\nthNamevi{\nNamevi\nthstring}
\newcommand*\nthNamevii{\nNamevii\nthstring}
\newcommand*\nthNameviii{\iflowernumtoname e\else E\fi igh\nthstring}
\newcommand*\nthNameix{\iflowernumtoname n\else N\fi in\nthstring}
\newcommand*\nthNamexii{\iflowernumtoname t\else T\fi welf\nthstring}
% \end{macrocode}
%
% \begin{macro}{\unitordinalname}
% Get the ordinal name of a unit (0 -- 9)
% \begin{macrocode}
\newcommand*{\unitordinalname}[1]{%
\ifcase #1 \nthNameo\or
\nthNamei\or
\nthNameii\or
\nthNameiii\or
\nthNameiv\or
\nthNamev\or
\nthNamevi\or
\nthNamevii\or
\nthNameviii\or
\nthNameix\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\teenordinalname}
% Get the ordinal name of a 'teen number (10 -- 19). Using \cs{nthstring}
% instead of `th' to save some tokens.
% \begin{macrocode}
\newcommand*{\teenordinalname}[1]{%
\ifcase #1 \nNamex\nthstring\or
\nNamexi\nthstring\or
\nthNamexii\or
\nNamexiii\nthstring\or
\nNamexiv\nthstring\or
\nNamexv\nthstring\or
\nNamexvi\nthstring\or
\nNamexvii\nthstring\or
\nNamexviii\nthstring\or
\nNamexix\nthstring\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tensordinalname}
% Get the ordinal name of a tens number (20 -- 90)
% (Mathew Dafilis (\texttt{mpd@swin.edu.au}) sent Email on 2003/11/14
% saying that \cs{ordinaltoname} didn't work for 20, 30, etc. He was
% correct. It is now fixed.
% \begin{macrocode}
\newcommand*{\tensordinalname}[2]{%
\ifnum #1=\@ne
\teenordinalname{#2}\ifnotnumtonameallcaps\lowernumtonametrue\fi
\else
\ifnum #2> \z@
\ifcase #1
\or
\or \nNamexx
\or \nNamexxx
\or \nNamexl
\or \nNamel
\or \nNamelx
\or \nNamelxx
\or \nNamelxxx
\or \nNamexc
\fi
\ifnotnumtonameallcaps\lowernumtonametrue\fi
\tensunitsep\unitordinalname{#2}
\else
\ifcase #1
\or
\or \nthNamexx
\or \nthNamexxx
\or \nthNamexl
\or \nthNamel
\or \nthNamelx
\or \nthNamelxx
\or \nthNamelxxx
\or \nthNamexc
\fi
\ifnotnumtonameallcaps\lowernumtonametrue\fi
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% The names of tens ordinals. The use of \cs{tiethstring} instead
% of `tieth' saves somes tokens.
% \begin{macrocode}
\newcommand*\nthNamexx{\iflowernumtoname t\else T\fi wen\tiethstring}
\newcommand*\nthNamexxx{\iflowernumtoname t\else T\fi hir\tiethstring}
\newcommand*\nthNamexl{\iflowernumtoname f\else F\fi or\tiethstring}
\newcommand*\nthNamel{\iflowernumtoname f\else F\fi if\tiethstring}
\newcommand*\nthNamelx{\iflowernumtoname s\else S\fi ix\tiethstring}
\newcommand*\nthNamelxx{\iflowernumtoname s\else S\fi even\tiethstring}
\newcommand*\nthNamelxxx{\iflowernumtoname e\else E\fi igh\tiethstring}
\newcommand*\nthNamexc{\iflowernumtoname n\else N\fi ine\tiethstring}
% \end{macrocode}
%
% \begin{macro}{\n@me@number}
% \cs{n@me@number}\marg{number} is an internal macro to convert a
% \meta{number} to names.
% \begin{macrocode}
\newcommand*{\n@me@number}[1]{%
\begingroup
\numdigits{#1}%
\ifminusnumber\minusname\fi
\priornumfalse
%% billions
\ifnum \c@bsm@mctr > \z@
\unitnumbername{\thebsm@mctr}\space
\ifnotnumtonameallcaps\lowernumtonametrue\fi\nNamemmm
\priornumtrue
\fi
%% hundred millions
\ifnum \c@cmsm@mctr > \z@
\ifpriornum\namenumbercomma\fi
\unitnumbername{\thecmsm@mctr}\space
\ifnotnumtonameallcaps\lowernumtonametrue\fi\nNamec
\priornumtrue
\fi
%% tens/units millions
\ifnum \c@xmsm@mctr > \z@
\ifpriornum
\ifnum\c@cmsm@mctr>\z@\namenumberand\else\namenumbercomma\fi
\fi
\tensnumbername{\thexmsm@mctr}{\themsm@mctr}%
\priornumtrue
\else
\ifnum \c@msm@mctr > \z@
\ifpriornum
\ifnum\c@cmsm@mctr>\z@\namenumberand\else\namenumbercomma\fi
\fi
\unitnumbername{\themsm@mctr}%
\ifnotnumtonameallcaps\lowernumtonametrue\fi
\priornumtrue
\fi
\fi
\ifnum \c@cmsm@mctr > \z@
\ifpriornum\space\fi
\nNamemm
\else
\ifnum \c@xmsm@mctr > \z@
\ifpriornum\space\fi
\nNamemm
\else
\ifnum \c@msm@mctr > \z@
\ifpriornum\space\fi
\nNamemm
\fi
\fi
\fi
%% hundred thousands
\ifnum \c@cksm@mctr > \z@
\ifpriornum\namenumbercomma\fi
\unitnumbername{\thecksm@mctr}\space
\ifnotnumtonameallcaps\lowernumtonametrue\fi\nNamec
\priornumtrue
\fi
%% tens/units thousands
\ifnum \c@xksm@mctr > \z@
\ifpriornum
\ifnum\c@cksm@mctr>\z@\namenumberand\else\namenumbercomma\fi
\fi
\tensnumbername{\thexksm@mctr}{\theksm@mctr}%
\priornumtrue
\else
\ifnum \c@ksm@mctr > \z@
\ifpriornum
\ifnum\c@cksm@mctr>\z@\namenumberand\else\namenumbercomma\fi
\fi
\unitnumbername{\theksm@mctr}%
\ifnotnumtonameallcaps\lowernumtonametrue\fi
\priornumtrue
\fi
\fi
\ifnum \c@cksm@mctr > \z@
\ifpriornum\space\fi
\nNamem
\else
\ifnum \c@xksm@mctr > \z@
\ifpriornum\space\fi
\nNamem
\else
\ifnum \c@ksm@mctr > \z@
\ifpriornum\space\fi
\nNamem
\fi
\fi
\fi
%% hundreds
\ifnum \c@csm@mctr > \z@
\ifpriornum\namenumbercomma\fi
\unitnumbername{\thecsm@mctr}\space
\ifnotnumtonameallcaps\lowernumtonametrue\fi\nNamec
\priornumtrue
\fi
%% tens/units
\ifmakeordinal
\ifnum \c@xsm@mctr > \z@
\ifpriornum\namenumberand\fi
\tensordinalname{\thexsm@mctr}{\theism@mctr}%
\else
\ifnum \c@ism@mctr > \z@
\ifpriornum\namenumberand\fi
\unitordinalname{\theism@mctr}%
\else
\ifpriornum\nthstring\else\unitordinalname{\theism@mctr}\fi
\fi
\fi
\else % not ordinal
\ifnum \c@xsm@mctr > \z@
\ifpriornum\namenumberand\fi
\tensnumbername{\thexsm@mctr}{\theism@mctr}%
\else
\ifnum \c@ism@mctr > \z@
\ifpriornum\namenumberand\fi
\unitnumbername{\theism@mctr}%
\else
\ifpriornum\else\unitnumbername{\theism@mctr}\fi
\fi
\fi
\fi % end ifmakeordinal
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \changes{v1.61803}{2008/01/30}{Made all \cs{(num/ordinal)toname} robust}
% \begin{macro}{\numtoname}
% Lowercase all names
% \begin{macrocode}
\DeclareRobustCommand{\numtoname}[1]{%
\makeordinalfalse
\notnumtonameallcapstrue%
\lowernumtonametrue%
\n@me@number{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\numtoName}
% Uppercase first letter of first name (all else lowercase).
% \begin{macrocode}
\DeclareRobustCommand{\numtoName}[1]{%
\makeordinalfalse
\notnumtonameallcapstrue%
\lowernumtonamefalse%
\n@me@number{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NumToName}
% Uppercase first letter of all names (all else lowercase).
% \begin{macrocode}
\DeclareRobustCommand{\NumToName}[1]{%
\makeordinalfalse
\notnumtonameallcapsfalse%
\lowernumtonamefalse%
\n@me@number{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ordinaltoname}
% Lowercase all ordinal names
% \begin{macrocode}
\DeclareRobustCommand{\ordinaltoname}[1]{%
\makeordinaltrue
\notnumtonameallcapstrue%
\lowernumtonametrue%
\n@me@number{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ordinaltoName}
% Uppercase first letter of first ordinal name (all else lowercase).
% \begin{macrocode}
\DeclareRobustCommand{\ordinaltoName}[1]{%
\makeordinaltrue
\notnumtonameallcapstrue%
\lowernumtonamefalse%
\n@me@number{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\OrdinalToName}
% Uppercase first letter of all ordinal names (all else lowercase).
% \begin{macrocode}
\DeclareRobustCommand{\OrdinalToName}[1]{%
\makeordinaltrue
\notnumtonameallcapsfalse%
\lowernumtonamefalse%
\n@me@number{#1}}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{A fix for two column headings}
%
%
% This is from a posting by Donald Arseneau to \ctt{} on 23 April 2001 to fix
% a problem --- `When I use \verb?\onecolumn\chapter...? its headline
% is printed lower on the page than for two-column chapters'
%
% DA and I had previously discussed this in relation to the Index
% and I had put a hack into the \Lpack{tocbibind} package to fix the Index.
%
% Donald posted the following.
%
% \cs{vspace*} gives bad spacing after a pagebreak and \cs{@makechapterhead}
% starts with \cs{vspace*}.
% The biggest problem is the definition of \cs{@topnewpage}, which is used
% for the two-column spanning text. Here is a redefinition:
% \changes{v0.2}{2001/06/03}{Added DA's redefinition of \cs{@topnewpage}}
% \begin{macro}{\@topnewpage}
% \begin{macrocode}
\long\def \@topnewpage [#1]{%
\@nodocument
\@next\@currbox\@freelist{}{}%
\global \setbox\@currbox
\vbox {%
\break
\prevdepth\z@
\begingroup
\normalcolor
\hsize\textwidth
\@parboxrestore
\col@number \@ne
#1%
\vskip -\dbltextfloatsep
\endgroup
\null % ordinary \baselineskip
\vskip -\topskip
}%
\begingroup %% \showbox\@currbox
\splitmaxdepth\maxdepth \splittopskip\topskip
\setbox\@tempboxa \vsplit\@currbox to \z@
\endgroup %% \showbox\@currbox
\ifdim \ht\@currbox>\textheight
\ht\@currbox \textheight
\fi
\global \count\@currbox \tw@
\@tempdima -\ht\@currbox
\advance \@tempdima -\dbltextfloatsep
\global \advance \@colht \@tempdima
\ifx \@dbltoplist \@empty
\else
\@latexerr{Float(s) lost}\@ehb
\let \@dbltoplist \@empty
\fi
\@cons \@dbltoplist \@currbox
\global \@dbltopnum \m@ne
\ifdim \@colht<2.5\baselineskip
\@latex@warning@no@line {Optional argument of \noexpand\twocolumn
too tall on page \thepage}%
\@emptycol
\if@firstcolumn
\else
\@emptycol
\fi
\else
\global \vsize \@colht
\global \@colroom \@colht
\@floatplacement
\fi}
% \end{macrocode}
% \end{macro}
%
% The original version of \cs{@topnewpage} is in \file{ltouput.dtx}, line 159.
%
% \subsection{Time of day}
%
% William Adams (2006/08/28) supplied a basis for
% \cs{printime}, which he needed for \cs{quarkmarks} but I have used one
% from \textit{TeX for the Impatient}
% as it saves some counters.
% \changes{v1.61803}{2008/01/30}{Added \cs{printime} and friends (mempatch v4.6)}
% \begin{macro}{\m@mcalchm}
% Calculate the hours and minutes from \cs{time}.
% \begin{macrocode}
\newcommand*{\m@mcalchm}{%
\count0 = \time \divide \count0 by 60\relax
\count2 = \count0\relax% the hour
\count4 = \time \multiply\count0 by 60\relax
\advance\count4 by -\count0\relax% the minute
\ifnum\count4<10 \toks1 = {0}% make a leading zero
\else \toks1 = {}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hmpunct}
% \begin{macro}{\amname}
% \begin{macro}{\pmname}
% User format controls for \cs{printtime}
% \begin{macrocode}
%%% punctuation, am and pm for \printtime
\newcommand*{\hmpunct}{:}% hours minutes separator
\newcommand*{\amname}{am}% ante meridiem
\newcommand*{\pmname}{pm}% post meridiem
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\printtime}
% \begin{macro}{\printtime*}
% Print the time of day as 24 hour clock or 12 hour clock
% \cs{printtime} prints the time par 24 hour clock and \cs{printtime*}
% per 12 hour clock.
% \begin{macrocode}
\newcommand*{\printtime}{%
\@ifstar{\m@msprtime}{\m@mprtime}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mprtime}
% \begin{macro}{\m@msprtime}
% These implement time printing: \cs{m@mprtime} as 24 hour clock and
% \cs{m@msprtime} as 12 hour clock
% \begin{macrocode}
\newcommand*{\m@mprtime}{\begingroup
\m@mcalchm
\number\count2\hmpunct\the\toks1 \number\count4
\endgroup}
\newcommand*{\m@msprtime}{\begingroup
\m@mcalchm
\def\@mpm{\pmname}%
\ifnum\count2<1\relax% early in the morning
\count2=12\relax
\ifnum\count4>0\relax% not midnight
\def\@mpm{\amname}%
\fi
\else
\ifnum\time<721\relax% noon or earlier
\def\@mpm{\amname}%
\else
\ifnum\time>779\relax% 1300 hrs or later
\advance\count2 by -12\relax
\fi
\fi
\fi
\number\count2\hmpunct\the\toks1 \number\count4\ \@mpm
\endgroup}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Sequential sheet (page) numbers}
%
% \begin{macro}{\c@sheetsequence}
% Peter Heslin asked for the ability to add a sequential page number
% (1 for the first page, N for the last page, no matter what value
% the page counter has) to the trimming marks.
%
% \cs{c@sheetsequence} is a new counter for pages starting at the
% beginning and independent
% of the standard page counter. This should not be reset by anything.
% The counter increment has to be added to the output routine.
%
% This may also be useful for page N of M numbering.
% \changes{v1.3}{2002/10/10}{Added sheetsequence counter.}
% \begin{macrocode}
\newcounter{sheetsequence}
\setcounter{sheetsequence}{1}
\renewcommand{\thesheetsequence}{\@arabic\c@sheetsequence}
\g@addto@macro{\@outputpage}{\stepcounter{sheetsequence}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@lastsheet}
% \begin{macro}{\c@lastpage}
% While we're at it, might as well provide for lastpage and lastsheet counters
% \changes{v1.3}{2002/11/14}{Added lastsheet and lastpage functions.}
% \begin{macrocode}
\newcounter{lastsheet}
\setcounter{lastsheet}{0}
\newcounter{lastpage}
\setcounter{lastpage}{0}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\dol@stsheet}
% \begin{macro}{\dol@stpage}
% These two macros write the values of lastsheet and lastpage to the
% \file{aux} file. They have to be called at the end of the document
% after a \cs{clearpage} to flush out any floats.
% \changes{v1.4}{2003/02/27}{In \cs{dol@stpage} use the page counter value,
% not \cs{thepage} otherwise problems with
% non-arabic page numbers (patch 1.1)}
% \changes{v1.61}{2004/03/21}{In \cs{dol@stpage} use the sheet counter value,
% not \cs{thesheetsequence} otherwise problems
% if (e.g., hangul.sty) \cs{@arabic} is redefined}
% \changes{v1.618}{2005/09/02}{Made \cs{dol@stsheet} and \cs{dol@stpage}
% obey \cs{nofiles}}
% \changes{v1.61803}{2008/01/30}{Made \cs{dol@stsheet} and \cs{dolastpage}
% use \cs{memsetcounter} instead of \cs{setcounter}}
% \begin{macrocode}
\newcommand{\dol@stsheet}{%
\if@filesw
\addtocounter{sheetsequence}{-1}%
\immediate\write\@auxout%
{\string\memsetcounter{lastsheet}{\the\c@sheetsequence}}%
\stepcounter{sheetsequence}%
\fi}
\newcommand{\dol@stpage}{%
\if@filesw
\addtocounter{page}{-1}%
\immediate\write\@auxout%
{\string\memsetcounter{lastpage}{\the\c@page}}%
\stepcounter{page}%
\fi}
% \end{macrocode}
% I originally used this: \\
% \verb?\AtEndDocument{\clearpage\dol@stsheet\dol@stpage}?
% but following the CTT thread \textit{AtEndDocument produces unwanted page
% break}, 2004/03/11, and in particular Dan Luecking's response I now
% try as hard as possible to do it right at the end, but even this is not
% 100\% reliable. The only way to ensure reliability is to modify the kernel
% \verb?\enddocument? which doesn't seem to be a particularly wise thing
% to do.
% \changes{v1.61}{2004/03/14}{Changed location of calls to \cs{dol@stsheet}
% and \cs{dol@stpage}}
% \begin{macrocode}
\AtBeginDocument{\AtEndDocument{\clearpage\dol@stsheet\dol@stpage}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Leaves per gathering}
%
% Traditionally books are assembled in terms of gatherings, or signatures,
% with perhaps 8 or 16 pages (or leaves) per grouping (a leaf has two pages,
% recto and one verso). At the request of Alan Ristow code for this has
% been included in the class.
%
% \begin{macro}{\ifcntrmod}
% \begin{macro}{\ifnotcntrmod}
% \begin{macro}{\iscntrmod}
% \cs{iscntrmod}\marg{counter}\marg{number} returns \cs{cntrmod(true|false)}
% and \cs{notcntrmod(false|true)} if \meta{counter} is a multiple of
% \meta{number}.
% \changes{v1.61803}{2008/01/30}{Added \cs{iscntrmod}}
% \begin{macrocode}
\newif\ifcntrmod
\newif\ifnotcntrmod
\newcommand*{\iscntrmod}[2]{
\@tempcnta=\@nameuse{c@#1}%
\@tempcntb=\@tempcnta
\divide\@tempcnta #2\relax
\multiply\@tempcnta #2\relax
\advance\@tempcntb-\@tempcnta
\ifnum\@tempcntb=0\relax
\cntrmodtrue
\notcntrmodfalse
\else
\cntrmodfalse
\notcntrmodtrue
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@memensuresigpages}
% Ouput enough (empty) pages to make up a complete final signature.
% \changes{v1.61803}{2008/01/30}{Added \cs{@memensuresigpages}}
% \begin{macrocode}
\newcommand*{\@memensuresigpages}{%
\ifnum\@mempagespersig<\@ne
\else
\iscntrmod{sheetsequence}{\@mempagespersig}
\ifcntrmod
\else
\clearpage
\pagestyle{empty}
\mbox{}
\loop
\iscntrmod{sheetsequence}{\@mempagespersig}
\ifnotcntrmod
\clearpage
\pagestyle{empty}
\mbox{}
\repeat
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\leavespergathering}
% \cs{leavespergathering}\marg{num} is the user command for specifying that
% there must be \meta{num} leaves per gathering (2\meta{num} pages per
% gathering). For \meta{num} more than one the total number of pages output
% is exactly divisible by 2\meta{num}. \meta{num} less than two (the default)
% has no effect.
% \changes{v1.61803}{2008/01/30}{Added \cs{leavespergathering}}
% \begin{macrocode}
\newcommand*{\leavespergathering}[1]{\@memcnta=#1\relax
\ifnum\@memcnta<\tw@
\def\@mempagespersig{-1}%
\else
\multiply\@memcnta \tw@
\edef\@mempagespersig{\@memcnta}%
\fi}
\leavespergathering{0}
% \end{macrocode}
% \end{macro}
%
% Finally, make sure that the requested number of pages is output.
% \begin{macrocode}
\AtEndDocument{\@memensuresigpages}
% \end{macrocode}
%
% \subsection{Text case}
% \changes{v3.6k}{2012/09/13}{Included a copy of the \texttt{textcase}
% package.}
%
% \changes{3.7i}{2019/10/22}{Made textcase into a required package instead}
%
% Since, say, \cs{MakeUppercase} does too much, i.e.\ also upper case
% math and arguments to, say, \cs{ref}, we provide a version that does
% not. David Carlisle wrote the simple package ---
% \Lpack{textcase}~\cite{TEXTCASE} which we simply present as a carbon
% copy including Davids explanations. We do \emph{not} mark this
% package as have been emulated. Loading \texttt{textcase} just
% overwrites the macros if they exist.
%
% As of October 2019, we will instead load the \texttt{textcase}
% package if found. If not we resort to the old version we had
% embedded.
%
%
% \begin{macrocode}
\expandafter\let\csname MemOrigMakeUppercase \expandafter\endcsname
\csname MakeUppercase \endcsname
\expandafter\let\csname MemOrigMakeLowercase \expandafter\endcsname
\csname MakeLowercase \endcsname
\def\MemRestoreOrigMakecase{
\expandafter\let\csname MakeUppercase \expandafter\endcsname
\csname MemOrigMakeUppercase \endcsname
\expandafter\let\csname MakeLowercase \expandafter\endcsname
\csname MemOrigMakeLowercase \endcsname
}
\IfFileExists{textcase.sty}{
\RequirePackage[overload]{textcase}
}{% resort to the
% \end{macrocode}
%
% \MakeShortVerb{\|}
% \changes{v3.7j}{2019/11/21}{Forgot to double the \# inside
% \cs{IfFileExists}, also added a warning if textcase if not found on
% the system}
% \begin{macrocode}
\@memwarn{Haven't found the textcase package,\MessageBreak resorting to embedded
copy of v0.07 (2004/10/07),\MessageBreak consider installing the textcase package}
%%%% Nearly a carbon copy from textcase.dtx by David Carlisle
%%%% Since we are inside a \IfFileExists we need to double the #/daleif
% \end{macrocode}
% \begin{macro}{\@uclcnotmath}
% This is the main macro from \texttt{textcase}. It is basically
% a copy of |\MakeUppercase| and |\MakeLowercase|
% from the \LaTeX\ kernel, modified slightly so that they
% can share code (that modification could be done to the
% standard versions as well) and then further changed to
% skip certain features like math mode and |\label| arguments.
%
% The arguments are:\\
% |#1|: Extra commands to apply for case changing.
% Used to locally redefine |\i| and |\j| for uppercasing.\\
% |#2|: Either |##1##2| or |##2##1| to control the order
% in which |\let| is applied to the pairs of control
% sequences in |\@uclclist|.\\
% |#3|: |\uppercase| or |\lowercase|.\\
% |#4|: The text to be upper (or lower) cased.
% \begin{macrocode}
\def\@uclcnotmath##1##2##3##4{\begingroup
% \end{macrocode}
% Run extra commands (currently just to redefine |\i| and |\j|).
% \begin{macrocode}
##1%
% \end{macrocode}
%
% Locally set |\( \)| to be just |$ $|, so that the math skipping
% code can be simplified, just to look for |$|.
% \begin{macrocode}
\def\({$}\let\)\(% $ for emacs :-)
% \end{macrocode}
%
% Set up the `non-math' things that also have to be skipped.
% \begin{macrocode}
\def\NoCaseChange####1{\noexpand\NoCaseChange{\noexpand####1}}%
\@nonchangecase\label
\@nonchangecase\ref
\@nonchangecase\ensuremath
% \end{macrocode}
%
% |\cite| a bit trickier, as we want to uppercase any optional argument.
% This will fail if the optional argument contains a brace group, but
% should catch most cases.
%
% |text \cite[page 1]{foo} more text| ends up as
%\begin{verbatim}
% \uppercase{text \toks@{\cite[page1]}%
% \the\toks@{foo}%
% \uppercase{ more text}
%\end{verbatim}
% \begin{macrocode}
\def\cite####1####{\toks@{\noexpand\cite####1}\@citex}%
\def\@citex####1{\NoCaseChange{\the\toks@{####1}}}%
% \end{macrocode}
% (|\@citex| is a scratch macro here, not a redefinition of the existing
% |\@citex|.)
%
% The following is essentially taken from |\MakeUppercase|.
% Recursively execute |\reserved@a| to |\let| the pairs in |\@uclclist|.
% The strange construction with |\@gobble| at the end just gobbles the
% final recursive call.
%
% Incidentally, packages should not use the |\reserved@|\ldots\ scratch
% macros, which are `reserved' for use within the \LaTeX\ kernel, but
% (a) this code is essentially a copy from the kernel, and
% (b) I'm allowed to break the rules, so there.
% \begin{macrocode}
\def\reserved@a####1####2{\let##2\reserved@a}%
\expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
% \end{macrocode}
%
% Expand everything first so that the `skipping' code can see what to
% skip and so that tokens are revealed to |\uppercase|.
% This makes the argument `moving'.
% The |$\valign$| is just a fake math expression used to terminate
% the parsing done by |\@skipmath|.
% \begin{macrocode}
\protected@edef\reserved@a{\endgroup
\noexpand\@skipmath##3##4$\valign$}%
% \end{macrocode}
%
% \begin{macrocode}
\reserved@a}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@nonchangecase}
% \begin{macrocode}
\def\@nonchangecase##1{\def##1####1{\NoCaseChange{##1{####1}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NoCaseChange}
% For hiding arbitrary text from |\uppercase|. This innocuous
% definition is used for any occurrence of |\NoCaseChange|
% in text that is not passed to |\MakeTextUppercase|. For example a
% section heading may be uppercased, but the toc entry may not.
% It is also used for nested definitions of |\cite| etc, where the
% |\NoCaseChange| is inserted by expansion, but not removed as it is
% hidden by the brace group.
% \begin{macrocode}
\let\NoCaseChange\@firstofone
% \end{macrocode}
% \end{macro}
%
%\begin{macro}{\@skipmath}
% |#1|: operation |\uppercase| / |\lowercase|\\
% |#2|: text up to first (next) |$|\\
% |#3|: first math mode material (or |\valign| sentinel)
% \begin{macrocode}
\def\@skipmath##1##2$##3${%
\@skip@nonchangecase##1##2\NoCaseChange\valign
\ifx\valign##3%
\else
$##3$%
\expandafter\@skipmath\expandafter##1%
\fi}
% \end{macrocode}
% \end{macro}
%
%\begin{macro}{\@skip@nonchangecase}
% |#1|: |\uppercase| or |\lowercase|\\
% |#2|: Text up to the first command (such as |\cite|) made `safe'.
% or the first use of |\NoCaseChange|.
% \begin{macrocode}
\def\@skip@nonchangecase##1##2\NoCaseChange##3{%
##1{##2}%
\ifx\valign##3%
\else
##3%
\expandafter\@skip@nonchangecase\expandafter##1%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MakeTextUppercase}
% Put it all together. Arrange for \i\ and \j\ to uppercase, and
% to read the pairs in the ucase list `forwards'.
% \begin{macrocode}
\DeclareRobustCommand\MakeTextUppercase{%
\@uclcnotmath{\def\i{I}\def\j{J}}{####1####2}\uppercase}
% \end{macrocode}
%
% \begin{macrocode}
\protected@edef\MakeTextUppercase##1{\MakeTextUppercase{##1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MakeTextLowercase}
% Use |\lowercase| and read the pairs in the uppercase list `backwards'.
% \begin{macrocode}
\DeclareRobustCommand\MakeTextLowercase{%
\@uclcnotmath{}{####2####1}\lowercase}
% \end{macrocode}
%
% \begin{macrocode}
\protected@edef\MakeTextLowercase##1{\MakeTextLowercase{##1}}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
%%%% End copy from textcase.dtx
% \end{macrocode}
% \DeleteShortVerb{\|}
%
% \begin{macrocode}
} % end of \IfFileExists
% \end{macrocode}
%
% \section{Initialization} \label{sec:init}
%
% \subsection{Words and phrases}
%
% This document class is for documents prepared in the English language.
% To prepare a version for another language, various English words
% and phrases must
% be replaced. The English elements that require replacement are
% defined below in command names.
%
% \begin{macro}{\abstractname}
% \begin{macro}{\contentsname}
% \begin{macro}{\listfigurename}
% \begin{macro}{\listtablename}
% \begin{macro}{\bookname}
% \begin{macro}{\partname}
% \begin{macro}{\chaptername}
% \begin{macro}{\appendixname}
% \begin{macro}{\appendixtocname}
% \begin{macro}{\appendixpagename}
% \begin{macro}{\bibname}
% \begin{macro}{\indexname}
% \begin{macro}{\glossaryname}
%
% This list is for titles of document sections.
%
% \begin{macrocode}
\newcommand*{\abstractname}{Abstract}
\newcommand*{\contentsname}{Contents}
\newcommand*{\listfigurename}{List of Figures}
\newcommand*{\listtablename}{List of Tables}
\newcommand*{\bookname}{Book}
\newcommand*{\partname}{Part}
\newcommand*{\chaptername}{Chapter}
\newcommand*{\appendixname}{Appendix}
\newcommand*{\appendixtocname}{Appendices}
\newcommand*{\appendixpagename}{Appendices}
\newcommand*{\bibname}{Bibliography}
\newcommand*{\indexname}{Index}
\newcommand*{\glossaryname}{Glossary}
% \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}
%
% \begin{macro}{\figurename}
% \begin{macro}{\tablename}
% \begin{macro}{\figurerefname}
% \begin{macro}{\tablerefname}
% \begin{macro}{\pagename}
% \begin{macro}{\pagrefename}
%
% These are the names and phrases used for general elements.
%
% \begin{macrocode}
\newcommand*{\figurename}{Figure}
\newcommand*{\tablename}{Table}
\newcommand*{\figurerefname}{Figure}
\newcommand*{\tablerefname}{Table}
\newcommand*{\pagename}{page}
\newcommand*{\pagerefname}{page}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bookrefname}
% \begin{macro}{\partrefname}
% \begin{macro}{\chapterrefname}
% \begin{macro}{\sectionrefname}
% \begin{macro}{\appendixrefname}
% More names for referencing.
% \changes{v1.2}{2002/07/27}{Added \cs{partrefname}, \cs{chapterrefname}
% and \cs{sectionrefname}}
% \changes{v1.61803}{2008/01/30}{Added \cs{bookrefname} (mempatch v4.9+)}
% \changes{v1.61803}{2008/05/17}{Added \cs{appendixrefname}}
% \begin{macrocode}
\newcommand*{\bookrefname}{Book~}
\newcommand*{\partrefname}{Part~}
\newcommand*{\chapterrefname}{Chapter~}
\newcommand*{\sectionrefname}{\S}
\newcommand*{\appendixrefname}{Appendix~}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Date}
%
% \begin{macro}{\today}
% This macro uses the \TeX\ primitives \cs{month}, \cs{day} and \cs{year}
% to provide the date of the \LaTeX-run.
% \begin{macrocode}
\newcommand{\today}{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space\number\day, \number\year}
% \end{macrocode}
% \end{macro}
%
% \subsection{Two column mode}
%
% \begin{macro}{\columnsep}
% This gives the distance between two columns in two column mode.
% \begin{macrocode}
\setlength\columnsep{10\p@}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\columnseprule}
% This gives the width of the rule between two columns in two
% column mode. We have no visible rule.
% \begin{macrocode}
\setlength\columnseprule{0\p@}
% \end{macrocode}
% \end{macro}
%
% \subsection{Some counters}
% We set the sectional counters to zero, the \verb?tocdepth? to
% one (sections and above listed), the \verb?secnumdepth? to
% two (sections and above numbered), and \cs{maxsecnumdepth} to
% the same.
% \changes{v1.1a}{2002/04/28}{Added initialisation of \cs{maxsecnumdepth}}
% \begin{macrocode}
\setcounter{part}{0}
\setcounter{chapter}{0}
\setcounter{tocdepth}{1}
\setcounter{secnumdepth}{2}
\maxsecnumdepth{section}
% \end{macrocode}
%
% Set the \cs{linenumberfrequency} to zero to prohibit line numbering
% and also set the font for line numbers. Can now set the final space
% for boxed verbatim line numbers.
% \begin{macrocode}
\linenumberfrequency{0}
\linenumberfont{\small\rmfamily}
\settowidth{\bvnumlength}{\vlvnumfont 9999}
% \end{macrocode}
%
%
% \subsection{Single or double sided printing}
%
%
% Unless the \Lopt{twoside} wasn't specified, We do not try to make
% each page of equal height.
% \begin{macrocode}
\if@twoside
\else
\raggedbottom
\fi
% \end{macrocode}
% When the \Lopt{twocolumn} option was specified we call
% \cs{twocolumn} to activate this mode. We try to make each column as
% long as the others, but call \cs{sloppy} to make our life easier.
% \begin{macrocode}
\if@twocolumn
\twocolumn
\sloppy
\flushbottom
% \end{macrocode}
% Normally we call \cs{onecolumn} to initiate typesetting in one
% column.
% \begin{macrocode}
\else
\onecolumn
\fi
% \end{macrocode}
%
% \subsection{Floats}
%
% Here are the implementations of the figure and table environments
% and their accompanying List of\ldots
%
% \begin{environment}{figure}
% \begin{environment}{figure*}
% This is the definition of the actual environment. The form with the
% \verb?*? is used for double column figures. We use \cs{newfloat} to set it.
% In this class figures are numbered per chapter, but we need to change
% the default definition of \cs{thefigure} if a figure
% is in a pre-numbered chapter.
% \changes{v1.3a}{2002/11/22}{Added \cs{kill@lastcounter} after new
% figure float}
% \changes{v1.61803}{2008/01/30}{Killed \cs{kill@lastcounter} after new
% figure float}
% \begin{macrocode}
\newfloat[chapter]{figure}{lof}{\figurename}
%%% \kill@lastcounter{lofdepth}
\renewcommand{\thefigure}{\thechapter.\@arabic\c@figure}
% \end{macrocode}
% \end{environment}
% \end{environment}
%
% \begin{macro}{\listoffigures}
% \begin{macro}{\listoffigures*}
% These macros request that LaTeX produces a list of figures.
% The LoF heading is added to the ToC unless the starred
% version is used.
% \changes{v1.3}{2002/11/14}{Added \cs{kill@lastcounter} after new
% list of figures}
% \changes{v1.61803}{2008/01/30}{Killed \cs{kill@lastcounter} after new
% listoffigures}
% \begin{macrocode}
\newlistof{listoffigures}{lof}{\listfigurename}
%%% \kill@lastcounter{lofdepth}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@figure}
% \cs{l@figure}\marg{title}\marg{page} typesets the LoF entry for
% a \cs{figure} caption heading.
% \changes{v1.3a}{2002/11/22}{Deleted \cs{kill@lastcounter} after new
% figure listentry}
% \begin{macrocode}
\newlistentry[chapter]{figure}{lof}{0}
\cftsetindents{figure}{0em}{2.3em}
%% \kill@lastcounter{lofdepth}
% \end{macrocode}
% \end{macro}
%
%
% \begin{environment}{table}
% \begin{environment}{table*}
% The definition for tables is almost identical.
% \changes{v1.3a}{2002/11/22}{Added \cs{kill@lastcounter} after new
% table float}
% \changes{v1.61803}{2008/01/30}{Killed \cs{kill@lastcounter} after new
% table float}
% \begin{macrocode}
\newfloat[chapter]{table}{lot}{\tablename}
%%% \kill@lastcounter{lotdepth}
\renewcommand{\thetable}{\thechapter.\@arabic\c@table}
% \end{macrocode}
% \end{environment}
% \end{environment}
%
% \begin{macro}{\listoftables}
% \begin{macro}{\listoftables*}
% These macros request that LaTeX produces a list of tables.
% The LoT heading is added to the ToC unless the starred
% version is used.
% \changes{v1.3}{2002/11/14}{Added \cs{kill@lastcounter} after new
% list of tables}
% \changes{v1.61803}{2008/01/30}{Killed \cs{kill@lastcounter} after new
% list of tables}
% \begin{macrocode}
\newlistof{listoftables}{lot}{\listtablename}
%%% \kill@lastcounter{lotdepth}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@table}
% \cs{l@table}\marg{title}\marg{page} typesets the LoT entry for
% a \cs{table} caption heading.
% \changes{v1.3a}{2002/11/22}{Deleted \cs{kill@lastcounter} after new
% table listentry}
% \begin{macrocode}
\newlistentry[chapter]{table}{lot}{0}
\cftsetindents{table}{0em}{2.3em}
%% \kill@lastcounter{lotdepth}
% \end{macrocode}
% \end{macro}
%
% The \Lpack{subfigure} package defines \verb?lofdepth? and \verb?lotdepth?
% counters. If is not used, then we have to define them. The \Lpack{subfig}
% package replaced \Lpack{subfigure} in 2005, and this only defined
% the counters if they were not previously defined. It now seems sensible
% to ignore any use of the \Lpack{subfigure} package. This makes life a lot
% simpler.
% \changes{v1.61803}{2008/01/30}{Ignore subfig(ure) package re \cs{lofdepth}
% and \cs{lotdepth}}
% \begin{macrocode}
%%%\AtBeginDocument{%
%%% \@ifundefined{c@lofdepth}%
%%% {\newcounter{lofdepth}\setcounter{lofdepth}{1}}{}
%%% \@ifundefined{c@lotdepth}%
%%% {\newcounter{lotdepth}\setcounter{lotdepth}{1}}{}}
% \end{macrocode}
%
% \subsection{The \Lopt{article} option}
%
% The \Lopt{article} option requires changes to the default chapterstyle,
% and the numbering of floats, etc.
%
% Emanuele Vicentini (2003/07/21) suggested making \cs{maketitle} more
% closely match the real article's appearance.
% Alan Budden\footnote{\texttt{alan.s.budden@bristol.ac.uk}} commented
% on 2003/12/18 that the equation counter should be continuous.
% \changes{v1.0a}{2001/12/07}{Added footnote and chaptername changes to the article option}
% \changes{v1.4}{2003/11/22}{Added some resets of maketitle macros to
% the article option (from patch v1.7)}
% \changes{v1.4}{2003/12/18}{Added equation counter to article resets}
%
% Victor Ivrii\footnote{\texttt{vivrii@gmail.com}} (October 2014)
% noted that adding \pstyle{headings} and english \Lpack{babel}
% produce unexpected headers containing the frase ``Chapter''.
% \begin{macrocode}
\ifartopt
\chapterstyle{article}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\counterwithout{footnote}{chapter}
\counterwithout{equation}{chapter}
% \end{macrocode}
% Setting \cs{chaptername} empty was added in v1.0a, with no
% indication why. Because of \Lpack{babel} (and others) this is
% clearly not a good idea. We will adjust \pstyle{headings} in a
% different manner, but leave all the other page styles alone as using
% the \Lopt{article} as the basis of design work might not be
% recommended.
% \changes{v3.7d}{2014/11/05}{Redone \cs{chaptername} adjustment plus
% \pstyle{headings} under \Lopt{article} option}
% \begin{macrocode}
%\renewcommand{\chaptername}{}
\if@twoside
\addtopsmarks{headings}{}{%
\createmark{chapter}{left}{shownumber}{}{. \ }
}
\else
\addtopsmarks{headings}{}{%
\createmark{chapter}{right}{shownumber}{}{. \ }
}
\fi
\renewcommand{\maketitlehookb}{%
\vskip -1.5\topsep\vskip -1.5\partopsep}
\renewcommand{\maketitlehookc}{%
\vskip -1.5\topsep\vskip -1.5\partopsep}
\fi
% \end{macrocode}
%
%
% \subsection{The \Lopt{ms} option}
%
% This should be done last as it makes various changes to the defaults.
%
% \begin{macro}{\msdoublespacing}
% \begin{macro}{\mssinglespacing}
% These do nothing unless the \Lopt{ms} option is used; then they change
% the \cs{baselinestretch}.
% \begin{macrocode}
\newcommand{\msdoublespacing}{}
\newcommand{\mssinglespacing}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
\ifmsdoc
\renewcommand{\msdoublespacing}{%
\renewcommand{\baselinestretch}{1.6}\large\normalsize}
\renewcommand{\mssinglespacing}{%
\renewcommand{\baselinestretch}{1.0}\large\normalsize}
\renewcommand{\familydefault}{cmtt}
\renewcommand{\rmdefault}{cmtt}
\renewcommand{\sfdefault}{cmtt}
\renewcommand{\bfdefault}{m}
\renewcommand{\itdefault}{n}
\renewcommand{\sldefault}{n}
\renewcommand{\scdefault}{n}
\renewcommand{\baselinestretch}{1.6}
\@twocolumnfalse
\onecolumn
\sloppy
\@twosidefalse
\raggedbottom
\pagestyle{plain}
\fi
% \end{macrocode}
%
% \subsection{Emulated packages}
%
% Many of the `emulations' are extensions and integration of package
% facilities. In some cases an `emulated' package just won't work with the
% class, so I've added it here to prevent it from being loaded. In any case,
% most of the packages are mine.
% \changes{v1.6180339}{2008/07/23}{Added dates to emulated packages}
% \changes{v1.61803398d}{2010/02/13}{Emulated tocvsec2, used the date
% from the other lines, tocvsec2 provides the same macros as memoir}
% \begin{macrocode}
\EmulatedPackage{abstract}[2008/07/23]
\EmulatedPackage{appendix}[2008/07/23]
% \end{macrocode}
% \changes{v3.6k}{2012/07/19}{Changed the enumated date for the
% \Lpack{array} package. Apparently the only thing changed between
% v2.4b (2005) and c (2008) are some copyright years.}
% \changes{v3.7g}{2018/03/05}{Embedded the latest version of the
% \Lpack{array} package}
% \changes{v3.7h}{2018/09/06}{\Lpack{array} no longer embedded,
% required instead}
% \begin{macrocode}
% \EmulatedPackage{array}[2016/10/06]
\EmulatedPackage{booktabs}[2016/05/16]
\EmulatedPackage{ccaption}[2008/07/23]
\EmulatedPackage{changepage}[2008/07/23]
\EmulatedPackage{chngcntr}[2008/07/23]
\EmulatedPackage{chngpage}[2008/07/23]
\EmulatedPackage{crop}
% \end{macrocode}
% \changes{v3.7h}{2018/09/06}{\Lpack{dcolumn} is no longer embedded,
% emulation removed. We require it instead}
% \begin{macrocode}
% \EmulatedPackage{dcolumn}[2008/07/23]
% \end{macrocode}
% \changes{v3.7g}{2018/03/06}{Adjusted the date for \Lpack{delarray},
% the code is the same}
% \changes{v3.7h}{2018/09/06}{\Lpack{delarray} is no longer embedded,
% emulation removed. We require it instead}
% \begin{macrocode}
% \EmulatedPackage{delarray}[2014/10/28]
\EmulatedPackage{enumerate}[2008/07/23]
\EmulatedPackage{epigraph}[2008/07/23]
%%%%%\EmulatedPackage{framed}[2008/07/23]
\EmulatedPackage{ifmtarg}[2008/07/23]
% \end{macrocode}
% \changes{v3.7g}{2018/03/08}{Removed if\meta{engine} emulation}
% \begin{macrocode}
%\ifm@mifetex\EmulatedPackage{ifetex}[2008/07/23]\fi
%\ifm@mifluatex\EmulatedPackage{ifluatex}[2008/07/23]\fi
%\ifm@mifpdf\EmulatedPackage{ifpdf}[2008/07/23]\fi
%\ifm@mifxetex\EmulatedPackage{ifxetex}[2008/07/23]\fi
\EmulatedPackage{index}[2008/07/23]
\EmulatedPackage{makeidx}[2008/07/23]
\EmulatedPackage{moreverb}[2008/07/23]
% \end{macrocode}
% \changes{v3.7o}{2021/03/22}{removed mparhack emulation, as we don't
% emulate all of it, especially not the fix for \cs{if@firstcolumn},
% instead load it if twocolumn }
% \begin{macrocode}
\if@twocolumn
\RequirePackage{mparhack}
\fi
%\EmulatedPackage{mparhack}[2008/07/23]
\EmulatedPackage{needspace}[2008/07/23]
\EmulatedPackage{newfile}[2008/07/23]
\EmulatedPackage{nextpage}[2008/07/23]
\EmulatedPackage{pagenote}[2008/07/23]
\EmulatedPackage{parskip}[2008/07/23]
\EmulatedPackage{patchcmd}[2008/07/23]
\EmulatedPackage{setspace}[2008/07/23]
\EmulatedPackage{shortvrb}[2008/07/23]
\EmulatedPackage{showidx}[2008/07/23]
% \end{macrocode}
% \changes{v3.7g}{2018/03/02}{Updated the embedded version of \Lpack{tabularx} to v2.11 2016/02/03}
% \changes{v3.7h}{2018/09/08}{\Lpack{tabularx} is no longer emulated,
% but a required package}
% \begin{macrocode}
% \EmulatedPackage{tabularx}[2016/02/03]
\EmulatedPackage{titleref}[2008/07/23]
\EmulatedPackage{titling}[2008/07/23]
\EmulatedPackage{tocbibind}[2008/07/23]
\EmulatedPackage{tocloft}[2008/07/23]
\EmulatedPackage{tocvsec2}[2008/07/23]
\EmulatedPackage{verbatim}[2008/07/23]
\EmulatedPackage{verse}[2008/07/23]
% \end{macrocode}
%
% \subsection{Interaction with the \Lpack{caption} package}
%
% As of 2020, whenever the \Lpack{caption} package is loaded with the
% memoir class, it will map relevant memoir captioning macros onto the
% corresponding features provided by \Lpack{caption}. As this is now
% done automatically, we have removed the code that reset \cs{caption}
% to something more friendly to \Lpack{caption} in earler versions of
% the class.
%
% \changes{v3.7o}{2021/03/15}{removed code to reset for the caption package}
%
% \subsection{Interaction with the \Lpack{float} package}
%
% The \Lpack{float} package also defines \cs{newfloat}, so kill memoir's
% version when the \Lpack{float} package gets used.
% \changes{v1.61803}{2008/01/30}{Killed \cs{newfloat} when float package is
% used (mempatch v4.9)}
% \begin{macrocode}
\AtBeginPackage{float}{\let\newfloat\relax}
% \end{macrocode}
%
%
% \subsection{Interaction with the \Lpack{hyperref} package}
%
% Ulrike Fischer has ask that the \Lpack{memhfixc} autoload is moved
% from \Lpack{hyperref} to \Lpack{memoir}.
% \changes{v3.7q}{2022/02/20}{Added autoloading}
% \begin{macrocode}
\AtEndPackage{hyperref}{\RequirePackage{memhfixc}}
% \end{macrocode}
%
% \subsection{Default page style}
% We use the page style \pstyle{headings} by
% default and arabic page numbering. But if the \verb?article?
% class option is in effect, we will use the \pstyle{plain} style
% which is the default in the \verb?article? class.
% \changes{v3.6d}{2010/05/13}{When emulating the article class the
% plain page style should used instead of headings}
% \changes{v3.7i}{2019/01/07}{Moved here because
% \cs{newlistof}{...}{X}{...} also defines \cs{Xmark}, but using
% \cs{markboth}, and thus if \Lopt{oneside} is active \cs{lofmark}
% will still be using \cs{mathboth} and not \cs{markright} that the
% \pstyle{headings} style dictates}
% \begin{macrocode}
\ifartopt
\pagestyle{plain}
\else
\pagestyle{headings}
\fi
\pagenumbering{arabic}
% \end{macrocode}
% ^^A\subsection{Patch file}
% ^^A
% ^^A At the suggestion of Danie Els (\texttt{DanieEls@sun.ac.za}), Dan Leucking
% ^^A (\texttt{luecking@uark.edu}) and others, input a patch file, if one exists,
% ^^A as the final act. (This is preferable to my series of \file{memfixa.sty},
% ^^A \file{memfixb.sty} packages, and so on, for each release of the class.)
% ^^A \changes{v1.3}{2002/11/14}{Added input of mempatch.sty}
% ^^A \changes{v1.6180339c}{2008/12/26}{Added the two missing arguments when inputting
% ^^A mempatch.sty (courtesy of Wilhelm Muller)}
% ^^A \changes{v1.61803398}{2009/07/27}{PW: changed call to mempatch, which I think
% ^^A restores Lars' v1.6180339h change}
% ^^A \changes{v3.7g}{2018/03/08}{mempatch have been empty for almost
% ^^A 10years, we will no longer load it.}
% ^^A \begin{macrocode}
% ^^A\IfFileExists{mempatch.sty}{%
% ^^A \RequirePackage{mempatch}}{}
% ^^A
% ^^A \end{macrocode}
% ^^A
% The end of the class definitions.
% \begin{macrocode}
%</class>
% \end{macrocode}
%
% \section{Glossary Makeindex style file}
%
% Here is the basic style (configuration) file for Makeindex
% for use with the default glossary setup.
% \changes{v1.618}{2005/09/25}{Added basic.gst file}
%
% \begin{macrocode}
%<*gst>
%%%%% basic.gst basic makeindex glossary configuration file for memoir
%%%%% Output style parameters
preamble "\\begin{theglossary}"
postamble "\n\\end{theglossary}\n"
group_skip "\n\\glossaryspace\n"
item_0 "\n\\glossitem"
delim_0 "{\\memglonum{"
encap_suffix "}}}"
%%% Input style parameters
keyword "\\glossaryentry"
%</gst>
% \end{macrocode}
%
% The end of the configuration file code
%
% \bibliographystyle{alpha}
% \begingroup
% \raggedright
% \begin{thebibliography}{GMSN94A}
%
%
% \bibitem[ABH90]{bk:Impatient}
% Paul W.~Abrahams, Karl Berry and Kathryn A.~Hargreaves.
% \newblock \emph{TeX{} for the Impatient}.
% \newblock
% Addison-Wesley, Reading, Massachusetts, 1990.
% \newblock (Available from CTAN in \texttt{info/impatient})
%
% \bibitem[Ars01a]{TITLEREF}
% Donald Arseneau.
% \newblock \emph{\Lpack{Titleref} package (version 3.1)}.
% \newblock April 2001.
% \newblock (Available from CTN as
% \texttt{macros/latex/contrib/misc/titleref.sty})
%
% \bibitem[Ars01b]{CHAPTERBIB}
% Donald Arseneau.
% \newblock \emph{\Lpack{Chapterbib} package (version 1.9)}.
% \newblock September 2001.
% \newblock (Available from CTN as
% \texttt{macros/latex/contrib/misc/chapterbib.sty})
%
% \bibitem[Ars03]{FRAMED}
% Donald Arseneau.
% \newblock \emph{\Lpack{Framed} package (version 0.8a)}.
% \newblock July 2003.
% \newblock (Available from CTAN as
% \texttt{macros/latex/contrib/misc/framed.sty})
%
% \bibitem[Ars05]{PLACEINS}
% Donald Arseneau.
% \newblock \emph{\Lpack{Placeins} package (version 2.2)}.
% \newblock May 2005.
% \newblock (Available from CTN as
% \texttt{macros/latex/contrib/placeins/placeins.sty})
%
%
% \bibitem[ArWi00]{IFMTARG}
% Donald Arseneau and Peter Wilson.
% \newblock \emph{The ifmtarg package}.
% \newblock March, 2000.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/misc})
%
%
% \bibitem[Car94]{DELARRAY}
% David Carlisle.
% \newblock \emph{The \Lpack{delarray} package}.
% \newblock March 1994.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/required/tools})
%
%
% \bibitem[Car98a]{ENUMERATE}
% David Carlisle.
% \newblock \emph{The enumerate package}.
% \newblock August, 1998.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/required/tools})
%
% \bibitem[Car98b]{REMRESET}
% David Carlisle.
% \newblock \emph{The remreset package}.
% \newblock August, 1998.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/carlisle})
%
% \bibitem[Car99]{TABULARX}
% David Carlisle.
% \newblock \emph{The \Lpack{tabularx} package}.
% \newblock February 2016.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/required/tools})
%
% \bibitem[Car01]{DCOLUMN}
% David Carlisle.
% \newblock \emph{The \Lpack{dcolumn} package}.
% \newblock May, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/required/tools})
%
% \bibitem[Car19]{TEXTCASE}
% David Carlisle.
% \newblock \emph{The \Lpack{textcase} package}.
% \newblock September, 2019.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/textcase})
%
% \bibitem[Coc02]{SUBFIGURE}
% Steven Douglas Cochran.
% \newblock \emph{The subfigure package}.
% \newblock March, 2002.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/subfigure})
%
% \bibitem[Dal99]{NATBIB}
% Patrick W. Daly.
% \newblock \emph{Natural Sciences Citations and References}.
% \newblock May, 1999.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/natbib})
%
% \bibitem[Dow00]{PATCHCMD}
% Michael J. Downes
% \newblock \emph{The patchcmd package}.
% \newblock July 2000.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/patchcmd})
%
% \bibitem[Fai98]{MOREVERB}
% Robin Fairbairns.
% \newblock \emph{The moreverb package}.
% \newblock December, 1998.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/moreverb})
%
% \bibitem[Fai03]{FOOTMISC}
% Robin Fairbairns.
% \newblock \emph{\Lpack{footmisc} --- a portmanteau package for
% customising footnotes in LaTeX}.
% \newblock February 2003.
% \newblock (Available from CTAN in
% \texttt{macros/latex/contrib/footmisc})
%
%
% \bibitem[Fea03]{BOOKTABS}
% Simon Fear.
% \newblock \emph{Publication quality tables in \LaTeX}.
% \newblock March, 2003.
% \newblock (Available from CTAN in
% \texttt{macros/latex/contrib/booktabs})
%
% \bibitem[Fra00]{CROP}
% Melchior Franz.
% \newblock \emph{The crop package}.
% \newblock February, 2000.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/crop})
%
%
% \bibitem[GMS94]{GOOSSENS94}
% Michel Goossens, Frank Mittelbach, and Alexander Samarin.
% \newblock \emph{The LaTeX Companion}.
% \newblock Addison-Wesley Publishing Company, 1994.
%
%
%
% \bibitem[Knu84]{bk:knuth}
% Donald E. Knuth.
% \newblock \emph{The \TeX{}book}.
% \newblock
% Addison-Wesley, Reading, Massachusetts, 1984.
%
%
% \bibitem[KWG]{TUFTE}
% Bil Kleb, Bill Wood, and Kevin Godby.
% \newblock \emph{Tufte LaTeX}.
% \newblock December 2009.
% \newblock (Available from CTAN in \texttt{macros/latex/contrib/tufte-latex/})
%
% \bibitem[Lam94]{bk:lamport}
% Leslie Lamport.
% \newblock \emph{\LaTeX\ --- A Document Preparation System}.
% \newblock
% Addison-Wesley, Reading, Massachusetts, 1994.
%
% \bibitem[LMB99]{CLASSES}
% Leslie Lamport, Frank Mittelbach and Johannes Braams.
% \newblock \emph{Standard Document Classes for LaTeX version 2e}.
% \newblock September, 1999.
% \newblock (Available from CTAN as
% \texttt{/macros/latex/base/classes.dtx})
%
% \bibitem[LPT19]{IFTEX}
% The \LaTeX{} Project Team.
% \newblock \emph{The iftex package}.
% \newblock November, 2019.
% \newblock (Available from CTAN in \texttt{/macros/latex/contrib/iftex})
%
% \bibitem[MC98]{ARRAY}
% Frank Mittelbach and David Carlisle.
% \newblock \emph{A new implementation of LaTeX's tabular and array
% environment}
% \newblock April 2017.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/required/tools})
%
% \bibitem[Mit2020a]{LTFILEHOOK}
% Frank Mittelbach
% \newblock \emph{The ltfilehook package}
% \newblock July 2020.
%
% \bibitem[Mit2020b]{LTHOOKS}
% Frank Mittelbach
% \newblock \emph{The lthooks package}
% \newblock July 2020.
%
% \bibitem[Mit2020c]{LTSHIPOUT}
% Frank Mittelbach
% \newblock \emph{The ltshipout package}
% \newblock July 2020.
%
% \bibitem[Oos96]{FANCYHDR}
% Piet van Oostrum.
% \newblock \emph{Page layout in LaTeX}.
% \newblock June, 1996.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/fancyhdr})
%
%
% \bibitem[Rah01]{NAMEREF}
% Sebastian Rahtz.
% \newblock \emph{Section name references in LaTeX}.
% \newblock January 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/hyperref})
%
% \bibitem[Rah02]{HYPERREF}
% Sebastian Rahtz.
% \newblock \emph{Hypertext marks in LaTeX}.
% \newblock March 2002.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/hyperref})
%
%
% \bibitem[Sch98]{EVERYSHI}
% Martin Schr\"{o}der.
% \newblock \emph{The everyshi package}.
% \newblock August, 1998.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/ms})
%
% \bibitem[SRR01]{VERBATIM}
% Rainer Sch\"{o}pf, Bernd Raichle and Chris Rowley.
% \newblock \emph{A new implementation of LaTeX's verbatim and verbatim*
% environments}.
% \newblock March, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/required/tools})
%
% \bibitem[Wil99]{TOCVSEC2}
% Peter Wilson.
% \newblock \emph{The tocvsec2 package}.
% \newblock January, 1999.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/tocvsec2})
%
% \bibitem[Wil00a]{EPIGRAPH}
% Peter Wilson.
% \newblock \emph{The epigraph package}.
% \newblock February, 2000.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/epigraph})
%
% \bibitem[Wil00b]{ISOCLASS}
% Peter Wilson.
% \newblock \emph{LaTeX files for typesetting ISO standards}.
% \newblock February, 2000.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/isostds/iso})
%
% \bibitem[Wil00c]{NEXTPAGE}
% Peter Wilson.
% \newblock \emph{The nextpage package}.
% \newblock February, 2000.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/misc})
%
% \bibitem[Wil00d]{NEEDSPACE}
% Peter Wilson.
% \newblock \emph{The needspace package}.
% \newblock March, 2000.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/misc})
%
% \bibitem[Wil01a]{ABSTRACT}
% Peter Wilson.
% \newblock \emph{The abstract package}.
% \newblock February, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/abstract})
%
% \bibitem[Wil01b]{CHNGPAGE}
% Peter Wilson.
% \newblock \emph{The chngpage package}.
% \newblock February, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/misc})
%
% \bibitem[Wil01c]{APPENDIX}
% Peter Wilson.
% \newblock \emph{The appendix package}.
% \newblock March, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/appendix})
%
% \bibitem[Wil01d]{CCAPTION}
% Peter Wilson.
% \newblock \emph{The ccaption package}.
% \newblock March, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/ccaption})
%
% \bibitem[Wil01e]{CHNGCNTR}
% Peter Wilson.
% \newblock \emph{The chngcntr package}.
% \newblock March, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/misc})
%
% \bibitem[Wil01f]{HANGING}
% Peter Wilson.
% \newblock \emph{The hanging package}.
% \newblock March, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/hanging})
%
% \bibitem[Wil01g]{TITLING}
% Peter Wilson.
% \newblock \emph{The titling package}.
% \newblock March, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/titling})
%
% \bibitem[Wil01h]{TOCBIBIND}
% Peter Wilson.
% \newblock \emph{The tocbibind package}.
% \newblock April, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/tocbibind})
%
% \bibitem[Wil01i]{TOCLOFT}
% Peter Wilson.
% \newblock \emph{The tocloft package}.
% \newblock April, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/tocloft})
%
% \bibitem[Wil01j]{VERSE}
% Peter Wilson.
% \newblock \emph{Typesetting simple verse with LaTeX}.
% \newblock August, 2001.
% \newblock (Available from CTAN in
% \texttt{/macros/latex/contrib/verse})
%
%
% \bibitem[Wil03]{LEDMAC}
% Peter Wilson.
% \newblock \emph{\Lpack{ledmac}: A presumptuous attempt to port EDMAC and
% TABMAC to LaTeX}.
% \newblock August 2003.
% \newblock (Available from CTAN in
% \texttt{macros/latex/contrib/ledmac})
%
% \bibitem[Wil07]{GLISTER07}
% Peter Wilson.
% \newblock `Glisterings' \emph{TUGboat}, 28(2):229--232,
% \newblock 2007.
%
% \bibitem[Wil08]{GLISTER08}
% Peter Wilson.
% \newblock `Glisterings' \emph{TUGboat}, 29(2):324--327,
% \newblock 2008.
%
%
%
%
%
% \end{thebibliography}
% \endgroup
%
%
% \Finale
%
\endinput
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%% Digits \0\1\2\3\4\5\6\7\8\9
%% Exclamation \! Double quote \" Hash (number) \#
%% Dollar \$ Percent \% Ampersand \&
%% Acute accent \' Left paren \( Right paren \)
%% Asterisk \* Plus \+ Comma \,
%% Minus \- Point \. Solidus \/
%% Colon \: Semicolon \; Less than \<
%% Equals \= Greater than \> Question mark \?
%% Commercial at \@ Left bracket \[ Backslash \\
%% Right bracket \] Circumflex \^ Underscore \_
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%%
|