%\NeedsTeXFormat{LaTeX2e}
%\ProvidesPackage{equation}[1998/2/2 equation.sty]

\newskip\@eqnskip
\@eqnskip=\@centering
%\@eqnskip=\mathindent

%\DeclareOption{fleqn}{\@eqnskip=\mathindent}
%\ProcessOptions

% `eqnalign': 2-spaltig in der Form
%       lhs	(number1)
%     = rhs	(number2)
% Die *-Variante von `eqnalign' macht keine Numerierung
% S"amtliche Umgebungen arbeiten mit `fleqn' zusammen.

\def\eqnalign{\stepcounter{equation}\let\@currentlabel\theequation
\global\@eqnswtrue\m@th
\tabskip\@eqnskip\let\\\@eqncr
$$\halign to\linewidth\bgroup\global\@eqcnt\@ne\@eqnsel\hskip\@centering
  \hfil${##}$\hfil\tabskip\z@&\global\@eqcnt\tw@
  \hskip 2\arraycolsep$\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}

\let\endeqnalign=\endeqnarray

\@namedef{eqnalign*}{\def\@eqncr{\nonumber\@seqncr}\eqnalign}
\@namedef{endeqnalign*}{\nonumber\endeqnalign}

% `eqnalignref': 3-spaltig (letzte Spalte Erkl"arung im LR-Modus)
%       lhs	comment1
%     = rhs	comment2

\def\eqnalignref{
\tabskip\@eqnskip\let\\=\@eqnrefcr
$$\halign to \linewidth\bgroup\global\@eqcnt\@ne\@eqnsel\hskip\@centering
    \hfil${##}$\hfil\tabskip\z@&\global\@eqcnt\tw@
    \hskip 2\arraycolsep$\displaystyle{##}$\hfil\tabskip\@centering
    &\global\@eqcnt\thr@@\hbox to 0pt{\hss\ignorespaces##\unskip}\tabskip\z@\cr}

\def\endeqnarrayref{\@@eqnrefcr\egroup$$\global\@ignoretrue}

\let\endeqnalignref=\endeqnarrayref

\let\@eqnsel = \hfil

\def\@eqnrefcr{{\ifnum0=`}\fi\@ifstar{\global\@eqpen\@M
    \@yeqnrefcr}{\global\@eqpen\interdisplaylinepenalty \@yeqnrefcr}}

\def\@yeqnrefcr{\@ifnextchar [{\@xeqnrefcr}{\@xeqnrefcr[\z@]}}

\def\@xeqnrefcr[#1]{\ifnum0=`{\fi}\@@eqnrefcr
   \noalign{\penalty\@eqpen\vskip\jot\vskip #1\relax}}

\def\@@eqnrefcr{\let\@tempa\relax
     \ifcase\@eqcnt \def\@tempa{& & &}\or \def\@tempa{& &} 
      \or \def\@tempa{&}\fi\@tempa\global\@eqcnt\z@\cr}

% `eqnarrayref': 4-spaltig (letzte Spalte Erkl"arung im LR-Modus)
%     lhs = rhs1	comment1
%         = rhs2	comment2

\def\eqnarrayref{
\global\@eqcnt\z@\tabskip\@eqnskip\let\\=\@eqnrefcr
$$\halign to \linewidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne 
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@eqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil 
   \tabskip\@centering&\global\@eqcnt\thr@@\hbox to 0pt{\hss\ignorespaces##\unskip}\tabskip\z@\cr}
