|
[Rivet-svn] r2580 - trunk/docblackhole at projects.hepforge.org blackhole at projects.hepforge.orgMon Jul 12 16:52:53 BST 2010
Author: hoeth Date: Mon Jul 12 16:53:03 2010 New Revision: 2580 Log: added mparhack.sty to fix #427 Added: trunk/doc/mparhack.sty Added: trunk/doc/mparhack.sty ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/doc/mparhack.sty Mon Jul 12 16:53:03 2010 (r2580) @@ -0,0 +1,287 @@ +%% +%% 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} + [2005/04/17 v1.4 (T. Sgouros and S. Ulrich)] +\newif\if at mph@firstcol@ +\newif\if at mph@warning@ +\newif\if at debug@ +\newcommand*\mph at debug[2][]{% + \if at debug@ + \typeout{DBG: #2}% + \else + \ifx#1\@empty\else + \typeout{DBG (#1): #2}% + \fi + \fi +} + +\DeclareOption{debug}{% + \newcommand\mph at info{% + \@tempcnta=\mph at cnt + \advance\@tempcnta1 + \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\tiny\the\@tempcnta}}% + }% + \long\def\@xmpar[#1]#2{% + \@savemarbox\@marbox{\mph at info#1}% + \@savemarbox\@currbox{\mph at info#2}% + \@xympar + }% + \long\def\@ympar#1{% + \@savemarbox\@marbox{\mph at info#1}% + \global\setbox\@currbox\copy\@marbox + \@xympar + }% + \global\@debug at true +}% +\ProcessOptions* +\newcommand*\mph at nr{0} +\newcommand*\mph at pg@new{0} +\newcommand*\mph at lastpage{0} +\newcommand*\mph at cnt{0} +\newcommand*\mph at step@cnt[1]{% + \begingroup + \@tempcnta#1 + \advance\@tempcnta\@ne + \protected at xdef#1{\the\@tempcnta}% + \endgroup +} + +\newcommand*\mph at setcol[2]{% + \expandafter\xdef\csname mph at last@#1\endcsname{#2}% +} +\newcommand*\mph at tempa{} +\newcommand*\mph at check[2]{% + \protected at edef\mph at tempa{#2}% + \expandafter\ifx\csname mph at last@#1\endcsname\mph at tempa + \mph at debug{\csname mph at last@#1\endcsname\space == \mph at tempa}% + \else + \mph at debug{\csname mph at last@#1\endcsname\space != \mph at tempa!}% + \global\@mph at warning@true + \fi +} +\newcommand*\mph at do@warn{% + \if at mph@warning@ + \PackageWarningNoLine{mparhack}{Marginpars may have + changed.\MessageBreak Rerun to get them right% + }% + \fi +} +\AtBeginDocument{% + \protected at write\@auxout{}{% + \string\providecommand\string\mph at setcol[2]{}% + }% + \@ifpackageloaded{eso-pic}{% + \let\mph at orig@picture\@picture + \renewcommand\@picture{\let\hb at xt@\mph at orig@hb at xt@\mph at orig@picture}% + }{% + \relax + }% +} +\AtEndDocument{% + \let\mph at setcol\mph at check + \clearpage + \immediate\write\@auxout{% + \string\gdef\string\mph at lastpage{\the\c at page}^^J% + \string\csname\space mph at do@warn\string\endcsname + }% +} +\newcommand*\mph at ifundef@or at smaller[1]{% + \expandafter\ifx#1\relax + \let\mph at tempa\@firstoftwo + \else + \ifnum#1<\mph at cnt\relax + \let\mph at tempa\@firstoftwo + \else + \let\mph at tempa\@secondoftwo + \fi + \fi + \mph at tempa +} + +\newcommand*\mph at pg@orig{} +\newcommand*\mph at get@margin{% + \begingroup + \edef\mph at pg@orig{\the\c at page} + \loop + \@tempswafalse + \mph at debug{--- checking marginpar \mph at cnt}% + \if at twocolumn + \mph at debug{last on page \thepage: + \csname mph at last@i:\thepage\endcsname(i) + \csname mph at last@ii:\thepage\endcsname(ii), + }% + \mph at ifundef@or at smaller{% + \csname mph at last@i:\thepage\endcsname + }{% + \mph at ifundef@or at smaller{% + \csname mph at last@ii:\thepage\endcsname + }{% + \global\@mph at firstcol@true + \@tempswatrue + \advance\c at page by 1 + \mph at debug{\mph at cnt\space > + \csname mph at last@ii:\thepage\endcsname, + incrementing \thepage, set col to i + }% + }{% + \global\@mph at firstcol@false + \@tempswafalse + \mph at debug{\mph at cnt\space <= + \csname mph at last@ii:\thepage\endcsname, + exiting loop + }% + }% + }{% + \@tempswafalse + \global\@mph at firstcol@true + \mph at debug{exiting loop}% + }% + \else + \mph at debug{last on page \thepage\space is + \csname mph at last@ii:\thepage\endcsname + }% + \mph at ifundef@or at smaller{% + \csname mph at last@ii:\thepage\endcsname + }{% + \@tempswatrue + \advance\c at page by 1 + \mph at debug{\mph at cnt\space > + \csname mph at last@ii:\thepage\endcsname, + incrementing page number + }% + }{% + \@tempswafalse + \mph at debug{\mph at cnt\space <= + \csname mph at last@ii:\thepage\endcsname, + exiting loop + }% + }% + \fi + \ifnum\mph at lastpage>\c at page + \else + \@tempswafalse + \mph at debug{\c at page >= \mph at lastpage!}% + \c at page=\mph at pg@orig + \if at firstcolumn + \global\@mph at firstcol@true + \else + \global\@mph at firstcol@false + \fi + \mph at debug{using original value: \c at page for + \string\c at page and exiting loop. + }% + \fi + \if at tempswa + \mph at debug{iterating ...}% + \repeat + \mph at debug{=== marginpar \mph at cnt\space is on page \thepage% + \if at twocolumn, col \if at mph@firstcol@ 1 \else 2 \fi\fi + }% + \protected at xdef\mph at pg@new{\the\c at page}% + \endgroup +} + +\newcommand\mph at 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 at users.sourceforge.net>, along with the file `\jobname.log'. + }% +} +\newcommand\mph at orig@c at page{} +\newcommand\mph at orig@addmarginpar{} +\let\mph at orig@addmarginpar\@addmarginpar + +\renewcommand\@addmarginpar{% + \mph at step@cnt\mph at cnt + \protected at write\@auxout{}% + {\string\def\string\mph at nr{\mph at cnt}}% + \mph at get@margin + \def\mph at orig@c at page{\c at page} + \c at page=\mph at pg@new + \if at mph@firstcol@ + \@firstcolumntrue + \else + \@firstcolumnfalse + \fi + \mph at orig@addmarginpar + \c at page=\mph at orig@c at page +} + +\newcommand*\mph at outputpage@hook{% + \bgroup + \advance\c at page\m at ne + \immediate\write\@auxout{% + \string\mph at setcol{ii:\thepage}{\string\mph at nr}% + }% + \egroup +} +\g at addto@macro{\@outputpage}{\mph at outputpage@hook} + +\newcommand\mph at orig@hb at xt@{} +\newcommand\mph at orig@outputdblcol{} +\newcommand\mph at chk@dcl{0}% +\let\mph at orig@hb at xt@\hb at xt@ +\let\mph at orig@outputdblcol\@outputdblcol + +\renewcommand\@outputdblcol{% + \def\mph at chk@dcl{0}% + \def\hb at xt@##1##2{% + \ifx##1\columnwidth + \mph at step@cnt\mph at chk@dcl + \protected at edef\mph at tempa{% + \noexpand\write\noexpand\@auxout{% + \noexpand\string\noexpand\mph at setcol{% + \romannumeral\mph at chk@dcl:\noexpand\thepage% + }{% + \noexpand\string\noexpand\mph at nr% + }% + }% + }% + \else + \def\mph at tempa{}% + \fi + \mph at orig@hb at xt@##1{##2\mph at tempa}% + }% + \mph at orig@outputdblcol + \def\hb at xt@{\mph at orig@hb at xt@}% + \ifnum\mph at chk@dcl=0\relax + \else + \ifnum\mph at chk@dcl=2\relax + \else + \mph at error{\string\@outputdblcol}% + \fi + \fi +} + +\newcommand\mph at orig@picture{} +\endinput +%% +%% End of file `mparhack.sty'.
More information about the Rivet-svn mailing list |