Debian Codegraph @

texmf-dist/source/latex/bosisio/envmath.dtx

raw
1 %\iffalse % MetaComment
2 %%
3 %% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
4 %% | Copyright(C) 1997-2010 by F. Bosisio |
5 %% | |
6 %% | This program can be redistributed and/or modified under |
7 %% | the terms of the LaTeX Project Public License, either |
8 %% | version 1.3 of this license or (at your option) any later |
9 %% | version. The latest version of this license is in |
10 %% | http://www.latex-project.org/lppl.txt |
11 %% | and version 1.3 or later is part of all LaTeX distributions |
12 %% | version 2005/12/01 or later. |
13 %% | |
14 %% | This work has the LPPL maintenance status `maintained'. |
15 %% | The Current Maintainer of this work is F. Bosisio. |
16 %% | |
17 %% | This work consists of files envmath.dtx and envmath.html |
18 %% | and of the derived files envmath.sty and envmath.pdf. |
19 %% | |
20 %% | E-mail: [email protected] |
21 %% | CTAN location: macros/latex/contrib/bosisio/ |
22 %% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
23 %%
24 %% If you make any improvment, find any bug or have
25 %% any suggestion, please let me know about it.
26 %%
27 %<*package,driver>
28 %\fi
29 %
30 \def\FileName{envmath}
31 %\iffalse % MetaComment
32 %</package,driver>
33 %<*package>
34 %\fi
35 \def\fileversion{2.5}
36 \def\filedate{2010/02/10}
37 \def\docdate{2005/04/09}
38 \def\filedescr{Extended math environments (FB)}
39 %
40 %\iffalse % MetaComment
41 %</package>
42 %<*dtx>
43 %- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44 % This section is the installation driver
45 %
46 \def\batchfile{\FileName.dtx}
47 %
48 \input docstrip
49 %
50 \keepsilent
51 % \askforoverwritefalse
52 %
53 \generateFile{\FileName.sty}{f}{\from{\FileName.dtx}{package}}
54 %
55 \generateFile{\FileName.drv}{f}{\from{\FileName.dtx}{driver}}
56 %
57 \Msg{******************************************************}
58 \Msg{*}
59 \Msg{* To produce the documentation run the}
60 \Msg{* file `\FileName.drv' through LaTeX.}
61 \Msg{*}
62 \Msg{******************************************************}
63 %
64 \endbatchfile
65 %
66 % End of the installation driver
67 %- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
68 %</dtx>
69 %
70 % This section is the documentation driver
71 %
72 %<+driver>\documentclass[12pt,a4paper]{ltxdoc}
73 %<+driver> \EnableCrossrefs
74 %<+driver> \CodelineIndex
75 %<+driver> \RecordChanges
76 %<+driver> %\OnlyDescription % Uncomment not to see the implementation
77 %<+driver>\begin{document}
78 %<+driver> \DocInput{\FileName.dtx}
79 %<+driver> \PrintIndex
80 %<+driver> \PrintChanges
81 %<+driver>\end{document}
82 %
83 % End of the documentation driver
84 %- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
85 %<*package>
86 %\fi
87 %
88 % \changes{v0.1}{20 April 1997}{First release (basic environments)}
89 % \changes{v0.2}{10 May 1997}{Added the ``*-form'' of environments}
90 % \changes{v1.0}{24 May 1997}{Documentation added}
91 % \changes{v1.1}{18 October 1997}{``EQNarray'' and ``EqSystem'' environments}
92 % \changes{v1.2}{5 November 1997}{Options to behave like ``Standard'' LateX}
93 % \changes{v1.3}{8 November 1997}{Documentation updated}
94 % \changes{v2.0}{20 December 1997}{Separated from package ``mathcmd''}
95 % \changes{v2.1}{4 February 1998}{``MultiLine'' and ``EqSystem'' environments
96 % reimplemented; ``EQNarray'' environment and
97 % ``CONTINUE'' command made obsolete}
98 % \changes{v2.2}{6 February 1998}{``@StandartEquation'' deferred
99 % ``AtBeginDocument''; some ``def'' replaced
100 % by ``newcommand*''; documentation updated}
101 % \changes{v2.3}{5 March 1999}{Added copyright notice and changed addresses}
102 % \changes{v2.4}{9 April 2005}{Usage of the double-quote character (") avoided}
103 % \changes{v2.5}{10 February 2010}{Package renamed from ``mathenv'' to
104 % ``envmath'' to avoid name conflicts}
105 %\iffalse % MetaComment
106 % The previous change was requested by Karl Berry ([email protected])
107 %\fi
108 %
109 % \MakeShortVerb{\|}
110 %
111 % \title{Package \texttt{\FileName}\thanks{This is version \fileversion,
112 % last revised \filedate; documentation date \docdate}}
113 % \author{F. Bosisio\\\normalsize E-mail: \texttt{[email protected]}}
114 % \date{\filedate}
115 % \maketitle
116 %
117 % \begin{abstract}
118 % Documentation for the package \texttt{\FileName}.
119 % \end{abstract}
120 %
121 % \section{Introduction}
122 % This package provides some useful math-commands and enviroments,
123 % which are simpler to use and prettier then their standard \LaTeX{}
124 % counterpart.
125 %
126 % In particular some commands are redefined\footnote{See the options
127 % in next section if you don't want these comand to be redefined}, so
128 % care should be taken, expecially when including this package in an
129 % already existent \LaTeX{} file.
130 %
131 % \noindent
132 % The redefined commands are:\\
133 % |\(|, |\)|, |\[|, |\]|, |\{| and |\}| \\
134 % The effect of ``|\(| \dots |\)|'' can still be achieved by the
135 % \LaTeX{} equivalent commands ``|\begin{math}| \dots |\end{math}|''
136 % or ``|$| \dots |$|''.
137 %
138 % \noindent
139 % Similarly, the effect of ``|\[| \dots |\]|'' can be achieved by
140 % the \LaTeX{} equivalent commands
141 % ``|\begin{displaymath}| \ldots |\end{displaymath}|''
142 % or ``|$$| \dots |$$|''.
143 %
144 % \noindent
145 % The ``|\{|'' and ``|\}|'' commands are the more error-prone, since
146 % one may try to use ``|\left\{|'', which now is incorrect, because
147 % the ``|\{|'' command already contains a ``|\left|'' declaration.
148 % In the rare occasions where a brace of normal size is needed, one
149 % can use the \LaTeX{} commands ``|\lbrace|'' and ``|\rbrace|''
150 %
151 % \noindent
152 % Also the ``|equation|'' environment has been changed, but it is
153 % completly compatible with the original definition, so it should
154 % be safe, perhaps except when the first character of the equation
155 % is an open square bracket or it is placed in a moving argument:
156 % in fact, the new version of this command is fragile, and this is
157 % true also for most of the commands defined by this package.
158 %
159 % \section{Backward compatibility}
160 % The package has been renamed from ``|mathenv|'' to ``|envmath|'',
161 % in order to avoid conflicts with another package with the same name:
162 % if you were using the ``old'' package, you need to change your \LaTeX{}
163 % files in order to include the new ones.\\
164 % Alternatively, you can also rename the package to give it the ``old''
165 % name (you need to change also the ``|\def\FileName{...}|'' line inside
166 % the ``|sty|''-file), but you must take care not to have another package
167 % with the same name installed on your system.
168 %
169 % \section{The options}
170 % At now, five options are available with the \texttt{\FileName}
171 % package.
172 %
173 % \noindent
174 % The ``|RedefEquation|''/``|StdEquation|'' and
175 % ``|RedefBrackets|''/``|StdBrackets|'' options control
176 % whether the ``|equation|'' environment and the brace commands
177 % ``|\(|'', ``|\(|'', ``|\)|'', ``|\[|'', ``|\]|'', ``|\{|'' and ``|\}|
178 % should be redefined or retain their original \LaTeX{} meaning.
179 % More precisely, ``|RedefEquation|'' (default) redefines the
180 % ``equation'' environment to have an optional argument (used as a
181 % label), while ``|StdEquation|'' leaves it unchanged. In the first
182 % case, the ``equation'' environment will be equivalent to the
183 % ``Equation'' environment (capitalized!) described below, whereas in
184 % the second case they will be different.
185 % Similarly, the ``|RedefBrackets|'' option (default) makes the
186 % brackets command to be redefined, whilst ``|StdBrackets|'' leave
187 % them their original meaning.
188 % Also a ``|Standard|'' option exists, which amounts to specify both
189 % the ``|StdEquation|'' and ``|StdBrackets|'' options, thus making the
190 % package fully standard, which may be useful when sending your
191 % \LaTeX{} files to someone else.
192 %
193 % \section{Math-mode environments}
194 % This package provides three math-mode environments, each with a
195 % ``*-form'' which does not generates numbers.
196 %
197 % \subsection{The \texttt{Equation} environment}
198 % The ``|Equation|'' environment has an optional argument
199 % which is used as a label to reference it.
200 % \begin{verbatim}
201 % \begin{Equation}[label]
202 % ...
203 % \end{Equation}
204 % \end{verbatim}
205 % If the ``|RedefEquation|'' option is in effect (default),
206 % then the ``|equation|'' environment is redefined to have
207 % the same optional argument as ``|Equation|''.
208 %
209 % There is also a *-form, which does not generate a number
210 % (so this *-form is really a ``displaymath'' and not an
211 % equation, but it has been added for simmetry and for making
212 % it easier to add or remove the number to a formula).
213 %
214 % \noindent
215 % The *-form has an optional argument like the non-* form,
216 % which is disregarded by the environment and is added only
217 % for simmetry reasons.
218 % \begin{verbatim}
219 % \begin{equation*}[disregarded-label]
220 % ...
221 % \end{equation*}
222 % \end{verbatim}
223 %
224 % \subsection{The \texttt{MultiLine} equation environment}
225 % The ``|MultiLine|'' environment is intended for formulas
226 % that don't fit on a single line, and so must be broken
227 % across lines.
228 %
229 % \noindent
230 % As for the |Equation| environment above, it has an optional
231 % argument which is used as a label.
232 %
233 % \noindent
234 % All the lines but the first are automatically indented by
235 % the lenght ``|\MultiLineIndent|'', which is rougthly what
236 % one expects, but can be changed at any time by the user
237 % with ``|\setlenght{\MultiLineIndent}{...}|''.
238 % You can also control the alignment of the continuation rows
239 % by placing an optional |&| in the first row: is such a case
240 % all the others line will \emph{not} be indented
241 % by ``|\MultiLineIndent|'' but wil behave \emph{as if} there
242 % there were an ampersand in front of them (i.e. they will be
243 % left-aligned at the right of the \& in the first row).
244 %
245 % \noindent
246 % Each line but the last must end with a ``|\\|'' command
247 % (which can have an optional argument to add some vertical
248 % space between lines).
249 % When the line is broken in the middle (e.g. after a ``+''
250 % sign) and not at the end (i.e. after a ``='' or similar), the
251 % *-form ``|\\*|'' may be used to indicate the line-break, the
252 % difference being in an extra space added at the beginning of
253 % the next line.
254 % The width of a thise space defaults to 1em and can be changed
255 % by the user with ``|\setlenght{\MultiLineStarIndent}{...}|''.
256 %
257 % \begin{verbatim}
258 % \begin{MultiLine}[label]
259 % ... [&]= ... = \\
260 % = ... + \\*
261 % + ... = \\
262 % = ...
263 % \end{MultiLine}
264 % \end{verbatim}
265 %
266 % Also this environment has a *-form which differs only in that
267 % it does not generate an equation number.
268 % \begin{verbatim}
269 % \begin{MultiLine*}[disregarded-label]
270 % ... [&]= ... = \\
271 % = ... + \\*
272 % + ... = \\
273 % = ...
274 % \end{MultiLine*}
275 % \end{verbatim}
276 %
277 % \subsection{The \texttt{System} environment}
278 % The ``|System|'' environment is used for grouping a set of
279 % equations together inside a left brace, with one only
280 % equation number.
281 %
282 % \noindent
283 % Again there is an optional argument to indicate a label and
284 % each equation is separated by a ``|\\|'' or ``|\\*|'' command,
285 % as for the ``|MultiLine|'' environment.
286 %
287 % \noindent
288 % The rows (except the ones ended with the *-form ``|\\*|'')
289 % may optionally contain one ``|&|'', which is usually used
290 % when some text should be added to the equation.
291 % \begin{verbatim}
292 % \begin{System}[label]
293 % ... = ... [& ...] \\
294 % ... = ... + \\*
295 % + ... [& ...] \\
296 % ... = ... [& ...]
297 % \end{System}
298 % \end{verbatim}
299 %
300 % A *-form which does not generate any number is also provided.
301 % \begin{verbatim}
302 % \begin{System*}[disregarded-label]
303 % ... = ... [& ...] \\
304 % ... = ... + \\*
305 % + ... [& ...] \\
306 % ... = ... [& ...]
307 % \end{System*}
308 % \end{verbatim}
309 %
310 % \subsection{The \texttt{EqSystem} environment}
311 % The ``|EqSystem|'' environment is used for grouping a set of
312 % equations together inside a left brace, each with its own
313 % equation number.
314 %
315 % \noindent
316 % Again there is an optional argument to indicate a label and
317 % each equation is separated by a ``|\\|'' or ``|\\*|'' command.
318 %
319 % \noindent
320 % The rows may optionally contain one ``|&|'', which is
321 % usually used when some text should be added to the equation.
322 % \begin{verbatim}
323 % \begin{EqSystem}[label]
324 % ... = ... [& ...] \\ % (1.1)
325 % ... = ... + \\* % (1.2)
326 % + ... [& ...] \\ % (1.3)
327 % ... = ... [& ...] % (1.4)
328 % \end{EqSystem}
329 % \end{verbatim}
330 %
331 % A *-form is also provided: it differs in that each equation
332 % is numbered with the same number but with a lowercase letter
333 % added, i.e. like (1.1a), (1.1b), etc. instead of (1.1),
334 % (1.2) and so on.
335 % \begin{verbatim}
336 % \begin{EqSystem*}[label]
337 % ... = ... [& ...] \\ % (1.5a)
338 % ... = ... + \\* % (1.5b)
339 % + ... [& ...] \\ % (1.5c)
340 % ... = ... [& ...] % (1.5d)
341 % \end{EqSystem*}
342 % \end{verbatim}
343 % In both cases, if the optional argument is present, each
344 % equation can be referenced by |\ref{<label>:a}|,
345 % |\ref{<label>:b}|, \dots, where |<label>|, stands for
346 % the string used as optional argument.
347 % In the case of the *-form, a reference of the kind
348 % |\ref{<label>}| will print the equation number without
349 % any letter, thus referring to the system as a whole,
350 % whereas such a reference is meaningless (and indeed does
351 % not exists) when dealing with the non *-form.
352 %
353 %
354 % \section{Math-mode commands}
355 % In addition to the previously mentioned environments, the
356 % \texttt{\FileName} package defines also some of math-mode
357 % commands which considerably simplify the use of adjustable-size
358 % parentheses.
359 %
360 % \noindent
361 % The ``|\(|'', ``|\[|'', ``|\{|'', ``|\)|'', ``|\]|''
362 % and ``|\}|'' generates the corresponding parenthesis but
363 % with a ``|\left|'' or ``|\right|'' declaration
364 % (respectively) added, so they must come in matched pairs or
365 % coupled with a ``|\left.|'' or ``|\rigtht.|'' or another
366 % adjustable-size delimiter.
367 %
368 % \StopEventually{}
369 % \newpage
370 % \section{Implementation}
371 %
372 % \begin{macrocode}
373 %%
374 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
375 \ProvidesPackage{\FileName}[\filedate\space v\fileversion\space\filedescr]
376 %%
377 \newif\if@Redefine@Equation@
378 \DeclareOption{RedefEquation}{\@Redefine@Equation@true}
379 \DeclareOption{StdEquation}{\@Redefine@Equation@false}
380 %%
381 \newif\if@Redefine@Brackets@
382 \DeclareOption{RedefBrackets}{\@Redefine@Brackets@true}
383 \DeclareOption{StdBrackets}{\@Redefine@Brackets@false}
384 %%
385 \DeclareOption{Standard}{\@Redefine@Equation@false\@Redefine@Brackets@false}
386 %%
387 \ExecuteOptions{RedefEquation,RedefBrackets}
388 % \end{macrocode}
389 %
390 % The ``|\ProcessOptions*|'' command was used here instead of
391 % ``|\ProcessOptions*|'' in order to process the options in the
392 % ``|\usepackage|'' order, rather than in the declaration order
393 % \begin{macrocode}
394 %%
395 \ProcessOptions*
396 % \end{macrocode}
397 %
398 % \begin{macro}{\StartMath@Err}
399 % The ``|\StartMath@Err|'' prints an error message if used in math-mode
400 % (saying that you can't use the command passed to it as an argument in
401 % math-mode); otherwise it just enters math-mode through a |$$|.
402 % It is used by the *-form of the math-environments to prevent
403 % their use in math-mode.
404 % \begin{macrocode}
405 %%
406 \newcommand*\StartMath@Err[1]{%
407 \ifmmode\PackageError{\FileName}{%
408 You can't use environment ``#1'' in math mode}{%
409 You probably used ``\string\end{#1}'' without a previous ``\string\begin{#1}''.}%
410 \else$$\fi%
411 }
412 % \end{macrocode}
413 % \end{macro}
414 %
415 % \begin{environment}{Equation}
416 % The definition of the original ``|equation|'' environment is first saved
417 % in the ``|\@StandardEquation|'' command.
418 % Then the ``|\@LabelledEquation|'' command is defined as an |equation|
419 % with a label.
420 % The |Equation| command simply calls ``|\@LabelledEquation|'' or
421 % ``|\@StandardEquation|'', depending on the presence or absence of the
422 % optional argument (indicated by the square bracket).
423 % \begin{macrocode}
424 %%
425 \AtBeginDocument{%
426 \let\@StandardEquation=\equation
427 }
428 \def\@LabelledEquation[#1]{\@StandardEquation\label{#1}}
429 \newenvironment{Equation}{%
430 \@ifnextchar[{\@LabelledEquation}{\@StandardEquation}%
431 }{%
432 \endequation%
433 }
434 % \end{macrocode}
435 %
436 % If the ``|RedefEquation|'' option is in effect, |equation| is defined
437 % to be the same as |Equation|.
438 % The actual definition of the |equation| environment is deferred at the
439 % ``|\begin{document}|'' in order to minimize the possibility of
440 % conflicts with other packages.
441 % \begin{macrocode}
442 \if@Redefine@Equation@
443 \AtBeginDocument{\let\equation=\Equation}
444 \fi
445 % \end{macrocode}
446 % \end{environment}
447 %
448 % \begin{environment}{equation*}
449 % The command ``|\Equation@Star|'' simply enters math-mode (via the
450 % ``|\StartMath@Err|'' command).
451 % The definition of ``|equation*|'' is deferred at the
452 % ``|\begin{document}|'' so that this definition takes precedence over
453 % the analogue one from the ``|amsmath|'' package, if both are included.
454 % The command ``|\global\@ignoretrue|'' in the definition of
455 % ``|\end{equation*}|'' prevents spurious spaces at the beginning of next
456 % line.
457 % \begin{macrocode}
458 %%
459 \def\Equation@Star[#1]{\StartMath@Err{equation*}}
460 \AtBeginDocument{%
461 \@namedef{equation*}{\@ifnextchar[{\Equation@Star}{\Equation@Star[]}}%
462 \@namedef{endequation*}{$$\global\@ignoretrue}%
463 }
464 % \end{macrocode}
465 % \end{environment}
466 %
467 % \begin{macro}{\ARRAY@CR}
468 % The original definition of ``|\@arraycr|'' is saved in the command
469 % ``|\@ArrayCR|''.
470 % Then ``|\ARRAY@CR|'' is defined to do the same job of ``|\@arraycr|''
471 % and add a ``|\displaystyle|'' declation at the beginning of next row.
472 % \begin{macrocode}
473 %%
474 \let\@ArrayCR=\@arraycr
475 \def\@ArrayCR@quadra[#1]{\@ArrayCR[#1]\displaystyle}
476 \def\@ArrayCR@star@quadra[#1]{%
477 \@ArrayCR[#1]\displaystyle\mbox{\hspace{\SystemStarIndent}}%
478 }
479 \def\@ArrayCR@star*{%
480 \@ifnextchar[{\@ArrayCR@star@quadra}{%
481 \@ArrayCR\displaystyle\mbox{\hspace{\SystemStarIndent}}}}%
482 \newcommand*{\ARRAY@CR}{\@ifnextchar*{\@ArrayCR@star}{%
483 \@ifnextchar[{\@ArrayCR@quadra}{\@ArrayCR\displaystyle}}%
484 }
485 % \end{macrocode}
486 % \end{macro}
487 %
488 % \begin{macro}{\MakeAmper@Active}
489 % Makes ``\&'' active (instead of a tab marker), giving
490 % it the meaning specified by the argument.
491 % \begin{macrocode}
492 %%
493 \newcommand*\MakeAmper@Active[1]{
494 \global\def\@AMPERSAND{#1}%
495 \begingroup%
496 \catcode`\~\active \lccode`\~`\&%
497 \lowercase{%
498 \global\expandafter\let
499 \csname ac\string\&\endcsname~%
500 \gdef~{\@AMPERSAND}}%
501 \endgroup%
502 \global\catcode`\&\active%
503 }
504 % \end{macrocode}
505 % \end{macro}
506 %
507 % \begin{macro}{\MakeAmper@Tab}
508 % Restores ``\&'' to its original meaning (a tab marker).
509 % \begin{macrocode}
510 %%
511 \newcommand*\MakeAmper@Tab{\global\catcode`\&=4}
512 % \end{macrocode}
513 % \end{macro}
514 %
515 % \begin{macro}{\OneShot@Amper}
516 % Makes ``\&'' active for one occurrence only: when encountered, the
517 % code in the first argument is executed, then ``\&'' is restored to
518 % its original meaning, a tab marker is inserted, and finally the
519 % code in the second argument is executed.
520 % \begin{macrocode}
521 %%
522 \newcommand*\OneShot@Amper[2]{%
523 \MakeAmper@Active{#1\expandafter\MakeAmper@Tab&#2}%
524 }
525 % \end{macrocode}
526 % \end{macro}
527 %
528 % \begin{macro}{\MultiLineIndent}
529 % The length ``|\MultiLineIndent|'' represents the amount of spece by
530 % which each line but the first of a ``|MultiLine|'' environment is
531 % indented. It defaults to 1.7em, which is roughtly equal to the width
532 % of a character followed by an equal sign (e.g.: ``|A = |'' ).
533 % \begin{macrocode}
534 %%
535 \newlength\MultiLineIndent
536 \setlength{\MultiLineIndent}{1.7em}
537 % \end{macrocode}
538 % \end{macro}
539 %
540 % \begin{macro}{\MultiLineStarIndent}
541 % The length ``|\MultiLineStarIndent|'' represents the amount of spece by
542 % which each line following a ``|\\*|'' in a ``|MultiLine|'' environment is
543 % indented. It defaults to 1em, which is roughtly equal to the width
544 % of a an equal sign (e.g.: ``|=|'' ).
545 % \begin{macrocode}
546 %%
547 \newlength\MultiLineStarIndent
548 \setlength\MultiLineStarIndent{1em}
549 % \end{macrocode}
550 % \end{macro}
551 %
552 % \begin{macro}{\@MultiLineCR}
553 % The ``|\@MultiLineCR|'' command does the original job of ``|\@arrycr|''
554 % (saved in ``|\ArrayCR|'') and then executes the ``|\ML@EveryRow|''
555 % command.
556 % In the *-form it also adds a space equal to ``|\MultiLineStarIndent|''.
557 % The splitting in subcommands is required in order to pass the optional
558 % argument to ``|\@ArrayCR|'' and not to the last executed command.
559 % \begin{macrocode}
560 %%
561 \newcommand*\@MultiLineCR{%
562 \@ifnextchar*{\MLineCR@star}{%
563 \@ifnextchar[{\MLineCR@quadra}{\@ArrayCR\ML@EveryRow}}%
564 }
565 \def\MLineCR@star*{%
566 \@ifnextchar[{\MLineCR@star@quadra}{%
567 \@ArrayCR\ML@EveryRow\hspace{\MultiLineStarIndent}}%
568 }
569 \def\MLineCR@star@quadra[#1]{%
570 \@ArrayCR[#1]%
571 \ML@EveryRow%
572 \hspace{\MultiLineStarIndent}%
573 }
574 \def\MLineCR@quadra[#1]{\@ArrayCR[#1]\ML@EveryRow}
575 % \end{macrocode}
576 %
577 % The ``|MultiLine|'' environment starts by setting ``|\ML@EveryRow|''
578 % to be equivalent to ``|\@MultiLINEcr|'', so that this command is
579 % executed at the end of the first row.
580 % It checks the |\catcode| of \& and redefines ``|\ML@EveryRow|''
581 % accordingly: if \& is a tab marker (|\catcode|=4), an ampersand has
582 % occurred in the first row, so that each row must begin itself with
583 % an ampersand; otherwise (i.e. if the |\catcode| of \& is \emph{active})
584 % no ampersand were found in the first row, so that each line must begin
585 % with a space equal to ``|\MultiLineStarIndent|''.
586 % \begin{macrocode}
587 \newcommand*\@MultiLINEcr{%
588 \ifnum\catcode`\&=4%
589 \global\def\ML@EveryRow{&\displaystyle\mbox{}}%
590 \else%
591 \MakeAmper@Tab%
592 \global\def\ML@EveryRow{\displaystyle\mbox{\hspace{\MultiLineIndent}}}%
593 \fi%
594 \ML@EveryRow%
595 }
596 % \end{macrocode}
597 % \end{macro}
598 %
599 % \begin{macro}{\CONTINUE}
600 % The command ``|\CONTINUE|'' is obsolete: you should use ``|\\*|'' instead.
601 % \begin{macrocode}
602 %%
603 \newcommand*{\CONTINUE}{%
604 \PackageError{\FileName}{%
605 Command ``\string\CONTINUE'' is obsolete: use ``\string\\*'' instead}{%
606 You'd better correct your input file as stated above,\MessageBreak%
607 but if you press ENTER everything will work for the moment.}%
608 \MLineCR@star*%
609 }
610 % \end{macrocode}
611 % \end{macro}
612 %
613 % \begin{environment}{MultiLine}
614 % The internal commad ``|\Start@MultiLine|'' is used by the ``|MultiLine|''
615 % and ``|MultiLine*|'' environments.
616 % It makes \& add a ``|\displaystyle|'' declaration.
617 % It also changes the meaning of ``|\\|'' to ``|\@MultiLineCR|'', sets
618 % ``|\ML@EveryRow|'' to its default value ``|\@MultiLINEcr|'' and then
619 % starts an ``|array|'' environment (we already are in math-mode
620 % here) with one only column which is left aligned.
621 % Finally, if there is an optional argument it is used as a ``|\label|''
622 % or ignored, depending on the current meaning of ``|\@LABEL|'' (which
623 % is the same as ``|\label|'' in the standard form and does nothing in
624 % the *-form).
625 % \begin{macrocode}
626 %%
627 \newcommand*\Start@MultiLine{%
628 \@ifnextchar[{\Start@MultiLine@quadra}{\Start@MultiLine@no}%
629 }
630 %%
631 \def\Start@MultiLine@quadra[#1]{\@LABEL{#1}\Start@MultiLine@no}
632 %%
633 \newcommand*\Start@MultiLine@no{%
634 \OneShot@Amper{}{\displaystyle}%
635 \let\@arraycr=\@MultiLineCR%
636 \let\ML@EveryRow=\@MultiLINEcr%
637 \begin{array}{l@{\hspace{0.3em}}l}%
638 \displaystyle%
639 }
640 % \end{macrocode}
641 %
642 % The internal command ``|\Stop@MultiLine|'' is used by the ``|MultiLine|''
643 % and ``|MultiLine*|'' environments.
644 % It simply closes the ``|array|'' environment anr restores ``|\@arrycr|''
645 % to its original meaning.
646 % \begin{macrocode}
647 %%
648 \newcommand*\Stop@MultiLine{%
649 \end{array}%
650 \let\@arraycr=\@ArrayCR%
651 \MakeAmper@Tab% % For the case no ``\\'' is used
652 }
653 % \end{macrocode}
654 %
655 % The ``|MultiLine|'' environment invokes ``|\Start@MultiLine|'' and
656 % ``|\Stop@MultiLine|'' inside an ``|equation|'' environment.
657 % \begin{macrocode}
658 %%
659 \newenvironment{MultiLine}{%
660 \let\@LABEL=\label%
661 \@StandardEquation%
662 \Start@MultiLine%
663 }{%
664 \Stop@MultiLine%
665 \endequation%
666 \global\@ignoretrue%
667 }
668 % \end{macrocode}
669 % \end{environment}
670 %
671 % \begin{environment}{MultiLine*}
672 % The ``|\MultiLine@Star|'' command issues an error message if used inside
673 % math mode, while when in text mode starts a ``|displaymath|'' environment
674 % (throught the ``|$$|'' command) in which a ``|\Start@MultiLineEq|'' command
675 % is issued (so it is the same as ``|\Label@MultiLineEq|'', but with
676 % ``|\equation|'' substituted by ``|$$|'').
677 % \begin{macrocode}
678 %%
679 \@namedef{MultiLine*}{\ifmmode\Not@MathErr{MultiLine*}\else$$\fi%
680 \def\@LABEL##1{}%
681 \Start@MultiLine%
682 }
683 \@namedef{endMultiLine*}{\Stop@MultiLine$$\global\@ignoretrue}
684 % \end{macrocode}
685 % \end{environment}
686 %
687 % \begin{environment}{System}
688 % The ``|\@System@Def|'' command is the kernel of the ``|System|'' and
689 % ``|System*|'' environments.
690 % It redefines ``|\@arraycr|'' so that ``|\\|'' not only ends the
691 % line but also adds a ``|\displaystyle|'' declaration.
692 % Then it draws an adjustable-size left brace, which will be as big as
693 % the system requires.
694 % Finally, a two-column array environment with a ``|\qquad|'' space
695 % between the columns is started and a ``|\displaystyle|'' declaration
696 % is added to the first row.
697 % \begin{macrocode}
698 %%
699 \newcommand*\@System@Def{%
700 \let\@arraycr=\ARRAY@CR%
701 \left\lbrace%
702 \begin{array}{l@{\qquad}l@{}}%
703 \displaystyle%
704 }
705 % \end{macrocode}
706 % The ``|\Label@System|'' commands opens an equation environment, issues
707 % a ``|\label|'' command for cross-referencing, and then calls the
708 % command ``|\@System@Def|'' defind above.
709 % \begin{macrocode}
710 \def\Label@System[#1]{\@StandardEquation\label{#1}\@System@Def}
711 % \end{macrocode}
712 % The ``|\begin{System}|'' command does the same things, skipping the
713 % ``|\label|'' command if there isn't the optional parameter.
714 % The ``|\end{System}|'' command closes the array, puts an invisible
715 % delimiter (``|\right.|'') which pairs with the left brace of the
716 % ``|\@System@Def|'' command, restores ``|\@arraycr|'' to its original
717 % meaning, ends the equation, and prevents spurious spaces by issuing
718 % the command ``|\global\@ignoretrue|''.
719 % \begin{macrocode}
720 \newenvironment{System}{%
721 \@ifnextchar[{\Label@System}{\@StandardEquation\@System@Def}%
722 }{%
723 \end{array}%
724 \right.%
725 \endequation%
726 \let\@arraycr=\@ArrayCR%
727 \global\@ignoretrue%
728 }
729 % \end{macrocode}
730 % \end{environment}
731 %
732 % \begin{environment}{System*}
733 % The ``|\System@Star|'' command generates en error message when used in
734 % math-mode, and calls ``|\@System@Def|'' inside a ``|displaymath|''
735 % environment (the ``|$$|'') when used in text-mode.
736 % \begin{macrocode}
737 %%
738 \def\System@Star[#1]{\StartMath@Err{System*}\@System@Def}
739 % \end{macrocode}
740 % The ``|System*|'' environment is the same as ``|System|'', but with
741 % ``|\begin{equation}|$\ldots$|\end{equation}|'' substituted by
742 % ``|$$|\ldots|$$|''.
743 % \begin{macrocode}
744 \@namedef{System*}{\@ifnextchar[{\System@Star}{\System@Star[]}}
745 \@namedef{endSystem*}{\end{array}\right. $$\let\@arraycr=\@ArrayCR \global\@ignoretrue}
746 % \end{macrocode}
747 % \end{environment}
748 %
749 % \begin{environment}{EQNarray}
750 % The |EQNarray| environment is only for backward compatibility:
751 % use the |equationarry| environment from package |eqnarray| if
752 % you need more control than an |eqnarray| environment allows.
753 % \begin{macrocode}
754 %%
755 \newenvironment{EQNarray}{%
756 \PackageError{\FileName}{Environment ``EQNarray'' is obsolete}{%
757 Use the ``equationarry'' environment from the ``eqnarray'' package instead!}%
758 \eqnarray%
759 }{%
760 \endeqnarray%
761 }
762 % \end{macrocode}
763 % \end{environment}
764 % \begin{macro}{\SystemColSep,\SystemBraceSep,\SystemStarIndent}
765 % \begin{macrocode}
766 %%
767 \newlength\SystemColSep
768 \setlength\SystemColSep{2em}
769 %%
770 \newlength\SystemBraceSep
771 \setlength\SystemBraceSep{3pt}
772 %%
773 \newlength\SystemStarIndent
774 \setlength\SystemStarIndent{2em}
775 % \end{macrocode}
776 % \end{macro}
777 %
778 % \begin{environment}{EqSystem}
779 % \begin{macrocode}
780 %%
781 \newsavebox{\SysRow@Box}
782 \newlength\ColOne@Width
783 \newlength\ColTwo@Width
784 \newlength\SysCol@TmpWidth
785 %%
786 \newcommand*\Start@EqSysRow{%
787 \OneShot@Amper{%
788 $\end{lrbox}%
789 \settowidth\SysCol@TmpWidth{\usebox{\SysRow@Box}}%
790 \ifnum\SysCol@TmpWidth>\ColOne@Width\global\setlength\ColOne@Width\SysCol@TmpWidth\fi%
791 \usebox{\SysRow@Box}%
792 }{%
793 \begin{lrbox}{\SysRow@Box}$\displaystyle%
794 }%
795 \begin{lrbox}{\SysRow@Box}$\displaystyle%
796 }
797 %%
798 \newcommand*\Stop@EqSysRow{%
799 $\end{lrbox}%
800 \settowidth\SysCol@TmpWidth{\usebox{\SysRow@Box}}%
801 \ifnum\catcode`\&=4%
802 \ifnum\SysCol@TmpWidth>\ColTwo@Width\global\setlength\ColTwo@Width\SysCol@TmpWidth\fi%
803 \else%
804 \MakeAmper@Tab%
805 \ifnum\SysCol@TmpWidth>\ColOne@Width\global\setlength\ColOne@Width\SysCol@TmpWidth\fi%
806 \fi%
807 \usebox{\SysRow@Box}%
808 }
809 %%
810 \def\@EqSystCR@star@quadra[#1]{%
811 \Sys@@eqncr%
812 \noalign{\penalty\@eqpen\vskip #1\relax}%
813 \Start@EqSysRow%
814 \mbox{\hspace{\SystemStarIndent}}%
815 }
816 %%
817 \def\@EqSystCR@star*{%
818 \global\@eqnswfalse%
819 \@ifnextchar[{\@EqSystCR@star@quadra}{%
820 \Sys@@eqncr\Start@EqSysRow\mbox{\hspace{\SystemStarIndent}}}%
821 }
822 %%
823 \def\@EqSystCR@quadra[#1]{%
824 \Sys@@eqncr%
825 \noalign{\penalty\@eqpen\vskip #1\relax}%
826 \Start@EqSysRow%
827 }
828 %%
829 \newcommand*\EqSyst@CR{%
830 \Stop@EqSysRow%
831 \@ifnextchar*{\@EqSystCR@star}{%
832 \@ifnextchar[{\@EqSystCR@quadra}{\Sys@@eqncr\Start@EqSysRow}}%
833 }
834 %%
835 \let\Label@EqSystem=\relax
836 %%
837 \newcommand*\Sys@@eqncr{%
838 \let\reserved@a\relax%
839 \ifcase\@eqcnt\def\reserved@a{& &}% %% \@eqcnt = 0
840 \or\def\reserved@a{&}% %% \@eqcnt = 1
841 \else% %% \@eqcnt > 1
842 \let\reserved@a\@empty%
843 \PackageError{\FileName}{Too many columns in EqSystem environment}{%
844 You can use at most one ``&'' in each row of an ``EqSystem'' environment.}%
845 \fi%
846 \reserved@a%
847 \if@eqnsw\Label@EqSystem\@eqnnum\stepcounter{equation}\fi%
848 \global\@eqnswtrue%
849 \global\@eqcnt\z@%
850 \cr%
851 }
852 %%
853 \newenvironment{EqSystem}[1][\relax]{%
854 \setcounter{EqSys@counter}{0}%
855 \def\Label@EqSystem{#1}%
856 \def\@tempa{\relax}%
857 \ifx\Label@EqSystem\@tempa\else%
858 \def\Label@EqSystem{\stepcounter{EqSys@counter}\label{#1:\alph{EqSys@counter}}}%
859 \fi%
860 \BEGIN@EqSystem%
861 }{%
862 \Stop@EqSysRow%
863 %%%-------------------- \endEQNarr@y ----------------------%
864 \Sys@@eqncr%
865 \egroup%
866 \global\advance\c@equation\m@ne%
867 $$%
868 %%%--------------------------------------------------------%
869 \vspace*{-\belowdisplayskip}%
870 \end{minipage}%
871 \advance\ColTwo@Width\ColOne@Width%
872 \advance\ColTwo@Width\SystemColSep%
873 \setlength\SysCol@TmpWidth\displaywidth%
874 \global\advance\SysCol@TmpWidth-\ColTwo@Width%
875 \global\divide\SysCol@TmpWidth\tw@%
876 \global\advance\SysCol@TmpWidth\ColTwo@Width%
877 \global\advance\SysCol@TmpWidth\SystemBraceSep% %% Space around left-brace
878 \global\advance\SysCol@TmpWidth 1em% %% ~= Left-brace size
879 \hspace{-\SysCol@TmpWidth}%
880 \right\lbrace%
881 \advance\SysCol@TmpWidth-1em% %% ~= Left-brace size
882 \hspace*{\SysCol@TmpWidth}%
883 $$\global\@ignoretrue%
884 }
885 %%
886 \newcommand*\BEGIN@EqSystem{%
887 \setlength\ColOne@Width\z@%
888 \setlength\ColTwo@Width\z@%
889 $$\left.%
890 \begin{minipage}{\displaywidth}%
891 \vspace*{-\abovedisplayskip}%
892 %%%-------------------------- \EQNarr@y -------------------%
893 \stepcounter{equation}%
894 \let\@currentlabel=\theequation%
895 \global\@eqnswtrue%
896 \global\@eqcnt\z@%
897 \tabskip\@centering%
898 \let\\=\EqSyst@CR%
899 $$\halign to \displaywidth\bgroup%
900 \tabskip\z@{##}\hfil%
901 &\global\@eqcnt\@ne%
902 \hspace{\SystemColSep}{##}\hfil%
903 \tabskip\@centering%
904 &\llap{##}\tabskip\z@\cr%
905 %%%--------------------------------------------------------%
906 \Start@EqSysRow%
907 }
908 % \end{macrocode}
909 % \end{environment}
910 %
911 % \begin{environment}{EqSystem*}
912 % \begin{macrocode}
913 %%
914 \newcounter{EqSys@counter}
915 %%
916 \newcommand*\EqSystem@Star[1][\relax]{%
917 \stepcounter{equation}%
918 \setcounter{EqSys@counter}{\value{equation}}%
919 \def\Label@EqSystem{#1}%
920 \def\@tempa{\relax}%
921 \ifx\Label@EqSystem\@tempa\else%
922 \let\@currentlabel=\theequation%
923 \label{#1}%
924 \def\Label@EqSystem{\label{#1:\alph{equation}}}%
925 \fi%
926 \let\INNER@theEQUATION=\theequation%
927 \xdef\inner@theEQUATION{\theequation}%
928 \def\theequation{\inner@theEQUATION\alph{equation}}%
929 \setcounter{equation}{0}%
930 \BEGIN@EqSystem%
931 }
932 %%
933 \@namedef{EqSystem*}{\EqSystem@Star}
934 %%
935 \@namedef{endEqSystem*}{%
936 \endEqSystem%
937 \setcounter{equation}{\value{EqSys@counter}}%
938 \global\let\theequation=\INNER@theEQUATION%
939 }
940 % \end{macrocode}
941 % \end{environment}
942 %
943 % The \LaTeX{} environments \texttt{math} and \texttt{displaymath}
944 % are redefined so that they will not be affected by the subsequent
945 % redefinition of the brackets commands.
946 % The redefinition of the brackets commands is deferred at the
947 % |\begin{document}|, so that other packages may use the original
948 % definitions and cannot override the new ones.
949 % It only takes place if the ``|RedefBrackets|'' option is in effect.
950 % \begin{macrocode}
951 \if@Redefine@Brackets@
952 \AtBeginDocument{%
953 \let\math=\(
954 \let\endmath=\)
955 \let\displaymath=\[
956 \let\enddisplaymath=\]
957 \renewcommand*{\(}{\left(}%
958 \renewcommand*{\)}{\right)}%
959 \renewcommand*{\[}{\left[}%
960 \renewcommand*{\]}{\right]}%
961 \renewcommand*{\{}{\left\lbrace}%
962 \renewcommand*{\}}{\right\rbrace}%
963 }
964 \fi
965 % \end{macrocode}
966 %
967 %\iffalse % MetaComment
968 %<*package>
969 %\fi
970 %
971 % \CheckSum{653}
972 % \Finale
973 %
974 \endinput
975