% \iffalse meta-comment
%
% tocbibind.dtx
% Copyright 1998, 1999 Peter R. Wilson
%
% This program is provided under the terms of the
% LaTeX Project Public License distributed from CTAN
% archives in directory macros/latex/base/lppl.txt.
%
% Author: Peter Wilson (CUA and NIST) (now at: peter.r.wilson@boeing.com)
% 
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\setcounter{StandardModuleDepth}{1}
\begin{document}
  \DocInput{tocbibind.dtx}
\end{document}
%</driver>
%
% \fi
%
% \CheckSum{365}
%
% \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}
%
% \def\fileversion{v1.3a}
% \def\filedate{1999/09/12}
% \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 has version number \fileversion, last revised
%        \filedate.}}
%
% \author{%
% Peter Wilson\\
% Catholic University of America \\
% Now at {\tt peter.r.wilson@boeing.com}
% }
% \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.
%
% The package requres the \Lpack{stdclsdv} package.
% \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}.
% The package requires the \Lpack{stdclsdv} package to be available.
%
% \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.
% \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).
%
% \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 |\tocindexname{|\meta{name}|}|, and similarly for
% the other headings. Thus, the following two lines of code have the 
% same effect:
% \begin{verbatim}
% \renewcommand{\listfigurename}{Figures}
% \toclofname{Figures}
% \end{verbatim}
% \textit{Note that these commands replace the } |\toc...name| 
% \textit{commands that were in version 1.1.}
%
% Unlike the default |theindex| environment, provided the \Lopt{notindex}
% option is not used, the |\columnseprule| and |\columnsep| lengths can be
% changed via |\setlength| to alter the column seperation and the thickness
% of a rule between the two columns in the index.
%
% \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}.
% \begin{verbatim}
%   \begin{abstract}
%   \addcontentsline{toc}{section}{\abstractname}
%   ... rest of the abstract
% \end{verbatim}
%
%     A question that arises from time to time on \file{comp.text.tex}
% is how to have a fullwidth abstract in a two column document.
% The code:
% \begin{verbatim}
% \documentclass[twocolumn]{article}
% % all in twocolumn mode
% ...
% \begin{abstract} ... \end{abstract}
% \end{verbatim}
% puts the abstract into one of the columns. The trick is to start
% the document in single column mode and at the appropriate place
% issue a |\twocolumn| command with the abstract forming the optional
% argument to the command. For example:
% \begin{verbatim}
% \documentclass{article}
% % single column mode
% ...
% \twocolumn[{\begin{abstract}...\end{abstract}}]
% ... rest in two column mode
% \end{verbatim}
%
%     If you want, for example, to have the abstract treated like
% any other numbered part of the document or to change other aspects
% of the abstract environment, then you will have to
% do some work on your own. Just for interest, the default code
% for the abstract environment is:
% \begin{verbatim}
% \if@titlepage
%   \newenvironment{abstract}{%
%     \titlepage
%     \null\vfil
%     \@beginparpenalty\@lowpenalty
%     \begin{center}%
%       \bfseries \abstractname
%       \@endparpenalty\@M
%     \end{center}}%
%     {\par\vfil\null\endtitlepage}
% \else 
%   \newenvironment{abstract}{%
%     \if@twocolumn
%       \section*{\abstractname}%
%     \else
%       \small
%       \begin{center}%
%         {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
%       \end{center}%
%       \quotation
%     \fi}%
%   {\if@twocolumn\else\endquotation\fi}
% \fi
% \end{verbatim}
% This code is from the \Lpack{report} and \Lpack{article} classes;
% the \Lpack{book} class does not have an abstract 
% environment.
% 
% \section{The package code} \label{sec:code}
%
%    Announce the name and version of the package, which requires
% \LaTeXe{} and the \Lpack{stdclsdv} package.
%    \begin{macrocode}
%<*usc>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tocbibind}[1999/09/12 v1.3a extra ToC listings]
\RequirePackage{stdclsdv}
%    \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}
%
% Issue warning(s) if there are no recognized sectional divisions and
% prepare to skip the rest of the package code.
% \changes{v1.3}{1999/08/22}{Now call SCDquit after the options}
%    \begin{macrocode}
\ifSCDnodivs
  \PackageWarning{tocbibind}%
    {I don't recognize any sectional divisions.
     I hope you have used the `other' option}
  \renewcommand{\SCDquit}{\endinput}
\fi
%%\SCDquit
\ifSCDknownclass\else
  \PackageWarning{tocbibind}%
    {| don't recognize the class but I'll do my best}
%%  \ifSCDnodivs
%%    \PackageWarning{tocbibind}%
%%      {I don't recognize any sectional divisions so I'll do nothing}
%%    \renewcommand{\SCDquit}{\endinput}
%%  \fi
\fi
%%\SCDquit
%    \end{macrocode}
%
% \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@bibchapter}
%    Used for knowing whether to use chapter or section style headings.
%    \begin{macrocode}
\newif\if@bibchapter\@bibchapterfalse
\ifSCDchapter
  \@bibchaptertrue
\fi
%    \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}
%
%    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}{%
  \ifx\chapter\undefined
    \@bibchapterfalse
    \PackageWarning{tocbibind}%
                   {Chapters are undefined, using section instead}
  \else
    \ifx\@makeschapterhead\undefined
      \@bibchapterfalse
      \PackageWarning{tocbibind}%
                     {Makeschapterhead undefined, using section instead}
    \else
       \@bibchaptertrue
    \fi
  \fi}
%    \end{macrocode}
%
% The \Lopt{other} option makes |\SCDquit| a no-op and cancels any 
% chapter based processing.
% \changes{v1.3}{1999/08/22}{Added the `other' option}
%    \begin{macrocode}
\DeclareOption{other}{\renewcommand{\SCDquit}{}
                      \@bibchapterfalse}
%    \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
\SCDquit
%    \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
%%  \PackageWarning{tocbibind}{Using chapter style headings}
  \PRWPackageNoteNoLine{tocbibind}{Using chapter style headings}
\else
%%  \PackageWarning{tocbibind}{Using section or other style headings}
  \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}{\prw@mkboth}
