%%
%% This is file `mparhack.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mparhack.dtx  (with options: `sty')
%% 
%% For fixing the marginpar bug.
%% 
\typeout{Style-option: `mparhack' (Stefan Ulrich & Tom Sgouros)}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mparhack}
        [1999/03/02 v1.0
   LaTeX2e fix for marginpars%
                   ]
\newcounter{mp@cnt}

%%% we use our own \pageref to avoid problems with babel:

\def\mp@setref#1#2#3{%
  \ifx#1\relax
    0 % just a dummy
  \else
   \expandafter#2#1%
  \fi
}

\def\mp@pageref#1{%
    \expandafter\mp@setref\csname r@#1\endcsname
    \@secondoftwo{#1}%
}


\def\@addmarginpar{%
    \stepcounter{mp@cnt}%
    \label{@mp@lab:\themp@cnt}%
    \@next\@marbox\@currlist{\@cons\@freelist\@marbox
    \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne
    \if@twocolumn
        \if@firstcolumn \@tempcnta\m@ne \fi
    \else
      \if@mparswitch
        \@ifundefined{r@@mp@lab:\themp@cnt}%
          {\ifodd\c@page \else\@tempcnta\m@ne \fi}%
          {\ifodd\mp@pageref{@mp@lab:\themp@cnt}%
            \else\@tempcnta\m@ne \fi}%
      \fi
    \if@reversemargin \@tempcnta -\@tempcnta \fi
    \fi
    \ifnum\@tempcnta <\z@  \global\setbox\@marbox\box\@currbox \fi
    \@tempdima\@mparbottom
    \advance\@tempdima -\@pageht
    \advance\@tempdima\ht\@marbox
    \ifdim\@tempdima >\z@
      \@latex@warning@no@line {Marginpar on page \thepage\space moved}%
    \else
      \@tempdima\z@
    \fi
    \global\@mparbottom\@pageht
    \global\advance\@mparbottom\@tempdima
    \global\advance\@mparbottom\dp\@marbox
    \global\advance\@mparbottom\marginparpush
    \advance\@tempdima -\ht\@marbox
    \global\setbox \@marbox
                   \vbox {\vskip \@tempdima
                          \box \@marbox}%
    \global \ht\@marbox \z@
    \global \dp\@marbox \z@
    \kern -\@pagedp
    \nointerlineskip
    \hb@xt@\columnwidth
      {\ifnum \@tempcnta >\z@
          \hskip\columnwidth \hskip\marginparsep
       \else
          \hskip -\marginparsep \hskip -\marginparwidth
       \fi
       \box\@marbox \hss}%
    \nointerlineskip
    \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}%
}

%%% Test for `twocolumn' option and issue an error if it's used,
%%% (maybe we should be using rather \@classoptionslist or \@ifclasswith?)

\DeclareOption{twocolumn}{%
        \PackageWarningNoLine{mparhack}{%
                Sorry, this package won't work correctly\MessageBreak
                with the `twocolumn' class option%
        }%
}%
\ProcessOptions*


\endinput
%%
%% End of file `mparhack.sty'.
