summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tocbibind/tocbibind.dtx
blob: 1570545523aba1c69c3360b8618bcbf8868c67d2 (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
% \iffalse meta-comment
% tocbibind.dtx
% Author: Peter Wilson, Herries Press
% Maintainer: Will Robertson (will dot robertson at latex-project dot org)
% Copyright 1998--2004 Peter R. Wilson
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any 
% later version: <http://www.latex-project.org/lppl.txt>
%
% This work has the LPPL maintenance status "maintained".
% The Current Maintainer of this work is Will Robertson.
%
% This work consists of the files listed in the README file.
%
% 
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\setcounter{StandardModuleDepth}{1}
\begin{document}
  \DocInput{tocbibind.dtx}
\end{document}
%</driver>
%
% \fi
%
% \CheckSum{464}
%
% \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
% \DoNotIndex{\@centercr,\@cite}
% \DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue}
% \DoNotIndex{\@input,\@ixpt,\@m}
% \DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
% \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
% \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
% \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
% \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
% \DoNotIndex{\advance,\Alph,\alph}
% \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
% \DoNotIndex{\bullet}
% \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
% \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
% \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
% \DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup}
% \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
% \DoNotIndex{\fbox}
% \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
% \DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule}
% \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi}
% \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
% \DoNotIndex{\input}
% \DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark}
% \DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright}
% \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
% \DoNotIndex{\NeedsTeXFormat,\newdimen}
% \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
% \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
% \DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip}
% \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
% \DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright}
% \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
% \DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman}
% \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
% \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
% \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
% \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
% \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
% \DoNotIndex{\wd,\xiipt,\year,\z@}
%
% \changes{v1.0}{1998/10/24}{First public release}
% \changes{v1.1}{1998/11/15}{Added the proc class and extra support for unknown classes}
% \changes{v1.2}{1999/01/17}{Using the stdclsdv package}
% \changes{v1.2}{1999/01/17}{Made compatible with the tocloft package}
% \changes{v1.3}{1999/08/22}{Fixed index numbering, options, headings}
% \changes{v1.3a}{1999/09/12}{Added PackageNote commands}
% \changes{v1.4}{2000/03/04}{Fixed shift of Index title}
% \changes{v1.4}{2000/03/04}{Added support for numbered Listof headings}
% \changes{v1.4a}{2000/03/04}{Added delimeter for simple chapters}
% \changes{v1.5}{2001/04/17}{Fixed \cs{addcontentsline} problem with hyperref package}
% \changes{v1.5}{2001/04/17}{Removed requirement for the stdclsdv package}
% \changes{v1.5a}{2001/08/07}{Made \cs{restorechapter} safer}
% \changes{v1.5b}{2001/11/10}{Fiddled with page styling}
% \changes{v1.5c}{2002/03/11}{Fixed \cs{@mkboth}}
% \changes{v1.5d}{2002/04/09}{Fixed \cs{tocchapter} for article classes}
% \changes{v1.5e}{2003/01/22}{Changed thebibliography}
% \changes{v1.5f}{2003/02/04}{Changed theindex}
% \changes{v1.5h}{2004/05/10}{Changed license from LPPL v1.0 to v1.3}
% \changes{v1.5i}{2009/09/04}{New maintainer (Will Robertson)}
% \changes{v1.5k}{2010/10/13}{Remove a message in the console output}
%
% \def\dtxfile{tocbibind.dtx}
% \def\fileversion{v1.4a} \def\filedate{2000/03/05}
% \def\fileversion{v1.5}  \def\filedate{2001/04/17}
% \def\fileversion{v1.5a} \def\filedate{2001/08/07}
% \def\fileversion{v1.5b} \def\filedate{2001/11/10}
% \def\fileversion{v1.5c} \def\filedate{2002/03/11}
% \def\fileversion{v1.5d} \def\filedate{2002/04/09}
% \def\fileversion{v1.5e} \def\filedate{2003/01/22}
% \def\fileversion{v1.5f} \def\filedate{2003/02/04}
% \def\fileversion{v1.5g} \def\filedate{2003/03/13}
% \def\fileversion{v1.5h} \def\filedate{2004/05/10}
% \def\fileversion{v1.5i} \def\filedate{2009/09/04}
% \def\fileversion{v1.5j} \def\filedate{2009/12/28}
% \def\fileversion{v1.5k} \def\filedate{2010/10/13}
% \newcommand*{\Lpack}[1]{\textsf {#1}}           ^^A typeset a package
% \newcommand*{\Lopt}[1]{\textsf {#1}}            ^^A typeset an option
% \newcommand*{\file}[1]{\texttt {#1}}            ^^A typeset a file
% \newcommand*{\Lcount}[1]{\textsl {\small#1}}    ^^A typeset a counter
% \newcommand*{\pstyle}[1]{\textsl {#1}}          ^^A typeset a pagestyle
% \newcommand*{\Lenv}[1]{\texttt {#1}}            ^^A typeset an environment
%
% \title{The \Lpack{tocbibind} package\thanks{This
%        file (\texttt{\dtxfile}) has version number \fileversion, last revised
%        \filedate.}}
%
% \author{
%   Author: Peter Wilson, Herries Press\\
%   Maintainer: Will Robertson\\
%   \texttt{will dot robertson at latex-project dot org}
% }
% \date{\filedate}
% \maketitle
% \begin{abstract}
%    The \Lpack{tocbibind} package can be used to add document elements
% like a bibliography or an index to the Table of Contents. The package
% is designed to work with the four standard \Lpack{book}, \Lpack{report},
% \Lpack{article} and \Lpack{proc} classes, and to a limited extent with the
% \Lpack{ltxdoc} class. Results with other classes may be
% problematical. The package has been tested with the \Lpack{tocloft}
% package, but has not been tested with other packages
% that change the definitions of the |\chapter*| or |\section*| commands.
%
% \end{abstract}
% \tableofcontents
%
% \StopEventually{}
%
% 
%
% \section{Introduction}
%
% Questions about adding the bibliography to the Table of Contents
% seem to pop up fairly regularly on the
% \texttt{comp.text.tex} newsgroup. 
%
%  The \Lpack{tocbibind} package provides a solution for
% automatically inserting references to a bibliography or an index,
% or other headed document elements into the Table of Contents.
% (\Lpack{tocbibind} is meant to be shorthand for `Table of Contents,
% Bibliography, Index, etc').
% Portions of the package were developed as part of a class
% and package bundle for typesetting ISO standards~\cite{PRW96i}.
% This manual is typeset according to the conventions of the
% \LaTeX{} \textsc{docstrip} utility which enables the automatic
% extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
%
%    Section~\ref{sec:usc} describes the usage of the package.
% Commented source code for the package is in Section~\ref{sec:code}.
%
% \section{The \Lpack{tocbibind} package} \label{sec:usc}
%
%    The \Lpack{tocbibind} package enables the titles of the
% Table of Contents, the List of Figures, the List of Tables, the
% Bibliography and the Index all to be added to the Table of Contents.
%    By default, all of these document elements, if they exist, will be
% incorporated into the Table of Contents (ToC for short).
%    Package options are available to switch off any of these inclusions.
% \begin{itemize}
% \item \Lopt{notbib} Disables the inclusion of the Bibliography.
% \item \Lopt{notindex} Disables the inclusion of the Index (inclusion
%       of the Index of an \Lpack{ltxdoc} class document is permanantly
%       disabled).
% \item \Lopt{nottoc} Disables the inclusion of the ToC.
% \item \Lopt{notlot} Disables the inclusion of the List of Tables.
% \item \Lopt{notlof} Disables the inclusion of the List of Figures.
% \item \Lopt{chapter} Use chapter-level headings, if possible.
% \item \Lopt{section} Use section-level headings, if possible.
% \item \Lopt{numbib} Number the Bibliography heading (default is no number).
% \item \Lopt{numindex} Number the Index heading (default is no number).
% \item \Lopt{other} Use a non-traditional heading command. This option
% effectively requires the use of the |\tocotherhead| command.
% \item \Lopt{none} Disables everything.
% \end{itemize}
%
%    The package is designed to work with the standard \LaTeX{}
% document classes \Lpack{book}, \Lpack{report}, \Lpack{article}, \Lpack{proc}
% and \Lpack{ltxdoc} class (which is based to a large extent on
% the \Lpack{article} class).
% In the \Lpack{article}, \Lpack{proc} and \Lpack{ltxdoc} classes \LaTeX{} 
% uses the |\section*| heading
% style for the bibliography etc., while for the other two classes
% it uses the |\chapter*| heading style. \Lpack{tocbibind} honours
% these conventions. However, if the package is used with another
% class (perhaps with a class for typesetting theses which has
% different conventions), then the
% \Lopt{chapter} or \Lopt{section} options can be used to select the
% appropriate style (but the class must define |\chapter*| and
% |\@makeschapterhead|, or |\section*| respectively).
%
% The standard classes, except for \Lpack{ltxdoc}, have a feature whereby the
% height of the title for an index is at a different height than
% any other in a document (latex bug~3126). The \Lpack{tocbibind} package
% disables this feature.
% The disablement has the side effect that 
% the |\columnseprule| and |\columnsep| lengths can be
% set via |\setlength| to alter the column seperation and the thickness
% of a rule between the two columns in the index.
% The effect of using the \Lopt{none} option is to limit any changes to
% the single one of disabling this standard feature.
%
% \DescribeMacro{\tocotherhead}
%  In the standard \LaTeX{} classes the bibliography and index headings
% are either both defined in terms of the |\chapter*| command or in
% terms of the |\section*| command.
%  The package assumes that any class, other than the standard classes
% already mentioned, will either use code from the standard classes for
% implementing the bibliography and other headings, or will use very
% similar code. Some classes (and maybe packages) change the names of
% the heading commands. One example that I am aware of uses |\clause|
% instead of |\section|, |\sclause| instead of |\subsection| and so on.
% If your document's headings are defined like this and the same
% heading level is used for the bibliography, etc., then you can use
% the \Lopt{other} option and 
% the |\tocotherhead{|\meta{headingname}|}| command to cater for this.
% If your document uses |\clause| then put |\tocotherhead{clause}|
% in the preamble after loading the package. The package then assumes
% that the bibliography heading is defined in terms of |\clause*|.
%
%    If you use the |\tocotherhead| command, then it overrides any
% \Lopt{chapter} or \Lopt{section} option.
%
% \DescribeMacro{\tocbibname}
%  The package attempts to pick up the name for the Bibliography from
%  the class definition. (Note that the \Lpack{article} class and
%  its derivatives stores
%  the name text in the |\refname| whilst the \Lpack{book} and \Lpack{report}
%  classes
%  store the name in |\bibname|). This package uses |\tocbibname|
%  to store the name of the bibliography. 
%
% \changes{v1.2}{1999/01/17}{Replaced toc\ldots name commands by the set\ldots commands.}
% \DescribeMacro{\setindexname}
% \DescribeMacro{\settocname}
% \DescribeMacro{\setlotname}
% \DescribeMacro{\setlofname}
% \DescribeMacro{\settocbibname}
%    These commands set the heading texts for the index,
% ToC, list of tables and list of figures. When used with the three
% standard classes, the heading text is picked up from the |\indexname|,
% |\contentsname|, |\listtablename| and |\listfigurename| commands
% respectively. The heading texts can be changed by changing the standard
% commands, or by using |\setindexname{|\meta{name}|}|, and similarly for
% the other headings. Thus, the following two lines of code have the 
% same effect:
% \begin{verbatim}
% \renewcommand{\listfigurename}{Figures}
% \setlofname{Figures}
% \end{verbatim}
% \textit{Note that these commands replace the } |\toc...name| 
% \textit{commands that were in version 1.1.}
%
%
% \subsection{Numbering the List of Figures, etc.}
%
%    Some authors like, or are required, to number the Listof headings.
% Some commands are provided to simplify doing this. 
%
% \DescribeMacro{\simplechapter}
% \DescribeMacro{\simplechapterdelim}
% \DescribeMacro{\restorechapter}
% In chaptered documents, the Listof headings are effectively typeset as
% |\chapter*{}|. The natural way to get numbered headings would be to
% typeset them as |\chapter{}| but this has the potential disadvantage
% that the word `Chapter', or equivalent, would be written before the 
% heading, which is probably not what is required. The 
% |\simplechapter[|\meta{name}|]|
% command modifies any subsequent |\chapter| commands so that the result
% looks like that of |\chapter*| except that the chapter number is put
% on the same line as the title and the value of |\simplechapterdelim|
% is typeset immediately after the number. By default, |\simplechapterdelim|
% is empty.
% If the optional \meta{name} argument
% is present, the \meta{name} is typeset before the number. For example:
% \begin{verbatim}
% \renewcommand{\simplechapterdelim}{:}
% \simplechapter[Chap]
% \end{verbatim}
% will result in |\chapter{First chapter}| being typeset like: \\
% \quad \textbf{Chap 1: First chapter}. \\
% The |\restorechapter| command resets
% any subsequent |\chapter| commands to their default behaviour.
%
% \DescribeMacro{\tocchapter}
% \DescribeMacro{\tocsection}
% Internally, the Listof commands in the \Lpack{tocbibind} package use 
% |\toc@chapter| for typesetting
% the Listof headings in chaptered documents and |\toc@section| for 
% non-chaptered documents. The |\tocchapter| command modifies the
% |\toc@chapter| command to use a `simple chapter' heading. The |\tocsection|
% command modifies |\toc@section| to typeset using |\section| instead of
% |\section*|.
%
%    For example, to get a numbered List of Figures heading in a chaptered
% document, put the following in the preamble:
% \begin{verbatim}
% \renewcommand{\listoffigures}{\begingroup
%    \tocchapter
%    \tocfile{\listfigurename}{lof}
% \endgroup}
% \end{verbatim}
% while to get a numbered List of Tables in a non-chaptered document:
% \begin{verbatim}
% \renewcommand{\listoftables}{\begingroup
%    \tocsection
%    \tocfile{\listtablename}{lot}
% \endgroup}
% \end{verbatim}
% More generally, to number the Table of Contents in a (non-)chaptered document
% you can do:
% \begin{verbatim}
% \renewcommand{\tableofcontents}{\begingroup
%    \tocsection
%    \tocchapter
%    \tocfile{\contentsname}{toc}
% \endgroup}
% \end{verbatim}
% The |\begingroup| |\endgroup| pairing keeps the changes local. 
%
% \subsection{Page styles}
%
%    The package, by default, supports the standard |empty|, |plain|, and
% |headings| page styles. Other page styles, for example ones you specify
% yourself via the \Lpack{fancyhdr} package, are indirectly supported.
% 
%    As an example, assume that you are using the \Lpack{fancyhdr} package
% and you use a |fancy| pagestyle in a \Lpack{book/report} class 
% document like:
% \begin{verbatim}
% \pagestyle{fancy}
% \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
% \end{verbatim}
% then you will find that the chapter titles in headers are in normalcase
% but the ToC, etc., headers are still in uppercase.
%
% \DescribeMacro{\tocetcmark}
% In this package, the marks for the ToC, LoF\ldots headers are specified
% via the command |\tocetcmark|\marg{head}. To match the |fancy| pagestyle
% this must be redefined, like:
% \begin{verbatim}
% \pagestyle{fancy}
% \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
% \renewcommand{\tocetcmark}[1]{\markboth{#1}{}}
% \end{verbatim}
% which will give normalcase headers for the ToC, LoF\ldots. As these
% are not normally numbered, it would be a misjudgement to try and
% get a non-existent chapter number into the header.
%
%    Documents with sections, but not chapters, can be treated in a similar
% manner by redefining |\tocetcmark| appropriately.
% 
%
%
% \subsection{Package Defined Listof...}
%
% There are packages, such as \Lpack{listings} and \Lpack{ccaption}, that
% provide new Listof lists. These can be handled by the \Lpack{tocbibind}
% package in a similar manner to the usual Listofs. Two examples are given
% below.
%
%    The \Lpack{listings} package version 0.2 provides a |\lstlistoflistings|
% command to print a list of listings. The header name for this list
% is in |\lstlistingname| and the listing file has the extension |lol|.
% This can be treated just like the |\listoffigure|, etc., commands.
% To add the List of Listings header to the ToC do:
% \begin{verbatim}
% \renewcommand{\lstlistoflistings}{\begingroup
%    \tocfile{\lstlistingname}{lol}
% \endgroup}
% \end{verbatim}
% and to number the Listof heading do:
% \begin{verbatim}
% \renewcommand{\lstlistoflistings}{\begingroup
%    \tocsection
%    \tocchapter
%    \tocfile{\lstlistingname}{lol}
% \endgroup}
% \end{verbatim}
%
%    The \Lpack{ccaption} package enables authors to define new kinds of
% floats (together with their captions) and Listof for each new kind of float.
% The command to define a new float is essentially 
% |\newfloatlist{|\meta{fenv}|}{|\meta{ext}|}{|\meta{listname}|}{|\meta{capname}|}|,
% where \meta{fenv} is the name of the new float environment and \meta{ext}
% is the file extension for the listof file. The typesetting of the
% Listof listing is called by the command 
% |\listoffenv|, where |fenv| is the name \meta{fenv}.
% For example, a new float environment for diagrams could be
% defined via \\
% |\newfloatlist{diagram}{dia}{List of Diagrams}{Diagram}|, and the Listof
% called for by \\
% |\listofdiagram|
%
%    In this case, to add the `List of Diagrams' to the ToC it is 
% necessary to define a
% new listof command, and use this in place of the |\listoffenv|. 
% For the diagram example this could be (unnumbered):
% \begin{verbatim}
% \newcommand{\listofdia}{\begingroup
%    \tocfile{List of Diagrams}{dia}
% \endgroup}
% \end{verbatim}
% and correspondingly for a numbered version:
% \begin{verbatim}
% \newcommand{\listofdia}{\begingroup
%    \tocsection  
%    \tocchapter  
%    \tocfile{List of Diagrams}{dia}
% \endgroup}
% \end{verbatim}
% and then use |\listofdia| instead of |\listofdiagram|.
% 
%
%
% \subsection{Abstracts}
%
% On rare occasions a publisher may want an abstract listed in the
% ToC. This package does not provide for that, partly because
% it is easier to do than the other headings. Just proceed along
% the lines below, where \texttt{section} might have to be 
% \texttt{chapter}, and if you are using the \Lpack{hyperref} package
% you have to use the |\phantomsection| macro.
% \begin{verbatim}
%   \begin{abstract}
%   % \phantomsection  % required if using hyperref
%   \addcontentsline{toc}{section}{\abstractname}
%   ... rest of the abstract
% \end{verbatim}
%
%
% 
% \section{The package code} \label{sec:code}
%
%    Announce the name and version of the package, which requires
% \LaTeXe.
% \changes{v1.5}{2001/04/17}{Deleted requirement for stdclsdv package} 
%    \begin{macrocode}
%<*usc>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tocbibind}[2010/10/13 v1.5k extra ToC listings]
%    \end{macrocode}
%
% \begin{macro}{\PRWPackageNote}
% \begin{macro}{\PRWPackageNoteNoLine}
% These two commands write a package Note to the terminal and log file.
% Use as |\PRWPackageNote{|\meta{package name}|}{|\meta{note text}|}|.
% The NoLine version does not show the line number. The commands are
% intermediate between the kernel |\PackageWarning| and |\PackageInfo|
% commands. I have provided them as other packages (of mine) may also
% incorporate them. The code is based on \file{lterror.dtx}.
% \changes{v1.3a}{1999/09/12}{Provided PRWPackageNote and PRWPackageNoteNoLine
%                             commands}
%    \begin{macrocode}
\providecommand{\PRWPackageNote}[2]{%
  \GenericWarning{%
    (#1)\@spaces\@spaces\@spaces\@spaces
  }{%
    Package #1 Note: #2%
   }%
}
\providecommand{\PRWPackageNoteNoLine}[2]{%
  \PRWPackageNote{#1}{#2\@gobble}%
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@bibquit}
% \begin{macro}{\if@bibchapter}
%  We need to know what sectional divisions are supported.
% \changes{v1.5}{2001/04/17}{Major surgery to code for checking divisions}
%    \begin{macrocode}
\newcommand{\@bibquit}{}
\newif\if@bibchapter
\@ifundefined{chapter}{%
  \@bibchapterfalse
  \@ifundefined{section}{%
    \PackageWarning{tocbibind}%
      {I don't recognize any sectional divisions.\MessageBreak
       I hope you have used the `other' option\MessageBreak
       otherwise I'll ignore the package}
    \renewcommand{\@bibquit}{\endinput}
    }{\PackageInfo{tocbibind}{The document has section divisions}}
  }{\@bibchaptertrue
    \PackageInfo{tocbibind}{The document has chapter divisions}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@inltxdoc}
%    This is used as a flag for the \Lpack{ltxdoc} class. This has a
% particular kind of index that I am not going to mess with.
%    \begin{macrocode}
\newif\if@inltxdoc
\@ifclassloaded{ltxdoc}{\@inltxdoctrue}{\@inltxdocfalse}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\if@dotocbib}
% \begin{macro}{\if@dotocind}
% \begin{macro}{\if@dotoctoc}
% \begin{macro}{\if@dotoclot}
% \begin{macro}{\if@dotoclof}
%    A set of booleans for deciding what is to go into the ToC. By
% default add everything.
%    \begin{macrocode}
\newif\if@dotocbib\@dotocbibtrue
\newif\if@dotocind\@dotocindtrue
\newif\if@dotoctoc\@dotoctoctrue
\newif\if@dotoclot\@dotoclottrue
\newif\if@dotoclof\@dotocloftrue

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@donumbib}
% \begin{macro}{\if@donumindex}
%    A set of booleans for deciding whether or not to produce numbered
% headings (default is to do unnumbered headings).
%    \begin{macrocode}
\newif\if@donumbib\@donumbibfalse
\newif\if@donumindex\@donumindexfalse
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@dot@cb@bsection}
%    If TRUE, use a section heading for the bibliography no matter what
% the main document divisions are.
% \changes{v1.5e}{2003/01/22}{Added \cs{if@dot@cb@bsection}}
%    \begin{macrocode}
\newif\if@dot@cb@bsection\@dot@cb@bsectionfalse

%    \end{macrocode}
% \end{macro}
%
%    Now we can do the options. Most of them are easy.
%    \begin{macrocode}
\DeclareOption{section}{\@bibchapterfalse}
\DeclareOption{notbib}{\@dotocbibfalse}
\DeclareOption{notindex}{\@dotocindfalse}
\DeclareOption{nottoc}{\@dotoctocfalse}
\DeclareOption{notlot}{\@dotoclotfalse}
\DeclareOption{notlof}{\@dotocloffalse}
\DeclareOption{numbib}{\@donumbibtrue}
\DeclareOption{numindex}{\@donumindextrue}

%    \end{macrocode}
%  The \Lopt{chapter} option needs to check whether or not the chapter
%  heading commands are defined. If they are not, then go with the
%  section level headings.
%    \begin{macrocode}
\DeclareOption{chapter}{%
  \if@bibchapter\else
    \PackageWarning{tocbibind}%
                   {Chapters are undefined, using section instead}
  \fi}

%    \end{macrocode}
%
% The \Lopt{other} option makes |\@bibquit| a no-op and cancels any 
% chapter based processing.
% \changes{v1.3}{1999/08/22}{Added the `other' option}
%    \begin{macrocode}
\DeclareOption{other}{\renewcommand{\@bibquit}{}
                      \@bibchapterfalse}
%    \end{macrocode}
%
% The \Lopt{none} option turns everything off.
% \changes{v1.}{2000/03/04}{Added the `none' option}
%    \begin{macrocode}
\DeclareOption{none}{%
  \@dotocbibfalse
  \@dotocindfalse
  \@dotoctocfalse
  \@dotoclotfalse
  \@dotocloffalse
  \@donumbibfalse
  \@donumindexfalse
}
%    \end{macrocode}
%
% Process the options now, and then quit if necessary.
% \changes{v1.3}{1999/08/22}{Now quit after option processing}
%    \begin{macrocode}
\ProcessOptions\relax
\@bibquit

%    \end{macrocode}
%
% Issue a note about the heading style being used.
% \changes{v1.3a}{1999/09/12}{Replaced PackageWarning here by PRWPackageNoteNoLine}
%    \begin{macrocode}
\if@bibchapter
  \PRWPackageNoteNoLine{tocbibind}{Using chapter style headings, unless overridden}
\else
  \PRWPackageNoteNoLine{tocbibind}{Using section or other style headings}
\fi
%    \end{macrocode}
%
% Ensure that the index is not processed if it is an \Lpack{ltxdoc} class.
%    \begin{macrocode}
\if@inltxdoc \@dotocindfalse \fi

%    \end{macrocode}
%
% \begin{macro}{\@tocextra}
% \begin{macro}{\tocotherhead}
%  |\@tocextra| is the internal command to store the heading command name.
% |\tocotherhead{|\meta{name}|}| is the user command to set the
% heading command \meta{name} (without the backslash). 
% The default is section.
% \changes{v1.3}{1999/08/22}{Renamed tocextrahead command as tocotherhead}
%    \begin{macrocode}
\newcommand{\@tocextra}{section}
\newcommand{\tocotherhead}[1]{\renewcommand{\@tocextra}{#1}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocetcmark}
% \begin{macro}{\prw@mkboth}
% \begin{macro}{\toc@section}
% \begin{macro}{\toc@headstar}
%    Utility macros, as the code that they represent gets
%  used several times over. They deal with marking for page headers
%  (code taken from \file{classes.dtx}),
%  and adding starred sectional headings to the ToC.
%
% |\tocetcmark|\marg{text} is the default mark code as called by
% sectional headings.
% \changes{v1.5b}{2001/11/10}{Added \cs{tocetcmark}}
% \changes{v1.5c}{2002/03/11}{Changed \cs{@markboth} to \cs{@mkboth} in \cs{tocetcmark}}
%    \begin{macrocode}
\newcommand{\tocetcmark}[1]{%
  \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
%    \end{macrocode}
%
% |\prw@mkboth|\marg{text} is used later for the ToC headings.
% \changes{v1.5b}{2001/11/10}{Defined \cs{prw@mkboth} in terms of
%     \cs{tocetcmark}}
%    \begin{macrocode}
\newcommand{\prw@mkboth}[1]{\tocetcmark{#1}}
%    \end{macrocode}
%
% |\toc@section{|\meta{sec}|}{|\meta{text}|}| is a generalised version
% of |\sec*{|\meta{text}|}| which also makes an entry of \meta{text} into
% the ToC, where \meta{sec} is the name of a sectional division (with no
% backslash). |\toc@headstar{|\meta{sec}|}{|\meta{text}|}| is similar except
% that it makes no entry into the ToC.
% \changes{v1.5}{2001/04/17}{Added \cs{phantomsection} to \cs{toc@section}
%          and \cs{toc@chapter}}
% \changes{v1.5j}{2009/12/28}{Removed \cs{phantomsection}}
%    \begin{macrocode}
\newcommand{\toc@section}[2]{%
  \@nameuse{#1}*{#2\prw@mkboth{#2}}
  \addcontentsline{toc}{#1}{#2}}
\newcommand{\toc@headstar}[2]{%
  \@nameuse{#1}*{{#2}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\toc@chapter}
% |\toc@chapter{|\meta{text}|}| is equivalent to |\chapter*{|\meta{text}|}|
% except that it makes an entry into the ToC.
%
%  Until version 1.5f the chapter part of the code was |\chapter*{#1\prw@mkboth{#1}}|.
% On 2003/03/12 James Szinger\footnote{\texttt{szinger@lanl.gov}} wrote that
% this failed for a bibliography in a two column book; the page headings
% for the previous chapter continued through the bibliography! James
% suggested that the mark
% part should be moved outside the chapter part (as is now done). I have
% no idea why there should have been this problem. As part of looking at
% it I even replaced the \cs{toc@chapter} as used in the |thebibliography|
% environment with the standard book class definition, which failed as
% well. 
%
% \changes{v1.5g}{2003/03/13}{Minor, but vital, change to \cs{toc@chapter}}
% \changes{v1.5j}{2009/12/28}{Removed \cs{phantomsection}}
%    \begin{macrocode}
\newcommand{\toc@chapter}[1]{%
  \chapter*{#1}\prw@mkboth{#1}
  \addcontentsline{toc}{chapter}{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tocbibname}
%    This holds the text for the Bibliography heading. We try and
% get the text from the class (either |\bibname| or |\refname|).
%    \begin{macrocode}
\ifx\bibname\undefined
  \ifx\refname\undefined
    \newcommand{\tocbibname}{References}
  \else
    \newcommand{\tocbibname}{\refname}
  \fi
\else
  \newcommand{\tocbibname}{\bibname}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setindexname}
% \begin{macro}{\settocname}
% \begin{macro}{\setlotname}
% \begin{macro}{\setlofname}
% \begin{macro}{\settocbibname}
%    The remaining heading texts are simpler as we only need to check
% if their respective names are defined in the class. Note that these
% commands in version 1.2 have been changed from version 1.1 in order to
% integrate with the \Lpack{tocloft} package (which operates with
% the |\contentsname| etc commands).
%    \begin{macrocode}
\providecommand{\indexname}{Index}
\newcommand{\setindexname}[1]{\renewcommand{\indexname}{#1}}
\providecommand{\contentsname}{Contents}
\newcommand{\settocname}[1]{\renewcommand{\contentsname}{#1}}
\providecommand{\listtablename}{List of Tables}
\newcommand{\setlotname}[1]{\renewcommand{\listtablename}{#1}}
\providecommand{\listfigurename}{List of Figures}
\newcommand{\setlofname}[1]{\renewcommand{\listfigurename}{#1}}
\newcommand{\settocbibname}[1]{\renewcommand{\tocbibname}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    The rest is just hacking the various environments and commands
% from \file{classes.dtx}.
%
% Following a suggestion by Donald Arseneau (CTT, `Re: memoir, natbib, and
% chapterbib', 9 Jan 2003), use |\bibsection| as a hook into 
% |thebibliography| for the style of the heading.
%
% \begin{macro}{\t@cb@bchapsection}
% \begin{macro}{\t@cb@bsection}
%  Internal macros holding the heading for |thebibliography|.
% \changes{v1.5e}{2003/01/13}{Added \cs{t@cb@bchapsec} and \cs{t@cb@bsection}}
%    \begin{macrocode}
\newcommand{\t@cb@bchapsec}{%
  \if@bibchapter
    \if@donumbib
      \chapter{\tocbibname}%
    \else
      \toc@chapter{\tocbibname}%
    \fi
  \else
    \if@donumbib
      \@nameuse{\@tocextra}{\tocbibname}%
    \else
      \toc@section{\@tocextra}{\tocbibname}%
    \fi
  \fi}
\newcommand{\t@cb@bsection}{%
  \if@donumbib
    \@nameuse{\@tocextra}{\tocbibname}%
  \else
    \toc@section{\@tocextra}{\tocbibname}%
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%    Redefine \Lenv{thebibliography}, but only if requested. Take care that
% the \Lpack{natbib} package has not already modified the environment, noting
% that \Lpack{natbib} defines and uses |\bibsection|.
% \changes{v1.5e}{2003/01/13}{Major changes in redefining the thebibliography environment}
%    \begin{macrocode}
\if@dotocbib
%    \end{macrocode}
%
%    \begin{macrocode} 
  \@ifpackageloaded{natbib}{}{% natbib not loaded
%    \end{macrocode}
% The natbib package has not been used (yet), so go ahead and change
% the environment.
% \begin{macro}{\bibsection}
% Macro holding heading for |thebibliography|.
% \changes{v1.5e}{2003/01/13}{Added \cs{bibsection}}
%    \begin{macrocode}
    \newcommand{\bibsection}{\t@cb@bchapsec}
%    \end{macrocode}
% \end{macro}
% \begin{environment}{thebibliography}
% \changes{v1.5e}{2003/01/13}{Changed thebibliography to use \cs{bibsection}}
%    \begin{macrocode}
    \renewenvironment{thebibliography}[1]{%
      \bibsection
      \begin{thebibitemlist}{#1}}{\end{thebibitemlist}}}
%    \end{macrocode}
% \end{environment}
%
%
% \begin{environment}{thebibitemlist}
%    Just as a matter of style, I have extracted the list making code
% from the definition of the \Lenv{thebibliography}. It might also
% make it easier for someone to change the list environment.
% The code is a straight copy from \file{classes.dtx}.
%    \begin{macrocode}
  \newenvironment{thebibitemlist}[1]{
    \list{\@biblabel{\@arabic\c@enumiv}}%
         {\settowidth\labelwidth{\@biblabel{#1}}%
          \leftmargin\labelwidth
          \advance\leftmargin\labelsep
          \@openbib@code
          \usecounter{enumiv}%
          \let\p@enumiv\@empty
          \renewcommand\theenumiv{\@arabic\c@enumiv}}%
    \sloppy
    \clubpenalty4000
    \@clubpenalty \clubpenalty
    \widowpenalty4000%
    \sfcode`\.\@m}
   {\def\@noitemerr
     {\@latex@warning{Empty `thebibliography' environment}}%
     \endlist}

%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\sectionbib}
%    The \Lpack{chapterbib} package defines a macro |\sectionbib|
% which, if its |sectionbib| option is used, it calls at the beginning 
% of the document to fiddle with
% the |thebibliography| environment (but it doesn't work when it
% is renewed as above). We need to disable the macro because we do
% our own fiddling
% \changes{v1.5e}{2003/01/22}{Killed \cs{sectionbib} from the chapterbib
%                             package}
%    \begin{macrocode}
  \@ifpackagewith{chapterbib}{sectionbib}%
    {\renewcommand{\sectionbib}[2]{}}%
    {}

%    \end{macrocode}
% \end{macro}
% This is the end of |\if@dotocbib|.
%    \begin{macrocode}
\fi

%    \end{macrocode}
%
%    At the end of the preamble we have to check if the \Lpack{natbib}
% and/or \Lpack{chapterbib} packages have been loaded after the 
% \Lpack{tocbibind} package. If this is the case, we have to make sure
% that we have control with respect to their |sectionbib| options.
% \changes{v1.5e}{2003/01/22}{Added code to cater for natbib and chapterbib
%                             packages}
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackagewith{natbib}{sectionbib}{\@dot@cb@bsectiontrue}{}
%    \end{macrocode}
% If the \Lpack{chapterbib} package was loaded before \Lpack{tocbibind}
% we have already killed |\sectionbib|. If \Lpack{chapterbib} has been 
% loaded afterwards
% we must kill |\sectionbib| now before it gets used.
%    \begin{macrocode}
  \@ifpackagewith{chapterbib}{sectionbib}%
    {\@dot@cb@bsectiontrue
     \@ifundefined{sectionbib}{}{\def\sectionbib#1#2{}}}%
    {}

%    \end{macrocode}
% Lastly, use our definition of |\bibsection| for the |thebibliography|
% environment.
%    \begin{macrocode}
  \if@dotocbib
    \if@dot@cb@bsection
      \renewcommand{\bibsection}{\t@cb@bsection}%
    \else
      \renewcommand{\bibsection}{\t@cb@bchapsec}%
    \fi
  \fi
%    \end{macrocode}
% This is the end of |\AtBeginDocument|
%    \begin{macrocode}
}

%    \end{macrocode}
%
% \begin{environment}{theindex}
% In an earlier version of this
% package, for reasons that I didn't
% understand, I had to add/remove some vertical space around the Index heading
% to make its height match other chapter/section headings. In an unrelated
% thread on the \texttt{comp.text.tex} newsgroup, 
% Donald Arseneau pointed out that
% that this effect was a known feature of the standard classes and
% recorded as latex bug~3126, and was caused by misplaced topskips. The
% following removes this feature for all except the \Lpack{doc} class.
% \changes{v1.4}{2000/03/04}{Fixed index head spacing for all standard classes}
%
% The first bit of code is a copy from \file{classes.dtx}.
%    \begin{macrocode}
\if@inltxdoc\else
  \renewenvironment{theindex}%
    {\if@twocolumn
       \@restonecolfalse
     \else
       \@restonecoltrue
     \fi
%    \end{macrocode}
% This next bit is where we make the package changes. Note that in the
% default definition the values for |\columnseprule| and |\columnsep|
% were set at this point to be |0pt| and |35pt| respectively. They
% are not set in this definition so that they can be adjusted by the
% user, if necessary, before starting the environment.
% \changes{v1.3}{1999/08/22}{Assorted changes for the index}
% \changes{v1.5}{2001/04/17}{Added \cs{phantomsection} to the theindex environment}
% \changes{v1.5f}{2003/02/04}{Replaced \cs{MakeUppercase} code from theindex environment}
% \changes{v1.5j}{2009/12/28}{Removed \cs{phantomsection}}
%    \begin{macrocode}
     \if@bibchapter
        \if@donumindex
          \refstepcounter{chapter}
          \twocolumn[\vspace*{2\topskip}%
                     \@makechapterhead{\indexname}]%
          \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}\indexname}
          \chaptermark{\indexname}
        \else
          \if@dotocind
            \twocolumn[\vspace*{2\topskip}%
                       \@makeschapterhead{\indexname}]%
            \prw@mkboth{\indexname}
            \addcontentsline{toc}{chapter}{\indexname}
          \else
            \twocolumn[\vspace*{2\topskip}%
                       \@makeschapterhead{\indexname}]%
            \prw@mkboth{\indexname}
          \fi
        \fi
     \else
        \if@donumindex
          \twocolumn[\vspace*{-1.5\topskip}%
                     \@nameuse{\@tocextra}{\indexname}]%
          \csname \@tocextra mark\endcsname{\indexname}
        \else
          \if@dotocind
            \twocolumn[\vspace*{-1.5\topskip}%
                       \toc@headstar{\@tocextra}{\indexname}]%
            \prw@mkboth{\indexname}
            \addcontentsline{toc}{\@tocextra}{\indexname}
          \else
            \twocolumn[\vspace*{-1.5\topskip}%
                       \toc@headstar{\@tocextra}{\indexname}]%
            \prw@mkboth{\indexname}
          \fi
        \fi
     \fi
%    \end{macrocode}
% Now we are back to the original code.
%    \begin{macrocode}
   \thispagestyle{plain}\parindent\z@
   \parskip\z@ \@plus .3\p@\relax
   \let\item\@idxitem}
   {\if@restonecol\onecolumn\else\clearpage\fi}
\fi

%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\toc@start}
% \begin{macro}{\toc@finish}
%  These two macros deal with the start and finish of the |\tableofcontents|
% and friends by adjusting the column settings if need be.
%    \begin{macrocode}
\newcommand{\toc@start}{%
  \if@bibchapter
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
  \fi}

\newcommand{\toc@finish}{%
  \if@bibchapter
    \if@restonecol\twocolumn\fi
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocfile}
%    The code for |\tableofcontents|, |\listoftables| and |\listoffigures|
% is virtually identical in each case, except for the heading text.
% |\tocfile| embodies the common code. This is virtually a parameterized copy
% from \file{classes.dtx}, except that it handles the differences between
% the \Lpack{article} class and the other two, and incorporates the
% code for additions to the ToC. It is a useful hook if any other
% package wants to extend \Lpack{tocbibind} for other kinds of listings.
%
%    The command is |\tocfile{|\meta{head-text}|}{|\meta{file-extension}|}|,
% where \meta{head-text} is the heading (e.g., List of Figures)
% and \meta{file-extension} is the file extension (e.g., \file{lof}).
%    \begin{macrocode}
\newcommand{\tocfile}[2]{%
  \toc@start
%    \end{macrocode}
% The next bit is for the heading changes.
%    \begin{macrocode}
  \if@bibchapter
    \toc@chapter{#1}
  \else
    \toc@section{\@tocextra}{#1}
  \fi
%    \end{macrocode}
% And finish up with a parameterized call to start the listing and tidy up.
%    \begin{macrocode}
  \@starttoc{#2}
  \toc@finish}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tableofcontents}
%    If requested, we redefine this command, using |\tocfile| to do
% all the work for us.
%    \begin{macrocode}
\if@dotoctoc
  \renewcommand{\tableofcontents}{%
    \tocfile{\contentsname}{toc}
  }
\fi

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listoftables}
%  This is almost identical to the code for |\tableofcontents|
%    \begin{macrocode}
\if@dotoclot
  \renewcommand{\listoftables}{%
    \tocfile{\listtablename}{lot}
  }
\fi

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listoffigures}
%  This is almost identical to the code for |\tableofcontents|
%    \begin{macrocode}
\if@dotoclof
  \renewcommand{\listoffigures}{%
    \tocfile{\listfigurename}{lof}
  }
\fi

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\simplechapter}
% \begin{macro}{\restorechapter}
% \begin{macro}{\simplechapterdelim}
% The |\simplechapter| command modifies the |\@makechapterhead| command to
% result in an appearance akin to |\@makeschapterhead|, and is based on the
% latter. The |\restorechapter| command restores everything back to its
% original state. The value of |\simplechapterdelim| is appended to the
% chapter number before the title text.
% \changes{v1.4}{2000/03/04}{Added \cs{simplechapter} and \cs{restorechapter}
% commands}
% \changes{v1.4a}{2000/03/05}{Added \cs{simplechapterdelim} command}
% \changes{v1.5a}{2000/08/07}{Added undefined test to \cs{restorechapter}}
%    \begin{macrocode}
\newcommand{\simplechapter}[1][\@empty]{%
  \let\@tbiold@makechapterhead\@makechapterhead
  \renewcommand{\@makechapterhead}[1]{%
    \vspace*{50\p@}%
    {\parindent \z@ \raggedright
     \normalfont
     \interlinepenalty\@M
     \Huge\bfseries #1\space\thechapter\simplechapterdelim\space 
        ##1\par\nobreak
     \vskip 40\p@
   }}
}
\newcommand{\restorechapter}{%
  \@ifundefined{@tbiold@makechapterhead}{}%
  {\let\@makechapterhead\@tbiold@makechapterhead}
}
\newcommand{\simplechapterdelim}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocchapter}
% \begin{macro}{\tocsection}
% These two commands modify the |\toc@chapter| and |\toc@section| commands
% to make numbered Listof headings.
% \changes{v1.4}{2000/03/04}{Added \cs{tocchapter} and \cs{tocsection}
% commands}
% \changes{v1.5d}{2002/04/09}{Provided \cs{@makechapterhead} in \cs{tocchapter}}
%    \begin{macrocode}
\newcommand{\tocchapter}{%
  \providecommand{\@makechapterhead}{}
  \simplechapter
  \renewcommand{\toc@chapter}[1]{\chapter{##1}}
}
\newcommand{\tocsection}{%
  \renewcommand{\toc@section}[2]{\@nameuse{##1}{##2}}
}
    
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%    The end of this package.
%    \begin{macrocode}
%</usc>
%    \end{macrocode}
%
%
% \bibliographystyle{alpha}
%
% \begin{thebibliography}{GMS94}
%
% \bibitem[GMS94]{GOOSSENS94}
% Michel Goossens, Frank Mittelbach, and Alexander Samarin.
% \newblock {\em The LaTeX Companion}.
% \newblock Addison-Wesley Publishing Company, 1994.
%
% \bibitem[Wil96]{PRW96i}
% Peter~R. Wilson.
% \newblock {\em {LaTeX for standards: The LaTeX package files user manual}}.
% \newblock NIST Report NISTIR, June 1996.
%
% \end{thebibliography}
%
%
% \Finale
% \PrintIndex
%
\endinput

%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}