diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/marginfix/marginfix.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/marginfix/marginfix.sty | 268 |
1 files changed, 268 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/marginfix/marginfix.sty b/Master/texmf-dist/tex/latex/marginfix/marginfix.sty new file mode 100644 index 00000000000..f05168d0661 --- /dev/null +++ b/Master/texmf-dist/tex/latex/marginfix/marginfix.sty @@ -0,0 +1,268 @@ +%% +%% This is file `marginfix.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% marginfix.dtx (with options: `package,debug') +%% +%% IMPORTANT NOTICE: +%% +%% For the copyright see the source file. +%% +%% Any modified versions of this file must be renamed +%% with new filenames distinct from marginfix.sty. +%% +%% For distribution of the original source see the terms +%% for copying and modification in the file marginfix.dtx. +%% +%% This generated file may be distributed as long as the +%% original source files, as listed above, are part of the +%% same distribution. (The sources need not necessarily be +%% in the same archive or directory.) +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{marginfix}% + [2010/08/28 v0.9.1 Fix Margin Paragraphs] +\makeatletter +\chardef\@ight=8 +\chardef\f@ur=4 +\chardef\@c=100 +\def\MFX@debug{\@ifstar\message{\message{^^JMFX:}\message}} +\errorcontextlines=20 +\newif\ifmfx@ypos +\DeclareOption{ypos}{\mfx@ypostrue} +\ProcessOptions\relax +\let\mfx@marginlist\@empty +\newbox\Mfx@marginbox +\newdimen\Mfx@marginboxspace +\newdimen\Mfx@marginpos +\newdimen\Mfx@marginheight +\newdimen\Mfx@mparshift +\newdimen\marginheightadjustment +\newdimen\marginposadjustment +\def\@addmarginpar{% + \@next\@marbox\@currlist{}\MFX@bug +\MFX@debug{addmarginpar (running insert) \@marbox/\@currbox at + \the\c@page:\the\@pageht, marginlist=\meaning\mfx@marginlist}% + \MFX@getypos + \MFX@cons\mfx@marginlist{% TODO: later this will be a run@marginlist + \noexpand\mfx@margin@note\@marbox\@currbox{\mfx@ypos}% (^i.e. for phantoms) + \noexpand\mfx@margin@skip{\the\marginparpush}% + }% +\MFX@debug{addmarginpar (exit): marginlist=\meaning\mfx@marginlist}% +} +\def\MFX@cons#1#2{% + \edef\temp@{#2}% + \expandafter\expandafter\expandafter\gdef + \expandafter\expandafter\expandafter#1% + \expandafter\expandafter\expandafter{\expandafter#1\temp@}% +} + +\def\MFX@snoc#1#2{% + \edef\temp@{#2}% + \expandafter\expandafter\expandafter\gdef + \expandafter\expandafter\expandafter#1% + \expandafter\expandafter\expandafter{\expandafter\temp@#1}% +} +\def\MFX@getypos{% + \edef\mfx@ypos{% + \the\dimexpr\@pageht - \Mfx@strutheight + + \marginposadjustment + \Mfx@mparshift\relax}% + \global\Mfx@mparshift\z@ +} +\newdimen\Mfx@strutheight +\edef\marginpar{% + \unexpanded{\setbox\@tempboxa\hbox{\strut}\Mfx@strutheight\ht\@tempboxa}% + \expandafter\unexpanded\expandafter{\marginpar}% +} +\expandafter\def\expandafter\@combinefloats\expandafter{\expandafter + \MFX@combinefloats@before\@combinefloats} +\def\MFX@combinefloats@before{% + \MFX@buildmargin + \MFX@attachmargin + \Mfx@marginheight\marginheightadjustment +} +\def\MFX@attachmargin{% +\MFX@debug{attachmargin}% + \ifdim\ht\@outputbox<\ht\Mfx@marginbox + \setbox\@outputbox\vbox to \ht\Mfx@marginbox{% + \box\@outputbox + \vfill + }% + \else + \setbox\Mfx@marginbox\vbox to \ht\@outputbox{% + \unvbox\Mfx@marginbox + \vfill + }% + \fi + \setbox\@outputbox\vbox to \ht\@outputbox{% + \hbox to \wd\@outputbox{% + \if\MFX@leftmargin + \llap{\box\Mfx@marginbox\hskip\marginparsep}% + \box\@outputbox + \else + \box\@outputbox + \rlap{\hskip\marginparsep\box\Mfx@marginbox}% + \fi + }}% +} +\def\MFX@buildmargin{% + \advance\Mfx@marginheight\@colroom +\MFX@debug{buildmargin: marginheight=\the\Mfx@marginheight}% + \MFX@buildmargin@down + \MFX@buildmargin@up +} +\def\MFX@buildmargin@down{% +\MFX@debug{buildmargin@down: ENTRY}% +\MFX@debug{marginlist=\meaning\mfx@marginlist}% + \let\mfx@margin@note\MFX@margin@note@down + \let\mfx@margin@skip\@gobble + \let\mfx@margin@clear\MFX@margin@clear@down + \let\mfx@marginout\@empty + \expandafter\global\expandafter\let + \expandafter\mfx@marginlist\expandafter\@empty + \mfx@marginlist +\MFX@debug{buildmargin@down: RETURN}% +\MFX@debug{marginlist=\meaning\mfx@marginlist}% +} +\def\MFX@margin@note@down#1#2#3{% +\MFX@debug{note@down: ENTRY: #1/#2 at #3}% + \ifdim#3>\Mfx@marginpos + \dimen@\dimexpr#3-\Mfx@marginpos\relax +\MFX@debug{note@down: adding compressible \the\dimen@}% + \MFX@snoc\mfx@marginout{\noexpand\mfx@margin@compressible{\the\dimen@}}% + \advance\Mfx@marginpos\the\dimen@ + \fi + \MFX@whichbox#1#2% + \advance\Mfx@marginboxspace\dimexpr\ht\@marbox+\dp\@marbox\relax + \ifdim\Mfx@marginboxspace>\Mfx@marginheight +\MFX@debug{note@down: out of space: + \the\Mfx@marginboxspace>\the\Mfx@marginheight}% + \advance\Mfx@marginboxspace\dimexpr-\ht\@marbox-\dp\@marbox\relax + \mfx@margin@clear + \mfx@margin@note#1#2{#3}% + \else +\MFX@debug{note@down: adding \@marbox + ht \the\ht\@marbox dp \the\dp\@marbox}% + \advance\Mfx@marginpos\dimexpr\ht\@marbox+\dp\@marbox\relax + \MFX@snoc\mfx@marginout{% + \noexpand\mfx@margin@note\@marbox + \noexpand\@cons\noexpand\@freelist#1% + \noexpand\@cons\noexpand\@freelist#2% + }% + \fi + \let\mfx@margin@skip\MFX@margin@skip@down +\MFX@debug{note@down: RETURN space=\the\Mfx@marginboxspace, + pos=\the\Mfx@marginpos}% +} +\def\MFX@whichbox#1#2{% + \if\MFX@leftmargin + \def\@marbox{#1}% + \else + \def\@marbox{#2}% + \fi +\MFX@debug{whichbox: \@marbox}% +} +\def\MFX@margin@skip@down#1{% +\MFX@debug{skip@down #1}% + \advance\Mfx@marginpos#1\relax + \advance\Mfx@marginboxspace#1\relax + \MFX@snoc\mfx@marginout{\noexpand\mfx@margin@skip{#1}}% +} +\def\MFX@margin@clear@down{% +\MFX@debug{clear@down}% + \def\mfx@margin@note##1##2##3{% + \MFX@cons\mfx@marginlist{\noexpand\mfx@margin@note##1##2{\MFX@minus@inf}}}% + \def\mfx@margin@skip##1{% + \MFX@cons\mfx@marginlist{\noexpand\mfx@margin@skip{##1}}}% + \def\mfx@margin@clear{% + \MFX@cons\mfx@marginlist{\noexpand\mfx@margin@clear}}% +} +\def\MFX@minus@inf{-4000pt} +\def\MFX@leftmargin{% + 00\fi % close out the \if + \@tempcnta\@ne + \if@mparswitch + \unless\ifodd\c@page + \@tempcnta\m@ne + \fi + \fi + \if@reversemargin + \@tempcnta-\@tempcnta + \fi +\MFX@debug{margin on \ifnum\@tempcnta<\z@ left\else right\fi}% + \ifnum\@tempcnta<\z@ % start a new \if +} +\def\MFX@buildmargin@up{% +\MFX@debug{buildmargin@up: excess=\the\dimexpr + \Mfx@marginpos-\Mfx@marginheight\relax}% +\MFX@debug{marginout=\meaning\mfx@marginout} + \let\mfx@margin@note\MFX@margin@note@up + \let\mfx@margin@compressible\MFX@margin@skip@gobble@up + \let\mfx@margin@skip\MFX@margin@skip@gobble@up + \mfx@marginout +} +\def\MFX@margin@skip@gobble@up#1{% +\MFX@debug{skip@gobble@up: #1}% + \advance\Mfx@marginpos-#1\relax +} +\def\MFX@margin@note@up#1{% +\MFX@debug{note@up: #1}% + \setbox\Mfx@marginbox\vbox{\box#1\unvbox\Mfx@marginbox}% + \let\mfx@margin@skip\MFX@margin@skip@up + \let\mfx@margin@compressible\MFX@margin@compressible@up +} +\def\MFX@margin@skip@up#1{% +\MFX@debug{skip@up: #1}% + \setbox\Mfx@marginbox\vbox{\vskip#1\relax\unvbox\Mfx@marginbox}% +} +\def\MFX@margin@compressible@up#1{% +\MFX@debug{compressible@up: #1, excess=\the\dimexpr + \Mfx@marginpos-\Mfx@marginheight\relax}% + \dimen@#1\relax + \ifdim\Mfx@marginpos>\Mfx@marginheight + \advance\dimen@\dimexpr\Mfx@marginheight-\Mfx@marginpos\relax + \ifdim\dimen@<\z@ + \dimen@\z@ + \fi + \advance\Mfx@marginpos\dimexpr\dimen@-#1\relax + \fi + \ifdim\dimen@>\z@ + \MFX@margin@skip@up\dimen@ + \fi +} +\def\dumpmargins{% +\MFX@debug{dumpmargins}% + \loop + \unless\ifx\mfx@marginlist\@empty + \let\temp@\mfx@marginlist + \vbox{}\clearpage + \ifx\temp@\mfx@marginlist + \PackageError{marginfix}{lost some margin notes% +: \meaning\mfx@marginlist + }\@eha + \let\mfx@marginlist\@empty % be nicer by just dropping one? + % TODO: also, set an emergency mode to allow oversized notes + \fi + \repeat +} +\AtEndDocument{\dumpmargins} +\def\marginskip#1{% + \MFX@cons\mfx@marginlist{\noexpand\mfx@margin@skip{#1}}% +} +\def\clearmargin{% + \MFX@cons\mfx@marginlist{\noexpand\mfx@margin@clear}% +} +\def\softclearmargin{% + \marginskip{\the\textheight}% +} +\def\extendmargin#1{% + \advance\Mfx@marginheight#1\relax +} +\def\mparshift#1{% + \advance\Mfx@mparshift#1\relax +} +\makeatother +\endinput +%% +%% End of file `marginfix.sty'. |