%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     filename      = "eqnarray.sty",
%%%     url           = "ftp://theory.lcs.mit.edu/pub/tex/eqnarray.sty",
%%%     version       = "2.00",
%%%     date          = "14 November 1994",
%%%     time          = "14:56:12 EST",
%%%     author        = "David M. Jones",
%%%     address       = "MIT Laboratory for Computer Science
%%%                      Room NE43-316
%%%                      545 Technology Square
%%%                      Cambridge, MA 02139
%%%                      USA",
%%%     telephone     = "(617) 253-5936",
%%%     FAX           = "(617) 253-3480",
%%%     checksum      = "57112 118 494 4533",
%%%     email         = "dmjones@theory.lcs.mit.edu (Internet)",
%%%     codetable     = "ISO/ASCII",
%%%     keywords      = "LaTeX, eqnarray",
%%%     supported     = "yes",
%%%     docstring     = "This file reimplements the LaTeX eqnarray
%%%                      environment to eliminate the absurd amount of
%%%                      space placed around the second column (10
%%%                      points in the standard styles).
%%%
%%%                      I know of no bugs in this implementation,
%%%                      but would be happy to hear of any problems
%%%                      that arise with it.
%%%
%%%                      Oh, by the way, all of this would be
%%%                      unnecessary if you used AMS-LaTeX.
%%%
%%%                      The checksum field above contains a CRC-16
%%%                      checksum as the first value, followed by
%%%                      the equivalent of the standard UNIX wc
%%%                      (word count) utility output of lines,
%%%                      words, and characters.  This is produced by
%%%                      Robert Solovay's checksum utility.  This
%%%                      program, as well as Nelson Beebe's proposal
%%%                      for standard file headers, is available via
%%%                      anonymous ftp from math.utah.edu.",
%%%     edit-history  = "v2.0, 14 Nov 1994 -- updated for LaTeX2e",
%%%  }
%%% ====================================================================

\ProvidesPackage{eqnarray}[1994/11/14 v2.0 fix eqnarray environment]

%% \@eqnmar controls whether the eqnarray environment is centered or
%% flushleft; if the environment should be centered, \@eqnmar should
%% be set equal to \@centering; else it should be set equal to
%% \mathindent.  \@eqnhook takes care of some other modifications that
%% should be made in flushleft mode; normally it's a no-op.

\let\@eqnmar\@centering

\let\@eqnhook\relax

\DeclareOption{fleqn}{%
    \let\@eqnmar\mathindent
    \def\@eqnhook{%
        \abovedisplayskip\topsep
        \ifvmode\advance\abovedisplayskip\partopsep\fi
        \belowdisplayskip\abovedisplayskip
        \belowdisplayshortskip\abovedisplayskip
        \abovedisplayshortskip\abovedisplayskip
    }%
}

\ProcessOptions

%% I removed the two occurences of \hskip 2\arraycolsep and changed
%% the template for the second column to ${{}##{}}$.  This restores
%% the proper amount of space around the second column of the
%% eqnarray.  I also introduced the parameters \@eqnmar and \@eqnhook
%% to provide support for the flush left equation style.

%% For version 2.0, I also replaced the \hskip\@centering that I had
%% removed from the beginning of the template in version 1.0.  It
%% seems to be necessary (I *thought* it worked without it before, but
%% I guess I was mistaken.)

\def\eqnarray{%
    \stepcounter{equation}%
    \def\@currentlabel{\p@equation\theequation}%
    \global\@eqnswtrue
    \m@th
    \global\@eqcnt\z@
    \tabskip\@eqnmar
    \let\\\@eqncr
    \@eqnhook
    $$\everycr{}
    \halign to\displaywidth\bgroup
        \hskip\@centering
        $\displaystyle
        \tabskip\z@skip
        {##}$%
        \@eqnsel
       &\global\@eqcnt\@ne
        \hfil${{}##{}}$\hfil
       &\global\@eqcnt\tw@
        $\displaystyle{##}$%
        \hfil
        \tabskip\@centering
       &\global\@eqcnt\thr@@
        \hbox to\z@\bgroup\hss##\egroup
        \tabskip\z@skip
    \cr
}

%% Since we've removed the \arraycolsep's from \eqnarray, we have to
%% redefine \lefteqn to put that space back in.  It seems unlikely
%% that \arraycolsep is really what should be used here, but the
%% following definition maintains compatibility with the old
%% definition of eqnarray.

\def\lefteqn#1{\hbox to 4\arraycolsep{$\displaystyle #1$\hss}}

\endinput
