blob: 64d5adb5fc23586dbb3a5bdbfbc93e35d04f53a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
%%
%% 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'.
|