%%
%% This is file `tocbibind.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tocbibind.dtx  (with options: `usc')
%% 
%%  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
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tocbibind}[2001/04/17 v1.5 extra ToC listings]

\providecommand{\PRWPackageNote}[2]{%
  \GenericWarning{%
    (#1)\@spaces\@spaces\@spaces\@spaces
  }{%
    Package #1 Note: #2%
   }%
}
\providecommand{\PRWPackageNoteNoLine}[2]{%
  \PRWPackageNote{#1}{#2\@gobble}%
}

\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}
    }{\PRWPackageNoteNoLine{tocbibind}{The document has section divisions}}
  }{\@bibchaptertrue
    \PRWPackageNoteNoLine{tocbibind}{The document has chapter divisions}}

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

\newif\if@dotocbib\@dotocbibtrue
\newif\if@dotocind\@dotocindtrue
\newif\if@dotoctoc\@dotoctoctrue
\newif\if@dotoclot\@dotoclottrue
\newif\if@dotoclof\@dotocloftrue

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

\DeclareOption{section}{\@bibchapterfalse}
\DeclareOption{notbib}{\@dotocbibfalse}
\DeclareOption{notindex}{\@dotocindfalse}
\DeclareOption{nottoc}{\@dotoctocfalse}
\DeclareOption{notlot}{\@dotoclotfalse}
\DeclareOption{notlof}{\@dotocloffalse}
\DeclareOption{numbib}{\@donumbibtrue}
\DeclareOption{numindex}{\@donumindextrue}

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

\DeclareOption{other}{\renewcommand{\@bibquit}{}
                      \@bibchapterfalse}
\DeclareOption{none}{%
  \@dotocbibfalse
  \@dotocindfalse
  \@dotoctocfalse
  \@dotoclotfalse
  \@dotocloffalse
  \@donumbibfalse
  \@donumindexfalse
}
\ProcessOptions\relax
\@bibquit

\if@bibchapter
  \PRWPackageNoteNoLine{tocbibind}{Using chapter style headings}
\else
  \PRWPackageNoteNoLine{tocbibind}{Using section or other style headings}
\fi
\if@inltxdoc \@dotocindfalse \fi

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

\providecommand{\phantomsection}{}

\providecommand{\prw@mkboth}[1]{\@mkboth{%
  \MakeUppercase{#1}}{\MakeUppercase{#1}}}

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

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

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

\ifx\bibname\undefined
  \ifx\refname\undefined
    \newcommand{\tocbibname}{References}
  \else
    \newcommand{\tocbibname}{\refname}
  \fi
\else
  \newcommand{\tocbibname}{\bibname}
\fi

\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}}

\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}}

  \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

\if@inltxdoc\else
  \renewenvironment{theindex}%
    {\if@twocolumn
       \@restonecolfalse
     \else
       \@restonecoltrue
     \fi
     \if@bibchapter
        \if@donumindex
          \refstepcounter{chapter}
          \twocolumn[\vspace*{2\topskip}%
                     \@makechapterhead{\indexname}]%
          \phantomsection
          \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}\indexname}
%%          \prw@mkboth{\indexname}
          \chaptermark{\indexname}
        \else
          \if@dotocind
            \twocolumn[\vspace*{2\topskip}%
                       \@makeschapterhead{\indexname}]%
            \prw@mkboth{\indexname}
            \phantomsection
            \addcontentsline{toc}{chapter}{\indexname}
          \else
            \twocolumn[\vspace*{2\topskip}%
                       \@makeschapterhead{\indexname}]%
            \@mkboth{\MakeUppercase\indexname}%
                    {\MakeUppercase\indexname}%
          \fi
        \fi
     \else
        \if@donumindex
          \twocolumn[\vspace*{-1.5\topskip}%
                     \@nameuse{\@tocextra}{\indexname}]%
%%          \prw@mkboth{\indexname}
          \prw@mkboth{\csname the\@tocextra\endcsname \quad\indexname}
        \else
          \if@dotocind
            \twocolumn[\vspace*{-1.5\topskip}%
                       \toc@headstar{\@tocextra}{\indexname}]%
            \prw@mkboth{\indexname}
            \phantomsection
            \addcontentsline{toc}{\@tocextra}{\indexname}
          \else
            \twocolumn[\vspace*{-1.5\topskip}%
                       \toc@headstar{\@tocextra}{\indexname}]%
            \prw@mkboth{\indexname}
          \fi
        \fi
     \fi
   \thispagestyle{plain}\parindent\z@
   \parskip\z@ \@plus .3\p@\relax
   \let\item\@idxitem}
   {\if@restonecol\onecolumn\else\clearpage\fi}
\fi

\newcommand{\toc@start}{%
  \if@bibchapter
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
  \fi}

\newcommand{\toc@finish}{%
  \if@bibchapter
    \if@restonecol\twocolumn\fi
  \fi}

\newcommand{\tocfile}[2]{%
  \toc@start
  \if@bibchapter
    \toc@chapter{#1}
  \else
    \toc@section{\@tocextra}{#1}
  \fi
  \@starttoc{#2}
  \toc@finish}

\if@dotoctoc
  \renewcommand{\tableofcontents}{%
    \tocfile{\contentsname}{toc}
  }
\fi

\if@dotoclot
  \renewcommand{\listoftables}{%
    \tocfile{\listtablename}{lot}
  }
\fi

\if@dotoclof
  \renewcommand{\listoffigures}{%
    \tocfile{\listfigurename}{lof}
  }
\fi

\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}{%
  \let\@makechapterhead\@tbiold@makechapterhead
}
\newcommand{\simplechapterdelim}{}

\newcommand{\tocchapter}{%
  \simplechapter
  \renewcommand{\toc@chapter}[1]{\chapter{##1}}
}
\newcommand{\tocsection}{%
  \renewcommand{\toc@section}[2]{\@nameuse{##1}{##2}}
}

\endinput
%%
%% End of file `tocbibind.sty'.