% \begin{macro}{\toc@section}
% \begin{macro}{\toc@chapter}
% \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.
%
% |\prw@mkboth{|\meta{text}|}| is shorthand for 
% |\@mkboth{|\meta{left}|}{|\meta{right}|}| as called by sectional headings.
%    \begin{macrocode}
\providecommand{\prw@mkboth}[1]{\@mkboth{%
  \MakeUppercase{#1}}{\MakeUppercase{#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.
%    \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}
% |\toc@chapter{|\meta{text}|}| is equivalent to |\chapter*{|\meta{text}|}|
% except that it makes an entry into the ToC.
%    \begin{macrocode}
\newcommand{\toc@chapter}[1]{%
  \chapter*{#1\prw@mkboth{#1}}
  \addcontentsline{toc}{chapter}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \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}.
%
% \begin{environment}{thebibliography}
%    Redefine \Lenv{thebibliography}, but only if requested.
%    \begin{macrocode}
\if@dotocbib
  \renewenvironment{thebibliography}[1]
     {\if@bibchapter
        \if@donumbib
          \chapter{\tocbibname}
        \else
          \toc@chapter{\tocbibname}
        \fi
      \else
        \if@donumbib
          \@nameuse{\@tocextra}{\tocbibname}
        \else
          \toc@section{\@tocextra}{\tocbibname}
        \fi
      \fi
      \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}
\fi
%    \end{macrocode}
% \end{environment}
%
%
% \begin{environment}{theindex}
%    We redefine the \Lenv{theindex} if asked for.
% The first bit of code is a copy from \file{classes.dtx}.
%    \begin{macrocode}
\if@dotocind
  \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}
%
%    For reasons I don't understand I have to add/remove some vertical
% space around a numbered heading to make their height match other
% numbered chapter/section headings. The values were reached by running
% some experiments.
%    \begin{macrocode}
     \if@bibchapter
        \if@donumindex
          \refstepcounter{chapter}
          \twocolumn[\vspace*{2\baselineskip}%
                     \@makechapterhead{\indexname}]%
          \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}\indexname}
%%          \prw@mkboth{\indexname}
          \chaptermark{\indexname}
        \else
          \twocolumn[\@makeschapterhead{\indexname}]%
          \prw@mkboth{\indexname}
          \addcontentsline{toc}{chapter}{\indexname}
        \fi
     \else
        \if@donumindex
          \twocolumn[\vspace*{-\baselineskip}%
                     \@nameuse{\@tocextra}{\indexname}]%
%%          \prw@mkboth{\indexname}
          \prw@mkboth{\csname the\@tocextra\endcsname \quad\indexname}
        \else
          \twocolumn[\toc@headstar{\@tocextra}{\indexname}]%
          \prw@mkboth{\indexname}
          \addcontentsline{toc}{\@tocextra}{\indexname}
        \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}{%
  \ifSCDchapter
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
  \fi}
\newcommand{\toc@finish}{%
  \ifSCDchapter
    \if@restonecol\twocolumn\fi
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\toc@file}
%    The code for |\tableofcontents|, |\listoftables| and |\listoffigures|
% is virtually identical in each case, except for the heading text.
% |\toc@file| 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 |\toc@file{|\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{\toc@file}[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 |\toc@file| to do
% all the work for us.
%    \begin{macrocode}
\if@dotoctoc
  \renewcommand{\tableofcontents}{%
    \toc@file{\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}{%
    \toc@file{\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}{%
    \toc@file{\listfigurename}{lof}
  }
\fi
%    \end{macrocode}
% \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         \~}


