Debian Codegraph @

texmf-dist/tex/latex/mdwtools/mathenv.sty

raw
1 %%
2 %% This is file `mathenv.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% mdwtab.dtx (with options: `mathenv')
8 %%
9 %% IMPORTANT NOTICE
10 %%
11 %% mdwtab package -- another rewrite of the tabular environment, etc.
12 %% Copyright (c) 1996 Mark Wooding
13 %%
14 %% This program is free software; you can redistribute it and/or modify
15 %% it under the terms of the GNU General Public License as published by
16 %% the Free Software Foundation; either version 2 of the License, or
17 %% (at your option) any later version.
18 %%
19 %% This program is distributed in the hope that it will be useful,
20 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
21 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 %% GNU General Public License for more details.
23 %%
24 %% You should have received a copy of the GNU General Public License
25 %% along with this program; if not, write to the Free Software
26 %% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 %%
28 \NeedsTeXFormat{LaTeX2e}
29 \ProvidesPackage{mathenv}
30 [1998/04/28 1.9 Various maths environments]
31 %% \CharacterTable
32 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
33 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
34 %% Digits \0\1\2\3\4\5\6\7\8\9
35 %% Exclamation \! Double quote \" Hash (number) \#
36 %% Dollar \$ Percent \% Ampersand \&
37 %% Acute accent \' Left paren \( Right paren \)
38 %% Asterisk \* Plus \+ Comma \,
39 %% Minus \- Point \. Solidus \/
40 %% Colon \: Semicolon \; Less than \<
41 %% Equals \= Greater than \> Question mark \?
42 %% Commercial at \@ Left bracket \[ Backslash \\
43 %% Right bracket \] Circumflex \^ Underscore \_
44 %% Grave accent \` Left brace \{ Vertical bar \|
45 %% Right brace \} Tilde \~}
46 %%
47 %%
48 \newif\if@fleqn
49 \newif\if@leqno
50 \DeclareOption{fleqn}{\@fleqntrue}
51 \DeclareOption{leqno}{\@leqnotrue}
52 \ProcessOptions
53 \RequirePackage{mdwtab}
54 \newif\if@eqalast
55 \newskip\eqaopenskip
56 \newskip\eqacloseskip
57 \newskip\eqacolskip
58 \newskip\eqainskip
59 \newskip\splitleft
60 \newskip\splitright
61 \AtBeginDocument{%
62 \eqacloseskip\@centering%
63 \eqacolskip1.5em\@plus\@m\p@
64 \eqainskip\z@%
65 \if@fleqn%
66 \eqaopenskip\mathindent%
67 \splitleft\mathindent\relax%
68 \splitright\mathindent\@minus\mathindent\relax%
69 \else%
70 \eqaopenskip\@centering%
71 \splitleft2.5em\@minus2.5em%
72 \splitright\splitleft%
73 \fi%
74 \relax%
75 }
76 \def\dsp@startouter{%
77 \let\dsp@end\dsp@endouter%
78 $$%
79 }
80 \def\dsp@endouter{$$}
81 \def\dsp@startinner{%
82 \let\dsp@end\dsp@endinner%
83 \if@fleqn\kern-\mathindent\fi%
84 \if@leqno\vtop\else\vtop\fi\bgroup%
85 }
86 \def\dsp@endinner{\egroup}
87 \def\dsp@start{%
88 \ifmmode%
89 \ifinner\mth@err@mdsp\fi%
90 \expandafter\dsp@startinner%
91 \else%
92 \ifhmode\ifinner\mth@err@hdsp\fi\fi%
93 \expandafter\dsp@startouter%
94 \fi%
95 }
96 \def\dsp@tabpause{%
97 \def\tab@startpause%
98 {\penalty\postdisplaypenalty\vskip\belowdisplayskip}%
99 \def\tab@endpause%
100 {\penalty\predisplaypenalty\vskip\abovedisplayskip}%
101 }
102 \let\eqastyle\displaystyle
103 \def\eqnarray{%
104 \eqnarray@i\eqa@eqcount%
105 }
106 \@namedef{eqnarray*}{\eqnarray@i{}}
107 \def\eqnarray@i#1{\@ifnextchar[{\eqnarray@ii{#1}}{\eqnarray@ii{#1}[rcl]}}
108 \def\eqnarray@ii#1[#2]{%
109 \stepcounter{equation}%
110 \def\@currentlabel{\p@equation\theequation}%
111 \let\eqa@oldnumber\eqa@number%
112 \def\eqa@defnumber{#1}%
113 \global\let\eqa@number\eqa@defnumber%
114 \@eqalastfalse%
115 \m@th%
116 \colset{eqnarray}%
117 \tab@initread%
118 \def\tab@tabtext{&\tabskip\z@skip}%
119 \tab@preamble{\tabskip\z@skip}%
120 \tab@readpreamble{#2@{\tabskip\eqacloseskip}}%
121 \dsp@tabpause%
122 \[email protected]\eqainskip%
123 \everycr{}%
124 \let\\\@eqncr%
125 \dsp@start%
126 \tabskip\eqaopenskip%
127 \halign to\displaywidth\expandafter\bgroup%
128 \the\tab@preamble%
129 &&\eqa@lastcol\hb@xt@\z@{\hss##}\tabskip\z@\cr%
130 }
131 \def\endeqnarray{%
132 \eqa@eqnum%
133 \egroup%
134 \dsp@end%
135 \global\let\eqa@number\eqa@oldnumber%
136 \global\@ignoretrue%
137 \global\advance\c@equation\m@ne%
138 }
139 \expandafter\let\csname endeqnarray*\endcsname\endeqnarray
140 \colpush{eqnarray}
141 \coldef r{\tabcoltype{\hfil$\eqastyle}{{}$}}
142 \coldef c{\tabcoltype{\hfil$\eqastyle{}}{{}$\hfil}}
143 \coldef l{\tabcoltype{$\eqastyle{}}{$\hfil}}
144 \coldef x{\tabcoltype{\if@fleqn\else\hfil\fi$\eqastyle}{$\hfil}}
145 \collet T [tabular]T
146 \coldef L{\tabcoltype{\hb@xt@2em\bgroup$\eqastyle}{$\hss\egroup}}
147 \coldef :{\tabspctype{\tabskip\eqacolskip}}
148 \coldef q{\tabspctype{\quad}}
149 \collet > [tabular]>
150 \collet < [tabular]<
151 \collet * [tabular]*
152 \collet @ [tabular]@
153 \colpop
154 \def\@eqncr{\tab@cr\eqacr@i\interdisplaylinepenalty\@M}%
155 \def\eqacr@i#1#2{%
156 \eqa@eqnum%
157 \noalign{\penalty#2\vskip\jot\vskip#1}%
158 }
159 \if@leqno
160 \def\eqa@eqpos#1{%
161 \hb@[email protected]\p@{}\rlap{\normalfont\normalcolor\hskip-\displaywidth#1}%
162 }
163 \else
164 \def\eqa@eqpos#1{\normalfont\normalcolor#1}
165 \fi
166 \def\eqa@eqnum{%
167 \global\let\eqa@lastcol\@eqalasttrue%
168 \eqa@eqnum@i%
169 }
170 \def\eqa@eqnum@i{%
171 \relax%
172 \if@eqalast%
173 \expandafter\eqa@eqnum@ii%
174 \else%
175 \expandafter\eqa@eqnum@iii%
176 \fi%
177 }
178 \def\eqa@eqnum@ii{%
179 \eqa@eqpos\eqa@number%
180 \global\let\eqa@number\eqa@defnumber%
181 \global\let\eqa@lastcol\eqa@@lastcol%
182 \cr%
183 }
184 \def\eqa@eqnum@iii{&\eqa@eqnum@i}
185 \def\eqa@@lastcol{\mth@err@number\setbox\z@}
186 \let\eqa@lastcol\eqa@@lastcol
187 \newcommand\eqnumber[1][\eqa@eqcount]{\gdef\eqa@number{#1}}
188 \def\eqa@eqcount{(\theequation)\global\advance\c@equation\@ne}
189 \def\nonumber{\global\let\eqa@number\@empty}
190 \def\eqnalign{\@ifnextchar[\eqnalign@i{\eqnalign@i[rcl]}}
191 \def\eqnalign@i[#1]{%
192 \@ifnextchar[{\eqnalign@ii{#1}}{\eqnalign@ii{#1}[c]}%
193 }
194 \def\eqnalign@ii#1[#2]{%
195 \let\\\eqn@cr%
196 \colset{eqnarray}%
197 \tab@initread%
198 \def\tab@tabtext{&\tabskip\z@skip}%
199 \tabskip\z@skip%
200 \[email protected]\eqainskip%
201 \tab@readpreamble{#1}%
202 \everycr{}%
203 \if#2t\vtop\else%
204 \if#2b\vbox\else%
205 \vcenter%
206 \fi%
207 \fi%
208 \bgroup%
209 \halign\expandafter\bgroup\the\tab@preamble\cr%
210 }
211 \def\endeqnalign{%
212 \crcr%
213 \egroup%
214 \egroup%
215 }
216 \def\eqn@cr{\tab@cr\eqn@cr@i{}{}}
217 \def\eqn@cr@i#1{\cr\noalign{\vskip\jot\vskip#1}\@gobble}
218 \def\eqlines{\eqnarray[x]}
219 \let\endeqlines\endeqnarray
220 \expandafter\edef\csname eqlines*\endcsname{%
221 \expandafter\noexpand\csname eqnarray*\endcsname[x]%
222 }
223 \expandafter\let\csname endeqlines*\expandafter\endcsname
224 \csname endeqnarray*\endcsname
225 \def\spliteqn{%
226 \let\eqa@oldnumber\eqa@number%
227 \global\let\eqa@number\eqa@eqcount%
228 \spliteqn@i%
229 }
230 \@namedef{spliteqn*}{%
231 \let\eqa@oldnumber\eqa@number%
232 \gdef\eqa@number{}%
233 \spliteqn@i%
234 }
235 \def\endspliteqn{%
236 \hfilneg\seq@lastcr%
237 \egroup%
238 \dsp@end%
239 \global\let\eqa@number\eqa@oldnumber%
240 \global\advance\c@equation\m@ne%
241 }
242 \expandafter\let\csname endspliteqn*\endcsname\endspliteqn
243 \def\spliteqn@i{%
244 \stepcounter{equation}%
245 \def\@currentlabel{\p@equation\theequation}%
246 \if@leqno%
247 \global\let\seq@docr\seq@eqnocr%
248 \else%
249 \global\let\seq@docr\seq@cr%
250 \fi%
251 \global\let\seq@lastcr\seq@eqnocr%
252 \dsp@start%
253 \dsp@tabpause%
254 \def\\{\seq@docr}%
255 \seq@dosplit%
256 {\hb@xt@\displaywidth{%
257 \hskip\splitleft\hfil$\displaystyle##$%
258 \hfil\hskip\splitright}}%
259 {\hfilneg}%
260 }
261 \def\subsplit{%
262 \let\\\seq@cr%
263 \vcenter\bgroup%
264 \seq@dosplit{\hfil\qquad$##$\qquad\hfil}{\hfilneg\hskip-2em}%
265 }
266 \def\endsubsplit{%
267 \hfilneg\hskip-2em\cr%
268 \egroup\egroup%
269 }
270 \def\seq@dosplit#1#2{%
271 \halign\bgroup%
272 #1&&\mth@err@number\setbox\z@\hbox{##}\cr%
273 #2\relax%
274 }
275 \def\seq@eqnocr{%
276 &\omit%
277 \hb@xt@\z@{\hss\eqa@eqpos\eqa@number}%
278 \global\let\seq@docr\seq@cr%
279 \global\let\seq@lastcr\seq@cr%
280 \seq@cr%
281 }
282 \def\seq@cr{\tab@cr\seq@cr@i\interdisplaylinepenalty\@M}
283 \def\seq@cr@i#1#2{\cr\noalign{\penalty#2\vskip\jot\vskip#1}}
284 \def\genmatrix#1#2#3#4#5{%
285 \let\mat@style#1%
286 \ifx#2\scriptstyle%
287 \let\mat@font\scriptfont%
288 \else\ifx#2\scriptscriptstyle%
289 \let\mat@font\scriptscriptfont%
290 \else%
291 \let\mat@font\textfont%
292 \fi\fi%
293 \ifx\mat@style\scriptstyle%
294 \let\mat@textsize\scriptsize%
295 \else\ifx\mat@style\scriptscriptstyle%
296 \let\mat@textsize\scriptscriptsize%
297 \else%
298 \let\mat@textsize\relax%
299 \fi\fi%
300 \def\mat@left{\bgroup\mat@style\left#4#3\vcenter\bgroup}%
301 \toks@{\egroup#3\right#5\egroup}%
302 \@tempswatrue%
303 \ifx\mat@style\displaystyle\else\ifx\mat@style\textstyle\else%
304 \@tempswafalse%
305 \setbox\z@\hbox\bgroup$%
306 \toks@\expandafter{\the\toks@$\m@th\egroup\raise.75\p@\box\z@}%
307 \fi\fi%
308 \if@tempswa\ifmmode\else%
309 $\m@th%
310 \toks@\expandafter{\the\toks@$}%
311 \fi\fi%
312 \edef\mat@right{\the\toks@}%
313 \@ifnextchar[\genmatrix@i{\genmatrix@i[[c]}%
314 }
315 \def\genmatrix@i[#1]{%
316 \colset{matrix}%
317 \tab@initread%
318 \setbox\z@\hbox{$\mat@style\mskip12mu$}%
319 \edef\tab@tabtext{&\kern\the\wd\z@}%
320 \tab@readpreamble{#1}%
321 \if1\ifx\mat@style\scriptstyle1\else%
322 \ifx\mat@style\scriptscriptstyle1\else0\fi\fi%
323 \baselineskip\fontdimen10\mat@font\tw@%
324 \advance\baselineskip\fontdimen12\mat@font\tw@%
325 \lineskip\thr@@\fontdimen8\mat@font\thr@@%
326 \else%
327 \baselineskip\fontdimen8\mat@font\tw@%
328 \advance\baselineskip\fontdimen11\mat@font\tw@%
329 \lineskip7\fontdimen8\mat@font\thr@@%
330 \fi%
331 \lineskiplimit\lineskip%
332 \let\\\mat@cr%
333 \tabskip\z@skip%
334 \col@sep\z@%
335 \mat@left%
336 \halign\expandafter\bgroup\the\tab@preamble\tabskip\z@skip\cr%
337 \ifx\mat@font\textfont%
338 \omit$\mat@style\mathstrut$\cr\noalign{\kern-\baselineskip}%
339 \fi%
340 }
341 \def\endgenmatrix{%
342 \crcr%
343 \ifx\mat@font\textfont%
344 \omit$\mat@style\mathstrut$\cr\noalign{\kern-\baselineskip}%
345 \fi%
346 \egroup%
347 \mat@right%
348 }
349 \def\mat@cr{\tab@cr\mat@cr@i{}{}}
350 \def\mat@cr@i#1{\cr\noalign{\vskip#1}\@gobble}
351 \def\newmatrix#1#2{%
352 \@namedef{#1}{\genmatrix#2}%
353 \expandafter\let\csname end#1\endcsname\endgenmatrix%
354 }
355 \newmatrix{matrix}{{\textstyle}{\textstyle}{\,}{.}{.}}
356 \newmatrix{pmatrix}{{\textstyle}{\textstyle}{\,}{(}{)}}
357 \newmatrix{dmatrix}{{\textstyle}{\textstyle}{\,}}
358 \newmatrix{smatrix}{{\scriptstyle}{\scriptstyle}{}{.}{.}}
359 \newmatrix{spmatrix}{{\scriptstyle}{\scriptstyle}{}{(}{)}}
360 \newmatrix{sdmatrix}{{\scriptstyle}{\scriptstyle}{}}
361 \newmatrix{smatrix*}{{\scriptstyle}{\textstyle}{}{.}{.}}
362 \newmatrix{spmatrix*}{{\scriptstyle}{\textstyle}{}{(}{)}}
363 \newmatrix{sdmatrix*}{{\scriptstyle}{\textstyle}{}}
364 \def\script{%
365 \let\mat@style\scriptstyle%
366 \def\mat@left{\vcenter\bgroup}%
367 \def\mat@right{\egroup}%
368 \let\mat@font\scriptfont%
369 \let\mat@textsize\scriptsize%
370 \@ifnextchar[\genmatrix@i{\genmatrix@i[c]}%
371 }
372 \let\endscript\endgenmatrix
373 \colpush{matrix}
374 \coldef l{\tabcoltype{\kern\z@$\mat@style}{\m@th$\hfil}}
375 \coldef c{\tabcoltype{\hfil$\mat@style}{\m@th$\hfil}}
376 \coldef r{\tabcoltype{\hfil$\mat@style}{\m@th$}}
377 \coldef T#1{\tab@aligncol{#1}{\begingroup\mat@textsize}{\endgroup}}
378 \coldef {[}{%
379 \@firstoftwo{%
380 \ifnum\tab@columns=\z@%
381 \def\@tempa##1\q@delim{%
382 \tab@mkpreamble##1[##1\q@delim%
383 }%
384 \expandafter\@tempa%
385 \else%
386 \tab@setstate\tab@prestate%
387 \tab@append\tab@preamble{&}%
388 \expandafter\tab@mkpreamble%
389 \fi%
390 }%
391 }
392 \colpop
393 \def\mdw@dots#1{\ensuremath{\mathpalette\mdw@dots@i{#1}}}
394 \def\mdw@dots@i#1#2{%
395 \setbox\z@\hbox{$#1\mskip1.8mu$}%
396 \dimen@\wd\z@%
397 \setbox\z@\hbox{$#1.$}%
398 #2%
399 }
400 \def\vdots{%
401 \mdw@dots{\vbox{%
402 \baselineskip4\dimen@%
403 \lineskiplimit\z@%
404 \kern6\dimen@%
405 \copy\z@\copy\z@\box\z@%
406 }}%
407 }
408 \def\ddots{%
409 \mdw@dots{\mathinner{%
410 \mkern1mu%
411 \raise7\dimen@\vbox{\kern7\dimen@\copy\z@}%
412 \mkern2mu%
413 \raise4\dimen@\copy\z@%
414 \mkern2mu%
415 \raise\dimen@\box\z@%
416 \mkern1mu%
417 }}%
418 }
419 \def\cases{\left\{\,\array{@{}lTl@{}}}
420 \def\endcases{\endarray\,\right.}
421 \def\smcases{\left\{\smarray{@{}lTl@{}}}
422 \def\endsmcases{\endsmarray\,\right.}
423 \def\mth@error{\PackageError{mathenv}}
424 \def\mth@err@number{%
425 \mth@error{Too many `&' characters found}{%
426 You've put too many `&' characters in an alignment^^J%
427 environment (like `eqnarray' or `spliteqn') and wandered^^J%
428 into trouble. I've gobbled the contents of that column^^J%
429 and hopefully I can recover fairly easily.%
430 }%
431 }
432 \def\mth@err@mdsp{%
433 \mth@error{Can't do displays in nondisplay maths mode}{%
434 You're trying to start a display environment, but you're^^J%
435 in nondisplay maths mode. The display will appear but^^J%
436 don't blame me when it looks horrible.%
437 }%
438 }
439 \def\mth@err@hdsp{%
440 \mth@error{Can't do displays in LR mode}{%
441 You're trying to start a display environment, but you're^^J%
442 in LR (restricted horizontal) mode. Everything will go^^J%
443 totally wrong, so your best bet is to type `X', fix the^^J%
444 mistake and start again.%
445 }%
446 }
447 \endinput
448 %%
449 %% End of file `mathenv.sty'.