%%
%% This is file `volumes.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% volumes.dtx  (with options: `volumes')
%% 
%% Copyright (C) 2003 Frank Küster.
%% 
%% All rights reserved.
\ProvidesPackage{volumes}
            [2004/06/02 v1.0 print only parts of a LaTeX document,
            with complete indices etc.]
\newif\if@allincludes\@allincludestrue
\newif\if@tocall\@tocallfalse
\newif\if@lofall\@lofallfalse
\newif\if@lotall\@lotallfalse
\DeclareOption{manual}{\@allincludesfalse}
\DeclareOption{tocall}{\@tocalltrue}
\DeclareOption{lofall}{\@lofalltrue}
\DeclareOption{lotall}{\@lotalltrue}
\ProcessOptions%
\RequirePackage{nowtoaux}
\newcommand{\vol@do@addto}[1]{#1}
\let\vol@dont@addto\@gobble
\newcommand{\voladdtotoc}[1]{%
  \addtocontents{toc}{\protect\vol@maybe@addto@toc{#1}}%
}%
\let\vol@maybe@addto@toc\vol@do@addto
\newcommand{\voladdtolof}[1]{%
  \addtocontents{lof}{\protect\vol@maybe@addto@lof{#1}}%
}%
\let\vol@maybe@addto@lof\vol@do@addto
\newcommand{\voladdtolot}[1]{%
  \addtocontents{lot}{\protect\vol@maybe@addto@lot{#1}}%
}%
\let\vol@maybe@addto@lot\vol@do@addto
\let\volumes@orig@contentsline\contentsline \RequirePackage{scrlfile}
\AfterPackage{hyperref}{\let\volumes@orig@contentsline\contentsline}
\@ifpackageloaded{hyperref}{%
  \let\volumes@new@contentsline\@gobblefour
}{%
  \def\volumes@new@contentsline#1#2#3{}
  \AfterPackage{hyperref}{%
    \let\volumes@new@contentsline\@gobblefour
  }
}
\def\volumes@switch@orig@contentsline@toc{%
  \let\contentsline\volumes@orig@contentsline%
  \let\vol@maybe@addto@toc\vol@do@addto
}
\def\volumes@switch@new@contentsline@toc{%
  \let\contentsline\volumes@new@contentsline%
  \let\vol@maybe@addto@toc\vol@dont@addto
}
\def\volumes@switch@orig@contentsline@lof{%
  \let\contentsline\volumes@orig@contentsline%
  \let\vol@maybe@addto@lof\vol@do@addto
}
\def\volumes@switch@new@contentsline@lof{%
  \let\contentsline\volumes@new@contentsline%
  \let\vol@maybe@addto@lof\vol@dont@addto
}
\def\volumes@switch@orig@contentsline@lot{%
  \let\contentsline\volumes@orig@contentsline%
  \let\vol@maybe@addto@lot\vol@do@addto
}
\def\volumes@switch@new@contentsline@lot{%
  \let\contentsline\volumes@new@contentsline%
  \let\vol@maybe@addto@lot\vol@dont@addto
}
\def\volume@switch@off{%
  \if@tocall\else%
    \immediateaddtocontents{toc}{\protect\volumes@switch@new@contentsline@toc}%
  \fi%
  \if@lofall\else%
    \immediateaddtocontents{lof}{\protect\volumes@switch@new@contentsline@lof}%
  \fi%
  \if@lotall\else%
    \immediateaddtocontents{lot}{\protect\volumes@switch@new@contentsline@lof}%
  \fi%
}
\def\volume@switch@on{%
  \immediateaddtocontents{toc}{\protect\volumes@switch@orig@contentsline@toc}%
  \immediateaddtocontents{lof}{\protect\volumes@switch@orig@contentsline@lof}%
  \immediateaddtocontents{lot}{\protect\volumes@switch@orig@contentsline@lof}%
}
\def\volumecommand#1#2{%
  \expandafter\def\csname volume@command@#1\endcsname{%
    #2%
  }%
}
\def\allvolumescommand#1{%
  \def\all@volumes@command{#1}%
}
\let\all@volumes@command\relax
\providecommand\ifnumber[3]{
 \begingroup\@tempswafalse\let\scr@next\test@number
 \expandafter\scr@next#1\scr@next
 \if@tempswa\endgroup#2\else\endgroup#3\fi
}
\providecommand*{\test@number}[1]{
 \ifx \scr@next#1
  \let\scr@next\relax
 \else
  \@tempcnta=\expandafter\expandafter\expandafter\number
  \expandafter`#1\relax
  \ifnum \@tempcnta>47\relax
   \ifnum \@tempcnta<58\relax
    \@tempswatrue
   \else\@tempswafalse\fi
  \else\@tempswafalse\fi
  \if@tempswa\else\let\scr@next\gobble@till@next\fi\fi
 \scr@next}
\providecommand*{\gobble@till@next}{}
\def\gobble@till@next#1\scr@next{}
\newcommand*{\volumename}[1]{%
  \def\volume@name{#1}%
}%
\volumename{volume}%
\newcommand*{\alwaysinclude}[1]{%
  \if@allincludes
    \PackageError{volumes}{%
      need option "manual" for \string\alwaysinclude.%
    }{%
      You must use the option "manual" when you want to use
      \string\alwaysinclude, and\MessageBreak  specify
       the volumes using \string\volumeone\space etc. - see
       the package documentation.
    }
  \else
    \def\always@include{,#1}
  \fi
}
\def\always@include{}
\newcommand*{\onlyvolume}[1]{}
\def\onlyvolume{%
  \@ifnextchar [{\@onlyvolume}{\@@onlyvolume}
}
\def\@onlyvolume[#1]{%
  \ifnumber{#1}{%
    \def\volume{#1}
  }{%
    \PackageError{volumes}{%
      Argument to \string\onlyvolume\space must be a number%
    }{%
      The optional argument to \string\onlyvolume\space is used to
      tell volumes.sty which volume it should typeset. You should have
      specified a number there, but instead, you said: \volume%
    }%
  }%
  \@@onlyvolume
}
\newcounter{volume}%
\newcounter{numberofvolumes}\setcounter{numberofvolumes}{10}%
\def\@@onlyvolume{%
  \ifx\volume\undefined%
    \PackageWarningNoLine{volumes}{Typesetting complete document.}
    \setcounter{volume}{0}%
    \@whilenum\c@volume<\c@numberofvolumes\do
    {%
      \expandafter\let%
      \csname volume@switch@\arabic{volume}\endcsname\relax%
      \stepcounter{volume}%
    }%
    \setcounter{volume}{0}%
    \AtBeginDocument{\all@volumes@command}%
  \else
    \ifnumber{\volume}{%
      \PackageWarningNoLine{volumes}{Typesetting part \volume.}
    }{%
      \PackageError{volumes}{\string\volume\space is defined, but not a
        number}{%
        The macro \string\volume\space is used to tell volumes.sty which
        volume it should typeset. You have defined this macro, but it is
        not a number. Instead, it is: \volume%
      }%
    }%
    \setcounter{volume}{0}%
    \@whilenum\c@volume<\c@numberofvolumes\do {%
      \expandafter\let%
      \csname volume@switch@\arabic{volume}\endcsname%
      \volume@switch@off%
      \stepcounter{volume}%
    }
    \setcounter{volume}{0}%
    \AtBeginDocument{\csname volume@command@\volume\endcsname}
    \expandafter\let%
    \csname volume@switch@\volume\endcsname\volume@switch@on
    \includeonly{\volume@name\volume\always@include}%
  \fi
  \if@allincludes\else%
    \@ifundefined{volumelist}{%
      \def\volumelist{one,two,three,four,five,six,seven,eight,nine,ten}%
    }{}%
    \@for\vol@num:=\volumelist\do
    {%
      \stepcounter{volume}%
      \expandafter\let\csname volume\vol@num\expandafter\endcsname%
        \csname volume@switch@\arabic{volume}\endcsname%
    }%
    \setcounter{volume}{0}%
  \fi
}
\setcounter{volume}{0}%
\if@allincludes%
  \let\volume@orig@include\include%
  \def\include{%
    \stepcounter{volume}%
    \csname volume@switch@\arabic{volume}\endcsname%
    \volume@orig@include%
  }
\fi
\endinput
%%
%% End of file `volumes.sty'.
