summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/mparhack
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-12 23:59:43 +0000
committerKarl Berry <karl@freefriends.org>2006-01-12 23:59:43 +0000
commit91686423316d9adbdb83d6ed2e97c61f1e46d335 (patch)
tree5c65bb40f20fa44557c937ef4460587208113131 /Master/texmf-dist/tex/latex/mparhack
parentb0c5106727df8ef4ff38eb5a8bfb014f4acf142c (diff)
mparhack
git-svn-id: svn://tug.org/texlive/trunk@1109 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/mparhack')
-rw-r--r--Master/texmf-dist/tex/latex/mparhack/mparhack.sty280
1 files changed, 280 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/mparhack/mparhack.sty b/Master/texmf-dist/tex/latex/mparhack/mparhack.sty
new file mode 100644
index 00000000000..d1b3c650614
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/mparhack/mparhack.sty
@@ -0,0 +1,280 @@
+%%
+%% This is file `mparhack.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% mparhack.dtx (with options: `sty')
+%%
+%% Workaround for the marginpar bug.
+%%
+%% This program is free software; you can redistribute it and/or
+%% modify it under the terms of the GNU General Public License
+%% as published by the Free Software Foundation; either version 2
+%% of the License, or (at your option) any later version.
+%%
+%% This program is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+%% GNU General Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License
+%% along with this program; if not, write to the Free Software
+%% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+%%
+\NeedsTeXFormat{LaTeX2e}[1997/04/14]
+\ProvidesPackage{mparhack}
+ [2003/05/22 v1.3a (T. Sgouros and S. Ulrich)]
+\newif\if@mph@firstcol@
+\newif\if@mph@warning@
+\newif\if@debug@
+\newcommand*\mph@debug[2][]{%
+ \if@debug@
+ \typeout{DBG: #2}%
+ \else
+ \ifx#1\@empty\else
+ \typeout{DBG (#1): #2}%
+ \fi
+ \fi
+}
+
+\DeclareOption{debug}{%
+ \newcommand\mph@info{%
+ \@tempcnta=\mph@cnt
+ \advance\@tempcnta1
+ \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\tiny\the\@tempcnta}}%
+ }%
+ \long\def\@xmpar[#1]#2{%
+ \@savemarbox\@marbox{\mph@info#1}%
+ \@savemarbox\@currbox{\mph@info#2}%
+ \@xympar
+ }%
+ \long\def\@ympar#1{%
+ \@savemarbox\@marbox{\mph@info#1}%
+ \global\setbox\@currbox\copy\@marbox
+ \@xympar
+ }%
+ \global\@debug@true
+}%
+\ProcessOptions*
+\newcommand*\mph@nr{0}
+\newcommand*\mph@pg@new{0}
+\newcommand*\mph@lastpage{0}
+\newcommand*\mph@cnt{0}
+\newcommand*\mph@step@cnt[1]{%
+ \begingroup
+ \@tempcnta#1
+ \advance\@tempcnta\@ne
+ \protected@xdef#1{\the\@tempcnta}%
+ \endgroup
+}
+
+\newcommand*\mph@setcol[2]{%
+ \expandafter\xdef\csname mph@last@#1\endcsname{#2}%
+}
+\newcommand*\mph@tempa{}
+\newcommand*\mph@check[2]{%
+ \protected@edef\mph@tempa{#2}%
+ \expandafter\ifx\csname mph@last@#1\endcsname\mph@tempa
+ \mph@debug{\csname mph@last@#1\endcsname\space == \mph@tempa}%
+ \else
+ \mph@debug{\csname mph@last@#1\endcsname\space != \mph@tempa!}%
+ \global\@mph@warning@true
+ \fi
+}
+\newcommand*\mph@do@warn{%
+ \if@mph@warning@
+ \PackageWarningNoLine{mparhack}{Marginpars may have
+ changed.\MessageBreak Rerun to get them right%
+ }%
+ \fi
+}
+\AtBeginDocument{%
+ \protected@write\@auxout{}{%
+ \string\providecommand\string\mph@setcol[2]{}%
+ }%
+}
+\AtEndDocument{%
+ \let\mph@setcol\mph@check
+ \clearpage
+ \immediate\write\@auxout{%
+ \string\gdef\string\mph@lastpage{\the\c@page}^^J%
+ \string\csname\space mph@do@warn\string\endcsname
+ }%
+}
+\newcommand*\mph@ifundef@or@smaller[1]{%
+ \expandafter\ifx#1\relax
+ \let\mph@tempa\@firstoftwo
+ \else
+ \ifnum#1<\mph@cnt\relax
+ \let\mph@tempa\@firstoftwo
+ \else
+ \let\mph@tempa\@secondoftwo
+ \fi
+ \fi
+ \mph@tempa
+}
+
+\newcommand*\mph@pg@orig{}
+\newcommand*\mph@get@margin{%
+ \begingroup
+ \edef\mph@pg@orig{\the\c@page}
+ \loop
+ \@tempswafalse
+ \mph@debug{--- checking marginpar \mph@cnt}%
+ \if@twocolumn
+ \mph@debug{last on page \thepage:
+ \csname mph@last@i:\thepage\endcsname(i)
+ \csname mph@last@ii:\thepage\endcsname(ii),
+ }%
+ \mph@ifundef@or@smaller{%
+ \csname mph@last@i:\thepage\endcsname
+ }{%
+ \mph@ifundef@or@smaller{%
+ \csname mph@last@ii:\thepage\endcsname
+ }{%
+ \global\@mph@firstcol@true
+ \@tempswatrue
+ \advance\c@page by 1
+ \mph@debug{\mph@cnt\space >
+ \csname mph@last@ii:\thepage\endcsname,
+ incrementing \thepage, set col to i
+ }%
+ }{%
+ \global\@mph@firstcol@false
+ \@tempswafalse
+ \mph@debug{\mph@cnt\space <=
+ \csname mph@last@ii:\thepage\endcsname,
+ exiting loop
+ }%
+ }%
+ }{%
+ \@tempswafalse
+ \global\@mph@firstcol@true
+ \mph@debug{exiting loop}%
+ }%
+ \else
+ \mph@debug{last on page \thepage\space is
+ \csname mph@last@ii:\thepage\endcsname
+ }%
+ \mph@ifundef@or@smaller{%
+ \csname mph@last@ii:\thepage\endcsname
+ }{%
+ \@tempswatrue
+ \advance\c@page by 1
+ \mph@debug{\mph@cnt\space >
+ \csname mph@last@ii:\thepage\endcsname,
+ incrementing page number
+ }%
+ }{%
+ \@tempswafalse
+ \mph@debug{\mph@cnt\space <=
+ \csname mph@last@ii:\thepage\endcsname,
+ exiting loop
+ }%
+ }%
+ \fi
+ \ifnum\mph@lastpage>\c@page
+ \else
+ \@tempswafalse
+ \mph@debug{\c@page >= \mph@lastpage!}%
+ \c@page=\mph@pg@orig
+ \if@firstcolumn
+ \global\@mph@firstcol@true
+ \else
+ \global\@mph@firstcol@false
+ \fi
+ \mph@debug{using original value: \c@page for
+ \string\c@page and exiting loop.
+ }%
+ \fi
+ \if@tempswa
+ \mph@debug{iterating ...}%
+ \repeat
+ \mph@debug{=== marginpar \mph@cnt\space is on page \thepage%
+ \if@twocolumn, col \if@mph@firstcol@ 1 \else 2 \fi\fi
+ }%
+ \protected@xdef\mph@pg@new{\the\c@page}%
+ \endgroup
+}
+
+\newcommand\mph@error[1]{%
+ \PackageError{mparhack}{%
+ Couldn't hook into command `#1'
+ }{%
+ This means that a LaTeX version incompatible with
+ mparhack.sty^^J%
+ has been used. See also the section on `Bugs/Restrictions'^^J%
+ in mparhack.dvi. Please send an email about this bug to^^J%
+ <stefanulrich@users.sourceforge.net>, along with the file `\jobname.log'.
+ }%
+}
+\newcommand\mph@orig@c@page{}
+\newcommand\mph@orig@addmarginpar{}
+\let\mph@orig@addmarginpar\@addmarginpar
+
+\renewcommand\@addmarginpar{%
+ \mph@step@cnt\mph@cnt
+ \protected@write\@auxout{}%
+ {\string\def\string\mph@nr{\mph@cnt}}%
+ \mph@get@margin
+ \def\mph@orig@c@page{\c@page}
+ \c@page=\mph@pg@new
+ \if@mph@firstcol@
+ \@firstcolumntrue
+ \else
+ \@firstcolumnfalse
+ \fi
+ \mph@orig@addmarginpar
+ \c@page=\mph@orig@c@page
+}
+
+\newcommand*\mph@outputpage@hook{%
+ \bgroup
+ \advance\c@page\m@ne
+ \immediate\write\@auxout{%
+ \string\mph@setcol{ii:\thepage}{\string\mph@nr}%
+ }%
+ \egroup
+}
+\g@addto@macro{\@outputpage}{\mph@outputpage@hook}
+
+\newcommand\mph@orig@hb@xt@{}
+\newcommand\mph@orig@outputdblcol{}
+\newcommand\mph@chk@dcl{0}%
+\let\mph@orig@hb@xt@\hb@xt@
+\let\mph@orig@outputdblcol\@outputdblcol
+
+\renewcommand\@outputdblcol{%
+ \def\mph@chk@dcl{0}%
+ \def\hb@xt@##1##2{%
+ \ifx##1\columnwidth
+ \mph@step@cnt\mph@chk@dcl
+ \protected@edef\mph@tempa{%
+ \noexpand\write\noexpand\@auxout{%
+ \noexpand\string\noexpand\mph@setcol{%
+ \romannumeral\mph@chk@dcl:\noexpand\thepage%
+ }{%
+ \noexpand\string\noexpand\mph@nr%
+ }%
+ }%
+ }%
+ \else
+ \def\mph@tempa{}%
+ \fi
+ \mph@orig@hb@xt@##1{##2\mph@tempa}%
+ }%
+ \mph@orig@outputdblcol
+ \def\hb@xt@{\mph@orig@hb@xt@}%
+ \ifnum\mph@chk@dcl=0\relax
+ \else
+ \ifnum\mph@chk@dcl=2\relax
+ \else
+ \mph@error{\string\@outputdblcol}%
+ \fi
+ \fi
+}
+
+\endinput
+%%
+%% End of file `mparhack.sty'.