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
|
% \iffalse
%%
%% File: nccsect.dtx Copyright (C) 2002--2006 by Alexander I. Rozhenko
%%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{nccsect}
%<package> [2006/01/19 v1.5 Extended Section, Caption, and TOC Handling (NCC)]
%
% \changes{v1.00}{2002/02/01}{This version is uploaded to CTAN}
% \changes{v1.01}{2002/02/08}{\NCC@thetocchapter hook added}
% \changes{v1.02}{2002/02/13}{Bug in using the \nosectiontag fixed}
% \changes{v1.02}{2002/03/19}{Test for caption with empty text added}
% \changes{v1.03}{2002/05/19}{Vskips in captions after style changes now}
% \changes{v1.04}{2002/05/22}{Centering in captions now works}
% \changes{v1.1}{2004/12/12}{Introduce |\NCC@sec@reset@controls|}
% \changes{v1.1}{2004/12/12}{Simplify making sections. The |\NCC@makesection| now
% incompatible with previous version!!!}
% \changes{v1.1}{2004/12/12}{Revised version: many internal changes}
% \changes{v1.1}{2004/12/12}{Documentation was prepared}
% \changes{v1.2}{2005/04/15}{Emulate |\@makecaption| for compatibility}
% \changes{v1.2}{2005/04/15}{Compatibility with the supertabular package added}
% \changes{v1.2}{2005/04/15}{Compatibility with the longtable package added}
% \changes{v1.2}{2005/05/20}{Introduce |\beforechapter| hook}
% \changes{v1.2}{2005/05/20}{Add |\StartFromTextArea| and |\StartFromHeaderArea|}
% \changes{v1.2}{2005/05/21}{Add |\epigraph| and |\epigraphparameters|}
% \changes{v1.2}{2005/05/22}{Add |\captionstyle| and related staff}
% \changes{v1.2}{2005/05/22}{Add |\TOCMarginDrift|}
% \changes{v1.2}{2005/05/22}{Add |\applystyle| command to TOC Entry style}
% \changes{v1.2}{2005/06/08}{Set |\@twocolumnfalse| in before-chapter hook}
% \changes{v1.2}{2005/06/08}{Allow sectioning in |\beforechapter| hook}
% \changes{v1.3}{2005/06/15}{Fixed bug with using |\applystyle| command}
% \changes{v1.4}{2005/12/26}{Conditionally define |\StartFromTextArea| and |\StartFromHeaderArea|}
% \changes{v1.4}{2005/12/28}{|\sectionstyle| now has a |type| parameter}
% \changes{v1.4}{2005/12/28}{New section styles: hangparindent, hangparindent*}
% \changes{v1.4}{2005/12/28}{|\NCC@makechapfinal| hook introduced}
% \changes{v1.4}{2005/12/28}{|\NCC@makeparttitle|, |\NCC@makechaptitle| hooks}
% \changes{v1.4}{2005/12/28}{The scope of declarations in |\@svsec| is localized}
% \changes{v1.4}{2005/12/28}{|\aftersectionvspace| introduced}
% \changes{v1.4}{2005/12/29}{Add |\DeclarePart| and |\DeclareTOCPart| commands}
% \changes{v1.4}{2005/12/30}{Make the package completely independent on standard commands}
% \changes{v1.4}{2005/12/31}{Add more hooks and fix |\MakeUppercase| related bugs}
% \changes{v1.4}{2006/01/01}{Introduce |\RunningSectionSuffux| command}
% \changes{v1.4}{2006/01/01}{Introduce |\NCC@preparesectag| hook}
% \changes{v1.4}{2006/01/01}{Remove |\NCC@defaultsectag| hook}
% \changes{v1.4}{2006/01/01}{|\NCC@nexttocnum|, |\NCC@preparetocnum| hooks}
% \changes{v1.4}{2006/01/03}{The |\norunningsuffix| modifier introduced}
% \changes{v1.5}{2006/01/06}{Introduce |\SetTOCStyle| and |\ChapterPrefixStyle|}
% \changes{v1.5}{2006/01/17}{Replace addtopackage to afterpackage}
% \changes{v1.5}{2006/01/17}{Remove \protect before \numberline, because it is robust now}
% \changes{v1.5}{2006/01/19}{Allow caption width be greater than a line width}
% \changes{v1.5}{2006/01/19}{Compatibility with the xtab package added}
% \changes{v1.5}{2006/01/19}{Add |\newplainsectionstyle|, |\newhangsectionstyle|}
% \changes{v1.5}{2006/01/19}{Add |\adjustsectionmargins|}
% \changes{v1.5}{2006/01/19}{Introduce |centerlast| section style}
% \changes{v1.5}{2006/01/19}{Introduce |\sectiontagsuffix| command}
% \changes{v1.5}{2006/01/19}{Introduce |\captiontagsuffix| command}
%
%<*driver>
\let\makeindex\relax
\documentclass{ltxdoc}
\usepackage{nccsect,nccboxes,desclist}
\GetFileInfo{nccsect.sty}
\newhangsectionstyle{margin}{2in}[r]{-2in}{0pt plus 1fil}
\newhangsectionstyle{list}{1in}{0pt}{1in plus 1fil}
\newplainsectionstyle{flushright}{0pt}[r]{1in plus 1fil}{0pt}
\begin{document}
\title{The \textsf{nccsect} package\thanks{This file
has version number \fileversion, last
revised \filedate.}\ \thanks{Great thanks to Denis G. Samsonenko
\texttt{<d.g.samsonenko@gmail.com>} who proposed many significant
improvements to the package.}}
\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
\date{\filedate}
\maketitle
\DocInput{nccsect.dtx}
\end{document}
%</driver>
% \fi
%
% \tableofcontents
%
% \section{The Scope and Objectives}
%
% The package provides a new implementation of sections, captions,
% and toc-entries independent on the \LaTeX\ kernel. The reasons for this
% are concerned with the following disadvantages of the
% standard \LaTeX\ implementation:
%
% \paragraph{1} Standard \LaTeX\ sectioning commands can prepare
% display sections in the single style: justified paragraph
% with hang indented number. To change this style to another
% one (centered, par-indented, or else), you need
% to re-implement the internal |\@sect| command. It is no
% control for this style on user's level.
%
% \paragraph{2} If you want to customize the presentation a number in
% a section (for example, put a paragraph mark \S\ before a number
% or put a point after a number), you at least need to
% re-implement the |\@sect| command.
%
% \paragraph{3} The sectioning commands provide no straightforward
% control for running headings. The marking commands
% like the |\sectionmark| solve this problem partially.
% Using them within parameter of sectioning command,
% you can change the mark properly, but this solution does not work in
% complicated documents which use first and last marks
% appearing on a page. The safe solution consists in direct
% replacement a mark prepared within the |\@sect| command
% to a custom mark.
%
% \paragraph{4} Special efforts are required to pass a section
% without number to the header and to the toc-list. There is no simple
% solution providing this action.
%
% \paragraph{5} Captions for tables and figures are prepared in
% just the same way, although, they are usually used in different
% places of floating environments: table captions start
% \textit{before\/} a table, but figure captions go \textit{after\/}
% a figure. So, the vertical skip inserted before a caption is
% unnecessary for table captions. The right solution is to design
% captions for different float types in different ways.
%
% \paragraph{6} The star-form of captions is absent. It is useful
% when a document contains an alone figure or table. Moreover,
% in fiction books, unnumbered captions useful.
%
% \paragraph{7} The design of toc-entries is hard for modifications.
% It is much better to calculate the skips in toc-entries on the
% base of prototyping technique instead of hard-coding them
% with absolute values. Moreover, the skips for nested sections
% must depend on higher level skips. For example, if we
% change skips for a section entry, the skips for subsection entries
% should be adjusted automatically.
%
% \bigskip
% The package eliminates above-mention disadvantages of the standard
% \LaTeX\ implementation. The commands implemented in it are divided
% into two levels: user level and design level. The user-level commands
% are intended for use within a document and the design-level commands
% are directed to class and package writers.
%
% \section{User Interface}
%
% The table below shows sectioning commands provided with standard
% \LaTeX\ classes. Every section has a \textit{level\/} (an integer
% number). Sections can be printed in one of two modes:
% \textit{display\/} or \textit{running\/} mode. Display section is
% prepared as a separate justified paragraph having a hang indent if a
% section has a number. Running section starts a paragraph.
% \begin{center}\catcode`|=12
% \small\tabcolsep=10pt
% \renewcommand\cboxstyle{\footnotesize}
% \begin{tabular}{|l|c|c|}\hline
% \hfill\cbox{Command}\hfill\mbox{} &
% \hfill\cbox{Level}\hfill\mbox{} &
% \hfill\cbox{Mode}\hfill\mbox{}\\\hline
% \Strut/.8/
% \cs{part} & $-$1 or 0\footnotemark & display \\
% \cs{chapter} & 0\footnotemark & display \\
% \cs{section} & 1 & display \\
% \cs{subsection} & 2 & display \\
% \cs{subsubsection} & 3 & display \\
% \cs{paragraph} & 4 & running \\
% \cs{subparagraph} & 5 & running \\
% \hline
% \end{tabular}\footnotetext[1]{The \cs{part} command has zero level
% in article-like classes and has the negative level in book-like
% classes. In book-like classes a part is prepared on
% a separate page.}\footnotetext{The \cs{chapter} command is defined
% in book-like classes only.}
% \end{center}
%
% \DescribeMacro\startsection
% The package redefines all standard sectioning commands. Along with the
% commands shown in the table above, you can use the following
% uniform notations:
% \begin{quote}
% |\startsection|\marg{level}\oarg{toc-entry}\marg{title}\quad or\\
% |\startsection|\marg{level}|*|\marg{title}
% \end{quote}
% The \meta{level} is a level of section. A negative level produces
% a part. The first command
% produces a numbered section (if~the numbering depth allows this)
% and the last one produces a section without number.
% As for the standard \LaTeX\ sectioning, the first variant of
% the |\startsection| command additionally passes their arguments
% to the section mark command (if the mark command exists)
% and to the aux-file.
% The last variant does no additional actions.
%
% \bigskip
% \textbf{NOTE}: The package allows declaring additional section
% levels. They, of course, have no predefined alias names as
% standard section levels.
%
% \bigskip
% \DescribeMacro\sectionstyle
% The |\sectionstyle|\oarg{type}\marg{style} command allows change
% a style of subsequent display sections of the given \meta{type}:
% \begin{desclist}{\tt}{\quad}[subsubsection]\itemsep=0mm
% \item[main] the section of zero level (|\part| or |\chapter|);
% \item[section] the |\section|;
% \item[subsection] the |\subsection|;
% \item[subsubsection] the |\subsubsection|;
% \item[paragraph] the |\paragraph|;
% \item[subparagraph] the |\subparagraph|;
% \item[section@vi] the section of 6th level, and so on.
% \end{desclist}
% If the \meta{type} parameter is omitted, the command acts on
% all subsequent display sections expect those having a specialized style.
% The following styles are predefined:
% \begin{desclist}{\tt}{\quad}[hangparindent*]\itemsep=0mm
% \item[hangindent] standard LaTeX style (default);
% \item[hangindent*] the same as |hangindent|, but ragged right;
% \item[parindent] title indented on |\parindent|;
% \item[parindent*] the same as |parindent|, but ragged right;
% \item[hangparindent] |\parindent| indented with hang number;
% \item[hangparindent*] the same as |hangparindent|, but ragged right;
% \item[center] centered title;
% \item[centerlast] justified title without indent whose last line is centered.
% \end{desclist}
% You can apply the |\sectionstyle| so many times in the document
% as you want. This command complies with standard \LaTeX\ scoping
% rules.
%
% \bigskip
% \textbf{NOTE}: The section style acts on display sections that were
% prepared with the dynamic alignment (see Section~\ref{s:decl}). By default,
% the sections of levels from 0 to 3 have the dynamic alignment. The
% section of zero level has no hang indentation.
%
% \bigskip
% \DescribeMacro\sectiontagsuffix
% The |\sectiontagsuffix|\oarg{type}\marg{style} command allows change
% a suffix inserted after number tag for sections of the given \meta{type}.
% If the \meta{type} parameter is omitted, the command acts on
% all subsequent sections expect those having a specialized tag suffix.
%
% \bigskip
% \DescribeMacro\indentaftersection
% \DescribeMacro\noindentaftersection
% The paragraph indentation after a display section is controlled with
% the |\indentaftersection| and |\noindentaftersection| commands.
% The first one allows and the last one suppresses
% indentation after section. The commands act on the subsequent
% display sections in the scope of their use.
%
% \DescribeMacro\aftersectionvspace
% If a document contains two subsequent sectioning commands (for example,
% |\section| and |\subsection|) the distance between their titles is
% equal to the skip after the first sectioning command. Sometimes
% it is necessary to insert another vertical space here. To override
% the space inserted between sections, use the command
% \begin{quote}
% |\aftersectionvspace|\marg{distance}
% \end{quote}
% This command replaces the space inserted by a previous sectioning
% command with the |\vspace|\marg{distance}. It works in the only case when
% goes right after a command producing a display section. Otherwise, the
% specified \meta{distance}
% is ignored. The following example shows how to customize the
% |\subsection| command in such a way that the distance between it and
% a previous |\section| will be |3ex plus .5ex minus .2ex|:
% \begin{quote}
% |\renewcommand\subsection{%|\\
% | \aftersectionvspace{3ex plus .5ex minus .2ex}%|\\
% | \startsection{2}}|
% \end{quote}
%
% \DescribeMacro\adjustsectionmargins
% Margins of a display section can be adjusted using the command
% \begin{quote}
% |\adjustsectionmargins|\marg{left skip}\marg{right skip}
% \end{quote}
% The \meta{left skip} and \meta{right skip} are added to the left and
% right margins of the subsequent section if it is a display section.
% Otherwise, this command is ignored.
%
% \bigskip
% \textbf{Modifiers.} The customization of a number tag and running head of a concrete
% section is provided with so-call \textit{modifiers}. A modifier
% is a command acting on the nearest sectioning command going after it.
% Usually, the modifiers are placed just before a sectioning command.
% All modifiers act with non-starred versions of sections.
% If the next sectioning command is starred, modifiers are ignored.
%
% \DescribeMacro\norunninghead
% The |\norunninghead| modifier suppresses generation of running head for the
% next non-starred section, i.e.\ it skips the call of section mark command
% in the next section.
%
% \DescribeMacro\runninghead
% The |\runninghead|\marg{running-title} modifier overrides a text going to the
% running head when a new non-starred section starts and an appropriate\linebreak
% |\pagestyle| is in use. This command has higher priority
% than the |\norunninghead|.
%
% \DescribeMacro\noheadingtag
% The |\noheadingtag| modifier suppresses a number tag in the next section,
% but all other attendant actions are executed (writing to the aux-file and
% updating the running head).
%
% \DescribeMacro\headingtag
% The |\headingtag|\marg{tag} modifier overrides a number tag in the next
% section. It has the higher priority than |\noheadingtag|. Overridden
% section tag can be referred with the |\label| command.
% All fragile commands in the overridden tag should be protected.
%
% \DescribeMacro{\headingtag*}
% The |\headingtag*|\marg{tag} modifier prepares a number tag as is, ignoring
% the tag style, prefix, and suffix. The aux-file and running head are not
% updated in this case.
%
% \DescribeMacro\skipwritingtoaux
% The |\skipwritingtoaux| suppresses writing to aux-file for the next section
% command.
%
% \bigskip
% \textbf{NOTE}: All modifiers use global settings.
%
% \bigskip
% \DescribeMacro\caption
% \DescribeMacro{\caption*}
% The captions are implemented in this package using the same technique as
% the sectioning commands. There are two versions of caption command
% allowed within floating environments:
% \begin{quote}
% |\caption|\oarg{toc-entry}\marg{title}\quad and\\
% |\caption*|\marg{title}
% \end{quote}
% The first one works in the same manner as the standard \LaTeX\ |\caption|
% command. Its starred version prepares a caption without number and preceding
% words `Figure' or `Table'.
%
% You can use line breaking commands in captions. But in this case,
% you need to set the optional \meta{toc-entry} parameter to avoid
% translation errors.
%
% Caption appearance can be customized. You can customize ether all caption
% types or only selected caption type. The following commands do this:
% \begin{quote}
% |\captionstyle|\oarg{type}\marg{style}\\
% |\captiontagstyle|\oarg{type}\marg{style}\\
% |\captiontagsuffix|\oarg{type}\marg{suffix}\\
% |\captionwidth|\oarg{type}\marg{length}
% \end{quote}
% If \meta{type} is omitted and these commands appear out of float
% environments, they are applied to all types.
% A command without \meta{type} applied within a float environment
% is considered as a command having the type of this environment. Typed
% version of a command has a precedence before a non-typed one.
%
% \medskip\noindent
% \DescribeMacro\captionstyle
% specifies a style
% the caption text will be formatted:
% \begin{desclist}{\tt}{\quad}[centerlast]\itemsep=0mm
% \item[default] standard \LaTeX's style,
% \item[para] simple paragraph without paragraph indent,
% \item[left] all lines are flushed left,
% \item[center] all lines are centered,
% \item[right] all lines are flushed right, or
% \item[centerlast] as |para|, but the last line is centered.
% \end{desclist}
%
% \medskip\noindent
% \DescribeMacro\captiontagstyle
% specifies a position of caption tag:
% \begin{desclist}{\tt}{\quad}[centerlast]\itemsep=0mm
% \item[para] tag is formatted together with text,
% \item[left] tag is adjusted to the left in a separate line,
% \item[center] tag is centered in a separate line, or
% \item[right] tag is adjusted to the right in a separate line.
% \end{desclist}
%
% \medskip\noindent
% \DescribeMacro\captiontagsuffix
% specifies a suffix after caption tag.
%
% \medskip\noindent
% \DescribeMacro\captionwidth
% specifies a width of caption.
%
% \medskip\noindent
% Defaults:
% \begin{quote}
% |\captionstyle{default}|\\
% |\captiontagstyle{para}|\\
% |\captiontagsuffix{:\hspace{0.7em plus 0.2em minus 0.1em}}|\\
% |\captionwidth{\linewidth}|
% \end{quote}
%
% \textbf{NOTE}: The above-described section modifiers can be used with non-starred
% captions. Although, the |\runninghead| and |\norunninghead| commands
% have no sense with captions, but you can do them working if define
% a |\figuremark{}| or |\tablemark{}| command.
%
% \bigskip
% \DescribeMacro\SetTOCStyle
% The |\SetTOCStyle|\marg{declarations} command allows customize
% the table of contents and other content lists. For example, the declaration
% \begin{quote}
% |\SetTOCStyle{\small}|
% \end{quote}
% specifies that content lists will be prepared with the |\small| font.
% This command is allowed in the preamble only.
%
% \DescribeMacro\ChapterPrefixStyle
% The appearance of Chapter/Appendix prefix in a table of contents and
% in a running head can be customized using the command
% \begin{quote}
% |\ChapterPrefixStyle|\marg{appearance list}
% \end{quote}
% The \meta{appearance list} can contain up to two words, namely
% |header| and/or |toc|, delimited with a comma. Using them, you can
% set a prefix-style for the header and/or the table of contents, respectively.
% By default, the prefix-style is specified for the header only. This command
% is allowed for book-like classes in which the |\chapter| command is
% defined. It can be used in the preamble only.
%
% \section{Create New Section Styles}
%
% Along with 8 predefined section styles, you can easy create more styles.
%
% \DescribeMacro\newplainsectionstyle
% The command
% \begin{quote}
% |\newplainsectionstyle|\marg{name}\marg{indent}\oarg{pos}\\
% | |\marg{left skip}\marg{right skip}
% \end{quote}
% creates a new paragraph-like section style with the given \meta{name}.
% It has the \meta{indent} paragraph indent
% and margins specified with \meta{left skip} and \meta{right skip} lengths.
% To prepare a centered style, the optional \meta{pos} parameter
% should be equal to |[c]|. In this case, left and right margins must
% have an additional |1fil| glue. If optional parameter is |[r]|, the
% left margin must have an additional |1fil| glue.
%
% Four of predefined section styles are created using this command as follows:
% \begin{quote}
% |\newplainsectionstyle{parindent}{0pt}{\parindent}{0pt}|\\
% |\newplainsectionstyle{parindent*}{0pt}{\parindent}{0pt plus 1fil}|\\
% |\newplainsectionstyle{center}{0pt}[c]{0pt plus 1fil}{0pt plus 1fil}|\\
% |\newplainsectionstyle{centerlast}{0pt}[c]{0pt plus 1fil}{0pt plus -1fil}|
% \end{quote}
%
% \DescribeMacro\newhangsectionstyle
% The command
% \begin{quote}
% |\newhangsectionstyle|\marg{name}\marg{min tag width}\oarg{pos}\\
% | |\marg{left skip}\marg{right skip}
% \end{quote}
% creates a new hang-indented section style with the given \meta{name}.
% The \meta{min tag width} length specifies a minimum width of the section
% tag. If a width of section tag is less than this parameter value,
% a white space will be inserted surround the tag to have the required
% width. The method of inserting a white space is the same as in the
% |\makebox| command. It is controlled with the optional \meta{pos}
% parameter (|l|, |c|, or |r|; |l| default). Other parameters have
% the same meaning as in the previous command.
%
% Four of predefined section styles are created using this command as follows:
% \begin{quote}
% |\newhangsectionstyle{hangindent}{0pt}{0pt}{0pt}|\\
% |\newhangsectionstyle{hangindent*}{0pt}{0pt}{0pt plus 1fil}|\\
% |\newhangsectionstyle{hangparindent}{0pt}{\parindent}{0pt}|\\
% |\newhangsectionstyle{hangparindent*}{0pt}{\parindent}{0pt plus 1fil}|
% \end{quote}
%
% The following examples shows possibilities of these commands:
%
% \skipwritingtoaux
% \sectionstyle[subsection]{margin}
% \subsection{This subsection was prepared in the margin style}
%
% The definition of the |margin| style is the following:
% \begin{quote}
% |\newhangsectionstyle{margin}{2in}[r]{-2in}{0pt plus 1fil}|
% \end{quote}
%
% \skipwritingtoaux
% \sectionstyle[subsection]{list}
% \subsection{This subsection was prepared in the list style}
%
% The definition of the |list| style is the following:
% \begin{quote}
% |\newhangsectionstyle{list}{1in}{0pt}{1in plus 1fil}|
% \end{quote}
%
% \skipwritingtoaux
% \sectionstyle[subsection]{flushright}
% \subsection{This subsection was prepared in the flushright style}
%
% The definition of the |flushright| style is the following:
% \begin{quote}
% |\newplainsectionstyle{flushright}{0pt}[r]{1in plus 1fil}{0pt}|
% \end{quote}
% \sectionstyle[subsection]{hangindent}
%
% \section{Declare Sections and Captions\label{s:decl}}
%
% \DescribeMacro\DeclareSection
% To define or redefine a section or caption command, you can use
% in the preamble of your document the
% following command:
% \begin{quote}
% |\DeclareSection|\marg{level}\marg{type}\oarg{indent}\marg{prefix}\marg{beforeskip}\\
% | |\marg{afterskip}\marg{style}
% \end{quote}
% \begin{desclist}{}{}[\meta{beforeskip}]
% \item[\meta{level}] a section level number. Zero and negative values
% are interpreted as follows:
% 0 means declaring the |\chapter| or |\part| command depending on a
% class used; a negative value means declaring a caption.
%
% \item[\meta{type}] a section type. For zero level, this
% parameter is ignored. For negative level, it defines a float type
% (i.e., |figure| or |table|). For positive level, it defines
% a counter name. The name of marking command is composed from
% the type as |\|\meta{type}|mark|.
%
% \item[\meta{indent}] indentation of heading from the left margin
% (zero is default). Ignored for negative levels.
%
% \item[\meta{prefix}] a prefix inserted before a section-number tag
% (usually empty). In chapter, part, or caption declaration commands,
% it is inserted right before the tag name, e.g., before the |\@chapapp|,
% |\partname|, |\figurename|, or |\tablename| command.
%
% \item[\meta{beforeskip}] the skip to leave above the heading.
%
% \item[\meta{afterskip}] if positive, then the skip to leave below
% the heading, else negative of skip to leave to right of running
% heading. The negative value is allowed for positive section levels
% only.
%
% \item[\meta{style}] commands to set a style. The last command in
% this argument may be a command such as |\MakeUppercase| that
% takes an argument. The section heading will be supplied as the
% argument to this command. So setting it to, say,
% |\bfseries\MakeUppercase| would produce bold, uppercase headings.
% \end{desclist}
% Sections having nonnegative \meta{level} and positive \meta{afterskip}
% are display sections. They are declared with the |hangindent| style
% and do not obey the |\sectionstyle| command.
%
% \DescribeMacro{\DeclareSection*}
% To declare a display section having dynamic alignment controlled with the
% |\sectionstyle| command, use the star-version of the previous command:
% \begin{quote}
% |\DeclareSection*|\marg{level}\marg{type}\marg{prefix}\marg{beforeskip}\\
% | |\marg{afterskip}\marg{style}
% \end{quote}
% A negative \meta{afterskip} has no meaning in this case.
%
% \DescribeMacro\bff
% To prepare bold section headings,
% you can use the |\bff| command in the \meta{style} parameter.
% It tries to set everything bold. Its definition is the following:
% \begin{quote}
% |\newcommand{\bff}{\normalfont\bfseries\mathversion{bold}}|
% \end{quote}
%
% Examples of section and caption declarations:
% \begin{quote}
% |\DeclareSection{-2}{table}{}{0pt}{10pt}{}|\\
% |\DeclareSection{-1}{figure}{}{10pt}{0pt}{}|\\
% |\DeclareSection*{1}{section}{}%|\\
% | {3.5ex plus 1ex minus .2ex}%|\\
% | {2.3ex plus .2ex}{\Large\bff}|
% \end{quote}
% Here we declare the table caption command with zero skip
% before it and |10pt| skip after it. On contrary, the
% figure caption command produces |10pt| skip before it
% and zero skip after it. The |\section| command is declared with
% dynamic horizontal alignment. It is prepared in the |\Large|
% font with everything bold.
%
% \DescribeMacro\SectionTagSuffix
% The |\SectionTagSuffix|\marg{suffix} command specifies a default suffix
% inserted after a section number tag. For example, the command
% \begin{quote}
% |\SectionTagSuffix{.\quad}|
% \end{quote}
% sets the decimal point after every section number tag.
% Sections of 0th level ignore this suffix. The default tag is |\quad|.
% The command can be used in the preamble only.
%
% \DescribeMacro\RunningSectionSuffix
% The |\RunningSectionSuffix|\marg{suffix} command specifies a suffix
% inserted after a running section title right before the skip after
% section. It can be used in the preamble only.
% The default value is an empty suffix.
%
% \DescribeMacro\norunningsuffix
% To remove the suffix after a running section, put the
% |\norunningsuffix| modifier in the parameter of running section.
%
% \DescribeMacro\CaptionTagSuffix
% The |\CaptionTagSuffix|\marg{suffix} command specifies a default suffix
% inserted after a caption number tag. It can be used in the preamble only.
% The default caption tag is:
% \begin{quote}
% |\CaptionTagSuffix{:\hspace{0.7em plus 0.2em minus 0.1em}}|
% \end{quote}
%
% \section{Declare TOC-Entries}
%
% \DescribeMacro\DeclareTOCEntry
% To declare an entry of table of contents or other lists
% (list of figures or list of tables), use the following command
% (in the preamble only):
% \begin{quote}
% |\DeclareTOCEntry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\
% | |\marg{style}\oarg{next}
% \end{quote}
% \begin{desclist}{}{\hfill}[\meta{prototype}]
% \item[\meta{level}] a section level number.
% For zero and negative level the following commands are created:
% 0 means |\l@chapter| or |\l@part| depending on class used;
% $-1$ means |\l@figure|; $-2$ means |\l@table|. If level
% is greater than 5, the name of toc-entry command is
% generated as |\l@section@|\meta{level-in-roman},
% i.e., the toc-entry of 6th level is |\l@section@vi|.
%
% \item[\meta{action}] commands applied before entry is produced (usually empty).
%
% \item[\meta{prefix}] text inserted before the section number (usually empty).
%
% \item[\meta{prototype}] prototype of number for alignment the toc-entry body.
% The hang indent of this toc-entry will be equal to the width of
% \begin{quote}
% \meta{style}|{|\meta{prefix}\meta{prototype}\meta{numberline-suffix}|}|
% \end{quote}
%
% \item[\meta{style}] commands to set a style. The last command in this argument
% may be a command such as |\MakeUppercase| that takes an
% argument. The produced entry will be supplied as the
% argument to this command. So setting it to, say,
% |\bfseries\MakeUppercase| would produce bold,
% uppercase entry. This style is applied to the number also and to the
% page number.
% To apply different styles to the text of entry and to its page
% number, use in this parameter the command
% \begin{quote}
% |\applystyle|\marg{text-style}\marg{number-style}
% \end{quote}
%
% \item[\meta{next}] prototype for left margin adjustment for an entry of the
% next level. Default is the hang indent of the current toc-entry.
% \end{desclist}
% A toc-entry is produced within a group.
%
% \DescribeMacro\NumberlineSuffix
% The |\NumberlineSuffix|\marg{calc-suffix}\marg{actual-suffix}
% command allows customize a skip inserted after
% numbers in TOC-like entries. The \meta{calc-suffix} parameter
% is used in calculations of hang indent of toc-entries and the
% \meta{actual-suffix} is really inserted at the end of number.
% The \marg{calc-suffix} is usually wider than the \meta{actual-suffix}.
% The default is |\NumberlineSuffix{\quad}{\enskip}|.
% This command is available in the preamble only.
%
% \DescribeMacro\PnumPrototype
% The |\PnumPrototype|\marg{prototype} command is used for adjustment
% the right margin of the text of toc-entries in toc-lists.
% Default is |\PnumPrototype{99}|.
% If your document has more than 99 pages, use
% |\PnumPrototype{999}|.
% This command is available in the preamble only.
%
% \DescribeMacro\TOCMarginDrift
% The |\TOCMarginDrift|\marg{increment} command specifies a value of
% right-margin drift in TOCs. The increment is applied after the |\@plus|
% token in definition of right margin. Empty argument means no drift.
% Examples:
% \begin{quote}
% |\TOCMarginDrift{2em}|\\
% |\TOCMarginDrift{1fil}|
% \end{quote}
% The command can be use anywhere in the document.
%
% \DescribeMacro\runinsectionskip
% This command is useful in the \meta{action} parameter of the
% toc-entry declaration to produce the skip before a toc-entry
% equal to the skip before run-in sections.
%
% The following example shows how toc-entries are declared in books:
% \begin{quote}
% |\DeclareTOCEntry{-2}{}{}{9.9}{}% table|\\
% |\DeclareTOCEntry{-1}{}{}{9.9}{}% figure|\\
% |\DeclareTOCEntry{0}{\runinsectionskip\def\@dotsep{1000}%|\\
% | \aftergroup\penalty\aftergroup\@highpenalty}{}{9}{\bff}% chapter|\\
% |\DeclareTOCEntry{1}{}{}{9.9}{}[9.9]% section|\\
% |\DeclareTOCEntry{2}{}{}{9.9.9}{}[9.9.9]% subsection|\\
% |\DeclareTOCEntry{3}{}{}{}{}[\qquad]% subsubsection|
% \end{quote}
% The number prototype for figures and tables is `9.9' here.
% The |\l@chapter| entry applies the run-in section skip before it and
% redefines the |\@dotsep| command to remove dot leaders.
% Using the |\aftergroup| command, it inserts the |\@highpenalty|
% after this toc-entry to avoid a page break at this point.
% The left margin adjustment after section and nested toc-entries
% is calculated here using the prototype of widest section number.
% This produces the following nesting:
% \begin{flushleft}
% {\bf 1\quad Chapter}\\
% \jhbox{{\bf 1\quad}}{}1.1\quad Section\\
% \jhbox{{\bf 1\quad}1.1}{}1.1.1\quad Subsection\\
% \jhbox{{\bf 1\quad}1.11.1.1}{}Subsubsection
% \end{flushleft}
%
% \section{Declare New Float Types}
%
% The standard \LaTeX\ classes provide two types of floating environments:
% figures and tables. If you have prepared a new floating
% environment in some way (i.e., using the |float| package by Anselm
% Lingnau), you can declare a caption for the new float
% with the commands described in previous sections.
%
% \DescribeMacro\RegisterFloatType
% In books, when a new chapter starts, the |\chapter| command
% puts a special vertical skip to the contents of list of figures and
% of list of tables. This behaviour can be easy extended to new float types
% if you register them within this package. The registration is
% provided with the following command:
% \begin{quote}
% |\RegisterFloatType|\marg{float-type}
% \end{quote}
% After the float type is registered, you can declare a toc-entry
% for it using the negation of its registration number in the
% \meta{level} parameter. The
% first new float type is registered third (after the figure and table).
% So, you must
% use \meta{level} = $-3$ for it, $-4$ for the next registered float
% type and so on.
%
% In the following example, we define a new float type, |program|,
% and prepare the caption and toc-entry commands for it.
% The caption of programs
% is supposed to be used at the beginning of program.
% So, we make it in the same manner as the table caption.
% \begin{quote}
% |\documentclass{book}|\\
% |\usepackage{float,nccsect}|\\
% |\newfloat{program}{tp}{lop}[chapter]|\\
% |\floatname{program}{Program}|\\
% |\RegisterFloatType{program}|\\
% |\DeclareSection{-3}{program}{}{0pt}{10pt}{}|\\
% |\DeclareTOCEntry{-3}{}{}{9.9}{}|
% \end{quote}
%
% To produce a list of programs, you can then use the |\listof|
% command from the |float| package as follows:
% \begin{quote}
% |\listof{program}{List of Programs}|
% \end{quote}
% \StopEventually{}
%
% \section{Epigraphs and Related Staff}
%
% \DescribeMacro\beforechapter
% \DescribeMacro\epigraph
% To put epigraph before any chapter, you can use two methods:
% low-level |\beforechapter|\marg{anything} hook or
% user-level command
% \begin{quote}
% |\epigraph|\oarg{width}\marg{text}\marg{author}
% \end{quote}
% The last one applies a special formatting to epigraph and
% calls the first one. The |\beforechapter| hook inserts its
% contents at the beginning of page just before a chapter
% instead of spacing specified in the chapter declaration.
%
% \DescribeMacro\epigraphparameters
% Formatting of user-level epigraph is provided with the
% following command
% \begin{quote}
% |\epigraphparameters|\marg{style}\marg{width}\marg{height}\marg{author-style}\\
% | |\marg{after-action}
% \end{quote}
% Here \meta{style} is a style applied to the whole epigraph
% (font selection, spacing and positioning, etc.), the \meta{width}
% is the default epigraph width (can be changed in an epigraph),
% the \meta{author-style} is the style applied to the author's
% signature, and the \meta{after-action} is an action applied after
% the epigraph (usually a vertical spacing). All styles and actions
% are applied in the vertical mode. An \meta{author-style} can finish with
% one-argument macro getting the author of epigraph and formatting it.
%
% \DescribeMacro\epigraphwidth
% In |\epigraphparameters|, you can use the |\epigraphwidth| macro
% which contains a selected epigraph width.
%
% The default style is:
% \begin{quote}
% |\epigraphparameters{\StartFromHeaderArea\small\raggedleft}|\\
% | {.45\linewidth}{5\baselineskip}|\\
% | {\raggedleft\itshape}{\vspace{2ex}}|
% \end{quote}
%
% \DescribeMacro\StartFromTextArea
% The |\vspace*| command applied at the beginning of page has one serious
% disadvantage: it skips more space that specified in its parameter.
% To remove this disadvantage, we introduce the |\StartFromTextArea|
% command that
% inserts a zero-height strut and allows use the |\vspace| command after it
% without troubles.
%
% \DescribeMacro\StartFromHeaderArea
% You can also extend the text area on the header if apply the
% |\StartFromHeaderArea| command at the beginning of page.
% Such action is useful in epigraphs: the first chapter's page usually
% has an empty header and positioning an epigraph from the header
% is the good practice.{\sloppy\par}
%
% \section{Declare Part}
%
% The |\part| command in book-like classes is the only sectioning command
% that cannot be prepared with the |\DeclareSection| command. So, we add
% special declarations to provide parts in books with features of other
% sectioning commands.
%
% \DescribeMacro\DeclarePart
% To redefine the |\part| in books, use the following declaration:
% \begin{quote}
% |\DeclarePart|\marg{before}\marg{after}\marg{prefix}\marg{style}
% \end{quote}
% \begin{desclist}{}{}[\meta{before}]
% \item[\meta{before}] an action applied before a part at the beginning of
% page. It usually specifies a vertical skip |\vfil| and a
% paragraph style to be applied to the part number tag and title.
% \item[\meta{after}] an action applied after the part. It usually contains
% |\vfil| and page finishing commands.
% \item[\meta{prefix}] a prefix inserted before a part tag. It contains
% style commands to be applied to the tag and the |\vspace| command
% specifying a distance between the part tag and title.
% The |\partname| command goes right after the prefix.
% \item[\meta{style}] a style to be applied to the part title. It can end
% with |\MakeUppercase|.
% \end{desclist}
%
% The default declaration of the |\part| is the following:
% \begin{quote}
% |\DeclarePart{\StartFromTextArea\vfil\centering}%|\\
% | {\vfil\newpage \if@twoside\if@openright|\\
% | \mbox{}\thispagestyle{empty}\newpage\fi\fi}%|\\
% | {\vspace{4ex}\huge\bff}{\Huge\bff}|
% \end{quote}
% The |\StartFromTextArea| command prevents ignoring a vertical space
% at the beginning of page. All paragraphs of part title are centered
% horizontally using the |\centering| declaration, and the title
% is centered vertically using |\vfil| commands
% before and after it. A page after the part is made empty in two-side
% mode if it is even. The space after the part tag is set to |4ex|.
%
% In Russian typesetting tradition, the part can be prepared in the
% same manner as a chapter, i.e.\ a text going after a part is prepared
% on the same page with the part title. It is easy to re-declare
% the part in such style.
% Let us start a part from the header and delimit it from the text
% with a decorative line. The following declaration does this:
% \begin{quote}
% |\DeclarePart{\StartFromHeaderArea\centering}|\\
% | {\vspace{2mm}\noindent\hrulefill\par|\\
% | \addvspace{5mm}}|\\
% | {\vspace{.5em}\LARGE\bff}{\Huge\bff}|
% \end{quote}
% But when a chapter goes right after a part, we need to place the part and
% chapter titles together
% on the same page. This can be applied using the |\beforechapter| hook:
% \begin{quote}
% |\beforechapter{\part|\marg{part title}|}|\\
% |\chapter|\marg{chapter title}
% \end{quote}
% Modifiers stored in the parameter of |\beforechapter| hook will act on
% the |\part| command. Modifiers outside of |\beforechapter| will act on
% the |\chapter| command.
%
% \DescribeMacro\DeclareTOCPart
% To produce a toc-entry command for a part, the following declaration is
% specified for book-like classes:
% \begin{quote}
% |\DeclareTOCPart|\marg{action}\oarg{afterskip}\marg{prefix}\marg{prototype}\marg{style}
% \end{quote}%
% \begin{desclist}{}{}[\meta{afterskip}]
% \item[\meta{action}] an action applied before the part toc-entry. It usually
% a skip before part. It is recommended to prepare it with |\NCC@secskip|
% command.
% \item[\meta{afterskip}] a skip after this entry. If it is omitted,
% the default |\NCC@runskip| value is applied after this entry.
% \item[\meta{prefix}] a prefix inserted before a part tag (usually empty).
% \item[\meta{prototype}] a prototype of part tag used for calculation the
% hang indent in this entry.
% \item[\meta{style}] a style applied to the whole text of entry and to
% the page number. The |\MakeUppercase| is allowed to finish this
% parameter. The |\applystyle| command can be used inside it to
% apply different styles to the toc-entry and the page number.
% \end{desclist}
%
% The default declaration of the part toc-entry is the following:
% \begin{quote}
% |\DeclareTOCPart{\NCC@secskip{4ex \@plus .2ex}%|\\
% | \def\@dotsep{1000}}%|\\
% | {}{\partname\ II}{\large\bff}|\\
% \end{quote}
%
% \section{The Implementation}
%
% The \textbf{afterpackage} package is used to add compatibility
% commands.
% \begin{macrocode}
%<*package>
\RequirePackage{afterpackage}
% \end{macrocode}
%
% \begin{macro}{\NCC@secskip}
% \begin{macro}{\NCC@runskip}
% The package shares the following commands with the
% |nccthm| package:
% \begin{quote}
% |\NCC@secskip|\marg{skip} adds the \meta{skip} before a section,\\
% |\NCC@runskip| is a skip inserted before run-in sections.
% \end{quote}
% We protect the definitions of these commands with testing
% the |nccthm| package to be already loaded.
% \begin{macrocode}
\@ifpackageloaded{nccthm}{}{%
\def\NCC@secskip#1{%
\if@noskipsec \leavevmode \fi \par
\if@nobreak \everypar{}\else
\addpenalty\@secpenalty
\addvspace{#1}%
\fi
}
\def\NCC@runskip{2.75ex \@plus 1ex \@minus .2ex}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\runinsectionskip}
% This command is useful in toc-entries:
% \begin{macrocode}
\newcommand{\runinsectionskip}{\NCC@secskip{\NCC@runskip}}
% \end{macrocode}
% \end{macro}
%
% \subsection{The Kernel}
%
% We start with declaring the section controls (modifiers):
% \begin{desclist}{\tt}{\hfill}[NCC@secstartag]\raggedright
% \item[NCC@nosectag] is true if |\noheadingtag| is applied;
% \item[NCC@secstartag] is true if |\headingtag*|\marg{tag} is applied;
% \item[\cs{NCC@sectag}] saves a value of the |\headingtag| parameter;
% \item[NCC@nosecmark] is true if |\norunninghead| is applied;
% \item[\cs{NCC@secmark}\rm\marg{mark-command}] executes the \meta{mark-command}
% with the parameter of |\runninghead| command;
% \item[NCC@noaux] is true if |\skipwritingtoaux| is applied.
% \end{desclist}
% \begin{macrocode}
\newif\ifNCC@nosectag
\newif\ifNCC@secstartag
\newif\ifNCC@nosecmark
\newif\ifNCC@noaux
% \end{macrocode}
%
% \begin{macro}{\NCC@global}
% We reset all controls globally, but in the |\beforechapter|
% hook we need to reset them locally. So, we reset all controls
% using the |\NCC@global| modifier which value is |\global| by default.
% \begin{macrocode}
\let\NCC@global\global
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@sec@reset@controls}
% This command resets all controls to default values.
% It must be applied at the end of every section command.
% \begin{macrocode}
\def\NCC@sec@reset@controls{%
\NCC@global\NCC@nosectagfalse
\NCC@global\NCC@secstartagfalse
\NCC@global\let\NCC@sectag\relax
\NCC@global\NCC@nosecmarkfalse
\NCC@global\let\NCC@secmark\relax
\NCC@global\NCC@noauxfalse
}
\NCC@sec@reset@controls
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\norunninghead}
% \begin{macro}{\runninghead}
% \begin{macro}{\noheadingtag}
% \begin{macro}{\headingtag}
% \begin{macro}{\headingtag*}
% \begin{macro}{\skipwritingtoaux}
% User interface to section controls:
% \begin{macrocode}
\newcommand{\norunninghead}{\NCC@global\NCC@nosecmarktrue}
\newcommand*{\runninghead}[1]{\NCC@global\def\NCC@secmark##1{##1{#1}}}
\newcommand{\noheadingtag}{\NCC@global\NCC@nosectagtrue}
\newcommand{\headingtag}{%
\@ifstar{\NCC@global\NCC@secstartagtrue\NCC@setsectag}{\NCC@setsectag}%
}
\def\NCC@setsectag#1{\NCC@global\def\NCC@sectag{#1}}
\newcommand{\skipwritingtoaux}{\NCC@global\NCC@noauxtrue}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\NCC@makesection}
% The |\NCC@makesection|\marg{type}\marg{level}\marg{toc-entry}\marg{toc-action}
% produces a section or caption. It analyzes the modifiers and customizes
% sections or captions. The \meta{toc-action} parameter contains an
% attendant action that must be applied at the end of macro.
% It writes a toc-entry to aux-file.
%
% The command uses the following hooks that must be prepared
% before its call:
% \begin{desclist}{}{}[\cs{NCC@make}\marg{action}]
% \item[\cs{NCC@makesectag}\marg{value}] produces a tag in |\@svsec|
% using the given value;
%
% \item[\cs{NCC@make}\marg{action}] makes a section or caption heading
% and applies the \meta{action} after heading. Before the call
% of this command, the |\@svsec| macro is prepared (it contains a
% prepared tag).
% \end{desclist}
% We start from the case when the |\headingtag*|\marg{tag} modifier was
% applied and the section tag was saved in the |\NCC@sectag| macro.
% We apply the |\NCC@make| procedure with the given section tag.
% Attendant actions are ignored for this case.
% \begin{macrocode}
\def\NCC@makesection#1#2#3#4{%
\ifNCC@secstartag
\let\@svsec\NCC@sectag
\NCC@make{}%
\else
% \end{macrocode}
% Prepare a tag creation command in the |\the|\meta{type} macro.
% We can do some temporary changes here that will be restored
% at the end of macro. The restore hook is prepared in the
% |\NCC@restsec| command.
% \begin{macrocode}
\ifx\NCC@sectag\relax
% \end{macrocode}
% The |\noheadingtag| case: we temporary set the |secnumdepth|
% counter to very low negative value. This prevents numbering
% this section:
% \begin{macrocode}
\ifNCC@nosectag
\edef\NCC@restsec{%
\noexpand\c@secnumdepth \the\c@secnumdepth\relax
}%
\c@secnumdepth -1000
% \end{macrocode}
% The ordinary case: No restore actions is necessary here.
% \begin{macrocode}
\else
\let\NCC@restsec\relax
\ifnum#2>\c@secnumdepth \else\refstepcounter{#1}\fi
\fi
% \end{macrocode}
% The |\headingtag|\marg{tag} case: we temporary let the
% |\the|\meta{type} macro to be equal to the |\NCC@sectag|
% command produced by the |\headingtag|,
% save the original value in the |\NCC@thesec| command,
% and prepare the |\NCC@restsec| macro.
% \begin{macrocode}
\else
\expandafter\let\expandafter\NCC@thesec\csname the#1\endcsname
\def\NCC@restsec{%
\expandafter\let\csname the#1\endcsname\NCC@thesec
}%
\expandafter\let\csname the#1\endcsname\NCC@sectag
\protected@edef\@currentlabel{\NCC@sectag}%
\fi
% \end{macrocode}
%
% Prepare section tag in the |\@svsec| command:
% \begin{macrocode}
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\else
\protected@edef\@svsec{%
\protect\NCC@makesectag{\csname the#1\endcsname}%
}%
\fi
% \end{macrocode}
%
% We cannot do the marking right now because the producing of section
% can be suspended to the beginning of the nearest paragraph
% (in run-in sections). So, we need to prepare a mark action
% in a command that will save its state as long as necessary.
% This command is |\NCC@makemark|.
% \begin{macrocode}
\let\NCC@makemark\@empty
\@ifundefined{#1mark}{}{%
\ifx\NCC@secmark\relax
% \end{macrocode}
% Ordinary case: prepare the section mark with the
% \meta{toc-entry} parameter.
% \begin{macrocode}
\ifNCC@nosecmark \else
\def\NCC@makemark{\csname #1mark\endcsname{#3}}%
\fi
% \end{macrocode}
% The |\runninghead|\marg{heading} case:
% pass the mark command in the parameter of |\NCC@secmark|.
% We need to save the |\NCC@secmark| value in some command
% and pass this command within |\NCC@makemark| because
% the |\NCC@secmark| could be removed before the use.
% \begin{macrocode}
\else
\let\NCC@savesecmark\NCC@secmark
\def\NCC@makemark{%
\NCC@savesecmark{\csname #1mark\endcsname}%
\let\NCC@savesecmark\relax
}%
\fi
}%
% \end{macrocode}
%
% Make the section. We must apply the restore action at
% the end action of |\NCC@make| command by the same reason that
% the section making may be suspended:
% \begin{macrocode}
\ifNCC@noaux
\NCC@make{\NCC@makemark \NCC@restsec}%
\else
\NCC@make{\NCC@makemark #4\NCC@restsec}%
\fi
% \end{macrocode}
%
% Reset modifiers:
% \begin{macrocode}
\fi
\NCC@sec@reset@controls
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Section Making Commands}
%
% \begin{macro}{\indentaftersection}
% \begin{macro}{\noindentaftersection}
% Introduce macros controlling indentation after display sections:
% \begin{macrocode}
\newcommand{\indentaftersection}{\@afterindenttrue}
\newcommand{\noindentaftersection}{\@afterindentfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\SectionTagSuffix}
% The |\SectionTagSuffix|\marg{suffix} sets a default suffix after
% a section tag.
% \begin{macrocode}
\newcommand*{\SectionTagSuffix}[1]{\def\NCC@asecnum{#1}}
\@onlypreamble\SectionTagSuffix
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sectiontagsuffix}
% |\sectiontagsuffix|\oarg{type}\marg{suffix} changes a suffix after section
% tag that will be used for sections of the given
% \meta{type}. If \meta{type} is omitted, the specified suffix will be used
% in text flow for all sections having no special suffix.
% \begin{macrocode}
\newcommand*\sectiontagsuffix[2][]{%
\expandafter\def\csname NCC@asecnum@#1\endcsname{\def\NCC@asecnum{#2}}%
}
\let\NCC@asecnum@\@empty
\def\NCC@setsectionsuffix#1{%
\edef\@tempa{NCC@asecnum@\NCC@secname{#1}}%
\@ifundefined{\@tempa}{%
\let\NCC@asecnumset\NCC@asecnum@
}{%
\expandafter\let\expandafter\NCC@asecnumset\csname\@tempa\endcsname
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\RunningSectionSuffix}
% The |\RunningSectionSuffix|\marg{suffix} sets a suffix after a title
% of a running section:
% \begin{macrocode}
\newcommand*{\RunningSectionSuffix}[1]{\def\NCC@asectitle{\unskip#1}}
\@onlypreamble\RunningSectionSuffix
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@preparesectag}
% The |\NCC@preparesectag|\marg{style}\marg{before} hook prepares the
% |\NCC@makesectag| command:
% \begin{macrocode}
\def\NCC@preparesectag#1#2{\def\NCC@makesectag##1{#1#2##1\NCC@asecnum}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@secname}
% The |\NCC@secname|\marg{level} command generates section name
% (|main|, |section|, |subsection|, \ldots,
% or |section@vi|, |section@vii|, \ldots\ for new section levels).
% This name is used as the second parameter of the |\addcontentsline|
% command, in the declarations of toc-entries, and in the style
% selection command.
% \begin{macrocode}
\def\NCC@secname#1{%
\ifcase#1main\or section\or subsection\or subsubsection\or
paragraph\or subparagraph\else section@\romannumeral#1\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@startsection}
% The |\NCC@startsection| command
% has the same syntax as its non-NCC prototype:
% \begin{quote}
% |\NCC@startsection|\marg{type}\marg{level}\marg{indent}\marg{beforeskip}\\
% | |\marg{afterskip}\marg{style}
% \end{quote}
% but works in a bit different way: it ignores the sign of
% \meta{beforeskip}. In the original version the testing
% was applied to set an appropriate |afterindent| mode.
% But we change this mode using |\indentaftersection| and
% |\noindentaftersection| macros.
% \begin{macrocode}
\def\NCC@startsection#1#2#3#4#5#6{%
\@tempskipa #4\relax
\ifdim \@tempskipa <\z@ \@temskipa -\@tempskipa \fi
\NCC@secskip \@tempskipa
\secdef{\NCC@sect{#1}{#2}{#3}{#4}{#5}{#6}}{\NCC@ssect{#3}{#4}{#5}{#6}}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makesec}
% The interface of |\NCC@ssect| and |\NCC@sect| commands is similar to their
% \LaTeX's prototypes. They are based on the following
% command:
% \begin{quote}
% |\NCC@makesec|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
% \end{quote}
% In fact, there are two versions of this command:
% the traditional version, |\NCC@makesect|, and the
% version with dynamic control of section style,\linebreak |\NCC@makesecx|.
% One of them should be selected before applying the |\NCC@ssect| and |\NCC@sect|
% commands.
% \end{macro}
%
% \begin{macro}{\NCC@ssect}
% The starred form of section:
% \begin{quote}
% |\NCC@ssect|\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{heading}
% \end{quote}
% \begin{macrocode}
\def\NCC@ssect#1#2#3#4#5{%
\let\@svsec\@empty
\NCC@makesec{#1}{#4}{#5}{#3}{}%
\NCC@sec@reset@controls
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@sect}
% The base form of section:
% \begin{quote}
% |\NCC@sect|\marg{type}\marg{level}\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\\
% | |\oarg{toc-entry}\marg{heading}
% \end{quote}
% \begin{macrocode}
\def\NCC@sect#1#2#3#4#5#6[#7]#8{%
\def\NCC@make{\NCC@makesec{#3}{#6}{#8}{#5}}%
\NCC@makesection{#1}{#2}{#7}{%
\addcontentsline{toc}{\NCC@secname{#2}}{%
\ifnum #2>\c@secnumdepth \else
\numberline{\csname the#1\endcsname}%
\fi
#7%
}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makesect}
% The traditional section making command:
% \begin{quote}
% |\NCC@makesect|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
% \end{quote}
% \begin{macrocode}
\def\NCC@makesect#1#2#3#4#5{%
\@tempskipa #4\relax
\ifdim \@tempskipa>\z@
\begingroup \normalfont
\NCC@asecnumset
% \end{macrocode}
% The |\NCC@secttitle|\marg{style}\marg{tag}\marg{title} hook prepares
% traditional display section:
% \begin{macrocode}
\NCC@secttitle{#2}{\NCC@hangfrom{\hskip #1\relax\@svsec}}%
{\interlinepenalty \@M\ignorespaces #3\@@par}
\endgroup
#5%
\else
% \end{macrocode}
% The |\NCC@secptitle|\marg{style}\marg{tag}\marg{title} hook prepares
% running section. The |\norunningsuffix| modifier applied in the
% parameter of running section removes a suffix after section title.
% \begin{macrocode}
\def\@svsechd{{\normalfont
\NCC@asecnumset
\def\norunningsuffix{\protect\NCC@nosecsuffix}%
\NCC@secptitle{#2}{\hskip #1\relax{\@svsec}}%
{\ignorespaces #3\NCC@asectitle}#5}}%
\fi
\@xsect{#4}%
}
\def\NCC@secttitle#1#2#3{#1{#2#3}}
\def\NCC@secptitle#1#2#3{#1{#2#3}}
\newcommand*\norunningsuffix{}
\def\NCC@nosecsuffix{\let\NCC@asectitle\@empty}
% \end{macrocode}
% \end{macro}
%
% \subsection{Create Section Styles}
%
% \begin{macro}{\NCC@hangfrom}
% |\NCC@hangfrom|\marg{section tag} works as
% the \LaTeX's |\@hangfrom| command, but its margins can be adjusted
% with the |\adjustsectionmargins| command.
% \begin{macrocode}
\def\NCC@hangfrom{%
\NCC@setsecmargins{\z@skip}{\z@skip}\NCC@hangsecstyle{\z@}{}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@setsecmargins}
% |\NCC@setsecmargins|\marg{left skip}\marg{right skip} sets
% section margins and applies the hook that can be defined by the
% |\adjustsectionmargins| command.
% \begin{macrocode}
\def\NCC@setsecmargins#1#2{%
\leftskip\z@skip \rightskip\z@skip
\parfillskip\@flushglue
\let\\\@normalcr
\NCC@adjsecmargins{#1}{#2}%
\NCC@secmarginshook
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@adjsecmargins}
% |\NCC@adjsecmargins|\marg{left skip}\marg{right skip} adjusts
% section margins. The |\parfillskip| value is also adjusted to
% a difference between stretchabilities of the \meta{left skip}
% and the \meta{right skip}. Using this trick, we can easy specify
% the |centerlast| style just setting the stretchability of the
% \meta{right skip} as a negation of the \meta{left skip} stretchability.
% To extract a stretchability from a skip, we simply add it multiplied
% by |-1| (while multiplication the stretchability is removed!).
% \begin{macrocode}
\def\NCC@adjsecmargins#1#2{%
\setlength\@tempskipa{#1}\advance\leftskip\@tempskipa
\setlength\@tempskipb{#2}\advance\rightskip\@tempskipb
\advance\@tempskipa -1\@tempskipa \advance\@tempskipb -1\@tempskipb
\advance\@tempskipa -\@tempskipb \advance\parfillskip\@tempskipa
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@hangsecstyle}
% |\NCC@hangsecstyle|\marg{min tag width}\marg{pos}\marg{section tag}
% starts a hang paragraph and prints its tag. The \meta{min tag width}
% specifies a minimum width of hang indent and \meta{pos} specifies
% an alignment of \meta{section tag} (|l|, |c|, |r|) if its width
% is less than the minimum width.
% \begin{macrocode}
\def\NCC@hangsecstyle#1#2#3{%
\setlength\@tempdima{#1}%
\setbox\@tempboxa\hbox{#3}%
\ifdim \wd\@tempboxa > \@tempdima
\hangindent\wd\@tempboxa \noindent \box\@tempboxa
\else
\hangindent\@tempdima
\noindent \makebox[\@tempdima][#2]{\unhbox\@tempboxa}%
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\adjustsectionmargins}
% |\adjustsectionmargins|\marg{left skip}\marg{right skip}
% defines the |\NCC@secmarginshook| macro to be applied after
% margins are set. To be sure this hook will be applied only once,
% we release it in the |\NCC@sec@reset@controls| hook.
% \begin{macrocode}
\newcommand*\adjustsectionmargins[2]{%
\NCC@global\def\NCC@secmarginshook{\NCC@adjsecmargins{#1}{#2}}
}
\g@addto@macro\NCC@sec@reset@controls{%
\NCC@global\let\NCC@secmarginshook\@empty
}
\let\NCC@secmarginshook\@empty
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@sec}
% A style of sections having dynamic control is defined by the
% |\NCC@sec|\marg{tag} hook. This hook is applied inside a group
% preparing a heading. All section style commands redefine this hook.
% \end{macro}
%
% \begin{macro}{\newplainsectionstyle}
% |\newplainsectionstyle|\marg{name}\marg{indent}\oarg{pos}\marg{left skip}\marg{right skip}
% \begin{macrocode}
\newcommand*\newplainsectionstyle[2]{%
\@ifnextchar[{\NCC@newplainsec{#1}{#2}}{\NCC@newplainsec{#1}{#2}[l]}%
}
\def\NCC@newplainsec#1#2[#3]#4#5{%
\def\@tempa{#3}\def\@tempb{c}%
\ifx\@tempa\@tempb
\expandafter\newcommand\csname NCC@sec@#1\endcsname
{\def\NCC@sec{\NCC@setsecmargins{#4}{#5}%
\let\\\@centercr \advance\parfillskip -\@flushglue
\setlength\parindent{#2}}}%
\else
\def\@tempb{r}%
\ifx\@tempa\@tempb
\expandafter\newcommand\csname NCC@sec@#1\endcsname
{\def\NCC@sec{\NCC@setsecmargins{#4}{#5}%
\let\\\@centercr \advance\parfillskip -\@flushglue
\advance\parfillskip -\@flushglue
\setlength\parindent{#2}}}%
\else
\expandafter\newcommand\csname NCC@sec@#1\endcsname
{\def\NCC@sec{\NCC@setsecmargins{#4}{#5}\setlength\parindent{#2}}}%
\fi
\fi
}
\@onlypreamble\newplainsectionstyle
\@onlypreamble\NCC@newplainsec
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newhangsectionstyle}
% |\newhangsectionstyle|\marg{name}\marg{min tag width}\oarg{pos}\marg{left skip}\marg{right skip}
% \begin{macrocode}
\newcommand*\newhangsectionstyle[2]{%
\@ifnextchar[{\NCC@newhangsec{#1}{#2}}{\NCC@newhangsec{#1}{#2}[l]}%
}
\def\NCC@newhangsec#1#2[#3]#4#5{%
\expandafter\newcommand\csname NCC@sec@#1\endcsname
{\def\NCC@sec{\NCC@setsecmargins{#4}{#5}\NCC@hangsecstyle{#2}{#3}}}%
}
\@onlypreamble\newhangsectionstyle
\@onlypreamble\NCC@newhangsec
% \end{macrocode}
% \end{macro}
%
% Specify predefined section styles. The |\@flushglue| is equal to |0pt plus 1fil|.
% \begin{macrocode}
\newhangsectionstyle{hangindent}{\z@}{\z@skip}{\z@skip}
\newhangsectionstyle{hangindent*}{\z@}{\z@skip}{\@flushglue}
\newhangsectionstyle{hangparindent}{\z@}{\parindent}{\z@skip}
\newhangsectionstyle{hangparindent*}{\z@}{\parindent}{\@flushglue}
\newplainsectionstyle{parindent}{\z@}{\parindent}{\z@skip}
\newplainsectionstyle{parindent*}{\z@}{\parindent}{\@flushglue}
\newplainsectionstyle{center}{\z@}[c]{\@flushglue}{\@flushglue}
\newplainsectionstyle{centerlast}{\z@}[c]{\@flushglue}{-\@flushglue}
% \end{macrocode}
%
% \subsection{Make Sections with Dynamic Control}
%
% \begin{macro}{\sectionstyle}
% The |\sectionstyle|\oarg{type}\marg{style} changes a style
% for display sections of the given \meta{type}.
% \begin{macrocode}
\newcommand*{\sectionstyle}[2][]{%
\@ifundefined{NCC@sec@#2}{%
\PackageError{nccsect}{Unknown section style `#2'}{}%
}{%
\expandafter\def\csname NCC@secstyle@#1\endcsname{%
\csname NCC@sec@#2\endcsname
}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@setsectionstyle}
% The |\NCC@setsectionstyle|\marg{level} set a style for the
% given section level. If a style for the given level is
% undefined, the default style is selected.
% \begin{macrocode}
\def\NCC@setsectionstyle#1{%
\edef\@tempa{NCC@secstyle@\NCC@secname{#1}}%
\@ifundefined{\@tempa}{\NCC@secstyle@}{\csname\@tempa\endcsname}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makesecx}
% The dynamic section making command:
% \begin{quote}
% |\NCC@makesecx|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
% \end{quote}
% It prepares only display sections and ignores the \meta{indent} parameter.
% \begin{macrocode}
\def\NCC@makesecx#1#2#3#4#5{%
\begingroup\normalfont
\NCC@asecnumset
% \end{macrocode}
% The |\NCC@secxtitle|\marg{style}\marg{tag}\marg{title} hook prepares
% display section with dynamic control. The |\NCC@sec| macro is protected
% to prevent its expansion by |\MakeUppercase|.
% \begin{macrocode}
\NCC@secxtitle{#2}{\protect\NCC@sec{\@svsec}}
{\interlinepenalty \@M\ignorespaces #3\@@par}%
\endgroup #5%
\par \nobreak \vskip #4\relax \@afterheading \ignorespaces
}
\def\NCC@secxtitle#1#2#3{#1{#2#3}}
% \end{macrocode}
% \end{macro}
%
% \subsection{Make the Main Section}
%
% \begin{macro}{\partmark}
% Define the |\partmark| if it is undefined yet.
% \begin{macrocode}
\providecommand*\partmark[1]{\markboth{}{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@startmainsec}
% The main section is a section of zero level.
% It is prepared with the following command:
% \begin{quote}
% |\NCC@startmainsec|\marg{alignment}\marg{prefix}\marg{beforeskip}\\
% | |\marg{afterskip}\marg{style}
% \end{quote}
% It starts either a new chapter or a new part depending on the class
% loaded. To decide what version should be prepared, we test the
% |\chapter| command on existence.
% \begin{macrocode}
\@ifundefined{chapter}{%
% \end{macrocode}
%
% The case of an article-like class. Zero-level section is the |\part|.
% \begin{macrocode}
\def\NCC@startmainsec#1#2#3#4#5{%
\NCC@preparesectag{\leavevmode#2}{\partname\nobreakspace}%
\NCC@secskip{#3}%
\secdef{\NCC@part{#1}{#4}{#5}}{\NCC@spart{#1}{#4}{#5}}%
}
% \end{macrocode}
%
% \begin{macro}{\NCC@spart}
% Prepare the starred version of part:
% \begin{quote}
% |\NCC@spart|\marg{alignment}\marg{afterskip}\marg{style}\marg{heading}
% \end{quote}
% \begin{macrocode}
\def\NCC@spart#1#2#3#4{%
\let\@svsec\@empty
\NCC@makepart{#1}{#3}{#4}{#2}{}%
\NCC@sec@reset@controls
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@part}
% Prepare the non-starred version of part:
% \begin{quote}
% |\NCC@part|\marg{alignment}\marg{afterskip}\marg{style}\oarg{toc-entry}\marg{heading}
% \end{quote}
% \begin{macrocode}
\def\NCC@part#1#2#3[#4]#5{%
\def\NCC@make{\NCC@makepart{#1}{#3}{#5}{#2}}%
\NCC@makesection{part}{\z@}{#4}{%
\addcontentsline{toc}{part}{%
\ifnum \c@secnumdepth>\m@ne \numberline{\thepart}\fi
#4%
}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makepart}
% This command makes a part.
% \begin{quote}
% |\NCC@makepart|\marg{alignment}\marg{style}\marg{heading}\marg{afterskip}\marg{action}
% \end{quote}
% The |\@svsec| is either |\@empty| or contains a part tag.
% \begin{macrocode}
\def\NCC@makepart#1#2#3#4#5{%
\begingroup \normalfont
\NCC@asecnumset
\NCC@makeparttitle{#1}{#2}{#3}%
\endgroup
#5%
\par\nobreak \vskip #4\relax \@afterheading \ignorespaces
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makeparttitle}
% This command makes a part title itself. The |\NCC@secmain| hook contains
% the dynamic alignment style or nothing.
% \begin{quote}
% |\NCC@makeparttitle|\marg{alignment}\marg{style}\marg{heading}
% \end{quote}
% \begin{macrocode}
\def\NCC@makeparttitle#1#2#3{%
\ifx\@svsec\@empty \else
\NCC@secmain#1{\let\NCC@asecnum\@empty\@svsec\@@par}\nobreak
\fi
\interlinepenalty \@M \NCC@secmain#1{#2{#3\@@par}}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@partsection}
% Define the |\NCC@partsection| to be equal to the |\NCC@mainsection| command
% which will be specified later when a main section will be declared.
% \begin{macrocode}
\def\NCC@partsection{\NCC@mainsection}
}{
% \end{macrocode}
% \end{macro}
%
% The case of a book-like class. Zero-level section is the |\chapter|.
% \begin{macrocode}
\def\NCC@startmainsec#1#2#3#4#5{%
\NCC@startchap
\NCC@preparesectag{\leavevmode#2}{\@chapapp\nobreakspace}%
\secdef{\NCC@chapter{#1}{#3}{#4}{#5}}{\NCC@schapter{#1}{#3}{#4}{#5}}%
}
% \end{macrocode}
%
% \begin{macro}{\NCC@startchap}
% The start chapter hook:
% \begin{macrocode}
\def\NCC@startchap{%
\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}\global\@topnum\z@
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@schapter}
% Prepare the starred version of chapter:
% \begin{quote}
% |\NCC@schapter|\marg{alignment}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{heading}
% \end{quote}
% \begin{macrocode}
\def\NCC@schapter#1#2#3#4#5{%
\let\@svsec\@empty
\NCC@makechapter{#1}{#2}{#4}{#5}{#3}{}%
\NCC@sec@reset@controls
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@chapter}
% Prepare the non-starred version of chapter:
% \begin{quote}
% |\NCC@chapter|\marg{alignment}\marg{beforeskip}\marg{afterskip}\marg{style}\\
% | |\oarg{toc-entry}\marg{heading}
% \end{quote}
% It uses the |\NCC@infloats|\marg{action} hook that applies the specified
% action for all registered float types.
% \begin{macrocode}
\def\NCC@chapter#1#2#3#4[#5]#6{%
\@ifundefined{if@mainmatter}{}{\if@mainmatter\else\noheadingtag\fi}%
\def\NCC@make{\NCC@makechapter{#1}{#2}{#4}{#6}{#3}}%
\NCC@makesection{chapter}{\z@}{#5}{%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}{%
\ifnum \c@secnumdepth>\m@ne
\numberline{\NCC@thetocchapter}\fi
#5%
}%
\NCC@infloats{\addtocontents{\@nameuse{ext@\@captype}}%
{\protect\runinsectionskip}}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\beforechapter}
% The |\beforechapter|\marg{something} hook is applied to the nearest
% chapter. An empty value of its parameter means no hook.
% \begin{macrocode}
\newcommand\beforechapter[1]{\gdef\NCC@beforechapter{#1}}
\beforechapter{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@thetocchapter}
% The following hook allows redefine the appearance of chapter name
% in the TOC:
% \begin{macrocode}
\def\NCC@thetocchapter{\thechapter}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makechapter}
% This command makes a chapter:
% \begin{quote}
% |\NCC@makechapter|\marg{alignment}\marg{beforeskip}\marg{style}\marg{heading}\\
% | |\marg{afterskip}\marg{action}
% \end{quote}
% The |\@svsec| is either |\@empty| or contains a chapter tag.
% \begin{macrocode}
\def\NCC@makechapter#1#2#3#4#5#6{%
\if@twocolumn
\@topnewpage[\NCC@makechaphead{#1}{#2}{#3}{#4}{#5}]%
\else
\NCC@makechaphead{#1}{#2}{#3}{#4}{#5}%
\fi
\NCC@makechapfinal{#6}%
\@afterheading
\ignorespaces
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makechapfinal}
% \begin{macro}{\NCC@makechapfinalgobble}
% The |\NCC@makechapfinal| hook applies a final action which can contain the
% |\chaptermark| command. Its default value is to put the parameter as is.
% If you let this command to be equal to the |\NCC@makechapfinalgobble|, the
% chapter mark will contain no chapter name.
% \begin{macrocode}
\let\NCC@makechapfinal\@firstofone
\def\NCC@makechapfinalgobble#1{%
\let\NCC@makechapmark\NCC@makemark
\def\NCC@makemark{%
\let\NCC@temp\@chapapp
\let\@chapapp\@gobble
\NCC@makechapmark
\let\@chapapp\NCC@temp
}%
#1%
}
\@onlypreamble\NCC@makechapfinalgobble
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\NCC@makechaphead}
% This command makes a chapter head:
% \begin{quote}
% |\NCC@makechaphead|\marg{alignment}\marg{beforeskip}\marg{style}\marg{heading}\\
% | |\marg{afterskip}
% \end{quote}
% \begin{macrocode}
\def\NCC@makechaphead#1#2#3#4#5{%
\ifx\NCC@beforechapter\@empty
\StartFromTextArea \vskip #2%
\else
\begingroup
\@twocolumnfalse
\let\NCC@global\@empty
\NCC@sec@reset@controls
\normalfont \NCC@beforechapter \par
\endgroup
\beforechapter{}%
\fi
\begingroup \normalfont
\NCC@asecnumset
\NCC@makechaptitle{#1}{#3}{#4}%
\endgroup
\par\nobreak \vskip #5\relax
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makechaptitle}
% This command makes a chapter title itself:
% \begin{quote}
% |\NCC@makechaptitle|\marg{alignment}\marg{style}\marg{heading}
% \end{quote}
% The |\NCC@secmain| hook contains the dynamic alignment style
% or nothing.
% \begin{macrocode}
\def\NCC@makechaptitle#1#2#3{%
\ifx\@svsec\@empty \else
\NCC@secmain#1{\let\NCC@asecnum\@empty\@svsec\@@par}%
\fi
\interlinepenalty \@M \NCC@secmain#1{#2{#3\@@par}}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\epigraph}
% \begin{macro}{\epigraphparameters}
% \begin{quote}
% |\epigraph|\oarg{width}\marg{text}\marg{author}\\
% |\epigraphparameters|\marg{style}\marg{width}\marg{height}\marg{author-style}\\
% | |\marg{after-action}
% \end{quote}
% \begin{macrocode}
\newcommand*\epigraph[1][\NCC@epigraphwidth]{\NCC@epigraph{#1}}
\newcommand*\epigraphparameters[5]{%
\def\NCC@epigraphwidth{#2}%
\long\def\NCC@epigraph##1##2##3{
\beforechapter{\def\epigraphwidth{##1}%
#1\par
\NCC@makeepigraph{#3}{##2}{#4{##3}}\par
#5%
}%
}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\NCC@makeepigraph}
% \begin{quote}
% |\NCC@makeepigraph|\marg{height}\marg{text}\marg{author}
% \end{quote}
% \begin{macrocode}
\long\def\NCC@makeepigraph#1#2#3{%
\@begin@tempboxa\vtop{\setlength{\hsize}{\epigraphwidth}%
\@parboxrestore{#2\@@par}#3\@@par
}%
\setlength\@tempdima{#1}\advance\@tempdima -\totalheight
\ifdim\@tempdima>\z@
\advance\@tempdima\depth
\dp\@tempboxa\@tempdima
\fi
\leavevmode\box\@tempboxa
\@end@tempboxa
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Make Part in Book-like Classes}
%
% \begin{macro}{\NCC@startpart}
% The start-part hook:
% \begin{macrocode}
\def\NCC@startpart{%
\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@spart}
% Prepare the starred version of part:
% \begin{quote}
% |\NCC@spart|\marg{before}\marg{after}\marg{style}\marg{heading}
% \end{quote}
% \begin{macrocode}
\def\NCC@spart#1#2#3#4{%
\let\@svsec\@empty
\NCC@makepart{#1}{#3}{#4}{#2}{}%
\NCC@sec@reset@controls
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@part}
% Prepare the non-starred version of part:
% \begin{quote}
% |\NCC@part|\marg{before}\marg{after}\marg{style}\oarg{toc-entry}\marg{heading}
% \end{quote}
% \begin{macrocode}
\def\NCC@part#1#2#3[#4]#5{%
\def\NCC@make{\NCC@makepart{#1}{#3}{#5}{#2}}%
\NCC@makesection{part}{\m@ne}{#4}{%
\addcontentsline{toc}{part}{%
\ifnum \c@secnumdepth>-2
\numberline{\NCC@thetocpart}\fi
#4%
}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@thetocpart}
% The following hook allows redefine the appearance of part name
% in the TOC:
% \begin{macrocode}
\def\NCC@thetocpart{\thepart}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makepart}
% This command makes a part:
% \begin{quote}
% |\NCC@makepart|\marg{before}\marg{style}\marg{heading}\marg{after}\marg{action}
% \end{quote}
% The |\@svsec| is either |\@empty| or contains a part tag.
% \begin{macrocode}
\def\NCC@makepart#1#2#3#4#5{%
\if@twocolumn \onecolumn \@tempswatrue \else \@tempswafalse \fi
\begingroup\normalfont
\NCC@asecnum@
\NCC@makeparttitle{#1}{#2}{#3}%
\endgroup
\NCC@makepartfinal{#5}#4%
\if@tempswa \twocolumn \fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makepartfinal}
% \begin{macro}{\NCC@makepartfinalgobble}
% The |\NCC@makepartfinal| hook applies a final action which can contain the
% |\partmark| command. Its default value is to put the parameter as is.
% If you let this command to be equal to the |\NCC@makepartfinalgobble|, the
% chapter mark will contain no chapter name.
% \begin{macrocode}
\let\NCC@makepartfinal\@firstofone
\def\NCC@makepartfinalgobble#1{%
\let\NCC@makepartmark\NCC@makemark
\def\NCC@makemark{%
\let\NCC@temp\partname
\let\partname\@gobble
\NCC@makepartmark
\let\partname\NCC@temp
}%
#1%
}
\@onlypreamble\NCC@makepartfinalgobble
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\NCC@makeparttitle}
% This command makes a part title itself:
% \begin{quote}
% |\NCC@makeparttitle|\marg{before}\marg{style}\marg{heading}
% \end{quote}
% \begin{macrocode}
\def\NCC@makeparttitle#1#2#3{#1%
\ifx\@svsec\@empty \else
{\let\NCC@asecnum\@empty\@svsec\@@par}\nobreak \fi
\interlinepenalty \@M #2{#3\@@par}
}
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Make Captions}
%
% \begin{macro}{\CaptionTagSuffix}
% |\CaptionTagSuffix|\marg{suffix} sets a default suffix after caption tag:
% \begin{macrocode}
\newcommand*{\CaptionTagSuffix}[1]{\def\NCC@acapnum{#1}}
\@onlypreamble\CaptionTagSuffix
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\captiontagsuffix}
% |\captiontagsuffix|\oarg{type}\marg{suffix} changes a suffix after caption
% tag.
% \begin{macrocode}
\newcommand*\captiontagsuffix[2][]{%
\NCC@prepare@capkey{suffix}{#1}{\def\NCC@acapnum{#2}}%
}
\let\NCC@capsuffix@\@empty
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\captionstyle}
% |\captionstyle|\oarg{type}\marg{style} selects a style to be applied
% to the caption text. Three styles are available now: |default|, |center|,
% and |centerlast|.
% \begin{macrocode}
\newcommand*\captionstyle[1][]{%
\NCC@set@capkey{style}{style}{#1}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\captiontagstyle}
% |\captiontagstyle|\oarg{type}\marg{style} selects a style of caption tag:
% |right| or |para|.
% \begin{macrocode}
\newcommand*\captiontagstyle[1][]{%
\NCC@set@capkey{tag}{tag style}{#1}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\captionwidth}
% The |\captionwidth|\oarg{type}\marg{length} specifies a caption width
% in |\@tempdima|. Default width is |\linewidth|.
% \begin{macrocode}
\newcommand*\captionwidth[2][]{%
\NCC@prepare@capkey{width}{#1}{\setlength{\@tempdima}{#2}}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@set@capkey}
% |\NCC@set@capkey|\marg{key}\marg{description}\marg{type}\marg{value}
% \begin{macrocode}
\def\NCC@set@capkey#1#2#3#4{%
\@ifundefined{NCC@makecap#1@#4}
{\PackageError{nccsect}{Unknown caption #2 `#4'}{}%
}{%
\edef\@tempa{\noexpand\NCC@prepare@capkey{#1}{#3}{%
\expandafter\noexpand\csname NCC@makecap#1@#4\endcsname
}%
}%
\@tempa
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@prepare@capkey}
% |\NCC@prepare@capkey|\marg{key}\marg{type}\marg{definition}
% \begin{macrocode}
\def\NCC@prepare@capkey#1#2{%
\def\@tempa{#2}%
\ifx\@tempa\@empty
\ifx\@captype\@undefined \else \let\@tempa\@captype \fi
\fi
\expandafter\def\csname NCC@cap#1@\@tempa\endcsname
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@apply@cap}
% |\NCC@apply@cap|\marg{key}
% \begin{macrocode}
\def\NCC@apply@cap#1{%
\@ifundefined{NCC@cap#1@\@captype}%
{\let\@tempa\@empty}{\let\@tempa\@captype}%
\csname NCC@cap#1@\@tempa\endcsname
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@startcaption}
% This command starts a caption:
% \begin{quote}
% |\NCC@startcaption|\marg{beforeskip}\marg{afterskip}\marg{style}
% \end{quote}
% \begin{macrocode}
\def\NCC@startcaption#1#2#3{%
\secdef{\NCC@caption{#1}{#2}{#3}}{\NCC@scaption{#1}{#2}{#3}}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@scaption}
% Starred version of caption:
% \begin{quote}
% |\NCC@scaption|\marg{beforeskip}\marg{afterskip}\marg{style}\marg{text}
% \end{quote}
% \begin{macrocode}
\long\def\NCC@scaption#1#2#3#4{%
\let\@svsec\@empty
\NCC@makecaption{#3}{#1}{#4}{#2}{}%
\NCC@sec@reset@controls
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@caption}
% Non-starred version of caption:
% \begin{quote}
% |\NCC@caption|\marg{beforeskip}\marg{afterskip}\marg{style}\oarg{toc-entry}\marg{text}
% \end{quote}
% \begin{macrocode}
\long\def\NCC@caption#1#2#3[#4]#5{%
\def\NCC@make{\NCC@makecaption{#3}{#1}{#5}{#2}}%
\NCC@makesection{\@captype}{\z@}{#4}{%
\begingroup
\let\centering\@empty
\addcontentsline{\@nameuse{ext@\@captype}}{\@captype}{%
\ifnum \c@secnumdepth>\m@ne
\numberline{\@nameuse{the\@captype}}\fi
#4%
}%
\endgroup
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecaption}
% This command makes a caption:
% \begin{quote}
% |\NCC@makecaption|\marg{style}\marg{beforeskip}\marg{text}\marg{afterskip}\marg{action}
% \end{quote}
% The |\@svsec| is either |\@empty| or contains a caption tag.
% \begin{macrocode}
\long\def\NCC@makecaption#1#2#3#4#5{%
\begingroup\par\normalfont
#1{}\addvspace{#2}\noindent
% \end{macrocode}
% Calculate in |\@tempcnta| caption variants:
% 0~-- no caption, 1~-- caption tag only, 2~-- caption text only,
% 3~-- both caption tag and text are nonempty.
% \begin{macrocode}
\ifx\@svsec\@empty \@tempcnta\z@ \else \@tempcnta\@ne \fi
\def\@tempa{#3}%
\ifx\@tempa\@empty \else \advance\@tempcnta\tw@ \fi
% \end{macrocode}
% Put caption in a parbox aligned at the top line.
% \begin{macrocode}
\ifnum\@tempcnta=\z@ \else
\NCC@apply@cap{suffix}%
\NCC@apply@cap{width}%
\NCC@vtopcap{\@parboxrestore\NCC@apply@cap{tag}{#3}\@@par}\par
% \end{macrocode}
% We avoid insert zero skip after parbox to allow captions of
% side-by-side figures to be aligned at their top line.
% \begin{macrocode}
\setlength\@tempskipa{#4}%
\ifdim\@tempskipa=\z@ \else \vskip \@tempskipa\fi
\fi
\endgroup
#5%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@vtopcap}
% |\NCC@vtopcap|\marg{text} places a text in a vertical
% top-aligned box. Its width is prepared in |\@tempdima|
% before this macro. If its width is greater than the
% |\linewidth|, we allow overlap the box out of line.
% The overlapping directions are calculated from stretches of
% paragraph marginal skips.
% \begin{macrocode}
\def\NCC@vtopcap#1{%
\ifdim\@tempdima>\linewidth
\@tempskipa \leftskip \advance\@tempskipa -1\@tempskipa
\@tempskipb \rightskip \advance\@tempskipb \parfillskip
\advance\@tempskipb -1\@tempskipb
\vtop{\hb@xt@\linewidth{%
\NCC@ifzeroskip\@tempskipa{}{\hss}%
\vtop{\hsize\@tempdima#1}%
\NCC@ifzeroskip\@tempskipb{}{\hss}%
}}%
\else
\vtop{\hsize\@tempdima#1}%
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@ifzeroskip}
% |\NCC@ifzeroskip|\marg{register}\marg{true-clause}\marg{false-clause}
% executes the \meta{true-clause} if the value of skip register
% is exactly zero skip without stretchability. Otherwise, the
% \meta{false-clause} is executed.
% \begin{macrocode}
\def\NCC@ifzeroskip#1{%
\edef\@tempa{\the#1}\edef\@tempb{\the\z@skip}%
\ifx\@tempa\@tempb
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecaptag@para}
% The |\NCC@makecaptag@para|\marg{text} prepares run-in tag.
% \begin{macrocode}
\long\def\NCC@makecaptag@para#1{%
\ifnum\@tempcnta<\thr@@ \let\NCC@acapnum\@empty\fi
\NCC@apply@cap{style}{{\@svsec}\ignorespaces#1}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecaptag@left}
% The |\NCC@makecaptag@left|\marg{text} prepares flush-left tag.
% \begin{macrocode}
\def\NCC@makecaptag@left{\NCC@separate@captag\raggedright}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecaptag@center}
% The |\NCC@makecaptag@center|\marg{text} prepares centered tag.
% \begin{macrocode}
\def\NCC@makecaptag@center{\NCC@separate@captag\centering}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecaptag@right}
% The |\NCC@makecaptag@right|\marg{text} prepares flush-right tag.
% \begin{macrocode}
\def\NCC@makecaptag@right{\NCC@separate@captag\raggedleft}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@separate@captag}
% The |\NCC@separate@captag|\marg{style}\marg{text} prepares a
% caption tag in a separate line.
% \begin{macrocode}
\long\def\NCC@separate@captag#1#2{%
\ifodd\@tempcnta
{\let\NCC@acapnum\@empty #1\@svsec\@@par}%
\fi
\ifnum\@tempcnta>\@ne
\ifnum\@tempcnta=\thr@@ \vskip .5ex\fi
\NCC@apply@cap{style}{#2}%
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecapstyle@default}
% The |\NCC@makecapstyle@default|\marg{text} prepares caption text
% in default \LaTeX's style.
% \begin{macrocode}
\long\def\NCC@makecapstyle@default#1{%
\setbox\@tempboxa\vtop{\hsize\linewidth\@parboxrestore#1\@@par}%
\ifdim\dp\@tempboxa<\baselineskip \centering#1%
\else \box\@tempboxa \fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecapstyle@para}
% The |\NCC@makecapstyle@para|\marg{text} prepares ordinary caption.
% \begin{macrocode}
\long\def\NCC@makecapstyle@para#1{#1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecapstyle@left}
% The |\NCC@makecapstyle@left|\marg{text} prepares flush-left caption.
% \begin{macrocode}
\long\def\NCC@makecapstyle@left#1{\raggedright#1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecapstyle@right}
% The |\NCC@makecapstyle@right|\marg{text} prepares flush-right caption.
% \begin{macrocode}
\long\def\NCC@makecapstyle@right#1{\raggedleft#1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecapstyle@center}
% The |\NCC@makecapstyle@center|\marg{text} prepares centered caption.
% \begin{macrocode}
\long\def\NCC@makecapstyle@center#1{\centering#1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@makecapstyle@centerlast}
% The |\NCC@makecapstyle@centerlast|\marg{text} prepares caption with
% last line centered.
% \begin{macrocode}
\long\def\NCC@makecapstyle@centerlast#1{%
\leftskip\@flushglue \rightskip -\@flushglue
\parfillskip\z@\@plus 2fil\relax#1%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\RegisterFloatType}
% The |\RegisterFloatType|\marg{type} command registers a float type:
% \begin{macrocode}
\newcommand*{\RegisterFloatType}[1]{%
\edef\NCC@floatlist{\NCC@floatlist{#1}}%
}
\let\NCC@floatlist\@empty
\@onlypreamble\RegisterFloatType
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@infloats}
% The |\NCC@infloats|\marg{action} command applies the given \meta{action}
% to all registered float types. During the cycle,
% the |\@captype| contains a name of float and
% the |\@tempcnta| is equal to its registration number
% (1~for the figure float, 2~for the table float, and so on).
% \begin{macrocode}
\def\NCC@infloats#1{%
\@tempcnta\z@
\let\NCC@temp \@captype
\expandafter \@tfor \expandafter \@captype
\expandafter :\expandafter =\NCC@floatlist \do
{\advance\@tempcnta\@ne #1}%
\let\@captype\NCC@temp
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Declare Sections and Captions}
%
% \begin{macro}{\DeclareSection}
% Now we can implement the |\DeclareSection| command.
% It generates:
% \begin{desclist}{}{}
% \item[\cs{NCC@mainsection}] command if \meta{level} = 0;
% \item[\cs{NCC@section}\meta{level-in-roman}] command if \meta{level} $>$ 0;
% \item[\cs{NCC@cap@}\meta{float-type}] command if \meta{level} $<$ 0.
% \end{desclist}
% \begin{macrocode}
\newcommand{\DeclareSection}{\@ifstar{\NCC@dsecx}{\NCC@dsec}}
\def\NCC@dsec#1#2{%
\@ifnextchar[{\NCC@dsect{#1}{#2}}{\NCC@dsect{#1}{#2}[\z@skip]}%
}
\@onlypreamble\DeclareSection
\@onlypreamble\NCC@dsec
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@dsect}
% The non-starred version of section declaration command
% prepares display sections with traditional formatting:
% \begin{quote}
% |\NCC@dsect|\marg{level}\marg{type}\oarg{indent}\marg{prefix}\marg{beforeskip}\\
% | |\marg{afterskip}\marg{style}
% \end{quote}
% It is also used for generation of run-in sections
% and captions.
% \begin{macrocode}
\def\NCC@dsect#1#2[#3]#4#5#6#7{%
\ifnum#1>\z@
\expandafter\def\csname NCC@section\romannumeral#1\endcsname{%
\NCC@setsectionsuffix{#1}%
\NCC@preparesectag{#4}{}%
\let\NCC@makesec\NCC@makesect
\NCC@startsection{#2}{#1}{#3}{#5}{#6}{#7}}%
\else
\ifnum#1=\z@
\def\NCC@mainsection{%
\NCC@setsectionsuffix\z@
\let\NCC@secmain\@empty
% \end{macrocode}
% The empty |\NCC@secmain| means standard alignment of main section
% \begin{macrocode}
\NCC@startmainsec{%
\NCC@hangfrom{\hskip #3}\NCC@adjsecmargins{}\@flushglue
\ignorespaces}%
{#4}{#5}{#6}{#7}%
}%
\else
\NCC@dsecf{#2}{#4}{#5}{#6}{#7}%
\fi
\fi
}
\@onlypreamble\NCC@dsect
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@dsecx}
% The starred version of section declaration command
% prepares display sections with dynamic formatting:
% \begin{quote}
% |\NCC@dsecx|\marg{level}\marg{type}\marg{prefix}\marg{beforeskip}\marg{afterskip}\marg{style}
% \end{quote}
% It can also be used for generation of captions.
% \begin{macrocode}
\def\NCC@dsecx#1#2#3#4#5#6{%
\ifnum#1>\z@
\expandafter\def\csname NCC@section\romannumeral#1\endcsname{%
\NCC@setsectionsuffix{#1}%
\NCC@setsectionstyle{#1}%
\NCC@preparesectag{#3}{}%
\let\NCC@makesec\NCC@makesecx
\NCC@startsection{#2}{#1}{\z@}{#4}{#5}{#6}}%
\else
\ifnum#1=\z@
% \end{macrocode}
% The non-empty |\NCC@secmain| hook means the dynamic alignment.
% We also redefine the dynamic section style |\NCC@sec| in such a way that the
% right skip stretchability will be |1fil| if the section style has
% no flush glue.
% \begin{macrocode}
\def\NCC@mainsection{%
\NCC@setsectionsuffix\z@
\NCC@setsectionstyle\z@
\let\NCC@secsave\NCC@sec \let\NCC@sec\NCC@secflush
\def\NCC@secmain{\protect\NCC@sec{}}%
\NCC@startmainsec{}{#3}{#4}{#5}{#6}%
}%
\else
\NCC@dsecf{#2}{#3}{#4}{#5}{#6}%
\fi
\fi
}
\@onlypreamble\NCC@dsecx
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@secflush}
% |\NCC@secflush|\marg{tag} applies a section style saved in the
% |\NCC@secsave| macro and adjusts |\rightskip| and |\parfillskip|
% if left and right margins have no stretchability in sum.
% To adjust the right skip, we do the same tricks as in
% |\NCC@adjsecmargins|.
% \begin{macrocode}
\def\NCC@secflush#1{\NCC@secsave{#1}%
\@tempskipa\leftskip \advance\@tempskipa\rightskip
\advance\@tempskipa -1\@tempskipa
\NCC@ifzeroskip\@tempskipa{%
\@tempskipa 1\rightskip \advance\@tempskipa -\rightskip
\advance\@tempskipa \@flushglue
\advance\rightskip \@tempskipa
\advance\parfillskip -\@tempskipa
}{}%
\ignorespaces
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@dsecf}
% This command declares captions of floats:
% \begin{quote}
% |\NCC@dsecf|\marg{type}\marg{prefix}\marg{beforeskip}\marg{afterskip}\marg{style}
% \end{quote}
% \begin{macrocode}
\def\NCC@dsecf#1#2#3#4#5{%
\expandafter\def\csname NCC@cap@#1\endcsname{%
\def\NCC@makesectag####1{#2{\csname #1name\endcsname}%
\nobreakspace####1\NCC@acapnum}%
\NCC@startcaption{#3}{#4}{#5}%
}%
}
\@onlypreamble\NCC@dsectf
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclarePart}
% In book-like classes, a part is declared in a special way:
% \begin{quote}
% |\DeclarePart|\marg{before}\marg{after}\marg{prefix}\marg{style}
% \end{quote}
% Long parameters are allowed in this declaration.
% \begin{macrocode}
\@ifundefined{chapter}{}{%
\newcommand\DeclarePart[4]{%
\def\NCC@partsection{%
\NCC@startpart
\NCC@preparesectag{\leavevmode#3}{\partname\nobreakspace}%
\secdef{\NCC@part{#1}{#2}{#4}}{\NCC@spart{#1}{#2}{#4}}%
}%
}
\@onlypreamble\DeclarePart
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Caption Patches}
%
% \begin{macro}{\@makecaption}
% We emulate here the |\@makecaption{\fnum@|\meta{type}|}|\marg{caption}
% command to provide the compatibility with packages using it.
% It calls the |\NCC@cap@|\meta{type} command using the type specified
% in |\@captype| command. The counter is already stepped
% before this command and all necessary things are written
% to aux. Therefore, we turn off writing to aux and decrease a value of
% the float counter by |-1| because it will be stepped within again.
% \begin{macrocode}
\long\def\@makecaption#1#2{%
\begingroup
\skipwritingtoaux
\addtocounter\@captype\m@ne
\csname NCC@cap@\@captype\endcsname[]{#2}%
\endgroup
}
% \end{macrocode}
% \end{macro}
%
% Add patch to the \textbf{supertabular} package:
% \begin{macrocode}
\AfterPackage{supertabular}{%
\long\def\ST@caption#1[#2]#3{\par%
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup\centering
\def\@captype{#1}%
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup
}
}
% \end{macrocode}
%
% Add patch to the \textbf{xtab} package:
% \begin{macrocode}
\AfterPackage{xtab}{%
\long\def\ST@caption#1[#2]#3{\par%
\@initisotab
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup\centering
\def\@captype{#1}%
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup
\global\advance\ST@pageleft -\PWSTcapht
\ST@trace\tw@{Added caption. Space left for xtabular: \the\ST@pageleft}%
}
}
% \end{macrocode}
%
% Add patch to the \textbf{longtable} package:
% \begin{macrocode}
\AfterPackage{longtable}{%
\def\LT@makecaption#1#2#3{%
\LT@mcol\LT@cols c{\hbox to\z@{\hss
\parbox[t]\LTcapwidth{\centering\def\@captype{table}%
\ifx#1\@gobble \NCC@cap@table*{#3}%
\else \@makecaption{\fnum@table}{#3}%
\fi
}%
\hss
}}%
}
}
% \end{macrocode}
%
% \subsection{Declare TOC-Entries}
%
% \begin{macro}{\DeclareTOCEntry}
% The toc-entries declaration command:
% \begin{quote}
% |\DeclareTOCEntry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\
% | |\marg{style}\oarg{next}
% \end{quote}
% \begin{macrocode}
\newcommand*{\DeclareTOCEntry}[5]{%
\@ifnextchar[{\NCC@dtoc{#1}{#2}{#3}{#4}{#5}}%
{\NCC@dtoc{#1}{#2}{#3}{#4}{#5}[\NCC@nexttocnum{#3}{#4}]}%
}
\def\NCC@dtoc#1#2#3#4#5[#6]{%
% \end{macrocode}
% Declare a toc-entry command for a registered float.
% We scan the registration list and find the necessary
% float type comparing its registration number with the negation
% of level. The generated command is |\l@|\meta{float-type}:
% \begin{macrocode}
\ifnum#1<\z@
\@tempswatrue
\NCC@infloats{%
\ifnum#1=-\@tempcnta
\expandafter\def\csname l@\@captype\endcsname
{\NCC@tocentry\z@{#2}{#3}{#4}{#5}}%
\@tempswafalse
\@break@tfor
\fi
}%
% \end{macrocode}
% Incorrect level number. Generate an error.
% \begin{macrocode}
\if@tempswa
\@tempcnta#1\relax
\@tempcnta -\@tempcnta
\PackageError{nccsect}%
{Float type registration number \the\@tempcnta\space
is out of range}{}%
\fi
\else
% \end{macrocode}
% Prepare in |\@tempa| a command name: |\l@section| or |\l@subsection|
% or \ldots\ or |\l@subparagraph| or |\l@section@vi| or \ldots:
% \begin{macrocode}
\ifnum#1>\z@
\edef\@tempa{\noexpand\def\expandafter\noexpand
\csname l@\NCC@secname{#1}\endcsname}%
% \end{macrocode}
% or |\l@part| or |\l@chapter|:
% \begin{macrocode}
\else
\@ifundefined{chapter}{\def\@tempa{\def\l@part}}%
{\def\@tempa{\def\l@chapter}}%
\fi
% \end{macrocode}
% Declare the toc-entry:
% \begin{macrocode}
\@tempa{\NCC@tocentry{#1}{#2}{#3}{#4}{#5}}%
% \end{macrocode}
% Prepare in the |\l@tocskip@|\meta{next-level-in-roman} command
% the left margin adjustment command. The
% |\NCC@tocnumprototype|\marg{style}\marg{prototype} hook
% applies a style to the prototype of toc-entry number.
% \begin{macrocode}
\@tempcnta #1\relax \advance\@tempcnta\@ne
\expandafter\def\csname l@tocskip@\romannumeral\@tempcnta
\endcsname{\NCC@tocadj{\NCC@tocnumprototype{#5}{#6}}}%
\fi
}
\@onlypreamble\DeclareTOCEntry
\@onlypreamble\NCC@dtoc
\def\NCC@nexttocnum#1#2{#1#2\NCC@atocnum}
\def\NCC@tocnumprototype#1#2{\let\applystyle\@firstoftwo#1{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@tocadj}
% The command increases |\@tempdimb| on the width of the argument:
% \begin{macrocode}
\def\NCC@tocadj#1{%
\settowidth\@tempdima{\let\NCC@atocdo\@firstoftwo#1}%
\advance\@tempdimb\@tempdima
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareTOCPart}
% Part toc-entry declaration in book-like classes. If optional
% \meta{afterskip} is omitted, the default |\NCC@runskip| value
% is applied after this entry.
% \begin{quote}
% |\DeclareTOCPart|\marg{action}\oarg{afterskip}\marg{prefix}\marg{prototype}\marg{style}
% \end{quote}
% \begin{macrocode}
\@ifundefined{chapter}{}{%
\newcommand*\DeclareTOCPart[1]{%
\@ifnextchar[{\NCC@dtocpart{#1}}{\NCC@dtocpart{#1}[\NCC@runskip]}%
}
\def\NCC@dtocpart#1[#2]#3#4#5{%
\def\l@part##1##2{%
\NCC@tocentry{-1}{%
% \end{macrocode}
% We temporary add |1fil| to the toc right margin to prepare
% a ragged right toc-entry.
% \begin{macrocode}
\TOCMarginDrift{1fil}%
% \end{macrocode}
% Breaks before part are preferred.
% \begin{macrocode}
\addpenalty{-\@highpenalty}#1%
}{#3}{#4}{#5}{##1}{\hss##2}%
\nobreak \vskip #2\relax
\@nobreaktrue
\everypar{\@nobreakfalse\everypar{}}%
}%
}
\@onlypreamble\DeclareTOCPart
\@onlypreamble\NCC@dtocpart
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@tocentry}
% This command makes a toc-entry:
% \begin{quote}
% |\NCC@tocentry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\
% | |\marg{style}\marg{entry}\marg{page-number}
% \end{quote}
% \begin{macrocode}
\def\NCC@tocentry#1#2#3#4#5#6#7{%
\ifnum #1>\c@tocdepth \else
\par\begingroup\normalfont #2%
\let\applystyle\@firstoftwo
% \end{macrocode}
% Calculate the left margin in the |\@tempdimb| register
% applying the |\l@tocskip@i|, \ldots, |\l@tocskip@|\meta{level-in-roman}
% commands:
% \begin{macrocode}
\@tempdimb\z@ \@tempcnta #1\relax
\@whilenum \@tempcnta >\z@\do
{\@nameuse{l@tocskip@\romannumeral \@tempcnta}%
\advance\@tempcnta\m@ne}%
% \end{macrocode}
% The |\NCC@preparetocnum|\marg{style}\marg{prefix} hook prepares
% the |\NCC@maketocnum|\marg{tag} command creating
% a number-line tag:
% \begin{macrocode}
\NCC@preparetocnum{#5}{#3}%
% \end{macrocode}
% Calculate the hang indent value in |\@tempdima|:
% \begin{macrocode}
\settowidth\@tempdima{\let\NCC@atocdo\@firstoftwo\NCC@maketocnum{#4}}%
% \end{macrocode}
% Produce the toc-entry. The |\NCC@tocentrytitle|\marg{style}\marg{title}
% hook applies the style to the toc-entry title.
% \begin{macrocode}
\@dottedtocline{#1}{\@tempdimb}{\@tempdima}%
{\let\NCC@atocdo\@secondoftwo\NCC@tocentrytitle{#5}{#6\unskip}}%
{\let\applystyle\@secondoftwo#5{#7}}%
% \end{macrocode}
% Allow break after toc-entry:
% \begin{macrocode}
\@nobreakfalse
\endgroup
\fi
}
\def\NCC@preparetocnum#1#2{%
\def\NCC@maketocnum##1{\NCC@atocdo{#1}{}{#2##1\NCC@atocnum}}%
}
\def\NCC@tocentrytitle#1#2{#1{\ignorespaces#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\numberline}
% Redefine the |\numberline|\marg{tag} command to work correct
% if the width of tag is greater than |\@tempdima|. The
% tag is prepared with the |\NCC@maketocnum|\marg{tag} command.
% \begin{macrocode}
\DeclareRobustCommand*\numberline[1]{%
\setbox\@tempboxa\hbox{\NCC@maketocnum{#1}}%
\ifdim \wd\@tempboxa > \@tempdima
\box\@tempboxa
\else
\hb@xt@\@tempdima{\unhbox\@tempboxa\hfil}%
\fi
\ignorespaces
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@maketocnum}
% The default implementation of the |\NCC@maketocnum|\marg{tag} command.
% We must define it because the |\numberline| command must
% work out of scope of toc-entries.
% \begin{macrocode}
\def\NCC@maketocnum#1{#1\NCC@atocnum}
\let\NCC@atocdo\@secondoftwo
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NumberlineSuffix}
% The |\NumberlineSuffix|\marg{calc-suffix}\marg{actual-suffix}
% command saves suffices inserted after number tag in the |\numberline|
% command. It saves it in the |\NCC@atocnum| hook as parameters of
% |\NCC@atocdo| command. Letting the last one to |\@firstoftwo| or
% |\@secondoftwo|, we select the \meta{calc-suffix} or \meta{actual-suffix}
% respectively.
% \begin{macrocode}
\newcommand*{\NumberlineSuffix}[2]{\def\NCC@atocnum{\NCC@atocdo{#1}{#2}}}
\@onlypreamble\NumberlineSuffix
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TOCMarginDrift}
% The |\TOCMarginDrift|\marg{drift} specifies allowed drift of right margin
% in TOC.
% \begin{macrocode}
\newcommand*\TOCMarginDrift[1]{%
\def\@tempa{#1}%
\ifx\@tempa\@empty \let\NCC@tocdrift\@empty
\else \def\NCC@tocdrift{\@plus #1\relax}\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PnumPrototype}
% The |\PnumPrototype|\marg{prototype} command saves the page number
% prototype in the |\NCC@pnum| hook and applies the |\NCC@setpnum|
% command.
% \begin{macrocode}
\newcommand*{\PnumPrototype}[1]{\def\NCC@pnum{#1}\NCC@setpnum}
\@onlypreamble\PnumPrototype
\def\NCC@setpnum{%
\settowidth\@tempdima{\NCC@pnum}%
\edef\@pnumwidth{\the\@tempdima}%
\advance\@tempdima 1em
\edef\@tocrmarg{\the\@tempdima \noexpand\NCC@tocdrift}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SetTOCStyle}
% The toc-style hook is embedded into the |\@starttoc| command.
% We also recalculate the page number prototype and update
% margins when a toc starts.
% \begin{macrocode}
\newcommand*{\SetTOCStyle}[1]{\def\NCC@tocstyle{#1}}
\@onlypreamble\SetTOCStyle
\let\NCC@latexstarttoc\@starttoc
\def\@starttoc#1{%
\begingroup
\normalfont \NCC@tocstyle \NCC@setpnum
\NCC@latexstarttoc{#1}%
\endgroup
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Service and Defaults}
%
% \begin{macro}{\StartFromTextArea}
% \begin{macro}{\StartFromHeaderArea}
% These commands are applied at the beginning of page
% to set current position exactly at the first line
% of text area or at the header line, respectively.
% Both these commands are defined in two packages: in this one and in
% the \textbf{textarea}. To be sure that the commands are specified
% in these packages only, we mutually test packages to be loaded.
% \begin{macrocode}
\@ifpackageloaded{textarea}{}{%
\newcommand\StartFromTextArea{\par
{\parskip\z@ \strut\par}\vskip -\baselineskip
}
\newcommand\StartFromHeaderArea{%
\StartFromTextArea
\vskip -\headsep \vskip -\ht\strutbox
}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bff}
% The |\bff| command tries to set everything bold.
% \begin{macrocode}
\newcommand{\bff}{\normalfont\bfseries\mathversion{bold}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\aftersectionvspace}
% This command eliminates a vertical space inserted after a previous
% section and inserts a vertical space specified.
% \begin{macrocode}
\newcommand*\aftersectionvspace[1]{%
\ifvmode \if@nobreak
\vskip -\lastskip \vskip #1\relax
\fi \fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\startsection}
% Define the |\startsection| command. In article-class,
% both zero and negative levels refer to the same part section.
% \begin{macrocode}
\newcommand*{\startsection}[1]{%
\ifnum#1>\z@
\def\@tempa{\csname NCC@section\romannumeral#1\endcsname}%
\else
\ifnum#1=\z@
\def\@tempa{\NCC@mainsection}%
\else
\def\@tempa{\NCC@partsection}%
\fi
\fi
\@tempa
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\part}
% \begin{macro}{\section}
% \begin{macro}{\subsection}
% \begin{macro}{\subsubsection}
% \begin{macro}{\paragraph}
% \begin{macro}{\subparagraph}
% Set aliases for almost all section levels, except chapter.
% The part is called here as a section of a negative level.
% \begin{macrocode}
\def\part{\startsection\m@ne}
\def\section{\startsection\@ne}
\def\subsection{\startsection\tw@}
\def\subsubsection{\startsection\thr@@}
\def\paragraph{\startsection4}
\def\subparagraph{\startsection5}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\caption}
% Redefine the |\caption| command. We do this at the beginning
% of document to reject possible redefinitions of captions
% in other packages such as |float|. I think this is not the
% |float|'s responsibility to decide where a caption must go on:
% before or after the float body. And what about complicated
% floats consisting of side floats and etc.? We also reset to zero
% the |\abovecaptionskip| and |\belowcaptionskip| registers if they
% are specified to provide partial compatibility with the |float|
% package. If the registers are not specified (as in |ncc| class),
% they are emulated with macros.
% \begin{macrocode}
\AtBeginDocument{%
\def\caption{%
\ifx\@captype\@undefined
\@latex@error{\noexpand\caption outside float}\@ehd
\expandafter\@gobble
\else
\expandafter\@firstofone
\fi
{\csname NCC@cap@\@captype\endcsname}%
}%
\@ifundefined{abovecaptionskip}{\def\abovecaptionskip{\z@}}%
{\abovecaptionskip\z@}%
\@ifundefined{belowcaptionskip}{\def\belowcaptionskip{\z@}}%
{\belowcaptionskip\z@}%
}
% \end{macrocode}
% \end{macro}
%
% Registration of standard floats:
% \begin{macrocode}
\RegisterFloatType{figure}
\RegisterFloatType{table}
% \end{macrocode}
%
% Declare all sections and captions except the part and chapter:
% \begin{macrocode}
\DeclareSection{-2}{table}{}{\z@}{10pt}{}
\DeclareSection{-1}{figure}{}{10pt}{\z@}{}
\DeclareSection*1{section}{}%
{3.5ex \@plus 1ex \@minus .2ex}%
{2.3ex \@plus .2ex}{\Large\bff}
\DeclareSection*2{subsection}{}%
{3.25ex \@plus 1ex \@minus .2ex}%
{1.5ex \@plus .2ex}{\large\bff}
\DeclareSection*3{subsubsection}{}%
{3ex \@plus 1ex \@minus .2ex}%
{1.5ex \@plus .2ex}{\normalsize\bff}
\DeclareSection4{paragraph}{}%
{\NCC@runskip}{-1em}{\normalsize\bff}
\DeclareSection5{subparagraph}[\parindent]{}%
{\NCC@runskip}{-1em}{\normalsize\bff}
\@ifundefined{chapter}{
% \end{macrocode}
%
% Declare the part and toc-entries for the article-like style:
% \begin{macrocode}
\DeclareSection*0{part}{\Large\bff}%
{5ex \@plus 1ex \@minus .2ex}%
{4ex \@plus .2ex}{\huge\bff}
\DeclareTOCEntry{-2}{}{}{9}{}% table
\DeclareTOCEntry{-1}{}{}{9}{}% figure
\DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}}{}{III}{\bff}[]
\DeclareTOCEntry1{\runinsectionskip}{}{9}{}
\DeclareTOCEntry2{}{}{9.9}{}
\DeclareTOCEntry3{}{}{9.9.9}{}
}{
% \end{macrocode}
%
% \begin{macro}{\ChapterPrefixStyle}
% Specify the appearance of chapter prefix in the toc and the header.
% \begin{macrocode}
\newcommand*{\ChapterPrefixStyle}[1]{%
\def\NCC@thetocchapter{\thechapter}%
\let\NCC@makechapfinal\NCC@makechapfinalgobble
\@for\@tempa:=#1\do{%
\@ifundefined{NCC@chapin@\@tempa}{%
\PackageError{nccsect}{Unknown style `\@tempa'\MessageBreak
Only the `toc' and `header' styles are allowed}{}%
}{\csname NCC@chapin@\@tempa\endcsname}%
}%
}
\def\NCC@chapin@toc{\def\NCC@thetocchapter{\@chapapp\ \thechapter}}
\def\NCC@chapin@header{\let\NCC@makechapfinal\@firstofone}
\@onlypreamble\ChapterPrefixStyle
\@onlypreamble\NCC@chapin@toc
\@onlypreamble\NCC@chapin@header
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chapter}
% Declare the part, the chapter, toc-entries for the
% book-like style, and specify default epigraph parameters:
% \begin{macrocode}
\def\chapter{\startsection\z@}
\DeclarePart{\StartFromTextArea\vfil\centering}%
{\vfil\newpage \if@twoside\if@openright
\mbox{}\thispagestyle{empty}\newpage\fi\fi}%
{\vspace{4ex}\huge\bff}{\Huge\bff}
\DeclareSection*0{chapter}{\vspace{3ex}\huge\bff}{10ex}%
{8ex \@plus .2ex}{\Huge\bff}
\DeclareTOCEntry{-2}{}{}{9.9}{}% table
\DeclareTOCEntry{-1}{}{}{9.9}{}% figure
\DeclareTOCPart{\NCC@secskip{4ex \@plus .2ex}\def\@dotsep{1000}}
{}{II}{\large\bff}
\DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}%
\aftergroup\penalty\aftergroup\@highpenalty}{}{9}{\bff}
\DeclareTOCEntry1{}{}{9.9}{}[9.9]
\DeclareTOCEntry2{}{}{9.9.9}{}[9.9.9]
\DeclareTOCEntry3{}{}{}{}[\qquad]
\epigraphparameters{\StartFromHeaderArea\small\raggedleft}%
{.45\linewidth}{5\baselineskip}%
{\raggedleft\itshape}{\vspace{2ex}}
}
% \end{macrocode}
% \end{macro}
%
% Declare other toc-entries:
% \begin{macrocode}
\DeclareTOCEntry4{}{}{}{}[\qquad]
\DeclareTOCEntry5{}{}{}{}[\qquad]
% \end{macrocode}
%
% Set defaults:
% \begin{macrocode}
\noindentaftersection
\sectionstyle{hangindent}
\SectionTagSuffix{\quad}
\RunningSectionSuffix{}
\captionwidth{\linewidth}
\captionstyle{default}
\captiontagstyle{para}
\CaptionTagSuffix{:\hskip .7em \@plus .2em \@minus .1em}
\NumberlineSuffix{\quad}{\enskip}
\PnumPrototype{99}
\TOCMarginDrift{}
\SetTOCStyle{}
%</package>
% \end{macrocode}
\endinput
|