%% eqnarrays.sty
%% Written by Tom Cormen, October 2003.
%% Provides the following environments:
%%   eqnarrayl: like eqnarray, but left column is flush left
%%   eqnarrayr: like eqnarray, but right column is flush right
%%   eqnarrayreason: like eqnarray, but has an additional column on the right;
%%                   the extra column is flush left and NOT in math mode, so
%%                   it's good for putting text justifying the line

\ProvidesPackage{eqnarrays}

\def\eqnarrayl{%
   \stepcounter{equation}%
   \def\@currentlabel{\p@equation\theequation}%
   \global\@eqnswtrue
   \m@th
   \global\@eqcnt\z@
   \tabskip\@centering
   \let\\\@eqncr
   $$\everycr{}\halign to\displaywidth\bgroup
       \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
      \hfil&\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${##}$\hfil
      &\global\@eqcnt\tw@ \hskip \tw@\arraycolsep
         $\displaystyle{##}$\hfil\tabskip\@centering
      &\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
         \tabskip\z@skip
      \cr
}
\def\endeqnarrayl{%
      \@@eqncr
      \egroup
      \global\advance\c@equation\m@ne
   $$\@ignoretrue
}
\@namedef{eqnarrayl*}{\def\@eqncr{\nonumber\@seqncr}\eqnarrayl}
\@namedef{endeqnarrayl*}{\nonumber\endeqnarrayl}

\def\eqnarrayr{%
   \stepcounter{equation}%
   \def\@currentlabel{\p@equation\theequation}%
   \global\@eqnswtrue
   \m@th
   \global\@eqcnt\z@
   \tabskip\@centering
   \let\\\@eqncr
   $$\everycr{}\halign to\displaywidth\bgroup
       \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
      &\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${##}$\hfil
      &\global\@eqcnt\tw@ \hskip \tw@\arraycolsep
         \hfil$\displaystyle{##}$\tabskip\@centering
      &\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
         \tabskip\z@skip
      \cr
}
\def\endeqnarrayr{%
      \@@eqncr
      \egroup
      \global\advance\c@equation\m@ne
   $$\@ignoretrue
}
\@namedef{eqnarrayr*}{\def\@eqncr{\nonumber\@seqncr}\eqnarrayr}
\@namedef{endeqnarrayr*}{\nonumber\endeqnarrayr}

\def\eqnarrayreason{%
   \stepcounter{equation}%
   \def\@currentlabel{\p@equation\theequation}%
   \global\@eqnswtrue
   \m@th
   \global\@eqcnt\z@
   \tabskip\@centering
   \let\\\@eqncr
   $$\everycr{}\halign to\displaywidth\bgroup
       \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
      &\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${##}$\hfil
      &\global\@eqcnt\tw@ \hskip \tw@\arraycolsep
         $\displaystyle{##}$\hfil\tabskip\@centering
       &\global\@eqcnt\tw@ \hskip \tw@\arraycolsep
          {##}\hfil\tabskip\@centering
      &\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
         \tabskip\z@skip
      \cr
}
\def\endeqnarrayreason{%
      \@@eqncr
      \egroup
      \global\advance\c@equation\m@ne
   $$\@ignoretrue
}
\@namedef{eqnarrayreason*}{\def\@eqncr{\nonumber\@seqncr}\eqnarrayreason}
\@namedef{endeqnarrayreason*}{\nonumber\endeqnarrayreason}

\endinput
