%%
%% This is file `tocbibind.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tocbibind.dtx  (with options: `usc')
%% 
%% -----------------------------------------------------------------
%%   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.
%% -----------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tocbibind}[2010/10/13 v1.5k 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}
    }{\PackageInfo{tocbibind}{The document has section divisions}}
  }{\@bibchaptertrue
    \PackageInfo{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
\newif\if@dot@cb@bsection\@dot@cb@bsectionfalse

\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, unless overridden}
\else
  \PRWPackageNoteNoLine{tocbibind}{Using section or other style headings}
\fi
\if@inltxdoc \@dotocindfalse \fi

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

\newcommand{\tocetcmark}[1]{%
  \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
\newcommand{\prw@mkboth}[1]{\tocetcmark{#1}}
\newcommand{\toc@section}[2]{%
  \@nameuse{#1}*{#2\prw@mkboth{#2}}
  \addcontentsline{toc}{#1}{#2}}
\newcommand{\toc@headstar}[2]{%
  \@nameuse{#1}*{{#2}}}
\newcommand{\toc@chapter}[1]{%
  \chapter*{#1}\prw@mkboth{#1}
  \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}}
\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}

\if@dotocbib
  \@ifpackageloaded{natbib}{}{% natbib not loaded
    \newcommand{\bibsection}{\t@cb@bchapsec}
    \renewenvironment{thebibliography}[1]{%
      \bibsection
      \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}

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

\fi

\AtBeginDocument{%
  \@ifpackagewith{natbib}{sectionbib}{\@dot@cb@bsectiontrue}{}
  \@ifpackagewith{chapterbib}{sectionbib}%
    {\@dot@cb@bsectiontrue
     \@ifundefined{sectionbib}{}{\def\sectionbib#1#2{}}}%
    {}

  \if@dotocbib
    \if@dot@cb@bsection
      \renewcommand{\bibsection}{\t@cb@bsection}%
    \else
      \renewcommand{\bibsection}{\t@cb@bchapsec}%
    \fi
  \fi
}

\if@inltxdoc\else
  \renewenvironment{theindex}%
    {\if@twocolumn
       \@restonecolfalse
     \else
       \@restonecoltrue
     \fi
     \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
   \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}{%
  \@ifundefined{@tbiold@makechapterhead}{}%
  {\let\@makechapterhead\@tbiold@makechapterhead}
}
\newcommand{\simplechapterdelim}{}

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

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