blob: 6a576bf1a66b2c1def1c571ab470aaf968b31e7c (
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
%%
%% This is file `environ.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% environ.dtx (with options: `package')
%%
%% __________________________________
%% Copyright (C) 2007 Will Robertson
%%
%% License information appended.
%%
\ProvidesPackage{environ}[2008/06/18 v0.2 A new way to define environments]
\def\environbodyname#1{\def\env@BODY{#1}}
\environbodyname\BODY
\def\environfinalcode#1{%
\def\env@finalcode{#1}}
\environfinalcode{\ignorespacesafterend}
\def\longdef@c#1{%
\expandafter\long\expandafter\def\csname#1\endcsname}
\catcode`\Q=3
\long\def\trim@spaces#1{\romannumeral-`\q\trim@trim@\noexpand#1Q Q}
\long\def\trim@trim@#1 Q{\trim@trim@@#1Q}
\long\def\trim@trim@@#1Q#2{#1}
\catcode`\Q=11
\unless\ifdefined\collect@body
\newtoks\@emptytoks
\newtoks\@envbody
\def\collect@body#1{%
\@envbody{\expandafter#1\expandafter{\the\@envbody}}%
\edef\process@envbody{\the\@envbody\noexpand\end{\@currenvir}}%
\@envbody\@emptytoks \def\begin@stack{b}%
\begingroup
\expandafter\let\csname\@currenvir\endcsname\collect@@body
\edef\process@envbody{%
\expandafter\noexpand\csname\@currenvir\endcsname}%
\process@envbody
}
\def\push@begins#1\begin#2{%
\ifx\end#2\else
b\expandafter\push@begins
\fi}
\def\addto@envbody#1{%
\global\@envbody\expandafter{\the\@envbody#1}}
\def\collect@@body#1\end#2{%
\edef\begin@stack{%
\push@begins#1\begin\end \expandafter\@gobble\begin@stack}%
\ifx\@empty\begin@stack
\endgroup
\@checkend{#2}%
\addto@envbody{#1}%
\else
\addto@envbody{#1\end{#2}}%
\fi
\process@envbody}
\fi
\long\def\Collect@Body#1{%
\@envbody{\expandafter#1\expandafter{\the\@envbody}}%
\edef\process@envbody{\the\@envbody\noexpand\end{\@currenvir}}%
\@envbody\@emptytoks \def\begin@stack{b}%
\begingroup
\expandafter\let\csname\@currenvir\endcsname\Collect@@Body
\edef\process@envbody{%
\expandafter\noexpand\csname\@currenvir\endcsname}%
\process@envbody
}
\long\def\Push@Begins#1\begin#2{%
\ifx\end#2\else
b\expandafter\Push@Begins
\fi}
\long\def\Addto@Envbody#1{%
\global\@envbody\expandafter{\the\@envbody#1}}
\long\def\Collect@@Body#1\end#2{%
\edef\begin@stack{%
\Push@Begins#1\begin\end\expandafter\@gobble\begin@stack}%
\ifx\@empty\begin@stack
\endgroup
\@checkend{#2}%
\Addto@Envbody{#1}%
\else
\Addto@Envbody{#1\end{#2}}%
\fi
\process@envbody}
\def\NewEnviron{%
\let\env@newcommand\newcommand
\let\env@newenvironment\newenvironment
\env@NewEnviron}
\def\RenewEnviron{%
\let\env@newcommand\renewcommand
\let\env@newenvironment\renewenvironment
\env@NewEnviron}
\def\env@NewEnviron#1{%
\@ifnextchar[
{\env@new@i{#1}}
{\env@new@iii{#1}{}}}
\def\env@new@i#1[#2]{%
\@ifnextchar[
{\env@new@ii{#1}[#2]}
{\env@new@iii{#1}{[#2]}}}
\def\env@new@ii#1[#2][#3]{%
\env@new@iii{#1}{[#2][#3]}}
\long\def\env@new@iii#1#2#3{%
\@temptokena={\env@new{#1}{#2}{#3}}%
\@ifnextchar[{%
\the\@temptokena
}{%
\expandafter\the\expandafter
\@temptokena\expandafter[\env@finalcode]%
}}
\long\def\env@new#1#2#3[#4]{%
\env@newenvironment{#1}{%
\expandafter\Collect@Body\csname env@#1@parse\endcsname
}{#4}
\longdef@c{env@#1@parse}##1{%
\csname env@#1@save@env\endcsname##1\env@nil
\csname env@#1@process\endcsname##1\env@nil}%
\expandafter\env@newcommand
\csname env@#1@save@env\endcsname#2{\env@save}%
\expandafter\env@newcommand
\csname env@#1@process\endcsname#2{#3\env@ignore}}
\long\def\env@save#1\env@nil{%
\expandafter\edef\env@BODY{%
\unexpanded\expandafter
\expandafter\expandafter{\trim@spaces{#1}}}}
\long\def\env@ignore#1\env@nil{}
\newcommand\NewEnvironment{%
\let\env@newenvironment\newenvironment
\let\env@newcommand\newcommand
\Make@Environment}
\newcommand\RenewEnvironment{%
\let\env@newenvironment\renewenvironment
\let\env@newcommand\renewcommand
\Make@Environment}
\newcommand\Make@Environment[2]{%
\expandafter\let\csname env@args@#1\endcsname\ignorespaces
\env@newenvironment{#1}{%
\expandafter\Collect@Body\csname env@@#1\endcsname}{\ignorespacesafterend}%
\longdef@c{env@@#1}##1{%
\csname env@@@#1\endcsname{%
\csname env@args@#1\endcsname##1\unskip}}%
\longdef@c{env@@@#1}##1{#2}}
\newcommand\EnvironArgs[1]{%
\@ifnextchar[
{\Env@Args{#1}}
{\Env@Args{#1}[0]}}
\long\def\Env@Args#1[#2]{%
\@ifnextchar[
{\Env@@@Args{#1}[#2]}
{\Env@@Args{#1}[#2]}}
\long\def\Env@@Args#1[#2]#3{%
\expandafter\renewcommand\csname env@args@#1\endcsname[#2]{%
#3\ignorespaces}}
\long\def\Env@@@Args#1[#2][#3]#4{%
\expandafter\renewcommand\csname env@args@#1\endcsname[#2][#3]{%
#4\ignorespaces}}
%%
%% Copyright (C) 2007 by Will Robertson <wspr81@gmail.com>
%%
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%%
%% This work is "maintained" (as per LPPL maintenance status)
%% by Will Robertson.
%%
%% This work consists of the file environ.dtx
%% and the derived files environ.pdf,
%% environ.sty, and
%% environ.ins.
%%
%%
%% End of file `environ.sty'.
|