%%
%% This is file `marginnote.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% marginnote.dtx  (with options: `package')
%% 
%% IMPORTANT NOTE:
%% 
%% This is a generated file and you are not allowed to distribute it
%% without the source ot the work.  See below about more informations
%% about the files the work consists of.
%% 
%% Copyright (c) Markus Kohm  2005-2012
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% The author of the initial version of these work was
%% Markus Kohm <komascript@gmx.info>
%%
%% This work consists of the files marginnote.dtx, marginnote.ins,
%% and REAMDE.
%%
%% Important Recommendation:
%%   The LPPL requires that distributions of the Work contain all the files of
%%   the Work (see ``Important Recommendations'' at lppl.txt).
%%
\ProvidesPackage{marginnote}[%
  2012/03/29 v1.1i non floating margin notes for LaTeX]
\begingroup
  \def\@tempb{}%
  \def\@tempa{%
    \PackageError{marginnote}{seems you are not running e-TeX\@tempb}{%
      Since 2004 the LaTeX team recommends to use e-TeX.\MessageBreak
      marginnote since version 1.1d uses e-TeX features.\MessageBreak
      At actual systems `latex' should already use e-TeX.\MessageBreak
      At deprecated systems it may be called `elatex'.\MessageBreak
      Use either unsupported marginnote up to version 1.1c or\MessageBreak
      ask you administrator for LaTeX using e-TeX\@tempb.\MessageBreak
      Not using e-TeX\@tempb\space is a fatal error!\MessageBreak
      Processing cannot be continued!}%
    \endgroup
    \batchmode \errmessage{}\csname @@end\endcsname\end\relax
    \csname endinput\endcsname
  }%
  \expandafter\ifx\csname eTeXversion\endcsname\relax\else
    \ifnum\eTeXversion <2
      \def\@tempb{ V 2}%
    \else
      \let\@tempa\endgroup
    \fi
  \fi
\@tempa
\newif\if@mn@verbose\@mn@verbosetrue
\DeclareOption{verbose}{\@mn@verbosetrue}
\DeclareOption{quiet}{\@mn@verbosefalse}
\newcommand*{\mn@strut}{}
\newcommand{\mn@zbox}[1]{}
\DeclareOption{fulladjust}{%
  \renewcommand*{\mn@strut}{\strut}%
  \renewcommand{\mn@zbox}[1]{%
    \bgroup
      \setbox\@tempboxa\vbox{#1}%
      \ht\@tempboxa\ht\strutbox
      \dp\@tempboxa\dp\strutbox
      \wd\@tempboxa\z@
      \box\@tempboxa
    \egroup
  }%
}
\DeclareOption{heightadjust}{%
  \renewcommand*{\mn@strut}{\begingroup\dp\strutbox\z@\strut\endgroup}%
  \renewcommand{\mn@zbox}[1]{%
    \bgroup
      \setbox\@tempboxa\vbox{#1}%
      \ht\@tempboxa\ht\strutbox
      \dp\@tempboxa\dp\z@
      \wd\@tempboxa\z@
      \box\@tempboxa
    \egroup
  }%
}
\DeclareOption{depthadjust}{%
  \renewcommand*{\mn@strut}{\begingroup\ht\strutbox\z@\strut\endgroup}%
  \renewcommand{\mn@zbox}[1]{%
    \bgroup
      \setbox\@tempboxa\vbox{#1}%
      \ht\@tempboxa\ht\z@
      \dp\@tempboxa\dp\strutbox
      \wd\@tempboxa\z@
      \box\@tempboxa
    \egroup
  }%
}
\DeclareOption{noadjust}{%
  \renewcommand*{\mn@strut}{\relax}%
  \renewcommand{\mn@zbox}[1]{%
    \bgroup
      \setbox\@tempboxa\vbox{\kern-\ht\strutbox #1}%
      \ht\@tempboxa\ht\z@
      \dp\@tempboxa\dp\z@
      \wd\@tempboxa\z@
      \box\@tempboxa
    \egroup
  }%
}
\ExecuteOptions{verbose,fulladjust}
\ProcessOptions\relax
\newcommand*{\newmarginnote}{\@newl@bel{mn}}
\newif\if@mn@pdfmode\@mn@pdfmodefalse
\AtBeginDocument{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname pdflastxpos\endcsname\relax\else % bg or 1
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname pdftexversion\endcsname\relax % bg 2
      \begingroup\expandafter\expandafter\expandafter\endgroup
      \expandafter\ifx\csname pdfoutput\endcsname\relax % bg 3
        \begingroup\expandafter\expandafter\expandafter\endgroup
        \expandafter\ifx\csname XeTeXrevision\endcsname\relax\else % bg 4
          \@mn@pdfmodetrue
        \fi % ed 4
      \else % or 3
        \ifcase\pdfoutput\else\@mn@pdfmodetrue\fi % bg ed 4
      \fi % ed 3
    \else % or 2
      \ifnum \pdftexversion<140 % bg 3
        \begingroup\expandafter\expandafter\expandafter\endgroup
        \expandafter\ifx\csname pdfoutput\endcsname\relax % bg 4
        \else % or 4
          \ifcase\pdfoutput\else\@mn@pdfmodetrue\fi % bg ed 5
        \fi % ed 4
      \else % or 3
        \@mn@pdfmodetrue
      \fi % ed 3
    \fi % ed 2
  \fi % ed 1
  \if@mn@verbose
    \if@mn@pdfmode
      \PackageInfo{marginnote}{%
        \string\pdfoutput\space not 0 and \string\pdflastxpos\space
        available.\MessageBreak
        Extended position detection mode activated\@gobble
      }%
    \else
      \PackageInfo{marginnote}{%
        either \string\pdflastxpos\space or \string\pdfoutput\space not
        available\MessageBreak
        or \string\pdfoutput\space set to 0.\MessageBreak
        Extended position detection mode deactivated\@gobble
      }%
    \fi
  \fi
}
\newcommand*{\marginnotetextwidth}{}
\let\marginnotetextwidth\textwidth
\AtBeginDocument{\if@mn@pdfmode\edef\marginnotetextwidth{\the\textwidth}\fi}
\newcommand*{\@mn@thispage}{}
\newcommand*{\@mn@currpage}{}
\newcommand*{\@mn@currxpos}{}
\newcounter{mn@abspage}
\AtBeginDocument{\setcounter{mn@abspage}{1}%
  \g@addto@macro\@outputpage{\stepcounter{mn@abspage}}}
\newcommand*{\@mn@margintest}{%
  \expandafter\ifx\csname @mn@thispage\endcsname\@empty
    \gdef\@mn@atthispage{1}%
  \else\expandafter\ifnum \@mn@thispage=\value{mn@abspage}%
      \begingroup
        \@tempcnta\@mn@atthispage\advance\@tempcnta by \@ne
        \xdef\@mn@atthispage{\the\@tempcnta}%
      \endgroup
    \else
      \gdef\@mn@atthispage{1}%
    \fi
  \fi
  \xdef\@mn@thispage{\themn@abspage}%
  \let\@mn@currpage\relax
  \let\@mn@currxpos\relax
  \if@mn@pdfmode
    \pdfsavepos
    \protected@write\@auxout{\let\themn@abspage\relax}{%
      \string\newmarginnote{note.\@mn@thispage.\@mn@atthispage}{%
        {\themn@abspage}{\noexpand\number\pdflastxpos sp}}%
    }%
  \else
    \protected@write\@auxout{\let\themn@abspage\relax}{%
      \string\newmarginnote{note.\@mn@thispage.\@mn@atthispage}{%
        {\themn@abspage}{}}%
    }%
  \fi
  \expandafter\ifx\csname mn@note.\@mn@thispage.\@mn@atthispage\endcsname\relax
    \if@twoside
      \if@mn@verbose
        \PackageInfo{marginnote}{Suggest that margin
          note \@mn@thispage.\@mn@atthispage\space will be on\MessageBreak
          absolute page \themn@abspage.\MessageBreak
          This may be wrong}%
      \fi
      \ifodd\value{mn@abspage}\@tempswatrue\else\@tempswafalse\fi
    \else
      \if@mn@verbose
        \PackageInfo{marginnote}{right page because not two side mode}%
      \fi
      \@tempswatrue
    \fi
  \else
    \edef\@mn@currpage{\csname
      mn@note.\@mn@thispage.\@mn@atthispage\endcsname}%
    \edef\@mn@currxpos{\expandafter\@secondoftwo\@mn@currpage}%
    \edef\@mn@currxpos{\the\dimexpr \@mn@currxpos -\hoffset\relax}%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname pdfhorigin\endcsname\relax\else
      \begingroup\expandafter\expandafter\expandafter\endgroup
      \expandafter\ifx\csname pdfoutput\endcsname\relax\else
        \ifnum \pdfoutput=1 %
          \edef\@mn@currxpos{\the\dimexpr \@mn@currxpos -\pdfhorigin
            +1in\relax}%
        \fi
      \fi
    \fi
    \edef\@mn@currpage{\expandafter\@firstoftwo\@mn@currpage}%
    \if@mn@verbose
      \PackageInfo{marginnote}{Margin note \@mn@thispage.\@mn@atthispage\space
        is on absolute page \@mn@currpage\MessageBreak}%
    \fi
    \if@twoside
      \ifodd\@mn@currpage\relax
        \@tempswatrue
      \else
        \@tempswafalse
      \fi
    \else
      \if@mn@verbose
        \PackageInfo{marginnote}{right page because not two side mode}%
      \fi
      \@tempswatrue
    \fi
  \fi
}
\newcommand*{\marginnote}{%
  \@dblarg\@mn@marginnote
}
\newcommand{\@mn@marginnote}[2][]{%
  \ifhmode
    \@bsphack
    \begingroup
    \ifdim\@savsk>\z@\else
      \def\:{\@xifnch}\expandafter\def\: { \futurelet\@let@token\@ifnch}%
    \fi
  \else
    \begingroup
  \fi
  \@ifnextchar [{\@mn@@marginnote[{#1}]{#2}}{\@mn@@marginnote[{#1}]{#2}[\z@]}%
}
\newcommand{\@mn@@marginnote}{}
\long\def\@mn@@marginnote[#1]#2[#3]{%
  \endgroup
  \ifhmode
    \@mn@@@marginnote[{#1}]{#2}[{#3}]%
    \@esphack
  \else
    \@mn@@@marginnote[{#1}]{#2}[{#3}]%
  \fi
}
\newcommand{\@mn@@@marginnote}{}
\long\def\@mn@@@marginnote[#1]#2[#3]{%
  \begingroup
    \ifmmode\mn@strut\let\@tempa\mn@vadjust\else
      \if@inlabel\leavevmode\fi
      \ifhmode\mn@strut\let\@tempa\mn@vadjust\else\let\@tempa\mn@vlap\fi
    \fi
    \@tempa{%
      \vbox to\z@{%
        \vss
        \@mn@margintest
        \if@reversemargin\if@tempswa
            \@tempswafalse
          \else
            \@tempswatrue
        \fi\fi
        \if@tempswa
          \rlap{%
            \ifx\@mn@currxpos\relax
              \kern\marginnoterightadjust
              \if@mn@verbose
                \PackageInfo{marginnote}{%
                  xpos not known,\MessageBreak
                  using \string\marginnoterightadjust}%
              \fi
            \else\ifx\@mn@currxpos\@empty
                \kern\marginnoterightadjust
                \if@mn@verbose
                  \PackageInfo{marginnote}{%
                    xpos not known,\MessageBreak
                    using \string\marginnoterightadjust}%
                \fi
              \else
                \if@mn@verbose
                  \PackageInfo{marginnote}{%
                    xpos seems to be \@mn@currxpos,\MessageBreak
                    \string\marginnoterightadjust
                    \space ignored}%
                \fi
                \begingroup
                  \setlength{\@tempdima}{\@mn@currxpos}%
                  \kern-\@tempdima
                  \if@twoside\ifodd\@mn@currpage\relax
                      \kern\oddsidemargin
                    \else
                      \kern\evensidemargin
                    \fi
                  \else
                    \kern\oddsidemargin
                  \fi
                  \kern 1in
                \endgroup
              \fi
            \fi
            \kern\marginnotetextwidth\kern\marginparsep
            \vbox to\z@{\kern\marginnotevadjust\kern #3
              \vbox to\z@{%
                \hsize\marginparwidth
                \linewidth\hsize
                \kern-\parskip
                \marginfont\raggedrightmarginnote\strut\hspace{\z@}%
                \ignorespaces#2\endgraf
                \vss}%
              \vss}%
          }%
        \else
          \llap{%
            \vbox to\z@{\kern\marginnotevadjust\kern #3
              \vbox to\z@{%
                \hsize\marginparwidth
                \linewidth\hsize
                \kern-\parskip
                \marginfont\raggedleftmarginnote\strut\hspace{\z@}%
                \ignorespaces#1\endgraf
                \vss}%
              \vss}%
            \ifx\@mn@currxpos\relax
              \kern\marginnoteleftadjust
              \if@mn@verbose
                \PackageInfo{marginnote}{%
                  xpos not known,\MessageBreak
                  using \string\marginnoteleftadjust}%
              \fi
            \else\ifx\@mn@currxpos\@empty
                \kern\marginnoteleftadjust
                \if@mn@verbose
                  \PackageInfo{marginnote}{%
                    xpos not known,\MessageBreak
                    using \string\marginnoteleftadjust}%
                \fi
              \else
                \if@mn@verbose
                  \PackageInfo{marginnote}{%
                    xpos seems to be \@mn@currxpos,\MessageBreak
                    \string\marginnoteleftadjust
                    \space ignored}%
                \fi
               \begingroup
                  \kern\@mn@currxpos
                  \if@twoside\ifodd\@mn@currpage\relax
                      \kern-\oddsidemargin
                    \else
                      \kern-\evensidemargin
                    \fi
                  \else
                    \kern-\oddsidemargin
                  \fi
                  \kern-1in
                \endgroup
              \fi
            \fi
            \kern\marginparsep
          }%
        \fi
      }%
    }%
  \endgroup
}
\newcommand*{\marginnoterightadjust}{}
\newcommand*{\marginnoteleftadjust}{}
\let\marginnoterightadjust\z@
\let\marginnoteleftadjust\z@
\newcommand*{\marginnotevadjust}{}
\let\marginnotevadjust\z@
\newcommand{\mn@vlap}[1]{%
  \setbox\@tempboxa\vbox to \ht\strutbox{#1\vss}%
  \box\@tempboxa\vskip-\baselineskip
}
\newcommand{\mn@vadjust}[1]{%
  \mn@zbox{\kern-\parskip
    \leavevmode\vadjust{#1}%
    \kern\parskip
  }%
}
\providecommand*{\marginfont}{}
\newcommand*{\raggedleftmarginnote}{\raggedleft}
\newcommand*{\raggedrightmarginnote}{\raggedright}
\endinput
%%
%% End of file `marginnote.sty'.
