-% \begin{ignore}
-% The following is the original definition of the enhanced eqnarray
-% environment. It's not supported, although if you can figure out how to
-% extract it, it's all yours.
-% \end{ignore}
-%
-% \begin{old-eqnarray}
-%
-% \subsection{The sparkly new \env{eqnarray}}
-%
-% Start off by writing a different package.
-%
-% \begin{macrocode}
-%</package>
-%<*oldeqnarray>
-% \end{macrocode}
-%
-% \subsubsection{Options handling}
-%
-% We need to be able to cope with \textsf{fleqn} and \textsf{leqno} options.
-% This will adjust our magic modified \env{eqnarray} environment
-% appropriately.
-%
-% \begin{macrocode}
-\newif\if@fleqn
-\newif\if@leqno
-\DeclareOption{fleqn}{\@fleqntrue}
-\DeclareOption{leqno}{\@leqnotrue}
-\ProcessOptions
-% \end{macrocode}
-%
-% This is all really different to the \LaTeX\ version. I've looked at the
-% various \env{tabular} implementations, the original \env{eqnarray} and the
-% \textit{\TeX book} to see how best to do this, and then went my own way.
-% If it doesn't work it's all my fault.
-%
-% \subsubsection{Some useful registers}
-%
-% The old \LaTeX\ version puts the equation numbers in by keeping a count of
-% where it is in the alignment. Since I don't know how may columns there are
-% going to be, I'll just use a switch in the preamble to tell me to stop
-% tabbing.
-%
-% \begin{macrocode}
-\newif\if@eqalast
-% \end{macrocode}
-%
-% Now define some useful length parameters. First allocate them:
-%
-% \begin{macrocode}
-\newskip\eqaopenskip
-\newskip\eqacloseskip
-\newskip\eqacolskip
-\newskip\eqainskip
-% \end{macrocode}
-%
-% Now assign some default values. Users can play with these if they really
-% want although I can't see the point myself.
-%
-% \begin{macrocode}
-\if@fleqn
- \AtBeginDocument{\eqaopenskip\leftmargini}
-\else
- \eqaopenskip\@centering
-\fi
-\eqacloseskip\@centering
-\eqacolskip\@centering
-\eqainskip\z@
-% \end{macrocode}
-%
-% We allow the user to play with the style if this is really wanted. I dunno
-% why, really. Maybe someone wants very small alignments.
-%
-% \begin{macrocode}
-\let\eqa@style\displaystyle
-% \end{macrocode}
-%
-% \subsubsection{The main environments}
-%
-% We define the toplevel commands here. They just add in default arguments
-% and then call |\@eqnarray| with a preamble string. The only difference is
-% the last column they add in -- \env{eqnarray$*$} throws away the last
-% column by sticking it in box~0. (I used to |\@gobble| it but that caused
-% the |\cr| to be lost.)
-%
-% \begin{macrocode}
-\def\eqnarray{\@ifnextchar[\eqnarray@i{\eqnarray@i[rcl]}}
-\def\eqnarray@i[#1]{%
- \@eqnarray{#1!{\hb@xt@\z@{\hss##}\tabskip\z@}}
-}
-\@namedef{eqnarray*}{\@ifnextchar[\eqnarray@s@i{\eqnarray@s@i[rcl]}}
-\def\eqnarray@s@i[#1]{%
- \@eqnarray{#1!{\nonumber\setbox\z@\hbox{##}\tabskip\z@}}%
-}
-% \end{macrocode}
-%
-% \subsubsection{Set up the initial display}
-%
-% \begin{macro}{\@eqnarray}
-%
-% The |\@eqnarray| command does most of the initial work. It sets up some
-% flags and things, builds the |\halign| preamble, and returns.
-%
-% \begin{macrocode}
-\def\@eqnarray#1{%
-% \end{macrocode}
-%
-% Start playing with the counter here. The original does some icky internal
-% playing, which isn't necessary. The |\if@eqnsw| switch is |true| if the
-% user hasn't supplied an equation number. The |\if@eqalast| switch is
-% |true| in the final equation-number column.
-%
-% \begin{macrocode}
- \refstepcounter{equation}%
- \@eqalastfalse%
- \global\@eqnswtrue%
- \m@th%
-% \end{macrocode}
-%
-% Set things up for the |\halign| which is coming up.
-%
-% \begin{macrocode}
- \openup\jot%
- \tabskip\eqaopenskip%
- \let\\\@eqncr%
- \everycr{}%
- $$%
-% \end{macrocode}
-%
-% We'll build the real |\halign| and preamble in a token register. All we
-% need to do is stuff the header in the token register, clear a switch
-% (that'll be explained later), parse the preamble and then expand the
-% tokens we collected. Easy, no?
-%
-% \begin{macrocode}
- \toks@{\halign to\displaywidth\bgroup}%
- \@tempswafalse%
- \eqa@preamble#1\end%
- \the\toks@\cr%
-}
-% \end{macrocode}
-%
-% \end{macro}
-%
-% \subsubsection{Parsing the preamble}
-%
-% All this actually involves is reading the next character and building a
-% command from it. That can pull off an argument if it needs it. Just make
-% sure we don't fall off the end and we'll be OK.
-%
-% \begin{macrocode}
-\def\eqa@preamble#1{%
- \ifx\end#1\else\csname eqa@char@#1\expandafter\endcsname\fi%
-}
-% \end{macrocode}
-%
-% Adding stuff to the preamble tokens is a simple matter of using
-% |\expandafter| in the correct way.\footnote{^^A
-% I have no idea why \LaTeX\ uses \cmd\edef\ for building its preamble. It
-% seems utterly insane to me -- the amount of bodgery that \env{tabular}
-% has to go through to make everything expand at the appropriate times is
-% scary. Maybe Messrs~Lamport and Mittelbach just forgot about token
-% registers when they were writing the code. Maybe I ought to rewrite the
-% thing properly some time. Sigh.
-%
-% As a sort of postscript to the above, I \emph{have} rewritten the
-% \env{tabular} environment, and made a damned fine job of it, in my
-% oh-so-humble opinion. All this \env{eqnarray} stuff has been remoulded
-% in terms of the generic column-defining things in \package{mdwtab}.
-% You're reading the documentation of the old version, which isn't
-% supported any more, so any bugs here are your own problem.}
-%
-% \begin{macrocode}
-\def\eqa@addraw#1{\expandafter\toks@\expandafter{\the\toks@#1}}
-% \end{macrocode}
-%
-% Now for some cleverness again. In order to put all the right bits of
-% |\tabskip| glue in the right places we must \emph{not} terminate each
-% column until we know what the next one is. We set |\if@tempswa| to be
-% |true| if there's a column waiting to be closed (so it's initially
-% |false|). The following macro adds a column correctly, assuming we're in
-% a formula. Other column types make their own arrangements.
-%
-% \begin{macrocode}
-\def\eqa@add#1{%
- \if@tempswa%
- \eqa@addraw{\tabskip\eqainskip}%
- \else%
- \eqa@addraw{#1}%
- \fi%
- \@tempswatrue%
-}
-% \end{macrocode}
-%
-% Now to defining column types. Let's define a macro which allows us to
-% define column types:
-%
-% \begin{macrocode}
-\def\eqa@def#1{\expandafter\def\csname eqa@char@#1\endcsname}
-% \end{macrocode}
-%
-% Now we can define the column types. Each column type must loop back to
-% |\eqa@preamble| once it's finished, to read the rest of the preamble
-% string. Note the positioning of ord atoms in the stuff below. This will
-% space out relations and binops correctly when they occur at the edges of
-% columns, and won't affect ord atoms at the edges, because ords pack
-% closely.
-%
-% First the easy onces. Just stick |\hfil| in the right places and
-% everything will be all right.
-%
-% \begin{macrocode}
-\eqa@def r{\eqa@add{\hfil$\eqa@style##{}$}\eqa@preamble}
-\eqa@def c{\eqa@add{\hfil$\eqa@style{}##{}$\hfil}\eqa@preamble}
-\eqa@def l{\eqa@add{$\eqa@style{}##$\hfil}\eqa@preamble}
-\eqa@def x{\eqa@add{\hfil$\eqa@style##$\hfil}\eqa@preamble}
-% \end{macrocode}
-%
-% Now for the textual ones. This is also fairly easy.
-%
-% \begin{macrocode}
-\eqa@def T#1{%
- \eqa@add{}%
- \if#1l\else\eqa@addraw{\hfil}\fi%
- \eqa@addraw{##}%
- \if#1r\else\eqa@addraw{\hfil}\fi%
- \eqa@preamble%
-}
-% \end{macrocode}
-%
-% Sort of split types of equations. I mustn't use |\rlap| here, or
-% everything goes wrong -- |\\| doesn't get noticed by \TeX\ in the same way
-% as |\cr| does.
-%
-% \begin{macrocode}
-\eqa@def L{\eqa@add{\hb@xt@\z@{$\eqa@style##$\hss}\qquad}\eqa@preamble}
-% \end{macrocode}
-%
-% The \lit{:} column type is fairly simple. We set |\tabskip| up to make
-% lots of space and close the current column, because there must be one.^^A
-% \footnote{This is an assumption.}
-%
-% \begin{macrocode}
-\eqa@def :{%
- \eqa@addraw{\tabskip\eqacolskip&}\@tempswafalse\eqa@preamble%
-}
-\eqa@def q{\eqa@add{\quad}\@tempswafalse\eqa@preamble}
-% \end{macrocode}
-%
-% The other column types just insert given text in an appropriate way.
-%
-% \begin{macrocode}
-\eqa@def >#1{\eqa@add{#1}\@tempswafalse\eqa@preamble}
-\eqa@def <#1{\eqa@addraw{#1}\eqa@preamble}
-% \end{macrocode}
-%
-% Finally, the magical \lit{!} column type, which sets the equation number.
-% We set up the |\tabskip| glue properly, tab on, and set the flag which
-% marks the final column.
-%
-% \begin{macrocode}
-\eqa@def !#1{%
- \eqa@addraw{\tabskip\eqacloseskip&\@eqalasttrue#1}\eqa@preamble%
-}
-% \end{macrocode}
-%
-% \subsubsection{Newline codes}
-%
-% Newline sequences (|\\|) get turned into calls of |\@eqncr|. The job is
-% fairly simple, really. However, to avoid reading `|&|' characters
-% prematurely, we set up a magic brace (from the \package{array} package --
-% this avoids creating ord atoms and other nastyness).
-%
-% \begin{macrocode}
-\def\@eqncr{%
- \iffalse{\fi\ifnum0=`}\fi%
- \@ifstar{\eqacr@i{\@M}}{\eqacr@i{\interdisplaylinepenalty}}%
-}
-\def\eqacr@i#1{\@ifnextchar[{\eqacr@ii{#1}}{\eqacr@ii{#1}[\z@]}}
-\def\eqacr@ii#1[#2]{%
- \ifnum0=`{}\fi%
- \eqa@eqnum%
- \noalign{\penalty#1\vskip#2\relax}%
-}
-% \end{macrocode}
-%
-% \subsubsection{Setting equation numbers}
-%
-% Before we start, we need to generalise the flush-left number handling bits.
-% The macro |\eqa@eqpos| will put its argument in the right place.
-%
-% \begin{macrocode}
-\if@leqno
- \def\eqa@eqpos#1{%
- \hb@xt@.01\p@{}\rlap{\normalfont\normalcolor\hskip-\displaywidth#1}%
- }
-\else
- \def\eqa@eqpos#1{\normalfont\normalcolor#1}
-\fi
-% \end{macrocode}
-%
-% First we need to move into the right column. Then we just set the equation
-% number appropriately. There is some subtlety here, ish. The |\relax| is
-% important, to delay expansion of the |\if|\dots\ until the new column has
-% been started. The two helper macros are important too, to hide `|&|'s and
-% `|\cr|'s from \TeX's scanner until the right time.
-%
-% \begin{macrocode}
-\def\eqa@eqnum{%
- \relax%
- \if@eqalast\expandafter\eqa@eqnum@i\else\expandafter\eqa@eqnum@ii\fi%
-}
-\def\eqa@eqnum@i{%
- \if@eqnsw%
- \eqa@eqpos{(\theequation)}\stepcounter{equation}%
- \else%
- \eqa@eqpos\eqa@number%
- \fi%
- \global\@eqnswtrue%
- \cr%
-}
-\def\eqa@eqnum@ii{&\eqa@eqnum}
-% \end{macrocode}
-%
-% \subsubsection{Numbering control}
-%
-% This is trivial. We set the |\if@eqnsw| flag to be |false| and store the
-% text in a macro.
-%
-% \begin{macrocode}
-\let\nonumber\relax
-\newcommand\nonumber[1][]{\global\@eqnswfalse\global\def\eqa@number{#1}}
-% \end{macrocode}
-%
-% \subsubsection{Closing the environments off}
-%
-% This is really easy. Set the final equation number, close the |\halign|,
-% tidy up the equation counter (it's been stepped once too many times) and
-% close the display.
-%
-% \begin{macrocode}
-\def\endeqnarray{%
- \eqa@eqnum%
- \egroup%
- \global\advance\c@equation\m@ne%
- $$%
- \global\@ignoretrue%
-}
-\expandafter\let\csname endeqnarray*\endcsname\endeqnarray
-% \end{macrocode}
-%
-% Now start up the other package again.
-%
-% \begin{macrocode}
-%</oldeqnarray>
-%<*package>
-% \end{macrocode}
-%
-% \end{old-eqnarray}
-%