summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/koma-script/tocstyle.dtx
blob: 9d2bd1c0a375264a2221f179e23e50b932780b14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
% \CheckSum{1699}
% \iffalse meta-comment
% ======================================================================
% tocstyle.dtx
% Copyright (c) Markus Kohm, 2007-2015
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% The KOMA-Script bundle consists of all files listed in manifest.txt.
% The work `tocstyle' consists of the files `tocstyle.dtx' and 
% `scrlogo.dtx'.
%
% If you're missing the installation batch file `tocstyle.ins', try
%    tex tocstyle.dtx
% to unpack all files. 
% The package documentation may be produced repeating
%    latex tocstyle.dtx
% at least three times.
% ----------------------------------------------------------------------
% tocstyle.dtx
% Copyright (c) Markus Kohm, 2007-2015
%
% Diese Datei ist Teil des LaTeX2e KOMA-Script-Pakets.
%
% Dieses Werk darf nach den Bedingungen der LaTeX Project Public Lizenz,
% Version 1.3c.
% Die neuste Version dieser Lizenz ist
%   http://www.latex-project.org/lppl.txt
% und Version 1.3c ist Teil aller Verteilungen von LaTeX
% Version 2005/12/01 und dieses Werks.
%
% Dieses Werk hat den LPPL-Verwaltungs-Status "author-maintained"
% (allein durch den Autor verwaltet).
%
% Der Aktuelle Verwalter und Autor dieses Werkes ist Markus Kohm.
%
% Das KOMA-Script-Paket besteht aus allen Dateien, die in manifest.txt
% genannt sind.
% Das Werk `tocstyle' besteht aus den Dateien `tocstyle.dtx' und
% `scrlogo.dtx'.
%
% Falls Sie die Installations-Batch-Datei `tocstyle.ins' vermissen,
% probieren Sie einfach einmal
%    tex tocstyle.dtx
% um alle Dateien auszupacken. Zur englischen Anleitung siehe den
% englischen Kommentar oben.
% ======================================================================
% \fi
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \iffalse
%%% From File: $Id: tocstyle.dtx 1977 2015-03-09 08:17:29Z kohm $
%<*dtx>
% \fi
\def\LaTeXformat{LaTeX2e}
\let\ifbeta=\iffalse %^^A with = will be replaced by release process
\ifx\fmtname\LaTeXformat\else
% \iffalse
%</dtx>
%<*insfile>
% \fi
\def\batchfile{tocstyle.dtx}
\input docstrip.tex
\ifToplevel{%
  \Msg{**********************************************************************}
  \Msg{*}
  \Msg{* KOMA-Script presents tocstyle}
  \Msg{* a package to define, configure and several different styles for}
  \Msg{* table of contents, list of floats and comparables.}
  \Msg{*}
  \Msg{* This is `\batchfile', a batchfile to unpack the package tocstyle,}
  \Msg{* the documentation of the package, and an archive of all these files.}
  \Msg{*}
  \Msg{**********************************************************************}
  \keepsilent
  \askforoverwritefalse
}

\preamble

Copyright (c) 2007-2013 by Markus Kohm <komascript(at)gmx.info>

Copyright (c) 1994-2007
Markus Kohm and any individual authors listed elsewhere in this file.

This file was generated from file(s) of the KOMA-Script bundle.
---------------------------------------------------------------

This work may be distributed and/or modified under the conditions of
the LaTeX Project Public License, version 1.3c of the license.
The latest version of this license is in
  http://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of LaTeX
version 2005/12/01 or later and of this work.

This work has the LPPL maintenance status "author-maintained".

The Current Maintainer and author of this work is Markus Kohm.

This file may only be distributed together with the file
`tocstyle.dtx' and `scrlogo.dtx'. You may however distribute the files
`tocstyle.dtx' and `scrlogo.dtx' without this file.

If this file is a beta version, you are not allowed to distribute it.

English and German manuals are part of KOMA-Script bundle.
----------------------------------------------------------

The english manual is at `tocstyle.dtx', too.

The KOMA-Script bundle (but not this file) was based upon the LaTeX2.09 
Script family created by Frank Neukam 1993 and the LaTeX2e standard 
classes created by The LaTeX3 Project 1994-1996.

THIS IS AN ALPHA VERSION!
USAGE OF THIS VERSION IS ON YOUR OWN RISK!
EVERYTHING MAY HAPPEN!
EVERYTHING MAY CHANGE IN FUTURE!
THERE IS NO SUPPORT, IF YOU USE THIS PACKAGE!

\endpreamble

\generate{\usepreamble\defaultpreamble
  \file{tocstyle.sty}{%
    \from{tocstyle.dtx}{package,trace,tocstyle}%
    \from{scrlogo.dtx}{logo}%
  }%
}

\ifToplevel{%
  \generate{\usepreamble\defaultpreamble
    \file{tocstyle.ins}{%
      \from{tocstyle.dtx}{insfile}%
    }%
    \file{tocstyle.tex}{%
      \from{tocstyle.dtx}{doc}%
    }%
    \file{tocstyle.drv}{%
      \from{tocstyle.dtx}{driver}%
    }%
  }%
}

\ifToplevel{%
  \Msg{**********************************************************************}
  \Msg{*}
  \ifbeta
  \Msg{* THIS IS A BETA VERSION. YOU SHOULD NOT INSTALL OR USE IT!}
  \Msg{* THERE MAY BE A LOT OF BUGS AT THIS VERSION!}
  \Msg{* PLEASE INSTALL THE RELEASE YOU MAY FIND AT CTAN!}
  \else
  \Msg{* To finish the installation you have to copy the file `tocstyle.sty'}
  \Msg{* to folder `tex/latex/tocstyle/' of one of your TEXMF trees.}
  \Msg{* You should also produce the documentation using}
  \Msg{*\space\space latex tocstyle.dtx}
  \Msg{* and copy it to folder `doc/latex/tocstyle/' of one of your}
  \Msg{* TEXMF trees.}
  \Msg{*}
  \Msg{* See the manual of your TeX distribution for more informations about}
  \Msg{* package installation.}
  \fi
  \Msg{*}
  \Msg{**********************************************************************}
}
% \iffalse
%</insfile>
%<*dtx>
% \fi
  \def\ProvidesFile{\csname fi\endcsname\csname endinput\endcsname}
\fi
\ProvidesFile{tocstyle.dtx}
% \iffalse
%</dtx>
%<package|driver>\NeedsTeXFormat{LaTeX2e}[1995/06/01]
%<package>\ProvidesPackage{tocstyle}
%<driver>\ProvidesFile{tocstyle.drv}
%<doc>\ProvidesFile{tocstyle.tex}
%<*dtx|package|driver|doc>
  [2013/08/11 v0.2e-alpha KOMA-Script package (versatile toc styles)]
%</dtx|package|driver|doc>
%<*driver>
\documentclass{scrdoc}
\usepackage[ngerman,english]{babel}
\usepackage{listings}
\lstnewenvironment{lstcode}[1][]{%
  \lstset{language=[LaTeX]TeX,basicstyle=\ttfamily\small,#1}%
}{}

\usepackage{tocstyle}
\usetocstyle[toc]{nopagecolumn}
\CodelineIndex
\RecordChanges
\GetFileInfo{tocstyle.dtx}
\title{The \KOMAScript{} package \texttt{tocstyle}%
  \footnote{This is version \fileversion\ of file \texttt{\filename}.}}
\date{\filedate}
\author{Markus Kohm}

\newenvironment{Explain}{\par}{\par}
\let\Macro\cs
\let\Package\textsf
\let\File\texttt
\let\Option\texttt
\let\Counter\texttt
\let\ShowOutput\quote
\let\endShowOutput\endquote
\let\Parameter\marg
\let\OParameter\oarg
\newcommand\PParameter[1]{\mbox{\texttt{\{#1\}}}}
\let\PName\meta
\let\PValue\texttt
\newlength\descwidth
\newenvironment{desctabular}{%
  \setlength{\descwidth}{\linewidth}
  \addtolength{\descwidth}{-1em}
  \addtolength{\descwidth}{-2\tabcolsep}
  \tabular{@{}lp{\descwidth}@{}}
  \hline
}{%
  \hline
  \endtabular
}
\newcommand{\pventry}[2]{%
  \multicolumn{2}{@{}l@{}}{\PValue{#1}}\\
  ~ & #2 \\ }
\providecommand*{\autoref}[1]{\expandafter\AUTOREF#1:}
\newcommand*{\AUTOREF}{}
\makeatletter
\def\AUTOREF#1:#2:{%
  \edef\@tempa{#1}%
  \edef\@tempb{tab}\ifx\@tempa\@tempb table~\fi
  \edef\@tempb{sec}\ifx\@tempa\@tempb section~\fi
  \ref{#1:#2}%
}
\makeatother

\begin{document}
  \maketitle
  \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
% \selectlanguage{english}
%
% \changes{v0.1}{2007/06/23}{start of new package}
%
%\iffalse
%<doc>\chapter{Other Styles for Table of Contents and Lists of Floats}
%<doc>\labelbase{tocstyle}
%<doc>\BeginIndex{Package}{tocstyle}
%\fi
%
% \begin{abstract}
%\iffalse
%<*doc>
%\fi
While the main classes of the \KOMAScript\ bundle were made, there where
several ideas for formating the table of contents and lists of floats, but
almost none of them where implemented. One reason was, that the \KOMAScript\
author didn't like to change the \LaTeX\ kernel at a class, because this may
result in serveral problems with other packages. The package
\Package{tocstyle} will fill the gap. If it conflicts with another package,
you simply may decide not to use it.
%\iffalse
%</doc>
%\fi
% \end{abstract}
%
% \def\appendixtocdepth{\value{tocdepth}}
% \tableofcontents
% \def\appendixtocdepth{2}
%
%\iffalse
%<*doc>
%\fi
%
\section{How It Works}
\label{sec:tocstyle.howitworks}

\begin{Explain}
  Loading the package \Package{tocstyle} will redefine the kernel macro
  \Macro{@starttoc}. Using the redefined \Macro{@starttoc} will redefine
  \Macro{@dottedtocline}, \Macro{l@part} down to \Macro{l@subparagraph},
  \Macro{l@figure}, and \Macro{l@table}, if and only if \Package{tocstyle}
  wasn't deactivated for all TOCs or this TOC. Usage the redefined
  \Macro{@dottedtocline} will redefine \Macro{numberline}.

  Redefining \Macro{@starttoc}, \Macro{@dottedtocline}, and \Macro{numberline}
  will activate the features of \Package{tocstyle} for all lists that uses
  these, e.g. table of contents, list of figures and list of tables at the
  standard or the \KOMAScript{} classes. But while not all classes uses
  \Macro{@dottedtocline} and \Macro{@numberline} for all entries to table of
  contents and list of floats the package redefines some other macros that are
  typically used for those entries. These are e.g. \Macro{l@part},
  \Macro{l@chapter} and some more. If the class even does not use those
  macros, you may not use \Package{tocstyle} to change the lists. The term TOC
  will be used for all kind of list, that may be processed by
  \Package{tocstyle}. The package tests wether the original kernel macros
  \Macro{@starttoc}, \Macro{@dottedtocline}, and \Macro{numberline} were used
  or not and warns if not.

  Package \Package{tocstyle} needs some more information. For the standard and
  the \KOMAScript{} classes these informations may be detected by the
  package. If the result is not the expected, you may configure these
  informations manually.

  The entries of every TOC hat a depth. See the counter \Counter{tocdepth} for
  more information about the depth. You may change several settings for the
  entries of either all depths of all TOCs, all depths of one TOC, or one
  depth of one TOC. 

  But most users will not need to set up \Package{tocstyle} at this low
  level. They simply will select one of the predefined styles and maybe select
  one of the optional features.
\end{Explain}

\section{Optional Features}
\label{sec:tocstyle.options}

Optional features will be selected using a package option while loading the
package or using the package option as a global option loading the class using
\Macro{documentclass}. Optional features change generall behaviour of all
TOCs.

%\iffalse
\begin{Description}
  \Option{tocindentauto}
  \Option{tocindentmanual}
\end{Description}
\BeginIndex{Option}{tocindentauto}\BeginIndex{Option}{tocindentmanual}
%</doc>
%<*dtx>
%\fi
\DescribeMacro{tocindentauto}
\DescribeMacro{tocindentmanual}
%\iffalse
%</dtx>
%<*doc>
%\fi
With option \Option{tocindentauto} all widths at the TOCs are calculated by
\Package{tocstyle}. The calculation of the width needs at least one \LaTeX{}
run with all TOC entries. So you need at least three \LaTeX{} runs:
\begin{itemize}
\item one to write all the TOC entries to the TOC file
\item one with the known TOC entries from the TOC file but unknown widths
\item one with the known TOC entries from the TOC file and known widths
\end{itemize}
If the TOC entries changed between the second and the third
run\,---\,e.g. because of page numbers changed\,---\,you'll need one more run
(and so on).

Note: The widths of all entries of same depth and same TOC are same. Don't ask
for less width of page numbers at the first than the last TOC page!
%\iffalse
\EndIndex{Option}{tocindentauto}\EndIndex{Option}{tocindentmanual}
%\fi
%
%\iffalse
\begin{Description}
  \Option{tocgraduated}
  \Option{tocflat}
  \Option{tocfullflat}
\end{Description}%
\BeginIndex{Option}{tocgraduated}\BeginIndex{Option}{tocflat}%
\BeginIndex{Option}{tocfullflat}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{tocgraduated}
\DescribeMacro{tocflat}
\DescribeMacro{tocfullflat}
%\iffalse
%</dtx>
%<*doc>
%\fi
The option \Option{tocgraduated} selects the graduated version of all
TOCs. You know the graduated version from the standard classes. Entries of lower
depth are indented against entries of higher depth. This may e.g. look like:
\begin{ShowOutput}
  \showtoc[{%
    \aliastoc{\tocstyleTOC}{toc}%
    \usetocstyle[toc]{standard}%
    \settocfeature[toc]{raggedhook}{\raggedright}%
    \selecttocstyleoption{tocgraduated}%
  }]{toc}
\end{ShowOutput}
The option \Option{tocflat} selects the flat\,---\,aka left
aligned\,---\,version of all TOCs. You know the flat version from the
\KOMAScript{} classes using option \Option{tocleft}. This may e.g. look like:
\begin{ShowOutput}
  \showtoc[{%
    \aliastoc{\tocstyleTOC}{toc}%
    \usetocstyle[toc]{standard}%
    \selecttocstyleoption{tocflat}%
  }]{toc}%
\end{ShowOutput}
The option \Option{tocfullflat} is similar to flat version of all
TOCs, but there is even no box of same width for the numbers of all entries.
This may e.g. look like:
\begin{ShowOutput}
  \showtoc[{%
    \aliastoc{\tocstyleTOC}{toc}%
    \usetocstyle[toc]{standard}%
    \selecttocstyleoption{tocfullflat}%
  }]{toc}%
\end{ShowOutput}
Default is option \Option{tocgraduated}.
%\iffalse
\EndIndex{Option}{tocgraduated}\EndIndex{Option}{tocflat}%
\EndIndex{Option}{tocfullflat}%
%\fi
%
%\iffalse
\begin{Description}
  \Option{tocbreaksstrict}\\
  \Option{tocbreakscareless}
\end{Description}%
\BeginIndex{Option}{tocbreaksstrict}%
\BeginIndex{Option}{tocbreakscareless}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{tocbreaksstrict}
\DescribeMacro{tocbreakscareless}
%\iffalse
%</dtx>
%<*doc>
%\fi
Default option \Option{tocbreaksstrict} sets a lot of penalties before and
after TOC entries to avoid page break between a TOC entry and it's parent. But
sometimes you may like to allow more page breaks. You may use option
\Option{tocbreakscareless} for this.
%\iffalse
\EndIndex{Option}{tocbreaksstrict}\EndIndex{Option}{tocbreakscareless}%
%\fi
%
%\iffalse
\begin{Description}
  \Option{toctextentriesindented}\\
  \Option{toctextentriesleft}
\end{Description}%
\BeginIndex{Option}{toctextentriesindented}%
\BeginIndex{Option}{toctextentriesleft}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{toctextentriesindented}
\DescribeMacro{toctextentriesleft}
%\iffalse
%</dtx>
%<*doc>
%\fi
With default option \Option{toctextentriesleft} unnumbered TOC entries,
e.g. from \KOMAScript{} command \Macro{addchap}, are indented only as wide as
the number of numbered TOC entries of the same level are. But with option
\Option{toctextentriesindented} these are indented as if they have an empty
number.
%\iffalse
\EndIndex{Option}{toctextentriesindented}%
\EndIndex{Option}{toctextentriesleft}%
%\fi
%
\section{Using TOC Styles}
\label{sec:tocstyle.usestyles}

Package \Package{tocstyle} hat several predefined toc styles. Most users will
never need to define their own toc style but only select one of the
predefined and maybe configure it by one of the options described at the
previsous section.

%\iffalse
\begin{Description}
  \Macro{usetocstyle}\OParameter{TOC}\Parameter{style}
\end{Description}%
\BeginIndex{Macro}{usetocstyle}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{\usetocstyle}
%\iffalse
%</dtx>
%<*doc>
%\fi
You may set the style of one or all TOCs. If you want to set the style of all
TOCs, you'd simply say \Macro{usetocstyle}\Parameter{style}. This will set
all settings of the given style to all TOCs. Individual settings will
overwrite this generall setting.

If you use \Macro{usetocstyle}\OParameter{TOC}\Parameter{style}, only the
style of the given TOC will be set. This will be done \emph{after} the general
setting. Only individual settings of single features may overwrite the setting
of the style.

The \autoref{tab:tocstyle.styles} shows the predefined styles, that may be
used as mandatory argument of \Macro{tocstyle}. The optional argument
\PName{TOC} is the shortcut (file extension) of the TOC. Examples of known
shortcuts are shown at \autoref{tab:tocstyle.shortcuts}.

\begin{table}
  \centering
  \caption{Predefined TOC Styles}
  \label{tab:tocstyle.styles}
  \begin{desctabular}
    \pventry{standard}{A style similar to the standard classes. All width are
      predefined to the width of the standard classes, but may be overwritten
      by the general options (see \autoref{sec:tocstyle.options}). The depth -1
      (part) and 0 (chapter) are set in bold face (\Macro{bfseries}). If no
      depth 0 was found at the TOC, depth 1 (section) will be set in bold
      face, too. All other depth will be set in normal font. Depth -1 (part)
      will be set using \Macro{large}. The font changes are valid for the
      page numbers, too.}%
    \pventry{KOMAlike}{A style similar to the \KOMAScript{} classes. This is
      almost the same like \PValue{standard}, but instead of bold face
      \Macro{usekomafont}\PParameter{disposition} will be used if
      \Macro{usekomafont} was defined and sans serif, bold face
      (\Macro{sffamily}\Macro{bfseries}) if not.}%
    \pventry{classic}{Like \PValue{KOMAlike} but all page numbers are set
      using normal font.}%
    \pventry{allwithdot}{Like \PValue{classic} but dots between entry text and
      page numbers are used at all depths.}%
    \pventry{noonewithdot}{Like \PValue{classic} but not dots between entry
      text and page numbers are used.}%
    \pventry{nopagecolumn}{Like \PValue{noonewithdot} but also the gap
      between text and page numbers is omited. This means, that the page
      numbers are set 1\,em after the text.}%
  \end{desctabular}
\end{table}

Note: Before you're setting a style the style of the TOCs are
unspecified. This means that some entries may be set using \Package{tocstyle}
others may not.

\begin{table}
  \centering
  \caption{Known TOC Shortcuts}
  \label{tab:tocstyle.shortcuts}
  \begin{desctabular}
    \pventry{toc}{Table of contents of almost all known classes.}
    \pventry{lof}{List of figures of almost all known classes.}
    \pventry{lot}{List of tables of almost all known classes.}
    \pventry{lol}{List of listings of package \Package{listings}. Currently
      the usability of \Package{listings} with \Package{tocstyle} is not
      recomended. Maybe it works, maybe not. Maybe you should try
      \Macro{deactivatetocstyle[lol]}.}
  \end{desctabular}
\end{table}
%\iffalse
\EndIndex{Macro}{usetocstyle}%
%\fi
%
%\iffalse
\begin{Description}
  \Macro{deactivatetocstyle}\OParameter{TOC}\\
  \Macro{reactivatetocstyle}\OParameter{TOC}
\end{Description}%
\BeginIndex{Macro}{\deactivatetocstyle}\BeginIndex{Macro}{\reactivatetocstyle}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{\deactivatetocstyle}\DescribeMacro{\reactivatetocstyle}
Both commands have one optional argument \PName{TOC}.
%\iffalse
%</dtx>
%<*doc>
%\fi
You may deactive the influence of \Package{tocstyle} for a TOC and reactivate
it. If you use \Macro{deactivatetocstyle} without the optional argument or
empty optional argument, the influence of \Package{tocstyle} for all TOCs will
be deactivated and may reactivated only using \Macro{reactivatetocstyle}
without the optional argument or empty optional argument too.

After deactivation of \Package{tocstyle} for one TOC or all TOCs you may
continue configuring TOCs. All these changes will be used after reactivation.
%\iffalse
\EndIndex{Macro}{\deactivatetocstyle}\EndIndex{Macro}{\reactivatetocstyle}%
%\fi

%

\section{Setting-up Single Features}
\label{sec:tocstyle.singlefeatures}

At the previous section you've learned how to select a predefined TOC
style. You were also told, that you may change one ore more features against
the used predefined TOC style for one or all depth of one ore all TOCs. Now
you will learn how to do this.

%\iffalse
\begin{Description}
  \Macro{settocfeature}%
  \OParameter{TOC}\OParameter{depth}\Parameter{feature}\Parameter{commands}\\
  \Macro{settocstylefeature}%
  \OParameter{depth}\Parameter{feature}\Parameter{commands}
\end{Description}%
\BeginIndex{Macro}{settocfeature}\BeginIndex{Macro}{settocstylefeature}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{\settocfeature}
\DescribeMacro{\settocstylefeature}
%\iffalse
%</dtx>
%<*doc>
%\fi
These commands are used to set a single feature eiher of all depth of all TOCs
(\Macro{settocfeature} \Parameter{feature} \Parameter{command} or
\Macro{settocstylefeature} \Parameter{feature} \Parameter{commands}), or of
all depth of a single TOC (\Macro{settocfeature}
\OParameter{TOC} \Parameter{feature} \Parameter{commands}), or of a single
depth of all TOCs (\Macro{settocstylefeature}
\OParameter{depth} \Parameter{feature} \Parameter{commands}), or of a single
depth of a single TOC (\Macro{settocfeature} \OParameter{TOC}
\OParameter{depth} \Parameter{feature} \Parameter{commands}).

Parameter \PName{commands} is a list of commands. In most cases these must not
be commands, that need an argument. So you should e.g. not use \Macro{textbf}
but \Macro{bfseries} to switch to bold face. Parameter \PName{feature} is
the feature, that may be configured with parameter \PName{commands}. All known
features are show at \autoref{tab:tocstyle.features}.

\begin{table}
  \centering
  \caption{Features that May Be Set}
  \label{tab:tocstyle.features}
  \begin{desctabular}
    \pventry{dothook}{will be executed before any dot of the dot line}%
    \pventry{entryhook}{hook before the entry will be set}%
    \pventry{entryvskip}{initial vertical skip amount (if not set 0pt plus
      .2pt will be used)}%
    \pventry{leaders}{commands for fillin the gap between entry text and page
      number (if not set the default leaders command with dots will be used)}%
    \pventry{pagenumberbox}{the box command for setting the page number (if
      not set the default box of with \Macro{@pnumwidth} will be used); note,
      that this has to be a command with exactly one argument}%
    \pventry{pagenumberhook}{hook before the page number will be set at the
      page number box}%
    \pventry{parfillskip}{add this amount to the default value of
      \Macro{parfillskip} after setting up all lengths}%
    \pventry{raggedhook}{the only allowed values here are \Macro{raggedright}
      or nothing}%
    \pventry{spaceafternumber}{amount of minimum space after the entry number,
      if the needed width will be calculated automaticly}%
  \end{desctabular}
\end{table}

The order of used commands for a feature is
\begin{enumerate}
\item commands for all depths of all TOCs,
\item commands for all depth of a single TOC,
\item commands for a single depth of all TOCs,
\item commands for a single depth of a single TOC,
\end{enumerate}
and settings of \Macro{usetocstyle} may be overwritten by
\Macro{settocfeature} und \Macro{settocstylefeature}.
%\iffalse
\EndIndex{Macro}{settocfeature}\EndIndex{Macro}{settocstylefeature}%
%\fi
%

\section{Defining New TOC Styles}
\label{sec:tocstyle.define}

Now you know how to select a prefedined TOC style and how to change single
features. But wouldn't it be nice to define your own TOC style?

%\iffalse
\begin{Description}
  \Macro{newtocstyle}\OParameter{parent style}\OParameter{exclude features}%
  \Parameter{new style}%
  \Parameter{\Macro{settocstylefeature}-commands}
\end{Description}%
\BeginIndex{Macro}{\newtocstyle}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{\newtocstyle}
You may do this using \Macro{newtocstyle}\OParameter{parent
  style} \OParameter{exclude features} \Parameter{style
  name} \Parameter{\Macro{settocstylefeature}-commands}.
%\iffalse
%</dtx>
%<*doc>
%\fi
If you used the optional argument \PName{parent style} all features of the
parent style will be part of the new style, before overwriting them with the
features of the \PName{\Macro{settocstylefeature}-commands}. You should not
use any other commands at the last argument. But at \Macro{newtocstyle} the
command \Macro{settocfeature} becomes an alias for \Macro{settocstylefeature}
to avoid to much mistakes.

The second optional argument is a comma seperated list of feature names. If it
is used, these features of the parent style (and all ancestors of the parent)
will not be part of the new style.
%\iffalse
\EndIndex{Macro}{\newtocstyle}%
%\fi

%\iffalse
\begin{Description}
  \Macro{aliastoc}\Parameter{original-TOC}\Parameter{alias-TOC}
\end{Description}%
\BeginIndex{Macro}{\aliastoc}%
You
%</doc>
%<*dtx>
%\fi
\DescribeMacro{\aliastoc}
Using \Macro{aliastoc}\Parameter{original-TOC}\Parameter{alias-TOC} you
%\iffalse
%</dtx>
%<*doc>
%\fi
may define an alias for a TOC. The first argument is the original TOC for that
the second argument should be the alias. An alias-TOC will be processed
with all settings, that were done for the original-TOC. Internally this
command is used as default for the optional, first argument of
\Macro{showtoc}.%
%\iffalse
\EndIndex{Macro}{\aliastoc}
%\fi

\section{Processing a TOC}
\label{sec:tocstyle.processing}

While \LaTeX{} inputs a toc file it processes the commands of the TOC.  These
commands mainly produce the entries of the toc.  Some commands are only
available or valid while a TOC is processed.  But be carefull: Some of these
are read-only commands.  Changing such a read-only command may result in
various errors!

%\iffalse
\begin{Description}
  \Macro{@starttoc}\Parameter{TOC}\\
  \Macro{showtoc}\OParameter{preprocession}\Parameter{TOC}
\end{Description}%
\BeginIndex{Macro}{\@starttoc}%
\BeginIndex{Macro}{\showtoc}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{\@starttoc}%
\DescribeMacro{\showtoc}%
%\iffalse
%</dtx>
%<*doc>
%\fi
The internal comand \Macro{@startoc} is defined by the \LaTeX{} kernel. It is
used by package and class authors to build commands like
\Macro{tableofcontents} or \Macro{listoffigures}. Without using it you will
not get a toc file. \Package{tocstyle} redefines it, to add pre- and
post-processing commands. The original definition found by \Package{tocstyle}
will be used inside the redefinition.

\Macro{showtoc}%
%\iffalse
%</doc>
%<*dtx>
%\fi
\OParameter{preprocession}\Parameter{TOC}%
%\iffalse
%</dtx>
%<*doc>
%\fi
\ is an addition of \texttt{tocstyle}. Using it will procude a copy of TOC and
process this copy. The copy will be done just after creating the original
TOC. The copy will be an alias for the original file. The extension of the
copy is the generated alias if \PName{TOC}. You may generate the alias using
\Macro{aliastoc} at the optional argument of \Macro{showtoc}. The default for
this optional argument will be
\Macro{aliastoc}\Macro{tocstyleTOC}\Macro{tocstyleAliasTOC} and the default
alias \Macro{tocstyleAliasTOC} will be \Macro{tocstyleTOC} extended by a
number.
%\iffalse
\begin{example}
%\fi
The first TOC example at \autoref{sec:tocstyle.options} was made using
\begin{lstcode}
  \showtoc[{%
    \aliastoc{\tocstyleTOC}{toc}%
    \usetocstyle[toc]{standard}%
    \settocfeature[toc]{raggedhook}{\raggedright}%
    \selecttocstyleoption{tocgraduated}%
  }]{toc}
\end{lstcode}
If you want to show a copy of the table of contents, that shows only depth~1 of
the headlines you may simply use:
\begin{lstcode}
  \showtoc[{%
    \expandafter\value{tocdepth}=1\relax
    \aliastoc{\tocstyleTOC}{toc}%
  }]{toc}
\end{lstcode}
or
\begin{lstcode}
  \newcounter{savedtocdepth}
  \setcounter{savedtocdepth}{\value{tocdepth}}
  \setcounter{tocdepth}{1}
  \showtoc{toc}
  \setcounter{tocdepth}{\value{savedtocdepth}}
\end{lstcode}
%\iffalse
\end{example}%
\EndIndex{Macro}{\showtoc}
%\fi

%\iffalse
\begin{Description}
  \Macro{tocstyleTOC}\\
  \Macro{tocstyleAliasTOC}
\end{Description}%
\BeginIndex{Macro}{\tocstyleTOC}%
\BeginIndex{Macro}{\tocstyleAliasTOC}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{\tocstyleTOC}%
\DescribeMacro{\tocstyleAliasTOC}%
%\iffalse
%</dtx>
%<*doc>
%\fi
These are read-only macros. While processing a TOC using \Macro{@starttoc} or
\Macro{showtoc}, \Macro{tocstyleAliasTOC} is the shortcut, that is valid for
the features and \Macro{tocstyleTOC} is valid for the file extension to be
used.%
%\iffalse
\EndIndex{Macro}{\tocstyleAliasTOC}%
\EndIndex{Macro}{\tocstyleTOC}
%\fi

%\iffalse
\begin{Description}
  \Macro{tocstyledepth}
\end{Description}%
\BeginIndex{Macro}{\tocstyledepth}%
%</doc>
%<*dtx>
%\fi
\DescribeMacro{\tocstyledepth}
%\iffalse
%</dtx>
%<*doc>
%\fi
This is a read-only macro. While processing a single toc entry with
\Macro{@dottedtocline} this is the depth (first argument of
\Macro{@dottedtocline}) of this entry. Most users will never need this, but it
is often used internaly. Because of this \emph{you should never change it!}%
%\iffalse
\EndIndex{Macro}{\tocstyledepth}
%\fi

%\iffalse
\begin{Description}
  \Macro{iftochasdepth}\Parameter{TOC}\Parameter{depth}\Parameter{true}%
  \Parameter{false}
\end{Description}
\BeginIndex{Macro}{\iftochasdepth}%
You
%</doc>
%<*dtx>
%\fi
\DescribeMacro{\iftochasdepth}
Using \Macro{iftochasdepth}\Parameter{TOC}\Parameter{depth}\Parameter{true}%
  \Parameter{false} you
%\iffalse
%</dtx>
%<*doc>
%\fi
may test, if an entry of a given depth was already output to a TOC. If so
the commands of argument \PName{true} will be processed. If not so the
commands of argument \PName{false} will be processed.%
%\iffalse
\EndIndex{Macro}{\iftochasdepth}
%\fi

\section{Configuration file}
\label{sec:tocstyle.cfg}

There's another feature for new toc styles. If there's a file
\File{tocstyle.cfg} it will be loaded at the end of the package. This is
usefull to define your own toc styles.

%
%\iffalse
%</doc>
%\fi
%
% \StopEventually{%
%   \clearpage
%   \appendix
%   \addtocontents{toc}{%
%     \value{tocdepth}=\protect\appendixtocdepth\relax}
%   \section{Examples for the Different TOC Styles}
%   Here you will find the table of contents of this document set in the
%   different TOC styles. All are set with option \Option{tocindentauto}.
%^^A   The appendix will be omitted.
%   \subsection{Graduated Versions}
%   First of all all graduated versions of the table of contents
%   \selecttocstyleoption{tocgraduated}%
%   \subsubsection{\PValue{standard} with Option \Option{tocgraduated}}
%   \usetocstyle[toc]{standard}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{KOMAlike} with Option \Option{tocgraduated}}
%   \usetocstyle[toc]{KOMAlike}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{classic} with Option \Option{tocgraduated}}
%   \usetocstyle[toc]{classic}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{allwithdot} with Option \Option{tocgraduated}}
%   \usetocstyle[toc]{allwithdot}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{noonewithdot} with Option \Option{tocgraduated}}
%   \usetocstyle[toc]{noonewithdot}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{nopagecolumn} with Option \Option{tocgraduated}}
%   \usetocstyle[toc]{nopagecolumn}
%   \showtoc{toc}\clearpage
%   \subsection{Flat Versions}
%   Now, all flat versions of the table of contents
%   \selecttocstyleoption{tocflat}%
%   \subsubsection{\PValue{standard} with Option \Option{tocflat}}
%   \usetocstyle[toc]{standard}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{KOMAlike} with Option \Option{tocflat}}
%   \usetocstyle[toc]{KOMAlike}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{classic} with Option \Option{tocflat}}
%   \usetocstyle[toc]{classic}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{allwithdot} with Option \Option{tocflat}}
%   \usetocstyle[toc]{allwithdot}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{noonewithdot} with Option
%     \Option{tocflat}}
%   \usetocstyle[toc]{noonewithdot}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{nopagecolumn} with Option
%     \Option{tocflat}}
%   \usetocstyle[toc]{nopagecolumn}
%   \showtoc{toc}\clearpage
%   \subsection{Fullflat Versions}
%   Now, all full-flat versions of the table of contents
%   \selecttocstyleoption{tocfullflat}%
%   \subsubsection{\PValue{standard} with Option \Option{tocfullflat}}
%   \usetocstyle[toc]{standard}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{KOMAlike} with Option \Option{tocfullflat}}
%   \usetocstyle[toc]{KOMAlike}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{classic} with Option \Option{tocfullflat}}
%   \usetocstyle[toc]{classic}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{allwithdot} with Option \Option{tocfullflat}}
%   \usetocstyle[toc]{allwithdot}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{noonewithdot} with Option
%     \Option{tocfullflat}}
%   \usetocstyle[toc]{noonewithdot}
%   \showtoc{toc}\clearpage
%   \subsubsection{\PValue{nopagecolumn} with Option
%     \Option{tocfullflat}}
%   \usetocstyle[toc]{nopagecolumn}
%   \showtoc{toc}\clearpage
%   \PrintIndex\PrintChanges}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
%    \begin{macrocode}
\PackageWarningNoLine{tocstyle}{%
  THIS IS AN ALPHA VERSION!\MessageBreak
  USAGE OF THIS VERSION IS ON YOUR OWN RISK!\MessageBreak
  EVERYTHING MAY HAPPEN!\MessageBreak
  EVERYTHING MAY CHANGE IN FUTURE!\MessageBreak
  THERE IS NO SUPPORT, IF YOU USE THIS PACKAGE!\MessageBreak
  Maybe it would be better, not to load this package%
}
%    \end{macrocode}
%
% \subsection{Option}
%
% Options change general behaviour of TOCs.
%
% \begin{macro}{\selecttocstyleoption}
%    \begin{macrocode}
\newif\if@tocstyle@penalties
\newif\iftocstyle@autolength
\newif\iftocstyle@indentnotnumbered
\newcount\tocstyle@indentstyle\tocstyle@indentstyle=\z@
\newcommand*{\selecttocstyleoption}[1]{%
  \begingroup
    \edef\@tempa{#1}%
    \edef\@tempb{tocbreaksstrict}%
    \ifx\@tempa\@tempb\aftergroup\@tocstyle@penaltiestrue\else
      \edef\@tempb{tocbreakscareless}%
      \ifx\@tempa\@tempb\aftergroup\@tocstyle@penaltiesfalse\else
        \edef\@tempb{tocindentauto}
        \ifx\@tempa\@tempb\aftergroup\tocstyle@autolengthtrue\else
          \edef\@tempb{tocindentmanual}%
          \ifx\@tempa\@tempb\aftergroup\tocstyle@autolengthfalse\else
            \edef\@tempb{tocgraduated}%
            \ifx\@tempa\@tempb
              \aftergroup\tocstyle@indentstyle\aftergroup\z@
            \else
              \edef\@tempb{tocflat}%
              \ifx\@tempa\@tempb
                \aftergroup\tocstyle@indentstyle\aftergroup\@ne
                \aftergroup\relax
              \else
                \edef\@tempb{tocfullflat}%
                \ifx\@tempa\@tempb
                  \aftergroup\tocstyle@indentstyle\aftergroup\tw@
                  \aftergroup\relax
                \else
                  \edef\@tempb{toctextentriesindented}%
                  \ifx\@tempa\@tempb\aftergroup\tocstyle@indentnotnumberedtrue
                  \else
                    \edef\@tempb{toctextentriesleft}%
                    \ifx\@tempa\@tempb
                      \aftergroup\tocstyle@indentnotnumberedfalse
                    \else
                      \PackageError{tocstyle}{unknown option `#1'}{%
                        You've told me to select toc style option
                        `#1',\MessageBreak
                        but tocstyle doesn't know an option named `#1'}%
                    \fi
                  \fi
                \fi
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \begin{option}{chapter}
% \changes{v3.05}{2009/11/11}{New}
% \begin{option}{nochapter}
% \changes{v3.05}{2009/11/11}{New}
% \begin{macro}{\iftochaschapter}
% \changes{v3.05}{2009/11/11}{New}
% Do we have \cs{chapter} and \cs{l@chapter}?
%    \begin{macrocode}
\newif\iftochaschapter\tochaschapterfalse
\ifcsname l@chapter\endcsname
  \ifcsname chapter\endcsname
    \tochaschaptertrue
  \fi
\fi
%    \end{macrocode}
% \end{macro}
% \end{option}
% \end{option}
%
% \begin{option}{tocbreaksstrict}
% \begin{option}{tocbreakscareless}
% Switch on extended pernalties.
%    \begin{macrocode}
\DeclareOption{tocbreaksstrict}{\selecttocstyleoption\CurrentOption}
\DeclareOption{tocbreakscareless}{\selecttocstyleoption\CurrentOption}
%    \end{macrocode}
% \end{option}
% \end{option}
%
% \begin{option}{tocindentauto}
% \begin{option}{tocindentmanual}
%    \begin{macrocode}
\DeclareOption{tocindentauto}{\selecttocstyleoption\CurrentOption}
\DeclareOption{tocindentmanual}{\selecttocstyleoption\CurrentOption}
%    \end{macrocode}
% \end{option}
% \end{option}
%
% \begin{option}{toctextentriesindented}
% \begin{option}{toctextentriesleft}
%    \begin{macrocode}
\DeclareOption{toctextentriesindented}{\selecttocstyleoption\CurrentOption}
\DeclareOption{toctextentriesleft}{\selecttocstyleoption\CurrentOption}
%    \end{macrocode}
% \end{option}
% \end{option}
%
% \begin{option}{tocgraduated}
% \begin{option}{tocflat}
% \begin{option}{tocfullflat}
%    \begin{macrocode}
\DeclareOption{tocgraduated}{\selecttocstyleoption\CurrentOption}
\DeclareOption{tocflat}{\selecttocstyleoption\CurrentOption}
\DeclareOption{tocfullflat}{\selecttocstyleoption\CurrentOption}
%    \end{macrocode}
% \end{option}
% \end{option}
% \end{option}
%
% Defaults and others:
%    \begin{macrocode}
\ExecuteOptions{tocbreaksstrict,tocindentauto,tocgraduated,%
  toctextentriesleft}
\ProcessOptions\relax
%    \end{macrocode}
%
%    \begin{macrocode}
\ifcsname if@tocleft\endcsname
  \expandafter\let\csname if@tempswa\expandafter\endcsname
  \csname if@tocleft\endcsname
\else
  \@tempswafalse
\fi
\if@tempswa
  \PackageWarningNoLine{tocstyle}{%
    You should not use class option `toc=flat'!\MessageBreak
    This may result in errors or unexpected results.\MessageBreak
    I'll try to deactivate `toc=flat', now.\MessageBreak
    You may use package options `tocflat' and\MessageBreak
    `tocindentauto' instead of `toc=flat'}%
  \csname @tocleftfalse\endcsname
\fi
%    \end{macrocode}
%
%
% \subsection{Body}
%
% There are two parts at \Package{tocstyle}:
% \begin{itemize}
% \item redefining internal \LaTeX{} kernel macros,
% \item defining new macros and redefining class macros.
% \end{itemize}
% Redefining \LaTeX{} kernel macros may not be switched of. But redefining
% class macros will only be on demand.
%
% \subsubsection{Redefining \LaTeX{} Kernel Macros}
%
% Some \LaTeX{} kernel macros must be redefined to add the new
% functionality. Before redefining them, we test against the definition at
% kernel 2005/12/01
%
% \begin{macro}{\@starttoc}
% \begin{macro}{\tocstyle@saved@@starttoc}
% The original definition will be extended by defaults for \cs{parskip},
% \cs{parindent} and % \cs{parfillskip} and storage of the shortcut of the
% current TOC.
%    \begin{macrocode}
\newcommand*\tocstyle@saved@starttoc{}
\let\tocstyle@saved@starttoc\@starttoc
\renewcommand*{\@starttoc}[1]{%
  \tocstyle@pre@starttoc{#1}%
  \tocstyle@saved@starttoc{#1}%
  \tocstyle@post@starttoc{#1}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocstyle@saved@dottedtocline}
% For saving the unchanged definition (at \cs{begin{document}}):
%    \begin{macrocode}
\newcommand*{\tocstyle@saved@dottedtocline}{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tocstyle@dottedtocline}
% Implement new definition and redefine:
%^^A ------ Help me to find the \renecommand*{\@dottedtocline} ----------------
%    \begin{macrocode}
\newcommand*{\tocstyle@dottedtocline}[5]{%
  \let\numberline\tocstyle@numberline
  \ifnum #1>\c@tocdepth \else
%    \end{macrocode}
% Penalty feature: no page break between higher and lower depths.
%    \begin{macrocode}
    \if@tocstyle@penalties
      \begingroup
        \@tempcnta 20010
        \advance \@tempcnta by -#1
        \ifnum \@tempcnta>\lastpenalty
          \aftergroup\penalty\aftergroup\@lowpenalty
        \fi
      \endgroup
    \fi
%    \end{macrocode}
% Activation of all features for this TOC and depth:
%    \begin{macrocode}
    \edef\tocstyledepth{#1}%
    \tocstyle@activate@features
%    \end{macrocode}
% Similar to kernel command but if feature \texttt{entryvskip} was set use
% \cs{addvspace}:
%    \begin{macrocode}
    \ifx\tocstyle@feature@entryvskip\relax
      \vskip \z@ \@plus.2\p@
    \else
      \addvspace{\tocstyle@feature@entryvskip}%
    \fi
    {%
%    \end{macrocode}
% Preinitialization of lengths and skips and then call a hook
%    \begin{macrocode}
      \parskip \z@ \parindent \z@ \leftskip \z@ \rightskip \z@
      \tocstyle@feature@raggedhook
%    \end{macrocode}
% Set number indent to \cs{@tempdimb} and text indent to \cs{@tempdima}.
%    \begin{macrocode}
      \@tempdima #3\relax
      \@tempdimb #2\relax
%<trace>      \typeout{number indent by \string\l@... (\tocstyleTOC, \tocstyledepth): \space\the\@tempdimb}%
%<trace>      \typeout{text indent by \string\l@... (\tocstyleTOC, \tocstyledepth): \space\the\@tempdima}%
%    \end{macrocode}
% \changes{v0.2d}{2009/11/09}{fix: use of max-values}
% Calc auto lengths. Use max. of last run of parents if available.
%     \begin{macrocode}
      \ifnum #1>\z@\relax
        \@tempcnta #1\relax \advance\@tempcnta \m@ne
        \ifcsname tocstyle@maxskipwidth@\tocstyleTOC @\the\@tempcnta\endcsname
          \ifcsname tocstyle@maxnumwidth@\tocstyleTOC @\the\@tempcnta\endcsname
            \@tempdimb 
            \csname tocstyle@maxskipwidth@\tocstyleTOC @\the\@tempcnta\endcsname
            \advance\@tempdimb
            \csname tocstyle@maxnumwidth@\tocstyleTOC @\the\@tempcnta\endcsname
          \fi
        \fi
      \fi
%<trace>      \typeout{number indent by parent (\tocstyleTOC, \tocstyledepth): \space\the\@tempdimb}%
      \ifcsname tocstyle@skipwidth@\tocstyleTOC @#1\endcsname
        \ifdim \@tempdimb>
        \csname tocstyle@skipwidth@\tocstyleTOC @#1\endcsname\relax
          \expandafter\xdef\csname tocstyle@skipwidth@\tocstyleTOC 
          @#1\endcsname{\the\@tempdimb}%
        \fi
      \else
        \expandafter\xdef\csname tocstyle@skipwidth@\tocstyleTOC 
        @#1\endcsname{\the\@tempdimb}%
      \fi
      \iftocstyle@autolength
        \ifcsname tocstyle@maxskipwidth@\tocstyleTOC @#1\endcsname
          \@tempdimb \csname tocstyle@maxskipwidth@\tocstyleTOC @#1\endcsname
          \relax
        \fi
        \ifcsname tocstyle@maxnumwidth@\tocstyleTOC @#1\endcsname
          \@tempdima \csname tocstyle@maxnumwidth@\tocstyleTOC @#1\endcsname
          \relax
        \fi
%<trace>        \typeout{text indent calculated (\tocstyleTOC, \tocstyledepth): \the\@tempdima}%
%<trace>        \typeout{number indent calculated (\tocstyleTOC, \tocstyledepth): \the\@tempdimb}%
      \else
        \@tempdimb #2\relax
%<trace>        \typeout{number indent explicite (\tocstyleTOC, \tocstyledepth): \the\@tempdimb}%
      \fi
      \ifcsname tocstyle@unumwidth@\tocstyleTOC @\endcsname
        \ifdim \@tempdima>
        \csname tocstyle@unumwidth@\tocstyleTOC @\endcsname\relax
          \expandafter\xdef\csname tocstyle@unumwidth@\tocstyleTOC 
          @\endcsname{\the\@tempdima}%
        \fi
      \else
        \expandafter\xdef\csname tocstyle@unumwidth@\tocstyleTOC
        @\endcsname{\the\@tempdima}%
      \fi
      \ifcase\tocstyle@indentstyle\relax\else
        \@tempdimb \z@
        \ifcsname tocstyle@maxunumwidth@\tocstyleTOC @\endcsname
          \@tempdima \csname tocstyle@maxunumwidth@\tocstyleTOC @\endcsname
          \relax
        \fi
%<trace>        \typeout{text noindent (\tocstyleTOC, \tocstyledepth): \the\@tempdima}%
%<trace>        \typeout{number noindent (\tocstyleTOC, \tocstyledepth): \the\@tempdimb}%
      \fi
%    \end{macrocode}
% Advance instead of set, because of the hook above:
%    \begin{macrocode}
      \advance\parindent \@tempdimb\@afterindenttrue
      \advance\leftskip \parindent 
      \advance\rightskip \@tocrmarg 
      \parfillskip -\rightskip
      \ifx\tocstyle@feature@parfillskip\relax\else
        \advance\parfillskip \tocstyle@feature@parfillskip\relax
      \fi
      \interlinepenalty\@M
      \leavevmode
      \advance\leftskip \@tempdima 
      \null\nobreak
%    \end{macrocode}
% \cs{hskip}\cs{-leftskip} optional moved to \cs{numberline}
%    \begin{macrocode}
      \iftocstyle@indentnotnumbered\else
        \hskip -\leftskip
      \fi
%    \end{macrocode}
% Change at start of the entry
%    \begin{macrocode}
      \tocstyle@feature@entryhook
%    \end{macrocode}
% Similar to kernel command but if feature \texttt{leaders} was set use
% this instead of the default leaders. And if feature \texttt{dothook} was set
% (default is \cs{normalfont}) use this at the default leaders.
%    \begin{macrocode}
      {#4}\nobreak
      \ifx\tocstyle@feature@leaders\relax
        \leaders\hbox{$\m@th
          \mkern \@dotsep mu\hbox{\tocstyle@feature@dothook .}%
          \mkern \@dotsep mu$}\hfill
      \else
        \tocstyle@feature@leaders
      \fi
      \nobreak
      \ifx\tocstyle@feature@pagenumberbox\relax
        \hb@xt@\@pnumwidth{\hfil\tocstyle@feature@pagenumberhook #5}%
      \else
        \tocstyle@feature@pagenumberbox{\tocstyle@feature@pagenumberhook #5}%
      \fi
      \par
    }%
%    \end{macrocode}
% Last change is, another penalty change:
%    \begin{macrocode}
    \if@tocstyle@penalties
      \bgroup
        \@tempcnta 20009
        \advance\@tempcnta by -#1
        \edef\reserved@a{\egroup\penalty\the\@tempcnta\relax}%
      \reserved@a
    \fi
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tocstyle@saved@numberline}
% \begin{macro}{\tocstyle@numberline}
%   Define a new \cs{numberline}, that will do all the job after
%   \cs{begin{document}} and one to save the original definition.
%^^A----------------------- \renewcommand*\numberline ------------------------
%    \begin{macrocode}
\newcommand*{\tocstyle@saved@numberline}{}
\newcommand*{\tocstyle@numberline}[1]{%
  \begingroup
    \ifx\tocstyle@feature@spaceafternumber\relax
      \settowidth\@tempdima{\tocstyle@@numberline{#1}\enskip}%
    \else
      \settowidth\@tempdima{\tocstyle@@numberline{#1}}%
      \advance \@tempdima \tocstyle@feature@spaceafternumber\relax
    \fi
    \ifcsname tocstyle@numwidth@\tocstyleTOC @\tocstyledepth\endcsname
      \ifdim \@tempdima >
      \csname tocstyle@numwidth@\tocstyleTOC @\tocstyledepth\endcsname\relax
        \expandafter\xdef\csname tocstyle@numwidth@\tocstyleTOC
        @\tocstyledepth\endcsname{\the\@tempdima}%
      \fi
    \else
      \expandafter\xdef\csname tocstyle@numwidth@\tocstyleTOC
      @\tocstyledepth\endcsname{\the\@tempdima}%
    \fi
  \endgroup
  \iftocstyle@indentnotnumbered
    \hskip -\leftskip
  \fi
  \ifcase \tocstyle@indentstyle
    \hb@xt@\@tempdima{\tocstyle@@numberline{#1}\hfil}%
  \or
    \hb@xt@\@tempdima{\tocstyle@@numberline{#1}\hfil}%
  \else
    \ifx\tocstyle@feature@spaceafternumber\relax
      \hbox{\tocstyle@@numberline{#1}\enskip}%
    \else
      \hbox{\tocstyle@@numberline{#1}\hskip
        \tocstyle@feature@spaceafternumber\relax}%
    \fi
  \fi
}
%    \end{macrocode}
% \begin{macro}{\tocstyle@@numberline}
%   Do the main work!
%    \begin{macrocode}
\newcommand*{\tocstyle@@numberline}[1]{%
  #1\csname autodot\endcsname
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Redefining Class Macros}
%
% \begin{macro}{\l@part}
%   \changes{v2.4}{2009/11/11}{part level is always -1}
% \begin{macro}{\l@chapter}
% \begin{macro}{\l@section}
% \begin{macro}{\l@subsection}
% \begin{macro}{\l@subsubsection}
% \begin{macro}{\l@paragraph}
% \begin{macro}{\l@subparagraph}
% \begin{macro}{\l@table}
% \begin{macro}{\l@figure}
% Try to redefine the toc commands at startup.
%    \begin{macrocode}
\AtBeginDocument{%
  \ifcsname l@part\endcsname
    \setbox\@tempboxa\vbox{\hsize\maxdimen
      \l@part{\tocstyle@l@define{part}{-1}}{}}%
  \fi
  \ifcsname l@chapter\endcsname
    \setbox\@tempboxa\vbox{\hsize\maxdimen
      \l@chapter{\tocstyle@l@define{chapter}{0}}{}}%
  \fi
  \ifcsname l@section\endcsname
    \setbox\@tempboxa\vbox{\hsize\maxdimen
      \l@section{\tocstyle@l@define{section}{1}}{}}%
  \fi
  \ifcsname l@subsection\endcsname
    \setbox\@tempboxa\vbox{\hsize\maxdimen
      \l@subsection{\tocstyle@l@define{subsection}{2}}{}}%
  \fi
  \ifcsname l@subsubsection\endcsname
    \setbox\@tempboxa\vbox{\hsize\maxdimen
      \l@subsubsection{\tocstyle@l@define{subsubsection}{3}}{}}%
  \fi
  \ifcsname l@paragraph\endcsname
    \setbox\@tempboxa\vbox{\hsize\maxdimen
      \l@paragraph{\tocstyle@l@define{paragraph}{4}}{}}%
  \fi
  \ifcsname l@subparagraph\endcsname
    \setbox\@tempboxa\vbox{\hsize\maxdimen
      \l@subparagraph{\tocstyle@l@define{subparagraph}{5}}{}}%
  \fi
  \ifcsname l@table\endcsname
    \setbox\@tempboxa\vbox{\hsize\maxdimen
      \l@table{\tocstyle@l@define{table}{1}}{}}%
  \fi
  \ifcsname l@figure\endcsname
    \setbox\@tempboxa\vbox{\hsize\maxdimen
      \l@figure{\tocstyle@l@define{figure}{1}}{}}%
  \fi
%    \end{macrocode}
% \begin{macro}{\@dottedtocline}
% This will be used even for undotted toc lines. First check the definition,
% then redefine.
%    \begin{macrocode}
  \def\@tempa#1#2#3#4#5{%
    \ifnum #1>\c@tocdepth \else
      \vskip \z@ \@plus.2\p@
      {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
       \parindent #2\relax\@afterindenttrue
       \interlinepenalty\@M
       \leavevmode
       \@tempdima #3\relax
       \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
       {#4}\nobreak
       \leaders\hbox{$\m@th
          \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
          mu$}\hfill
       \nobreak
       \hb@xt@\@pnumwidth{\hfil \normalfont \normalcolor #5}%
       \par}%
    \fi}%
  \ifx\@dottedtocline\@tempa\else
    \tocstyle@macrochangewarning\@dottedtocline
  \fi
  \let\tocstyle@saved@dottedtocline\@dottedtocline
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\numberline}
%   This macro needed to be redefined to calculate the with of the numbers.
%   First of all: check the definition. This is a bit more difficult, because
%   of respecting \KOMAScript:
%    \begin{macrocode}
  \def\@tempa#1{\hb@xt@\@tempdima{#1\autodot\hfil}}%
  \ifx\numberline\@tempa\else
    \def\@tempa#1{\hb@xt@\@tempdima{#1\hfil}}%
    \ifx\numberline@tempa\else
      \tocstyle@macrochangewarning\numberline
    \fi
  \fi
  \let\tocstyle@saved@numberline\numberline
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocstyle@macrochangewarning}
%    \begin{macrocode}
\newcommand*{\tocstyle@macrochangewarning}[1]{%
  \PackageWarningNoLine{tocstyle}{%
    unexpected \string#1\space definition!\MessageBreak
    You are either using an unknown LaTeX kernel\MessageBreak
    version, an unknown class or package, that redefines\MessageBreak
    \string#1, or a \string#1\space
    redefinition\MessageBreak
    at the document preamble.\MessageBreak
    Because of this you may get unexpected results!\MessageBreak
    Maybe it would be better not to use package tocstyle}%
  \PackageInfo{tocstyle}{Unexpected definition is:\MessageBreak
    \meaning#1}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tocstyle@l@define}
% \begin{macro}{\tocstyle@activate@all@l}
%    \begin{macrocode}
\newcommand*{\tocstyle@activate@all@l}{}
\newcommand*{\tocstyle@l@define}[2]{%
  \advance\leftskip-\@tempdima
  \edef\@tempa{%
    \noexpand\global\noexpand\let
    \expandafter\noexpand\csname tocstyle@saved@l@#1\endcsname
    \expandafter\noexpand\csname l@#1\endcsname
    \noexpand\gdef
    \expandafter\noexpand\csname tocstyle@l@#1\endcsname{%
      \noexpand\@dottedtocline{#2}{\the\leftskip}{\the\@tempdima}}%
    \noexpand\g@addto@macro\noexpand\tocstyle@activate@all@l{%
      \noexpand\let\expandafter\noexpand\csname l@#1\endcsname
      \expandafter\noexpand\csname tocstyle@l@#1\endcsname
    }%
  }%
  \PackageInfo{tocstyle}{prepare \expandafter\string 
    \csname l@#1\endcsname\space for redefinition}%
  \@tempa
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{New Macros}
%
% \begin{macro}{\showtoc}
%    \begin{macrocode}
\newcommand*{\showtoc}[2][\aliastoc\tocstyleTOC\tocstyleAliasTOC]{%
  \ifcsname tocstyle@copyname@#2\endcsname
    \@tempcnta \csname tocstyle@copyname@#2\endcsname\relax
    \advance\@tempcnta \@ne
    \expandafter\xdef\csname tocstyle@copyname@#2\endcsname{\the\@tempcnta}%
  \else
    \expandafter\xdef\csname tocstyle@copyname@#2\endcsname{1}%
  \fi
  \ifx\@dofilelist\relax\let\@dofilelist\@empty\fi
  \edef\@tempa{\noexpand\g@addto@macro\noexpand\@dofilelist{%
      \noexpand\tocstyle@copy@toc{#2}{\csname
        tocstyle@copyname@#2\endcsname}}%
  }\@tempa%
  \begingroup
    \edef\tocstyleAliasTOC{#2}%
    \edef\tocstyleTOC{#2\csname tocstyle@copyname@#2\endcsname}%
    #1
    \tocstyle@pre@starttoc{#2\csname tocstyle@copyname@#2\endcsname}%
    \makeatletter
    \@input{\jobname.#2\csname tocstyle@copyname@#2\endcsname}%
    \@nobreakfalse
    \tocstyle@post@starttoc{#2\csname tocstyle@copyname@#2\endcsname}%
  \endgroup
}
%    \end{macrocode}
% \begin{macro}{\tocstyle@copy@toc}
%    \begin{macrocode}
\newcommand*{\tocstyle@copy@toc}[2]{%
  \if@filesw
    \begingroup
      \endlinechar=\m@ne
% While \LaTeX{} does not close the files, we have to do it know.
      \immediate\closeout\csname tf@#1\endcsname
      \immediate\openin\@inputcheck \jobname.#1
      \immediate\openout\@partaux \jobname.#1#2
      \loop\unless\ifeof\@inputcheck
        \immediate\readline\@inputcheck to \@tempa
        \immediate\write\@partaux{\@tempa}%
      \repeat
      \immediate\closeout\@partaux
      \immediate\closein\@inputcheck
    \endgroup
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\aliastoc}
% Internal use not the real TOC shortcut but another one.
%    \begin{macrocode}
\newcommand*{\aliastoc}[2]{%
  \expandafter\edef\csname tocstyle@alias@TOC@#1\endcsname{#2}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tocstyle@pre@starttoc}
% \begin{macro}{\tocstyle@post@starttoc}
% Commands before and after the original \cs{@starttoc}.
%    \begin{macrocode}
\newcommand*{\tocstyle@pre@starttoc}[1]{%
  \begingroup
    \expandafter\ifx\csname tocstyle@deactivated@\endcsname\relax
      \expandafter\ifx\csname tocstyle@deactivated@#1\endcsname\relax\relax
        \tocstyle@activetrue
      \else
        \tocstyle@activefalse
      \fi
    \else
      \tocstyle@activefalse
    \fi
    \iftocstyle@active
      \let\@dottedtocline\tocstyle@dottedtocline
      \parskip \z@
      \parindent \z@
      \parfillskip \z@\@plus 1fil
      \ifcsname tocstyle@alias@TOC@#1\endcsname
        \edef\tocstyleAliasTOC{\csname tocstyle@alias@TOC@#1\endcsname}%
      \else
        \edef\tocstyleAliasTOC{#1}%
      \fi
      \edef\tocstyleTOC{#1}%
      \tocstyle@activate@all@l
    \fi
}
\newcommand*{\tocstyle@post@starttoc}[1]{%
    \iftocstyle@active
      \if@filesw
        \ifcsname tocstyle@unumwidth@#1@\endcsname
          \protected@write\@auxout{}{%
            \protect\tocstyle@set@width{unum}{#1}{}{%
              \csname tocstyle@unumwidth@#1@\endcsname}%
          }%
        \fi
        \expandafter\let\expandafter\@tempa
          \csname tocstyle@depthlist@#1\endcsname
        \ifx\@tempa\relax\else
          \expandafter\@for \expandafter\@tempa\expandafter:\expandafter=\@tempa
          \do {%
            \ifcsname tocstyle@numwidth@#1@\@tempa\endcsname
              \protected@write\@auxout{}{%
                \protect\tocstyle@set@width{num}{#1}{\@tempa}{%
                  \csname tocstyle@numwidth@#1@\@tempa\endcsname}%
              }%
            \fi
            \ifcsname tocstyle@skipwidth@#1@\@tempa\endcsname
              \protected@write\@auxout{}{%
                \protect\tocstyle@set@width{skip}{#1}{\@tempa}{%
                  \csname tocstyle@skipwidth@#1@\@tempa\endcsname}%
              }%
            \fi
          }%
        \fi
      \fi
    \fi
  \endgroup
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocstyle@set@width}
%   \changes{v3.05}{2009/11/11}{improve handling of standard classes}
% Some classes do not use \cs{numberline}. This may result in negativ widths
% (esp. negativ skips). Following special handling of negativ values improves
% the toc handling of the standard classes. Nevertheless indentation of not
% numbered entries does not work with such classes!
%    \begin{macrocode}
\newcommand*{\tocstyle@set@width}[4]{%
  \iftocstyle@indentnotnumbered
    \ifdim #4<\z@
      \expandafter\gdef\csname tocstyle@max#1width@#2@#3\endcsname{%
        \dimexpr #4/2\relax}%
    \else
      \expandafter\gdef\csname tocstyle@max#1width@#2@#3\endcsname{#4}%
    \fi
  \else
    \ifdim #4<\z@
      \expandafter\gdef\csname tocstyle@max#1width@#2@#3\endcsname{\z@}%
    \else
      \expandafter\gdef\csname tocstyle@max#1width@#2@#3\endcsname{#4}%
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tocstyleTOC}
% \begin{macro}{\tocstyleAliasTOC}
%   Shortcut of the current processed TOC. Empty outside of TOCs.
%    \begin{macrocode}
\newcommand*{\tocstyleTOC}{}
\newcommand*{\tocstyleAliasTOC}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocstyledepth}
%   Current depth of the current processed TOC entry.
%    \begin{macrocode}
\newcommand*{\tocstyledepth}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\deactivatetocstyle}%
% \begin{macro}{\reactivatetocstyle}%
%     You may (de)activate all influence of tocstyle either for one or all TOCs.
%    \begin{macrocode}
\newif\iftocstyle@active
\newcommand*{\deactivatetocstyle}[1][]{%
  \expandafter\let\csname tocstyle@deactivated@#1\endcsname\@empty}
\newcommand*{\reactivatetocstyle}[1][]{%
  \expandafter\let\csname tocstyle@deactivated@#1\endcsname\relax}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\settocfeature}
% \begin{macro}{\@settocfeature}
% \begin{macro}{\@@@settocfeature}
% The primary command to set the features of a depth of a TOC.
%    \begin{macrocode}
\newcommand*{\@settocfeature}[1][]{%
  \@ifnextchar[ {\@@settocfeature[{#1}]}{\@@settocfeature[{#1}][]}
}
\def\@@settocfeature[#1][#2]#3#4{%
%<trace>  \typeout{exclude: \tocstyle@feature@excludelist}%
  \@expandtwoargs\in@{,#3,}{,\tocstyle@feature@excludelist,}%
  \ifin@\else
    \expandafter\ifcsname tocstyle@feature@#3\endcsname
      \@namedef{tocstyle@feature@#3@#1@#2}{#4}%
      \begingroup
        \expandafter\let\expandafter\@tempa
        \csname tocstyle@commandlist@#1\endcsname
        \@expandtwoargs\in@{,tocstyle@feature@#3@#1@#2,}{,\@tempa,}%
        \ifin@\let\@tempa\endgroup\else
          \edef\@tempa{\endgroup
            \noexpand\expandafter\noexpand\ifx
            \noexpand\csname tocstyle@commandlist@#1\noexpand\endcsname\relax
              \noexpand\expandafter\noexpand\expandafter\noexpand\expandafter
              \noexpand\def
            \noexpand\else
              \noexpand\expandafter\noexpand\expandafter\noexpand\expandafter
              \noexpand\l@addto@macro
            \noexpand\fi
            \noexpand\csname tocstyle@commandlist@#1\noexpand\endcsname%
            {tocstyle@feature@#3@#1@#2,}}%
        \fi
      \@tempa
    \else
      \PackageError{tocstyle}{unkown feature `#3'}{%
        You've told me to set up toc style feature `#3',\MessageBreak
        but I don't know this feature.\MessageBreak
        See the tocstyle manual for all known feature.\MessageBreak
      }%
    \fi
  \fi
}
\newcommand*{\settocfeature}{}
\let\settocfeature\@settocfeature
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@addto@macro}
% Something like \cs{g@addto@macro} but only with local effect. While other
% packages or classes may also define this, \cs{providecommand} will be used.
%    \begin{macrocode}
\providecommand{\l@addto@macro}[2]{%
  \edef#1{\unexpanded\expandafter{#1#2}}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\settocstylefeature}
% \begin{macro}{\@settocstylefeature}
% Same as above without TOC argument.
%    \begin{macrocode}
\newcommand*{\@settocstylefeature}{%
  \@ifnextchar[ {\@settocfeature[]}{\@settocfeature[][]}%
}
\newcommand*{\settocstylefeature}{}
\let\settocstylefeature\@settocstylefeature
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% Different commands will be defined:
% \begin{macro}{\tocstyle@feature@!<feature!>@@}
% Global feature (all TOCs all depths).
% \end{macro}
% \begin{macro}{\tocstyle@feature@@!<feature!>@!<TOC!>@} 
% All depth feature for one TOC.
% \end{macro}
% \begin{macro}{\tocstyle@feature@@!<feature!>@@!<depth!>}
% All TOCs feature for one depth.
% \end{macro}
% \begin{macro}{\tocstyle@feature@@!<feature!>@!<TOC!>@!<depth!>}
% One depth of one TOC feature.
% \end{macro}
%
% \begin{macro}{\tocstyle@activate@features}
% Activates the features
%    \begin{macrocode}
\newcommand*{\tocstyle@activate@features}{%
  \expandafter\ifx\csname tocstyle@depthlist@\tocstyleTOC\endcsname\relax
    \expandafter\xdef\csname tocstyle@depthlist@\tocstyleTOC\endcsname{%
      \tocstyledepth}%
  \else
    \expandafter\let\expandafter\@tempa
    \csname tocstyle@depthlist@\tocstyleTOC\endcsname
    \@expandtwoargs\in@{,\tocstyledepth,}{,\@tempa,}%
    \ifin@\else
      \expandafter\xdef\csname tocstyle@depthlist@\tocstyleTOC\endcsname{%
        \csname tocstyle@depthlist@\tocstyleTOC\endcsname,\tocstyledepth}%
    \fi
  \fi
  \expandafter\@for \expandafter\@tempa
  \expandafter:\expandafter=\tocstyle@featurelist \do 
  {%
    \@ifundefined{tocstyle@feature@\@tempa @\tocstyleAliasTOC @\tocstyledepth}{%
      \@ifundefined{tocstyle@feature@\@tempa @@\tocstyledepth}{%
        \@ifundefined{tocstyle@feature@\@tempa @\tocstyleAliasTOC @}{%
          \@ifundefined{tocstyle@feature@\@tempa @@}{%
            \expandafter\let\csname tocstyle@feature@\@tempa\endcsname\relax
          }{%
            \expandafter\let\csname tocstyle@feature@\@tempa
            \expandafter\endcsname
            \csname tocstyle@feature@\@tempa @@\endcsname
          }%
        }{%
          \expandafter\let\csname tocstyle@feature@\@tempa
          \expandafter\endcsname
          \csname tocstyle@feature@\@tempa @\tocstyleAliasTOC @\endcsname
        }%
      }{%
        \expandafter\let\csname tocstyle@feature@\@tempa
        \expandafter\endcsname
        \csname tocstyle@feature@\@tempa @@\tocstyledepth\endcsname
      }%
    }{%
      \expandafter\let\csname tocstyle@feature@\@tempa
      \expandafter\endcsname
      \csname tocstyle@feature@\@tempa @\tocstyleAliasTOC @\tocstyledepth\endcsname
    }%
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newtocstyle}
%   Defining a new TOC style. First optional argument is a TOC style, that
%   will be activated before the new definitions. Note that all new
%   definitions will overwirte the parent's definitions. So a new TOC style,
%   that defines all features doesn't need a parent.
%    \begin{macrocode}
\newcommand*{\newtocstyle}{%
  \@ifnextchar [{\@newtocstyle}{\@newtocstyle[]}}
\newcommand*{\@newtocstyle}{}
\def\@newtocstyle[#1]{%
  \@ifnextchar [{\@@newtocstyle[{#1}]}{\@newtocstyle[{#1}][]}}
\newcommand*{\@@newtocstyle}{}
\def\@@newtocstyle[#1][#2]#3#4{%
  \@ifundefined{tocstyle@style@#3}{%
    \@ifundefined{tocstyle@style@#1}{%
      \ifx \relax#1\relax\else
        \PackageError{tocstyle}{unknown parent TOC style `#1'}{%
          You've told me to inheritate parent TOC style `#1',\MessageBreak
          but there's no TOC style `#1' defined.}%
      \fi
      \expandafter\def\csname tocstyle@style@#3\endcsname{#4}%
    }{%
      \expandafter\def\csname tocstyle@style@#3\endcsname{%
        \edef\reserved@a{%
          \noexpand\l@addto@macro\noexpand\tocstyle@feature@excludelist{#2}%
          \noexpand\@usetocstyle{#1}%
          \noexpand\def\noexpand\tocstyle@feature@excludelist{%
            \tocstyle@feature@excludelist}%
        }\reserved@a
        #4%
      }%
    }%
  }{%
    \PackageError{tocstyle}{TOC style `#3' already defined}{%
      You've tried to define a new TOC style `#3',\MessageBreak
      but there's already a TOC style named `#3'.}%
  }%
}
\newcommand*{\tocstyle@feature@excludelist}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\usetocstyle}
% \begin{macro}{\@usetocstyle}
%   \changes{v0.2a}{2008/02/14}{extended for deprecated TOC styles}
%   Use the predefined TOC style. You may define
%   |\tocstyle@deprecated@style@foo| to mark TOC style |foo| to be
%   deprecated.  If |\tocstyle@deprecated@style@foo| is |\@empty| TOC style
%   |deprecated@foo| will be used instead almost silently.   Otherwise TOC
%   style |\tocstyle@deprecated@style@foo| will be used instead and the user
%   will be told about this change.
%    \begin{macrocode}
\newcommand*{\usetocstyle}[2][]{%
  \@ifundefined{tocstyle@deprecated@style@#2}{%
    \@ifundefined{tocstyle@style@#2}{%
      \PackageError{tocstyle}{unknown TOC style `#2'}{%
        You've told me to use TOC style `#2',\MessageBreak
        but there's no TOC style `#2' defined.}%
    }{%
      \def\settocfeature{%
        \@ifnextchar[ %]
        {\@@settocfeature[{#1}]}{\@@settocfeature[{#1}][]}%
      }%
      \let\settocstylefeature\settocfeature
%    \end{macrocode}
% Deactivate all known features for this TOC
%    \begin{macrocode}
      \expandafter\ifx\csname tocstyle@commandlist@#1\endcsname\relax
      \else
        \expandafter\expandafter\expandafter\@for 
        \expandafter\expandafter\expandafter\@tempa
        \expandafter\expandafter\expandafter:%
        \expandafter\expandafter\expandafter=%
        \csname tocstyle@commandlist@#1\endcsname
        \do{%
          \expandafter\let\csname \@tempa\endcsname\relax
        }%
%    \end{macrocode}
% So there are no more known features for this TOC.
%    \begin{macrocode}
        \expandafter\let\csname tocstyle@commandlist@#1\endcsname\relax
      \fi
%    \end{macrocode}
% Activate all known features for this style and TOC
%    \begin{macrocode}
      \@usetocstyle{#2}%
      \let\settocfeature\@settocfeature
      \let\settocstylefeature\@settocstylefeature
    }%
  }{%
    \expandafter\ifx\csname tocstyle@deprecated@style@#2\endcsname\@empty
      \PackageWarning{tocstyle}{%
        deprecated TOC style `#2'!\MessageBreak
        You should not longer use this style,\MessageBreak
        because it will be removed soon.\MessageBreak
        You should select another TOC style}%
      \usetocstyle[{#1}]{deprecated@#2}%
    \else
      \PackageWarning{tocstyle}{%
        deprecated TOC style `#2'!\MessageBreak
        You should use TOC style '\csname
        tocstyle@deprecated@style@#2\endcsname'\MessageBreak
        instead of `#2'}%
    \fi
  }%
}
\newcommand*{\@usetocstyle}[1]{%
  \csname tocstyle@style@#1\endcsname
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocstyle@featurelist}
%   Comma seperated list of all known features
%    \begin{macrocode}
\newcommand*{\tocstyle@featurelist}{%
  pagenumberhook,entryhook,dothook,entryvskip,leaders,raggedhook,%
  spaceafternumber,parfillskip,pagenumberbox,%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tocstyle@feature@pagenumberhook}
% \begin{macro}{\tocstyle@feature@pagenumberhook}
% \begin{macro}{\tocstyle@feature@entryhook}
% \begin{macro}{\tocstyle@feature@dothook}
% \begin{macro}{\tocstyle@feature@entryvskip}
% \begin{macro}{\tocstyle@feature@leaders}
% \begin{macro}{\tocstyle@feature@parfillskip}
% \begin{macro}{\tocstyle@feature@raggedhook}
% \begin{macro}{\tocstyle@feature@spaceafternumber}
%    \begin{macrocode}
\newcommand*{\tocstyle@feature@pagenumberhook}{}
\let\tocstyle@feature@pagenumberhook\relax
\newcommand*{\tocstyle@feature@pagenumberbox}{}
\let\tocstyle@feature@pagenumberbox\relax
\newcommand*{\tocstye@feature@entryhook}{}
\let\tocstyle@feature@entryhook\relax
\newcommand*{\tocstye@feature@dothook}{}
\let\tocstyle@feature@dothook\relax
\newcommand*{\tocstye@feature@entryvskip}{}
\let\tocstyle@feature@entryvskip\relax
\newcommand*{\tocstye@feature@leaders}{}
\let\tocstyle@feature@leaders\relax
\newcommand*{\tocstye@feature@parfillskip}{}
\let\tocstyle@feature@parfillskip\relax
\newcommand*{\tocstye@feature@raggedhook}{}
\let\tocstyle@feature@raggedhook\relax
\newcommand*{\tocstye@feature@spaceafternumber}{}
\let\tocstyle@feature@spaceafternumber\relax
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\iftochasdepth}
% Uses \Macro{tocstyle@depthlist@}\meta{TOC} to test, if the TOC has the depth
% already.
%    \begin{macrocode}
\newcommand*{\iftochasdepth}[2]{%
  \begingroup
    \expandafter\let\expandafter\@tempa\csname tocstyle@depthlist@#1\endcsname
    \ifx\@tempa\relax
      \aftergroup\@secondoftwo
    \else
      \@expandtwoargs\in@{,#2,}{,\@tempa}%
      \expandafter\aftergroup\ifin@
        \@firstoftwo
      \else
        \@secondoftwo
      \fi
    \fi
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Defining Some TOC Styles}
% \changes{v0.2e}{2013/08/11}{usage of new font elements of \KOMAScript\space
%   at \texttt{KOMAlike}}
%
%    \begin{macrocode}
\newtocstyle{standard}{%
  \settocfeature{dothook}{\normalfont}%
  \settocfeature[-1]{entryhook}{\bfseries}%
  \settocfeature[-1]{entryvskip}{2.25em\@plus\p@}%
  \settocfeature[-1]{leaders}{\hfill}%
  \settocfeature[0]{entryvskip}{1em\@plus\p@}%
  \settocfeature[0]{leaders}{\hfill}%
  \settocfeature[0]{entryhook}{\bfseries}
  \iftochaschapter\else
    \settocfeature[1]{entryvskip}{1em\@plus\p@}%
    \settocfeature[1]{leaders}{\hfill}%
    \settocfeature[1]{entryhook}{%
      \begingroup
        \edef\@tempa{toc}%
        \ifx\tocstyleAliasTOC\@tempa\aftergroup\bfseries\fi
      \endgroup
    }%
  \fi
}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname KOMAClassName\endcsname\relax
  \newtocstyle{KOMAlike}{%
    \settocfeature{dothook}{\normalfont}%
    \settocfeature[-1]{entryhook}{\sffamily\bfseries}%
    \settocfeature[-1]{entryvskip}{2.25em\@plus\p@}%
    \settocfeature[-1]{leaders}{\hfill}%
    \settocfeature[-1]{pagenumberhook}{\sffamily\bfseries}%
    \settocfeature[0]{entryvskip}{1em\@plus\p@}%
    \settocfeature[0]{leaders}{\hfill}%
    \settocfeature[0]{entryhook}{\sffamily\bfseries}
    \settocfeature[0]{pagenumberhook}{\sffamily\bfseries}%
    \iftochaschapter\else
      \settocfeature[1]{entryvskip}{1em\@plus\p@}%
      \settocfeature[1]{leaders}{\hfill}%
      \settocfeature[1]{entryhook}{%
        \begingroup
          \edef\@tempa{toc}%
          \ifx\tocstyleAliasTOC\@tempa
            \aftergroup\sffamily\aftergroup\bfseries
          \fi
        \endgroup
      }%
      \settocfeature[1]{pagenumberhook}{%
        \begingroup
          \edef\@tempa{toc}%
          \ifx\tocstyleAliasTOC\@tempa
            \aftergroup\sffamily\aftergroup\bfseries
          \fi
        \endgroup
      }%
    \fi
  }
\else
  \newtocstyle{KOMAlike}{%
    \settocfeature{dothook}{\normalfont}%
    \settocfeature[-1]{entryhook}{\usekomafont{partentry}}%
    \settocfeature[-1]{entryvskip}{2.25em\@plus\p@}%
    \settocfeature[-1]{leaders}{\hfill}%
    \settocfeature[-1]{pagenumberhook}{\usekomafont{partentrypagenumber}}%
    \settocfeature[0]{entryvskip}{1em\@plus\p@}%
    \settocfeature[0]{leaders}{\hfill}%
    \settocfeature[0]{entryhook}{\usekomafont{chapterentry}}%
    \settocfeature[0]{pagenumberhook}{\usekomafont{chapterentrypagenumber}}%
    \iftochaschapter\else
      \settocfeature[1]{entryvskip}{1em\@plus\p@}%
      \settocfeature[1]{leaders}{\hfill}%
      \settocfeature[1]{entryhook}{%
        \begingroup
          \edef\@tempa{toc}%
          \ifx\tocstyleAliasTOC\@tempa
            \def\@tempa{\endgroup\usekomafont{sectionentry}}%
          \else
            \let\@tempa\endgroup
          \fi
        \@tempa
      }%
      \settocfeature[1]{pagenumberhook}{%
        \begingroup
          \edef\@tempa{toc}%
          \ifx\tocstyleAliasTOC\@tempa
            \def\@tempa{\endgroup\usekomafont{sectionentrypagenumber}}%
          \else
            \let\@tempa\endgroup
          \fi
        \@tempa
      }%
    \fi
  }
\fi
\newcommand*{\tocstyle@deprecated@style@KOMAScript}{KOMAlike}%
\newtocstyle[KOMAlike]{classic}{%
  \settocfeature[-1]{pagenumberhook}{\normalfont\normalcolor}%
  \settocfeature[0]{pagenumberhook}{\normalfont\normalcolor}%
  \iftochaschapter\else
    \settocfeature[1]{pagenumberhook}{\normalfont\normalcolor}%
  \fi
  \settocfeature{pagenumberhook}{\normalfont\normalcolor}%
  \settocfeature{raggedhook}{\raggedright}%
}
\newtocstyle[classic][leaders]{allwithdot}{}
\newtocstyle[allwithdot]{noonewithdot}{%
  \settocfeature{leaders}{\hfill}%
}
\newtocstyle[classic][leaders]{nopagecolumn}{%
  \settocfeature{leaders}{\quad}%
  \settocfeature{parfillskip}{\z@ plus 1fil}%
  \settocfeature{pagenumberbox}{\hbox}%
}
%    \end{macrocode}
%
% \subsubsection{Defining Some TOC Styles}
%
% Loading a optional configuration file.
%    \begin{macrocode}
\InputIfFileExists{tocstyle.cfg}{%
  \PackageInfo{tocstyle}{using tocstyle.cfg}%
}{%
  \PackageInfo{tocstyle}{no tocstyle.cfg found}%
}
%    \end{macrocode}
%
% \iffalse
%</package>
% \fi
%
% \Finale
%
\endinput
%
% end of file `tocstyle.dtx'
%%% Local Variables:
%%% mode: doctex
%%% TeX-master: t
%%% End: