%%
%% This is file `collect.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% collect.dtx  (with options: `package')
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{collect}
   [2004/09/12 v0.9 collect the contents of an environment]
\newcommand{\definecollection}[1]{%
\@ifundefined{CE@@#1@out}{%
\expandafter\newwrite\csname CE@@#1@out\endcsname%
\expandafter\newif\csname ifCE@@#1@open\endcsname%
\csname CE@@#1@openfalse\endcsname%
}{%
\PackageError{collect}{Collection `#1' has already %
been defined}{\@ehc}%
}%
}
\newenvironment{collect*}[5]{%
\global\toks@{}%
\def\CE@file{#1}%
\def\CE@preenv{#2}%
\def\CE@postenv{#3}%
\def\CE@prefileenv{#4}%
\def\CE@postfileenv{#5}%
\CE@get@env@body@start%
}{%
\CE@ensure@opened{\CE@file}%
\edef\@tempa{\csname CE@@\CE@file @out\endcsname}%
\immediate\write\@tempa{\CE@meaning\CE@prefileenv}%
\immediate\write\@tempa{\CE@meaning\CE@preenv}%
\immediate\write\@tempa{\the\toks@}%
\immediate\write\@tempa{\CE@meaning\CE@postenv}%
\immediate\write\@tempa{\CE@meaning\CE@postfileenv}%
\immediate\openout\CE@tmp@out=\jobname.tmp%
\immediate\write\CE@tmp@out{\CE@meaning\CE@preenv}%
\immediate\write\CE@tmp@out{\the\toks@}%
\immediate\write\CE@tmp@out{\CE@meaning\CE@postenv}%
\immediate\closeout\CE@tmp@out%
\@input{\jobname.tmp}%
\par%
}
\newenvironment{collect}[3]{%
\global\toks@{}%
\def\CE@file{#1}%
\def\CE@prefileenv{#2}%
\def\CE@postfileenv{#3}%
\CE@get@env@body@start%
}{%
\CE@ensure@opened{\CE@file}%
\edef\@tempa{\csname CE@@\CE@file @out\endcsname}%
\immediate\write\@tempa{\CE@meaning\CE@prefileenv}%
\immediate\write\@tempa{\the\toks@}%
\immediate\write\@tempa{\CE@meaning\CE@postfileenv}%
}
\newcommand{\includecollection}[1]{%
\CE@ensure@closed{#1}%
\@input{\jobname.#1}%
}
\newenvironment{collectinmacro}[3]{%
\def\CE@destmacro{#1}%
\def\CE@postenv{#3}%
\toks@{#2}%
\CE@get@env@body@start%
}{%
\toks@\expandafter\expandafter\expandafter{%
\expandafter\the\expandafter\toks@\CE@postenv}%
\expandafter\expandafter\expandafter%
\gdef\expandafter\CE@destmacro\expandafter{\the\toks@}%
\toks@{}%
}
\newwrite\CE@tmp@out
\def\CE@get@env@body@start{%
\let\@tempa\CE@get@env@body%
\futurelet\@tempb\CE@get@env@body@start@%
}
\def\CE@get@env@body@start@{%
\ifx\@tempb\@sptoken%
\expandafter\CE@get@env@body@start@@%
\else%
\expandafter\CE@get@env@body%
\fi%
}
\def\CE@get@env@body@start@@{%
\afterassignment\CE@get@env@body%
\let\@tempb= %
}
\bgroup
\catcode`\Q=3
\long\gdef\CE@get@env@body#1\end#2{%
\def\@tempb{#2}%
\ifx\@tempb\@currenvir%
\CE@get@env@body@#1Q Q%
\def\@tempa{\end{#2}}%
\else
\toks@\expandafter{\the\toks@#1\end{#2}}%
\fi%
\@tempa%
}
\long\gdef\CE@get@env@body@#1 Q{%
\CE@get@env@body@@#1Q%
}

\long\gdef\CE@get@env@body@@#1Q#2{%
\toks@\expandafter{\the\toks@#1}%
}
\egroup
\long\def\CE@meaning#1{%
\expandafter\strip@prefix\meaning#1%
}
\def\CE@ensure@opened#1{%
\@ifundefined{ifCE@@#1@open}{%
\PackageError{collect}{Collection `#1' has not been defined}{\@ehc}%
}{%
\csname ifCE@@#1@open\endcsname\else%
\expandafter\immediate\expandafter\openout%
\csname CE@@#1@out\endcsname=\jobname.#1%
\expandafter\global\csname CE@@#1@opentrue\endcsname%
\fi%
}%
}
\def\CE@ensure@closed#1{%
\@ifundefined{ifCE@@#1@open}{%
\PackageError{collect}{Collection `#1' has not been defined}{\@ehc}%
}{%
\csname ifCE@@#1@open\endcsname%
\expandafter\immediate\expandafter\closeout%
\csname CE@@#1@out\endcsname%
\expandafter\global\csname CE@@#1@openfalse\endcsname%
\fi%
}%
}
\endinput
%%
%% End of file `collect.sty'.
