summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex-dev/base/doc.dtx
blob: 75e04cc299cd50c68408323a0b2668f316e5d578 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
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
% \iffalse meta-comment
%
% Copyright (C) 1993-2023
% The LaTeX Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the LaTeX base system.
% -------------------------------------------
%
% It 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 this license is in
%    https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% This file has the LPPL maintenance status "maintained".
%
% The list of all files belonging to the LaTeX base distribution is
% given in the file `manifest.txt'. See also `legal.txt' for additional
% information.
%
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
%
% \fi
% ^^A -*-LaTeX-*-
%
% ^^A These shouldn't come out in .ist files, hence the module
% ^^A comments, or in the printed version, hence temporary comment
% ^^A category for `<'
%\catcode`\<=14
%<+package|shortvrb>\NeedsTeXFormat{LaTeX2e}[1994/12/01]
%<+package>
%<+package>\providecommand\DeclareRelease[3]{}
%<+package>\providecommand\DeclareCurrentRelease[2]{}
%<+package>
%<+package>\DeclareRelease{v2.1g}{2016-02-15}
%<+package>                      {doc-2016-02-15.sty}
%<+package>\DeclareRelease{v2}{2021-06-01}
%<+package>                   {doc-2021-06-01.sty}
%<+package>\DeclareCurrentRelease{v3}{2022-06-01}
%<+package>
%<+package>\ProvidesPackage{doc}
%<+shortvrb>\ProvidesPackage{shortvrb}
%<+package|shortvrb>  [2022/11/13 v3.0m
%<+package|shortvrb>   Standard LaTeX documentation package V3 (FMi)]
%\catcode`\<=12
%
%%
%\iffalse    This is a METACOMMENT
%           Everything up to the next `\ fi' (without a blank) will
%           be ignored.  This is necessary because `%' may no longer
%           be a comment mark when this file is read in.
%
%
%% Package `doc' to use with LaTeX 2e
%% Copyright (C) 1989-2022 Frank Mittelbach, all rights reserved.
%
%
% Version:     Date:     Changes:
%
%  1.0a        5.5.88    This is nothing but a collection of tests and
%                        hacks. It is certainly going to be greatly
%                        changed.
%                        Better not to use it!
%  1.5a and earlier...   are not longer recorded
%  1.5b and higher...    are documented with the (undocumented) \changes
%                        feature.
%\fi
%  \changes{v1.5f}{1989/04/29}{Thanks to Brian who documented the
%                          \cs{changes} macro feature.}
%  \changes{v1.5g}{1989/05/07}{MacroTopsep now called MacrocodeTopsep and
%                          new MacroTopsep added}
%  \changes{v1.5h}{1989/05/17}{All lines shortened to <72 characters}
%  \changes{v1.5j}{1989/06/09}{Corrections by Ron Whitney added}
%  \changes{v1.5q}{1989/11/03}{`\ldots{}Listing macros renamed to
%                         `\ldots{}Input. Suggested by R. Wonneberger}
%  \changes{v1.5w}{1990/02/05}{Counter codelineno renamed to CodelineNo}
%  \changes{v1.9a}{1993/12/02}{Upgrade for LaTeX2e}
%  \changes{v1.9d}{1993/12/20}{Protected changes entry.}
%  \changes{v1.0p}{1994/05/21}{Use new error commands}
%  \changes{v3.0m}{2022/11/13}{Redefinitions of \cs{verb} removed as
%     no longer needed (gh/953)}
%
%
% \hyphenation{make-index}
%
% \DoNotIndex{\@,\@@par,\@beginparpenalty,\@empty}
% \DoNotIndex{\@flushglue,\@gobble,\@input}
% \DoNotIndex{\@makefnmark,\@makeother,\@maketitle}
% \DoNotIndex{\@namedef,\@ne,\@spaces,\@tempa}
% \DoNotIndex{\@tempb,\@tempswafalse,\@tempswatrue}
% \DoNotIndex{\@thanks,\@thefnmark,\@topnum}
% \DoNotIndex{\@@,\@elt,\@forloop,\@fortmp,\@gtempa,\@totalleftmargin}
% \DoNotIndex{\",\/,\@ifundefined,\@nil,\@verbatim,\@vobeyspaces}
% \DoNotIndex{\|,\~,\ ,\active,\advance,\aftergroup,\begingroup,\bgroup}
% \DoNotIndex{\mathcal,\csname,\def,\documentstyle,\dospecials,\edef}
% \DoNotIndex{\egroup}
% \DoNotIndex{\else,\endcsname,\endgroup,\endinput,\endtrivlist}
% \DoNotIndex{\expandafter,\fi,\fnsymbol,\futurelet,\gdef,\global}
% \DoNotIndex{\hbox,\hss,\if,\if@inlabel,\if@tempswa,\if@twocolumn}
% \DoNotIndex{\ifcase}
% \DoNotIndex{\ifcat,\iffalse,\ifx,\ignorespaces,\index,\input,\item}
% \DoNotIndex{\jobname,\kern,\leavevmode,\leftskip,\let,\llap,\lower}
% \DoNotIndex{\m@ne,\next,\newpage,\nobreak,\noexpand,\nonfrenchspacing}
% \DoNotIndex{\obeylines,\or,\protect,\raggedleft,\rightskip,\rm,\sc}
% \DoNotIndex{\setbox,\setcounter,\small,\space,\string,\strut}
% \DoNotIndex{\strutbox}
% \DoNotIndex{\thefootnote,\thispagestyle,\topmargin,\trivlist,\tt}
% \DoNotIndex{\twocolumn,\typeout,\vss,\vtop,\xdef,\z@}
% \DoNotIndex{\,,\@bsphack,\@esphack,\@noligs,\@vobeyspaces,\@xverbatim}
% \DoNotIndex{\`,\catcode,\end,\escapechar,\frenchspacing,\glossary}
% \DoNotIndex{\hangindent,\hfil,\hfill,\hskip,\hspace,\ht,\it,\langle}
% \DoNotIndex{\leaders,\long,\makelabel,\marginpar,\markboth,\mathcode}
% \DoNotIndex{\mathsurround,\mbox,\newcount,\newdimen,\newskip}
% \DoNotIndex{\nopagebreak}
% \DoNotIndex{\parfillskip,\parindent,\parskip,\penalty,\raise,\rangle}
% \DoNotIndex{\section,\setlength,\TeX,\topsep,\underline,\unskip,\verb}
% \DoNotIndex{\vskip,\vspace,\widetilde,\\,\%,\@date,\@defpar}
% \DoNotIndex{\[,\{,\},\]}
% \DoNotIndex{\count@,\ifnum,\loop,\today,\uppercase,\uccode}
% \DoNotIndex{\baselineskip,\begin,\tw@}
% \DoNotIndex{\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k,\l,\m,\n,\o,\p,\q}
% \DoNotIndex{\r,\s,\t,\u,\v,\w,\x,\y,\z,\A,\B,\C,\D,\E,\F,\G,\H}
% \DoNotIndex{\I,\J,\K,\L,\M,\N,\O,\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z}
% \DoNotIndex{\1,\2,\3,\4,\5,\6,\7,\8,\9,\0}
% \DoNotIndex{\!,\#,\$,\&,\',\(,\),\+,\.,\:,\;,\<,\=,\>,\?,\_}
% \DoNotIndex{\discretionary,\immediate,\makeatletter,\makeatother}
% \DoNotIndex{\meaning,\newenvironment,\par,\relax,\renewenvironment}
% \DoNotIndex{\repeat,\scriptsize,\selectfont,\the,\undefined}
% \DoNotIndex{\arabic,\do,\makeindex,\null,\number,\show,\write,\@ehc}
% \DoNotIndex{\@author,\@ehc,\@ifstar,\@sanitize,\@title,\everypar}
% \DoNotIndex{\if@minipage,\if@restonecol,\ifeof,\ifmmode}
% \DoNotIndex{\lccode,\newtoks,\onecolumn,\openin,\p@,\SelfDocumenting}
% \DoNotIndex{\settowidth,\@resetonecoltrue,\@resetonecolfalse,\bf}
% \DoNotIndex{\clearpage,\closein,\lowercase,\@inlabelfalse}
% \DoNotIndex{\selectfont,\mathcode,\newmathalphabet,\rmdefault}
% \DoNotIndex{\bfdefault}
%
% \MakeShortVerb{\|}
% \setcounter{StandardModuleDepth}{1}
%
% {\catcode`\p=12 \catcode`\t=12 ^^A hack used later on to print
% \gdef\dimenvalue#1pt{$#1$pt}}  ^^A a register value with a - sign
%
% \newcommand{\DOC}{\texttt{doc}\xspace}
%
% \changes{v3.0j}{2022/06/02}{Use \cs{providecommand} to define \cs{pkg}}
% \providecommand\env{\texttt}
% \providecommand\opt{\texttt}
% \providecommand\cls{\texttt}
% \providecommand\pkg{\texttt}
% \providecommand\prg{\textsf}
%
% \newcommand\DOX{\env{DoX}\xspace}
% \newcommand\api{\textsc{api}\xspace}
%
% \newcommand\fmi[1]{\par\textbf{TODO: }\textit{#1}\par}
%
% \newcommand\NewIn[1]{\leavevmode
%         \marginpar{\hfill\fbox{\fbox{New in #1}}\hspace*{1em}}\ignorespaces}
%
%
%\RenewDocElement[macrolike = true ,
%		 toplevel  = false,
%                idxtype   = ,
%                idxgroup  = LaTeX comands\actualchar\LaTeX{} commands ,
%                printtype =
%               ]{Macro}{macro}
%
%\RenewDocElement[macrolike = false ,
%		 toplevel  = false,
%                idxtype   = env.  ,
%                idxgroup  = Package environments,
%                printtype = \textit{env.}
%               ]{Env}{environment}
%
%
%\NewDocElement[macrolike = true ,
%               toplevel  = false,
%               idxtype   = ,
%               idxgroup  = Package commands,
%               printtype =
%               ]{InterfaceMacro}{imacro}
%
%\NewDocElement[macrolike = true ,
%		 toplevel  = false,
%                idxtype   = ,
%                idxgroup  = Package commands (obsolete),
%                printtype =
%               ]{ObsoleteInterfaceMacro}{omacro}
%
%\NewDocElement[macrolike = false ,
%		 toplevel  = false,
%                idxtype   =  counter  ,
%                idxgroup  = LaTeX counters\actualchar \LaTeX{} counters ,
%                printtype = \textit{counter}
%               ]{LaTeXCounter}{lcounter}
%
%\NewDocElement[macrolike = true ,
%		 toplevel  = false,
%                idxtype   =  counter  ,
%                idxgroup  = TeX counters\actualchar \protect\TeX{} counters ,
%                printtype = \textit{counter}
%               ]{TeXCounter}{tcounter}
%
%
%\NewDocElement[macrolike = true ,
%		 toplevel  = false,
%                idxtype   =  skip  ,
%                idxgroup  = LaTeX length\actualchar \LaTeX{} length (skip) ,
%                printtype = \textit{skip}
%               ]{LaTeXSkip}{lskip}
%
%\NewDocElement[macrolike = true ,
%		 toplevel  = false,
%                idxtype   =  dimen  ,
%                idxgroup  = LaTeX length\actualchar \LaTeX{} length (dimen) ,
%                printtype = \textit{dimen}
%               ]{LaTeXDimen}{ldimen}
%
%\NewDocElement[macrolike = false ,
%		 toplevel  = false,
%                idxtype   = option  ,
%                idxgroup  = Package options ,
%                printtype = \textit{option}
%               ]{Option}{option}
%
% \renewcommand\code[1]{\mbox{$\ell$-#1}}
% \renewcommand\main[1]{\underline{\mbox{$\ell$-#1}}}
% \setcounter{IndexColumns}{2}
%
%
% \changes{v1.9t}{1995/05/11}{Use \cs{GetFileInfo}}
% \GetFileInfo{doc.sty}
%
% \CheckSum{0}  ^^A % keep the checksum in this file but not now :-)
%
% \title{The \DOC{} and \texttt{shortvrb} Packages\thanks
%    {This file has version number \fileversion{} dated \filedate{}.}}
% \author{Frank Mittelbach\thanks{Further commentary added at Royal
%        Military College of Science by B. Hamilton Kelly; English
%        translation of parts of the original German commentary
%        provided by Andrew Mills; fairly substantial additions,
%        particularly from \texttt{newdoc},  and
%        documentation of post-v1.5q features added at v1.7a by Dave
%        Love (SERC Daresbury Lab).}~\thanks
%        {Extraction of \texttt{shortvrb}
%        package added by Joachim Schrod (TU~Darmstadt).}~\thanks
%        {Version~3 now integrates code from Didier Verna's
%        \DOX package and some of his documentation was
%        reused (a.k.a.\ stolen).}}
% \date{Printed \today}
%
% \MaintainedByLaTeXTeam{latex}
%
% \maketitle
%
% \begin{abstract}
%    Roughly 30 years ago (version 1.0 was dated 1988/05/05) I wrote
%    the first version of the \DOC package, a package to provide code
%    documentation for \TeX{} code. Since then it has been used all
%    over the place to document the \LaTeX{} kernel and most of the
%    packages that are nowadays available. The core code of version 2
%    (which is the current version) exists since 1998, i.e., for 20
%    years.
%
%    If I would restart from scratch I would do a lot of things
%    differently these days and in fact several other people have
%    tried to come up with better solutions. However, as the saying
%    goes, a bad standard is better than none, \DOC has prevailed and
%    changing it now in incompatible ways is probably not really
%    helpful.
%
%    So this is version 3 of the package with some smaller extensions
%    that are upwards compatible but hopefully serve well. Most
%    important modifications are the integration of the
%    \pkg{hypdoc} package to enable links within the document (in
%    particular from the index) if so desired. Also integrated are the
%    ideas from the \DOX package by Didier Verna (although I
%    offer a different interface that imho fits better with the rest
%    of \DOC's interfaces). Finally I updated a few odds and ends.
% \end{abstract}
%
%
% \newpage
%
% \addtocontents{toc}{\protect\begin{multicols}{2}}
%
% ^^A{\parskip 0pt                ^^A We have to reset \parskip
%                              ^^A (bug in \LaTeX)
% \tableofcontents
% ^^A}
%
% \changes{v1.7a}{1992/02/25}{Miscellaneous small changes to the text}
% \changes{v3.0a}{2018/03/04}{Integrated DoX package}
% \changes{v3.0a}{2018/03/04}{Interfaced hypdoc package}
%
%
%
% \section{Introduction}
%
% This is a new version of the \DOC package, written roughly 30 years
% after the initial release. As the package has been used for so long
% (and largely unchanged)
% it is absolutely important to preserve existing interfaces, even if
% we can agree that they could have been done better.
%
% So this is a light-weight change, basically adding hyperlink support
% and adding a way to provide generally \DOC elements (not just macros
% and environments) and try to do this properly (which wasn't the case
% for environments either in the past). The ideas for this have been
% stolen from the \DOX package by Didier Verna even though I
% didn't keep his interfaces.
%
% Most of the documentation below is from the earlier release  which
% accounts for some inconsistencies in presentation, mea culpa.
%
%
% \section{The User Interface}\label{sec:interface}
% \subsection{The driver file}
%
% If one is going to document a set of macros with the \DOC{}
% package one has to prepare a special driver file which produces the
% formatted document. This driver file has the following
% characteristics:
% \begin{quote}
% \noindent |\documentclass|\oarg{options}^^A
%           \marg{document-class}\\[1pt]
% |\usepackage{doc}|\\[3pt]
% \hspace*{10pt}\meta{preamble}\\[3pt]
% |\begin{document}|\\[3pt]
% \hspace*{10pt}\meta{special input commands}\\[3pt]
% |\end{document}|
% \end{quote}
% The \meta{document-class} might be any document class, I usually
% use \texttt{article}.
%
% In the \meta{preamble} one should place declarations which
% manipulate the behavior of the \DOC{} package like
% |\DisableCrossrefs| or |\OnlyDescription|.
%
%
% \DescribeInterfaceMacro\DocInput \DescribeInterfaceMacro\IndexInput
% Finally
% the \meta{special input commands} part should contain one or
% more |\DocInput|\marg{file name} and/or
% |\IndexInput|\marg{file name} commands.  The
% |\DocInput| command is used for files prepared for the
% \DOC{} package whereas |\IndexInput| can be used for all kinds of
% macro files.  See page \pageref{..Input} for more details of
% |\IndexInput|.  Multiple |\DocInput|s can be used with a
% number of included files which are each self-contained
% self-documenting packages---for instance, each containing
% |\maketitle|.
%
% As an example, the driver file for the \DOC{} package itself is
% the following text surrounded by |%<*driver>| and |%</driver>|.
% To produce the documentation you can simply run the \texttt{.dtx}
% file through \LaTeX{} in which case this code will be executed
% (loading the document class \texttt{ltxdoc}, etc.) or you can
% extract this into a separate file by using
% the \texttt{docstrip} program.
% The line numbers below are added by
% \DOC{}'s formatting.
% Note that the class \cls{ltxdoc} has the \DOC{} package
% preloaded.
% \changes{v1.7a}{1992/03/06}{Added
%                 docstrip-derivable driver file as example.}
% \changes{v1.7c}{1992/04/01}{Expurgated ltugboat.sty from driver.}
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}

\usepackage[T1]{fontenc}
\usepackage{xspace}          

\OnlyDescription

\EnableCrossrefs
 %\DisableCrossrefs     % Say \DisableCrossrefs if index is ready
\CodelineIndex
\RecordChanges          % Gather update information
\SetupDoc{reportchangedates}
 %\OnlyDescription      % comment out for implementation details
\setlength\hfuzz{15pt}  % don't show so many
\hbadness=7000          % over- and underfull box warnings
\begin{document}
   \DocInput{doc.dtx}
\end{document}
%</driver>
%    \end{macrocode}
%
% \RecordIndexType{\CodelineIndex}{InterfaceMacro}
% \RecordIndexType{\DisableCrossrefs}{InterfaceMacro}
% \RecordIndexType{\DocInput}{InterfaceMacro}
% \RecordIndexType{\EnableCrossrefs}{InterfaceMacro}
% \RecordIndexType{\OnlyDescription}{InterfaceMacro}
% \RecordIndexType{\RecordChanges}{InterfaceMacro}
% \RecordIndexType{\hbadness}{TeXCounter}
% \RecordIndexType{\hfuzz}{LaTeXDimen}
%
%
% \subsection{Package options}
%
% \NewIn{v3}
% Starting with version~3 the \DOC package now offers a small number
% of package options to modify its overall behavior. These are:
% \DescribeOption[noprint]{multicol}
% \DescribeOption[noprint]{nomulticol}
% \DescribeOption[noprint]{hyperref}
% \DescribeOption[noprint]{nohyperref}
% \DescribeOption[noprint]{debugshow}
% \DescribeOption[noprint]{noindex}
% \DescribeOption[noprint]{noprint}
% \DescribeOption[noprint]{reportchangedates}
% \begin{description}
% \item[\opt{hyperref}, \opt{nohyperref}] Boolean (default \texttt{true}). Load the
%    \pkg{hyperref} package and make index references to code lines
%    and pages and other items clickable links. \opt{nohyperref} is
%    the complementary key.
%
% \item[\opt{multicol}, \opt{nomulticol}] Boolean (default \texttt{true}). Load the
%    \pkg{multicol} package for use in typesetting the index and the
%    list of changes. \opt{nomulticol} is
%    the complementary key.
%
% \item[\opt{debugshow}] Boolean (default \texttt{false}). Provide
%    various tracing information at the terminal and in the transcript
%    file. In particular show which elements are indexed.
%
% \item[\opt{noindex}] Boolean (default \texttt{false}). If set, all
%    automatic indexing is suppressed. This option can also be used on
%    individual elements as described below.
%
% \item[\opt{noprint}] Boolean (default \texttt{false}). If set, then
%    printing of element names in the margin will be suppressed. This
%    option can also be used on individual elements as described
%    below.
% \item[\opt{reportchangedates}] Boolean (default \texttt{false}). If
%    set, then change entries list the date after the version number in
%    the change log.
% \end{description}
%
% \DescribeInterfaceMacro{\SetupDoc} Instead of providing options to the \DOC
%    package you can call \cs{SetupDoc} and provide them there. This
%    allows, for example,  to change default values in case \DOC was already
%    loaded earlier.
%
%
%
% \subsection{General conventions}
%
% A \TeX{} file prepared to be used with the `doc' package
% consists of `documentation parts' intermixed with `definition
% parts'.
%
% Every line of a `documentation part' starts with a percent sign
% (|%|) in column one.  It may contain arbitrary \TeX{} or
% \LaTeX{} commands except that the character `|%|' cannot be
% used as a comment character.
% \SortIndex{\string^\string^A}{\string\verb\verbatimchar
% \string^\string^A\verbatimchar \encapchar usage}^^A
% \SortIndex{\string^\string^X}{\string\verb\verbatimchar
% \string^\string^X\verbatimchar \encapchar usage}
% To allow user
% comments, the characters |^^A| and |^^X| are both defined as a comment character
% later on.\footnote{In version 2 it was only
%    \texttt{\string^\string^A}, but many keyboards combine
%    \texttt{\string^} and \texttt{A} and automatically turn it into
%    ``Ä''; so \texttt{\string^\string^X} was added as an
%    alternative in version 3.}
% Such `metacomments' may be also be included simply by
% surrounding them with |\iffalse| \ldots~|\fi|.
%
% All other parts of the file are called `definition parts'.  They
% contain fractions of the macros described in the `documentation
% parts'.
%
% If the file is used to define new macros (e.g.\ as a package file in
% the |\usepackage| macro), the `documentation parts' are
% bypassed at high speed and the macro definitions are pasted
% together, even if they are split into several `definition parts'.
%
% \DescribeEnv{macrocode}
% On the other hand, if the documentation of these macros is to be
% produced, the `definition parts' should be typeset verbatim. To
% achieve this, these parts are surrounded by the \env{macrocode}
% environment.
% More exactly: before a `definition part' there should be a line
% containing
% \begin{flushleft}
%   \hspace*{\MacroIndent}\verb*+%    \begin{macrocode}+
% \end{flushleft}
% and after this part a line
% \begin{flushleft}
%   \hspace*{\MacroIndent}\verb*+%    \end{macrocode}+
% \end{flushleft}
% There must be {\em exactly\/} four spaces between the |%|
% and |\end{macrocode}| --- \TeX{} is looking for this string
% and not for the macro while processing a `definition part'.
%
% Inside a `definition part' all \TeX{} commands are allowed; even the
% percent sign could be used to suppress unwanted spaces etc.
%
% \DescribeEnv{macrocode*} Instead of the \env{macrocode}
% environment one can also use the \env{macrocode$*$} environment
% which produces the same results except that spaces are printed as
% \nopagebreak\verb*+ + characters.
%
%
%
% \subsection{Describing the usage of macros and environments}
%
% \DescribeInterfaceMacro\DescribeMacro
% When you describe a new macro you may use |\DescribeMacro| to
% indicate that at this point the usage of a specific macro is
% explained. It takes one argument which will be printed in the margin
% and also produces a special index entry.  For example, I used
% |\DescribeMacro{\DescribeMacro}| to make clear that this is the
% point where the usage of |\DescribeMacro| is explained.
%
% As the argument to |\DescribeMacro| is a command name, many people
% got used to using the (incorrect) short form, i.e., omitting the
% braces around the argument as in |\DescribeMacro\foo|. This does
% work as long as the macro name consists only of ``letters''.
% However, if the name contains special characters that are normally
% not of type ``letter'' (such as |@|, or in case of \pkg{expl3} |_|
% and |:|) this will fail dramatically. |\DescribeMacro| would then
% receive only a partial command name (up to the first ``non-letter'')
% e.g., |\DescribeMacro\foo@bar| would be equivalent to
% |\DescribeMacro{\foo} @bar| and you can guess that this can
% resulting in both incorrect output and possibly low-level error
% messages.
%
% \DescribeInterfaceMacro\DescribeEnv
% An analogous macro |\DescribeEnv| should be used to indicate that a
% \LaTeX{} environment is explained. It will produce a somewhat
% different index entry and a slightly different display in the
% margin. Below I used |\DescribeEnv{verbatim}|.
%
%
% \NewIn{v3}
% Starting with version~3 the \cs{Describe...} commands accept an
% optional argument in which you can specify either \opt{noindex}
% or \opt{noprint} to suppress indexing or printing for that
% particular instance. Using both would be possible too, but pointless
% as then the commands wouldn't do anything any more.
%
%
% \subsection{Describing the definition of macros and environments}
%
% \DescribeEnv{macro}
% To describe the definition of a (new) macro we use the \env{macro}
% environment. It has one argument: the name of the new
% macro.\footnote{This is a change to the style design I described in
%                ^^A \TUB ^^A removed in case ltugboat.sty not used
%                \textsl{TUGboat\/}\ 10\#1 (Jan.~89). We finally decided
%                that it would
%                be better to use the macro name {\em with\/} the
%                backslash as an argument.}
% This argument is also used to print the name in the margin and to
% produce an index entry.
% Actually the index entries for usage and definition are different to
% allow an easy reference.
% This environment might be nested. In this case the
% labels in the margin are placed under each other.
% \changes{v1.7a}{1992/02/26}{Note on need for some text in macro env.}
% There should be some text---even  if it's just an empty
% |\mbox{}|---in this environment before |\begin{macrocode}| or the
% marginal label won't print in the right place.
%
% \NewIn{v3}
% In fact it is now allowed to specify several macros in the argument,
% separated by commas. This is a short form for starting several
% \env{macro} environments in direct succession. Of course, you
% should then have also only one matching |\end{macro}|.
%
% \DescribeLaTeXSkip\MacrocodeTopsep
% \DescribeLaTeXSkip\MacroTopsep
% There also exist four style parameters: |\MacrocodeTopsep| and
% |\MacroTopsep| are used to control the vertical spacing above
% and below the \env{macrocode} and the \env{macro}
% \DescribeLaTeXDimen\MacroIndent
% environment, |\MacroIndent| is used to indent the lines of code
% and
% \DescribeInterfaceMacro\MacroFont \label{sec:macrofont}
% |\MacroFont| holds the font and a possible size change command
% for the code lines, the |verbatim|[|*|] environment and the macro
% names printed in the margin.  If you want
% to change their default values in a
% class file (like \texttt{ltugboat.cls}) use the |\DocstyleParms|
% command described below. Starting with release 2.0a it can now
% be changed directly as long as the redefinition happens before
% the |\begin{document}|.
%
% \DescribeEnv{environment}
% For documenting the definition of environments one can use the
% environment \texttt{environment} which works like the \texttt{macro}
% environment, except that it expects an \meta{env-name}
% (without a backslash)
% as its argument and internally provides different index
% entries suitable for environments.
% Nowadays you can alternatively specify a comma-separated list of environments.
%
% \NewIn{v3}
% Starting with version~3 these environments accept an optional
% argument in which you can specify \opt{noindex} or \opt{noprint} or
% both to suppress indexing or printing for that particular
% instance. If any such setting is made on the environment level it
% overwrites whatever default was given when the \DOC element was
% defined or when the package was loaded.
%
%
%
%
% \subsection{Formatting names in the margin}
%
% \DescribeInterfaceMacro\PrintDescribeMacro
% \DescribeInterfaceMacro\PrintDescribeEnv
% \DescribeInterfaceMacro\PrintMacroName
% \DescribeInterfaceMacro\PrintEnvName
% As mentioned earlier, some macros and environment
% print their arguments in the margin. The actual formatting is done by four
% macros which are user
% definable.\footnote{You may place the changed definitions in a
%                     separate package
%                     file or at the beginning of the documentation
%                     file.
%                     For example, if you don't like any names in the
%                     margin
%                     but want a fine index you can simply redefine them
% accept their argument and do nothing with it.}
% They are named |\PrintDescribeMacro| and |\PrintDescribeEnv| (defining
% how |\DescribeMacro| and |\DescribeEnv| behave) and
% |\PrintMacroName| and
% |\PrintEnvName| (called by the \env{macro} and \env{environment}
% environments, respectively).
%
%
% \subsection{Providing further documentation items}
%
% Out of the box the \DOC package offers the above commands and
% environments to document macros and environments.
% \NewIn{v3}
% With version 3
% this has now been extended in a generic fashion so that you can
% easily provide your own items, such as counters, length register,
% options etc.
%
% \DescribeInterfaceMacro{\NewDocElement}
% The general syntax for providing a new \DOC element is
% \begin{quote}
%   \cs{NewDocElement}\oarg{options}\marg{element-name}\marg{env-name}
% \end{quote}
% By convention the \meta{element-name} has the first letter
% uppercased as in \texttt{Env} or \texttt{Macro}.
%
% Such a declaration will define for you
% \begin{itemize}
% \item the command |\Describe|\meta{element-name} which has the
%    syntax
%    \begin{quote}
%      |\Describe|\meta{element-name}\oarg{options}\marg{element}
%    \end{quote}
%
% \item the environment \meta{env-name} which has the syntax
%    \begin{quote}
%      \cs{begin}\marg{env-name}\oarg{options}\marg{element}
%    \end{quote}
%
% \item the display command |\PrintDescribe|\meta{element-name} with
%    the syntax
%    \begin{quote}
%      |\PrintDescribe|\meta{element-name}\marg{element}
%    \end{quote}
%
% \item and the
% |\Print|\meta{element-name}|Name|  display command for the
% environment.
% \end{itemize}
% If any of the commands or the environment is already defined (which
% especially with the \meta{env-name} is a danger) then you will
% receive an error telling you so.
%
% \DescribeInterfaceMacro{\RenewDocElement}
% If you want to modify an existing \DOC element use
% |\RenewDocElement| instead.
%
% For example, the already provided ``\texttt{Env}'' \DOC element could have been
% defined simply by making the declaration
%   |\NewDocElement{Env}{environment}|
% though that's not quite what has been done, as we will see later.
%
% \DescribeOption[noprint]{macrolike}
% \DescribeOption[noprint]{envlike}
% \DescribeOption[noprint]{toplevel}
% \DescribeOption[noprint]{notoplevel}
% \DescribeOption[noprint]{idxtype}
% \DescribeOption[noprint]{printtype}
% \DescribeOption[noprint]{idxgroup}
% The \meta{options} are keyword/value and define further details on
% how that \DOC element should behave. They are:
% \begin{description}
% \item[\opt{macrolike}] Boolean (default \opt{false}). Does this \DOC
%   element starts with a backslash?
%
% \item[\opt{envlike}] Boolean. Complementary option to
%   \opt{macrolike}.
%
% \item[\opt{toplevel}] Boolean (default \opt{true}). Should all
%   a top-level index entry be made? If set to \texttt{false} then
%   either no index entries are produced or only grouped index entries
%   (see \opt{idxgroup} for details).
%
% \item[\opt{notoplevel}] Boolean.  Complementary option to
%   \opt{toplevel}.
%
% \item[\opt{idxtype}] String (default \meta{env-name}). What to put
%   (in parentheses if non-empty) at the end of a top-level index entry.
%
% \item[\opt{printtype}] String (default \meta{env-name}). What to put
%   (in parentheses if non-empty) after an element name in the margin.
%
% \item[\opt{idxgroup}] String (default
%   \meta{env-name}\texttt{s}). Name of the top-level index entry if
%   entries are grouped. They are only grouped if this option is
%   non-empty.
%
% \item[\opt{noindex}] Boolean (default \texttt{false}).  If set this
%   will suppress indexing for elements of this type. This setting
%   overwrite any global setting of \opt{noindex}.
%
% \item[\opt{noprint}] Boolean (default \texttt{false}).  If set this
%   will suppress printing the element name in the margin. This setting
%   overwrite any global setting of \opt{noprint}.
% \end{description}
% As usual giving a boolean option without a value sets it to
% \texttt{true}.




% \subsection{Displaying sample code verbatim}
%
% \DescribeEnv{verbatim}
% It is often a good idea to include examples of the usage of new macros
% in the text. Because of the |%| sign in the first column of every
% row, the \env{verbatim} environment is slightly altered to suppress
% those
% characters.\footnote{These macros were written by Rainer
%                      Schöpf~\cite{art:verbatim}. He also
%                      provided a new \env{verbatim} environment
%                      which can be used inside of other macros.}
% \DescribeEnv{verbatim*}
% The \env{verbatim$*$} environment is changed in the same way.
% \changes{v1.7a}{1992/02/26}{Documented \cs{verb} change.}
% \DescribeInterfaceMacro\verb
% The |\verb| command is re-implemented to give an error report if a
% newline appears in its argument.
% The \env{verbatim} and \env{verbatim$*$} environments set text
% in the style defined by |\MacroFont|~(\S\ref{sec:macrofont}).
%
%

% \subsection{Using a special escape character}
%
% \DescribeInterfaceMacro\SpecialEscapechar
% If one defines complicated macros it is sometimes necessary to
% introduce a new escape character because the `|\|' has got a
% special |\catcode|. In this case one can use
% |\SpecialEscapechar| to indicate which character is actually
% used to play the r\^ole of the `|\|'. A scheme like this is
% needed because the \env{macrocode} environment and its counterpart
% \env{macrocode$*$} produce an index entry for every occurrence of a
% macro name. They would be very confused if you didn't tell them that
% you'd changed |\catcode|$\,$s.  The argument to
% |\SpecialEscapechar| is a single-letter control sequence, that
% is, one has to use \verb=\|= for example to denote that `\verb+|+'
% is used as an escape character. |\SpecialEscapechar| only
% changes the behavior of the next \env{macrocode} or
% \env{macrocode$*$} environment.
%
%  The actual index entries created will all be printed with |\|
% rather than \verb+|+, but this probably reflects their usage, if not
% their definition, and anyway must be preferable to not having any
% entry at all.  The entries {\em could\/} be formatted appropriately,
% but the effort is hardly worth it, and the resulting index might be
% more confusing (it would certainly be longer!).
%
%
% \subsection{Cross-referencing all macros used}
%
% \DescribeInterfaceMacro\DisableCrossrefs \DescribeInterfaceMacro\EnableCrossrefs As
% already mentioned, every macro name used within a
% \env{macrocode} or \env{macrocode$*$} environment will produce an
% index entry. In this way one can easily find out where a specific
% macro is used.  Since \TeX{} is considerably slower\footnote{This
% comment was written about 30 years ago. \TeX{} is still considerably
% slower but while it took minutes to process a large document (such
% as the \LaTeX{} kernel documentation) it takes seconds or less these
% days. Thus \cs{DisableCrossrefs} isn't really that necessary these
% days.}  when it has to produce such a bulk of index entries one can
% turn off this feature by using |\DisableCrossrefs| in the driver
% file. To turn it on again just use
% |\EnableCrossrefs|.\footnote{Actually, \cs{EnableCrossrefs} changes
% things more drastically; any following call to \cs{DisableCrossrefs}
% which might be present in the source will be ignored.}
%
%
% \DescribeInterfaceMacro\DoNotIndex
% But also finer control is provided. The |\DoNotIndex| macro
% takes a list of macro names separated by commas. Those names won't
% show up in the index. You might use several |\DoNotIndex|
% commands: their lists will be concatenated.  In this article I used
% |\DoNotIndex| for
% all macros which are already defined in \LaTeX.
%
% All three above declarations are local to the current group.
%
% Production (or not) of the index (via the |\makeindex| commend) is
% controlled by using or omitting the following declarations in the
% driver file preamble; if neither is used, no index is produced.
% \DescribeInterfaceMacro\PageIndex Using |\PageIndex| makes all index
% entries refer to their page number; with
% \DescribeInterfaceMacro\CodelineIndex |\CodelineIndex|, index entries
% produced by |\DescribeMacro| and |\DescribeEnv| and possibly further
% |\Describe...| commands refer to a page number
% but those produced by the \env{macro} environment (or other \DOC
% element environments) refer to the
% code lines, which will be numbered automatically.\footnote{The line
% number is actually that of the first line of the first
% \env{macrocode} environment in the \env{macro} environment.}
% \DescribeInterfaceMacro\theCodelineNo
% The style of this numbering can be controlled by defining the macro
% |\theCodelineNo|.  Its default definition is to use scriptsize
% arabic numerals; a user-supplied definition won't be overwritten.
%
% \DescribeInterfaceMacro\CodelineNumbered
% When you don't wish to get an index but want your code lines
% numbered use |\CodelineNumbered| instead of |\CodelineIndex|. This
% prevents the generation of an unnecessary |.idx| file.
%
%
% \subsection{Producing the actual index entries}
%
% Several of the aforementioned macros will produce some sort of index
% entries. These entries have to be sorted by an external
% program---the current implementation assumes that the
% \prg{makeindex} program by Chen~\cite{art:Chen} is used.
%
% But this isn't built in: one has only to redefine some of the
% following macros to be able to use any other index program.  All
% macros which are installation
% dependent are defined in such a way that they won't overwrite a
% previous definition. Therefore it is safe to put the changed
% versions in a package file which might be read in before the doc
% package.
%
%  To allow the user to change the specific characters recognized by
%  his or her index program all characters which have special meaning
%  in the \prg{makeindex} program are given symbolic
%  names.\footnote{I don't know if there exists a program which needs
%                  more command characters, but I hope not.}
% However, all characters used should be of |\catcode| other than
% `letter' (11).
%
% \DescribeInterfaceMacro{\actualchar}
% The |\actualchar| is used to separate the `key' and the actual
% index entry.
% \DescribeInterfaceMacro{\quotechar}
% The |\quotechar| is used before a special index program
% character to suppress its special meaning.
% \DescribeInterfaceMacro{\encapchar}
%  The |\encapchar| separates the indexing information from a
% letter string which \prg{makeindex} uses as a \TeX{} command to
% format the page number associated with a special entry.  It is used
% in this package to apply the |\main| and the |\usage|
% commands.
% \DescribeInterfaceMacro{\levelchar}
%  Additionally |\levelchar| is used to separate `item',
% `subitem' and `subsubitem' entries.
%
% It is a good idea to stick to these symbolic names even if you know
% which index program is used. In this way your files will be
% portable.
%
% \fmi{describe old \cs{SpecialMainIndex} and \cs{SpecialUsageIndex}}
%
% \DescribeInterfaceMacro\SpecialMainMacroIndex
% \DescribeInterfaceMacro\SpecialMainEnvIndex
% To produce a main index entry for a macro the
% |\SpecialMainMacroIndex| macro\footnote{This macro is called by the
% \env{macro} environment.} may be used.  It is called `special'
% because it has to print its argument verbatim.
% A similar macro, called |\SpecialMainEnvIndex| is used for indexing
% the main definition point of an
% environment.\footnote{This macro is called by the
% \env{environment} environment.}
%
% \DescribeInterfaceMacro\SpecialMacroIndex
% \DescribeInterfaceMacro\SpecialEnvIndex
% To index the usage of a macro or an environment
% |\SpecialMacroIndex| and |\SpecialEnvIndex| may be used.
%
% All these macros are normally used by other macros; you will need
% them only in an emergency.
%
% \NewIn{v3}
% If further code elements are declared with
% |\NewDocElement|\marg{name}\texttt{...} then this sets up
% additional indexing commands, e.g.,
% \cs{SpecialMain\meta{name}Index}.
%
% \DescribeInterfaceMacro\SpecialIndex
% The \env{macrocode} environment is automatically indexing macros
% (normally by code line number). You can (with care) also do this
% manually by
% |\SpecialIndex|. However, note that if |\CodelineIndex| is used
% this will generate an entry referring to the last code line which is
% usually not what you want. It does, however, make some sense if you
% always refer to pages only, i.e., if you use |\PageIndex|.
%
% \DescribeInterfaceMacro\SpecialShortIndex
% \NewIn{v3}
% For single character macros, e.g., |\{|, doesn't always work
% correctly.
% For this reason there is now also
% a special variant the can produce correct index entries for them.
%
% \DescribeInterfaceMacro\SortIndex
% Additionally a |\SortIndex| command is provided.  It takes two
% arguments---the sort key and the actual index entry.
%
% \DescribeInterfaceMacro\verbatimchar
% But there is one characteristic worth mentioning: all macro names in
% the index are typeset with the |\verb*| command. Therefore one
% special character is needed to act as a delimiter for this command.
% To allow a change in this respect, again this character is
% referenced indirectly, by the macro |\verbatimchar|. It expands
% by default to \verb?+?  but if your code lines contain macros with
% `\texttt{+}' characters in their names (e.g.\ when you use \verb?\+?)
% then that caused a problem because you ended up with an
% index entry containing \verb?\verb+\++?
% which will be typeset as `\verb+\++' and not as `\verb?\+?'.
% \NewIn{v3}
% In version 3 this is now automatically taken care of (with the help
% of the |\SpecialShortIndex| command).
%
% \DescribeInterfaceMacro\*
% We also provide a |\*| macro.  This is intended to be used for
% index entries like
% \begin{quote}
%    index entries \\
%    \hspace*{30pt} Special macros for \*
% \end{quote}
% Such an entry might be produced with the line:
%\begin{verbatim}
%   \index{index entries\levelchar Special macros for \*}
%\end{verbatim}
%
%
% \subsection{Setting the index entries}
%
% \changes{v1.7a}{1992/03/11}{Usage note on gind.ist.} After the first
% formatting pass through the \texttt{.dtx} file you need to sort the
% index entries written to the \texttt{.idx} file using
% \prg{makeindex} or your favorite alternative.  You need a
% suitable style file for \prg{makeindex} (specified by the
% \texttt{-s} switch).  A suitable one is supplied with \DOC{},
% called \texttt{gind.ist}.
%
% \DescribeInterfaceMacro\PrintIndex
% To read in and print the sorted index, just put the
% |\PrintIndex| command as the last (commented-out, and thus
% executed during the documentation pass through the file) command
% in your package file.  Precede it by any bibliography commands
% necessary for your citations.
% Alternatively, it may be more convenient to put all such calls
% amongst the arguments of the |\MaybeStop| macro, in
% which case a |\Finale| command should appear at the end of
% your file.
%
% \DescribeEnv{theindex}
% Contrary to standard \LaTeX, the index is typeset in three columns
% by default.
% \DescribeLaTeXCounter{IndexColumns}
% This is controlled by the \LaTeX{} counter
% `\textsf{IndexColumns}' and can therefore be changed with a
% |\setcounter| declaration.  Additionally one doesn't want to
% start a new page unnecessarily.  Therefore the \env{theindex}
% environment is redefined.
% \DescribeLaTeXDimen\IndexMin
% When the \env{theindex} environment starts it will measure how much
% space is left on the current page. If this is more than
% |\IndexMin| then the index will start on this page. Otherwise
% |\newpage| is called.
%
% Then a short introduction about the meaning of several index entries
% is typeset (still in onecolumn mode). Afterwards the actual index
% entries follow in multi-column mode.
% \DescribeInterfaceMacro\IndexPrologue
% You can change this prologue with the help of the
% |\IndexPrologue| macro. Actually the section heading is also
% produced in this way, so you'd better write something like:
% \begin{verbatim}
%   \IndexPrologue{\section*{Index} The index entries underlined ...}
%\end{verbatim}
% When the \env{theindex} environment is finished the last page will
% be reformatted to produce balanced columns. This improves the layout
% and allows the next article to start on the same page.
% \DescribeInterfaceMacro\IndexParms
% Formatting of the index columns (values for |\columnssep|
% etc.)\ is controlled by the |\IndexParms| macro. It assigns the
% following values:
% \SpecialLaTeXDimenIndex{\parindent}\SpecialLaTeXDimenIndex{\columnsep}^^A
% \SpecialLaTeXSkipIndex{\parskip}\SpecialLaTeXSkipIndex{\rightskip}^^A
% \SpecialLaTeXDimenIndex{\mathsurround}\SpecialLaTeXSkipIndex{\parfillskip}
% \begin{center}
%  \begin{tabular}{l@{\,=\,}ll@{\,=\,}l}
%  |\parindent|    & \IndexParms \the\parindent    &
%  |\columnsep|    & \IndexParms \the\columnsep    \\
%  |\parskip|      & \IndexParms \the\parskip           &
%  |\rightskip|    & \IndexParms
%                         \expandafter\dimenvalue\the\rightskip  \\
%  |\mathsurround| & \IndexParms \the\mathsurround  &
%  |\parfillskip|  & \IndexParms
%                         \expandafter\dimenvalue\the\parfillskip
%  \end{tabular}
% \end{center}
% \DescribeInterfaceMacro{\@idxitem}
% Additionally it defines |\@idxitem| (which will be used when an
% |\item| command is encountered) and selects |\small| size.
% If you want to change any of these values you have to define them
% all.
%
% \DescribeInterfaceMacro\main
% \DescribeInterfaceMacro\usage
% \DescribeInterfaceMacro\code
% The page numbers for main index entries are encapsulated by the
% |\main| macro (underlining its argument) and the numbers
% denoting the description are encapsulated by the |\usage| macro
% (which produces \textit{italics}). |\code| encapsulates page or code
%    line numbers in entries generated by parsing the code inside
%    \env{macrocode} environments. As usual these commands are user
% definable.
%
%
% \subsection{Changing the default values of style parameters}
%
% \DescribeInterfaceMacro\DocstyleParms If you want to overwrite some default
% settings made by the \DOC{} package, you can either put your
% declarations in the driver file (that is after \texttt{doc.sty} is
% read in) or use a separate package file for doing this work. In the
% latter case you can define the macro |\DocstyleParms| to contain all
% assignments.  This indirect approach is necessary if your package file
% might be read before the \texttt{doc.sty}, when some of the
% registers are not allocated.  Its default definition is null.
%
% The doc package currently assigns values to the following
% registers:
% \SpecialLaTeXDimenIndex{\IndexMin}^^A
% \SpecialLaTeXSkipIndex{\MacrocodeTopsep}^^A
% \SpecialLaTeXSkipIndex{\MacroTopsep}^^A
% \SpecialLaTeXDimenIndex{\MacroIndent}^^A
% \SpecialLaTeXDimenIndex{\marginparpush}^^A
% \SpecialLaTeXDimenIndex{\marginparwidth}^^A
% \SpecialTeXCounterIndex{\tolerance}
% \begin{center}
%  \begin{tabular}{l@{\,=\,}ll@{\,=\,}l}
%  |\IndexMin|      & \the\IndexMin    &
%  |\MacroTopsep|   & \the\MacroTopsep    \\
%  |\marginparwidth|& \the\marginparwidth  &
%  |\MacroIndent|   & \the\MacroIndent \\
%  |\marginparpush| & \the\marginparpush    &
%  |\MacrocodeTopsep|   & \the\MacrocodeTopsep \\
%  |\tolerance|     & \the\tolerance
%  \end{tabular}
% \end{center}
%
%
% \subsection{Short input of verbatim text pieces}
%
% \DescribeInterfaceMacro\MakeShortVerb
% \DescribeInterfaceMacro{\MakeShortVerb*} \DescribeInterfaceMacro\DeleteShortVerb It is
% awkward to have to type, say, \verb"\verb|"\ldots\verb"|" continually when
% quoting
% verbatim bits (like macro names) in the text, so an abbreviation
% mechanism is provided.  Pick a character \meta{c}---one which
% normally has catcode `other' unless you have very good reason not
% to---which you don't envisage using in the text, or not using often.
% (I like |"|, but you may prefer \verb"|" if you have |"| active to do
% umlauts, for instance.)  Then if you say
% |\MakeShortVerb{\|\meta{c}|}| you can subsequently use
% \meta{c}\meta{text}\meta{c} as the equivalent of
% |\verb|\meta{c}\meta{text}\meta{c};  analogously, the |*|-form
% |\MakeShortVerb*{\|\meta{c}|}| gives you the equivalent of
% |\verb*|\meta{c}\meta{text}\meta{c}.  Use
% |\DeleteShortVerb{\|\meta{c}|}| if you subsequently want \meta{c} to
% revert to its previous meaning---you can always turn it on again
% after the unusual section.  The `short verb' commands make global
% changes.  The abbreviated |\verb| may not appear in the argument of
% another command just like |\verb|.  However the `short verb'
% character may be used freely in the \env{verbatim} and
% \env{macrocode} environments without ill effect.
% |\DeleteShortVerb| is silently ignored if its argument does not
% currently represent a short verb character.  Both commands type a
% message to tell you the meaning of the character is being changed.
%
% Please remember that the command |\verb| cannot be used in arguments
% of other commands. Therefore abbreviation characters for |\verb|
% cannot be used there either.
%
% This feature is also available as a sole package, \texttt{shortvrb}.
%
%
% \subsection{Additional bells and whistles}
%
% We provide macros for logos such as \Web, \AmSTeX, \BibTeX,
% \SliTeX{} and \PlainTeX. Just type |\Web|, |\AmSTeX|,
% |\BibTeX|, |\SliTeX| or |\PlainTeX|, respectively.
% \LaTeX{} and \TeX{} are already defined in \texttt{latex.tex}.
%
% \DescribeInterfaceMacro\meta
% Another useful macro is |\meta| which has one argument and
% produces something like \meta{dimen parameter}.
%
% \DescribeInterfaceMacro\OnlyDescription
% \DescribeInterfaceMacro\MaybeStop
% \DescribeObsoleteInterfaceMacro\StopEventually
% You can use the |\OnlyDescription| declaration in the driver
% file to suppress the last part of your document (which presumably
% exhibits the code). To make this work
% \NewIn{v3}
% you have to place the command |\MaybeStop| at a suitable
% point in your file.  This macro\footnote{For about 30 years this
%    macro was called \cs{StopEventually} which was due to a ``false
%    friend'' misunderstanding. In the German language the word
%    ``eventuell'' mean roughly ``perhaps'' which isn't quite the same
%    as ``eventually''. But given that this is now used for so long
%    and all over the place we can't drop the old name. So it is still
%    there to allow processing all the existing documentation.}
% has one argument in which you put
% all information you want to see printed if your document ends at
% this point (for example a bibliography which is normally printed at
% the very end). When the |\OnlyDescription| declaration is
% missing the |\MaybeStop|
% \DescribeInterfaceMacro\Finale
% macro saves its argument in a macro called |\Finale| which can
% afterwards be used to get things back (usually at the very end).
% Such a scheme makes changes in two places unnecessary.
%
% Thus you can use this feature to produce a local guide for the
% \TeX{} users which describes only the usage of macros (most of them
% won't be interested in your definitions anyway).  For the same
% reason the |\maketitle| \DescribeInterfaceMacro\maketitle command is slightly
% changed to allow multiple titles in one document.  So you can make
% one driver file reading in several articles at once.
% \DescribeInterfaceMacro{\ps@titlepage} To avoid an unwanted
% \textsf{pagestyle} on the title page the |\maketitle| command issues
% a |\thispagestyle{titlepage}| declaration which produces a
% \textsf{plain} page if the \textsf{titlepage} page style is
% undefined.  This allows class files like \cls{ltugboat.cls} to
% define their own page styles for title pages.
%
% \DescribeInterfaceMacro\AlsoImplementation
% Typesetting the whole document is the default. However, this default
% can also be explicitly selected using the declaration
% |\AlsoImplementation|. This overwrites any previous
% |\OnlyDescription| declaration. The \LaTeXe{} distribution, for
% example, is documented using the \texttt{ltxdoc} class which allows
% for a configuration file \texttt{ltxdoc.cfg}. In such a file one
% could then add the statement
% \begin{quote}
% |\AtBeginDocument{\AlsoImplementation}|
% \end{quote}
% to make sure that all documents will show the code part.
%
% \DescribeInterfaceMacro\IndexInput \label{..Input} Last but not least I
% defined an |\IndexInput| macro which takes a file name as an
% argument and produces a verbatim listing of the file, indexing every
% command as it goes along.  This might be handy, if you want to learn
% something about macros without enough documentation.  I used this
% feature to cross-reference \texttt{latex.tex} getting a verbatim
% copy with about 15 pages index.\footnote{It took quite a long time
% and the resulting \texttt{.idx} file was longer than the
% \texttt{.dvi} file.  Actually too long to be handled by the
% \prg{makeindex} program directly (on our MicroVAX) but the final
% result was worth the trouble.}
%
% \changes{v2.1d}{2006/02/02}{Corrected description of \cs{changes}
% macro.}
% \DescribeInterfaceMacro\changes
% To maintain a change history within the file, the |\changes|
% command may be placed amongst the description part of the changed
% code.  It takes three arguments, thus:
% \begin{quote}
% |\changes{|\meta{version}|}{|\meta{date}|}{|^^A
% \meta{text}|}|
% \end{quote}
% The changes may be used to produce an auxiliary file (\LaTeX's
% |\glossary| mechanism is used for this) which may be printed
% after suitable formatting. The |\changes| macro generates the
% printed entry in such a change history; because old
% versions\footnote{Before 2.6.} of the \prg{makeindex}
% program limit such fields to 64 characters, care should be taken
% not to exceed this limit when describing the change. The actual
% entry consists of the \meta{version}, the |\actualchar|, the current
% macro name, a colon, the |\levelchar|, and, finally, the \meta{text}.
% The result is a glossary entry for the \meta{version}, with the name of
% the current macro as subitem.  Outside the |macro| environment, the
% text |\generalname| is used instead of the macro name.  When
% referring to macros in change descriptions it is conventional to use
% |\cs{|\meta{macroname}|}| rather than attempting to format it properly
% and using up valuable characters in the entry with old \prg{makeindex}
% versions.
%
% Note that in the history listing, the entry is shown with the page number
% that corresponds to its place in the source, e.g., general changes put at the
% very beginning of the file will show up with page number ``1'', change entries
% placed elsewhere might have different numbers (not necessarily always
% very useful unless you are careful).
%
%
% \changes{v1.7a}{1992/02/26}{Description of \cs{RecordChanges} etc.
% added
% to interface section.} \DescribeInterfaceMacro\RecordChanges To cause the
% change information to be written out, include |\RecordChanges| in
% the driver file.  \DescribeInterfaceMacro\PrintChanges To read in and print
% the sorted change history (in two columns), just put the
% |\PrintChanges| command as the last (commented-out, and thus
% executed during the documentation pass through the file) command in
% your package file.  Alternatively, this command may form one of the
% arguments of the |\MaybeStop| command, although a change
% history is probably {\em not\/} required if only the description is
% being printed.  The command assumes that \prg{makeindex} or some
% other program has processed the \texttt{.glo} file to generate a
% sorted \texttt{.gls} file.  You need a special \prg{makeindex}
% style file; a suitable one is supplied with \DOC{}, called
% \texttt{gglo.ist}.
%
% \DescribeLaTeXDimen\GlossaryMin
% \DescribeInterfaceMacro\GlossaryPrologue
% \DescribeInterfaceMacro\GlossaryParms
% \DescribeLaTeXCounter{GlossaryColumns}
%  The
% |\GlossaryMin|, |\GlossaryPrologue| and |\GlossaryParms| macros and
% the counter \texttt{GlossaryColumns} are
% analogous to the |\Index|\ldots\ versions.  (The \LaTeX{} `glossary'
% mechanism is used for the change entries.)
%
%
% \DescribeInterfaceMacro\bslash
% From time to time, it is necessary to print a |\| without
% being able to use the |\verb| command because the
% |\catcode|$\,$s of the symbols are already firmly
% established.  In this instance we can use the command
% |\bslash| presupposing, of course, that the actual font in
% use at this point contains a `backslash' as a symbol.  Note that
% this definition of |\bslash| is expandable; it inserts a
% $|\|_{12}$.  This means that you have to |\protect|
% it if it is used in `moving arguments'.
%
% \DescribeInterfaceMacro\MakePrivateLetters
% \changes{v1.7a}{1992/02/26}{Documented \cs{MakePrivateLetters} in
%                           interface section}^^A
% If your macros |\catcode| anything other than |@| to `letter', you
% should redefine |\MakePrivateLetters| so that it also makes the
% relevant characters `letters' for the benefit of the indexing.  The
% default definition is just |\makeatletter|.
%
% \DescribeInterfaceMacro\DontCheckModules \DescribeInterfaceMacro\CheckModules
% \DescribeInterfaceMacro\Module \DescribeInterfaceMacro\AltMacroFont The `module'
% directives of the \prg{docstrip} system \cite{art:docstrip} are
% normally recognized and invoke special formatting.  This can be
% turned on and off in the \texttt{.dtx} file or the driver file using
% |\CheckModules| and |\DontCheckModules|.  If checking for module
% directives is on (the default) then code in the scope of the
% directives is set as determined by the hook |\AltMacroFont|, which
% gives {\small\ttfamily\itshape small italic type\-writer\/} by
% default in the New Font Selection Scheme but just ordinary
% {\small\ttfamily small type\-writer} in the old one, where a font
% such as italic typewriter can't be used portably (plug for NFSS);
% you will need to override this if you don't have the italic
% typewriter font available.  Code is in such a scope if it's on a
% line beginning with |%<| or is between lines starting with
% |%<*|\meta{name list}|>| and |%</|\meta{name list}|>|.  The
% directive is formatted by the macro |\Module| whose single argument
% is the text of the directive between, but not including, the angle
% brackets; this macro may be re-defined in the driver or package file
% and by default produces results like \Module{+foo\string|bar} with no
% following space.
%
% \DescribeLaTeXCounter{StandardModuleDepth} Sometimes (as in this file) the
% whole code is surrounded by modules to produce several files from a
% single source. In this case it is clearly not appropriate to format
% all code lines in a special |\AltMacroFont|. For this reason a
% counter |StandardModuleDepth| is provided which defines the level of
% module nesting which is still supposed to be formatted in
% |\MacroFont| rather then |\AltMacroFont|. The default setting is
% |0|, for this documentation it was set to
%\begin{verbatim}
%   \setcounter{StandardModuleDepth}{1}
%\end{verbatim}
% at the beginning of the file.
%
%
% \section{Examples and basic usage summary}
%
% \subsection{Basic usage summary}
% \changes{v1.7a}{1992/03/11}{Added basic usage summary to spell
%                             it out.}
%
% To sum up, the basic structure of a \texttt{.dtx} file without any
% refinements is like this:
% \begin{verse}\small
% |% |\meta{waffle}\ldots\\
% \quad\ldots \\
% |% \DescribeMacro{\fred}|\\
% |% |\meta{description of fred's use}\\
% \quad\ldots\\
% |% \MaybeStop{|\meta{finale code}|}|\\
% \quad\ldots\\
% |% \begin{macro}{\fred}|\\
% |% |\meta{commentary on macro fred}\\
% \verb*+%    \begin{macrocode}+\\
% \meta{code for macro fred}\\
% \verb*+%    \end{macrocode}+\\
% |% \end{macro}|\\
% \quad\ldots\\
% |% \Finale \PrintIndex \PrintChanges|
% \end{verse}
% For further examples of the use of most---if not all---of the features
% described above, consult the \texttt{doc.dtx} source itself.
%
%
%
% \subsection{Examples}
%
% The default setup includes definitions for the \DOC elements
% ``macro'' and ``environment''. They correspond to the following
% declarations:
%\begin{verbatim}
% \NewDocElement[macrolike = true ,
%                 idxtype   = ,
%                 idxgroup  = ,
%                 printtype =
%                ]{Macro}{macro}
%
% \NewDocElement[macrolike = false ,
%                 idxtype   = env.  ,
%                 idxgroup  = environments ,
%                 printtype = \textit{env.}
%                ]{Env}{environment}
%\end{verbatim}
%
% To showcase the new features of \DOC version 3 to some extend, the
% current documentation is done by redefining these declarations and
% also adding a few additional declarations on top.
%
% For any internal command we document we use \texttt{Macro} and put
% all of them under the heading ``\LaTeX{} commands'' (note the use of \cs{actualchar}):
%\begin{verbatim}
%\RenewDocElement[macrolike = true ,
%                toplevel  = false,
%                idxtype   = ,
%                idxgroup  = LaTeX comands\actualchar\LaTeX{} commands ,
%                printtype =
%               ]{Macro}{macro}
%\end{verbatim}
%
% We only have package environments so we use \texttt{Env} for those
% and group them as well:
%\begin{verbatim}
%\RenewDocElement[macrolike = false ,
%                toplevel  = false,
%                idxtype   = env.  ,
%                idxgroup  = Package environments,
%                printtype = \textit{env.}
%               ]{Env}{environment}
%\end{verbatim}
%
%
% All the interface commands are also grouped together under the label
% ``Package commands'', we use \texttt{InterfaceMacro} for them:
%\begin{verbatim}
%\NewDocElement[macrolike = true ,
%                toplevel  = false,
%                idxtype   = ,
%                idxgroup  = Package commands,
%                printtype =
%               ]{InterfaceMacro}{imacro}
%\end{verbatim}
%
% And since we also have a few obsolete interfaces we add yet another category:
%\begin{verbatim}
%\NewDocElement[macrolike = true ,
%                toplevel  = false,
%                idxtype   = ,
%                idxgroup  = Package commands (obsolete),
%                printtype =
%               ]{ObsoleteInterfaceMacro}{omacro}
%\end{verbatim}
%
% Another type of category are the package keys:
%\begin{verbatim}
%\NewDocElement[macrolike = false ,
%                toplevel  = false,
%                idxtype   = key  ,
%                idxgroup  = Package keys ,
%                printtype = \textit{key}
%               ]{Key}{key} 
%\end{verbatim}
%
% Finally we have \TeX{} counters (with a backslash in front) and
% \LaTeX{} counters (no backslash) and the two types of \LaTeX{}
% length registers:
%\begin{verbatim}
%\NewDocElement[macrolike = true ,
%                toplevel  = false,
%                idxtype   =  counter  ,
%                idxgroup  = TeX counters\actualchar \protect\TeX{} counters ,
%                printtype = \textit{counter}
%               ]{TeXCounter}{tcounter}
%
%\NewDocElement[macrolike = false ,
%                toplevel  = false,
%                idxtype   =  counter  ,
%                idxgroup  = LaTeX counters\actualchar \LaTeX{} counters ,
%                printtype = \textit{counter}
%               ]{LaTeXCounter}{lcounter}
%
%\NewDocElement[macrolike = true ,
%                toplevel  = false,
%                idxtype   =  skip  ,
%                idxgroup  = LaTeX length\actualchar \LaTeX{} length (skip) ,
%                printtype = \textit{skip}
%               ]{LaTeXSkip}{lskip}
%
%\NewDocElement[macrolike = true ,
%                toplevel  = false,
%                idxtype   =  dimen  ,
%                idxgroup  = LaTeX length\actualchar \LaTeX{} length (dimen) ,
%                printtype = \textit{dimen}
%               ]{LaTeXDimen}{ldimen}
%
%\end{verbatim}
%
% And we modify the appearance of the index: just 2 columns not 3 and
% all the code-line entries get prefixed with an ``$\ell$'' (for line)
% so that they can easily be distinguished from page index entries.
%\begin{verbatim}
% \renewcommand\code[1]{\mbox{$\ell$-#1}}
% \renewcommand\main[1]{\underline{\mbox{$\ell$-#1}}}
% \setcounter{IndexColumns}{2}
%\end{verbatim}
%
%
%
% \section{Incompatibilities between version 2 and 3}
%
% The basic approach when developing version~3 was to provide a very
% high level of compatibility with version~2 so that nearly all
% older documents should work out of the box without the need for
% any adjustments.
%
% But as with any change there are situations where that change can
% result in some sort of incompatibility, e.g., if a newly introduce
% command name was already been defined in the user document then
% there will be a conflict that is nearly impossible to avoid
% 100\%.
%
% As mentioned earlier, \DOC now supports options on several commands
% and environments and as a result it is necessary to use braces
% around the argument for \cs{DescribeMaro} if the ``macro to be
% described'' uses private letters such as |@| or |_| as part of its
% name. That was always the official syntax but in the past you could
% get away with leaving out the braces more often than you can now.
%
% The old \DOC documentation also claimed that redefinitions of things
% like \cs{PrintDescribeMacro} could be done before loading the
% package (and not only afterwards) and \DOC would in that case not
% change those commands. As the setup mechanisms are now much more
% powerful and general such an approach is not really good. So with
% \DOC version~3 modifications have to be done after the \DOC package
% got loaded and the last modification will always win.
%
% I'm temped to drop compatibility with \LaTeX~2.09  (but so far I
% have left it in).
%
% In the past it was possible to use macros declared with \cs{outer}
% in the argument of \verb=\begin{macro}= or \cs{DoNotIndex} even
% though \cs{outer} is not a concept supported in \LaTeX{}. This is no
% longer possible. More exactly, it is no longer possible to prevent
% them from being indexed (as \cs{DoNotIndex} can't be used), but you
% can pass them to the \env{macro} environment as follows:
%\begin{verbatim}
%     \begin{macro}[outer]{\foo}
%\end{verbatim}
% if \cs{foo} is a macro declared with \cs{outer}. The technical
% reason for this change is that in the past various other commands,
% such as |\{| or |\}| did not work properly in these arguments when
% they where passed as ``strings'' and not as single macro tokens. But
% by switching to macro tokens we can't have \cs{outer} macros because
% their feature is to be not allowed in arguments. So what happens
% above when you use \texttt{[outer]} is that the argument is read as
% a string with four character tokens so that it is not recognized as
% being \cs{outer}.
%
%
% \section{Old interfaces no longer really needed}
%
% Thirty years is a long time in the life of computer programs, so
% there are a good number of interfaces within \DOC that are really
% only of historical interest (or when processing equally old sources.
% We list them here, but in general we suggest that for new
% documentation they should not be used.
%
%
% \subsection{\prg{makeindex} bugs}
%
% \DescribeObsoleteInterfaceMacro\OldMakeindex
% Versions of \prg{makeindex} prior to 2.9 had some bugs affecting
% \DOC{}.  One of these,
% pertaining to the |%| character doesn't have a work-around
% appropriate for versions with and without the
% bug.\label{makeindex:version}  If
% you really still have an old version, invoke |\OldMakeindex| in a
% package file or the driver file to prevent problems with index entries
% such as |\%|, although you'll probably normally want to turn off
% indexing of |\%| anyway.  Try to get an up-to-date \prg{makeindex}
% from one of the \TeX{} repositories.
%
% \subsection{File transmission issues}
%
% In the early days of the Internet file transmission issues have been
% a serious problem. There was a famous gateway in Rochester, UK that
% handled the traffic from the European continent to the UK and that
% consisted of two IBM machines running with different codepages (that
% had non-reversible differences). As a result ``strange'' \TeX{}
% characters got replaced with something else with the result that the
% files became unusable.
%
% To guard against this problem (or rather to detect it if something
% got broken in transfer I added code to \DOC to check a static
% character table and also to have a very simple checksum feature
% (counting backslashes).
%
% These days the \cs{CheckSum} is of little value (and a lot of pain
% for the developer) and character scrambling doesn't happen any more
% so the \cs{CharacterTable} is essentially useless. Thus neither
% should be used in new developments.
%
% \label{sec:checksum}
% \DescribeObsoleteInterfaceMacro\CharacterTable
% \DescribeObsoleteInterfaceMacro\CheckSum
% To overcome some of the problems of sending files over the networks
% we developed two macros which should detect corrupted files. If one
% places the lines
% \begin{flushleft}
% \small\ttfamily        ^^A \ttfamily to get the blanks between "..."s
%                        ^^A right
%|%%\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  |\verb=|=\\
%|%%  Right brace   \}     Tilde         \~}|\\
%|%%|
%\end{flushleft}
% at the beginning of the file then character translation failures
% will be detected, provided of course, that the used \DOC{}
% package has a correct default table.  The percent
% signs\footnote{There are two percent signs in each line. This has
% the effect that these lines are not removed by the
% \texttt{docstrip.tex} program.} at the beginning of the lines should
% be typed in, since only the \DOC{} package should look at this
% command.
%
%
% Another problem of mailing files is possible truncation.  To detect
% these sort of errors we provide a |\CheckSum| macro.  The check-sum
% of a file is simply the number of backslashes in the code, i.e.\ all
% lines between the \env{macrocode} environments.  But don't be
% afraid: you don't have count the code-lines yourself; this is done
% by the \DOC{} package for you.  You simply have add
% \begin{quote}
%    |%   \CheckSum{0}|
% \end{quote}
% near the beginning of the file and use the |\MaybeStop| (which
% starts looking for backslashes) and the |\Finale| command.  The
% latter will inform you either that your file has no check-sum
% (telling you the right number) or that your number is incorrect if
% you put in anything other than zero but guessed wrong (this time
% telling you both the correct and the incorrect one).  Then you go to
% the top of your file again and change the line to the right number,
% i.e.,  line
% \begin{quote}
%    |%   \CheckSum{|\meta{number}|}|
% \end{quote}
% and that's all.
%
% While |\CharacterTable| and |\CheckSum| have been important features
% in the early days of the public internet when \DOC{} was written as
% the mail gateways back then were rather unreliable and often mangled
% files they are these days more a nuisance than any help. They are
% therefore now fully optional and no longer recommended for use with
% new files.
%
%



% ^^A =============================================================



% \begin{multicols}{2}[\medskip \noindent\rule{\textwidth}{.3pt}
%                      \section{Introduction to previous releases}]
%
% \begin{quote}
%   \textbf{Original abstract:}
%    This package contains the definitions that are necessary to
%    format the documentation of package files.  The package was
%    developed in Mainz in cooperation with the Royal Military College
%    of Science.  This is an update which documents various changes
%    and new features in \DOC{} and integrates the features of
%    \env{newdoc}.
% \end{quote}
%
% The \TeX{} macros which are described here allow definitions and
% documentation to be held in one and the same file.  This has the
% advantage that normally very complicated instructions are made
% simpler to understand by comments inside the definition. In addition
% to this, updates are easier and only one source file needs to be
% changed.  On the other hand, because of this, the package files are
% considerably longer: thus \TeX{} takes longer to load them.  If this
% is a problem, there is an easy remedy: one needs only to run the
% \texttt{docstrip.tex} program that removes nearly all lines that begin
% with a
% percent sign.
%
% The idea of integrated documentation was born with the development
% of the \TeX{} program; it was crystallized in Pascal with the \Web{}
% system.  The advantages of this method are plain to see (it's easy
% to make comparisons \cite{art:Knuthliterat}).  Since this
% development, systems similar to \Web{} have been developed for other
% programming languages. But for one of the most complicated
% programming languages (\TeX) the documentation has however been
% neglected.  The \TeX{} world seems to be divided between:---
% \begin{itemize} \item a couple of ``wizards'', who produce many
% lines of completely unreadable code ``off the cuff'', and \item many
% users who are amazed that it works just how they want it to do.  Or
% rather, who despair that certain macros refuse to do what is
% expected of them.\end{itemize}
%
% I do not think that the \Web{} system is {\em the\/} reference work;
% on the contrary, it is a prototype which suffices for the
% development of programs within the \TeX{} world.  It is sufficient,
% but not totally sufficient.\footnote{I know that this will be seen
% differently by a few people, but this product should not be seen as
% the finished product, at least as far as applications concerning
% \TeX{} are concerned.  The long-standing debate over `multiple
% change files' shows this well.} As a result of \Web, new programming
% perspectives have been demonstrated; unfortunately, though, they
% haven't been developed further for other programming languages.
%
% The method of documentation of \TeX{} macros which I have introduced
% here should also only be taken as a first sketch.  It is designed
% explicitly to run under \LaTeX{} alone.  Not because I was of the
% opinion that this was the best starting point, but because from this
% starting point it was the quickest to develop.\footnote{This
% argument is a bad one, however, it is all too often trotted out.} As
% a result of this design decision, I had to move away from the
% concept of modularization; this was certainly a step backward.
%
% I would be happy if this article could spark off discussion over
% \TeX\ documentation.  I can only advise anyone who thinks that they
% can cope without documentation to ``Stop Time'' until he or she
% completely understands the \AmSTeX{} source code.
%
% \subsection*{Using the \DOC{} package}
%
% Just like any other package, invoke it by requesting it with a
% |\usepackage| command in the preamble. \DOC's use of
% |\reversemarginpars| may make it incompatible with some classes.
% \changes{v1.7a}{1992/02/25}{Altered usage info}
%
%
% \end{multicols}
%
%
%
%
% \begin{multicols}{2}[\subsection*{Preface to version 1.7 (from
%    around 1992)}]
%
% This version of \texttt{doc.dtx} documents changes which have occurred
% since the last published version \cite{art:doc} but which have been
% present in distributed versions of \texttt{doc.sty} for some time.  It
% also integrates the (undocumented) features of the distributed
% \texttt{newdoc.sty}.
%
% The following changes and additions have been made to the user
% interface since the published version~\cite{art:doc}.  See
% \S\ref{sec:interface} for more details.
% \begin{description}
% \item[Driver mechanism] |\DocInput| is now used in the driver file
%    to input possibly multiple independent \DOC{} files and \DOC{} no
%    longer has to be the last package.  |\IndexListing| is replaced
%    by |\IndexInput|;
% \item[Indexing] is controlled by |\PageIndex| and |\CodelineIndex|,
%    one of which must be specified to produce an index---there is no
%    longer a |\makeindex| in the default |\DocstyleParms|;
% \item[The \texttt{macro} environment] now takes as argument the
%    macro name {\em with\/} the backslash;
% \item[Verbatim text] Newlines are now forbidden inside |\verb| and
%    commands |\MakeShortVerb| and |\DeleteShortVerb| are provided for
%    verbatim shorthand;
% \item[\texttt{\bslash par}] can now be used in |\DoNotIndex|;
% \item[Checksum/character table support] for ensuring the integrity
%    of distributions is added;
% \item[\texttt{\bslash printindex}] becomes |\PrintIndex|;
% \item[\texttt{multicol.sty}] is no longer necessary to use \DOC{} or
%    print the documentation (although it is recommended);
% \item[`Docstrip' modules] are recognized and formatted specially.
% \end{description}
%
% As well as adding some completely new stuff,
% the opportunity has been taken to add some commentary to the code
% formerly in \pkg{newdoc} and that added after version 1.5k of
% \DOC.  Since (as noted in the sections concerned) this
% commentary wasn't written by Frank Mittelbach but the code was, it is
% probably {\em not\/} true in this case that ``if the code and
% comments disagree both are probably wrong''!
%
% \subsubsection*{Bugs}
%
% There are some known bugs in this version:
% \begin{itemize}
% \item The |\DoNotIndex| command doesn't work for some single
%    character commands most noticeable |\%|.
% \item The `General changes' glossary entry would come out after
%    macro names with a leading |!| and possibly a leading |"|;
% \item If you have an old version of \prg{makeindex} long |\changes|
%    entries will come out strangely and you may find the section
%    header amalgamated with the first changes entry.  Try to get an
%    up-to-date one (see p.~\pageref{makeindex:version});
% \item Because the accompanying \prg{makeindex} style files support
%    the inconsistent attribute specifications of older and newer
%    versions \prg{makeindex} always complains about three `unknown
%    specifier's when sorting the index and changes entries.
% \item If |\MakeShortVerb| and |\DeleteShortVerb| are used with
%    single character arguments, e.g., \verb"{|}" instead of \verb"{\|}" chaos
%    may happen.
% \end{itemize}
% (Some `features' are documented below.)
%
% \subsubsection*{Wish list}
%
% \begin{itemize}
% \item Hooks to allow |\DescribeMacro| and |\DescribeEnv| to write
% out to a special file information about the package's `exported'
% definitions which they describe.  This could subsequently be
% included in the \texttt{docstrip}ped \texttt{.sty} file in a
% suitable form for use by smart editors in command completion,
% spelling checking etc., based on the packages used in a document.
% This would need agreement on a `suitable form'.  \item Indexing of
% the modules used in \texttt{docstrip}'s |%<| directives.  I'm not
% sure how to index directives containing module combinations; \item
% Writing out bibliographic information about the package; \item Allow
% turning off use of the special font for, say, the next guarded
% block.
% \end{itemize}
%
%
% \end{multicols}


% \subsection*{Acknowledgements}
%
% I would like to thank all folks at Mainz and at the Royal Military
% College of Science for their help in this project. Especially Brian
% and Rainer who pushed everything with their suggestions, bug fixes,
% etc.
%
% A big thank you to David Love who brought the documentation
% up-to-date again, after I neglected this file for more than two
% years. This was most certainly a tough job as many features added to
% \texttt{doc.dtx} after its publication in \textsl{TUGboat\/} have
% been never properly described. Beside this splendid work he kindly
% provided additional code (like ``docstrip'' module formatting) which
% I think every \DOC user will be grateful for.
%
%
% \MaybeStop{
%  \begin{thebibliography}{1}
%    \bibitem{book:Buerger}  \textsc{G. A. B\"urger}.
%      \newblock Wunderbare Reisen zu Wasser und zu Lande, Feldzüge
%                und lustige Abenteuer des Freyherrn v.\ Münchhausen.
%      \newblock London, 1786 \& 1788.
%    \bibitem{art:Knuthliterat} \textsc{D. E. Knuth}.
%      \newblock Literate Programming.
%      \newblock Computer Journal, Vol.~27, \textit{pp}.~97--111,
%               May 1984.
%    \bibitem{book:KnuthA} \textsc{D. E. Knuth}.
%      \newblock Computers \& Typesetting (The \TeX book).
%      \newblock Addison-Wesley, Vol. A, 1986.
%    \bibitem{art:Chen} \textsc{L. Lamport}.
%      \newblock MakeIndex: An Index Processor for \LaTeX.
%      \newblock 17 February 1987.
%      \newblock (Taken from the file \texttt{makeindex.tex} provided
%                 with
%      the program source code.)
%    \bibitem{art:doc} \textsc{Frank Mittelbach}.
%      \newblock The \DOC{}-option.
%      \newblock \textsl{TUGboat}, Vol.~10(2), \textit{pp}.~245--273,
%        July 1989.
%    \bibitem{art:docstrip} \textsc{Frank Mittelbach, Denys Duchier and
%         Johannes Braams}.
%      \newblock \texttt{docstrip.dtx}.
%      \newblock The file is part of core \LaTeX{}.
%    \bibitem{book:Raspe} \textsc{R. E. Raspe} (*1737, \dag 1797).
%      \newblock Baron Münchhausens narrative of his marvelous
%                travels and campaigns in Russia.
%      \newblock Oxford, 1785.
%    \bibitem{art:verbatim} \textsc{Rainer Schöpf}.
%      \newblock A New Implementation of \LaTeX's \texttt{verbatim} and
%      \texttt{verbatim*} Environments.
%      \newblock File \texttt{verbatim.doc}, version 1.4i.
%  \end{thebibliography}
%
%  \addtocontents{toc}{\protect\end{multicols}}
%
%  \PrintIndex
%
% } ^^A end \MaybeStop
%
%
% \section{The Description of Macros}
%
% Most of the following code is destined for \texttt{doc.sty} after
% processing with \texttt{docstrip} to include the module
% \textbf{style} indicated here.  (All code in this file not
% appropriate to \texttt{doc.sty} has to be included explicitly by
% docstrip so that this \texttt{.dtx} file can be used as directly as
% a package file rather than the stripped version.)  The usual font
% change for the conditionally-included lines between the
% \Module{*style} and \Module{/style} directives is suppressed since
% only the lines with an explicit directive are special in this file.
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% Under \LaTeXe{} the test to avoid reading
% \DOC{} in twice is normally unnecessary. It was kept to only to
% stay compatible with \LaTeX209 styles that |\input| \DOC{}
% directly.
% \changes{v1.5i}{1989/06/07}{Avoid reading the file twice.}
%    \begin{macrocode}
\@ifundefined{macro@cnt}{}{\endinput}
%    \end{macrocode}
%
% \DescribeObsoleteInterfaceMacro\fileversion
% \DescribeObsoleteInterfaceMacro\filedate
% \DescribeObsoleteInterfaceMacro\docdate
% As you can see I used macros like |\fileversion| to denote the
% version number and the date. They are defined at the very beginning
% of the package file (without a surrounding \env{macrocode}
% environment), so I don't have to search for this place here when I
% change the version number.  You can see their actual outcome in a
% footnote to the title.
%
%
% The first thing that we do next is to get ourselves two alternative comment
% signs.  Because all sensible signs are already occupied, we will
% choose some that can only be entered indirectly:
% {\DoNotIndex{\^}^^A avoid misinterpretation !!!!! VERIFY
%    \begin{macrocode}
\catcode`\^^A=14
\catcode`\^^X=14
%    \end{macrocode}
% We repeat this statement at the beginning of the document in case
% the \texttt{inputenc} package is used disabling it again.
% \changes{v2.0b}{1998/05/19}{Init docs private comment char at begin
%  of document again (pr2581)}
%    \begin{macrocode}
\AtBeginDocument{\catcode`\^^A=14\relax\catcode`\^^X=14\relax}
%    \end{macrocode}
%    \SortIndex{\string^\string^A}{\string\verb\verbatimchar
%                                  \string^\string^A\verbatimchar
%                                  \encapchar main}^^A
%    \SortIndex{\string^\string^X}{\string\verb\verbatimchar
%                                  \string^\string^X\verbatimchar
%                                  \encapchar main}
% }
%
%
% \subsection{Keys supported by \DOC{}}
%
%    In the past this used \pkg{kvoptions} but this will be
%    replaced by using \texttt{l3keys} at some point in the future.
%    Right now this is only a lightweight shift---the code could and
%    should be altered further.
%    \fmi{cleanup replacement of kvoptions}
%
% Some keys are available as options for use in \cs{usepackage} some are
% for the generated item \api's:
% \changes{v3.0k}{2022/06/22}{Use \cs{DeclareKeys}}
% \changes{v3.0h}{2022/06/01}{fix choice key name (gh/750)}
% \changes{v3.0h}{2022/06/01}{fix default key name (gh/750)}
%    \begin{macrocode}
\DeclareKeys
  {
    noprint           .if    = {doc@noprint},
    noindex           .if    = {doc@noindex},
    hyperref          .if    = {doc@hyperref},
    nohyperref        .ifnot = {doc@hyperref},
    multicol          .if    = {doc@multicol},
    nomulticol        .ifnot = {doc@multicol},
    debugshow         .if    = {doc@debugshow},
    reportchangedates .if    = {doc@reportchangedates},
    toplevel          .if    = {doc@toplevel},
    notoplevel        .ifnot = {doc@toplevel},
    macrolike         .if    = {doc@macrolike},
    envlike           .ifnot = {doc@macrolike},
    idxtype           .store = \doc@idxtype,
    idxgroup          .store = \doc@idxgroup,
    printtype         .store = \doc@printtype,
    outer             .if    = {doc@outer},
  }
%    \end{macrocode}
%
% Setting these options to true initially.
%    \begin{macrocode}
\doc@hyperreftrue
\doc@multicoltrue
\doc@topleveltrue
%    \end{macrocode}
%
% \subsection{Processing the package keys}
%
%    \begin{macrocode}
\ProcessKeyOptions
%    \end{macrocode}
%
%
% \begin{macro}{\ifscan@allowed}
% \begin{macro}{\scan@allowedtrue}
% \begin{macro}{\scan@allowedfalse}
%    |\ifscan@allowed| is the switch used to determine if
%    the |\active@escape@char|\SpecialIndex{\active@escape@char}
%    should start the macro scanning mechanism.
%    \begin{macrocode}
\newif\ifscan@allowed    \scan@allowedtrue
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%  \begin{imacro}{\SetupDoc}
%
%    We need to save the default value for some options because \DOC elements
%    can locally set them.
% \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
%    \begin{macrocode}
\def\SetupDoc#1{%
  \csname keys_set:nn\endcsname{doc}{#1}%
    \edef\doc@noprintdefault{\ifdoc@noprint true\else false\fi}%
  \ifdoc@noindex
%    \end{macrocode}
%    If we do not index by default then we should also turn off
%    \cs{scan@allowed}.
%    \begin{macrocode}
    \def\doc@noindexdefault{true}%
    \scan@allowedfalse
  \else
    \def\doc@noindexdefault{false}%
  \fi
}
%    \end{macrocode}
%  \end{imacro}
%
%    \begin{macrocode}
\SetupDoc{}              % just save the default values
%    \end{macrocode}
%
%
%
% \subsection{Macros surrounding the `definition parts'}
%
% \begin{environment}{macrocode}
%    Parts of the macro definition will be surrounded by the
%    environment \env{macrocode}.  Put more precisely, they will be
%    enclosed by a macro whose argument (the text to be set
%    `verbatim') is terminated by the string
% \verb*+%    \end{macrocode}+.  Carefully note the number of spaces.
%    |\macrocode| is defined completely analogously to
%    |\verbatim|, but because a few small changes were carried
%    out, almost all internal macros have got new names.  We start by
%    calling the macro |\macro@code|, the macro which bears the
%    brunt of most of the work, such as |\catcode| reassignments,
%    etc.
% \changes{v1.5r}{1989/11/04}{Support for code line no. (Undoc)}
%    \begin{macrocode}
\def\macrocode{\macro@code
%    \end{macrocode}
%    Then we take care that all spaces have the same width, and that
%    they are not discarded.
%    \begin{macrocode}
   \frenchspacing \@vobeyspaces
%    \end{macrocode}
%    Before closing, we need to call |\xmacro@code|.  It is this
%    macro that expects an argument which is terminated by the above
%    string.  This way it is possible to keep the |\catcode|
%    changes local.
% \changes{v1.5r}{1989/11/04}{Support for code line no. (Undoc)}
% \changes{v1.5t}{1989/11/07}{Common code moved to \cs{macro@code}.}
%    \begin{macrocode}
   \xmacro@code}
%    \end{macrocode}
% \end{environment}
%
%
% \begin{macro}{\macro@code}
%    We will now begin with the macro that does the actual work:
%    \begin{macrocode}
\def\macro@code{%
%    \end{macrocode}
%    In theory it should consist of a \env{trivlist} environment, but
%    the empty space before and after the environment should not be
%    too large.
%    \begin{macrocode}
   \topsep \MacrocodeTopsep
%    \end{macrocode}
%    The next parameter we set is |\@beginparpenalty|, in order
%    to prevent a page break before such an environment.
%    \begin{macrocode}
   \@beginparpenalty \predisplaypenalty
%    \end{macrocode}
%    We then start a |\trivlist|, set |\parskip| back to
%    zero and start an empty |\item|.
% \changes{v1.9b}{1993/12/03}{Forcing any label from macro env.}
%    \begin{macrocode}
   \if@inlabel\leavevmode\fi
   \trivlist \parskip \z@ \item[]%
%    \end{macrocode}
%    The \cs{item} command sets the \cs{@labels} box but that box is
%    never typeset (as \cs{everypar} that normally does this gets
%    redefined later). That is normally not an issue, but produces a
%    problem when typesetting in mixed directions, (e.g., in
%    Japanese), so we explicitly clear it for that use case.
%  \changes{v2.1m}{2020/06/15}{Void \cs{@labels} for vertical
%    typesetting (gh/344)}
%    \begin{macrocode}
   \global\setbox\@labels\box\voidb@x
%    \end{macrocode}
%    Additionally, everything should be set in \texttt{typewriter} font.
%    Some people might prefer it somewhat differently; because of this
%    the font choice is
%    macro-driven.\footnote{The font change has to be placed
%                       {\em after\/}
%                       the \texttt{\bslash item}. Otherwise a change to
%                       \texttt{\bslash baselineskip} will affect the
%                       paragraph above.}
%    \begin{macrocode}
   \macro@font
%    \end{macrocode}
%    Because |\item| sets various parameters, we have found it
%    necessary to alter some of these retrospectively.
%    \begin{macrocode}
   \leftskip\@totalleftmargin \advance\leftskip\MacroIndent
   \rightskip\z@ \parindent\z@ \parfillskip\@flushglue
%    \end{macrocode}
%    The next line consists of the \LaTeX{} definition of |\par|
%    used in |\verbatim| and should result in blank lines being
%    shown as blank lines.
% \changes{v1.5l}{1989/09/10}{Code line numbers supported.}
% \changes{v1.5t}{1989/11/07}{Call \cs{leavevmode} to get \cs{everypar}
%                           on blank lines.}
% \changes{v1.7c}{1992/03/24}{Added \cs{interlinepenalty} to
%                          \cs{par} from
%                          verbatim.sty}
%    \begin{macrocode}
   \blank@linefalse \def\par{\ifblank@line
                             \leavevmode\fi
                             \blank@linetrue\@@par
                             \penalty\interlinepenalty}
%    \end{macrocode}
%    What use is this definition of |\par|\,?  We use the macro
%   |\obeylines| of \cite{book:KnuthA} which changes all |^^M|
%    to |\par| so that each can control its own indentation.
%    Next we must also ensure that all special signs are normalized;
%    that is, they must be given |\catcode| $12$.
% \changes{v1.8b}{1993/09/21}{Changed to conform to new LaTeX verbatim,
%                           which handles more ligatures.}
%    \begin{macrocode}
   \obeylines
   \let\do\do@noligs \verbatim@nolig@list
   \let\do\@makeother \dospecials
%    \end{macrocode}
% \changes{v1.5t}{1989/11/07}{Common code added.}
% \changes{v1.5w}{1990/02/05}{Skip of \cs{@totalleftmargin} added.} If
% indexing by code lines is switched on the line number is incremented
% and set appropriately.  We also check whether the start of the next
% line indicates a \texttt{docstrip} module directive and process it
% appropriately if so using |\check@module|.
%    \begin{macrocode}
   \global\@newlistfalse
   \global\@minipagefalse
   \ifcodeline@index
     \everypar{\global\advance\c@CodelineNo\@ne
               \llap{\theCodelineNo\ \hskip\@totalleftmargin}%
               \check@module}%
   \else \everypar{\check@module}%
   \fi
%    \end{macrocode}
%    We also initialize the cross-referencing feature by calling
%    |\init@crossref|. This will start the scanning mechanism
%    when encountering an escape character.
%    \begin{macrocode}
   \init@crossref}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\ifblank@line}
% \begin{macro}{\blank@linetrue}
% \begin{macro}{\blank@linefalse}
%    |\ifblank@line| is the switch used in the definition above.
%    In the original \env{verbatim} environment the |\if@tempswa|
%    switch is used. This is dangerous because its value may change
%    while processing lines in the \env{macrocode} environment.
%    \begin{macrocode}
\newif\ifblank@line
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\endmacrocode}
%    Because we have begun a \env{trivlist} environment in the
%    \env{macrocode} environment, we must also end it.  We must
%    also act on the value of the |pm@module| flag (see below) and
%    empty |\everypar|.
% \changes{v1.5r}{1989/11/04}{Support for code line no. (Undoc)}
%    \begin{macrocode}
\def\endmacrocode{%
                 \ifpm@module \endgroup \pm@modulefalse \fi
                 \everypar{}%
                 \global\@inlabelfalse
                 \endtrivlist
%    \end{macrocode}
%    Additionally |\close@crossref| is used to do anything needed
%    to end the cross-referencing mechanism.
%    \begin{macrocode}
                 \close@crossref}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{imacro}{\MacroFont}
%    Here is the default definition for the |\MacroFont| macro.
%    With the new math font handling in NFSS2 it isn't any longer
%    correct to suppress the math font setup since this is now handled
%    differently. But to keep the font change fast we use only a
%    single |\selectfont| (in |\small|) and do the rest by hand.
% \changes{v1.5x}{1990/02/17}{\cs{math@fontsfalse} added for NFSS.}
% \changes{v1.7a}{1992/03/13}{Added \cs{reset@font} for NFSS.}
% \changes{v1.8c}{1993/10/25}{NFSS standard}
% \changes{v1.9t}{1995/05/26}{Removed \cs{math@fontsfalse} (different
%                             math setup /pr1622}
%    \begin{macrocode}
\@ifundefined{MacroFont}{%
  \if@compatibility
%    \end{macrocode}
%    Despite the above statement we will call |\small| first if
%    somebody is using a \LaTeX2.09 document with doc. I wouldn't have
%    bothered since doc-sources should be up-to-date but since the
%    request came from someone called David Carlisle \ldots :-)
% \changes{v1.9y}{1996/01/26}{Support compat mode}
% \changes{v2.1l}{2019/12/16}{Use \cs{shapedefault} not
%    \cs{updefault} for extended NFSS}
%    \begin{macrocode}
    \def\MacroFont{\small
                   \usefont\encodingdefault
                           \ttdefault
                           \mddefault
                           \shapedefault
                   }%
  \else
    \def\MacroFont{\fontencoding\encodingdefault
                   \fontfamily\ttdefault
                   \fontseries\mddefault
                   \fontshape\shapedefault
                   \small}%
  \fi
  }{}
%    \end{macrocode}
% \end{imacro}
%
% \begin{imacro}{\AltMacroFont}
% \begin{macro}{\macro@font}
% \changes{v1.7a}{1992/03/12}{Added to support distinction of modules.}
% \changes{v1.7c}{1992/03/26}{Altered font change for OFSS.}
% \changes{v1.7m}{1992/10/11}{Use sltt as default.}
% \changes{v1.8c}{1993/10/25}{NFSS standard}
% \changes{v1.9t}{1995/05/26}{Removed \cs{math@fontsfalse} (different
%                             math setup /pr1622}
% Although most of the macro code is set in |\MacroFont| we want to be
% able to switch to indicate module code set in |\AltMacroFont|.
% |\macro@font| keeps track of which one we're using.  We can't do the
% same thing sensibly in OFSS as in NFSS.
%    \begin{macrocode}
\@ifundefined{AltMacroFont}{%
  \if@compatibility
%    \end{macrocode}
%    Again have |\small| first if we are in compat mode.
% \changes{v1.9y}{1996/01/26}{Support compat mode}
%    \begin{macrocode}
    \def\AltMacroFont{\small
                      \usefont\encodingdefault
                              \ttdefault
                              \mddefault
                              \sldefault
                      }%
  \else
    \def\AltMacroFont{\fontencoding\encodingdefault
                      \fontfamily\ttdefault
                      \fontseries\mddefault
                      \fontshape\sldefault
                      \small
                      }%
 \fi
  }{}
%    \end{macrocode}
%    To allow changing the |\MacroFont| in the preamble we defer
%    defining the internally used |\macro@font| until after the
%    preamble.
% \changes{v2.0a}{1998/05/16}{Support changing \cs{MacroFont} in
%          preamble}
%    \begin{macrocode}
\AtBeginDocument{\let\macro@font\MacroFont}
%    \end{macrocode}
% \end{macro}
% \end{imacro}
%
% \begin{macro}{\check@module}
% \begin{macro}{\ifpm@module}
% \changes{v1.7a}{1992/03/12}{Added.}
% This is inserted by |\everypar| at the start of each macrocode line to
% check whether it starts with module information.  (Such information is
% of the form |%<|\meta{switch}|>|, where the |%| must be at the
% start of the line and \meta{switch} comprises names with various
% possible separators and a possible leading |+|, |-|, |*| or |/|
% \cite{art:docstrip}.  All that concerns us here is what the first
% character of \meta{switch} is.)  First it checks the |pm@module|
% flag in case the previous line had a non-block module
% directive i.e., not |%<*| or |%</|; if it did we need to close the
% group it started and unset the flag.  |\check@module| looks ahead at
% the next token and then calls |\ch@percent| to take action depending
% on whether or not it's a |%|; we don't want to expand the token at
% this stage.  This is all done conditionally so it can be turned off
% if it causes problems with code that wasn't designed to be
% \texttt{docstrip}ped.
%    \begin{macrocode}
\def\check@module{%
  \ifcheck@modules
    \ifpm@module \endgroup \pm@modulefalse \fi
    \expandafter\futurelet\expandafter\next\expandafter\ch@percent
  \fi}
\newif\ifpm@module
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{imacro}{\DontCheckModules}
% \begin{imacro}{\CheckModules}
% \changes{v1.7a}{1992/03/12}{Added.}
% \begin{macro}{\ifcheck@modules}
% Here are two driver-file interface macros for turning the module
% checking on and off using the |check@modules| switch.
%    \begin{macrocode}
\def\DontCheckModules{\check@modulesfalse}
\def\CheckModules{\check@modulestrue}
\newif\ifcheck@modules  \check@modulestrue
%    \end{macrocode}
% \end{macro}
% \end{imacro}
% \end{imacro}
%
%
% \begin{macro}{\ch@percent}
% \changes{v1.7a}{1992/03/12}{Added.}
% If the lookahead token in |\next| is $|%|_{12}$ we go on to check
% whether the following one is |<| and otherwise do nothing.  Note the
% |\expandafter| to get past the |\fi|.
%    \begin{macrocode}
\def\ch@percent{%
  \if \percentchar\next
    \expandafter\check@angle
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\check@angle}
% \changes{v1.7a}{1992/03/12}{Added.}
% Before looking ahead for the |<| the |%| is gobbled by the
% argument here.
%    \begin{macrocode}
\def\check@angle#1{\futurelet\next\ch@angle}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ch@angle}
% \changes{v1.7a}{1992/03/12}{Added.}
% \changes{v1.9k}{1994/02/22}{Have \texttt{<} active}
%    If the current lookahead token is |<| we are defined to be
%    processing a module directive can go on to look for |+| etc.;
%    otherwise we must put back the gobbled |%|. With \LaTeXe{}
%    \texttt{<} is active so we have to be a bit careful.
%    \begin{macrocode}
\begingroup
\catcode`\<\active
\gdef\ch@angle{\ifx<\next
    \expandafter\ch@plus@etc
  \else \percentchar \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ch@plus@etc}
% \begin{macro}{\check@plus@etc}
% \changes{v1.7a}{1992/03/12}{Added.}
% We now have to decide what sort of a directive we're dealing with
% and do the right thing with it.
%    \begin{macrocode}
\gdef\ch@plus@etc<{\futurelet\next\check@plus@etc}
\gdef\check@plus@etc{%
    \if +\next
      \let\next\pm@module
    \else\if -\next
      \let\next\pm@module
    \else\if *\next
      \let\next\star@module
    \else\if /\next
      \let\next\slash@module
%    \end{macrocode}
%    At some point in the past the \texttt{docstrip} program was
%    partly rewritten and at that time it also got support for a very
%    special directive of the form |%<<| followed by an arbitrary
%    string. This is used for ``verbatim'' inclusion in case of
%    certain problem. We do not really attempt to pretty print that
%    case but we need at least account for it since otherwise we get
%    an error message since this is the only case where we will not
%    have a closing |>|.
% \changes{v2.0n}{2001/05/16}{Partly support docstrip's ``verbatim''
%    directive (pr/3331)}
%    \begin{macrocode}
    \else\ifx <\next
      \percentchar
    \else
      \let\next\pm@module
    \fi\fi\fi\fi\fi
    \next}
\endgroup
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\pm@module}
% If we're not dealing with a block
% directive (|*| or |/|) i.e., it's a single special line, we set
% everything up to the next |>| appropriately and then change to the
% special macro font inside a group which will be ended at the start
% of the next line.  If the apparent module directive is missing the
% terminating |>| this will lose, but then so will the \texttt{docstrip}
% implementation.  An alternative strategy would be to have
% |\pm@module| make |>| active and clear a flag set here to indicate
% processing the directive.  Appropriate action could then be taken if
% the flag was found still to be set when processing the next line.
% \changes{v1.7a}{1992/03/12}{Added.}
% \changes{v1.7i}{1992/07/11}{Support for fonts depending on nesting.}
%    \begin{macrocode}
\begingroup
\catcode`\~=\active
\lccode`\~=`\>
\lowercase{\gdef\pm@module#1~}{\pm@moduletrue
   \Module{#1}\begingroup
%    \end{macrocode}
%    We switch to a special font as soon the nesting is higher than
%    the current value of |\c@StandardModuleDepth|. We do a local
%    update to the |\guard@level| here which will be restored after
%    the current input line.
%    \begin{macrocode}
     \advance\guard@level\@ne
     \ifnum\guard@level>\c@StandardModuleDepth\AltMacroFont\fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\star@module}
% \begin{macro}{\slash@module}
% \changes{v1.7a}{1992/03/12}{Added.}
% \changes{v1.7f}{1992/05/16}{Take account of nested guards.}
% \changes{v1.7i}{1992/07/11}{Add counter to determine when to switch to
%                           special font.}
% If the start or end of a module {\em block\/} is indicated, after
% setting the guard we have to check whether a change in the macrocode
% font should be done.  This will be the case if we are already inside
% a block or are ending the outermost block.  If so, we globally
% toggle the font for subsequent macrocode sections between the normal
% and special form, switching to the new one immediately.
% \changes{v1.7i}{1992/07/17}{Support for fonts depending on module
%                           nesting}
%    \begin{macrocode}
\lowercase{\gdef\star@module#1~}{%
  \Module{#1}%
  \global \advance \guard@level\@ne
  \ifnum \guard@level>\c@StandardModuleDepth
    \global\let\macro@font=\AltMacroFont \macro@font
  \fi}
\catcode`\>=\active
\gdef\slash@module#1>{%
  \Module{#1}%
  \global \advance \guard@level\m@ne
  \ifnum \guard@level=\c@StandardModuleDepth
    \global\let\macro@font\MacroFont  \macro@font
  \fi
}
\endgroup
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%  \begin{lcounter}{StandardModuleDepth}
% \changes{v1.7i}{1992/07/11}{Counter added.}
%    Counter defining up to which level modules are considered part of
%    the main code. If, for  example, the whole code is surrounded by
%    a |%<*package>| module we better set this counter to |1| to avoid
%    getting the whole code be displayed in typewriter italic.
%    \begin{macrocode}
\newcounter{StandardModuleDepth}
%    \end{macrocode}
%  \end{lcounter}
%
%
% \begin{tcounter}{\guard@level}
% \changes{v1.7f}{1992/05/16}{Added.}
% We need a counter to keep track of the guard nesting.
%    \begin{macrocode}
\newcount \guard@level
%    \end{macrocode}
% \end{tcounter}

% \begin{macro}{\Module}
% \changes{v1.7a}{1992/03/12}{Added.}
% \changes{v1.7d}{1992/04/25}{Use sans font for modules.}
% This provides a hook to determine the way the module directive is
% set.  It gets as argument everything between the angle brackets.
% The default is to set the contents in sans serif text between
% $\langle\,\rangle$ with the special characters suitably |\mathcode|d
% by |\mod@math@codes|.  (You can't just set it in a sans text font
% because normally \verb"|" will print as an em-dash.)  This is done
% differently depending on whether we have the NFSS or the old one.  In
% the latter case we can easily change |\fam| appropriately.
% \changes{v1.8c}{1993/10/25}{NFSS standard}
%    \begin{macrocode}
\@ifundefined{Module}{%
%    \end{macrocode}
%    With NFSS what we probably {\em should\/} do is change to a new
%    |\mathversion| but I (Dave Love) haven't spotted an easy way to
%    do so correctly if the document uses a version other than
%    |normal|.  (We need to know in what font to set the other
%    groups.)  This uses a new math alphabet rather than version and
%    consequently has to worry about whether we're using
%    \env{oldlfnt} or not.  I expect there's a better
% way\ldots
%    \begin{macrocode}
      \def\Module#1{\mod@math@codes$\langle\mathsf{#1}\rangle$}
  }{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mod@math@codes}
% \changes{v1.7c}{1992/03/26}{Added.}
% \changes{v2.1e}{2010/02/04}{Added mathcodes for +,-,:, and = (pr/4096)}
%    As well as `words', the module
%    directive text might contain any of the characters \verb"*/+-,&|!()"
%    for the current version of \prg{docstrip}.  We only need
%    special action for two of them in the math code changing required
%    above: \verb"|" is changed to a |\mathop| (it's normally |"026A|) and
%    |&| is also made a |\mathop|, but in family 0.  Remember that |&|
%    will not have a special catcode when it's encountered.
%    \begin{macrocode}
\def\mod@math@codes{\mathcode`\|="226A \mathcode`\&="2026
                    \mathcode`\-="702D \mathcode`\+="702B
                    \mathcode`\:="703A \mathcode`\=="703D }
%    \end{macrocode}
% \end{macro}
%
%
% \begin{lskip}{\MacrocodeTopsep}
% \begin{ldimen}{\MacroIndent}
%    In the code above, we have used two registers. Therefore we have
%    to allocate them. The default values might be overwritten with
%    the help of the |\DocstyleParms| macro.
% \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
% \changes{v1.5y}{1990/02/24}{Default changed.}
% \changes{v1.6b}{1990/06/15}{\cs{rm} moved before \cs{scriptsize} to
%                           avoid unnecessary fontwarning.}
%    \begin{macrocode}
\newskip\MacrocodeTopsep \MacrocodeTopsep = 3pt plus 1.2pt minus 1pt
\newdimen\MacroIndent
\settowidth\MacroIndent{\rmfamily\scriptsize 00\ }
%    \end{macrocode}
% \end{ldimen}
% \end{lskip}
%
%
%
%
% \begin{environment}{macrocode*}
% \begin{macro}{\endmacrocode*}
%    Just as in the \env{verbatim} environment, there is also a
%    `star' variant of the \env{macrocode} environment in which a
%    space is shown by the symbol \verb*+ +.  Until this moment, I
%    have not yet used it (it will be used in the description of the
%    definition of |\xmacro@code| below) but it's exactly on this one
%    occasion {\em here\/} that you can't use it (cf.\ Münchhausens
%    Marsh problem)\footnote{Karl Friedrich Hieronymus Frhr.\ v.\
%    Münchhausen (*1720, \dag1797).  Several books were written
%    about fantastic adventures supposedly told by him (see
%    \cite{book:Raspe} or \cite{book:Buerger}). In one story he
%    escaped from the marsh by pulling himself out by his hair.}
%    directly. Because of this, on this one occasion we'll cheat
%    around the problem with an additional comment character.  But now
%    back to |\macrocode*|. We start with the macro |\macro@code|
%    which prepares everything and then call the macro |\sxmacro@code|
%    whose argument is terminated by the string
%\verb*+%    \end{macrocode*}+.
%    \begin{macrocode}
\@namedef{macrocode*}{\macro@code\sxmacro@code}
%    \end{macrocode}
%    As we know, |\sxmacro@code| and then |\end{macrocode*}|
%    (the macro, not the string), will be executed, so that for a
%    happy ending we still need to define the macro
%    |\endmacrocode*|.
%    \begin{macrocode}
\expandafter\let\csname endmacrocode*\endcsname = \endmacrocode
%    \end{macrocode}
% \end{macro}
% \end{environment}
%
%
%
%
%
%
%
% \begin{macro}{\xmacro@code}
\catcode`\!=\catcode`\%   ^^A In this section there must not be
                              ^^A any exclamation marks.
                              ^^A
%    As already mentioned, the macro |\xmacro@code| expects an
%    argument delimited by the string \verb*+%    \end{macrocode}+.  At
%    the moment that this macro is called, the |\catcode| of
%    \TeX's special characters are 12 (`other') or 13 (`active').
%    Because of this we need to utilize a different escape character
%    during the definition.  This happens locally.
%    \begin{macrocode*}
\begingroup
\catcode`\|=\z@ \catcode`\[=\@ne \catcode`\]=\tw@
%    \end{macrocode*}
%    Additionally, we need to ensure that the symbols in the above
%    string contain the |\catcode|$\,$s which are available
%    within the \env{macrocode} environment.
%    \begin{macrocode*}
\catcode`\{=12 \catcode`\}=12
\catcode`\%=12 \catcode`\ =\active \catcode`\\=\active
!%    \end{macrocode*}
!    Next follows the actual definition of  |\macro@code|;
!    notice the
!    use of the new escape character.  We manage to get the argument
!    surrounded by the string |\end{macrocode}|, but at the end
!    however, in spite of the actual characters used during the
!    definition of
!    this macro, |\end| with the argument |{macrocode}|
!    will be executed, to ensure a balanced environment.
!    \begin{macrocode*}
|gdef|xmacro@code#1%    \end{macrocode}[#1|end[macrocode]]
!%    \end{macrocode*}
! \begin{macro}{\sxmacro@code}
!    The definition of |\sxmacro@code| is completely analogous,
!    only
!    here a slightly different terminating string will be used.
!    Note that the space is not active in this environment.
!    \begin{macrocode}
|catcode`| =12
|gdef|sxmacro@code#1%    \end{macrocode*}[#1|end[macrocode*]]
!%    \end{macrocode}
!    because the |\catcode| changes have been made local by
!    commencing a
!    new group, there now follows the matching |\endgroup|
!    in a rather
!    unusual style of writing.
!    \begin{macrocode}
|endgroup
!%    \end{macrocode}
\catcode`\!=12
% \end{macro}
% \end{macro}
%
%
%
%
% \subsection{Macros for the `documentation parts'}
%
%

%    To put the labels in the left margin we have to use the
%    |\reversemarginpar| declaration. (This means that the
%    \texttt{doc.sty} can't be used with all classes or packages.)
%    We also
%    make the |\marginparpush| zero and |\marginparwidth| suitably
%    wide.
% \changes{v1.5d}{1989/04/28}{\cs{marginparwidth} setting added.}
%    \begin{macrocode}
\reversemarginpar
\setlength\marginparpush{0pt}  \setlength\marginparwidth{8pc}
%    \end{macrocode}
%
%    \begin{macrocode}
\setlength\marginparsep{\labelsep}
%    \end{macrocode}
%
% \begin{imacro}{\bslash}
% \changes{v1.7a}{1992/02/26}{Moved \cs{bslash} documentation to `user
%                           interface' part}
%    We start a new group in which to hide the alteration of
%    |\catcode|$\,$s, and make \verb+|+ introduce commands,
%    whilst |\| becomes an `other' character.
%
%    \begin{macrocode}
{\catcode`\|=\z@ \catcode`\\=12
%    \end{macrocode}
%    Now we are able to define |\bslash| (globally) to generate a
%    backslash of |\catcode| `other'.  We then close this group,
%    restoring original |\catcode|$\,$s.
%    \SpecialEscapechar{\|}
%    \begin{macrocode}
|gdef|bslash{\}}
%    \end{macrocode}
% \end{imacro}
%
%
%
% \begin{environment}{verbatim}
% \begin{environment}{verbatim*}
% \changes{v1.7i}{1992/07/12}{Added changed definition for verbatim!*.}
%    The \env{verbatim} environment holds no secrets; it consists of
%    the normal \LaTeX{} environment.  We also set the
%    |\@beginparpenalty| and change to the font given by
%    |\MacroFont|.
%    \begin{macrocode}
\def\verbatim{\@beginparpenalty \predisplaypenalty \@verbatim
              \MacroFont \frenchspacing \@vobeyspaces \@xverbatim}
%    \end{macrocode}
%    We deal in a similar way with the star form of this environment.
%    \begin{macrocode}
\@namedef{verbatim*}{\@beginparpenalty \predisplaypenalty \@verbatim
%    \end{macrocode}
%
%  \changes{v2.1j}{2019/11/03}{Kernel now sets up \cs{verbvisiblespace} (gh/205)}
%  \changes{v2.1k}{2019/11/10}{Put the definition into the right command :-( (gh/205)}
%    \begin{macrocode}
              \@setupverbvisiblespace
              \MacroFont \@vobeyspaces \@sxverbatim}
%    \end{macrocode}
% \end{environment}
% \end{environment}
%
% \begin{macro}{\@verbatim}
%    Additionally we redefine the |\@verbatim| macro so that it
%    suppresses |%| characters at the beginning of the line.  The
%    first lines are copied literally from \texttt{latex.tex}.
% \changes{v1.7i}{1992/07/12}{Added \cs{@@par} to clear possible
%                             \cs{parshape}.}
%  \changes{v3.0m}{2022/11/13}{Redefinitions of \cs{@verbatim} changed
%     to match the kernel definition (gh/953)}
%    \begin{macrocode}
\def\@verbatim{\trivlist \item\relax
  \if@minipage\else\vskip\parskip\fi
  \leftskip\@totalleftmargin\rightskip\z@
  \parindent\z@\parfillskip\@flushglue\parskip\z@
  \language\l@nohyphenation
  \@@par
  \@tempswafalse
%    \end{macrocode}
%    |\@verbatim| sets |^^M|, the end of line character, to
%    be equal to |\par|.  This control sequence is redefined
%    here; |\@@par| is the paragraph primitive of \TeX.
%    \changes{v1.7c}{1992/03/24}{Added \cs{interlinepenalty} to
%                             \cs{par} from verbatim.sty}
%    \begin{macrocode}
  \def\par{%
    \if@tempswa
      \leavevmode \null \@@par\penalty\interlinepenalty
    \else
      \@tempswatrue
      \ifhmode\@@par\penalty\interlinepenalty\fi
    \fi    
%    \end{macrocode}
%    We add a control sequence |\check@percent| to the definition
%    of |\par| whose task it is to check for a percent character.
%    \begin{macrocode}
   \check@percent}%
%    \end{macrocode}
%    The rest is again copied literally from \texttt{latex.tex} (less
%    "\tt").
% \changes{v1.7a}{1992/02/26}{Removed redundant \cs{tt}.}
% \changes{v1.8b}{1993/09/21}{Changed to conform to new LaTeX verbatim,
%                           which handles more ligatures.}
%    \begin{macrocode}
  \let\do\@makeother \dospecials
  \obeylines \verbatim@font \@noligs
  \everypar \expandafter{\the\everypar \unpenalty}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\check@percent}
%    Finally we define |\check@percent|.  Since this must compare a
%    character with a percent sign we must first (locally) change
%    percent's |\catcode| so that it is seen by \TeX.  The definition
%    itself is nearly trivial: grab the following character, check if
%    it is a |%|, and insert it again if not.  At the end of the
%    \env{verbatim} environment this macro will peek at the next
%    input line. In that case the argument to |\check@percent| might
%    be a |\par| or a macro with arguments. Therefore we make the
%    definition |\long| (|\par| allowed) and use the normal |\next|
%    mechanism to reinsert the argument after the |\fi| if necessary.
%  \changes{v1.5i}{1989/06/07}{Definition changed to `long'}
%  \changes{v1.5i}{1989/06/07}{Macro \cs{next} used to guard against
%                            macro with arguments}
%    There is a subtle problem here, the equal sign between
%    |\next| and |#1| is actually necessary. Do you see why?
%    The omission of this token once caused a funny error.
%  \changes{v1.5u}{1989/11/14}{equal sign added.}
%    \begin{macrocode}
{\catcode`\%=12
 \long\gdef\check@percent#1{\ifx #1%\let\next\@empty \else
                                    \let\next=#1\fi \next}}
%    \end{macrocode}
% \end{macro}
%
%
% In the early versions of the package it also redefined \cs{verb}
% because that didn't include the useful test for \enquote{newline} in
% the verbatim text. This is nowadays part of \LaTeX{} so we do not
% redefine it any longer (the original code is still kept in the file
% after \cs{endinput} to keep the long history intact).
%
% \begin{tcounter}{\macro@cnt}
%    \label{page:macro} The \env{macro} environment is implemented as
%    a \env{trivlist} environment, whereby in order that the macro
%    names can be placed under one another in the margin
%    (corresponding to the macro's nesting depth), the macro
%    |\makelabel| must be altered.  In order to store the nesting
%    depth, we use a counter. We also need a counter to count the
%    number of nested \env{macro} environments.
% \changes{v1.5k}{1989/08/17}{Fix for save stack problem.}
% \changes{v1.9k}{1994/02/22}{Fix probably no longer necessary}
%    \begin{macrocode}
\newcount\macro@cnt \macro@cnt=0
%    \end{macrocode}
% \end{tcounter}
%
%
% \begin{lskip}{\MacroTopsep}
%    Here is the default value for the |\MacroTopsep| parameter
%    used above.
%    \begin{macrocode}
\newskip\MacroTopsep     \MacroTopsep = 7pt plus 2pt minus 2pt
%    \end{macrocode}
% \end{lskip}
%
%
%
%
%
% \subsection{Formatting the margin}
%
% The following three macros should be user definable.
% Therefore we define those macros only if they have not already
% been defined.
%
%
% \subsection{Creating index entries by scanning `macrocode'}
%
%  The following macros ensure that index entries are created for each
%  occurrence of a \TeX-like command (something starting with
%  `|\|') providing indexing has been turned on with |\PageIndex|
%  or |\CodelineIndex|.  With the default definitions of
%  |\specialMainMacroIndex|, etc., the index file generated is
%  intended to be processed by Chen's \prg{makeindex} program
%  \cite{art:Chen}.
%
%
%  Of course, in {\em this\/} package file itself we've sometimes had to
%  make \verb+|+ take the r\^ole of \TeX's escape character to
%  introduce command names at places where |\| has to belong to
%  some other category.  Therefore, we may also need to recognize
%  \verb+|+ as the introducer for a command when setting the text
%  inside the \env{macrocode} environment.  Other users may have the
%  need to make similar reassignments for their macros.
%
%
% \begin{imacro}{\SpecialEscapechar}\label{sect:specialescapechar}
% \begin{macro}{\active@escape@char}
% \begin{macro}{\special@escape@char}
%    The macro |\SpecialEscapechar| is used to denote a special escape
%    character for the next \env{macrocode} environment. It has one
%    argument---the new escape character given as a `single-letter'
%    control sequence.  Its main purpose is defining
%    |\special@escape@char| to produce the chosen escape character
%    |\catcode|$\,$d to 12 and |\active@escape@char| to produce the
%    same character but with |\catcode| 13.
%
%    The macro |\special@escape@char| is used to {\em print\/}
%    the escape character while |\active@escape@char| is needed
%    in the definition of |\init@crossref| to start the scanning
%    mechanism.
%
%    In the definition of |\SpecialEscapechar| we need an
%    arbitrary character with |\catcode| 13. We use `\~{}' and
%    ensure that it is active. The |\begingroup| is used to make
%    a possible change local to the expansion of
%    |\SpecialEscapechar|.
% \changes{v1.7g}{1992/06/19}{Making tilde active moved outside
%    definition}
%    \begin{macrocode}
\begingroup
\catcode`\~\active
\gdef\SpecialEscapechar#1{%
    \begingroup
%    \end{macrocode}
%    Now we are ready for the definition of
%    |\active@escape@char|.  It's a little tricky: we first
%    define locally the uppercase code of `\~{}' to be the new escape
%    character.
%    \begin{macrocode}
     \uccode`\~`#1%
%    \end{macrocode}
%    Around the definition of |\active@escape@char| we place an
%    |\uppercase| command. Recall that the expansion of
%    |\uppercase| changes characters according to their
%    |\uccode|, but leaves their |\catcode|$\,$s untouched
%    (cf.\ \TeX{}book page 41).
%    \begin{macrocode}
     \uppercase{\gdef\active@escape@char{~}}%
%    \end{macrocode}
%    The definition of |\special@escape@char| is easier, we use
%    |\string| to |\catcode| the argument of
%    |\SpecialEscapechar| to 12 and suppress the preceding
%    |\escapechar|.
%    \begin{macrocode}
     \escapechar\m@ne  \xdef\special@escape@char{\string#1}%
%    \end{macrocode}
%    Now we close the group and end the definition: the value of
%    |\escapechar| as well as the |\uccode| and
%    |\catcode| of `\~{}' will be restored.
%    \begin{macrocode}
   \endgroup}
\endgroup
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{imacro}
%
%
%
%
% \begin{macro}{\init@crossref}
%    The replacement text of |\init@crossref| should fulfill the
%    following tasks:
%    \begin{itemize}
%       \parindent4em
%       \item[1)]
%          |\catcode| all characters used in macro names to
%          11 (i.e.\ `letter').
%       \item[2)]
%          |\catcode| the `|\|' character to 13
%          (i.e.\ `active').
%       \item[3a)]
%          |\let| the `|\|' equal |\scan@macro|
%          (i.e.\ start the macro scanning mechanism) if there is
%          no  special escape character (i.e.\ the
%          |\special@escape@char| is `|\|').
%       \item[3b)]
%          Otherwise |\let| it equal |\bslash|, i.e.\
%          produce a printable |\|.
%       \item[4)]
%          Make the \meta{special escape character} active.
%       \item[5)]
%          |\let| the active version of the special escape
%          character
%          (i.e.\ the expansion of |\active@escape@char|) equal
%          |\scan@macro|.
%    \end{itemize}
%    The reader might ask why we bother to |\catcode| the
%    `|\|' first to 12 (at the end of |\macro@code|) then
%    re-|\catcode| it to 13 in order to produce a $|\|_{12}$
%    in case 3b) above.  This is done because we have to ensure that
%    `|\|' has |\catcode| 13 within the \env{macrocode}
%    environment.  Otherwise the delimiter for the argument of
%    |\xmacro@code| would not be found (parameter matching
%    depends on |\catcode|$\,$s).
%
%    Therefore we first re-|\catcode| some characters.
%    \begin{macrocode}
\begingroup   \catcode`\|=\z@  \catcode`\\=\active
%    \end{macrocode}
%    We carry out tasks 2) and 3b) first.
%    \SpecialEscapechar\|
%    \begin{macrocode}
|gdef|init@crossref{|catcode`|\|active   |let\|bslash
%    \end{macrocode}
%    Because of the popularity of the `|@|' character as a
%    `letter' in macros, we normally have to change its
%    |\catcode| here, and thus fulfill task 1).  But the macro
%    designer might use other characters as private letters as well,
%    so we use a macro to do the |\catcode| switching.
%    \SpecialEscapechar\|
%    \begin{macrocode}
    |MakePrivateLetters
%    \end{macrocode}
%    Now we |\catcode| the special escape character to 13 and
%    |\let| it equal |\scan@macro|, i.e.\ fulfill tasks 4)
%    and 5). Note the use of |\expandafter| to insert the chosen
%    escape character saved in |\special@escape@char| and
%    |\active@escape@char|.
%    \SpecialEscapechar\|
%    \begin{macrocode}
    |catcode|expandafter`|special@escape@char|active
    |expandafter|let|active@escape@char|scan@macro}
|endgroup
%    \end{macrocode}
%    If there is no special escape character, i.e.\ if
%    |\SpecialEscapechar| is |\\|, the second last line will
%    overwrite the previous definition of $|\|_{13}$.  In this
%    way all tasks are fulfilled.
%
%    For happy documenting we give default values to
%    |\special@escape@char| and |\active@escape@char| with
%    the following line:
%    \begin{macrocode}
\SpecialEscapechar{\\}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{imacro}{\MakePrivateLetters}
%    Here is the default definition of this command, which makes just
%    the |@| into a letter. The user may change it if he/she
%    needs more or other characters masquerading as letters.
%    \begin{macrocode}
\@ifundefined{MakePrivateLetters}
    {\let\MakePrivateLetters\makeatletter}{}
%    \end{macrocode}
% \end{imacro}
%
% \begin{macro}{\close@crossref}
%    At the end of a cross-referencing part we prepare ourselves for
%    the next one by setting the escape character to `|\|'.
%    \begin{macrocode}
\def\close@crossref{\SpecialEscapechar\\}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \subsection{Macros for scanning macro names}
%
% \begin{macro}{\scan@macro}
% \changes{v1.5k}{1989/09/04}{Support for checksum added.}
% \begin{macro}{\macro@namepart}
%    The |\init@crossref| will have made |\active| our
%    |\special@escape@char|, so that each
%    |\active@escape@char| will invoke |\scan@macro| when
%    within the \env{macrocode} environment.  By this means, we can
%    automatically add index entries for every \TeX-like command which
%    is met whilst setting (in verbatim) the contents of
%    \env{macrocode} environments.
%    \begin{macrocode}
\def\scan@macro{%
%    \end{macrocode}
%    First we output the character which triggered this macro.  Its
%    version |\catcode|$\,$d to 12 is saved in
%    |\special@escape@char|. We also call |\step@checksum|
%    to generate later on a proper check-sum (see section
%    \ref{sec:checksum} for details).
%    \begin{macrocode}
   \special@escape@char
   \step@checksum
%    \end{macrocode}
%    If the \env{macrocode} environment contains, for example, the
%    command |\\|, the second |\| should not start the
%    scanning mechanism. Therefore we use a switch to decide if
%    scanning of macro names is allowed.
%    \begin{macrocode}
   \ifscan@allowed
%    \end{macrocode}
%    The macro assembles the letters forming a \TeX\ command in
%    |\macro@namepart| so this is initially cleared; we then set
%    |\next| to the \textit{first\/} character following the
%    |\| and call |\macro@switch| to determine whether that
%    character is a letter or not.
%    \begin{macrocode}
      \let\macro@namepart\@empty
      \def\next{\futurelet\next\macro@switch}%
%    \end{macrocode}
%    As you recognize, we actually did something else, because we have
%    to defer the |\futurelet| call until after the final
%    |\fi|.  If, on the other hand, the scanning is disabled we
%    simply |\let| |\next| equal `empty'.
%    \begin{macrocode}
   \else \let\next\@empty \fi
%    \end{macrocode}
%    Now we invoke |\next| to carry out what's needed.
%    \begin{macrocode}
   \next}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \begin{imacro}{\EnableCrossrefs}
% \begin{imacro}{\DisableCrossrefs}
%    At this point we might define two macros which allow the user to
%    disable or enable the cross-referencing mechanism. Processing of
%    files will be faster if only main index entries are generated
%    (i.e., if |\DisableCrossrefs| is in force).
%    \begin{macrocode}
\def\DisableCrossrefs{\@bsphack\scan@allowedfalse\@esphack}
%    \end{macrocode}
%    The macro |\EnableCrossrefs| will also disable any
%    |\DisableCrossrefs| command encountered afterwards.
%    \begin{macrocode}
\def\EnableCrossrefs{\@bsphack\scan@allowedtrue
                     \def\DisableCrossrefs{\@bsphack\@esphack}\@esphack}
%    \end{macrocode}
% \end{imacro}
% \end{imacro}
%
%
%
%
% \begin{macro}{\macro@switch}
%    Now that we have the character which follows the escape character
%    (in |\next|), we can determine whether it's a `letter'
%    (which probably includes |@|).
%
%    If it is, we let |\next| invoke a macro which assembles the
%    full command name.
%    \begin{macrocode}
\def\macro@switch{\ifcat\noexpand\next a%
     \let\next\macro@name
%    \end{macrocode}
%    Otherwise, we have a `single-character' command name.  For all
%    those single-character names, we use |\short@macro| to
%    process them into suitable index entries.
%    \begin{macrocode}
     \else \let\next\short@macro  \fi
%    \end{macrocode}
%    Now that we know what macro to use to process the macro name, we
%    invoke it~\ldots
%    \begin{macrocode}
   \next}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\short@macro}
%
% \changes{v1.5c}{1989/04/27}{Corrected bad bug by putting the
%                         scan@allowedfalse macro before printing
%                         the argument.}
% \changes{v1.7a}{1992/03/10}{Ensure character stored in
%           \cs{macro@namepart} as `letter' so index exclusion works.}
%    This macro will be invoked (with a single character as parameter)
%    when a single-character macro name has been spotted whilst
%    scanning within the \env{macrocode} environment.
%
%    First we take a look at the |\index@excludelist| to see
%    whether this macro name should produce an index entry.  This is
%    done by the |\ifnot@excluded| macro which assumes that the
%    macro name is saved in |\macro@namepart|.  The character
%    mustn't be stored with a special category code or exclusion from
%    the index won't work, so we we use \cs{string} to normalize it
%    the same way it is done in \cs{DoNotIndex}, i.e. everything ends up catcode 12
%    except for the space character.
% \changes{v2.0e}{1998/12/28}{Correctly use the case-changing trick.}
% \changes{v3.0l}{2022/11/03}{No longer using the case-changing trick.}
%    \begin{macrocode}
\def\short@macro#1{%
   \edef\macro@namepart{\string#1}%
%    \end{macrocode}
%    Any indexing is then delegated to
%    |\maybe@index@short@macro|. Depending on the actual character seen,
%    this macro has to do different things, which is why we keep it separate from
%    |\maybe@index@macro| to avoid the special tests in the more
%    common case of a multi-letter macro name.
%    \begin{macrocode}
     \maybe@index@short@macro\macro@namepart
%    \end{macrocode}
%    Then we disable the cross-referencing mechanism with
%    |\scan@allowedfalse| and print the actual character. The
%    index entry was generated first to ensure that no page break
%    intervenes (recall that a |^^M| will start a new line).
%    \begin{macrocode}
    \scan@allowedfalse#1%
%    \end{macrocode}
%    After typesetting the character we can safely enable the
%    cross-referencing feature again. Note that this macro won't be
%    called (since |\macro@switch| won't be called) if
%    cross-referencing is globally disabled.
%    \begin{macrocode}
    \scan@allowedtrue }
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\macro@name}
%    We now come to the macro which assembles command names which
%    consist of one or more `letters' (which might well include
%    |@| symbols, or anything else which has a |\catcode| of
%    11).
%
%    To do this we add the `letter' to the existing definition of
%    |\macro@namepart| (which you will recall was originally set
%    to |\@empty|).
%    \begin{macrocode}
\def\macro@name#1{\edef\macro@namepart{\macro@namepart#1}%
%    \end{macrocode}
%    Then we grab hold of the {\em next\/} single character and let
%    |\more@macroname| determine whether it belongs to the letter
%    string forming the command name or is a `non-letter'.
%    \begin{macrocode}
     \futurelet\next\more@macroname}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
% \begin{macro}{\more@macroname}
%
%    This causes another call of |\macro@name| to add in the next
%    character, if it is indeed a `letter'.
%    \begin{macrocode}
\def\more@macroname{\ifcat\noexpand\next a%
     \let\next\macro@name
%    \end{macrocode}
%    Otherwise, it finishes off the index entry by invoking
%    |\macro@finish|.
%    \begin{macrocode}
     \else \let\next\macro@finish \fi
%    \end{macrocode}
%    Here's where we invoke whatever macro was |\let| equal to
%    |\next|.
%    \begin{macrocode}
     \next}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
% \begin{macro}{\macro@finish}
%    When we've assembled the full `letter'-string which forms the
%    command name, we set the characters forming the entire command
%    name, and generate an appropriate |\index| command (provided
%    the command name is not on the list of exclusions).  The
%    `|\|' is already typeset; therefore we only have to output
%    all `letters' saved in |\macro@namepart|.
%    \begin{macrocode}
\def\macro@finish{%
  \macro@namepart
%    \end{macrocode}
%    Then we call |\ifnot@excluded| to decide whether we have to
%    produce an index entry. The construction with |\@tempa| is
%    needed because we want the expansion of |\macro@namepart| in
%    the |\index| command.\footnote{The \texttt{\bslash index}
%    command will expand its argument in the \texttt{\bslash output}
%    routine.  At this time \texttt{\bslash macro@namepart} might have a
%    new value.}
%    \begin{macrocode}
%  \ifnot@excluded
%     \edef\@tempa{\noexpand\SpecialIndex{\bslash\macro@namepart}}%
%     \@tempa  \fi
  \maybe@index@macro \macro@namepart
}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
% \subsection[The index exclude list]{The index exclude
%             list\footnotemark}
%            \footnotetext{Info: the incomplete commentary on
%            \texttt{\bslash DoNotIndex} and the macros it calls
%                          was written by Dave Love.}
%
%
%

% \def\MakePrivateLetters{%
%    \makeatletter
%    \catcode`\_11
%    \catcode`\:11}
%
%
% The following part of the code is a new implementation using the
% \LaTeX3 programming layer as the constructs and types
% provided therein are making programming much easier. Over time I
% will probably replace the rest of that \DOC code too.
%    \begin{macrocode}
\ExplSyntaxOn
%    \end{macrocode}
%
%
% \DescribeMacro\l__doc_donotindex_seq
%    Local sequence that holds names (as strings) of commands that
%    should not be indexed. Within a \DOC element environment that
%    element is placed into the sequence so that it isn't
%    unnecessarily index within that part of the code. As the sequence
%    is local it will revert this setting at the end of the
%    environment so that the command is indexed elsewhere (unless it
%    is generally disabled from indexing.
%
% \DescribeMacro\g__doc_idxtype_prop
%    Global property list that holds for all commands that are special
%    \DOC elements the type of the element. The key is the command
%    name without backslash and the  value is \DOC element type
%    identifier, e.g., |\texttt{Length}| for length registers if that
%    type has been set up. \DOC only indexes commands, that is things
%    starting with an escape character, i.e., a backslash (by
%    default). \DOC elements that do not start with an escape
%    character, e.g., environments are not identified when parsing
%    code so that aren't indexed automatically inside. Thus for them
%    there is no point in keeping them in that property list.
%
% \DescribeMacro{\doc_dont_index:n}
% \DescribeInterfaceMacro{\DoNotIndex}
%    Takes a clist of commands (with backslash) as input and exclude
%    all of them from the index. User facing we make this available as
%    |\DoNotIndex|.
%
%
% \DescribeInterfaceMacro\ShowIndexingState
%    Displays the current list of the exclude index list in a fairly
%    low-level form.
%
% \DescribeInterfaceMacro\RecordIndexType
%    This command takes two arguments: a command (with escape char)
%    and its type (i.e., first mandatory
%    argument of a |\NewDocElement| declaration. If |#1| should not be
%    included from the index, then the data is used to record that
%    this command is of this type. The information is then used to
%    generate appropriate index entries. Obviously, index entries
%    generated earlier will be listing the wrong type. Therefore this
%    information is also placed into the \texttt{.aux} file so that it
%    will be available  at the beginning of further runs.
%
%    This command is internally executed as part of any \DOC element
%    environment so  it only needs to be explicitly given if for some
%    reason a command with a special type has no corresponding environment.
%
%
%
%
%  \begin{macro}{\l__doc_donotindex_seq}
%  \begin{macro}{\g__doc_idxtype_prop}
%    Declarations.
%    \begin{macrocode}
\seq_new:N  \l__doc_donotindex_seq
\prop_new:N \g__doc_idxtype_prop
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
% ^^A --------------------------------------------------
%
%
%  \begin{macro}{\__doc_trace:x}
%    A helper for tracing\ldots
%    \begin{macrocode}
\cs_new:Npn\__doc_trace:x {
  \legacy_if:nTF{ doc@debugshow }{ \iow_term:x } { \use_none:n }
}
%    \end{macrocode}
%  \end{macro}
%
%
% ^^A --------------------------------------------------
%
%  \begin{macro}{\doc_dont_index:n}
%  \begin{macro}{\__doc_dont_index:n}
%  \begin{macro}{\__doc_dont_index_aux:n}
%
%    Parses the argument a clist of commands with
%    |\MakePrivateLetters| in force (so that special characters are
%    recognized as being part of command names) and puts each command
%    without is backslash as a string into the sequence
%    |\l__doc_donotindex_seq|.
%    \begin{macrocode}
\cs_new:Npn \doc_dont_index:n {
  \group_begin:
    \MakePrivateLetters
    \__doc_dont_index:n
}
%    \end{macrocode}
%
%    \begin{macrocode}
\cs_new:Npn \__doc_dont_index:n #1 {
  \group_end:
%    \end{macrocode}
%
%    \begin{macrocode}
  \__doc_trace:x{Disable~ indexing~ for~ '\tl_to_str:n{#1}' }
%    \end{macrocode}
%    Adding the commands to the |\l__doc_donotindex_seq| sequence is
%    done by mapping the function |\__doc_dont_index_aux:n|  on each
%    element in the clist.
%    \begin{macrocode}
  \clist_map_function:nN {#1} \__doc_dont_index_aux:n
}
%    \end{macrocode}
%    We record each command by using its name as a string.
%    This means more tokens in the sequence but it allows
%    to compare names not ``action'' which is important as different
%    commands may have the same meaning (e.g., they may not be defined
%    at all),
%    \begin{macrocode}
\cs_new:Npn \__doc_dont_index_aux:n #1 {
  \seq_put_right:Nx \l__doc_donotindex_seq {\expandafter\@gobble \string#1}
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\DoNotIndex}
%    The document-level interface
%    \begin{macrocode}
\cs_set_eq:NN \DoNotIndex \doc_dont_index:n
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\ShowIndexingState}
%    Some tracing information that may be helpful.
%    \begin{macrocode}
\def \ShowIndexingState {
  \__doc_trace:x{Show~ doc~ indexing~ state:}
  \seq_show:N  \l__doc_donotindex_seq
  \prop_show:N \g__doc_idxtype_prop
}
%    \end{macrocode}
%  \end{macro}



% ^^A --------------------------------------------------
%
%
%  \begin{macro}{\__doc_idxtype_put:Nn}
%  \begin{imacro}{\RecordIndexType}
%  \fmi{Change name of interface command!}
%  \begin{macro}{\RecordIndexTypeAux}
%    This is the internal form for |\RecordIndexType|. The first
%    argument is turned into a string and the rest of the processing
%    is then done by |\__doc_idxtype_put:nn|
%    \begin{macrocode}
\cs_new:Npn \__doc_idxtype_put:Nn #1#2 {
  \exp_args:Nx \__doc_idxtype_put:nn { \cs_to_str:N #1 }{#2}
%    \end{macrocode}
%    We also make an entry in the \texttt{.aux} file so that this
%    declaration becomes immediately available in the next
%    run. However, for this we aren't reusing |\__doc_idxtype_put:N|
%    (a.k.a.\ |\RecordIndexType|) since that would result in doubling
%    such lines each time the document is run. Instead we use
%    |\RecordIndexTypeAux| which is only updating the data structures
%    without writing to the \texttt{.aux} file.
%    \begin{macrocode}
  \protected@write\@auxout{}
     {\string\RecordIndexTypeAux {\string#1 }{#2} }
}
%    \end{macrocode}
%    When we execute this code from the \texttt{.aux} we better not
%    generate a new line in the \texttt{.aux}. Otherwise those would
%    cumulate over time.
%    \begin{macrocode}
\cs_new:Npn \RecordIndexTypeAux #1#2 {
  \exp_args:Nx \__doc_idxtype_put:nn { \cs_to_str:N #1 }{#2}
}
%    \end{macrocode}
%    Similarly, when the \texttt{.aux} is read at the end of the run we
%    should disable that command to avoid unnecessary processing.
%    \begin{macrocode}
\AtEndDocument{
  \cs_set_eq:NN \RecordIndexTypeAux \use_none:nn
}
%    \end{macrocode}
%    Finally, we provide the user-level interface
%    \begin{macrocode}
\cs_set_eq:NN \RecordIndexType \__doc_idxtype_put:Nn
%    \end{macrocode}
%  \end{macro}
%  \end{imacro}
%  \end{macro}
%
%
%  \begin{macro}{\__doc_idxtype_put_scan:nn}
%    When we want to record an index type for a scanned name we can't
%    turn that into a csname and then call |\__doc_idxtype_put:Nn|
%    because turning it into a csname may change the meaning of the
%    name from ``undefined'' to |\relax|. Got bitten by that when
%    processing the kernel sources containing |\@undefined| within the
%    code: suddenly that wasn't undefined any longer.
%    So here is another version that works only on characters as
%    input. As we don't know whether or not they are proper strings
%    already we first make sure that this is the case.
%    \begin{macrocode}
\cs_new:Npn \__doc_idxtype_put_scan:nn #1#2 {
  \exp_args:Nf \__doc_idxtype_put:nn { \tl_to_str:n {#1} }{#2}
%    \end{macrocode}
%    In this case we also have to append a backslash when writing to
%    the \texttt{.aux} file.
%    \begin{macrocode}
  \protected@write\@auxout{}
     {\string\RecordIndexTypeAux {\bslash #1 }{#2} }
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\__doc_idxtype_put_scan:on}
%    And here is the one we really need since the characters are
%    stored in some macro.
%    \begin{macrocode}
\cs_generate_variant:Nn \__doc_idxtype_put_scan:nn {o}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\record@index@type@save}
%    And here is the interface to the rest of the code:
%    \begin{macrocode}
\cs_set_eq:NN \record@index@type@save \__doc_idxtype_put_scan:on
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\__doc_idxtype_put:nn}
%    This internal command takes two arguments: a command name as
%    string (no backslash) and its type (i.e., first mandatory
%    argument of a |\NewDocElement| declaration. If |#1| is not in
%    |\l__doc_donotindex_seq| it will add this data to the property
%    list |\g__doc_idxtype_prop| using |#1| as key and |#2| as its
%    value. If the key already exist its value will be overwritten. If
%    the command is later marked for exclusion from the index the
%    property list setting remains unchanged but as long as no index
%    is produced for the command it will not be consulted.
%
%   Note: the command assumes that |#1| is already in string form
%    \begin{macrocode}
\cs_new:Npn \__doc_idxtype_put:nn #1#2 {
%    \end{macrocode}
%    No mystery here: if the command is not marked for exclusion from
%    the index add the property. The extra |\tl_to_str:n| is a safety
%    measure in case the input wasn't already in that form (should
%    only be the case with broken input but \ldots)
%    \begin{macrocode}
  \exp_args:NNf
  \seq_if_in:NnTF \l__doc_donotindex_seq {\tl_to_str:n{#1}}
%    \end{macrocode}
%    Some tracing info \ldots{}
%    \begin{macrocode}
     {
       \__doc_trace:x{Not~ recording~ index~ type~ for~ '\bslash #1' }
     }
     {
       \__doc_trace:x{Recording~ index~ type~ for~ '\bslash #1' ~ as~ #2 }
%    \end{macrocode}
%    Stick the data into the property list:
%    \begin{macrocode}
       \prop_gput:Nnn \g__doc_idxtype_prop {#1}{#2}
     }
}
%    \end{macrocode}
%  \end{macro}
%
% ^^A --------------------------------------------------
%
%
%  \begin{macro}{\exp_args:co}
%    A helper: construct a function and call it with its first argument
%    expanded once:
%    \begin{macrocode}
\cs_new:Npn \exp_args:co #1#2
   { \cs:w #1 \exp_after:wN \cs_end:\exp_after:wN {#2} }
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\tl_to_str:o}
%    Another helper: take some token list variable, expand it and turn
%    it into a string.
%    \begin{macrocode}
\cs_generate_variant:Nn \tl_to_str:n {o}
%    \end{macrocode}
%  \end{macro}
%
%
%
% ^^A --------------------------------------------------
%
%
%
% \DescribeMacro\maybe@index@macro
%
%    This takes a macro name (without backslash) as parsed within a
%    \env{macrocode} environment and checks if it should get indexed
%    (i.e., is not on the exclude list) and if so how (i.e., gets it
%    index type property and makes the right choice depending on that.
%


%  \begin{macro}{\maybe@index@macro}
%  \begin{macro}{\__doc_maybe_index:o}
%    We first make sure that the argument is really a string (so that
%    we have a defined situation) and then
%    pass it on to |\__doc_maybe_index_aux:nN| to do the work.
%    The second argument defines the indexing operation
%    \cs{SpecialIndex} for multi-letter macros and below
%    \cs{SpecialShortIndex} for single character macros.
%    \begin{macrocode}
\cs_new:Npn \__doc_maybe_index:o #1 {
  \exp_args:Nf \__doc_maybe_index_aux:nN { \tl_to_str:o {#1} }
                                         \SpecialIndex
}
%    \end{macrocode}
%    And here is what we call it in the older non-expl3 code:
%    \begin{macrocode}
\cs_set_eq:NN \maybe@index@macro \__doc_maybe_index:o
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
%  \begin{macro}{\maybe@index@short@macro}
%  \begin{macro}{\__doc_maybe_index_short:o}
%    Single character macros are handled similarly but there the
%    indexing is done by \cs{SpecialShortIndex} and it is simpler
%    because we know that the argument contains a string token not letters.
% \changes{v3.0l}{2022/11/03}{We know the argument expands to a single string token}
%    \begin{macrocode}
\cs_new:Npn \__doc_maybe_index_short:o #1 {
  \exp_args:No \__doc_maybe_index_aux:nN #1
                                         \SpecialShortIndex
}
\cs_set_eq:NN \maybe@index@short@macro \__doc_maybe_index_short:o
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
%
%  \begin{macro}{\__doc_maybe_index_aux:nN}
%    Take a string (representing a macro without backslash) and make
%    the right choices with respect to indexing.
%    \begin{macrocode}
\cs_new:Npn \__doc_maybe_index_aux:nN #1#2 {
%    \end{macrocode}
%    A bit of tracing:
%    \begin{macrocode}
  \__doc_trace:x{Searching~ for~ '\bslash #1'}
%    \end{macrocode}
%    If the name is on the exclude list do nothing.
%    \begin{macrocode}
  \seq_if_in:NnTF \l__doc_donotindex_seq {#1}
%    \end{macrocode}
%
%    \begin{macrocode}
    {
     \__doc_trace:x{Not~ indexing~ '\bslash #1' }
    }
%    \end{macrocode}
%    Otherwise check if this name has an index type property attached
%    to it.
%    \begin{macrocode}
    {
     \prop_get:NnNTF \g__doc_idxtype_prop {#1} \l__doc_idxtype_tl
%    \end{macrocode}
%    If so construct and execute
%    |\Code|\meta{idxtype}|Index|\footnote{I guess this should really
%    be an internal name not a user-level one.} which is done inside
%    |\__doc_maybe_index_aux|
%    \begin{macrocode}
       {
        \exp_args:Ncno \__doc_maybe_index_aux:Nnn
              { Code \tl_use:N \l__doc_idxtype_tl Index }
              {code} {\bslash #1}
        }
%    \end{macrocode}
%    Otherwise execute |\SpecialIndex| which is a short form for
%    |\CodeMacroIndex{code}| or execute \cs{SpecialShortIndex} which
%    deals with some special cases for single letter macros.
%    \begin{macrocode}
        {
          \__doc_trace:x{Indexing~ '\bslash #1'\space (\string #2)}
          \exp_args:No #2 {\bslash #1}
        }
    }
}
%    \end{macrocode}
%  \end{macro}
%
%
%
%  \begin{macro}{\SpecialShortIndex}
%    \fmi{to be documented; also needs cleaning up as it is a mix of
%    old and new right now}
%    \begin{macrocode}
\cs_new:Npn \SpecialShortIndex #1 {
    \@SpecialIndexHelper@ #1\@nil
  \@bsphack
  \ifdoc@noindex \else
    \str_case_e:nnF {\@gtempa }
        {
          {\cs_to_str:N \^^M } {\def\reserved@a{ \string \space \actualchar }
                                \def\reserved@b { \space }
                                \let\reserved@c \@empty                          }
%    \end{macrocode}
%    With the fix for
%    \verb*=\ = we now have to look for a real space to handle that command sequence.
% \changes{v3.0l}{2022/11/03}{look for the right token}
%    \begin{macrocode}
          { ~ }                {\def\reserved@a{ \string \space \actualchar }
                                \def\reserved@b { \space }
                                \let\reserved@c \@empty                          }
          {\c_left_brace_str} { \def\reserved@a{ \bgroup \actualchar }
                                \def\reserved@b { \c_left_brace_str }
                                \def\reserved@c { \noexpand\iffalse
                                                  \c_right_brace_str
                                                  \noexpand\fi }                 }
          {\c_right_brace_str} { \def\reserved@a{ \egroup \actualchar
                                                  \noexpand\iffalse
                                                    \c_left_brace_str
                                                  \noexpand\fi }
                                 \def\reserved@b { \c_right_brace_str }
                                 \let\reserved@c \@empty                         }
%    \end{macrocode}
%    The case of \cs{verbatimchar} is tricky. We can't stick it into
%    the normal \cs{verb} because we would then get something like
%    \verb=\verb+\++= which would comes out as ``\verb+\++'' instead
%    of \verb=\+=. So we use the \cs{verb} to only generate the
%    backslash and then use \cs{texttt} on the \cs{verbatimchar}
%    itself. However, that is not enough if we are unlucky and
%    somebody (like Will :-)) has used something like \verb=&= with a
%    special catcode for the \cs{verbatimchar}. We therefore also
%    apply \cs{string} to it when we read it back.
%    \begin{macrocode}
          {\verbatimchar}  { \def\reserved@a{ \quotechar\verbatimchar
                                              \actualchar }
                             \let\reserved@b \@empty
                             \def\reserved@c
                                 { \string\texttt{\string\string\verbatimchar} } }
        }
        { \def\reserved@a {\quotechar \@gtempa \actualchar }
          \def\reserved@b {\quotechar \@gtempa  }
          \let\reserved@c \@empty                             }
    \special@index {
    \reserved@a
    \string\verb
    \quotechar *\verbatimchar \quotechar \bslash
    \reserved@b
    \verbatimchar
    \reserved@c
    \encapchar code}
  \fi
  \@esphack
}
%    \end{macrocode}
%  \end{macro}





%  \begin{macro}{\__doc_maybe_index_aux:Nnn}
%    Execute the function passed on as first argument taking argument
%    2 and 3 as input.
%    \begin{macrocode}
\cs_new:Npn \__doc_maybe_index_aux:Nnn #1#2#3 {
%    \end{macrocode}
%    We have to be a little careful: as that function name is
%    constructed it may not actually exist (as constructions generate
%    |\relax| in \TeX{} in that case). In that case we raise an error,
%    otherwise we execute (with a little bit of tracing info):
%    \begin{macrocode}
    \cs_if_exist:NTF #1
      {
        \__doc_trace:x{Indexing~ '#3'\space as~
                       \tl_use:N \l__doc_idxtype_tl }
        #1{#2}{#3}
      }
      {
        \PackageError{doc}{Doc~ element~
           '\tl_use:N \l__doc_idxtype_tl'~ unknown}%

          {When~ using~ '\string\RecordIndexType'~ the~ type~ must~
           be~ known~\MessageBreak
           to~ the~ system,~ i.e.,~ declared~ via~
           '\string\NewDocElement'\MessageBreak
           before~ it~ can~ be~ used~ in~ indexing.}
     }
}
%    \end{macrocode}
%  \end{macro}
%
%
%    Back to old style coding \ldots
%    \begin{macrocode}
\ExplSyntaxOff
%    \end{macrocode}
%
%
%
% \subsection{Macros for generating index entries}
%
% Here we provide default definitions for the macros invoked to create
% index entries; these are either invoked explicitly, or automatically
% by |\scan@macro|.  As already mentioned, the definitions given
% here presuppose that the |.idx| file will be processed by
% Chen's \prg{makeindex} program --- they may be redefined for use
% with the user's favorite such program.
%
% To assist the reader in locating items in the index, all such
% entries are sorted alphabetically {\em ignoring\/} the initial
% `|\|'; this is achieved by issuing an |\index| command which
% contains the `actual' operator for \prg{makeindex}.  The default
% value for the latter operator is `|@|', but the latter character is
% so popular in \LaTeX\ package files that it is necessary to substitute
% another character.  This is indicated to \prg{makeindex} by means
% of an `index style file'; the character selected for this function
% is |=|, and therefore this character too must be specially treated
% when it is met in a \TeX\ command.  A suitable index style file is
% provided amongst the supporting files for this style file in
% \texttt{gind.ist} and is generated from this source by processing
% with \texttt{docstrip} to extract the module \textbf{gind}.  A
% similar style file \texttt{gglo.ist} is supplied for sorting the
% change information in the glossary file and is extracted as module
% \textbf{gglo}.  First of all we add some information to the front of
% the \texttt{.ist} files.  \changes{v1.7a}{1992/03/11}{glo.ist and
% gind.ist now derivable from doc.dtx with docstrip.}
%    \begin{macrocode}
%</package>
%<+gind|gglo>%% This is a MAKEINDEX style file which should be used to
%<+gind>%% generate the formatted index for use with the doc
%<+gglo>%% generate the formatted change history for use with the doc
%<+gind|gglo>%% package. The TeX commands used below are defined in
%<+gind|gglo>%% doc.sty.  The commands for MAKEINDEX like `level'
%<+gind|gglo>%% `item_x1' are described in `` Makeindex, A General
%<+gind|gglo>%% Purpose, Formatter-Independent Index Processor'' by
%<+gind|gglo>%% Pehong Chen.
%<+gind|gglo>
%    \end{macrocode}
%
% \begin{imacro}{\actualchar}
% \begin{imacro}{\quotechar}
% \begin{imacro}{\levelchar}
%    First come the definitions of |\actualchar|,
%    |\quotechar| and |\levelchar|. Note, that our defaults
%    are not the ones used by the \prg{makeindex} program without a
%    style file.
%    \begin{macrocode}
%<*package>
\@ifundefined{actualchar}{\def\actualchar{=}}{}
\@ifundefined{quotechar}{\def\quotechar{!}}{}
\@ifundefined{levelchar}{\def\levelchar{>}}{}
%</package>
%<+gind|gglo>actual '='
%<+gind|gglo>quote '!'
%<+gind|gglo>level '>'
%<*package>
%    \end{macrocode}
% \end{imacro}
% \end{imacro}
% \end{imacro}
%
%
% \begin{imacro}{\encapchar}
%    The \prg{makeindex} default for the |\encapchar| isn't
%    changed.
%    \begin{macrocode}
\@ifundefined{encapchar}{\def\encapchar{|}}{}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{imacro}{\verbatimchar}
%    We also need a special character to be used as a delimiter for
%    the |\verb*| command used in the definitions below.
%    \begin{macrocode}
\@ifundefined{verbatimchar}{\def\verbatimchar{+}}{}
%    \end{macrocode}
% \end{imacro}
%
%
%
% \begin{macro}{\@SpecialIndexHelper@}
%    \fmi{doc or drop}
%    \begin{macrocode}
\begingroup
 \catcode`\|=0
 \catcode`\\=12
%    \end{macrocode}
%    \SpecialEscapechar\|
%    \begin{macrocode}
 |gdef|@SpecialIndexHelper@#1#2|@nil{%
   |if |noexpand#1\%
     |gdef|@gtempa{#2}%
   |else
     |begingroup
       |escapechar|m@ne
       |expandafter|gdef|expandafter|@gtempa|expandafter{|string#1#2}%
     |endgroup
   |fi}
|endgroup
%    \end{macrocode}
%
% \end{macro}
%
%
%
% \begin{imacro}{\SortIndex}
%    This macro is used to generate the index entries for any
%    single-character command that |\scan@macro| encounters.  The
%    first parameter specifies the lexical order for the character,
%    whilst the second gives the actual characters to be printed in
%    the entry. It can also be used directly to generate index entries
%    which differ in sort key and actual entry.
%    \begin{macrocode}
\def\SortIndex#1#2{%
  \ifdoc@noindex\else
    \index{#1\actualchar#2}%
  \fi
}
%    \end{macrocode}
% \end{imacro}
%
%
%
%
% \begin{imacro}{\LeftBraceIndex}
% \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
% \begin{imacro}{\RightBraceIndex}
% \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)} These
%    two macros fix the problems with \prg{makeindex}.  Note the
%    `hack' with |\iffalse}\fi| to satisfy both \TeX{} and the
%    \prg{makeindex} program. When this is written to the
%    \texttt{.idx} file \TeX{} will see both braces (so we get a
%    balanced text).  \prg{makeindex} will also see balanced braces
%    but when the actual index entry is again processed by \TeX{} the
%    brace in between |\iffalse| |\fi| will vanish.
%    \begin{macrocode}
\@ifundefined{LeftBraceIndex}{\def\LeftBraceIndex{%
   \special@index{\bgroup\actualchar
                  \string\verb% % to fool emacs highlighting
                  \quotechar*\verbatimchar
                  \quotechar\bslash{\verbatimchar\string\iffalse}\string\fi}}}{}

\@ifundefined{RightBraceIndex}{\def\RightBraceIndex{%
 \special@index{\egroup\actualchar\string\iffalse{\string\fi
           \string\verb% % to fool emacs highlighting
           \quotechar*\verbatimchar\quotechar\bslash}\verbatimchar}}}{}
%    \end{macrocode}
% \end{imacro}
% \end{imacro}
%
%
% \begin{imacro}{\PercentIndex}
% \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
% \changes{v1.7c}{1992/03/25}{Default now for bug-fixed makeindex}
% By default we assume a version of \prg{makeindex} without the
% percent bug is being used.
%    \begin{macrocode}
\@ifundefined{PercentIndex}
  {\def\PercentIndex{\it@is@a\percentchar}}{}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{omacro}{\OldMakeindex}
% \changes{v1.7c}{1992/03/26}{Replaced \cs{NewMakeIndex}.}
% \begin{imacro}{\percentchar}
%    Here is one solution for the percent bug in \prg{makeindex}.
%    The macro |\percentchar| denotes a |%|$_{12}$.  Calling this from
%    a package or the driver file sets things up
%    appropriately.\label{bug:fixes}
%    \begin{macrocode}
\def\OldMakeindex{\def\PercentIndex{%
    \special@index{\quotechar\percentchar\actualchar
           \string\verb% % to fool emacs highlighting
           \quotechar*\verbatimchar\quotechar\bslash
           \percentchar\percentchar\verbatimchar}}}
{\catcode`\%=12 \gdef\percentchar{%}}
%    \end{macrocode}
% \end{imacro}
% \end{omacro}
%
%
% \begin{macro}{\it@is@a}
%    This macro is supposed to produce a correct |\SortIndex|
%    entry for a given character. Since this character might be
%    recognized as a `command' character by the index program used,
%    all characters are quoted with the |\quotechar|.
% \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
%    \begin{macrocode}
\def\it@is@a#1{\special@index{\quotechar #1\actualchar
                          \string\verb% % to fool emacs highlighting
                          \quotechar*\verbatimchar
                          \quotechar\bslash\quotechar#1\verbatimchar}}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
%
% \subsection{Redefining the \env{index} environment}
%
%\changes{v1.4r}{1989/04/22}{twocols env. placed into separate file}
%\changes{v1.4?}{1989/04/19}{use DEK's algorithm and implement
%                         a twocols env.}
%\changes{v1.4?}{1989/04/16}{changes to the index env.}
%\changes{v1.5a}{1989/04/26}{Now input multicol.sty instead of
%                         multcols.sty}

%
% \begin{ldimen}{\IndexMin}
% \begin{lcounter}{IndexColumns}
%    \changes{v1.4t}{1989/04/24}{Counter added.}
%    If \texttt{multicol} is in use,
%    when the index is started we compute the remaining space on the
%    current page; if it is greater than |\IndexMin|, the first
%    part of the index will then be placed in the available space.
%    The number of columns set is controlled by the counter
%    |\c@IndexColumns| which can be changed with a
%    |\setcounter| declaration.
%    \begin{macrocode}
\newdimen\IndexMin         \IndexMin       = 80pt
\newcount\c@IndexColumns   \c@IndexColumns = 3
%    \end{macrocode}
% \end{lcounter}
% \end{ldimen}
%
%
%
% \begin{environment}{theindex}
%    Now we start the multi-column mechanism, if appropriate. We use the
%    \LaTeX{} counter |\c@IndexColumns|  declared above to denote
%    the number of columns and insert the `index prologue' text (which
%    might contain a |\section| call, etc.). See the default
%    definition for an example.
%    \changes{v1.4t}{1989/04/24}{Incorporated new multicols env.}
%    \changes{v1.5a}{1989/04/26}{Call multicols first}
%    \changes{v1.6e}{1991/04/03}{Turned into env definition.}
%    \changes{v1.7a}{1992/03/04}{Include test for multicols.}
%    \begin{macrocode}
\ifdoc@multicol
%    \end{macrocode}
%
%    \begin{macrocode}
  \RequirePackage{multicol}
%    \end{macrocode}
%
%    \begin{macrocode}
  \renewenvironment{theindex}
    {\begin{multicols}\c@IndexColumns[\index@prologue][\IndexMin]%
%    \end{macrocode}
%    Then we make a few last minute assignments to read the individual
%    index |\item|$\,$s and finish off by ignoring any initial
%    space.
%    \begin{macrocode}
      \IndexParms \let\item\@idxitem \ignorespaces}%
%    \end{macrocode}
%
% \begin{macro}{\endtheindex}
%    \changes{v1.4t}{1989/04/24}{Incorporated new multicols env.}
%    At the end of the index, we have only to end the \env{multicols}
%    environment.
%    \begin{macrocode}
    {\end{multicols}}
%    \end{macrocode}
%    If we can't use \env{multicols} we warn the user and use an
%    environment that's basically the one from \texttt{article.sty}.
%    \begin{macrocode}
\else
  \def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
    \columnseprule \z@  \columnsep 35\p@
    \twocolumn[\index@prologue]%
    \IndexParms \let\item\@idxitem \ignorespaces}
  \def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
\fi
%    \end{macrocode}
% \end{macro}
% \end{environment}
%
% Here are the necessary \prg{makeindex} declarations. We disable
% scanning of macro names inside the index with |\scan@allowedfalse\n|
% to avoid recursion.
%    \begin{macrocode}
%</package>
%<+gind>preamble
%<+gind>"\n \\begin{theindex} \n \\makeatletter\\scan@allowedfalse\n"
%<+gind>postamble
%<+gind>"\n\n \\end{theindex}\n"
%<*package>
%    \end{macrocode}
%
%
% \begin{imacro}{\IndexPrologue}
% \begin{macro}{\index@prologue}
% \changes{v1.9w}{1995/12/27}{Text changed}
% \changes{v1.9x}{1996/01/11}{Text depends on code lines used}
%    The |\IndexPrologue| macro is used to place a short message
%    into the document above the index.  It is implemented by
%    redefining |\index@prologue|, a macro which holds the
%    default text.  We'd better make it a |\long| macro to allow
%    |\par| commands in its argument.
%    \begin{macrocode}
\long\def\IndexPrologue#1{\@bsphack\def\index@prologue{#1}\@esphack}
%    \end{macrocode}
%    Now we test whether the default is already defined by another
%    package file. If not we define it.
% \changes{v2.0j}{2000/05/22}{Less obscure wording? (CAR pr/3202)}
%    \begin{macrocode}
\@ifundefined{index@prologue}
     {\def\index@prologue{\section*{Index}%
                 \markboth{Index}{Index}%
                 Numbers written in italic refer to the page
                 where the corresponding entry is described;
                 numbers underlined refer to the
                 \ifcodeline@index
                   code line of the
                 \fi
                 definition; numbers in roman refer to the
                 \ifcodeline@index
                   code lines
                 \else
                   pages
                 \fi
                 where the entry is used.
                 }}{}
%    \end{macrocode}
% \end{macro}
% \end{imacro}
%
%
%
% \begin{imacro}{\IndexParms}
%    These are some last-minute assignments for formatting the index
%    entries. They are defined in a separate macro so that a user can
%    substitute different definitions.  We start by defining the
%    various parameters controlling leading and the separation between
%    the two columns.  The entire index is set in |\small| size.
%    \begin{macrocode}
\@ifundefined{IndexParms}
    {\def\IndexParms{%
       \parindent \z@
       \columnsep 15pt
       \parskip 0pt plus 1pt
       \rightskip 15pt
       \mathsurround \z@
       \parfillskip=-15pt
        \small
%    \end{macrocode}
% \begin{macro}{\@idxitem}
% \begin{macro}{\subitem}
% \begin{macro}{\subsubitem}
%    Index items are formatted with hanging indentation for any items
%    which may require more than one line.
%    \begin{macrocode}
       \def\@idxitem{\par\hangindent 30pt}%
%    \end{macrocode}
%    Any sub-item in the index is formatted with a 15pt indentation
%    under its main heading.
%    \begin{macrocode}
       \def\subitem{\@idxitem\hspace*{15pt}}%
%    \end{macrocode}
%    Whilst sub-sub-items go in a further 10pt.
%    \begin{macrocode}
       \def\subsubitem{\@idxitem\hspace*{25pt}}%
%    \end{macrocode}
% \begin{macro}{\indexspace}
%    The \prg{makeindex} program generates an |\indexspace|
%    before each new alphabetic section commences. After this final
%    definition we end the |\@ifundefined| and the definition of
%    |\IndexParms|.
%    \begin{macrocode}
       \def\indexspace{\par\vspace{10pt plus 2pt minus 3pt}}%
      }}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{imacro}
%
%
% \begin{imacro}{\efill}
%    This definition of |\efill| is intended to be used after index
%    items which have no following text (for example, ``\textit{
%    see\/}'' entries).  It just ensures that the current line is
%    filled, preventing ``|Underfull \hbox|'' messages.
%    \begin{macrocode}
\def\efill{\hfill\nopagebreak}%
%</package>
%<+gind|gglo>item_x1   "\\efill \n \\subitem "
%<+gglo>item_x2   "\\ "
%<+gind>item_x2   "\\efill \n \\subsubitem "
%<*package>
%    \end{macrocode}
% \end{imacro}
%
%
%
% \begin{imacro}{\pfill}
%     The following definitions provide the |\pfill| command; if
%    this is specified in the index style file to \prg{makeindex} as
%    the delimiter to appear after index items, then the intervening
%    space before the referenced page numbers will be filled with
%    dots, with a little white space interpolated at each end of the
%    dots.  If the line is broken the dots will show up on both lines.
%    \begin{macrocode}
\def\pfill{\unskip~%
           \leaders\hbox to.6em{\hss .\hss}\hfill
           \penalty500\strut\nobreak
           \leaders\hbox to.6em{\hss .\hss}\hfil
           ~\ignorespaces}%
%</package>
%<+gind|gglo>delim_0   "\\pfill "
%<+gind|gglo>delim_1   "\\pfill "
%<+gind|gglo>delim_2   "\\pfill "
%<*package>
%    \end{macrocode}
% \end{imacro}
%
%
%
% \begin{imacro}{\*}
%    Here is the definition for the |\*| macro. It isn't used in
%    this set of macros.
%    \begin{macrocode}
\def\*{\leavevmode\lower.8ex\hbox{$\,\widetilde{\ }\,$}}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{imacro}{\main}
%    The \textit{defining\/} entry for a macro name is flagged with
%    the string \texttt{\encapchar main}\footnote{With the current
%    definition of \texttt{\bslash encapchar} substituted for
%    \texttt{\encapchar}} in the |\index| command; \prg{makeindex}
%    processes this so that the |\main| macro will be invoked to
%    underline the page number(s) on which the {\em definition\/} of
%    the macro will be found.
%    \begin{macrocode}
\@ifundefined{main}{\def\main#1{\underline{#1}}}{}
%    \end{macrocode}
% \end{imacro}
%
% \begin{imacro}{\usage}
%    The |\usage| macro is used to indicate entries describing
%    the usage of a macro. The corresponding page number(s) will be
%    set in \textit{italics}.
%    \begin{macrocode}
\@ifundefined{usage}{\def\usage#1{\textit{#1}}}{}
%    \end{macrocode}
% \end{imacro}
%
% \begin{imacro}{\code}
%    The |\code| macro is used to indicate index entries to code lines
%    that aren't main entries.
%    By default we do nothing special with them
%    the usage of a macro.
%    \begin{macrocode}
\@ifundefined{code}{\def\code#1{#1}}{}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{imacro}{\PrintIndex}
% \changes{v1.5k}{1989/09/04}{\cs{printindex} changed to
%                             \cs{PrintIndex}}
% \changes{v1.7a}{1992/02/26}{Documentation moved to interface section.}
% \changes{v1.9h}{1994/02/10}{Use \cs{@input@} instead of \cs{@input}.}
% \changes{v1.9w}{1995/12/29}{Turn the cmd into a noop after use.}
%    This is the same as |\printindex| in the \pkg{makeidx} package.
%    \begin{macrocode}
\def\PrintIndex{\@input@{\jobname.ind}%
                \global\let\PrintIndex\@empty}
%    \end{macrocode}
% \end{imacro}
%
%
% We want headings in the index (and changes list) according to the
% initial character of the next block of entries and have to instruct
% \prg{makeindex} appropriately.  Unfortunately the specification
% for this changed sometime between versions 2.4 and 2.11 of
% \prg{makeindex}.  We provide both ways of doing it but
% unfortunately this will always produce a warning message from
% \prg{makeindex}.  This is for older versions:
% \changes{v1.7h}{1992/07/01}{Turn off headings in gls file}
%    \begin{macrocode}
%</package>
%<+gind,gglo>% The next lines will produce some warnings when
%<+gind,gglo>% running Makeindex as they try to cover two different
%<+gind,gglo>% versions of the program:
%<+gind,gglo>lethead_prefix   "{\\bfseries\\hfil "
%<+gind,gglo>lethead_suffix   "\\hfil}\\nopagebreak\n"
%<+gind>lethead_flag       1
%<+gglo>lethead_flag       0
%    \end{macrocode}
% This works for newer ones:
%    \begin{macrocode}
%<+gind,gglo>heading_prefix   "{\\bfseries\\hfil "
%<+gind,gglo>heading_suffix   "\\hfil}\\nopagebreak\n"
%<+gind>headings_flag       1
%<+gglo>headings_flag       0
%<*package>
%    \end{macrocode}
%
%
%
% \subsection[Dealing with the change history]
%            {Dealing with the change history\footnotemark}
% \footnotetext{The whole section was proposed by Brian \textsc{Hamilton
%               Kelly}. He also documented and debugged the macros as
%               well as many other parts of this package.}
%
% To provide a change history log, the |\changes| command has
% been introduced.  This takes three arguments, respectively, the
% version number of the file, the date of the change, and some detail
% regarding what change has been made.  The second of these arguments
% is otherwise ignored, but the others are written out and may be used
% to generate a history of changes, to be printed at the end of the
% document.  However, note that older versions of Chen's standard
% \prg{makeindex}
% program limit any textual field to just 64 characters; therefore,
% is important that the number of characters in the second and third
% parameters should not exceed 61 altogether (to allow for the
% parentheses placed around the date).
%
% \begin{imacro}{\changes}
% \changes{BHK}{1989/04/26}{Documented \texttt{\protect\bslash changes}
%                         command.}
% \changes{BHK}{1989/04/26}{Changed definition of
%    \texttt{\protect\bslash protect}.} The output of the |\changes|
%    command goes into the \meta{Glossary\_File} and therefore uses
%    the normal |\glossaryentry| commands.\footnote{Note that a recent
%    change in \LaTeX{} 2.09 changed the command name in the
%    \texttt{.glo} file from \texttt{\bslash indexentry} to
%    \texttt{\bslash glossaryentry}.  It is therefore necessary to
%    have a special \prg{makeindex} style file called
%    \texttt{gglo.ist} to process this file correctly.} Thus
%    \prg{makeindex} or a similar program can be used to process
%    the output into a sorted ``glossary''.  The |\changes| command
%    commences by taking the usual measures to hide its spacing, and
%    then redefines |\protect| for use within the argument of the
%    generated |\indexentry| command.
%
%    We re-code nearly all chars found in |\sanitize| to letter
%    since the use of special package which make some characters
%    active might upset the |\changes| command when writing its
%    entries to the file. However we have to leave |%| as comment
%    and \verb*+ + as \meta{space} otherwise chaos will happen.
%    And, of course the |\| should be available as escape
%    character.
% \changes{v1.5v}{1990/01/28}{`Re-code a lot of chars.}
% \changes{v1.5m}{1989/09/20}{\cs{actualchar} in second level removed.}
% \changes{v1.5o}{1989/09/24}{New sorting.}
% \changes{v1.6c}{1990/06/29}{Again new sorting.}
% \changes{v1.9u}{1995/08/06}{Use \cs{protected@edef}}
%    \begin{macrocode}
\def\changes{\@bsphack\begingroup\@sanitize
   \catcode`\\\z@ \catcode`\ 10 \MakePercentIgnore
   \changes@}
\def\changes@#1#2#3{%
  \protected@edef\@tempa{\noexpand\glossary{#1%
%    \end{macrocode}
%    If asked for we also show the date of in the change log (after
%    the version).
% \changes{v3.0g}{2022/06/01}{Show change dates if asked for (gh/531)}
%    \begin{macrocode}
                   \ifdoc@reportchangedates
                     \space -- #2\fi
                   \levelchar
%    \end{macrocode}
% \changes{v1.9u}{1995/08/06}{Use value of \cs{saved@macroname} to
%          find out about change entries at outer level}
%    If the macro |\saved@macroname| doesn't contain any macro name
%    (ie is empty) the current changes entry was done at top-level.
%    In this case we precede it by |\generalname|.
%    \begin{macrocode}
                   \ifx\saved@macroname\@empty
%    \end{macrocode}
%    Putting a |!| at the beginning of the entry hopefully moves this
%    entry to the very beginning during sorting.
%    \begin{macrocode}
                      \quotechar!%
                      \actualchar
                      \generalname
                   \else
%    \end{macrocode}
% \changes{v2.1g}{2016/02/15}{Use \cs{saved@indexname}}
%    \begin{macrocode}
                      \saved@indexname
                      \actualchar
                      \string\verb% % to fool emacs highlighting
                      \quotechar*%
                      \verbatimchar\saved@macroname
                      \verbatimchar
                   \fi
                   :\levelchar #3}}%
  \@tempa\endgroup\@esphack}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{macro}{\saved@macroname}
% \changes{BHK}{1989/04/26}{Provided for sorting outside \env{macro}
%    environment} The entries are sorted for convenience by the name
%    of the most recently introduced macroname (i.e., that in the most
%    recent |\begin{macro}| command).  We therefore provide
%    |\saved@macroname| to record that argument, and provide a default
%    definition in case |\changes| is used outside a \env{macro}
%    environment.  (This is a {\em wicked\/} hack to get such entries
%    at the beginning of the sorted list!  It works providing no macro
%    names start with |!| or |"|.)  \changes{v1.7a}{1992/03/02}{Changed
%    string used for better sorting.}
% \changes{v1.9u}{1995/08/06}{Now empty by default}
%    \begin{macrocode}
\def\saved@macroname{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\saved@indexname}
% \changes{v2.1g}{2016/02/15}{Use \cs{saved@indexname}}
%    The macroname being document without a backslash for the index
%    (or the environment name which doesn't have one in the first place).
%    \begin{macrocode}
\def\saved@indexname{}
%    \end{macrocode}
% \end{macro}
%
% \begin{imacro}{\generalname}
% \changes{v1.9u}{1995/08/06}{Macro added}
%    This macro holds the string placed before changes entries on
%    top-level.
%    \begin{macrocode}
\def\generalname{General}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{imacro}{\RecordChanges}
% \changes{BHK}{1989/04/26}{Renames former \texttt{\protect\bslash
%                         PrintChanges} command.}
%    To cause the changes to be written (to a \texttt{.glo}) file, we
%    define |\RecordChanges| to invoke \LaTeX's usual
%    |\makeglossary| command.
%    \begin{macrocode}
\let\RecordChanges\makeglossary
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{ldimen}{\GlossaryMin}
%    \changes{BHK}{1989/04/26}{Added to support
%                            \texttt{\protect\bslash changes}.}
% \begin{lcounter}{GlossaryColumns}
%    \changes{BHK}{1989/04/26}{Added to support \texttt{\protect\bslash
%    changes}.} The remaining macros are all analogues of those used
%    for the \env{theindex} environment.  When the glossary is
%    started we compute the space which remains at the bottom of the
%    current page; if this is greater than |\GlossaryMin| then the
%    first part of the glossary will be placed in the available space.
%    The number of columns set are controlled by the counter
%    |\c@GlossaryColumns| which can be changed with a |\setcounter|
%    declaration.
%    \begin{macrocode}
\newdimen\GlossaryMin         \GlossaryMin       = 80pt
\newcount\c@GlossaryColumns   \c@GlossaryColumns = 2
%    \end{macrocode}
% \end{lcounter}
% \end{ldimen}
%
%
% \begin{environment}{theglossary}
%  \changes{BHK}{1989/04/26}{Added to support
%                            \texttt{\protect\bslash changes}.}
% \changes{v1.5p}{1989/09/28}{Now call \cs{multicols} first.}
%    \changes{v1.6e}{1991/04/03}{Turned into env definition.}
%    \changes{v1.7a}{1992/03/10}{Changed to work without multicols if
%                              necessary.}
%    \changes{BHK}{1989/04/26}{Added to support
%                            \texttt{\protect\bslash changes}.}
%    The environment \env{theglossary} is defined in the same manner
%    as the \env{theindex} environment.
%    \begin{macrocode}
\ifdoc@multicol
  \newenvironment{theglossary}{%
    \begin{multicols}\c@GlossaryColumns
                     [\glossary@prologue][\GlossaryMin]%
    \GlossaryParms \let\item\@idxitem \ignorespaces}%
   {\end{multicols}}
\else
  \newenvironment{theglossary}{%
      \@restonecoltrue\if@twocolumn\@restonecolfalse\fi
      \columnseprule \z@  \columnsep 35\p@
      \twocolumn[\glossary@prologue]%
      \GlossaryParms \let\item\@idxitem \ignorespaces}
    {\if@restonecol\onecolumn\else\clearpage\fi}
\fi
%    \end{macrocode}
% \end{environment}
%
% Here are the necessary \prg{makeindex} declarations with scanning
% disabled as for the index.
%    \begin{macrocode}
%</package>
%<+gglo>preamble
%<+gglo>"\n \\begin{theglossary} \n
%<+gglo>    \\makeatletter\\scan@allowedfalse\n"
%<+gglo>postamble
%<+gglo>"\n\n \\end{theglossary}\n"
%    \end{macrocode}
% This difference from \texttt{gind.ist} is necessary if you have an
% up-to-date \LaTeX.
%    \begin{macrocode}
%<+gglo>keyword "\\glossaryentry"
%<*package>
%    \end{macrocode}
%
%
% \begin{imacro}{\GlossaryPrologue}
%    \changes{BHK}{1989/04/26}{Added to support
%                            \texttt{\protect\bslash changes}.}
% \begin{macro}{\glossary@prologue}
%    \changes{BHK}{1989/04/26}{Added to support
%                            \texttt{\protect\bslash changes}.}
%    The |\GlossaryPrologue| macro is used to place a short
%    message above the glossary into the document.  It is implemented
%    by redefining |\glossary@prologue|, a macro which holds the
%    default text.  We better make it a long macro to allow
%    |\par| commands in its argument.
%    \begin{macrocode}
\long\def\GlossaryPrologue#1{\@bsphack
                             \def\glossary@prologue{#1}%
                             \@esphack}
%    \end{macrocode}
%    Now we test whether the default is already defined by another
%    package file. If not we define it.
%    \begin{macrocode}
\@ifundefined{glossary@prologue}
     {\def\glossary@prologue{\section*{{Change History}}%
                 \markboth{{Change History}}{{Change History}}%
                 }}{}
%    \end{macrocode}
% \end{macro}
% \end{imacro}
%
% \begin{imacro}{\GlossaryParms}
%    \changes{BHK}{1989/04/26}{Added to support
%                            \texttt{\protect\bslash changes}.}
% Unless the user specifies otherwise, we set the change history
% using the same parameters as for the index except that we make it sort
% of ragged right as it contains text that often doesn't break nicely in
% small columns.
% \changes{v2.1g}{2016/02/15}{Use ragged setting by default}
%    \begin{macrocode}
\@ifundefined{GlossaryParms}{\let\GlossaryParms\IndexParms
  \expandafter\def\expandafter\GlossaryParms\expandafter{\GlossaryParms
     \rightskip 15pt plus 1fil
     \parfillskip -15pt plus -1fil\relax}
}{}
%    \end{macrocode}
% \end{imacro}
%
% \begin{imacro}{\PrintChanges}
%    \changes{BHK}{1989/04/26}{Added to support
%                            \texttt{\protect\bslash changes}.}
%    To read in and print the sorted change history, just put the
%    |\PrintChanges| command as the last (commented-out, and thus
%    executed during the documentation pass through the file) command
%    in your package file.  Alternatively, this command may form one of
%    the arguments of the |\MaybeStop| command, although a
%    change history is probably {\em not\/} required if only the
%    description is being printed.
%
%    The command assumes that \prg{makeindex} or some other program
%    has processed the \texttt{.glo} file to generate a sorted
%    \texttt{.gls} file.
% \changes{v1.9h}{1994/02/10}{Use \cs{@input@} instead of \cs{@input}.}
% \changes{v1.9w}{1995/12/29}{Turn the cmd into a noop after use.}
%    \begin{macrocode}
\def\PrintChanges{\@input@{\jobname.gls}%
                  \global\let\PrintChanges\@empty}
%    \end{macrocode}
% \end{imacro}
%
%
%
%
%
% \subsection{Bells and whistles}
%
% \begin{imacro}{\MaybeStop}
% \changes{v1.5k}{1989/09/04}{Support for checksum.}
% \begin{imacro}{\Finale}
% \changes{v1.5k}{1989/09/04}{Support for checksum.}
% \changes{v1.5z}{1990/04/22}{Define \cs{Finale} globally.}
% \begin{imacro}{\AlsoImplementation}
% \changes{v1.9w}{1995/12/27}{Macro added}
% \begin{imacro}{\OnlyDescription}
%    If |\AlsoImplementation| is in force the whole documentation
%    including the code part will be typeset. This is the default.
%    \begin{macrocode}
\newcommand\AlsoImplementation{%
%    \end{macrocode}
%    To make this happen we have to define
%    |\MaybeStop| in a way that its argument is typeset at the
%    very end or more exactly at |\Finale|. For this we
%    save its argument in the macro |\Finale|.
%    \begin{macrocode}
   \long\def\MaybeStop##1{\@bsphack\gdef\Finale{##1%
%    \end{macrocode}
%    But |\Finale| will be called at the very end of a file. This
%    is exactly the point were we want to know if the file is
%    uncorrupted. Therefore we also call |\check@checksum| at this
%    point.
%    \begin{macrocode}
                  \check@checksum}%
%    \end{macrocode}
%    On the other hand: |\MaybeStop| is more or less a
%    dividing point between description and code. So we start to look
%    for the check-sum of the documented file by calling
%    |\init@checksum|.
%    \begin{macrocode}
              \init@checksum
              \@esphack}%
         }
%    \end{macrocode}
%
%    Since |\AlsoImplementation| should be the default we execute it
%    and thus |\MaybeStop| gets the desired meaning.
%    \begin{macrocode}
\AlsoImplementation
%    \end{macrocode}
%    When the user places an |\OnlyDescription| declaration in
%    the driver file the document should only be typeset up to
%    |\MaybeStop|. We therefore have to redefine this macro.
%    \begin{macrocode}
\def\OnlyDescription{\@bsphack\long\def\MaybeStop##1{%
%    \end{macrocode}
%    In this case the argument of |\MaybeStop| should be set
%    and afterwards \TeX{} should stop reading from this file.
%    Therefore we finish this macro with
%    \begin{macrocode}
           ##1\endinput}\@esphack}
%    \end{macrocode}
%    If no |\MaybeStop| command is given we silently ignore a
%    |\Finale| issued.
% \changes{v1.9n}{1994/04/28}{Ignore \cs{Finale} if no
%                  \cs{MaybeStop} is given}
%    \begin{macrocode}
\let\Finale\relax
%    \end{macrocode}
% \end{imacro}
% \end{imacro}
% \end{imacro}
% \end{imacro}
%
%
%  \begin{omacro}{\StopEventually}
%    The old wrong name for |\MaybeStop|. We need to use |\def|
%    (i.e., expansion) as |\MaybeStop| gets redefined once in a while.
%    \begin{macrocode}
\def\StopEventually{\MaybeStop}
%    \end{macrocode}
%  \end{omacro}
%
% \begin{imacro}{\meta}
% \changes{v1.4t}{1989/04/24}{Macro added.}
% \changes{v1.5w}{1990/02/03}{Breaks at space allowed.}
% \changes{v1.6a}{1990/05/24}{Extra space bug corrected.}
%    The |\meta| macro is a bit tricky. We want to allow line
%    breaks at blanks in the argument but we don't want a break
%    in between. In the past this was done by defining |\meta| in a way that a
%    \verb*+ + is active when the argument is scanned. Words are then
%    scanned into |\hbox|es. The active \verb*+ + will end the
%    preceding |\hbox| add an ordinary space and open a new
%    |\hbox|. In this way breaks are only possible at spaces.  The
%    disadvantage of this method was that |\meta| was neither robust
%    nor could it be |\protect|ed. The new implementation  fixes this
%    problem by defining |\meta| in a radically different way: we
%    prevent hyphenation by defining a |\language| which has no
%    patterns associated with it and use this to typeset the words
%    within the angle brackets.
% \changes{v2.0i}{2000/05/21}{New implementation (pr/3170)}
%    \begin{macrocode}
\ifx\l@nohyphenation\undefined
  \newlanguage\l@nohyphenation
\fi
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand\meta[1]{%
%    \end{macrocode}
%    Since the old implementation of |\meta| could be used in math we
%    better ensure that this is possible with the new one as
%    well. So we use |\ensuremath| around |\langle| and
%    |\rangle|. However this is not enough: if |\meta@font@select|
%    below expands to |\itshape| it will fail if used in math
%    mode. For this reason we hide the whole thing inside an
%    |\nfss@text| box in that case.
% \changes{v2.0l}{2000/06/10}{Fixing changes for (pr/3170)}
%    \begin{macrocode}
     \ensuremath\langle
     \ifmmode \expandafter \nfss@text \fi
     {%
      \meta@font@select
%    \end{macrocode}
%    Need to keep track of what we changed just in case the user
%    changes font inside the argument so we store the font explicitly.
% \changes{v2.0m}{2000/07/04}{More fixing changes for (pr/3170)}
%    \begin{macrocode}
      \edef\meta@hyphen@restore
        {\hyphenchar\the\font\the\hyphenchar\font}%
      \hyphenchar\font\m@ne
      \language\l@nohyphenation
      #1\/%
      \meta@hyphen@restore
     }\ensuremath\rangle
}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{macro}{\meta@font@select}
% \changes{v2.0k}{2000/05/26}{Macro added (pr/3170)}
%    Make font used inside |\meta| customizable.
%    \begin{macrocode}
\def\meta@font@select{\itshape}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{imacro}{\IndexInput}
%    This next macro may be used to read in a separate file (possibly
%    a package file that is {\em not\/} documented by this means) and
%    set it verbatim, whilst scanning for macro names and indexing the
%    latter.  This could be a useful first pass in preparing to
%    generate documentation for the file read.
%    \begin{macrocode}
\def\IndexInput#1{%
%    \end{macrocode}
%     We commence by setting up a group, and initializing a
%    |\trivlist| as is normally done by a
%    |\begin{macrocode}| command.
%    \begin{macrocode}
     \begingroup \macro@code
%    \end{macrocode}
%    We also make spacing behave as in the \env{macrocode}
%    environment, because otherwise all the spaces will be shown
%    explicitly.
%    \begin{macrocode}
   \frenchspacing \@vobeyspaces
%    \end{macrocode}
%    Then it only remains to read in the specified file, and finish
%    off the |\trivlist|.
% \changes{v1.5t}{1989/11/07}{Call \cs{endmacrocode} instead
%                             of \cs{endtrivlist}.}
%    \begin{macrocode}
     \input{#1}\endmacrocode
%    \end{macrocode}
%    Of course, we need to finish off the group as well.
%    \begin{macrocode}
     \endgroup}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{imacro}{\maketitle}
%    The macro to generate titles is easily altered in order that it
%    can be used more than once (an article with many titles).  In the
%    original, diverse macros were concealed after use with
%    |\relax|. We must cancel anything that may have been put
%    into |\@thanks|, etc., otherwise {\em all\/} titles will
%    carry forward any earlier such setting!
%  \changes{v1.5j}{1989/06/09}{thispagestyle plain removed}
%  \changes{v1.9r}{1994/06/09}{Added new definitions of
%                 \cs{@makefnmark} and \cs{@makefntext}}
%    \begin{macrocode}
\def\maketitle{\par
      \begingroup \def \thefootnote {\fnsymbol {footnote}}%
      \setcounter {footnote}\z@
      \def\@makefnmark{\hbox to\z@{$\m@th^{\@thefnmark}$\hss}}%
      \long\def\@makefntext##1{\parindent 1em\noindent
            \hbox to1.8em{\hss$\m@th^{\@thefnmark}$}##1}%
      \if@twocolumn \twocolumn [\@maketitle ]%
      \else \newpage \global \@topnum \z@ \@maketitle \fi
%    \end{macrocode}
% \changes{v1.5k}{1989/09/04}{Added \cs{ps@titlepage}}
%    For special formatting requirements (such as in TUGboat), we use
%    pagestyle |titlepage| for this; this is later defined to be
%    |plain|, unless already defined, as, for example, by
%    |ltugboat.sty|.
%    \begin{macrocode}
       \thispagestyle{titlepage}\@thanks \endgroup
%    \end{macrocode}
%    If the driver file documents many files, we don't want parts of a
%    title of one to propagate to the next, so we have to cancel
%    these:
%    \begin{macrocode}
      \setcounter {footnote}\z@
      \gdef\@date{\today}\gdef\@thanks{}%
      \gdef\@author{}\gdef\@title{}}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{imacro}{\ps@titlepage}
% \changes{v1.5k}{1989/09/04}{Added \texttt{\protect\bslash
%    ps@titlepage}} When a number of articles are concatenated into a
%    journal, for example, it is not usual for the title pages of such
%    documents to be formatted differently.  Therefore, a class
%    such as \cls{ltugboat} can define this macro in advance.
%    However, if no such definition exists, we use pagestyle
%    \texttt{plain} for title pages.
%    \begin{macrocode}
\@ifundefined{ps@titlepage}
    {\let\ps@titlepage=\ps@plain}{}
%    \end{macrocode}
% \end{imacro}
%
% \begin{imacro}{\MakeShortVerb}
% \changes{v1.7a}{1992/02/27}{Added (from newdoc but now alters
%                           \cs{dospecials}, \cs{@sanitize}).}
% This arranges an abbreviation for |\verb| such that if you say
% |\MakeShortVerb{\|\meta{c}|}| subsequently using
% \meta{c}\meta{text}\meta{c} is equivalent to
% |\verb|\meta{c}\meta{text}\meta{c}.\footnote{Warning:
% the commentary in the rest of this section was written by Dave
% Love.}  In addition, the fact
% that \meta{c} is made active is recorded for the benefit of the
% \env{verbatim} and \env{macrocode} environments.
% Note particularly that the definitions below are global.
% The first thing we do (it needn't be first) is to record
% the---presumably new---special character in |\dospecials| and
% |\@sanitize| using |\add@special|.
%
% \changes{v1.9e.2}{1994/02/07}{-js: Check if \protect\meta{c} is
%                              already an
%                              abbreviation for \cs{verb}.}
% Some unwary user might issue |\MakeShortVerb| for a second time, we
% better protect against this. We assume that this happened if a
% control sequence |\cc\|\meta{c} is bound, the probability that this
% name is used by another module is low. We will output a warning
% below, so that a possible error might be noticed by the programmer
% if he reads the |LOG| file. (Should have used module internal names,
% 'though.)
%
% \begin{imacro}{\MakeShortVerb*}
% \changes{v2.1a}{2003/12/09}{(HjG) Added \texttt{*} form}
% This arranges an abbreviation for |\verb*| such that if you say
% |\MakeShortVerb*{\|\meta{c}|}| subsequently using
% \meta{c}\meta{text}\meta{c} is equivalent to
% |\verb*|\meta{c}\meta{text}\meta{c}.
%    \begin{macrocode}
%</package>
%<*package|shortvrb>
\def\MakeShortVerb{%
  \@ifstar
    {\def\@shortvrbdef{\verb*}\@MakeShortVerb}%
    {\def\@shortvrbdef{\verb}\@MakeShortVerb}}
%    \end{macrocode}
% \end{imacro}
% \end{imacro}
%
% \begin{macro}{\@MakeShortVerb}
%    \begin{macrocode}
\def\@MakeShortVerb#1{%
  \expandafter\ifx\csname cc\string#1\endcsname\relax
%    \end{macrocode}
% \changes{v1.9v}{1995/11/03}{(DPC) Use \cs{@shortvrbinfo}}
%    \begin{macrocode}
    \@shortvrbinfo{Made }{#1}\@shortvrbdef
    \add@special{#1}%
%    \end{macrocode}
% Then the character's current catcode is stored in |\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 |\verb| (for instance), having activated |~| in a group.
%    \begin{macrocode}
    \begingroup
      \catcode`\~\active  \lccode`\~`#1%
      \lowercase{%
%    \end{macrocode}
% The character's old meaning is recorded in |\ac\|\meta{c} prior to
% assigning it a new one.
%    \begin{macrocode}
      \global\expandafter\let
         \csname ac\string#1\endcsname~%
      \expandafter\gdef\expandafter~\expandafter{\@shortvrbdef~}}%
    \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}
% \changes{v1.9v}{1995/11/03}{(DPC) Use \cs{@shortvrbinfo}}
%    \begin{macrocode}
    \@shortvrbinfo\@empty{#1 already}%
                         {\@empty\verb% % to fool emacs highlighting
                          (*)}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{imacro}{\DeleteShortVerb}
% \changes{v1.7a}{1992/02/27}{Added (from newdoc but now alters
%                           \cs{dospecials}, \cs{@sanitize}).}
% Here's the means of undoing a |\MakeShortVerb|, for instance in a
% region where you need to use the character outside a verbatim
% environment.  It arranges for |\dospecials| and |\@sanitize| to be
% altered appropriately, restores the saved catcode and, if necessary,
% the character's meaning (as stored by
% |\MakeShortVerb|).  If the catcode wasn't stored in
% |\cc\|\meta{c} (by |\MakeShortVerb|) the command is silently
% ignored.
% \changes{v1.7a}{1992/02/28}{Check for previous matched
%                           \cs{MakeShortVerb}
%                           to avoid error.}
%    \begin{macrocode}
\def\DeleteShortVerb#1{%
  \expandafter\ifx\csname cc\string#1\endcsname\relax
%    \end{macrocode}
% \changes{v2.1a}{2003/12/10}{(HjG) Notify user
%             if it's not a short verb character}
%    \begin{macrocode}
    \@shortvrbinfo\@empty{#1 not}%
                         {\@empty\verb% % to fool emacs highlighting
                          (*)}%
  \else
%    \end{macrocode}
% \changes{v1.9v}{1995/11/03}{(DPC) Use \cs{@shortvrbinfo}}
%    \begin{macrocode}
    \@shortvrbinfo{Deleted }{#1 as}%
                            {\@empty\verb% % to fool emacs
                                           % highlighting
                            (*)}%
    \rem@special{#1}%
    \global\catcode`#1\csname cc\string#1\endcsname
%    \end{macrocode}
% \changes{v1.9e.2}{1994/02/07}{-js: Reset `cc`\protect\meta{c} in
%                       in \cs{DeleteShortVerb}}
% We must not forget to reset |\cc\|\meta{c}, otherwise the check in
% |\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{imacro}
%
%  \begin{macro}{\@shortvrbinfo}
% \changes{v1.9v}{1995/11/03}{(DPC) Macro added}
% \changes{v2.1a}{2003/12/10}{(HjG) Third argument added
%             on behalf of \cmd{\MakeShortVerb*}}
% Helper function for info messages.
%    \begin{macrocode}
\def\@shortvrbinfo#1#2#3{%
%<shortvrb>  \PackageInfo{shortvrb}{%
%<!shortvrb>  \PackageInfo{doc}{%
     #1\expandafter\@gobble\string#2 a short reference
                                          for \expandafter\string#3}}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\add@special}
% \changes{v1.7a}{1992/02/27}{Added for short verb facility.}
% This helper macro adds its argument to the
% |\dospecials| macro which is conventionally used by verbatim macros
% to alter the catcodes of the currently active characters.  We need
% to add |\do\|\meta{c} to the expansion of |\dospecials| after
% removing the character if it was already there to avoid multiple
% copies building up should |\MakeShortVerb| not be balanced by
% |\DeleteShortVerb| (in case anything that uses |\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 |\@makeother\|\meta{c} to |\@sanitize|
% (which is used in things like |\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}
% \changes{v1.7a}{1992/02/27}{Added for short verb facility.}
% The inverse of |\add@special| is slightly trickier.  |\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 |\dospecials| to be the expansion of itself.  The space
% after |=`##1| prevents an expansion to |\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 |\@sanitize| is the same except that we need to re-define
% |\@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}
%</package|shortvrb>
%<*package>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection[Providing a checksum and character table]
%        {Providing a checksum and character table\footnotemark}
%        \footnotetext{Warning: the commentary in this section was
%                      written by Dave Love. }
%
%
% \begin{macro}{\init@checksum}
% The checksum mechanism works by counting backslashes in the
% macrocode.  This initializes the count (when called from
% |\MaybeStop|).
% \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
%    \begin{macrocode}
\def\init@checksum{\relax
    \global\bslash@cnt\z@}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\check@checksum}
% \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
% This reports the sum compared with the value (|\bslash@cnt|) the
% file advertises.  It's called from |\Finale| (if that hasn't been
% re-defined).
% \changes{v2.1f}{2016/02/12}{Suppress \cs{CheckSum} check if no checksum
%    is specified in the file}
%    \begin{macrocode}
\def\check@checksum{\relax
  \ifnum\check@sum>\m@ne
%    \end{macrocode}
%    We do nothing if the checksum in the file is negative (or not given as
%    it is initialized with -1).
%    \begin{macrocode}
     \ifnum\check@sum=\z@
       \typeout{**********************************}%
       \typeout{* This macro file has no checksum!}%
       \typeout{* The checksum should be \the\bslash@cnt!}%
       \typeout{**********************************}%
     \else
       \ifnum\check@sum=\bslash@cnt
         \typeout{*******************}%
         \typeout{* Checksum passed *}%
         \typeout{*******************}%
       \else
         \PackageError{doc}{Checksum not passed
                    (\the\check@sum<>\the\bslash@cnt)}%
          {The file currently documented seems to be wrong.^^J%
           Try to get a correct version.}%
       \fi
     \fi
  \fi
  \global\check@sum\m@ne}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{tcounter}{\check@sum}
% \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
% \begin{tcounter}{\bslash@cnt}
% \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
% We need to define counters, |\bslash@cnt| for the number of
% backslashes counted and |\check@sum| for the value advertised by the
% file if any. A negative value means there is no checksum checking which is the default.
% \changes{v2.1f}{2016/02/12}{Suppress \cs{CheckSum} check if no checksum
%    is specified in the file}
%    \begin{macrocode}
\newcount\check@sum           \check@sum  = \m@ne
\newcount\bslash@cnt          \bslash@cnt = \z@
%    \end{macrocode}
% \end{tcounter}
% \end{tcounter}
%
%
% \begin{omacro}{\CheckSum}
% \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
% This is the interface to setting |\check@sum|.
%    \begin{macrocode}
\def\CheckSum#1{\@bsphack\global\check@sum#1\relax\@esphack}
%    \end{macrocode}
% \end{omacro}
%
%
%
% \begin{macro}{\step@checksum}
% \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
% This advances the count when a backslash is encountered in the
% macrocode.
%    \begin{macrocode}
\def\step@checksum{\global\advance\bslash@cnt\@ne}
%    \end{macrocode}
% \end{macro}
%
% \begin{omacro}{\CharacterTable}
%    The user interface to the character table-checking does some
%    |\catcode|ing and then compares the following table with the
%    stored version. We need to have |@| of type ``other'' within the
%    table since this is the way it is usually returned when reading
%    in a normal document. To nevertheless have a private letter we
%    use |~| for this purpose. |~| does no harm as a ``letter'' as it
%    comes last in the table and therefore will not gobble following
%    space.
% \changes{v1.5m}{1989/09/20}{Macro added to check character translation
%                           problems.}
% \changes{v1.5q}{1989/11/01}{Made character table more readable.}
% \changes{v1.5t}{1989/11/07}{Make \string\~{} letter in chartable
%                           macros.}
% \changes{v1.5u}{1989/11/14}{Made @ other in default table.}
%    \begin{macrocode}
\def\CharacterTable{\begingroup \CharTableChanges \character@table}
%    \end{macrocode}
% \end{omacro}
%
% \def\MakePrivateLetters{\catcode`\~=11\makeatletter}
%
% \begin{macro}{\character@table}
% This does the work of comparing the tables and reporting the result.
% Note that the following code is enclosed in a group
% with |~| catcoded to letter.
%    \begin{macrocode}
\begingroup
  \catcode`\~=11
  \gdef\character@table#1{\def\used~table{#1}%
      \ifx\used~table\default~table
           \typeout{***************************}%
           \typeout{* Character table correct *}%
           \typeout{***************************}%
      \else
         \PackageError{doc}{Character table corrupted}
                           {\the\wrong@table}
         \show\default~table
         \show\used~table
      \fi
      \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{omacro}{\CharTableChanges}
%    When the character table is read in we need to scan it with a
%    fixed set of |\catcode|s. The reference table below  was defined by
%    assuming the normal |\catcode|s of \TeX{}, i.e.\ |@| is of type
%    other and the only token of type ``letter'' are the usual letters
%    of the alphabet. If, for some reason, other characters are made
%    ``letters'' then their |\catcode|s need to be restored before
%    checking the table. Otherwise spaces in the table are gobbled and
%    we get the information that the tables are different, even if
%    they are actually equal. For this reason |\CharTableChanges| can
%    be set up to locally restore the |\catcode|s of such ``letters''
%    to ``other''.
%    \begin{macrocode}
  \global\let\CharTableChanges\@empty
%    \end{macrocode}
% \end{omacro}
%
% \begin{macro}{\default~table}
% Here's what the table {\em should\/} look like (modulo spaces).
%    \begin{macrocode}
  \makeatother
  \gdef\default~table
     {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         \~}
\endgroup
%    \end{macrocode}
% \end{macro}
% \let\MakePrivateLetters=\makeatletter
%
% \begin{macro}{\wrong@table}
% \changes{v1.7a}{1992/02/28}{Moved to where the catcodes are right
%                           so it works.}
% We need a help message in case of problems.
%    \begin{macrocode}
  \newhelp\wrong@table{Some of the ASCII characters are corrupted.^^J
            I now \string\show\space you both tables for comparison.}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection[Attaching line numbers to code lines]
%            {Attaching line numbers to code lines\footnotemark}
%            \footnotetext{Warning: the commentary was written by Dave
%            Love.}
%
%
% The code in this section allows index entries to refer to code line
% numbers---the number of the first line of macrocode in the
% \env{macro} environment.
%
%
% \begin{macro}{\codeline@index}
% Indexing by code line is controlled by the |codeline@index| switch.
% \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
% \changes{v1.7a}{1992/02/24}{Documented code line no. support.}
% \begin{imacro}{\CodelineNumbered}
% \changes{v1.8a}{1993/05/19}{Macro added}
%    \begin{macrocode}
\newif\ifcodeline@index \codeline@indexfalse
\let\CodelineNumbered\codeline@indextrue
%    \end{macrocode}
% \end{imacro}
% \end{macro}
%
% \begin{macro}{\codeline@wrindex}
%    The code index entries are written out by |\special@index|.  If
%    indexing is by code line this is |\let| to |\codeline@wrindex|;
%    if indexing is by page it is just |\index|.  However, if
%    |\nofiles| is given, we omit writing such an index entry at all.
% \changes{v1.7j}{1992/08/14}{Added \cs{if@filesw}.}
%    \begin{macrocode}
\def\codeline@wrindex#1{\if@filesw
     \begingroup
        \set@display@protect
        \immediate\write\@indexfile
            {\string\indexentry{#1}%
             {\number\c@CodelineNo}}%
      \endgroup
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\special@index}
% By default no index entries are written out.
%    \begin{macrocode}
\let\special@index = \@gobble
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\CodelineIndex}
% \changes{v1.5u}{1989/11/14}{Added \cs{PageIndex} and
%                  \cs{CodelineIndex} (Undoc)}
% This switches on use of the index file with |\makeindex|, sets the
% switch to indicate code line numbering and defines |\special@index|
% appropriately.
%    \begin{macrocode}
\def\CodelineIndex{\makeindex
                   \codeline@indextrue
                   \let\special@index\codeline@wrindex}
%    \end{macrocode}
% \end{macro}
% \begin{imacro}{\PageIndex}
% |\PageIndex| is similar.
%    \begin{macrocode}
\def\PageIndex{\makeindex
               \codeline@indexfalse
               \let\special@index\index}
%    \end{macrocode}
% \end{imacro}
%
%
% \begin{lcounter}{CodelineNo}
% \changes{v1.5l}{1989/09/10}{Counter added to support code line
%                             numbers}
% \changes{v1.5y}{1990/02/24}{Default changed.}
% \changes{v1.6b}{1990/06/15}{\cs{rm} moved before \cs{scriptsize} to
%                           avoid unnecessary fontwarning.}
% We need a counter to keep track of the line number.
%    \begin{macrocode}
\newcount\c@CodelineNo  \c@CodelineNo\z@
%    \end{macrocode}
% \end{lcounter}
%
% \begin{macro}{\theCodelineNo}
% \changes{v1.7a}{1992/02/25}{Existing definition not overwritten.}
% \changes{v1.7a}{1992/03/12}{Use \cs{reset@font} for NFSS.}
% This provides a hook to control the format of line numbers which may
% be defined in a class file.
%    \begin{macrocode}
\@ifundefined{theCodelineNo}
  {\ifx\selectfont\undefined
     \def\theCodelineNo{\rmfamily\scriptsize\arabic{CodelineNo}}%
   \else
     \def\theCodelineNo{\reset@font\scriptsize\arabic{CodelineNo}}%
   \fi}
  {}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \subsection{Layout Parameters for documenting package files}
%
% \begin{macro}{\tolerance}
%    People documenting package files would probably rather have things
%    ``sticking out'' in overfull |\hbox|es and poorish spacing,
%    because they probably don't want to spend a lot of time on making
%    all the line breaks perfect!
%    \begin{macrocode}
       \tolerance=1000\relax
%    \end{macrocode}
% \end{macro}
%
%
% The following |\mathcode| definitions allow the characters
% `|\|'
% and `\texttt{@}' to appear in |\ttfamily| font when invoked in math
% mode;\footnote{You may wonder why the definitions state that both
%                characters belong to the {\em variable family\/}
%                (i.e.\ the number 7 in front). The reason is this:
%                Originally the \texttt{\bslash mathcode} of
%                \texttt{\bslash} was defined to be \texttt{"075C},
%                i.e.\ ordinary character number 92 (hex 5C) in
%                math family number 7 which is the typewriter family in
%                standard \LaTeX.
%                But this file should not depend on this specific
%                setting, so I changed these
%                \texttt{\bslash mathcode}$\,$s
%                to work with any family assignments. For an example
%                see the article about the new font selection scheme.}
% particularly for something like |\@abc=1|.
%
% If an {\em old\/} version of the \pkg{german} package is in
% force, then the `|"|' character is active and would upset the
% definition of the \meta{16-bit number} quantities below, therefore
% we change the |\catcode| of |"| inside a group, and use
% |\global|.
%    \begin{macrocode}
{ \catcode`\"=12
  \global\mathcode`\\="705C \global\mathcode`\@="7040 }
%    \end{macrocode}
% \MakeShortVerb{\"}
%
% \begin{macro}{\DocstyleParms}
%    This macro can be used, for example, to assign new values to
%    |\MacrocodeTopsep| and |\MacroIndent| and some other internal
%    registers.  If it is already defined, the default definition
%    won't be carried out. Note that it is necessary to assign new
%    values via this macro if it should be done in a class file (like
%    \texttt{ltugboat.cls} for example) since the registers are
%    undefined before \texttt{doc.sty} is read in.  The default values
%    for the internal registers are scattered over this file.
% \changes{v1.5u}{1989/11/14}{\cs{DocStyleParms} now empty}
% \changes{v2.1h}{2018/02/01}{Only use\cs{DocStyleParms} if defined
%                             (previously the test defined it)}
%    \begin{macrocode}
\@ifundefined{DocstyleParms}{}{\DocstyleParms}
%    \end{macrocode}
%    Clear out |\DocstyleParms| after use (or non-use).
%    \begin{macrocode}
 \let\DocstyleParms\relax
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\AmSTeX}
%   \changes{v1.5j}{1989/06/09}{Macro AmsTeX renamed to AmSTeX}
% \begin{macro}{\BibTeX}
% \begin{macro}{\SliTeX}
%    Here are a few definitions which can usefully be employed when
%    documenting package files: now we can readily refer to \AmSTeX,
%    \BibTeX\ and \SliTeX, as well as the usual \TeX\ and \LaTeX.
%    \begin{macrocode}
\@ifundefined{AmSTeX}
   {\def\AmSTeX{\leavevmode\hbox{$\mathcal A\kern-.2em\lower.376ex%
        \hbox{$\mathcal M$}\kern-.2em\mathcal S$-\TeX}}}{}
\@ifundefined{BibTeX}
   {\def\BibTeX{{\rmfamily B\kern-.05em%
    \textsc{i\kern-.025em b}\kern-.08em%
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}}{}
\@ifundefined{SliTeX}
   {\def\SliTeX{{\rmfamily S\kern-.06emL\kern-.18em\raise.32ex\hbox
                {\scshape i}\kern -.03em\TeX}}}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\PlainTeX}
% \changes{v1.5g}{1989/05/07}{space between plain and TeX changed.}
% \begin{macro}{\Web}
%     There's even a \PlainTeX{} and a \Web.
%    \begin{macrocode}
\@ifundefined{PlainTeX}{\def\PlainTeX{\textsc{Plain}\kern2pt\TeX}}{}
\@ifundefined{Web}{\def\Web{\textsc{Web}}}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Changing the \texttt{\protect\bslash catcode} of \%}
%
% \begin{imacro}{\MakePercentIgnore}
% \begin{imacro}{\MakePercentComment}
%    And finally the most important bit: we change the |\catcode|
%    of `|%|' so that it is ignored (which is how we are able to
%    produce this document!). We provide two commands to do the actual
%    switching.
%^^A The |\MakePercentIgnore| is then called as the
%^^A last command in this file.
%    \begin{macrocode}
\def\MakePercentIgnore{\catcode`\%9\relax}
\def\MakePercentComment{\catcode`\%14\relax}
%    \end{macrocode}
% \end{imacro}
% \end{imacro}
%
% \begin{imacro}{\DocInput}
%    The two macros above are now used to define the |\DocInput| macro
%    which was introduced in version v1.5l (or so) of the \DOC{}
%    package. In older versions |\MakePercentIgnore| was placed
%    at the very end of \texttt{doc.sty}.
%    \begin{macrocode}
\def\DocInput#1{\MakePercentIgnore\input{#1}\MakePercentComment}
%    \end{macrocode}
% \end{imacro}
%
% \subsection{GetFileInfo}
%
% \begin{macro}{\GetFileInfo}
% \changes{v1.9o}{1994/05/08}{Macro added}
% \changes{v1.9z}{1997/02/05}{Missing percent latex/2404}
%    Define |\filedate| and friends from info in the
%    |\ProvidesPackage| etc.\ commands.
%    \begin{macrocode}
\def\GetFileInfo#1{%
  \def\filename{#1}%
  \def\@tempb##1 ##2 ##3\relax##4\relax{%
    \def\filedate{##1}%
    \def\fileversion{##2}%
    \def\fileinfo{##3}}%
  \edef\@tempa{\csname ver@#1\endcsname}%
  \expandafter\@tempb\@tempa\relax? ? \relax\relax}
%    \end{macrocode}
% \end{macro}
%




% \section{Integrating hypdoc}
%
%    If the option \texttt{hyperref} is selected (which is the
%    default), then we load the \pkg{hypdoc} package. We do that as
%    late as possible so that we don't generate option clashes if it
%    is also loaded in the preamble. That package currently changes
%    more commands than it should (not knowing about their new
%    definitions defined below) so we have to save and restore a few.
%
%    Midterm all this code in \pkg{hypdoc} should be directly included
%    in \DOC. For now, while they are separate we have to do this
%    juggling.
%    \begin{macrocode}
\AddToHook{begindocument/before}[doc/hyperref]{%
 \ifdoc@hyperref
%    \end{macrocode}
%    Annoying to code around issue \#22
%    \begin{macrocode}
  \expandafter\let\expandafter\doc@eoph@@k\csname doc.sty-h@@k\endcsname
%    \end{macrocode}
%    We require the package without any option so if it was already
%    loaded there is no option clash.
%    \begin{macrocode}
  \RequirePackage{hypdoc}
  \expandafter\let\csname doc.sty-h@@k\endcsname\doc@eoph@@k
%    \end{macrocode}
%    After \pkg{hypdoc} got loaded we need to undefine those macros
%    again so that later on \texttt{Macro} and \texttt{Env} \DOC items
%    appear to be undefined.
%    \begin{macrocode}
  \let\PrintDescribeMacro \@@PrintDescribeMacro
  \let\PrintDescribeEnv \@@PrintDescribeEnv
  \let\PrintMacroName \@@PrintMacroName
  \let\PrintEnvName \@@PrintEnvName
  \let\SpecialUsageIndex \@@SpecialUsageIndex
  \let\SpecialEnvIndex \@@SpecialEnvIndex
  \let\SortIndex \@@SortIndex
  \let\DescribeMacro \@@DescribeMacro
  \let\DescribeEnv \@@DescribeEnv
%    \end{macrocode}
%    The package adds new definitions for \cs{special@index} into
%    \cs{CodelineIndex} and \cs{PageIndex} but since we are loading it
%    very late we are already past them (in the preamble). So we test
%    the final state and do it here, if necessary.
%    \begin{macrocode}
  \ifx\special@index\@gobble  % do we write index entries at all?
  \else
    \ifcodeline@index
      \let\special@index\HD@codeline@wrindex
    \else
      \let\special@index\HD@page@wrindex
    \fi
  \fi
%    \end{macrocode}
%    The \pkg{amsmath} documentation uses \cs{env} in headings and
%    with \pkg{hyperref} enabled this causes trouble in bookmarks.
% \fmi{fix elsewhere eventually}
%    \begin{macrocode}
  \AddToHook{class/amsdtx/after}{%
     \pdfstringdefDisableCommands{\let\env\@empty }}%
%    \end{macrocode}
%    That package also adds extra code into |\index| entries but it doesn't
%    know about all the stuff that \DOC does (now). So we need to provide
%    us with two helpers that handle the |\encapchar| case in some entries.
%    \begin{macrocode}
  \def\doc@providetarget{\HD@target}%
  \def\doc@handleencap#1{\encapchar hdclindex{\the\c@HD@hypercount}{#1}}%
%    \end{macrocode}
%    If that package is not loaded these helpers do little to nothing.
%    \begin{macrocode}
 \else
  \let\doc@providetarget\@empty
  \def\doc@handleencap#1{\encapchar #1}%
%    \end{macrocode}
%    We define the next commands just in case the user changed the option
%    \texttt{hyperref} from \texttt{true} to \texttt{false} without
%    removing the auxiliary files.
%    \begin{macrocode}
  \def\hdclindex#1#2{\ifx\@nil#2\@nil\else\csname #2\expandafter\endcsname\fi}%
  \def\hdpindex   #1{\ifx\@nil#1\@nil\else\csname #1\expandafter\endcsname\fi}%
\fi
}  
%    \end{macrocode}
%
%
%
%
%
% \section{Integrating the \DOX package code}
%
% The code in this section is largely taken over from the \DOX package
% by Didier with only minor modifications (so far). This means it is a
% bit back and forth and both the code and the documentation need
% further updates.
%
% \subsection{\DOX environments}

% \begin{macro}{\@doc@env,\@doc@env@}
% \fmi{original doc -- fix}
%   \marg{are-we-macrolike}\marg{item}\marg{indextype}\marg{name}\\
%   In \texttt{doc.sty}, the \texttt{macro} and \texttt{environment}
%   environments go through the \cs{m@cro@} macro which implements specific
%   parts by testing a boolean condition as its first argument. This mechanism
%   is not extensible, so I have to hack away a more generic version that
%   would work for any new \texttt{dox} item, only which looks pretty much
%   like the original one (with the addition of options management).
%
%    First step is to see if we have a comma-separated list of names
%    in |#3| and if so we call the macro doing the work individually
%    for each
%    \begin{macrocode}
\ExplSyntaxOn
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\@doc@env#1#2#3{
%    \end{macrocode}
%    The |\endgroup| here closes the scanning of names (using special catcodes.
%    \begin{macrocode}
  \endgroup
  \clist_map_inline:nn {#3} { \@doc@env@{#1}{#2}{##1} }
}

\ExplSyntaxOff
%    \end{macrocode}
%
%    And here is the payload for each name from the given list:
%    \begin{macrocode}
\long\def\@doc@env@#1#2#3{%
  \topsep\MacroTopsep
  \trivlist
    \edef\saved@macroname{\string#3}%
%    \end{macrocode}
% Since version 2.1g, \texttt{doc} creates a \cs{saved@indexname} command
% which in used by \cs{changes}. We now support that as well. The expansion of
% this command depends on whether the documented item is macrolike or not,
% which we don't know here (it's only know by \cs{NewDocElement}). That's why we
% need one specific command generating \cs{saved@indexname} the right way for
% every single item. These commands are
%    named\cs{@Save\meta{item}IndexName};
% they are technically part of the generated API, only not meant for public
% use.
%
% \fmi{above docu is no longer right (but code needs further changes
% anyway}
%
%    |#1| is either \texttt{TT} (for true = macrolike) or \texttt{TF}.
%    If true then we drop the first char from |\saved@macroname| and
%    store the result in |\saved@indexname| and use the latter for
%    sorting in the index.
%    \begin{macrocode}
    \if #1%
      \edef\saved@indexname{\expandafter\@gobble\saved@macroname}%
%
%    \end{macrocode}
%    If the \DOC element described is macrolike but not a normal
%    ``macro'' then its type should be recorded and this is the places
%    where this happens. For macros (which should make up the bulk of
%    these items we don't do this and for anything else that looks
%    from an indexing perspective like a macro we don't do that either
%    to keep the list of exceptions small. That would be the case if
%    the indexing command |\Code|\meta{doc-element}|Index| is
%    equivalent to \cs{CodeMacroIndex}.
%    \begin{macrocode}
      \expandafter\ifx
                  \csname Code#2Index\endcsname
                  \CodeMacroIndex
      \else
        \record@index@type@save
          {\saved@indexname}{#2}%
      \fi
    \else
      \let\saved@indexname\saved@macroname
    \fi
%
    \def\makelabel##1{\llap{##1}}%
    \if@inlabel
      \let\@tempa\@empty
      \count@\macro@cnt
      \loop\ifnum\count@>\z@
        \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne
      \repeat
      \edef\makelabel##1{\llap{\vtop to\baselineskip{\@tempa\hbox{##1}\vss}}}%
      \advance\macro@cnt\@ne
    \else
      \macro@cnt\@ne
    \fi
    \ifdoc@noprint
      \item
    \else
      \edef\@tempa{%
        \noexpand\item[%
%    \end{macrocode}
% The second notable modification to the original macro involves dynamically
% constructing the name of the print macro:
%    \begin{macrocode}
        \noexpand\doc@providetarget
        \noexpand\strut
        \noexpand\@nameuse{Print#2Name}{\saved@macroname}]}%
      \@tempa
    \fi
    \ifdoc@noindex\else
      \global\advance\c@CodelineNo\@ne
%    \end{macrocode}
% and the third one involves dynamically constructing the name of the index
% macro:
%    \begin{macrocode}
      \csname SpecialMain#2Index\expandafter\endcsname
        \expandafter{\saved@macroname}\nobreak
      \global\advance\c@CodelineNo\m@ne
    \fi
%    \end{macrocode}
%    Suppress further |\index| entries when we are within a
%    \texttt{macrolike} environment. (There is no point doing that for
%    non-\texttt{macrolike} environments are index entries are only
%    generated for items starting with a backslash anyway.
% \fmi{fix}
%    \begin{macrocode}
    \if#1\expandafter\DoNotIndex \expandafter {\saved@macroname}\fi
    \ignorespaces}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
%
% \begin{macro}{\doc@env}
%   \marg{true-value}\marg{item}\oarg{options}\\
%   Handle optional arguments and call \cs{@doc@env}. Because environments can
%   be nested, we can't rely on grouping for getting options default values.
%   Hence, we need to reset the options at every call.
% \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
%    \begin{macrocode}
\def\doc@env#1#2[#3]{%
  \@nameuse{doc@noprint\doc@noprintdefault}%
  \@nameuse{doc@noindex\doc@noindexdefault}%
  \csname keys_set:nn\endcsname{doc}{#3}%
  \begingroup
    \ifdoc@outer
      \catcode`\\12
    \fi
    \MakePrivateLetters
    \@doc@env{#1}{#2}%
}
%    \end{macrocode}
% \end{macro}



% \subsection{\DOC descriptions}
%
% \begin{macro}{\@doc@describe}
%   \marg{item}\marg{name}\\
%    \begin{macrocode}
\def\@doc@describe#1#2{%
    \ifdoc@noprint\else
      \marginpar{\raggedleft
%    \end{macrocode}
%    The hyperref target has to be in horizontal mode (which is the
% case if it is after the \cs{strut}).
%    \begin{macrocode}
                 \strut
                 \doc@providetarget
                 \@nameuse{PrintDescribe#1}{#2}}%
    \fi
    \ifdoc@noindex\else
      \@nameuse{Special#1Index}{#2}%
    \fi
  \@esphack
  \endgroup
  \ignorespaces}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\doc@describe}
%   \marg{item}\oarg{options}\\
%   Handle optional arguments and call \cs{@doc@describe}.
% \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
%    \begin{macrocode}
\def\doc@describe#1[#2]{%
  \leavevmode\@bsphack
  \csname keys_set:nn\endcsname{doc}{#2}%
  \@doc@describe{#1}}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \subsection{API construction}
%
%
%  \begin{macro}{\@temptokenb}
%    A scratch register (which may have been defined elsewhere)
%    \begin{macrocode}
\@ifundefined{temptokenb}{\newtoks\@temptokenb}{}
%    \end{macrocode}
%  \end{macro}
%
%
% \begin{macro}{\doc@createspecialmainindex}
%   \marg{item}\marg{idxtype}\marg{idxcat}
% \begin{macro}{\doc@createspecialmainmacrolikeindex}
%   \marg{item}\marg{idxtype}\marg{idxcat}\\
% \fmi{original doc -- fix}
%   The ``macrolike'' version does something similar to |doc|'s
%   \cs{SpecialIndex@} macro, but simplified. Let's just hope nobody will ever
%   define \verb*|\ | or nonletter macros as macrolike \DOC elements\ldots
%    \begin{macrocode}
\def\doc@createspecialindexes#1#2#3{%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@temptokena{\space (#2)}%
  \@temptokenb{#3:}%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@nameedef{SpecialMain#1Index}##1{%
    \noexpand\@bsphack
  \ifdoc@toplevel
    \noexpand\special@index{##1\noexpand\actualchar
    {\string\ttfamily\space##1}%
    \ifx\@nil#2\@nil\else \the\@temptokena \fi
    \noexpand\encapchar main}%
  \fi
  \ifx\@nil#3\@nil\else
    \noexpand\special@index{\the\@temptokenb\noexpand\levelchar
      ##1\noexpand\actualchar{\string\ttfamily\space##1}%
      \noexpand\encapchar main}%
  \fi
    \noexpand\@esphack}%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@nameedef{Special#1Index}##1{%
    \noexpand\@bsphack
  \ifdoc@toplevel
    \noexpand\doc@providetarget
    \noexpand\index{##1\noexpand\actualchar{\string\ttfamily\space##1}%
    \ifx\@nil#2\@nil\else \the\@temptokena \fi
           \noexpand\doc@handleencap{usage}}%
  \fi
  \ifx\@nil#3\@nil\else
    \noexpand\index{\the\@temptokenb\noexpand\levelchar
       ##1\noexpand\actualchar{\string\ttfamily\space##1}%
           \noexpand\doc@handleencap{usage}}%
  \fi
    \noexpand\@esphack}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\doc@createspecialmacrolikeindexes#1#2#3{%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@temptokena{\space (#2)}%
  \@temptokenb{#3:}%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@nameedef{Code#1Index}##1##2{%
    \noexpand\@SpecialIndexHelper@##2\noexpand\@nil
    \noexpand\@bsphack
  \noexpand\ifdoc@noindex\noexpand\else
    \ifdoc@toplevel
      \noexpand\special@index{\noexpand\@gtempa\noexpand\actualchar
	\string\verb% % to fool emacs highlighting
	\noexpand\quotechar*\noexpand\verbatimchar
	\noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
	\ifx\@nil#2\@nil\else \the\@temptokena \fi
	\noexpand\encapchar ##1}%
    \fi
    \ifx\@nil#3\@nil\else
      \noexpand\special@index{\the\@temptokenb\noexpand\levelchar
	\noexpand\@gtempa\noexpand\actualchar
	\string\verb% % to fool emacs highlighting
	\noexpand\quotechar*\noexpand\verbatimchar
	\noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
	\noexpand\encapchar ##1}%
    \fi
  \noexpand\fi
    \noexpand\@esphack}%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@nameedef{SpecialMain#1Index}##1{%
    \expandafter\noexpand\csname Code#1Index\endcsname
        {main}{##1}}%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@nameedef{Special#1Index}##1{%
    \noexpand\@SpecialIndexHelper@##1\noexpand\@nil
    \noexpand\@bsphack
  \noexpand\ifdoc@noindex\noexpand\else
    \ifdoc@toplevel
      \noexpand\doc@providetarget
      \noexpand\index{\noexpand\@gtempa\noexpand\actualchar
	\string\verb% % to fool emacs highlighting
	\noexpand\quotechar*\noexpand\verbatimchar
	\noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
	\ifx\@nil#2\@nil\else \the\@temptokena \fi
	\noexpand\doc@handleencap{usage}}%
    \fi
    \ifx\@nil#3\@nil\else
      \noexpand\index{\the\@temptokenb\noexpand\levelchar
	\noexpand\@gtempa\noexpand\actualchar
	\string\verb% % to fool emacs highlighting
	\noexpand\quotechar*\noexpand\verbatimchar
	\noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
	\noexpand\doc@handleencap{usage}}%
    \fi
  \noexpand\fi
    \noexpand\@esphack}}
%    \end{macrocode}
% \end{macro}
% \end{macro}



% \begin{macro}{\doc@createdescribe}
%   \marg{item}
%    \begin{macrocode}
\def\doc@createdescribe#1{%
  \@namedef{Describe#1}{%
%    \end{macrocode}
%    Because of the optional argument we have to set
%    |\MakePrivateLetters| already before parsing that (fingers
%    crossed). Otherwise incorrect but quite common usage, such as
%    |\DescribeMacro\foo@bar| will break because the scan for the
%    optional argument will tokenize the following input (i.e., |\foo|
%    in that case) before the |@| sign becomes a letter. As a result
%    |DescribeMacro| would receive only |\foo| as its argument.
%    \begin{macrocode}
    \begingroup
      \MakePrivateLetters
      \@ifnextchar[%]
      {\doc@describe{#1}}{\doc@describe{#1}[]}}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\doc@createenv}
%   \marg{item}\marg{envname}
%    \begin{macrocode}
\def\doc@createenv#1#2#3{%
  \@namedef{#3}{%
    \@ifnextchar[%]
    {\doc@env{#1}{#2}}{\doc@env{#1}{#2}[]}}%
%    \end{macrocode}
%    Instead of |\let|ting the end of the environment to
%    |\endtrivlist| we use one level of expansion. This way any
%    possible change in that environment (if that ever happens) is
%    properly reflected.
%    \begin{macrocode}
  \@namedef{end#3}{\endtrivlist}%
%  \expandafter\let\csname end#3\endcsname\endtrivlist
}
%    \end{macrocode}
% \end{macro}


%
%  \begin{macro}{\@nameedef}
%
%    \begin{macrocode}
\def\@nameedef#1{\expandafter\edef\csname #1\endcsname}
%    \end{macrocode}
%  \end{macro}

%
% \subsection{API creation}
%
% The whole user interface is created in one macro call.
%
%\begin{verbatim}
% defaults:
%
%  idxtype   = #3
%  idxgroup  = #3s
%  printtype =
%\end{verbatim}



%  \begin{macro}{\doc@declareerror}
%
%    \begin{macrocode}
\def\doc@declareerror#1#2{%
   \PackageError{doc}{Doc element '#1/#2' already defined?\@gobble}%
      {There is already a definition for
       '\string\Print#1Name',\MessageBreak
       '\string\PrintDescribe#1'
       or the environment '#2'.\MessageBreak
       Maybe you are overwriting something by mistake!\MessageBreak
       Otherwise use '\string\RenewDocElement' instead.}%
}
%    \end{macrocode}
%  \end{macro}

%  \begin{macro}{\doc@notdeclarederror}
%
%    \begin{macrocode}
\def\doc@notdeclarederror#1#2{%
   \PackageError{doc}{Doc element '#1/#2' unknown}%
      {I expected an existing definition for
       '\string\Print#1Name',\MessageBreak
       '\string\PrintDescribe#1' and
       the environment '#2' but\MessageBreak
       not all of them are defined.\MessageBreak
       Maybe you wanted to use
       '\string\NewDocElement'?}%
}
%    \end{macrocode}
%  \end{macro}
%
%
% \begin{imacro}{\NewDocElement}
%   \oarg{options}\marg{name}\marg{envname}
%
%    \begin{macrocode}
\newcommand\NewDocElement[3][]{%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@ifundefined{Print#2Name}%
      {\@ifundefined{PrintDescribe#2}%
           {\@ifundefined{#3}%
               {\@ifundefined{end#3}%
                    {\@NewDocElement{#1}}%
                    \doc@declareerror
               }\doc@declareerror
           }\doc@declareerror
      }\doc@declareerror
  {#2}{#3}%
}
%    \end{macrocode}
%  \end{imacro}
%
% \begin{imacro}{\RenewDocElement}
%   \oarg{options}\marg{name}\marg{envname}
%
%    \begin{macrocode}
\newcommand\RenewDocElement[3][]{%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@ifundefined{Print#2Name}\doc@notdeclarederror
      {\@ifundefined{PrintDescribe#2}\doc@notdeclarederror
           {\@ifundefined{#3}\doc@notdeclarederror
               {\@ifundefined{end#3}\doc@notdeclarederror
                    {\@NewDocElement{#1}}%
               }%
           }%
      }%
  {#2}{#3}%
}
%    \end{macrocode}
%  \end{imacro}
%
%
% \begin{macro}{\@NewDocElement}
%   \marg{options}\marg{name}\marg{envname}
%
%    \begin{macrocode}
\def\@NewDocElement#1#2#3{%
%    \end{macrocode}
%
%    \begin{macrocode}
  \doc@macrolikefalse
  \doc@topleveltrue
%    \end{macrocode}
%
% \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
%    \begin{macrocode}
  \def\doc@idxtype{#3}%
  \def\doc@idxgroup{#3s}%
  \let\doc@printtype\@empty
  \csname keys_set:nn\endcsname{doc}{#1}%
%    \end{macrocode}
%   \begin{imacro}{\Print...Name}
%     \marg{name}
% \fmi{extremely messy this with so many \cs{expandafter}s \ldots{}
%       should reimplement in expl3}
%    \begin{macrocode}
  \ifx\doc@printtype\@empty
    \@temptokena{}%
  \else
    \@temptokena\expandafter{\expandafter
         \textnormal\expandafter{\expandafter
         \space\expandafter
         (\doc@printtype)}}%
  \fi
  \@nameedef{Print#2Name}##1{%
     {\noexpand\MacroFont
      \ifdoc@macrolike
         \noexpand\string
      \fi
      ##1%
      \the\@temptokena
     }}%
%    \end{macrocode}
%   \end{imacro}
%
%   \begin{imacro}{\PrintDescribe...}
%     \marg{name}
%    \begin{macrocode}
  \expandafter\let\csname PrintDescribe#2\expandafter\endcsname
                  \csname Print#2Name\endcsname
%    \end{macrocode}
%   \end{imacro}
%
%   \begin{imacro}{\SpecialMain...Index}
%     \marg{name}
%   \begin{imacro}{\Special...Index}
%     \marg{name}
%    \begin{macrocode}
  \edef\doc@expr{%
     \ifdoc@macrolike
       \noexpand\doc@createspecialmacrolikeindexes
     \else
       \noexpand\doc@createspecialindexes
     \fi
     {#2}%
    }%
   \expandafter\expandafter\expandafter
   \doc@expr
   \expandafter\expandafter\expandafter
     {\expandafter\doc@idxtype\expandafter}\expandafter
     {\doc@idxgroup}%
%    \end{macrocode}
%   \end{imacro}
%   \end{imacro}
%
%   \begin{imacro}{\Describe...}
%     \oarg{options}\marg{name}
%    \begin{macrocode}
  \doc@createdescribe{#2}%
%    \end{macrocode}
%   \end{imacro}
%
%   \begin{environment}{\meta{DocElement}}
%  \fmi{can't have formatting in argument -- fix}
%     \oarg{options}\marg{name}
%    \begin{macrocode}
    \ifdoc@macrolike
      \doc@createenv{TT}{#2}{#3}%
    \else
      \doc@createenv{TF}{#2}{#3}%
    \fi
}
%    \end{macrocode}
%   \end{environment}
% \end{macro}





% \subsection{Setting up the default \DOC elements}

% \subsubsection{Macro facilities}
%
%    Macros get only a single index entry (no index group, no index
%    type) and they do not get any label either when printing in the margin.
%    \begin{macrocode}
\NewDocElement[macrolike = true ,
                idxtype   = ,
                idxgroup  = ,
                printtype =
               ]{Macro}{macro}
%    \end{macrocode}


%  \begin{macro}{SpecialMainIndex}
%
%    In \DOC v2 we had \cs{SpecialMainIndex} and
%    \cs{SpecialMainEnvIndex} but now with additional \DOC elements we
%    always add the element name after ``\texttt{Main}'' so this would
%    be \cs{SpecialMainMacroIndex}. We use |\def| not |\let| so any
%    redefinition of |\SpecialMainMacroIndex| will be transparent.
%    \begin{macrocode}
\def\SpecialMainIndex{\SpecialMainMacroIndex}
%    \end{macrocode}
%  \end{macro}

%  \begin{macro}{SpecialUsageIndex}
%    \DOC v2 also had \cs{SpecialUsageIndex} which is now called
%    \cs{SpecialMacroIndex} generating the ``usage'' index entry  for
%    a macro. Again we provide that as an alias via |\def|.
%
%    In fact the documentation of \DOC v2 claimed that one can use
%    this for both macros and environments but that was never true as
%    for environments the result was that the first character was
%    dropped in sorting of the index. The correct way is to use
%    \cs{SpecialEnvIndex} for this.
%    \begin{macrocode}
\def\SpecialUsageIndex{\SpecialMacroIndex}
%    \end{macrocode}
%  \end{macro}
%

%  \begin{macro}{\SpecialIndex}
%    \begin{macrocode}
\def\SpecialIndex     {\CodeMacroIndex{code}}
%    \end{macrocode}
%  \end{macro}


%
% \subsubsection{Environment facilities}
%
%    Providing documentation support for environments. Here we differ
%    from \DOC V2 by marking the environments with ``(\textit{env.})''
%    when printing the name in the margin.
%    \begin{macrocode}
\NewDocElement[macrolike = false ,
                idxtype   = env.  ,
                idxgroup  = environments ,
                printtype = \textit{env.}
               ]{Env}{environment}
%    \end{macrocode}
%
%
%
%    To be able to restore the definition after \pkg{hypdoc} is loaded
%    we better save them here. We only load the package at the end of
%    the preamble, but the user might do this earlier and then chaos
%    is ensured.
%    \begin{macrocode}
  \let\@@PrintDescribeMacro \PrintDescribeMacro
  \let\@@PrintDescribeEnv \PrintDescribeEnv
  \let\@@PrintMacroName \PrintMacroName
  \let\@@PrintEnvName \PrintEnvName
  \let\@@SpecialUsageIndex \SpecialUsageIndex
  \let\@@SpecialEnvIndex \SpecialEnvIndex
  \let\@@SortIndex \SortIndex
  \let\@@DescribeMacro \DescribeMacro
  \let\@@DescribeEnv \DescribeEnv
%    \end{macrocode}
%
%
% \section{Misc additions}

% \begin{imacro}{\cs}
%    \begin{macrocode}
\DeclareRobustCommand\cs[1]{\texttt{\bslash #1}}
%    \end{macrocode}
%    \cls{amsdtx} has its own definition for \cs{cs} but that now
%    gets overwritten because the class loads \pkg{doc} afterwards. So
%    for now we reinstall it here.
%    \fmi{fix elsewhere}
%    \begin{macrocode}
\AddToHook{class/amsdtx/after}{%
  \DeclareRobustCommand\cs[1]{%
    \@boxorbreak{%
        \ntt
        \addbslash#1\@empty
        \@xp\@xp\@xp\@indexcs\@xp\@nobslash\string#1\@nil
    }%
  }%
  \def\cn{\cs}%
}
%    \end{macrocode}
% \end{imacro}


% We can now finish the \texttt{docstrip} main module.
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
%
% \Finale
% \PrintChanges
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% \section{Code no longer used}
%
% \begin{imacro}{\verb}
% \changes{v1.7a}{1992/02/27}{Now warns about newlines (from
%                           newdoc with `@noligs added).}
% \changes{v1.8b}{1993/09/21}{Changed to conform to new LaTeX \cs{verb}}
% We re-define |\verb| to check for newlines in its argument since a
% missing delimiter is difficult to detect in \DOC{} source.
% The code is the same as in \texttt{latex.tex} of September 19, 1993.
% Perhaps there should be a font-changing
% hook rather than just using |\ttfamily|, but if so it probably should be
% different from |\MacroFont| since that normally includes |\small|
% and would look wrong inline.
% \changes{v1.7a}{1992/02/28}{Added math mode check (from verbatim.sty)}
%    \begin{macrocode}
%\def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi
%  \bgroup \let\do\do@noligs \verbatim@nolig@list
%    \ttfamily \verb@eol@error \let\do\@makeother \dospecials
%    \@ifstar{\@sverb}{\@vobeyspaces \frenchspacing \@sverb}}
%    \end{macrocode}
% \end{imacro}
%
% \begin{macro}{\verb@balance@group}
% \begin{macro}{\verb@egroup}
% \begin{macro}{\verb@eol@error}
% \changes{v1.8b}{1993/09/21}{Renamed \cs{verb@err} to
%                   \cs{verb@eol@error}, as in new LaTeX verbatim.}
%    \begin{macrocode}
%\let\verb@balance@group\@empty
%    \end{macrocode}
%
%    \begin{macrocode}
%\def\verb@egroup{\global\let\verb@balance@group\@empty\egroup}
%    \end{macrocode}
%
%    \begin{macrocode}
%\begingroup
%  \obeylines%
%  \gdef\verb@eol@error{\obeylines%
%    \def^^M{\verb@egroup\@latex@error{%
%            \noexpand\verb command ended by end of line}\@ehc}}%
%\endgroup
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@sverb}
% \changes{v1.7a}{1992/02/27}{Added for \cs{verb} change.}
% \changes{v1.7a}{1992/02/28}{Now same as in verbatim.sty.}
% \changes{v1.8b}{1993/09/21}{Changed to conform to new LaTeX verbatim,
%                           which has better error trapping.}
% See \cite{art:verbatim} for commentary.
%  \changes{v2.1j}{2019/11/03}{Use the kernel definition, no change needed (gh/205)}
%    \begin{macrocode}
%\def\@sverb#1{%
%  \catcode`#1\active  \lccode`\~`#1%
%  \gdef\verb@balance@group{\verb@egroup
%     \@latex@error{Illegal use of \noexpand\verb command}\@ehc}%
%  \aftergroup\verb@balance@group
%  \lowercase{\let~\verb@egroup}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\verbatim@nolig@list}
% \begin{macro}{\do@noligs}
%     These macros replace the old |\@noligs| mechanism by an
%     extensible version to allow more ligatures to be added.
%    \begin{macrocode}
%\def\verbatim@nolig@list{\do\`\do\<\do\>\do\,\do\'\do\-}
%\def\do@noligs#1{%
%  \catcode`#1\active
%  \begingroup
%     \lccode`\~`#1\relax
%     \lowercase{\endgroup\def~{\leavevmode\kern\z@\char`#1}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}


^^A  Needed for emacs
^^A
^^A  Local Variables: 
^^A  mode: latex
^^A  coding: utf-8-unix
^^A  End: