The tocbibind package^{∗}

Peter Wilson Catholic University of America

             Now at peter.r.wilson@boeing.com

2003/02/04

Abstract The 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 book, report, article and proc classes, and to a limited extent with the ltxdoc class. Results with other classes may be problematical. The package has been tested with the tocloft package, but has not been tested with other packages that change the definitions of the

     \chapter* or \section* commands.

Contents

1 Introduction 1

2 The tocbibind package 2 2.1 Numbering the List of Figures, etc. . . . . . . . . . . . . . . . . . . 3 2.2 Page styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.3 Package Defined Listof... . . . . . . . . . . . . . . . . . . . . . . . . 5 2.4 Abstracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 The package code 6

1 Introduction

n Questions about adding the bibliography to the Table of Contents seem to pop up fairly regularly on the comp.text.tex newsgroup.

The 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. (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 [Wil96]. This manual is typeset according to the conventions of the L^{A}TEX docstrip utility which enables the automatic extraction of the L^{A}TEX macro source files [GMS94].

Section 2 describes the usage of the package. Commented source code for the package is in Section 3.

∗This file has version number v1.5f, last revised 2003/02/04.

2 The tocbibind package

The 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.

• notbib Disables the inclusion of the Bibliography.

• notindex Disables the inclusion of the Index (inclusion of the Index of an ltxdoc class document is permanantly disabled).

• nottoc Disables the inclusion of the ToC.

• notlot Disables the inclusion of the List of Tables.

• notlof Disables the inclusion of the List of Figures.

• chapter Use chapter-level headings, if possible.

• section Use section-level headings, if possible.

• numbib Number the Bibliography heading (default is no number).

• numindex Number the Index heading (default is no number).

• other Use a non-traditional heading command. This option effectively requires the use of the \tocotherhead command.

• none Disables everything.

The package is designed to work with the standard L^{A}TEX document classes book, report, article, proc and ltxdoc class (which is based to a large extent on the article class). In the article, proc and ltxdoc classes L^{A}TEX uses the \section* heading style for the bibliography etc., while for the other two classes it uses the \chapter* heading style. 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 chapter or 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 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 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 none option is to limit any changes to the single one of disabling this standard feature.

\tocotherhead In the standard L^{A}TEX 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 other option and the \tocotherhead{⟨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 chapter or section option.

\tocbibname The package attempts to pick up the name for the Bibliography from the class definition. (Note that the article class and its derivatives stores the name text in the \refname whilst the book and report classes store the name in \bibname). This package uses \tocbibname to store the name of the bibliography.

\setindexname These commands set the heading texts for the index, ToC, list of tables and list

\settocname
\setlotname
\setlofname
\settocbibname

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{⟨name⟩}, and similarly for the other headings. Thus, the following two lines of code have the same effect:

 \renewcommand{\listfigurename}{Figures}
 \setlofname{Figures}

Note that these commands replace the \toc...name commands that were in version 1.1.

2.1 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.

\simplechapter In chaptered documents, the Listof headings are effectively typeset as \chapter*{}.

\simplechapterdelim
\restorechapter

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[⟨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 ⟨name⟩ argument is present, the ⟨name⟩ is typeset before the number. For example:

 \renewcommand{\simplechapterdelim}{:}
 \simplechapter[Chap]

will result in \chapter{First chapter} being typeset like: Chap 1: First chapter. The \restorechapter command resets any subsequent \chapter commands to their default behaviour.

\tocchapter Internally, the Listof commands in the tocbibind package use \toc@chapter

\tocsection

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:

 \renewcommand{\listoffigures}{\begingroup
    \tocchapter
    \tocfile{\listfigurename}{lof}
 \endgroup}

while to get a numbered List of Tables in a non-chaptered document:

 \renewcommand{\listoftables}{\begingroup
    \tocsection
    \tocfile{\listtablename}{lot}
 \endgroup}

More generally, to number the Table of Contents in a (non-)chaptered document you can do:

 \renewcommand{\tableofcontents}{\begingroup
    \tocsection
    \tocchapter
    \tocfile{\contentsname}{toc}
 \endgroup}

The \begingroup \endgroup pairing keeps the changes local.

2.2 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 fancyhdr package, are indirectly supported.

As an example, assume that you are using the fancyhdr package and you use a fancy pagestyle in a book/report class document like:

 \pagestyle{fancy}
 \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}

then you will find that the chapter titles in headers are in normalcase but the ToC, etc., headers are still in uppercase.

\tocetcmark In this package, the marks for the ToC, LoF… headers are specified via the command \tocetcmark{⟨head⟩}. To match the fancy pagestyle this must be redefined, like:

 \pagestyle{fancy}
 \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
 \renewcommand{\tocetcmark}[1]{\markboth{#1}{}}

which will give normalcase headers for the ToC, LoF. … 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.

2.3 Package Defined Listof...

There are packages, such as listings and ccaption, that provide new Listof lists. These can be handled by the tocbibind package in a similar manner to the usual Listofs. Two examples are given below.

The 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:

 \renewcommand{\lstlistoflistings}{\begingroup
    \tocfile{\lstlistingname}{lol}
 \endgroup}

and to number the Listof heading do:

 \renewcommand{\lstlistoflistings}{\begingroup
    \tocsection
    \tocchapter
    \tocfile{\lstlistingname}{lol}
 \endgroup}

The 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{⟨fenv⟩}{⟨ext⟩}{⟨listname⟩}{⟨capname⟩}, where ⟨fenv⟩ is the name of the new float environment and ⟨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 ⟨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):

 \newcommand{\listofdia}{\begingroup
    \tocfile{List of Diagrams}{dia}
 \endgroup}

and correspondingly for a numbered version:

 \newcommand{\listofdia}{\begingroup
    \tocsection
    \tocchapter

    \tocfile{List of Diagrams}{dia}
 \endgroup}

and then use \listofdia instead of \listofdiagram.

2.4 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 section might have to be chapter, and if you are using the hyperref package you have to use the \phantomsection macro.

   \begin{abstract}
   % \phantomsection  % required if using hyperref
   \addcontentsline{toc}{section}{\abstractname}
   ... rest of the abstract

3 The package code

Announce the name and version of the package, which requires L^{A}TEX 2ε.

1 ⟨∗usc⟩

 2 \NeedsTeXFormat{LaTeX2e}
 3 \ProvidesPackage{tocbibind}[2003/02/04 v1.5f extra ToC listings]

4

\PRWPackageNote \PRWPackageNoteNoLine These two commands write a package Note to the terminal and log file. Use as \PRWPackageNote{⟨package name⟩}{⟨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 lterror.dtx.

 5 \providecommand{\PRWPackageNote}[2]{%
 6 \GenericWarning{%
 7  (#1)\@spaces\@spaces\@spaces\@spaces
 8 }{%
 9  Package #1 Note: #2%
10 }%

11 }

12 \providecommand{\PRWPackageNoteNoLine}[2]{%
13 \PRWPackageNote{#1}{#2\@gobble}%

14 }

15

\@bibquit \if@bibchapter We need to know what sectional divisions are supported.

16 \newcommand{\@bibquit}{}
17 \newif\if@bibchapter
18 \@ifundefined{chapter}{%
19 \@bibchapterfalse
20 \@ifundefined{section}{%
21  \PackageWarning{tocbibind}%
22  {I don't recognize any sectional divisions.\MessageBreak

23  I hope you have used the `other' option\MessageBreak
24  otherwise I'll ignore the package}
25  \renewcommand{\@bibquit}{\endinput}
26  }{\PRWPackageNoteNoLine{tocbibind}{The document has section divisions}}
27 }{\@bibchaptertrue
28  \PRWPackageNoteNoLine{tocbibind}{The document has chapter divisions}}

29

\if@inltxdoc This is used as a flag for the ltxdoc class. This has a particular kind of index that I am not going to mess with.

30 \newif\if@inltxdoc
31 \@ifclassloaded{ltxdoc}{\@inltxdoctrue}{\@inltxdocfalse}

32

\if@dotocbib \if@dotocind \if@dotoctoc \if@dotoclot \if@dotoclof A set of booleans for deciding what is to go into the ToC. By default add everything.

33 \newif\if@dotocbib\@dotocbibtrue
34 \newif\if@dotocind\@dotocindtrue
35 \newif\if@dotoctoc\@dotoctoctrue
36 \newif\if@dotoclot\@dotoclottrue
37 \newif\if@dotoclof\@dotocloftrue

38

\if@donumbib \if@donumindex A set of booleans for deciding whether or not to produce numbered headings (default is to do unnumbered headings).

39 \newif\if@donumbib\@donumbibfalse
40 \newif\if@donumindex\@donumindexfalse

\if@dot@cb@bsection If TRUE, use a section heading for the bibliography no matter what the main document divisions are.

41 \newif\if@dot@cb@bsection\@dot@cb@bsectionfalse

42

Now we can do the options. Most of them are easy.

43 \DeclareOption{section}{\@bibchapterfalse}
44 \DeclareOption{notbib}{\@dotocbibfalse}
45 \DeclareOption{notindex}{\@dotocindfalse}
46 \DeclareOption{nottoc}{\@dotoctocfalse}
47 \DeclareOption{notlot}{\@dotoclotfalse}
48 \DeclareOption{notlof}{\@dotocloffalse}
49 \DeclareOption{numbib}{\@donumbibtrue}
50 \DeclareOption{numindex}{\@donumindextrue}

51

The 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.

52 \DeclareOption{chapter}{%
53 \if@bibchapter\else
54  \PackageWarning{tocbibind}%
55  {Chapters are undefined, using section instead}
56 \fi}

57

The other option makes \@bibquit a no-op and cancels any chapter based processing.

58 \DeclareOption{other}{\renewcommand{\@bibquit}{}
59  \@bibchapterfalse}

The none option turns everything off.

60 \DeclareOption{none}{%
61 \@dotocbibfalse
62 \@dotocindfalse
63 \@dotoctocfalse
64 \@dotoclotfalse
65 \@dotocloffalse
66 \@donumbibfalse
67 \@donumindexfalse

68 }

Process the options now, and then quit if necessary.

69 \ProcessOptions\relax
70 \@bibquit

71

Issue a note about the heading style being used.

72 \if@bibchapter
73 \PRWPackageNoteNoLine{tocbibind}{Using chapter style headings, unless overridden}
74 \else
75 \PRWPackageNoteNoLine{tocbibind}{Using section or other style headings}
76 \fi

Ensure that the index is not processed if it is an ltxdoc class.

77 \if@inltxdoc \@dotocindfalse \fi

78

\@tocextra \tocotherhead \@tocextra is the internal command to store the heading command name. \tocotherhead{⟨name⟩} is the user command to set the heading command ⟨name⟩ (without the backslash). The default is section.

79 \newcommand{\@tocextra}{section}
80 \newcommand{\tocotherhead}[1]{\renewcommand{\@tocextra}{#1}}

81

\phantomsection \phantomsection is needed if the hyperref package is used to give some sort of mark for \addcontentsline. Read the hyperref documentation to see if you can work out why.

82 \providecommand{\phantomsection}{}

83

\tocetcmark \prw@mkboth \toc@section \toc@chapter \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 classes.dtx), and adding starred sectional headings to the ToC.

\tocetcmark{⟨text⟩} is the default mark code as called by sectional headings.

84 \newcommand{\tocetcmark}[1]{%
85 \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}

\prw@mkboth{⟨text⟩} is used later for the ToC headings.

86 \newcommand{\prw@mkboth}[1]{\tocetcmark{#1}}

87

\toc@section{⟨sec⟩}{⟨text⟩} is a generalised version of \sec*{⟨text⟩} which also makes an entry of ⟨text⟩ into the ToC, where ⟨sec⟩ is the name of a sectional division (with no backslash). \toc@headstar{⟨sec⟩}{⟨text⟩} is similar except that it makes no entry into the ToC.

 88 \newcommand{\toc@section}[2]{%
 89 \@nameuse{#1}*{#2\prw@mkboth{#2}}
 90 \phantomsection
 91 \addcontentsline{toc}{#1}{#2}}

92

 93 \newcommand{\toc@headstar}[2]{%
 94 \@nameuse{#1}*{{#2}}}

95

\toc@chapter{⟨text⟩} is equivalent to \chapter*{⟨text⟩} except that it makes an entry into the ToC.

 96 \newcommand{\toc@chapter}[1]{%
 97 \chapter*{#1\prw@mkboth{#1}}
 98 \phantomsection
 99 \addcontentsline{toc}{chapter}{#1}}

100

\tocbibname This holds the text for the Bibliography heading. We try and get the text from the class (either \bibname or \refname).

101 \ifx\bibname\undefined
102 \ifx\refname\undefined
103  \newcommand{\tocbibname}{References}
104 \else
105  \newcommand{\tocbibname}{\refname}
106 \fi
107 \else
108 \newcommand{\tocbibname}{\bibname}
109 \fi

110

\setindexname \settocname \setlotname \setlofname \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 tocloft package (which operates with the \contentsname etc commands).

111 \providecommand{\indexname}{Index}
112 \newcommand{\setindexname}[1]{\renewcommand{\indexname}{#1}}
113 \providecommand{\contentsname}{Contents}
114 \newcommand{\settocname}[1]{\renewcommand{\contentsname}{#1}}
115 \providecommand{\listtablename}{List of Tables}
116 \newcommand{\setlotname}[1]{\renewcommand{\listtablename}{#1}}
117 \providecommand{\listfigurename}{List of Figures}
118 \newcommand{\setlofname}[1]{\renewcommand{\listfigurename}{#1}}
119 \newcommand{\settocbibname}[1]{\renewcommand{\tocbibname}{#1}}

120

The rest is just hacking the various environments and commands from

 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.

\t@cb@bchapsection \t@cb@bsection Internal macros holding the heading for thebibliography.
121 \newcommand{\t@cb@bchapsec}{%
122 \if@bibchapter
123  \if@donumbib
124  \chapter{\tocbibname}%
125  \else
126  \toc@chapter{\tocbibname}%
127  \fi
128 \else
129  \if@donumbib
130  \@nameuse{\@tocextra}{\tocbibname}%
131  \else
132  \toc@section{\@tocextra}{\tocbibname}%
133  \fi
134 \fi}
135 \newcommand{\t@cb@bsection}{%
136 \if@donumbib
137  \@nameuse{\@tocextra}{\tocbibname}%
138 \else
139  \toc@section{\@tocextra}{\tocbibname}%
140 \fi}

141

Redefine thebibliography, but only if requested. Take care that the natbib package has not already modified the environment, noting that natbib defines and

 uses \bibsection.
142 \if@dotocbib
143 \@ifpackageloaded{natbib}{}{% natbib not loaded

The natbib package has not been used (yet), so go ahead and change the environment.

\bibsection Macro holding heading for thebibliography.
144  \newcommand{\bibsection}{\t@cb@bchapsec}
thebibliography
145  \renewenvironment{thebibliography}[1]{%
146  \bibsection
147  \begin{thebibitemlist}{#1}}{\end{thebibitemlist}}}

thebibitemlist Just as a matter of style, I have extracted the list making code from the definition of the thebibliography. It might also make it easier for someone to change the list environment. The code is a straight copy from classes.dtx.

148 \newenvironment{thebibitemlist}[1]{
149  \list{\@biblabel{\@arabic\c@enumiv}}%
150  {\settowidth\labelwidth{\@biblabel{#1}}%
151  \leftmargin\labelwidth
152  \advance\leftmargin\labelsep
153  \@openbib@code
154  \usecounter{enumiv}%
155  \let\p@enumiv\@empty
156  \renewcommand\theenumiv{\@arabic\c@enumiv}}%
157  \sloppy

158  \clubpenalty4000
159  \@clubpenalty \clubpenalty
160  \widowpenalty4000%
161  \sfcode`\.\@m}
162 {\def\@noitemerr
163  {\@latex@warning{Empty `thebibliography' environment}}%
164  \endlist}

165

\sectionbib The 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

166 \@ifpackagewith{chapterbib}{sectionbib}%
167  {\renewcommand{\sectionbib}[2]{}}%

168 {}

169

This is the end of \if@dotocbib.

170 \fi

171

At the end of the preamble we have to check if the natbib and/or chapterbib packages have been loaded after the tocbibind package. If this is the case, we have to make sure that we have control with respect to their sectionbib options.

172 \AtBeginDocument{%
173 \@ifpackagewith{natbib}{sectionbib}{\@dot@cb@bsectiontrue}{}

If the chapterbib package was loaded before tocbibind we have already killed \sectionbib. If chapterbib has been loaded afterwards we must kill \sectionbib now before it gets used.

174 \@ifpackagewith{chapterbib}{sectionbib}%
175  {\@dot@cb@bsectiontrue
176  \@ifundefined{sectionbib}{}{\def\sectionbib#1#2{}}}%

177 {}

178

Lastly, use our definition of \bibsection for the thebibliography environment.

179 \if@dotocbib
180  \if@dot@cb@bsection
181  \renewcommand{\bibsection}{\t@cb@bsection}%
182  \else
183  \renewcommand{\bibsection}{\t@cb@bchapsec}%
184  \fi
185 \fi
This is the end of \AtBeginDocument

186 }

187

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 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 doc class.

The first bit of code is a copy from classes.dtx.

188 \if@inltxdoc\else
189 \renewenvironment{theindex}%
190  {\if@twocolumn
191  \@restonecolfalse
192  \else
193  \@restonecoltrue
194  \fi

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.

195  \if@bibchapter
196  \if@donumindex
197  \refstepcounter{chapter}
198  \twocolumn[\vspace*{2\topskip}%
199  \@makechapterhead{\indexname}]%
200  \phantomsection
201  \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}\indexname}
202  \chaptermark{\indexname}
203  \else
204  \if@dotocind
205  \twocolumn[\vspace*{2\topskip}%
206  \@makeschapterhead{\indexname}]%
207  \prw@mkboth{\indexname}
208  \phantomsection
209  \addcontentsline{toc}{chapter}{\indexname}
210  \else
211  \twocolumn[\vspace*{2\topskip}%
212  \@makeschapterhead{\indexname}]%
213  \prw@mkboth{\indexname}
214  \fi
215  \fi
216  \else
217  \if@donumindex
218  \twocolumn[\vspace*{-1.5\topskip}%
219  \@nameuse{\@tocextra}{\indexname}]%
220  \csname \@tocextra mark\endcsname{\indexname}
221  \else
222  \if@dotocind
223  \twocolumn[\vspace*{-1.5\topskip}%
224  \toc@headstar{\@tocextra}{\indexname}]%
225  \prw@mkboth{\indexname}
226  \phantomsection
227  \addcontentsline{toc}{\@tocextra}{\indexname}
228  \else
229  \twocolumn[\vspace*{-1.5\topskip}%
230  \toc@headstar{\@tocextra}{\indexname}]%
231  \prw@mkboth{\indexname}
232  \fi

233  \fi
234  \fi

Now we are back to the original code.

235 \thispagestyle{plain}\parindent\z@
236 \parskip\z@ \@plus .3\p@\relax
237 \let\item\@idxitem}
238 {\if@restonecol\onecolumn\else\clearpage\fi}
239 \fi

240

\toc@start \toc@finish These two macros deal with the start and finish of the \tableofcontents and friends by adjusting the column settings if need be.

241 \newcommand{\toc@start}{%
242 \if@bibchapter
243  \if@twocolumn
244  \@restonecoltrue\onecolumn
245  \else
246  \@restonecolfalse
247  \fi
248 \fi}

249

250 \newcommand{\toc@finish}{%
251 \if@bibchapter
252  \if@restonecol\twocolumn\fi
253 \fi}

254

\tocfile The code for \tableofcontents, \listoftables and \listoffigures is virtu-

ally identical in each case, except for the heading text. \tocfile embodies the common code. This is virtually a parameterized copy from classes.dtx, except that it handles the differences between the 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 tocbibind for other kinds of listings.

The command is \tocfile{⟨head-text⟩}{⟨file-extension⟩}, where ⟨head-text⟩ is the heading (e.g., List of Figures) and ⟨file-extension⟩ is the file extension (e.g.,

lof).
255 \newcommand{\tocfile}[2]{%
256 \toc@start

The next bit is for the heading changes.

257 \if@bibchapter
258  \toc@chapter{#1}
259 \else
260  \toc@section{\@tocextra}{#1}
261 \fi

And finish up with a parameterized call to start the listing and tidy up.

262 \@starttoc{#2}
263 \toc@finish}

264

\tableofcontents If requested, we redefine this command, using \tocfile to do all the work for us.

265 \if@dotoctoc

266 \renewcommand{\tableofcontents}{%
267  \tocfile{\contentsname}{toc}

268 }

269 \fi

270

\listoftables This is almost identical to the code for \tableofcontents

271 \if@dotoclot
272 \renewcommand{\listoftables}{%
273  \tocfile{\listtablename}{lot}

274 }

275 \fi

276

\listoffigures This is almost identical to the code for \tableofcontents

277 \if@dotoclof
278 \renewcommand{\listoffigures}{%
279  \tocfile{\listfigurename}{lof}

280 }

281 \fi

282

\simplechapter \restorechapter \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.

283 \newcommand{\simplechapter}[1][\@empty]{%
284 \let\@tbiold@makechapterhead\@makechapterhead
285 \renewcommand{\@makechapterhead}[1]{%
286  \vspace*{50\p@}%
287  {\parindent \z@ \raggedright
288  \normalfont
289  \interlinepenalty\@M
290  \Huge\bfseries #1\space\thechapter\simplechapterdelim\space
291  ##1\par\nobreak
292  \vskip 40\p@

293 }} 294 }

295 \newcommand{\restorechapter}{%
296 \@ifundefined{@tbiold@makechapterhead}{}%
297 {\let\@makechapterhead\@tbiold@makechapterhead}

298 }

299 \newcommand{\simplechapterdelim}{}

300

\tocchapter \tocsection These two commands modify the \toc@chapter and \toc@section commands to

make numbered Listof headings.

301 \newcommand{\tocchapter}{%
302 \providecommand{\@makechapterhead}{}
303 \simplechapter
304 \renewcommand{\toc@chapter}[1]{\chapter{##1}}

305 }

306 \newcommand{\tocsection}{%
307 \renewcommand{\toc@section}[2]{\@nameuse{##1}{##2}}

308 }

309

The end of this package.

310 ⟨/usc⟩

References

[GMS94] Michel Goossens, Frank Mittelbach, and Alexander Samarin. The LaTeX Companion. Addison-Wesley Publishing Company, 1994.

[Wil96] Peter R. Wilson. LaTeX for standards: The LaTeX package files user manual. NIST Report NISTIR, June 1996.

Index

Numbers written in italic refer to the page where the corresponding entry is described; numbers underlined refer to the code line of the definition; numbers in roman refer to the code lines where the entry is used.

Symbols

\@bibchapterfalse .

. . . . . . . 19, 43, 59

\@bibchaptertrue . . 27
\@biblabel . . . 149, 150

\@bibquit … \underline{16}, 58, 70

\@clubpenalty . . . . . 159
\@donumbibfalse . 39, 66
\@donumbibtrue . . . . 49
\@donumindexfalse 40, 67
\@donumindextrue . . 50
\@dot@cb@bsectionfalse

. . . . . . . . . . . . 41

\@dot@cb@bsectiontrue

. . . . . . . . 173, 175

\@dotocbibfalse . 44, 61
\@dotocbibtrue . . . . 33
\@dotocindfalse . . .

. . . . . . . 45, 62, 77

\@dotocindtrue . . . . 34
\@dotocloffalse . 48, 65
\@dotocloftrue . . . . 37
\@dotoclotfalse . 47, 64
\@dotoclottrue . . . . 36
\@dotoctocfalse . 46, 63
\@dotoctoctrue . . . . 35

\@idxitem . . . . . . . . 237

\@ifclassloaded . . . 31
\@ifpackageloaded . 143

                          \@ifpackagewith . . .

…. 166, 173, 174

                          \@ifundefined . . . . .

. . 18, 20, 176, 296

                          \@inltxdocfalse . . . 31
                          \@inltxdoctrue . . . . 31
                          \@latex@warning . . . 163
                          \@makechapterhead .

. . . . . . . . 199, 284, 285, 297, 302

                          \@makeschapterhead .

. . . . . . . . 206, 212

                          \@nameuse . . . 89, 94,

130, 137, 219, 307

                          \@noitemerr . . . . . . . 162
                          \@openbib@code . . . . 153
                          \@restonecolfalse .

. . . . . . . . 191, 246

                          \@restonecoltrue . .

. . . . . . . . 193, 244 \@spaces . . . . . . . . . . 7

                          \@starttoc . . . . . . . 262
                          \@tbiold@makechapterhead

. . . . . . . . 284, 297

                          \@tocextra . . . . \underline{79},

130, 132, 137, 139, 219, 220, 224, 227, 230, 260

A

                                                   \addcontentsline . .

91, 99, 201, 209, 227

                                                   \AtBeginDocument . . 172

B \bibname . . . . . 101, 108

                                                   \bibsection . . . . . . .

. \underline{144}, 146, 181, 183

C \c@enumiv …. 149, 156 \chapter . . 97, 124, 304

                                                   \chaptermark . . . . . . 202
                                                   \clearpage . . . . . . . 238
                                                   \clubpenalty . . 158, 159
                                                   \contentsname . . . . .

…. 113, 114, 267 \csname . . . . . . . . . . 220

E

                                                   \endcsname . . . . . . . 220

\endinput . . . . . . . . 25 environments:

                                                       thebibitemlist . \underline{148}
                                                       thebibliography   \underline{145}

theindex . . . . . . \underline{188}

G

                                                   \GenericWarning . . . . 6

H

\Huge . . . . . . . . . . . . 290

I

\if@bibchapter . . . .

\underline{16}, 53, 72, 122, 195, 242, 251, 257

\if@donumbib . . . . . .

. \underline{39}, 123, 129, 136

\if@donumindex . . . .

. . . . . \underline{39}, 196, 217

\if@dot@cb@bsection

. . . . . . . . \underline{41}, 180

\if@dotocbib \underline{33}, 142, 179
\if@dotocind \underline{33}, 204, 222
\if@dotoclof . . . \underline{33}, 277
\if@dotoclot . . . \underline{33}, 271
\if@dotoctoc . . . \underline{33}, 265
\if@inltxdoc  \underline{30}, 77, 188
\if@restonecol 238, 252
\if@twocolumn . 190, 243
\indexname . . . 111,

112, 199, 201, 202, 206, 207, 209, 212, 213, 219, 220, 224, 225, 227, 230, 231

\interlinepenalty . 289

\item . . . . . . . . . . . . 237

L

\labelsep . . . . . . . . 152

\labelwidth . . . 150, 151
\leftmargin . . . 151, 152
\listfigurename . . .

…. 117, 118, 279

\listoffigures . . . . \underline{277}
\listoftables . . . . . \underline{271}
\listtablename . . . .

…. 115, 116, 273

M

\MakeUppercase . . . . 85

\MessageBreak . . . 22, 23

N

\newif . . . . . . . . 17,

30, 33–37, 39–41

\normalfont . . . . . . . 288

O

\onecolumn . . . 238, 244

P

\p@enumiv . . . . . . . . 155

\PackageWarning . 21, 54
\parindent . . . 235, 287

\parskip . . . . . . . . . 236

\phantomsection   \underline{82},

90, 98, 200, 208, 226

\providecommand . . .

. 5, 12, 82, 111, 113, 115, 117, 302

\ProvidesPackage . . . 3
\prw@mkboth . . . . \underline{84},

207, 213, 225, 231

\PRWPackageNote . . . . \underline{5}
\PRWPackageNoteNoLine

. . \underline{5}, 26, 28, 73, 75

R

\refname . . . . . 102, 105

\renewenvironment .

. . . . . . . . 145, 189

\restorechapter . 3, \underline{283}

S

\sectionbib . . . \underline{166}, 176
\setindexname . . . 3, \underline{111}
\setlofname . . . . . 3, \underline{111}
\setlotname . . . . . 3, \underline{111}
\settocbibname . . 3, \underline{111}
\settocname . . . . . 3, \underline{111}
\simplechapter . . . .

. . . . . . 3, \underline{283}, 303

\simplechapterdelim

. . . . . . . . . 3, \underline{283}

T

\t@cb@bchapsec . . . .

…. 121, 144, 183

\t@cb@bchapsection . \underline{121}
\t@cb@bsection   \underline{121}, 181
\tableofcontents . . \underline{265}
thebibitemlist (envi-

ronment) … \underline{148}

thebibliography (envi-

ronment) … \underline{145}

\thechapter . . . 201, 290
\theenumiv . . . . . . . 156

theindex (environ-

ment) . . . . . . \underline{188}

\thispagestyle . . . . 235
\toc@chapter . . . . . .

. \underline{84}, 126, 258, 304

\toc@finish . . . \underline{241}, 263
\toc@headstar . . . . .

. . . . . \underline{84}, 224, 230

\toc@section . . . \underline{84},

132, 139, 260, 307

\toc@start . . . \underline{241}, 256
\tocbibname . . 3, \underline{101},

119, 124, 126, 130, 132, 137, 139

\tocchapter . . . . . 3, \underline{301}
\tocetcmark . . . . . . 4, \underline{84}

\tocfile . . . . . . . . .

. \underline{255}, 267, 273, 279

\tocotherhead . . . . 2, \underline{79}
\tocsection . . . . . 3, \underline{301}

\topskip . . 198, 205,

211, 218, 223, 229

\twocolumn . . . . . . .

. 198, 205, 211, 218, 223, 229, 252

W

\widowpenalty . . . . . 160