summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/bosisio/envmath.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/bosisio/envmath.dtx
Initial commit
Diffstat (limited to 'macros/latex/contrib/bosisio/envmath.dtx')
-rw-r--r--macros/latex/contrib/bosisio/envmath.dtx975
1 files changed, 975 insertions, 0 deletions
diff --git a/macros/latex/contrib/bosisio/envmath.dtx b/macros/latex/contrib/bosisio/envmath.dtx
new file mode 100644
index 0000000000..e1f74afc03
--- /dev/null
+++ b/macros/latex/contrib/bosisio/envmath.dtx
@@ -0,0 +1,975 @@
+%\iffalse % MetaComment
+%%
+%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+%% | Copyright(C) 1997-2010 by F. Bosisio |
+%% | |
+%% | This program can be redistributed and/or modified under |
+%% | the terms of the LaTeX Project Public License, either |
+%% | version 1.3 of this license or (at your option) any later |
+%% | version. The latest version of this license is in |
+%% | http://www.latex-project.org/lppl.txt |
+%% | and version 1.3 or later is part of all LaTeX distributions |
+%% | version 2005/12/01 or later. |
+%% | |
+%% | This work has the LPPL maintenance status `maintained'. |
+%% | The Current Maintainer of this work is F. Bosisio. |
+%% | |
+%% | This work consists of files envmath.dtx and envmath.html |
+%% | and of the derived files envmath.sty and envmath.pdf. |
+%% | |
+%% | E-mail: fbosisio@bigfoot.com |
+%% | CTAN location: macros/latex/contrib/bosisio/ |
+%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+%%
+%% If you make any improvment, find any bug or have
+%% any suggestion, please let me know about it.
+%%
+%<*package,driver>
+%\fi
+%
+\def\FileName{envmath}
+%\iffalse % MetaComment
+%</package,driver>
+%<*package>
+%\fi
+\def\fileversion{2.5}
+\def\filedate{2010/02/10}
+\def\docdate{2005/04/09}
+\def\filedescr{Extended math environments (FB)}
+%
+%\iffalse % MetaComment
+%</package>
+%<*dtx>
+%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+% This section is the installation driver
+%
+\def\batchfile{\FileName.dtx}
+%
+\input docstrip
+%
+\keepsilent
+% \askforoverwritefalse
+%
+\generateFile{\FileName.sty}{f}{\from{\FileName.dtx}{package}}
+%
+\generateFile{\FileName.drv}{f}{\from{\FileName.dtx}{driver}}
+%
+\Msg{******************************************************}
+\Msg{*}
+\Msg{* To produce the documentation run the}
+\Msg{* file `\FileName.drv' through LaTeX.}
+\Msg{*}
+\Msg{******************************************************}
+%
+\endbatchfile
+%
+% End of the installation driver
+%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+%</dtx>
+%
+% This section is the documentation driver
+%
+%<+driver>\documentclass[12pt,a4paper]{ltxdoc}
+%<+driver> \EnableCrossrefs
+%<+driver> \CodelineIndex
+%<+driver> \RecordChanges
+%<+driver> %\OnlyDescription % Uncomment not to see the implementation
+%<+driver>\begin{document}
+%<+driver> \DocInput{\FileName.dtx}
+%<+driver> \PrintIndex
+%<+driver> \PrintChanges
+%<+driver>\end{document}
+%
+% End of the documentation driver
+%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+%<*package>
+%\fi
+%
+% \changes{v0.1}{20 April 1997}{First release (basic environments)}
+% \changes{v0.2}{10 May 1997}{Added the ``*-form'' of environments}
+% \changes{v1.0}{24 May 1997}{Documentation added}
+% \changes{v1.1}{18 October 1997}{``EQNarray'' and ``EqSystem'' environments}
+% \changes{v1.2}{5 November 1997}{Options to behave like ``Standard'' LateX}
+% \changes{v1.3}{8 November 1997}{Documentation updated}
+% \changes{v2.0}{20 December 1997}{Separated from package ``mathcmd''}
+% \changes{v2.1}{4 February 1998}{``MultiLine'' and ``EqSystem'' environments
+% reimplemented; ``EQNarray'' environment and
+% ``CONTINUE'' command made obsolete}
+% \changes{v2.2}{6 February 1998}{``@StandartEquation'' deferred
+% ``AtBeginDocument''; some ``def'' replaced
+% by ``newcommand*''; documentation updated}
+% \changes{v2.3}{5 March 1999}{Added copyright notice and changed addresses}
+% \changes{v2.4}{9 April 2005}{Usage of the double-quote character (") avoided}
+% \changes{v2.5}{10 February 2010}{Package renamed from ``mathenv'' to
+% ``envmath'' to avoid name conflicts}
+%\iffalse % MetaComment
+% The previous change was requested by Karl Berry (karl@freefriends.org)
+%\fi
+%
+% \MakeShortVerb{\|}
+%
+% \title{Package \texttt{\FileName}\thanks{This is version \fileversion,
+% last revised \filedate; documentation date \docdate}}
+% \author{F. Bosisio\\\normalsize E-mail: \texttt{fbosisio@bigfoot.com}}
+% \date{\filedate}
+% \maketitle
+%
+% \begin{abstract}
+% Documentation for the package \texttt{\FileName}.
+% \end{abstract}
+%
+% \section{Introduction}
+% This package provides some useful math-commands and enviroments,
+% which are simpler to use and prettier then their standard \LaTeX{}
+% counterpart.
+%
+% In particular some commands are redefined\footnote{See the options
+% in next section if you don't want these comand to be redefined}, so
+% care should be taken, expecially when including this package in an
+% already existent \LaTeX{} file.
+%
+% \noindent
+% The redefined commands are:\\
+% |\(|, |\)|, |\[|, |\]|, |\{| and |\}| \\
+% The effect of ``|\(| \dots |\)|'' can still be achieved by the
+% \LaTeX{} equivalent commands ``|\begin{math}| \dots |\end{math}|''
+% or ``|$| \dots |$|''.
+%
+% \noindent
+% Similarly, the effect of ``|\[| \dots |\]|'' can be achieved by
+% the \LaTeX{} equivalent commands
+% ``|\begin{displaymath}| \ldots |\end{displaymath}|''
+% or ``|$$| \dots |$$|''.
+%
+% \noindent
+% The ``|\{|'' and ``|\}|'' commands are the more error-prone, since
+% one may try to use ``|\left\{|'', which now is incorrect, because
+% the ``|\{|'' command already contains a ``|\left|'' declaration.
+% In the rare occasions where a brace of normal size is needed, one
+% can use the \LaTeX{} commands ``|\lbrace|'' and ``|\rbrace|''
+%
+% \noindent
+% Also the ``|equation|'' environment has been changed, but it is
+% completly compatible with the original definition, so it should
+% be safe, perhaps except when the first character of the equation
+% is an open square bracket or it is placed in a moving argument:
+% in fact, the new version of this command is fragile, and this is
+% true also for most of the commands defined by this package.
+%
+% \section{Backward compatibility}
+% The package has been renamed from ``|mathenv|'' to ``|envmath|'',
+% in order to avoid conflicts with another package with the same name:
+% if you were using the ``old'' package, you need to change your \LaTeX{}
+% files in order to include the new ones.\\
+% Alternatively, you can also rename the package to give it the ``old''
+% name (you need to change also the ``|\def\FileName{...}|'' line inside
+% the ``|sty|''-file), but you must take care not to have another package
+% with the same name installed on your system.
+%
+% \section{The options}
+% At now, five options are available with the \texttt{\FileName}
+% package.
+%
+% \noindent
+% The ``|RedefEquation|''/``|StdEquation|'' and
+% ``|RedefBrackets|''/``|StdBrackets|'' options control
+% whether the ``|equation|'' environment and the brace commands
+% ``|\(|'', ``|\(|'', ``|\)|'', ``|\[|'', ``|\]|'', ``|\{|'' and ``|\}|
+% should be redefined or retain their original \LaTeX{} meaning.
+% More precisely, ``|RedefEquation|'' (default) redefines the
+% ``equation'' environment to have an optional argument (used as a
+% label), while ``|StdEquation|'' leaves it unchanged. In the first
+% case, the ``equation'' environment will be equivalent to the
+% ``Equation'' environment (capitalized!) described below, whereas in
+% the second case they will be different.
+% Similarly, the ``|RedefBrackets|'' option (default) makes the
+% brackets command to be redefined, whilst ``|StdBrackets|'' leave
+% them their original meaning.
+% Also a ``|Standard|'' option exists, which amounts to specify both
+% the ``|StdEquation|'' and ``|StdBrackets|'' options, thus making the
+% package fully standard, which may be useful when sending your
+% \LaTeX{} files to someone else.
+%
+% \section{Math-mode environments}
+% This package provides three math-mode environments, each with a
+% ``*-form'' which does not generates numbers.
+%
+% \subsection{The \texttt{Equation} environment}
+% The ``|Equation|'' environment has an optional argument
+% which is used as a label to reference it.
+% \begin{verbatim}
+% \begin{Equation}[label]
+% ...
+% \end{Equation}
+% \end{verbatim}
+% If the ``|RedefEquation|'' option is in effect (default),
+% then the ``|equation|'' environment is redefined to have
+% the same optional argument as ``|Equation|''.
+%
+% There is also a *-form, which does not generate a number
+% (so this *-form is really a ``displaymath'' and not an
+% equation, but it has been added for simmetry and for making
+% it easier to add or remove the number to a formula).
+%
+% \noindent
+% The *-form has an optional argument like the non-* form,
+% which is disregarded by the environment and is added only
+% for simmetry reasons.
+% \begin{verbatim}
+% \begin{equation*}[disregarded-label]
+% ...
+% \end{equation*}
+% \end{verbatim}
+%
+% \subsection{The \texttt{MultiLine} equation environment}
+% The ``|MultiLine|'' environment is intended for formulas
+% that don't fit on a single line, and so must be broken
+% across lines.
+%
+% \noindent
+% As for the |Equation| environment above, it has an optional
+% argument which is used as a label.
+%
+% \noindent
+% All the lines but the first are automatically indented by
+% the lenght ``|\MultiLineIndent|'', which is rougthly what
+% one expects, but can be changed at any time by the user
+% with ``|\setlenght{\MultiLineIndent}{...}|''.
+% You can also control the alignment of the continuation rows
+% by placing an optional |&| in the first row: is such a case
+% all the others line will \emph{not} be indented
+% by ``|\MultiLineIndent|'' but wil behave \emph{as if} there
+% there were an ampersand in front of them (i.e. they will be
+% left-aligned at the right of the \& in the first row).
+%
+% \noindent
+% Each line but the last must end with a ``|\\|'' command
+% (which can have an optional argument to add some vertical
+% space between lines).
+% When the line is broken in the middle (e.g. after a ``+''
+% sign) and not at the end (i.e. after a ``='' or similar), the
+% *-form ``|\\*|'' may be used to indicate the line-break, the
+% difference being in an extra space added at the beginning of
+% the next line.
+% The width of a thise space defaults to 1em and can be changed
+% by the user with ``|\setlenght{\MultiLineStarIndent}{...}|''.
+%
+% \begin{verbatim}
+% \begin{MultiLine}[label]
+% ... [&]= ... = \\
+% = ... + \\*
+% + ... = \\
+% = ...
+% \end{MultiLine}
+% \end{verbatim}
+%
+% Also this environment has a *-form which differs only in that
+% it does not generate an equation number.
+% \begin{verbatim}
+% \begin{MultiLine*}[disregarded-label]
+% ... [&]= ... = \\
+% = ... + \\*
+% + ... = \\
+% = ...
+% \end{MultiLine*}
+% \end{verbatim}
+%
+% \subsection{The \texttt{System} environment}
+% The ``|System|'' environment is used for grouping a set of
+% equations together inside a left brace, with one only
+% equation number.
+%
+% \noindent
+% Again there is an optional argument to indicate a label and
+% each equation is separated by a ``|\\|'' or ``|\\*|'' command,
+% as for the ``|MultiLine|'' environment.
+%
+% \noindent
+% The rows (except the ones ended with the *-form ``|\\*|'')
+% may optionally contain one ``|&|'', which is usually used
+% when some text should be added to the equation.
+% \begin{verbatim}
+% \begin{System}[label]
+% ... = ... [& ...] \\
+% ... = ... + \\*
+% + ... [& ...] \\
+% ... = ... [& ...]
+% \end{System}
+% \end{verbatim}
+%
+% A *-form which does not generate any number is also provided.
+% \begin{verbatim}
+% \begin{System*}[disregarded-label]
+% ... = ... [& ...] \\
+% ... = ... + \\*
+% + ... [& ...] \\
+% ... = ... [& ...]
+% \end{System*}
+% \end{verbatim}
+%
+% \subsection{The \texttt{EqSystem} environment}
+% The ``|EqSystem|'' environment is used for grouping a set of
+% equations together inside a left brace, each with its own
+% equation number.
+%
+% \noindent
+% Again there is an optional argument to indicate a label and
+% each equation is separated by a ``|\\|'' or ``|\\*|'' command.
+%
+% \noindent
+% The rows may optionally contain one ``|&|'', which is
+% usually used when some text should be added to the equation.
+% \begin{verbatim}
+% \begin{EqSystem}[label]
+% ... = ... [& ...] \\ % (1.1)
+% ... = ... + \\* % (1.2)
+% + ... [& ...] \\ % (1.3)
+% ... = ... [& ...] % (1.4)
+% \end{EqSystem}
+% \end{verbatim}
+%
+% A *-form is also provided: it differs in that each equation
+% is numbered with the same number but with a lowercase letter
+% added, i.e. like (1.1a), (1.1b), etc. instead of (1.1),
+% (1.2) and so on.
+% \begin{verbatim}
+% \begin{EqSystem*}[label]
+% ... = ... [& ...] \\ % (1.5a)
+% ... = ... + \\* % (1.5b)
+% + ... [& ...] \\ % (1.5c)
+% ... = ... [& ...] % (1.5d)
+% \end{EqSystem*}
+% \end{verbatim}
+% In both cases, if the optional argument is present, each
+% equation can be referenced by |\ref{<label>:a}|,
+% |\ref{<label>:b}|, \dots, where |<label>|, stands for
+% the string used as optional argument.
+% In the case of the *-form, a reference of the kind
+% |\ref{<label>}| will print the equation number without
+% any letter, thus referring to the system as a whole,
+% whereas such a reference is meaningless (and indeed does
+% not exists) when dealing with the non *-form.
+%
+%
+% \section{Math-mode commands}
+% In addition to the previously mentioned environments, the
+% \texttt{\FileName} package defines also some of math-mode
+% commands which considerably simplify the use of adjustable-size
+% parentheses.
+%
+% \noindent
+% The ``|\(|'', ``|\[|'', ``|\{|'', ``|\)|'', ``|\]|''
+% and ``|\}|'' generates the corresponding parenthesis but
+% with a ``|\left|'' or ``|\right|'' declaration
+% (respectively) added, so they must come in matched pairs or
+% coupled with a ``|\left.|'' or ``|\rigtht.|'' or another
+% adjustable-size delimiter.
+%
+% \StopEventually{}
+% \newpage
+% \section{Implementation}
+%
+% \begin{macrocode}
+%%
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesPackage{\FileName}[\filedate\space v\fileversion\space\filedescr]
+%%
+\newif\if@Redefine@Equation@
+\DeclareOption{RedefEquation}{\@Redefine@Equation@true}
+\DeclareOption{StdEquation}{\@Redefine@Equation@false}
+%%
+\newif\if@Redefine@Brackets@
+\DeclareOption{RedefBrackets}{\@Redefine@Brackets@true}
+\DeclareOption{StdBrackets}{\@Redefine@Brackets@false}
+%%
+\DeclareOption{Standard}{\@Redefine@Equation@false\@Redefine@Brackets@false}
+%%
+\ExecuteOptions{RedefEquation,RedefBrackets}
+% \end{macrocode}
+%
+% The ``|\ProcessOptions*|'' command was used here instead of
+% ``|\ProcessOptions*|'' in order to process the options in the
+% ``|\usepackage|'' order, rather than in the declaration order
+% \begin{macrocode}
+%%
+\ProcessOptions*
+% \end{macrocode}
+%
+% \begin{macro}{\StartMath@Err}
+% The ``|\StartMath@Err|'' prints an error message if used in math-mode
+% (saying that you can't use the command passed to it as an argument in
+% math-mode); otherwise it just enters math-mode through a |$$|.
+% It is used by the *-form of the math-environments to prevent
+% their use in math-mode.
+% \begin{macrocode}
+%%
+\newcommand*\StartMath@Err[1]{%
+\ifmmode\PackageError{\FileName}{%
+You can't use environment ``#1'' in math mode}{%
+You probably used ``\string\end{#1}'' without a previous ``\string\begin{#1}''.}%
+\else$$\fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{Equation}
+% The definition of the original ``|equation|'' environment is first saved
+% in the ``|\@StandardEquation|'' command.
+% Then the ``|\@LabelledEquation|'' command is defined as an |equation|
+% with a label.
+% The |Equation| command simply calls ``|\@LabelledEquation|'' or
+% ``|\@StandardEquation|'', depending on the presence or absence of the
+% optional argument (indicated by the square bracket).
+% \begin{macrocode}
+%%
+\AtBeginDocument{%
+\let\@StandardEquation=\equation
+}
+\def\@LabelledEquation[#1]{\@StandardEquation\label{#1}}
+\newenvironment{Equation}{%
+\@ifnextchar[{\@LabelledEquation}{\@StandardEquation}%
+}{%
+\endequation%
+}
+% \end{macrocode}
+%
+% If the ``|RedefEquation|'' option is in effect, |equation| is defined
+% to be the same as |Equation|.
+% The actual definition of the |equation| environment is deferred at the
+% ``|\begin{document}|'' in order to minimize the possibility of
+% conflicts with other packages.
+% \begin{macrocode}
+\if@Redefine@Equation@
+ \AtBeginDocument{\let\equation=\Equation}
+\fi
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{equation*}
+% The command ``|\Equation@Star|'' simply enters math-mode (via the
+% ``|\StartMath@Err|'' command).
+% The definition of ``|equation*|'' is deferred at the
+% ``|\begin{document}|'' so that this definition takes precedence over
+% the analogue one from the ``|amsmath|'' package, if both are included.
+% The command ``|\global\@ignoretrue|'' in the definition of
+% ``|\end{equation*}|'' prevents spurious spaces at the beginning of next
+% line.
+% \begin{macrocode}
+%%
+\def\Equation@Star[#1]{\StartMath@Err{equation*}}
+\AtBeginDocument{%
+\@namedef{equation*}{\@ifnextchar[{\Equation@Star}{\Equation@Star[]}}%
+\@namedef{endequation*}{$$\global\@ignoretrue}%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{macro}{\ARRAY@CR}
+% The original definition of ``|\@arraycr|'' is saved in the command
+% ``|\@ArrayCR|''.
+% Then ``|\ARRAY@CR|'' is defined to do the same job of ``|\@arraycr|''
+% and add a ``|\displaystyle|'' declation at the beginning of next row.
+% \begin{macrocode}
+%%
+\let\@ArrayCR=\@arraycr
+\def\@ArrayCR@quadra[#1]{\@ArrayCR[#1]\displaystyle}
+\def\@ArrayCR@star@quadra[#1]{%
+\@ArrayCR[#1]\displaystyle\mbox{\hspace{\SystemStarIndent}}%
+}
+\def\@ArrayCR@star*{%
+\@ifnextchar[{\@ArrayCR@star@quadra}{%
+\@ArrayCR\displaystyle\mbox{\hspace{\SystemStarIndent}}}}%
+\newcommand*{\ARRAY@CR}{\@ifnextchar*{\@ArrayCR@star}{%
+\@ifnextchar[{\@ArrayCR@quadra}{\@ArrayCR\displaystyle}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MakeAmper@Active}
+% Makes ``\&'' active (instead of a tab marker), giving
+% it the meaning specified by the argument.
+% \begin{macrocode}
+%%
+\newcommand*\MakeAmper@Active[1]{
+\global\def\@AMPERSAND{#1}%
+\begingroup%
+ \catcode`\~\active \lccode`\~`\&%
+ \lowercase{%
+ \global\expandafter\let
+ \csname ac\string\&\endcsname~%
+ \gdef~{\@AMPERSAND}}%
+\endgroup%
+\global\catcode`\&\active%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MakeAmper@Tab}
+% Restores ``\&'' to its original meaning (a tab marker).
+% \begin{macrocode}
+%%
+\newcommand*\MakeAmper@Tab{\global\catcode`\&=4}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\OneShot@Amper}
+% Makes ``\&'' active for one occurrence only: when encountered, the
+% code in the first argument is executed, then ``\&'' is restored to
+% its original meaning, a tab marker is inserted, and finally the
+% code in the second argument is executed.
+% \begin{macrocode}
+%%
+\newcommand*\OneShot@Amper[2]{%
+\MakeAmper@Active{#1\expandafter\MakeAmper@Tab&#2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MultiLineIndent}
+% The length ``|\MultiLineIndent|'' represents the amount of spece by
+% which each line but the first of a ``|MultiLine|'' environment is
+% indented. It defaults to 1.7em, which is roughtly equal to the width
+% of a character followed by an equal sign (e.g.: ``|A = |'' ).
+% \begin{macrocode}
+%%
+\newlength\MultiLineIndent
+\setlength{\MultiLineIndent}{1.7em}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MultiLineStarIndent}
+% The length ``|\MultiLineStarIndent|'' represents the amount of spece by
+% which each line following a ``|\\*|'' in a ``|MultiLine|'' environment is
+% indented. It defaults to 1em, which is roughtly equal to the width
+% of a an equal sign (e.g.: ``|=|'' ).
+% \begin{macrocode}
+%%
+\newlength\MultiLineStarIndent
+\setlength\MultiLineStarIndent{1em}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@MultiLineCR}
+% The ``|\@MultiLineCR|'' command does the original job of ``|\@arrycr|''
+% (saved in ``|\ArrayCR|'') and then executes the ``|\ML@EveryRow|''
+% command.
+% In the *-form it also adds a space equal to ``|\MultiLineStarIndent|''.
+% The splitting in subcommands is required in order to pass the optional
+% argument to ``|\@ArrayCR|'' and not to the last executed command.
+% \begin{macrocode}
+%%
+\newcommand*\@MultiLineCR{%
+\@ifnextchar*{\MLineCR@star}{%
+\@ifnextchar[{\MLineCR@quadra}{\@ArrayCR\ML@EveryRow}}%
+}
+\def\MLineCR@star*{%
+\@ifnextchar[{\MLineCR@star@quadra}{%
+\@ArrayCR\ML@EveryRow\hspace{\MultiLineStarIndent}}%
+}
+\def\MLineCR@star@quadra[#1]{%
+\@ArrayCR[#1]%
+\ML@EveryRow%
+\hspace{\MultiLineStarIndent}%
+}
+\def\MLineCR@quadra[#1]{\@ArrayCR[#1]\ML@EveryRow}
+% \end{macrocode}
+%
+% The ``|MultiLine|'' environment starts by setting ``|\ML@EveryRow|''
+% to be equivalent to ``|\@MultiLINEcr|'', so that this command is
+% executed at the end of the first row.
+% It checks the |\catcode| of \& and redefines ``|\ML@EveryRow|''
+% accordingly: if \& is a tab marker (|\catcode|=4), an ampersand has
+% occurred in the first row, so that each row must begin itself with
+% an ampersand; otherwise (i.e. if the |\catcode| of \& is \emph{active})
+% no ampersand were found in the first row, so that each line must begin
+% with a space equal to ``|\MultiLineStarIndent|''.
+% \begin{macrocode}
+\newcommand*\@MultiLINEcr{%
+\ifnum\catcode`\&=4%
+\global\def\ML@EveryRow{&\displaystyle\mbox{}}%
+\else%
+\MakeAmper@Tab%
+\global\def\ML@EveryRow{\displaystyle\mbox{\hspace{\MultiLineIndent}}}%
+\fi%
+\ML@EveryRow%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CONTINUE}
+% The command ``|\CONTINUE|'' is obsolete: you should use ``|\\*|'' instead.
+% \begin{macrocode}
+%%
+\newcommand*{\CONTINUE}{%
+\PackageError{\FileName}{%
+Command ``\string\CONTINUE'' is obsolete: use ``\string\\*'' instead}{%
+You'd better correct your input file as stated above,\MessageBreak%
+but if you press ENTER everything will work for the moment.}%
+\MLineCR@star*%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{MultiLine}
+% The internal commad ``|\Start@MultiLine|'' is used by the ``|MultiLine|''
+% and ``|MultiLine*|'' environments.
+% It makes \& add a ``|\displaystyle|'' declaration.
+% It also changes the meaning of ``|\\|'' to ``|\@MultiLineCR|'', sets
+% ``|\ML@EveryRow|'' to its default value ``|\@MultiLINEcr|'' and then
+% starts an ``|array|'' environment (we already are in math-mode
+% here) with one only column which is left aligned.
+% Finally, if there is an optional argument it is used as a ``|\label|''
+% or ignored, depending on the current meaning of ``|\@LABEL|'' (which
+% is the same as ``|\label|'' in the standard form and does nothing in
+% the *-form).
+% \begin{macrocode}
+%%
+\newcommand*\Start@MultiLine{%
+\@ifnextchar[{\Start@MultiLine@quadra}{\Start@MultiLine@no}%
+}
+%%
+\def\Start@MultiLine@quadra[#1]{\@LABEL{#1}\Start@MultiLine@no}
+%%
+\newcommand*\Start@MultiLine@no{%
+\OneShot@Amper{}{\displaystyle}%
+\let\@arraycr=\@MultiLineCR%
+\let\ML@EveryRow=\@MultiLINEcr%
+\begin{array}{l@{\hspace{0.3em}}l}%
+\displaystyle%
+}
+% \end{macrocode}
+%
+% The internal command ``|\Stop@MultiLine|'' is used by the ``|MultiLine|''
+% and ``|MultiLine*|'' environments.
+% It simply closes the ``|array|'' environment anr restores ``|\@arrycr|''
+% to its original meaning.
+% \begin{macrocode}
+%%
+\newcommand*\Stop@MultiLine{%
+\end{array}%
+\let\@arraycr=\@ArrayCR%
+\MakeAmper@Tab% % For the case no ``\\'' is used
+}
+% \end{macrocode}
+%
+% The ``|MultiLine|'' environment invokes ``|\Start@MultiLine|'' and
+% ``|\Stop@MultiLine|'' inside an ``|equation|'' environment.
+% \begin{macrocode}
+%%
+\newenvironment{MultiLine}{%
+\let\@LABEL=\label%
+\@StandardEquation%
+\Start@MultiLine%
+}{%
+\Stop@MultiLine%
+\endequation%
+\global\@ignoretrue%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{MultiLine*}
+% The ``|\MultiLine@Star|'' command issues an error message if used inside
+% math mode, while when in text mode starts a ``|displaymath|'' environment
+% (throught the ``|$$|'' command) in which a ``|\Start@MultiLineEq|'' command
+% is issued (so it is the same as ``|\Label@MultiLineEq|'', but with
+% ``|\equation|'' substituted by ``|$$|'').
+% \begin{macrocode}
+%%
+\@namedef{MultiLine*}{\ifmmode\Not@MathErr{MultiLine*}\else$$\fi%
+\def\@LABEL##1{}%
+\Start@MultiLine%
+}
+\@namedef{endMultiLine*}{\Stop@MultiLine$$\global\@ignoretrue}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{System}
+% The ``|\@System@Def|'' command is the kernel of the ``|System|'' and
+% ``|System*|'' environments.
+% It redefines ``|\@arraycr|'' so that ``|\\|'' not only ends the
+% line but also adds a ``|\displaystyle|'' declaration.
+% Then it draws an adjustable-size left brace, which will be as big as
+% the system requires.
+% Finally, a two-column array environment with a ``|\qquad|'' space
+% between the columns is started and a ``|\displaystyle|'' declaration
+% is added to the first row.
+% \begin{macrocode}
+%%
+\newcommand*\@System@Def{%
+\let\@arraycr=\ARRAY@CR%
+\left\lbrace%
+\begin{array}{l@{\qquad}l@{}}%
+\displaystyle%
+}
+% \end{macrocode}
+% The ``|\Label@System|'' commands opens an equation environment, issues
+% a ``|\label|'' command for cross-referencing, and then calls the
+% command ``|\@System@Def|'' defind above.
+% \begin{macrocode}
+\def\Label@System[#1]{\@StandardEquation\label{#1}\@System@Def}
+% \end{macrocode}
+% The ``|\begin{System}|'' command does the same things, skipping the
+% ``|\label|'' command if there isn't the optional parameter.
+% The ``|\end{System}|'' command closes the array, puts an invisible
+% delimiter (``|\right.|'') which pairs with the left brace of the
+% ``|\@System@Def|'' command, restores ``|\@arraycr|'' to its original
+% meaning, ends the equation, and prevents spurious spaces by issuing
+% the command ``|\global\@ignoretrue|''.
+% \begin{macrocode}
+\newenvironment{System}{%
+\@ifnextchar[{\Label@System}{\@StandardEquation\@System@Def}%
+}{%
+\end{array}%
+\right.%
+\endequation%
+\let\@arraycr=\@ArrayCR%
+\global\@ignoretrue%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{System*}
+% The ``|\System@Star|'' command generates en error message when used in
+% math-mode, and calls ``|\@System@Def|'' inside a ``|displaymath|''
+% environment (the ``|$$|'') when used in text-mode.
+% \begin{macrocode}
+%%
+\def\System@Star[#1]{\StartMath@Err{System*}\@System@Def}
+% \end{macrocode}
+% The ``|System*|'' environment is the same as ``|System|'', but with
+% ``|\begin{equation}|$\ldots$|\end{equation}|'' substituted by
+% ``|$$|\ldots|$$|''.
+% \begin{macrocode}
+\@namedef{System*}{\@ifnextchar[{\System@Star}{\System@Star[]}}
+\@namedef{endSystem*}{\end{array}\right. $$\let\@arraycr=\@ArrayCR \global\@ignoretrue}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{EQNarray}
+% The |EQNarray| environment is only for backward compatibility:
+% use the |equationarry| environment from package |eqnarray| if
+% you need more control than an |eqnarray| environment allows.
+% \begin{macrocode}
+%%
+\newenvironment{EQNarray}{%
+\PackageError{\FileName}{Environment ``EQNarray'' is obsolete}{%
+Use the ``equationarry'' environment from the ``eqnarray'' package instead!}%
+\eqnarray%
+}{%
+\endeqnarray%
+}
+% \end{macrocode}
+% \end{environment}
+% \begin{macro}{\SystemColSep,\SystemBraceSep,\SystemStarIndent}
+% \begin{macrocode}
+%%
+\newlength\SystemColSep
+\setlength\SystemColSep{2em}
+%%
+\newlength\SystemBraceSep
+\setlength\SystemBraceSep{3pt}
+%%
+\newlength\SystemStarIndent
+\setlength\SystemStarIndent{2em}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{EqSystem}
+% \begin{macrocode}
+%%
+\newsavebox{\SysRow@Box}
+\newlength\ColOne@Width
+\newlength\ColTwo@Width
+\newlength\SysCol@TmpWidth
+%%
+\newcommand*\Start@EqSysRow{%
+\OneShot@Amper{%
+$\end{lrbox}%
+\settowidth\SysCol@TmpWidth{\usebox{\SysRow@Box}}%
+\ifnum\SysCol@TmpWidth>\ColOne@Width\global\setlength\ColOne@Width\SysCol@TmpWidth\fi%
+\usebox{\SysRow@Box}%
+}{%
+\begin{lrbox}{\SysRow@Box}$\displaystyle%
+}%
+\begin{lrbox}{\SysRow@Box}$\displaystyle%
+}
+%%
+\newcommand*\Stop@EqSysRow{%
+$\end{lrbox}%
+\settowidth\SysCol@TmpWidth{\usebox{\SysRow@Box}}%
+\ifnum\catcode`\&=4%
+\ifnum\SysCol@TmpWidth>\ColTwo@Width\global\setlength\ColTwo@Width\SysCol@TmpWidth\fi%
+\else%
+\MakeAmper@Tab%
+\ifnum\SysCol@TmpWidth>\ColOne@Width\global\setlength\ColOne@Width\SysCol@TmpWidth\fi%
+\fi%
+\usebox{\SysRow@Box}%
+}
+%%
+\def\@EqSystCR@star@quadra[#1]{%
+\Sys@@eqncr%
+\noalign{\penalty\@eqpen\vskip #1\relax}%
+\Start@EqSysRow%
+\mbox{\hspace{\SystemStarIndent}}%
+}
+%%
+\def\@EqSystCR@star*{%
+\global\@eqnswfalse%
+\@ifnextchar[{\@EqSystCR@star@quadra}{%
+\Sys@@eqncr\Start@EqSysRow\mbox{\hspace{\SystemStarIndent}}}%
+}
+%%
+\def\@EqSystCR@quadra[#1]{%
+\Sys@@eqncr%
+\noalign{\penalty\@eqpen\vskip #1\relax}%
+\Start@EqSysRow%
+}
+%%
+\newcommand*\EqSyst@CR{%
+\Stop@EqSysRow%
+\@ifnextchar*{\@EqSystCR@star}{%
+\@ifnextchar[{\@EqSystCR@quadra}{\Sys@@eqncr\Start@EqSysRow}}%
+}
+%%
+\let\Label@EqSystem=\relax
+%%
+\newcommand*\Sys@@eqncr{%
+\let\reserved@a\relax%
+\ifcase\@eqcnt\def\reserved@a{& &}% %% \@eqcnt = 0
+\or\def\reserved@a{&}% %% \@eqcnt = 1
+\else% %% \@eqcnt > 1
+\let\reserved@a\@empty%
+\PackageError{\FileName}{Too many columns in EqSystem environment}{%
+You can use at most one ``&'' in each row of an ``EqSystem'' environment.}%
+\fi%
+\reserved@a%
+\if@eqnsw\Label@EqSystem\@eqnnum\stepcounter{equation}\fi%
+\global\@eqnswtrue%
+\global\@eqcnt\z@%
+\cr%
+}
+%%
+\newenvironment{EqSystem}[1][\relax]{%
+\setcounter{EqSys@counter}{0}%
+\def\Label@EqSystem{#1}%
+\def\@tempa{\relax}%
+\ifx\Label@EqSystem\@tempa\else%
+\def\Label@EqSystem{\stepcounter{EqSys@counter}\label{#1:\alph{EqSys@counter}}}%
+\fi%
+\BEGIN@EqSystem%
+}{%
+\Stop@EqSysRow%
+%%%-------------------- \endEQNarr@y ----------------------%
+\Sys@@eqncr%
+\egroup%
+\global\advance\c@equation\m@ne%
+$$%
+%%%--------------------------------------------------------%
+\vspace*{-\belowdisplayskip}%
+\end{minipage}%
+\advance\ColTwo@Width\ColOne@Width%
+\advance\ColTwo@Width\SystemColSep%
+\setlength\SysCol@TmpWidth\displaywidth%
+\global\advance\SysCol@TmpWidth-\ColTwo@Width%
+\global\divide\SysCol@TmpWidth\tw@%
+\global\advance\SysCol@TmpWidth\ColTwo@Width%
+\global\advance\SysCol@TmpWidth\SystemBraceSep% %% Space around left-brace
+\global\advance\SysCol@TmpWidth 1em% %% ~= Left-brace size
+\hspace{-\SysCol@TmpWidth}%
+\right\lbrace%
+\advance\SysCol@TmpWidth-1em% %% ~= Left-brace size
+\hspace*{\SysCol@TmpWidth}%
+$$\global\@ignoretrue%
+}
+%%
+\newcommand*\BEGIN@EqSystem{%
+\setlength\ColOne@Width\z@%
+\setlength\ColTwo@Width\z@%
+$$\left.%
+\begin{minipage}{\displaywidth}%
+\vspace*{-\abovedisplayskip}%
+%%%-------------------------- \EQNarr@y -------------------%
+\stepcounter{equation}%
+\let\@currentlabel=\theequation%
+\global\@eqnswtrue%
+\global\@eqcnt\z@%
+\tabskip\@centering%
+\let\\=\EqSyst@CR%
+$$\halign to \displaywidth\bgroup%
+\tabskip\z@{##}\hfil%
+&\global\@eqcnt\@ne%
+\hspace{\SystemColSep}{##}\hfil%
+\tabskip\@centering%
+&\llap{##}\tabskip\z@\cr%
+%%%--------------------------------------------------------%
+\Start@EqSysRow%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{EqSystem*}
+% \begin{macrocode}
+%%
+\newcounter{EqSys@counter}
+%%
+\newcommand*\EqSystem@Star[1][\relax]{%
+\stepcounter{equation}%
+\setcounter{EqSys@counter}{\value{equation}}%
+\def\Label@EqSystem{#1}%
+\def\@tempa{\relax}%
+\ifx\Label@EqSystem\@tempa\else%
+\let\@currentlabel=\theequation%
+\label{#1}%
+\def\Label@EqSystem{\label{#1:\alph{equation}}}%
+\fi%
+\let\INNER@theEQUATION=\theequation%
+\xdef\inner@theEQUATION{\theequation}%
+\def\theequation{\inner@theEQUATION\alph{equation}}%
+\setcounter{equation}{0}%
+\BEGIN@EqSystem%
+}
+%%
+\@namedef{EqSystem*}{\EqSystem@Star}
+%%
+\@namedef{endEqSystem*}{%
+\endEqSystem%
+\setcounter{equation}{\value{EqSys@counter}}%
+\global\let\theequation=\INNER@theEQUATION%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% The \LaTeX{} environments \texttt{math} and \texttt{displaymath}
+% are redefined so that they will not be affected by the subsequent
+% redefinition of the brackets commands.
+% The redefinition of the brackets commands is deferred at the
+% |\begin{document}|, so that other packages may use the original
+% definitions and cannot override the new ones.
+% It only takes place if the ``|RedefBrackets|'' option is in effect.
+% \begin{macrocode}
+\if@Redefine@Brackets@
+ \AtBeginDocument{%
+ \let\math=\(
+ \let\endmath=\)
+ \let\displaymath=\[
+ \let\enddisplaymath=\]
+ \renewcommand*{\(}{\left(}%
+ \renewcommand*{\)}{\right)}%
+ \renewcommand*{\[}{\left[}%
+ \renewcommand*{\]}{\right]}%
+ \renewcommand*{\{}{\left\lbrace}%
+ \renewcommand*{\}}{\right\rbrace}%
+ }
+\fi
+% \end{macrocode}
+%
+%\iffalse % MetaComment
+%<*package>
+%\fi
+%
+% \CheckSum{653}
+% \Finale
+%
+\endinput
+