summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/etoc/etoc.dtx
blob: 3a4ee52d1b56381be30c5462d197d4227db45f28 (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
% ^^A -*- coding: iso-latin-1; -*-
% \iffalse meta-comment
% 
%    This file may be distributed and/or modified under the
%    conditions of the LaTeX Project Public License, either
%    version 1.2 of this license or (at your option) any later
%    version. The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
%    and version 1.2 or later is part of all distributions of
%    LaTeX version 1999/12/01 or later.
% 
%% Copyright (C) 2012 by Jean-Francois Burnol
%
%            Time-stamp: <18-11-2012 19:35:19 CET jfb>
%
%                          Installation
%
% `latex etoc.dtx' creates (among others) the  file `etoc.sty'.
% `latex etoc.dtx' (again) finishes producing the documentation.
%
%  Put `etoc.sty' in a suitable location within the TeX installation:
%          etoc.sty -> ..suitable..path..to../tex/latex/etoc/
%
%  The other generated files may be discarded.
% 
% \fi
%
% \CheckSum{1873}
%
% \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
%
%<*driver>
\def\pkgdate{2012/11/18}%
\def\pkgversion{v1.02}%
%</driver>
%
%<*batchfile>
\begin{filecontents*}{etoc.ins}
%% Package `etoc' by Jean-Francois Burnol
%%
%% This file `etoc.ins' is provided for compatibility reasons with 
%% TeX installations expecting to find an .ins file
%%
%% It can be used as usual:
%%
%% `latex etoc.ins' extracts `etoc.sty' from `etoc.dtx'
%%
%% But doing directly `latex etoc.dtx' already creates `etoc.sty'
%%
%% `latex etoc.dtx' generates `etoc.sty' (and also `etoc.ins')
%% `latex etoc.dtx' finishes generating the documentation
%%
%% In all cases, put the generated `etoc.sty' file in a suitable
%% location within the TeX installation:
%%   etoc.sty -> ................/tex/latex/etoc/
%%
%% Generated auxiliary files may then be discarded.
%%
\def\batchfile{etoc.ins}
\input docstrip.tex
\askforoverwritefalse
\def\jfpreamble{\defaultpreamble^^J\MetaPrefix^^J%
\string\ProvidesPackage{etoc}^^J%
\space[2012/11/18\space v1.02\space easily customizable TOCs (jfB)]}
\def\jfpostamble{\MetaPrefix\space End of file `\outFileName'.}
\generate{\usepreamble\jfpreamble
\file{etoc.sty}{\from{etoc.dtx}{package}}
\usepostamble\jfpostamble}
\endbatchfile
\end{filecontents*}
\begingroup
\input docstrip.tex
\askforoverwritefalse
\def\jfpreamble{\defaultpreamble^^J\MetaPrefix^^J%
\string\ProvidesPackage{etoc}^^J%
\space[\pkgdate\space\pkgversion\space easily customizable TOCs (jfB)]}
\def\jfpostamble{\MetaPrefix\space End of file `\outFileName'.}
\generate{\usepreamble\jfpreamble
\file{etoc.sty}{\from{etoc.dtx}{package}}
\usepostamble\jfpostamble}
\endgroup
%</batchfile>
%
%<*driver>
\ProvidesFile{etoc.dtx}[\pkgdate\space\pkgversion\space
                   etoc source and documentation (jfB)]
\documentclass[a4paper,12pt]{ltxdoc}
%\OnlyDescription
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[hscale=0.66,vscale=0.75]{geometry}
\usepackage{txfonts}
\usepackage{xspace}
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{color}
\definecolor{joli}{RGB}{225,95,0}
\renewcommand\partname{Part}
\usepackage[%dvipdfmx,% 
pdfencoding=pdfdoc,%
bookmarks=true,%
]{hyperref}
\hypersetup{%
linktoc=all,%
breaklinks=true,%
hidelinks,%
pdfauthor={Jean-Fran\c cois Burnol},%
pdftitle={The etoc package},%
pdfsubject={LaTeX, table of contents},%
pdfkeywords={LaTeX, table of contents},%
pdfstartview=FitH,%
pdfpagemode=UseOutlines}
\usepackage{etoc}
\newcommand\etoc{%
\texorpdfstring{{\color{joli}\ttfamily\bfseries etoc}\xspace}
{\textbackslash etoc\xspace}}
\renewcommand\cs[1]{\texorpdfstring{\csi{#1}}{\textbackslash #1}}
\newcommand\csb[1]{\texorpdfstring{\csbi{#1}}{\textbackslash #1}}
\newcommand\csi[1]{{\ttfamily\hyphenchar\font45\char92#1}}
\newcommand\csbi[1]{{\color{blue}\ttfamily\hyphenchar\font45\char92#1}}
\renewcommand\star{{\ttfamily \raisebox{-.25\height}{*}}}
\newcommand\starit[1]{\csi{#1}\star}
\newcommand\staritb[1]{{\color{blue}\csi{#1}\star}}
\newcommand\tocstar{\starit{tableofcontents}\xspace}
\newcommand\tocstarb{\staritb{tableofcontents}\xspace}
\hyphenation{sec-num-depth toc-num-depth etoc-set-style etoc-set-level 
etoc-set-toc-style etoc-if-num-bered etoc-name etoc-page etoc-number
etoc-framed-style etoc-multi-col-style etoc-ruled-style
etoc-skip-first-pre-fix}
\frenchspacing
\renewcommand\familydefault\sfdefault
\begin{document}
\DocInput{etoc.dtx}
\end{document}
%</driver>
%
% \fi
% \rmfamily
% \begin{center}
%   {\normalfont\Large The \etoc  package}\\
% \textsc{Jean-François Burnol}\par
%   \small \ttfamily 
%   jfbu (at) free (dot) fr\\
%   Package version: \pkgversion\ (\pkgdate).
% \end{center}
% \vskip1cm
% \begin{abstract}
%   The \etoc package gives the user complete control on
%   how the entries of the table of contents should be
%   constituted from the \emph{name}, \emph{number}, and
%   \emph{page number} of each sectioning unit. This goes via
%   the definition of \emph{line styles} for each sectioning
%   level used in the document. The package provides its own
%   custom line styles as an example, next to the standard
%   formatting inherited from the \LaTeX{} document classes. But
%   the idea is to give the means to the user to delegate the
%   details to packages dealing with list making environments
%   (such as |enumitem|). Regarding the \emph{global style},
%   \etoc typesets by default tables of contents in a
%   multi-column format, with either a standard heading, or a
%   ruled title, optionally with a frame around the table of
%   contents. The \cs{tableofcontents} command can be used
%   arbitrarily many times in the same document, and comes with
%   a starred variant which gives local table of contents.
% \end{abstract}
%
% \vskip1cm
% \tableofcontents
%
% \part{Although this is a short document, we are going to use many sectioning commands}
%
% \section{Overview}
%
% Popular packages dealing with TOCs include |tocloft|,
% |titletoc| and |minitoc|. Why another one? well, I started
% \etoc for my own use, and only later found out about the above
% mentioned packages . . . I realize (to some extent, as I still
% haven't read closely the documentations) that most if not all
% of the \etoc functionality could well be already available in
% the above mentioned packages.
%
% \subsection{Initial motivation}
%
% The specific initial impetus was to transform the `flat' data
% contained in the |.toc| file into a nested structure which
% could be given to list making environments. For example,
% typesetting the line corresponding to the first sub-section in
% a given section would open a group which would be closed only
% when a section, chapter, or part line entry in the |.toc| file
% would be encountered. Package \etoc allows to do this very
% easily and the opening and closing of the groups can for
% example be |\begin{enumerate}| and |\end{enumerate}| pairs,
% will all the customizing allowed by packages such as
% |enumitem|. Although there is a limitation to this method (the
% |.toc| file may contain other commands, such as language
% changing commands, which do not expect to see their scope
% limited in this way inside a group), I believe this procedure
% will be found the most convenient in many cases. However the
% own package custom line styles (illustrated by the main table
% of contents in this document) do not make use of environments
% to avoid that problem.
%
% \subsection{Line styles}
%
% To implement the above idea, the command \csb{etocsetstyle}
% will inform \etoc of what it should do at each sectioning
% level, from |part| downto |subparagraph|. Other sectioning
% names can be used too, if present in the document.
%
% \subsubsection{\csb{etocetoclines} vs \csb{etocstandardlines}}
%
% The \csb{etocetoclines} command selects the package predefined
% line styles, and \csb{etocstandardlines} uses the standard
% default formatting from the |article|, |book|, |report|, or
% also |scrartcl| classes. For any document class proceeding (as
% does |scrartcl|) in a manner analogous as does the |article|
% class in its typesetting of the table of contents, the
% \csb{etocstandardlines} should be functional: indeed nothing
% is hard-coded into the package code; rather, when
% \csb{etocstandardlines} is issued by the user, the package
% cancels its own mechanism and gives back the leadership to the
% class layer. Note though that this means that \etoc does not
% provide utilities to change this or that length from the
% \LaTeX{} default formatting of TOC entries. But if some other
% package has done it, then this should work correctly also when
% \etoc is in use (for its other aspects described below).
%
% \subsubsection{Instructing \etoc about sectioning command names}
%
% If the document class uses other names, such as \emph{atom},
% or \emph{particle}, then the command \csb{etocsetlevel} is
% provided to instruct \etoc about it.
%
% \subsection{Global style: multiple columns, ruled heading, framed TOC}
%
% At the global level, the default of \etoc is to typeset the
% TOC on two columns, using the package |multicol|.
% Additionally, the heading can be formatted as in the default
% manner, or as a ruled heading, or the entire TOC can be
% encapsulated in a frame (if it fits on the current page). And
% the user can specify to use a single column output, or three
% columns, etc . . .
%
% \subsection{Local table of contents}
%
% With \etoc, the \csb{tableofcontents} command can be used
% arbitrarily many times and it has a starred variant \tocstarb
% which prints a local table of contents (i.e. all subsections
% etc . . . inside a given section, or all subsubsections and
% lower inside a given subsection, etc . . . ).
%
% \part{Package commands for line styles}
%
% \etocsetstyle{section}
% {\begin{enumerate}[leftmargin=0pt,label=]}
% {\normalsize\bfseries\rmfamily\item}
% {\etocifnumbered{\makebox[1cm][c]{\color{green}\fboxrule1pt
%                   \fbox{\protect\normalcolor\etocnumber}}}{\hspace{1cm}}%
% \etocname (page \etocpage)}
% {\end{enumerate}}
%
% \etocsetstyle{subsection}
% {\begin{enumerate}[label=\etocnumber, leftmargin=1cm]}
% {\normalfont \item}
% {\etocname (p.~\etocpage)}
% {\end{enumerate}}
%
% \etocsetstyle{subsubsection}
% {\par\nobreak\begingroup\normalfont\footnotesize\itshape\etocskipfirstprefix}
% {\allowbreak\,--\,}
% {\etocname}
% {\unskip.\hfil\par\endgroup\pagebreak[3]}
%
% \etocruledstyle[1]{\etocfontminusone\color{green}%
%      \fboxrule1pt\fboxsep1ex%
%      \framebox[\linewidth]
%               {\normalcolor\hfil Contents of this second part\hfil}}
%
% \tableofcontents*
%
% \section{The \csb{etocsetstyle} command}
%
% \subsection{An example}
%
% Let us explain how \etoc was used to produce the (local) table
% of contents of this second part. We distinguish between the
% \emph{line styles}, and the \emph{global style}. The global
% style here is on one column, and has a heading of a certain
% sort, but first we describe the line styles. Essentially they
% were obtained via the following set-up:^^A
% \footnote{the present document has
%   {\ttfamily\string\renewcommand\string{^^A
%    \string\familydefault\string}\string{\string\sfdefault\string}}
%   in its preamble, hence \cs{normalfont} switches to the
%   |sans| typeface; so in the section line-style, I wrote
%   \cs{rmfamily} instead.} \footnote{\etoc uses the |xspace|
%   package, and there is no need to write
%   \cs{etocname\string{\string} text} rather than just
%   \cs{etocname text} for example. However, this forced us to
%   add the mysterious \cs{unskip} before the dot in the
%   subsubsection style.}
% \begin{verbatim}
% \etocsetstyle{section}
% {\begin{enumerate}}
% {\normalsize\bfseries\rmfamily\item}
% {\etocname (page \etocpage)}
% {\end{enumerate}}
%
% \etocsetstyle{subsection}
% {\begin{enumerate}}
% {\normalfont\item}
% {\etocname (p.~\etocpage)}
% {\end{enumerate}}
%
% \etocsetstyle{subsubsection}
% {\par\nobreak\begingroup\normalfont\footnotesize\itshape\etocskipfirstprefix}
% {\allowbreak\,--\,}
% {\etocname}
% {\unskip.\hfil\par\endgroup\pagebreak[3]}
% \end{verbatim}
% Each \csb{etocsetstyle} command has five mandatory arguments:\\
% \hbox to \linewidth
% {\hfil\cs{etocsetstyle}\color{blue}\marg{levelname}^^A
%   \marg{start}\marg{prefix}\marg{contents}\marg{finish}\hfil}
% The initially recognized \marg{levelname}'s are the sectioning
% levels of the standard document classes (from \emph{part}
% downto \emph{subparagraph}). 
%
% The \marg{start} code is executed when a toc entry of that level is
% encountered and the previous one was at a higher level. The
% \marg{finish} code is executed when one again encounters a higher
% level toc entry. In the mean-time all entries for that level are
% typeset by executing first the \marg{prefix} code and then the
% \marg{contents} code. 
%
% \subsubsection{\csb{etocname} and \csb{etocpage}}
%
% The line styles specifications use the commands \csb{etocname}
% and \csb{etocpage} to get the name, respectively the page
% number for each entry. The numbering here would be the one
% generated by the |enumerate| environment, we will shortly
% explain how we got the actual numbering from the data in the
% |.toc| file.
%
%
% \subsubsection{The \csb{etocskipfirstprefix} command}
%
% The |subsubsection| code specifies to list the names of the
% subsubsections from a given subsection in an inline manner,
% with -- as a separator. The command \csb{etocskipfirstprefix},
% which, if present, \emph{must} be the very last one in the
% \emph{start} code, instructs to not use that separator of the
% first item. With this style, one has to be imaginative to
% design something then for paragraph and subparagraph entries!
% perhaps as superscripts? Well, usually one does not need
% paragraphs and subparagraphs numbered and listed in the TOC,
% so our putative user here chose a design where no provision is
% made for them and added the definitive:
% \begin{verbatim}
% \etocsetstyle{paragraph}{}{}{}{}
% \etocsetstyle{subparagraph}{}{}{}{}
% \end{verbatim}
% This is also the situation with the default line styles from the package!
%
% \subsubsection{secnumdepth and tocdepth}
%
% Alternatively, the \LaTeX{} counters |secnumdepth| (which
% decides down to which levels things are numbered and
% automatically written to the |.toc| file) or |tocdepth| (which
% decides the finest level displayed in the table of contents)
% could be used, as they are obeyed by \etoc.
%
%
% \subsection{The \csb{etocsetlevel} command}
%
% If your document uses other sectioning names, such as, for
% example \emph{molecule}, or \emph{atom}, one informs \etoc of
% this via:
% \begin{verbatim}
% \etocsetlevel{cell}{0}
% \etocsetlevel{molecule}{1}
% \etocsetlevel{atom}{2}
% \etocsetlevel{nucleus}{3}
% \end{verbatim}
% The accepted numbers range from -1 to 5 inclusive. The package code
% does:
% \begin{verbatim}
% \etocsetlevel{part}{-1}
% \etocsetlevel{chapter}{0}
% \etocsetlevel{section}{1}
% \etocsetlevel{subsection}{2}
% \etocsetlevel{subsubsection}{3}
% \etocsetlevel{paragraph}{4}
% \etocsetlevel{subparagraph}{5}
% \end{verbatim}
%
% \subsection{Further informations and let's make this a very long title to see how it will look like}
%
%
% \subsubsection{The \csb{etocnumber} command}
% So far, our specifications would use the numbering generated
% by the |enumerate| environments, but it would be nicer to use
% the actual numbers as found in the |.toc| file. This is
% available via the \csb{etocnumber} command. To get the labels
% in the |enumerate| list to use it we can proceed with the
% syntax {\ttfamily label=\char32} from the package |enumitem|:
% \begin{verbatim}
% \etocsetstyle{section}
% {\begin{enumerate}[label=\etocnumber]}
% {\normalsize\bfseries\rmfamily\item}
% {\etocname (page \etocpage)}
% {\end{enumerate}}
% \end{verbatim}
% Rather than just\cs{etocnumber} we then used something like
% |\fbox{\etocnumber}|.
%
%
% \subsubsection{The \csb{etocifnumbered} switch}
%
% The \cs{fbox} would give an unaesthetic result in the case of an unnumbered
% section (which ended up in the table of contents via an \cs{addcontentsline}
% command). The \cs{etocifnumbered}\marg{A}\marg{B} command executes \meta{A} if
% the number exists, and \meta{B} if not. So our final code could be:
% \begin{verbatim}
% \etocsetstyle{section}
% {\begin{enumerate}[label=\etocifnumbered{\etocnumber}{}]}
% {\normalsize\bfseries\rmfamily\item}
% {\etocname (page \etocpage)}
% {\end{enumerate}}
% \end{verbatim}
% \vskip-.5cm
% We used, actually:
% \begin{verbatim}
% \etocsetstyle{section}
% {\begin{enumerate}[leftmargin=0pt,label=]}
% {\normalsize\bfseries\rmfamily\item}
% {\etocifnumbered{\makebox[1cm][c]{\color{green}\fboxrule1pt
%        \fbox{\protect\normalcolor\etocnumber}}{\hspace{1cm}}%
% \etocname (page \etocpage)}
% {\end{enumerate}}
%
% \etocsetstyle{subsection}
% {\begin{enumerate}[label=\etocnumber, leftmargin=1cm]}
% {\normalfont \item}
% {\etocname (p.~\etocpage)}
% {\end{enumerate}}
% \end{verbatim}
%
% If we had changed only the |section| level, and not the
% |subsection| level, an error on compilation would have occurred
% because the package style for subsections expects to start `in
% vertical mode'. An additional \cs{par} token in the
% \meta{contents} part of the |section| level would have fixed
% this: |{...(page \etocpage)\par}|.
%
%
% \color{red}
% \addtocontents{toc}{\string\color{red}}
%
% \subsubsection{This is a red subsubsection for illustrative purposes}
%
% Just before this subsubsection we inserted in the |.tex| file:
% \begin{verbatim}
% \color{red}
% \addtocontents{toc}{\string\color{red}}
% \end{verbatim}
% This entire subsubsection and its title is printed in red, as
% well as the title of the next section (we cancel the color
% change only after it). But what about its entry in the table
% of contents? well it is red in the main table of contents at
% the beginning of this document, which uses the package line
% styles, and it is not red in the table of contents at the
% beginning of this second document part. The reason is that the
% \meta{finish} code for the subsubsection level closed a group,
% whereas the \meta{start} and \meta{finish} code of the package
% line styles do not contain group opening and closing
% instructions. So here the group was closed while reading the
% |.toc| file and this explains why the next entry in the local
% TOC was not typeset in red.
%
% In the present case the group at the subsubsection level is
% there to confine the font changes, but this could be made
% superfluous via adding a \cs{normalsize} to the
% |subsection| specification. I take this opportunity to mention
% that \etoc always typesets the entire table of contents inside
% a group, hence no font change therein can propagate to the outside.
%
%
% \section{Am I also in red?}
%
% \begin{verbatim}
% \normalcolor
% \addtocontents{toc}{\string\normalcolor}
% \end{verbatim}
%
% \normalcolor
% \addtocontents{toc}{\string\normalcolor}
%
% Back to black. Note that this scope problem arises in real
% life in a multi-lingual document, as the |babel| package
% writes to the |.toc| file the language changes occurring in
% the document. There is no easy general solution\footnote{one
%   can insert by hand the language changes in each concerned
%   sectioning command.} to this problem, which probably will
% concern only a minority of cases. Again, the line styles
% defined by \etoc do not use groups.
%
% \section*{An unnumbered section}
% \addcontentsline{toc}{section}{An unnumbered section}
%
% I don't have much to say here. I just added an unnumbered
% section, and made it appear in the |.toc| file.
%
% \begin{verbatim}
% \section*{An unnumbered section}
% \addcontentsline{toc}{section}{An unnumbered section}
% \end{verbatim}
%
% \part{Package commands for global styles}
%
% We compare here various line styles: the standard formatting
% provided by the document class, the package line styles, and
% the custom line styles we defined above which use enumerate
% environments. We added some paragraphs, which are not taken
% into account by the \etoc style, nor by our enumerate styles.
%
% \begin{verbatim}
% \setcounter{secnumdepth}{4}
% \setcounter{tocdepth}{4}
% \end{verbatim}
%
% \setcounter{secnumdepth}{4}
% \setcounter{tocdepth}{4}
%
% \etocruledstyle[2]{\normalfont\normalsize\rmfamily\itshape
%  \fbox{\parbox{.8\linewidth}{This is the
%       table of contents defined with enumerate environments for the part,
%       section and subsection levels, and an inline italic style for
%       subsubsections.}}}
%
% First let us use again our set-up from the previous part. We add to it 
% \begin{verbatim}
% \etocsetstyle{part}
% {\begin{enumerate}[label=\etocnumber,leftmargin=1em]}
% {\etocfontminusone\item}
% {\etocname}
% {\end{enumerate}}
% \end{verbatim}
%
% \etocsetstyle{part}
% {\begin{enumerate}[label=\etocnumber,leftmargin=1em]}
% {\etocfontminusone\item}
% {\etocname}
% {\end{enumerate}}
%
% \tableofcontents
%
% Then we switch to the standard formatting of entries, as
% provided by the document class, but here on two columns:
% \begin{verbatim}
% \etocstandardlines
% \tableofcontents
% \end{verbatim}
%  (let's clear the present page) \clearpage
% \etocstandardlines
% \etocruledstyle[2]{\renewcommand{\etoctoprule}{\hrule height0pt}^^A
% \normalfont\normalsize\rmfamily\itshape 
% \parbox{.8\linewidth}{\centering 
% This is the table of contents with standard
%   entries (on 2 columns!)}}
%
% \tableofcontents
%
% Finally we use the package line styles, but restrict the table
% of contents to this third part, and as it is short we opted
% for a frame around it.
% \begin{verbatim}
% \etocetoclines
% \tableofcontents*
% \end{verbatim}
% How the frame and title were set up will be described later. Also,
% we reduced the package default left and right inner margins from 2em to 2ex.
%
% \etocframedstyle{\normalfont\normalsize\rmfamily\itshape
%   \fbox{\parbox{.8\linewidth}{\centering This is the table of
%       contents \`a la \etoc, but just for this part. As it is
%       put in a frame, it has to be small enough to fit on one
%       page.}}} \etocetoclines
%
% \begingroup \renewcommand{\etocinnerleftsep}{2ex}
% \renewcommand{\etocinnerrightsep}{2ex}
% \tableofcontents*
% \endgroup
%
% \section{Specifying the global style}
%
% The \emph{global} style says whether the TOC appears with
% multiple columns or just one, whether the title is typeset as
% in the |article| or |book| class, or should be centered above
% the entries, with rules on its sides, or if the entire TOC
% should be put in a frame. For example, to opt for a ruled
% heading and single column layout, one issues commands of the
% following type:
% \begin{verbatim}
% \etocruledstyle[1]{\etocfontminusone This is the table of contents}
% \tableofcontents or \tableofcontents*
% \end{verbatim}
%
% \subsection{The \csb{etocfontxxx...} commands}
%
% The \cs{etocfontminusone} gives the font specification for the
% top (i.e. part) level. The package predefines:
% \begin{verbatim}
% \newcommand\etocfontminusone{\normalfont \large \bfseries}
% \newcommand\etocfontzero{\normalfont \normalsize \bfseries}
% \newcommand\etocfontone{\normalfont \normalsize \bfseries}
% \newcommand\etocfonttwo{\normalfont \normalsize}
% \newcommand\etocfontthree{\normalfont \footnotesize}
% \newcommand\etocfontfour{\normalfont \footnotesize}
% \newcommand\etocfontfive{\normalfont \footnotesize}
% \end{verbatim}
% This has no impact under the \cs{etocstandardlines} regime.
% And, let us recall, levels four (paragraph) and five
% (subparagraphs) are not displayed in TOCs by the package
% default line styles.
%
%
% \subsection{The command \csb{etocruledstyle}}
%
% The general format of \cs{etocruledstyle} is:\\
% \centerline{\color{blue}\cs{etocruledstyle}^^A
% \oarg{number of columns}\marg{title of the toc}}
% \noindent Note that the title is horizontal material, if it does not fit on one
% line it can be put in a \cs{parbox} of a given width. We did this and even
% enclosed the parboxes in \cs{fbox}es to get frames around them. For the example
% with the standard formatting we did not use an \cs{fbox} and got rid of the
% horizontal rules via:
% \begin{verbatim}
% \renewcommand{\etoctoprule}{\hrule height 0pt}
% \end{verbatim}
% The green frame for the table of contents heading at the start of the second
% part of this document was obtained with
% \begin{verbatim}
% \etocruledstyle[1]{\etocfontminusone\color{green}%
%      \fboxrule1pt\fboxsep1ex%
%      \framebox[\linewidth]
%               {\normalcolor\hfil Contents of this second part\hfil}}
% \end{verbatim}
%
%
% \subsection{The command \csb{etocmulticolstyle}}
%
% This is also a command with one optional and one mandatory argument:\\
% \centerline{\color{blue}\cs{etocmulticolstyle}\oarg{number\_of\_columns}\marg{heading}}
% The \oarg{number\_of\_columns} can go from 1 to 10 (it defaults to 2, and from 2
% on is passed to a |multicols| environment). The \marg{heading} can be something like:
% \begin{center}
%   {\ttfamily\string\chapter\star}\marg{title},\\ 
%  or\\
% \cs{etocstandardheading}\marg{title},\\
% or\\
%  \cs{etocstandardheadingnomarks}\marg{title}.
% \end{center}
% These last two commands do either \starit{section} or
% \starit{chapter} depending on the document class, and the
% first one puts the marks for the page headings. To emulate the
% standard formatting one can thus use:\\
% \centerline{\ttfamily\string\etocmulticolstyle[1]\string{^^A
% \string\etocstandardheading\string{\string\contentsname\string}\string}}
% After such a command, future \cs{tableofcontents} will use the
% specified style. A shortcut for just one table of contents and
% not affecting the styles of later TOCs is:\\
% \centerline{\cs{etocmulticol}\oarg{number\_of\_columns}\marg{heading}}
% And the starred form will be
% \starit{etocmulticol}\oarg{number\_of\_columns}\marg{heading}.
%
% \subsubsection{A point of some importance}
%
% There is an important difference between the
% \cs{etocmulticolstyle} and \cs{etocruledstyle} commands. The
% mandatory argument of the former can not be just some
% \emph{naked text}. It should rather be something like
% |\hbox{naked text}| or |\vbox{naked text}|. 
% ^^A
% More conveniently, one can use things such as:\\
% \hbox to \linewidth{\hss |\section*{some not so naked text}|\hss} 
% Else, you will get an error:\\
% \hbox to \linewidth{\hss |ERROR: LaTeX Error: Something's wrong--perhaps a missing \item.|\hss}
% In the special case where the command was
% also given the optional argument |[1]|,
% it is possible to feed it with `|naked text\par|'.
% %
%
% On the other hand, it is exactly the opposite for \cs{etocruledstyle} which
% expects things which fit inside a horizontal box, hence it will gladly accepts a
% \emph{naked text} as argument.
%
%
% \paragraph{Do we really want paragraph entries in the TOC?}
%
% \paragraph{really?}
%
% \subsection{The command  \csb{etocruledstyle} (cont.)}
%
%
% As a shortcut to set the style with this command and then make a
% \cs{tableofcontents} or \tocstar call (in a group, so that the
% style for future table of contents is not affected) we have: \\
% \centerline{\csb{etocruled}\oarg{number\_of\_columns}\marg{title}}
% And the starred form will be with \staritb{etocruled}.
%
% \subsection{The command \csb{etocframedstyle}}
%
% Same mechanism:\\
% \centerline{\color{blue}\cs{etocframedstyle}\oarg{number\_of\_columns}\marg{title}}
% and the accompanying shortcut:\\
% \centerline{\csb{etocframed}\oarg{number\_of\_columns}\marg{title}}
% Here the entire table of contents is framed, hence this can only work if it fits
% on a page. Again the starred variant starts with \staritb{etocframed}.
%
% \subsection{The command \csb{etocsettocstyle}}
%
% This is a command with two mandatory arguments:\\
% \centerline{\color{blue}\cs{etocsettocstyle}\marg{before\_toc}\marg{after\_toc}}
% The \marg{before\_toc} part is responsible for typesetting the
% heading, for example it can be something like
% \starit{section}|{\contentsname}|. It can also contain
% instructions to mark the page headings.\footnote{\etoc
%   provides the command \cs{etocmarkboth}\oarg{optional\_name}, with an
%   optional argument which defaults to \cs{contentsname}.} Or
% it could check (book class) to see if two-column mode is on,
% and switch to one-column style, and the \meta{after\_toc} part
% would then reenact the two-column mode.\footnote{In our
%   testing, we had some difficulties, when using the |multicol|
%   package in a book class document with the two-column global
%   option. So, as we use |multicol| by default we decided
%   against trying to automatize a check for such a possible
%   |twocolumn| class option. It is up to the user to decide (or
%   not) to switch back and forth from two-column to one-column
%   when typesettings table of contents.}
%
% The three commands \cs{etocmulticolstyle}, \cs{etocruledstyle}, and
% \cs{etocframedstyle} actually call \cs{etocsettocstyle} as a
% lower-level routine.
% \clearpage
% \section{Summary of the main  local and global style
%   commands}
%
% {\color{green}\fboxrule1pt\fboxsep1em
% \setbox0\hbox{\cs{etocname}, \cs{etocnumber}, \cs{etocpage},
% \cs{etocifnumbered}\marg{A}\marg{B}}^^A
% \framebox[\linewidth][c]{^^A
% \vbox{\hsize\wd0\normalcolor\noindent
% \cs{etocsetstyle}\marg{levelname}^^A
%   \marg{start}\marg{prefix}\marg{contents}\marg{finish}\\
% \cs{etocname}, \cs{etocnumber}, \cs{etocpage},
% \cs{etocifnumbered}\marg{A}\marg{B}\\
% \cs{etocmulticolstyle}\oarg{number\_of\_columns}\marg{heading}\\
% \cs{etocruledstyle}\oarg{number\_of\_columns}\marg{title}\\
% \cs{etocframedstyle}\oarg{number\_of\_columns}\marg{title}\\
% \cs{etocsettocstyle}\marg{before\_toc}\marg{after\_toc}\\
% \cs{tableofcontents}\\ 
% \tocstar\\
% \cs{etocmulticol}\oarg{number\_of\_columns}\marg{heading}\\
% \cs{etocmulticol}\star\oarg{number\_of\_columns}\marg{heading}\\
% \cs{etocruled}\oarg{number\_of\_columns}\marg{title}\\
% \cs{etocruled}\star\oarg{number\_of\_columns}\marg{title}\\
% \cs{etocframed}\oarg{number\_of\_columns}\marg{title}\\
% \cs{etocframed}\star\oarg{number\_of\_columns}\marg{title}}}}
%
%
%
% \part{Customizing \etoc}
%
% \section{Customizing  the \etoc line styles}
%
% We will simply list the relevant commands as defined in the package. Customizing
% them goes through suitable \cs{renewcommand}s:
%
% \begin{verbatim}
% \newcommand\etocfontminusone{\normalfont \large \bfseries}
% \newcommand\etocfontzero{\normalfont \normalsize \bfseries}
% \newcommand\etocfontone{\normalfont \normalsize \bfseries}
% \newcommand\etocfonttwo{\normalfont \normalsize}
% \newcommand\etocfontthree{\normalfont \footnotesize}
% \newcommand\etocfontfour{\normalfont \footnotesize}
% \newcommand\etocfontfive{\normalfont \footnotesize}
%
% \newcommand\etocsepminusone{4ex plus .5ex minus .5ex}
% \newcommand\etocsepzero{2.5ex plus .4ex minus .4ex}
% \newcommand\etocsepone{1.5ex plus .3ex minus .3ex}
% \newcommand\etocseptwo{1ex plus .15ex minus .15ex}
% \newcommand\etocsepthree{.25ex plus .05ex minus .05ex}
% \newcommand\etocminusonelrmargins{1em}
%
% \newcommand\etocbaselinespreadminusone{1}
% \newcommand\etocbaselinespreadzero{1}
% \newcommand\etocbaselinespreadone{1}
% \newcommand\etocbaselinespreadtwo{1}
% \newcommand\etocbaselinespreadthree{.9}
%
% \newcommand\etoctoclineleaders
% {\hbox{\normalfont\normalsize\hbox to 2ex {\hfil.\hfil}}}
%
% \newcommand\etocabbrevpagename{p.~}
% \end{verbatim}
%
% No customizing of the standard line styles is possible from
% within \etoc. As already explained, when
% \cs{etocstandardlines} has been issued, the package just makes
% itself very discrete and acts only at the global level, and
% the TOC entries are (hopefully) formatted as would have
% happened in the absence of \etoc. In this mode the
% \cs{etocsetstyle} commands will have an effect only after the
% document encounters again an \cs{etocetoclines} command.
%
% The \cs{etocstandardlines} mechanism will work also with
% sectioning commands made known to \etoc via \cs{etocsetlevel},
% under the condition of course that these sectioning commands
% are accompanied with all the relevant definitions for
% typesetting toc entries in the \LaTeX{} default manner
% (existence of the macros \cs{l@something} . . .).
%
% \section{Customizing the global styles}
%
% Again we list the relevant macros, what they do should be legible from their
% names:
% \begin{verbatim}
% \newcommand\etocabovetocskip{3.5ex plus 1ex minus .2ex} 
% \newcommand\etocbelowtocskip{3.5ex plus 1ex minus .2ex}
%
% \newcommand\etoccolumnsep{2em}
% \newcommand\etocmulticolsep{0ex}
% \newcommand\etocmulticolpretolerance{-1}
% \newcommand\etocmulticoltolerance{200}
%
% \newcommand\etocinnertopsep{2ex}
% \newcommand\etocinnerbottomsep{3.5ex}
% \newcommand\etocinnerleftsep{2em}
% \newcommand\etocinnerrightsep{2em}
%
% \newcommand\etoctoprule{\hrule}
% \newcommand\etocleftrule{\vrule}
% \newcommand\etocrightrule{\vrule}
% \newcommand\etocbottomrule{\hrule}
%
% \newcommand\etoctoprulecolorcmd{\relax}
% \newcommand\etocbottomrulecolorcmd{\relax}
% \newcommand\etocleftrulecolorcmd{\relax}
% \newcommand\etocrightrulecolorcmd{\relax}
% \end{verbatim}
%
% Regarding the dimensions of the top rule they can be specified
% in |ex|'s or |em|'s as for example:\\
% \hbox to \linewidth{\hss |\renewcommand{\etoctoprule}{\hrule height 1ex}|\hss}
% The package code is done in such a way that it is the font
% size in instance at the end of typesetting the title argument
% to \cs{etocruledtoc} or \cs{etocframedtoc} which will be used
% for the meaning of the `1ex'. However for the side rules and
% bottom rule in the framed case, their dimensions, if specified
% with such font relative units, are decided on the basis of the
% font in effect just before the table of contents.
%
% The top, bottom, left, right rules do not have to be rules: they can be
% \emph{leaders} in the general \TeX{} sense.
%
% \subsection{Hacking  framed parboxes}
%
% \begin{verbatim}
% \renewcommand\etoctoprule{\hrule height 2pt depth 2pt}
% \etocruled*[3]{\color{green}\fboxrule2pt\fboxsep1ex%
%      \fbox{\raisebox{-\fontdimen22\textfont2}
%                     {\color{blue}\parbox{.5\linewidth}
%                        {\normalfont This text is perfectly centered
%                         vertically with respect to the
%                         surrounding horizontal rules, but as
%                         there are no subsubsections here, it
%                         sits above an empty (3-column) local toc.}}}}
% \end{verbatim}
%
% \renewcommand\etoctoprule{\hrule height 2pt depth 2pt}
% \etocruled*[3]{\color{green}\fboxrule2pt\fboxsep1ex^^A
%      \fbox{\raisebox{-\fontdimen22\textfont2}
%                     {\color{blue}\parbox{.5\linewidth}
%                        {\normalfont This text is perfectly centered
%                         vertically with respect to the
%                         surrounding horizontal rules, but as
%                         there are no subsubsections here, it
%                         sits above an empty (3-column)
%                         local toc.}}}}
%
% \subsection{Interverting the levels}
%
% Let us display and count all subsections occurring in this document. 
% \begin{verbatim}
% \setcounter{tocdepth}{2}
% \etocsetlevel{part}{3}
% \etocsetlevel{section}{3}
% \etocsetstyle{subsection}{\begin{enumerate}[itemsep=0pt,%
% label=,leftmargin=0pt]}
% {\normalfont\bfseries\item}
% {\roman{enumi}. \normalfont\etocname (\etocnumber, p.~\etocpage)}
% {\end{enumerate}}
% \renewcommand{\etoccolumnsep}{2.75em}
% \renewcommand{\columnseprule}{1pt}
% \etocmulticol[3]{\subsection{All subsections of this document}}
% \end{verbatim}
%
% \setcounter{tocdepth}{2}
% \etocsetlevel{part}{3}
% \etocsetlevel{section}{3}
% \etocsetstyle{subsection}{\begin{enumerate}[itemsep=0pt,^^A
% label=,leftmargin=0pt]}
% {\normalfont\bfseries\item}
% {\roman{enumi}. \normalfont\etocname (\etocnumber, p.~\etocpage)}
% {\end{enumerate}}
% \renewcommand{\etoccolumnsep}{2.75em}
% \renewcommand{\columnseprule}{1pt}
% \etocmulticol[3]{\subsection{All subsections of this document}}
%
%
% \subsection{Compatibility with other packages}
%
% \etoc uses the packages |multicol| and |xspace|. It is
% |hyperref| aware and hopefully |hyperref| compatible! The
% macros \cs{etocname}, \cs{etocnumber}, and \cs{etocpage}
% contain the |hyperref| links, if present (note that the
% |linktoc=all| option of |hyperref| tells it to put a link also
% in the page number corresponding to a given toc entry). The
% table of contents of the present document are fully linked.
%
% \etoc has not been tested with other packages than those
% cited. It has been tested to work as expected with the
% |article|, |book| and |scrartcl| document classes.
%
%
% \subsection{\TeX nical matters}
%
% The \cs{etocname}, \cs{etocnumber}, \cs{etocpage} and
% \cs{etocifnumbered} macros are protected against premature
% expansion. The macro \cs{etocsetstyle}, as well as \cs{etocsetlevel}
% and the global style commands \cs{etocmulticolstyle},
% \cs{etocruledstyle} and \cs{etocframedstyle} obey \LaTeX{}'s groups.
%
% \part{The code}
%
% \section{Implementation}
% 
% Source code commenting is hopefully for a future release.  Sorry.
% \StopEventually{}
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
%
\RequirePackage{multicol}
\RequirePackage{xspace}
\DeclareOption*{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}}
\ProcessOptions\relax
%
\newtoks\Etoc@toctoks
\newif\ifEtoc@j   % part  
\newif\ifEtoc@    % chapter
\newif\ifEtoc@i   % section
\newif\ifEtoc@ii  % subsection
\newif\ifEtoc@iii % subsubsection
\newif\ifEtoc@iv  % paragraph
\newif\ifEtoc@v   % subparagraph
\newif\ifEtoc@number
\newif\ifEtoc@hyperref
\newif\ifEtoc@star
\newif\ifEtoc@standard
\newif\ifEtoc@part 
%
\newif\ifEtoc@localtoc
\newif\ifEtoc@skipthisone
\newif\ifEtoc@stoptoc
\newif\ifEtoc@notactive
\newcounter{etoc@localtocid}
%
\let\Etoc@@minusone@@\m@ne
\chardef\Etoc@@zero@@\z@
\chardef\Etoc@@one@@\@ne
\chardef\Etoc@@two@@\tw@
\chardef\Etoc@@three@@\thr@@
\chardef\Etoc@@four@@4\relax
\chardef\Etoc@@five@@5\relax
\chardef\Etoc@@six@@6\relax
\let\Etoc@localtop\m@ne
\def\Etoc@@minusone@{minusone}
\def\Etoc@@zero@{zero}
\def\Etoc@@one@{one}
\def\Etoc@@two@{two}
\def\Etoc@@three@{three}
\def\Etoc@@four@{four}
\def\Etoc@@five@{five}
%
\def\Etoc@Lazarus{%
\def\Etoc@Lazarus@elta##1\Etoc@Lazarus@eltb##2{\let##1##2}%
\Etoc@Lazaruslist}
\def\Etoc@Lazaruslist{}
%
\def\Etoc@newdisciple#1#2{% 
    \def\Etoc@Lazarus@elta{\noexpand\Etoc@Lazarus@elta\noexpand}%
    \def\Etoc@Lazarus@eltb{\noexpand\Etoc@Lazarus@eltb\noexpand}%
    \edef\Etoc@Lazaruslist{\Etoc@Lazaruslist
                           \Etoc@Lazarus@elta#1
                           \Etoc@Lazarus@eltb#2}}
\def\etocsetlevel#1#2{%
 \let\Etoc@next\@firstofone
 \ifcase#2\or\or\or\or\or\else\ifnum#2=\m@ne\else
    \PackageWarning{etoc}
    {unexpected value `#2' in \string\etocsetlevel.^^J%
    Should be -1, 0, 1, 2, 3, 4 or 5. Set to -1}%
     \expandafter\def\csname Etoc@#1@\endcsname{minusone}%
     \expandafter\let\csname Etoc@#1@@\endcsname\m@ne
 \let\Etoc@next\@gobble\fi\fi
 \if@noskipsec 
 \else
    \expandafter\expandafter\expandafter
    \let\expandafter\expandafter\csname Etoc@savedl@#1\endcsname
               \csname l@#1\endcsname
    \expandafter\let \csname l@#1\endcsname\Etoc@lxyz
 \fi
 \expandafter\expandafter\expandafter\Etoc@newdisciple
 \expandafter\expandafter
     \csname l@#1\endcsname\csname Etoc@savedl@#1\endcsname
 \Etoc@next 
 {\ifcase#2\relax
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@zero@@
      \expandafter\def \csname Etoc@#1@\endcsname{zero}%
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@one@@
      \expandafter\def \csname Etoc@#1@\endcsname{one}%
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@two@@
      \expandafter\def \csname Etoc@#1@\endcsname{two}%
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@three@@
      \expandafter\def \csname Etoc@#1@\endcsname{three}%
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@four@@
      \expandafter\def \csname Etoc@#1@\endcsname{four}%
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@five@@
      \expandafter\def \csname Etoc@#1@\endcsname{five}%
   \else
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minusone@@
      \expandafter\def \csname Etoc@#1@\endcsname{minusone}%
   \fi}}
\etocsetlevel{part}{-1}
\etocsetlevel{chapter}{0}
\etocsetlevel{section}{1}
\etocsetlevel{subsection}{2}
\etocsetlevel{subsubsection}{3}
\etocsetlevel{paragraph}{4}
\etocsetlevel{subparagraph}{5}
%
\AtBeginDocument{%
\def\Etoc@Lazarus@elta#1\Etoc@Lazarus@eltb#2{\let#2#1\let#1\Etoc@lxyz}%
\Etoc@Lazaruslist
\let\Etoc@savedcontentsline\contentsline
\let\contentsline\Etoc@etoccontentsline
\@ifpackageloaded{hyperref}
{\Etoc@hyperreftrue
\def\Etoc@et@hop#1#2#3#4#5{#1{#3}{#4}{#5}#2}}
{\Etoc@hyperreffalse
\def\Etoc@et@hop#1#2#3#4{#1{#3}{#4}#2}}}
%
  \def\Etoc@swa#1{%
        \Etoc@et@hop 
          {\Etoc@savedcontentsline{#1}}
          {\Etoc@prefix\Etoc@contents}}
  \def\Etoc@swb#1{%
        \Etoc@et@hop 
          {\Etoc@savedcontentsline{#1}}
          {\Etoc@contents}}
  \let\etocskipfirstprefix\@thirdofthree 
%
\def\etoc@startlocaltoc#1{%
\let\Etoc@next\relax
    \ifEtoc@localtoc 
    \ifEtoc@notactive 
        \ifnum #1<\c@etoc@localtocid\relax
          \else 
          \ifEtoc@j   \global\let\Etoc@localtop\Etoc@@zero@@  \fi
          \ifEtoc@    \global\let\Etoc@localtop\Etoc@@one@@   \fi
          \ifEtoc@i   \global\let\Etoc@localtop\Etoc@@two@@   \fi
          \ifEtoc@ii  \global\let\Etoc@localtop\Etoc@@three@@ \fi
          \ifEtoc@iii \global\let\Etoc@localtop\Etoc@@four@@  \fi
          \ifEtoc@iv  \global\let\Etoc@localtop\Etoc@@five@@  \fi
          \ifEtoc@v   \global\let\Etoc@localtop\Etoc@@six@@   \fi
          \def\Etoc@next{\global\Etoc@notactivefalse
                      \global\Etoc@vfalse
                      \global\Etoc@ivfalse
                      \global\Etoc@iiifalse
                      \global\Etoc@iifalse
                      \global\Etoc@ifalse
                      \global\Etoc@false
                      \global\Etoc@jfalse}%
        \fi
    \fi\fi
\Etoc@next}
\def\Etoc@setflags #1{%
  \ifcase #1\relax
      \global\Etoc@vfalse
      \global\Etoc@ivfalse
      \global\Etoc@iiifalse
      \global\Etoc@iifalse
      \global\Etoc@ifalse
      \global\Etoc@true
  \or
      \global\Etoc@vfalse
      \global\Etoc@ivfalse
      \global\Etoc@iiifalse
      \global\Etoc@iifalse
      \global\Etoc@itrue
  \or
      \global\Etoc@vfalse
      \global\Etoc@ivfalse
      \global\Etoc@iiifalse
      \global\Etoc@iitrue
  \or
      \global\Etoc@vfalse
      \global\Etoc@ivfalse
      \global\Etoc@iiitrue
  \or
      \global\Etoc@vfalse
      \global\Etoc@ivtrue
  \or
      \global\Etoc@vtrue
  \else
      \global\Etoc@vfalse
      \global\Etoc@ivfalse
      \global\Etoc@iiifalse
      \global\Etoc@iifalse
      \global\Etoc@ifalse
      \global\Etoc@false
      \global\Etoc@jtrue
  \fi}
\def\Etoc@etoccontentsline#1{%
  \global\expandafter\let\expandafter\Etoc@tmp\csname Etoc@#1@@\endcsname
  \global\Etoc@partfalse
  \Etoc@skipthisonefalse
  \ifEtoc@hyperref
          \def\Etoc@next{\expandafter\@gobbletwo\@gobblefour}%
      \else
          \def\Etoc@next{\expandafter\@gobble\@gobblefour}%
  \fi
  \ifEtoc@localtoc
     \let\Etoc@prenext\relax
     \ifEtoc@stoptoc
        \Etoc@skipthisonetrue
     \fi
     \ifnum\Etoc@tmp<\Etoc@localtop 
        \def\Etoc@prenext{\global\Etoc@stoptoctrue}%
        \Etoc@skipthisonetrue
     \fi
     \ifEtoc@notactive
        \def\Etoc@prenext{\Etoc@setflags{\Etoc@tmp}}%
        \Etoc@skipthisonetrue
     \fi
     \Etoc@prenext
  \fi
  \ifnum\c@tocdepth<\Etoc@tmp\relax\else
  \ifEtoc@skipthisone\else
  \global\let\Etoc@next\relax  
  \ifcase\Etoc@tmp 
      \ifEtoc@v \Etoc@end@five\fi
      \ifEtoc@iv \Etoc@end@four\fi
      \ifEtoc@iii \Etoc@end@three\fi
      \ifEtoc@ii \Etoc@end@two\fi
      \ifEtoc@i \Etoc@end@one\fi
      \ifEtoc@ \else \def\Etoc@next{\Etoc@begin@zero}\fi
      \gdef\Etoc@contents{\Etoc@contents@zero}%
      \gdef\Etoc@prefix{\Etoc@prefix@zero}%
  \or
      \ifEtoc@v \Etoc@end@five\fi
      \ifEtoc@iv \Etoc@end@four\fi
      \ifEtoc@iii \Etoc@end@three\fi
      \ifEtoc@ii \Etoc@end@two\fi
      \ifEtoc@i \else \def\Etoc@next{\Etoc@begin@one}\fi
      \gdef\Etoc@contents{\Etoc@contents@one}%
      \gdef\Etoc@prefix{\Etoc@prefix@one}%
  \or
      \ifEtoc@v \Etoc@end@five\fi
      \ifEtoc@iv \Etoc@end@four\fi
      \ifEtoc@iii \Etoc@end@three\fi
      \ifEtoc@ii \else \def\Etoc@next{\Etoc@begin@two}\fi
      \gdef\Etoc@contents{\Etoc@contents@two}%
      \gdef\Etoc@prefix{\Etoc@prefix@two}%
  \or
      \ifEtoc@v \Etoc@end@five\fi
      \ifEtoc@iv \Etoc@end@four\fi
      \ifEtoc@iii \else \def\Etoc@next{\Etoc@begin@three}\fi
      \gdef\Etoc@contents{\Etoc@contents@three}%
      \gdef\Etoc@prefix{\Etoc@prefix@three}%
  \or 
      \ifEtoc@v \Etoc@end@five\fi 
      \ifEtoc@iv \else \def\Etoc@next{\Etoc@begin@four}\fi
      \gdef\Etoc@contents{\Etoc@contents@four}%
      \gdef\Etoc@prefix{\Etoc@prefix@four}%
  \or 
      \ifEtoc@v \else \def\Etoc@next{\Etoc@begin@five}\fi
      \gdef\Etoc@contents{\Etoc@contents@five}%
      \gdef\Etoc@prefix{\Etoc@prefix@five}%
  \else
      \ifEtoc@v \Etoc@end@five\fi
      \ifEtoc@iv \Etoc@end@four\fi
      \ifEtoc@iii \Etoc@end@three\fi
      \ifEtoc@ii \Etoc@end@two\fi
      \ifEtoc@i \Etoc@end@one\fi
      \ifEtoc@ \Etoc@end@zero\fi
      \ifEtoc@j \else \def\Etoc@next{\Etoc@begin@minusone}\fi
      \global\Etoc@parttrue
      \gdef\Etoc@contents{\Etoc@contents@minusone}%
      \gdef\Etoc@prefix{\Etoc@prefix@minusone}%
  \fi
  \Etoc@setflags{\Etoc@tmp}%
  \fi\fi
  \Etoc@next
  \@firstoftwo{\Etoc@swa{#1}}{\Etoc@swb{#1}}}
%
\def\Etoc@lxyz #1#2{\global\@namedef{etocname }{\leavevmode #1\xspace}%
                    \global\@namedef{etocpage }{\leavevmode #2\xspace}%
    \Etoc@getnb #1\relax\relax\etoc@
    \ifEtoc@number\else\ifEtoc@part 
    \Etoc@getit #1\hspace\relax\etoc@\fi\fi}
%
\def\Etoc@getnb #1{\let\Etoc@next\Etoc@getnb@nohyp
\ifEtoc@hyperref\ifx #1\hyper@linkstart
    \let\Etoc@next\Etoc@getnb@hyp\fi\fi\Etoc@next #1}
\def\Etoc@getit #1{\let\Etoc@next\Etoc@getit@nohyp
\ifEtoc@hyperref\ifx #1\hyper@linkstart
    \let\Etoc@next\Etoc@getit@hyp\fi\fi\Etoc@next #1}
%
\def\Etoc@getnb@nohyp #1#2#3\etoc@{%
\ifx #1\numberline
\global\@namedef{etocnumber }{\leavevmode #2\xspace}\global\Etoc@numbertrue
\else
\global\@namedef{etocnumber }{\leavevmode\xspace}\global\Etoc@numberfalse
\fi}
%
\def\Etoc@getnb@hyp #1#2#3#4#5#6\etoc@{%
  \def\Etoc@getnbr ##1##2##3\etoc@{%
    \ifx ##1\numberline
    \global\@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##2}#5\xspace}%
    \global\Etoc@numbertrue
    \else
    \global\@namedef{etocnumber }{\leavevmode\xspace}%
    \global\Etoc@numberfalse
    \fi}%
  \Etoc@getnbr #4\relax\relax\etoc@}
%
\def\Etoc@getit@nohyp #1\hspace#2#3\etoc@{%
    \def\Etoc@getname ##1\hspace\relax\etoc@{%
      \global\@namedef{etocname }{\leavevmode ##1\xspace}}%
    \ifx \relax#2\else 
    \global\@namedef{etocnumber }{\leavevmode #1\xspace}%
    \global\Etoc@numbertrue
    \Etoc@getname #3\etoc@\fi}
%
\def\Etoc@getit@hyp #1#2#3#4#5#6\etoc@{%
  \def\Etoc@getname ##1\hspace\relax\etoc@{%
   \global\@namedef{etocname }{\leavevmode #1{#2}{#3}{##1}#5}\xspace}%
  \def\Etoc@getnbr ##1\hspace##2##3\etoc@{%
   \ifx\relax##2\else
   \global\@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5\xspace}%
   \global\Etoc@numbertrue
   \Etoc@getname ##3\etoc@\fi}%
  \Etoc@getnbr #4\hspace\relax\etoc@}
%
\edef\etocpage{\noexpand\protect\expandafter\noexpand
               \csname etocpage \endcsname}
\edef\etocname{\noexpand\protect\expandafter\noexpand
               \csname etocname \endcsname}
\edef\etocnumber{\noexpand\protect\expandafter\noexpand
                 \csname etocnumber \endcsname}
%
\@namedef{etocifnumbered }{\ifEtoc@number
\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
%
\edef\etocifnumbered{\noexpand\protect\expandafter\noexpand
                     \csname etocifnumbered \endcsname}
%
\def\Etoc@readtoc#1{%
  \ifeof #1
     \let\Etoc@nextread\@gobble
  \else
     \let\Etoc@nextread\Etoc@readtoc
     \read #1 to \Etoc@buffer
     \global\Etoc@toctoks=\expandafter\expandafter\expandafter
       {\expandafter\the\expandafter\Etoc@toctoks\Etoc@buffer}%
  \fi
  \Etoc@nextread{#1}%
}
%
\def\Etoc@starttoc{%
\begingroup   
\makeatletter 
\chardef\ET@endline\endlinechar
\@ifpackageloaded{hyperref}
   {\ifx\hyper@last\@undefined
    \ltx@ifpackageloaded {parskip}{\parskip \z@ }{}%
    \IfFileExists {\jobname .toc}{\Hy@WarningNoLine {old toc file
    detected, not used; run LaTeX again (cheers from etoc)}}{}%
    \expandafter\@gobble\fi}{}%
{\IfFileExists{\jobname .toc}
    {\endlinechar=-1\relax
        \newread\Etoc@tf
        \openin\Etoc@tf\@filef@und
           \Etoc@readtoc\Etoc@tf
        \closein\Etoc@tf}
    {\typeout{No file \jobname .toc.}}}%
\endlinechar\ET@endline
\if@filesw \newwrite \tf@toc \immediate
\openout \tf@toc \jobname .toc\relax \fi 
\endgroup}
%
\AtBeginDocument{\Etoc@starttoc}
\def\Etoc@toctoc{%
\ifEtoc@standard
\Etoc@Lazarus
\etocsetstyle{@minusone}{}{}{}{}%
\etocsetstyle{@zero}{}{}{}{}%
\etocsetstyle{@one}{}{}{}{}%
\etocsetstyle{@two}{}{}{}{}%
\etocsetstyle{@three}{}{}{}{}%
\etocsetstyle{@four}{}{}{}{}%
\etocsetstyle{@five}{}{}{}{}%
\else  
\let\numberline\@gobble 
\fi
\the\Etoc@toctoks
\ifEtoc@notactive\else 
  \ifEtoc@v   \Etoc@end@five\fi
  \ifEtoc@iv  \Etoc@end@four\fi
  \ifEtoc@iii \Etoc@end@three\fi
  \ifEtoc@ii  \Etoc@end@two\fi
  \ifEtoc@i   \Etoc@end@one\fi
  \ifEtoc@    \Etoc@end@zero\fi
  \ifEtoc@j   \Etoc@end@minusone\fi
\fi
\global\Etoc@vfalse
\global\Etoc@ivfalse
\global\Etoc@iiifalse
\global\Etoc@iifalse
\global\Etoc@ifalse
\global\Etoc@false
\global\Etoc@jfalse}
%
\def\tableofcontents{\@ifstar{%
\stepcounter{etoc@localtocid}%
\global\Etoc@localtoctrue
\global\let\Etoc@localtop\m@ne
\global\Etoc@stoptocfalse
\global\Etoc@notactivetrue
\addtocontents{toc}{\string\etoc@startlocaltoc
\string{\arabic{etoc@localtocid}\string}}%
\Etoc@tableofcontents
\global\Etoc@notactivefalse
\global\Etoc@stoptocfalse
\global\Etoc@localtocfalse}
{\Etoc@tableofcontents}}
%
\newcommand\etocsettocstyle[2]{%
\long\def\Etoc@tableofcontents
{\ifnum\c@tocdepth>-2\let\Etoc@@next\@firstofone\else
\let\Etoc@@next\@gobble\fi
\Etoc@@next{\begingroup #1\Etoc@toctoc #2\endgroup}}}
%
\newcommand\etocsetstyle[5]{%
\long\expandafter\def
     \csname Etoc@begin@\csname Etoc@#1@\endcsname\endcsname {#2}%
\long\expandafter\def
     \csname Etoc@prefix@\csname Etoc@#1@\endcsname\endcsname {#3}%
\long\expandafter\def
     \csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname {#4}%
\long\expandafter\def
     \csname Etoc@end@\csname Etoc@#1@\endcsname\endcsname {#5}}
%
\def\etocstandardlines{\Etoc@standardtrue}
%
\newcommand\etocfontminusone{\normalfont \large \bfseries}
\newcommand\etocfontzero{\normalfont \normalsize \bfseries}
\newcommand\etocfontone{\normalfont \normalsize \bfseries}
\newcommand\etocfonttwo{\normalfont \normalsize}
\newcommand\etocfontthree{\normalfont \footnotesize}
\newcommand\etocfontfour{\normalfont \footnotesize}
\newcommand\etocfontfive{\normalfont \footnotesize}
%
\newcommand\etocsepminusone{4ex \@plus .5ex \@minus .5ex}
\newcommand\etocsepzero{2.5ex \@plus .4ex \@minus .4ex}
\newcommand\etocsepone{1.5ex \@plus .3ex \@minus .3ex}
\newcommand\etocseptwo{1ex \@plus .15ex \@minus .15ex}
\newcommand\etocsepthree{.25ex \@plus .05ex \@minus .05ex}
%
\newcommand\etocbaselinespreadminusone{1}
\newcommand\etocbaselinespreadzero{1}
\newcommand\etocbaselinespreadone{1}
\newcommand\etocbaselinespreadtwo{1}
\newcommand\etocbaselinespreadthree{.9}
%
\newcommand\etocminusonelrmargins{1em}
\newcommand\etoctoclineleaders
{\hbox{\normalfont\normalsize\hbox to 2ex {\hfil.\hfil}}}
\newcommand\etocabbrevpagename{p.~}
%
\def\etocetoclines{\Etoc@standardfalse
%
\etocsetstyle{@minusone}{\addpenalty\@highpenalty}{}
{\begingroup \etocfontminusone
  \addvspace{\etocsepminusone}%
  \parindent \z@ 
  \leftskip  \etocminusonelrmargins 
  \rightskip \etocminusonelrmargins
  \parfillskip \@flushglue
  \vbox{\etocifnumbered{\etocnumber.~}{}\etocname
  \baselineskip\etocbaselinespreadminusone\baselineskip\par}%
  \addvspace{\etocsepzero}\nobreak
\endgroup}
{\addpenalty\@secpenalty}%
\etocsetstyle{@zero}
{\addpenalty\@highpenalty}{}
{\begingroup 
   \etocfontzero
   \addvspace{\etocsepzero}%
   \parindent \z@ \parfillskip \@flushglue 
   \vbox{\etocifnumbered{\etocnumber\space}{}\etocname
   \baselineskip\etocbaselinespreadzero\baselineskip\par}%
   \addvspace{\etocsepone}\addpenalty\@itempenalty
\endgroup}
{\addpenalty\@secpenalty}%
%
\etocsetstyle{@one}
{\addpenalty\@medpenalty}
{}
{\begingroup\etocfontone
\addvspace{\etocsepone}%
\parindent \z@ \parfillskip \z@ 
\setbox\z@\vbox{\parfillskip\@flushglue
\etocname\par\setbox\tw@\lastbox
\global\setbox\@ne\hbox{\unhbox\tw@}}%
\dimen\z@=\wd\@ne
\setbox\z@=\etoctoclineleaders
\advance\dimen\z@\wd\z@
\etocifnumbered
{\setbox\tw@\hbox{\etocfonttwo\etocnumber, \etocabbrevpagename\etocpage}}
{\setbox\tw@\hbox{\etocfonttwo\etocabbrevpagename\etocpage}}%
\advance\dimen\z@\wd\tw@
\ifdim\dimen\z@ < \linewidth
       \vbox{\etocname\nobreak
       \leaders\box\z@\hfil\box\tw@
       \baselineskip\etocbaselinespreadone\baselineskip\par}
   \else
       \vbox{\etocname\nobreak
       \ifdim\wd\@ne<\linewidth\leaders\copy\z@\hfil\break\fi
       \hbox{}\leaders\box\z@\hfil\box\tw@
       \baselineskip\etocbaselinespreadone\baselineskip\par}
\fi
\addvspace{\etocseptwo}\addpenalty\@itempenalty
\endgroup}
{\addpenalty\@secpenalty}%
%
\etocsetstyle{@two}
{\addpenalty\@medpenalty} 
{}
{\begingroup\etocfonttwo
\addvspace{\etocseptwo}%
\parindent \z@ \parfillskip \z@
\setbox\z@\vbox{\parfillskip\@flushglue
\etocname\par\setbox\tw@\lastbox
\global\setbox\@ne\hbox{\unhbox\tw@}}%
\dimen\z@=\wd\@ne
\setbox\z@=\etoctoclineleaders
\advance\dimen\z@\wd\z@
\etocifnumbered
{\setbox\tw@\hbox{\etocnumber, \etocabbrevpagename\etocpage}}
{\setbox\tw@\hbox{\etocabbrevpagename\etocpage}}%
\advance\dimen\z@\wd\tw@
\ifdim\dimen\z@ < \linewidth
       \vbox{\etocname\nobreak
       \leaders\box\z@\hfil\box\tw@
       \baselineskip\etocbaselinespreadtwo\baselineskip\par}
   \else
       \vbox{\etocname\nobreak
       \ifdim\wd\@ne<\linewidth\leaders\copy\z@\hfil\break\fi
       \hbox{}\leaders\box\z@\hfil\box\tw@
       \baselineskip\etocbaselinespreadtwo\baselineskip\par}
\fi
\addvspace{\etocsepthree}\addpenalty\@itempenalty
\endgroup}
{\addpenalty\@secpenalty}%
%
\etocsetstyle{@three}
{\nobreak
\etocfontthree
\addvspace{\etocsepthree}%
\nointerlineskip\noindent
\etocskipfirstprefix}
{\allowbreak\,--\,}
{\etocname}
{\unskip.\hfil\begingroup
\baselineskip\etocbaselinespreadthree\baselineskip
\par\endgroup
\addpenalty{-\@highpenalty}}%
%
\etocsetstyle{@four}{}{}{}{}%
%
\etocsetstyle{@five}{}{}{}{}%
}
%
\newcommand\etocmarkboth[1][\contentsname]{%
    \@mkboth {\MakeUppercase #1}
             {\MakeUppercase #1}}
\def\etoc@article@tochead#1{\section *{#1\@mkboth 
       {\MakeUppercase{#1}}
       {\MakeUppercase{#1}}}}
\def\etoc@article@tochead@nomarks#1{\section *{#1}}
\def\etoc@book@tochead#1{\chapter *{#1\@mkboth
      {\MakeUppercase{#1}}
      {\MakeUppercase{#1}}}}
\def\etoc@book@tochead@nomarks#1{\chapter *{#1}}
\let\etoc@standard@tochead\etoc@article@tochead
\let\etoc@standard@tochead@nomarks\etoc@article@tochead@nomarks
\@ifclassloaded{book}{%
\let\etoc@standard@tochead\etoc@book@tochead
\let\etoc@standard@tochead@nomarks\etoc@book@tochead@nomarks}{}
\@ifclassloaded{report}{%
\let\etoc@standard@tochead\etoc@book@tochead
\let\etoc@standard@tochead@nomarks\etoc@book@tochead@nomarks}{}
%
\newcommand\etocstandardheading[1]{%
\etoc@standard@tochead{#1}}
\newcommand\etocstandardheadingnomarks[1]{%
\etoc@standard@tochead@nomarks{#1}}
%    
\newcommand\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} 
\newcommand\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex}
\newcommand\etoccolumnsep{2em}
\newcommand\etocmulticolsep{0ex}
\newcommand\etocmulticolpretolerance{-1}
\newcommand\etocmulticoltolerance{200}
%
\newcommand\etocmulticolstyle[2][2]{%
\etocsettocstyle
   {\addvspace{\etocabovetocskip}%
    \ifnum #1>\@ne\let\Etoc@next\@firstoftwo
         \else \let\Etoc@next\@secondoftwo\fi
    \Etoc@next{%
    \multicolpretolerance\etocmulticolpretolerance
    \multicoltolerance\etocmulticoltolerance
    \setlength{\columnsep}{\etoccolumnsep}%
    \setlength{\multicolsep}{\etocmulticolsep}%
    \begin{multicols}{#1}[#2\addvspace{\etocsepminusone}]}
    {#2\addvspace{\etocsepminusone}\pretolerance\etocmulticolpretolerance
         \tolerance\etocmulticoltolerance}} 
   {\ifnum #1>\@ne\let\Etoc@next\@firstofone
         \else \let\Etoc@next\@gobble\fi
    \Etoc@next{\end{multicols}}%
    \addvspace{\etocbelowtocskip}}}
%
\newcommand\etocinnertopsep{2ex}
\newcommand\etocinnerbottomsep{3.5ex}
\newcommand\etocinnerleftsep{2em}
\newcommand\etocinnerrightsep{2em}
\newcommand\etoctoprule{\hrule}
\newcommand\etocleftrule{\vrule}
\newcommand\etocrightrule{\vrule}
\newcommand\etocbottomrule{\hrule}
\newcommand\etoctoprulecolorcmd{\relax}
\newcommand\etocbottomrulecolorcmd{\relax}
\newcommand\etocleftrulecolorcmd{\relax}
\newcommand\etocrightrulecolorcmd{\relax}
%
\newcommand\etoc@ruledheading[1]{%
   \hbox to \linewidth{%
          \hfil #1\hfil\hskip-\linewidth
          {\etoctoprulecolorcmd\leaders\etoctoprule\hfil}%
          \phantom{#1}%
          {\etoctoprulecolorcmd\leaders\etoctoprule\hfil}}%
         \nointerlineskip\vskip\etocinnertopsep}
%
\newcommand\etocruledstyle[2][2]{%
\etocsettocstyle
   {\addvspace{\etocabovetocskip}%
    \ifnum #1>\@ne\let\Etoc@next\@firstoftwo
         \else \let\Etoc@next\@secondoftwo\fi
    \Etoc@next
       {\multicolpretolerance\etocmulticolpretolerance
        \multicoltolerance\etocmulticoltolerance
        \setlength{\columnsep}{\etoccolumnsep}%
        \setlength{\multicolsep}{\etocmulticolsep}%
        \begin{multicols}{#1}[\etoc@ruledheading{#2}]}
       {\etoc@ruledheading{#2}\nobreak
         \pretolerance\etocmulticolpretolerance
         \tolerance\etocmulticoltolerance}} 
   {\ifnum #1>\@ne\let\Etoc@next\@firstofone
         \else \let\Etoc@next\@gobble\fi
    \Etoc@next{\end{multicols}}%
    \addvspace{\etocbelowtocskip}}}
%
\newcommand\etocframedstyle[2][2]{%
\etocsettocstyle{%
    \addvspace{\etocabovetocskip}%
    \sbox\z@{#2}\dimen\z@\dp\z@
    \ifdim\wd\z@<\linewidth\dp\z@\z@\else\dimen\z@\z@\fi
    \hbox to \linewidth{%
        \hfil\copy\z@\hfil\hskip-\linewidth
        {\etoctoprulecolorcmd\leaders\etoctoprule\hfil}%
        \phantom{\box\z@}%
        {\etoctoprulecolorcmd\leaders\etoctoprule\hfil}}%
    \nointerlineskip\nobreak
    \hbox to \linewidth
    \bgroup
        {\etocleftrulecolorcmd\etocleftrule}%
        \kern\etocinnerleftsep
        \vbox\bgroup
        \kern\dimen\z@
        \vskip\etocinnertopsep
        \hbox\bgroup
        \setbox\z@\hbox{\etocleftrule\etocrightrule}%
        \dimen\z@\linewidth\advance\dimen\z@-\wd\z@
        \advance\dimen\z@-\etocinnerleftsep
        \advance\dimen\z@-\etocinnerrightsep
        \begin{minipage}{\dimen\z@}
    \ifnum #1>\@ne\let\Etoc@next\@firstoftwo
    \else \let\Etoc@next\@secondoftwo\fi
        \Etoc@next
        {\multicolpretolerance\etocmulticolpretolerance
        \multicoltolerance\etocmulticoltolerance
        \setlength{\columnsep}{\etoccolumnsep}%
        \setlength{\multicolsep}{\etocmulticolsep}%
        \begin{multicols}{#1}}
        {\pretolerance\etocmulticolpretolerance
         \tolerance\etocmulticoltolerance}}
     {\ifnum #1>\@ne\let\Etoc@next\@firstofone
         \else \let\Etoc@next\@gobble\fi
    \Etoc@next{\end{multicols}\unskip}%
    \end{minipage}\egroup
    \vskip\etocinnerbottomsep
    \egroup\kern\etocinnerrightsep
    \etocrightrulecolorcmd\etocrightrule\egroup
    \nointerlineskip\nobreak
    \hbox to \linewidth{\etocbottomrulecolorcmd
          \leaders\etocbottomrule\hfill}
    \addvspace{\etocbelowtocskip}}}
%
\newcommand\etoc@multicoltoc[2][2]{%
\begingroup
\ifnum\c@tocdepth>-2\relax 
\etocmulticolstyle[#1]{#2}%
 \ifEtoc@star
    \def\Etoc@next{\tableofcontents*}%
    \else\def\Etoc@next{\tableofcontents}%
 \fi
\Etoc@next
\fi\endgroup}
%
\newcommand\etoc@ruledtoc[2][2]{%
\begingroup
\ifnum\c@tocdepth>-2\relax 
\etocruledstyle[#1]{#2}%
   \ifEtoc@star
      \def\Etoc@next{\tableofcontents*}%
   \else
      \def\Etoc@next{\tableofcontents}%
   \fi
\Etoc@next
\fi\endgroup}
%
\newcommand\etoc@framedtoc[2][2]{%
\begingroup
\ifnum\c@tocdepth>-2\relax 
\etocframedstyle[#1]{#2}%
   \ifEtoc@star
      \def\Etoc@next{\tableofcontents*}%
   \else
      \def\Etoc@next{\tableofcontents}%
   \fi
\Etoc@next
\fi\endgroup}
%
\def\etocmulticol{\@ifstar{\global\Etoc@startrue\etoc@multicoltoc}
{\global\Etoc@starfalse\etoc@multicoltoc}}
\def\etocruled{\@ifstar{\global\Etoc@startrue\etoc@ruledtoc}
{\global\Etoc@starfalse\etoc@ruledtoc}}
\def\etocframed{\@ifstar{\global\Etoc@startrue\etoc@framedtoc}
{\global\Etoc@starfalse\etoc@framedtoc}}
%
\etocetoclines
\etocmulticolstyle{\etocstandardheading\contentsname}
\endinput
%</package>
%    \end{macrocode}
% \clearpage
% \Finale
% \endinput
\endinput
%%
%% End of file `etoc.dtx'.