summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/page-sid.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/page-sid.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/page-sid.mkiv1153
1 files changed, 577 insertions, 576 deletions
diff --git a/Master/texmf-dist/tex/context/base/page-sid.mkiv b/Master/texmf-dist/tex/context/base/page-sid.mkiv
index 9365f7508b5..4a24794eb06 100644
--- a/Master/texmf-dist/tex/context/base/page-sid.mkiv
+++ b/Master/texmf-dist/tex/context/base/page-sid.mkiv
@@ -5,7 +5,7 @@
%D subtitle=Side Floats,
%D author=Hans Hagen,
%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
@@ -15,24 +15,6 @@
\unprotect
-% problem: when too small, side effects; we need to determine the
-% shift earlier so that we can act when shift < size
-%
-% \definefloat[edgefigure]
-% \setupfloat
-% [edgefigure]
-% [rightmargindistance=-\rightmargintotal,
-% leftmargindistance=-\rightmargintotal,
-% default=outer]
-% \starttext
-% \placeedgefigure{}{\framed[width=12cm]{}} \input tufte
-% \placeedgefigure{}{\framed[width=5cm]{}} \input tufte
-% \placeedgefigure{}{\framed[width=4cm]{}} \input tufte
-% \placeedgefigure{}{\framed[width=2cm]{}} \input tufte
-% \stoptext
-
-% todo: dimexpr an dnumexpr
-
% These macro deal with side floats. We started with Daniel
% Comenetz macros as published in TUGBoat Volume 14 (1993),
% No.\ 1: Anchored Figures at Either Margin. I extended and
@@ -40,90 +22,113 @@
% messy module. Therefore, this module badly needs an update
% because it's now a mixture of old and new macros.
-% afhankelijke variabelen
+% Interesting cases where it goes wrong:
%
-% \overgap vervangen door \floatsidetopskip
-% \sidegap vervangen door \floatsideskip
-% \undergap vervangen door \floatsidebottomskip
+% \placefigure[left]{}{} \dorecurse{3}{\input ward } {\par} \input ward
%
-% \prskp vervangen door \ctxparskip
-
-% toegevoegde macro's/aanroepen
-%
-% \logsidefloat : loginformatie
-% \flushsidefloats : nodig voor koppen
-
-% recente wijzigingen:
+% Here we get an unwanted carried over hangindent and parindent. A
+% solution is to associate it with the local par node instead. This
+% is something to discuss with Taco as it could be a new luatex
+% feature: explicitly set par properties.
+
+% Maybe I should just rewrite the lot.
+
+\newdimen \d_page_sides_height % includes the topskip
+\newdimen \d_page_sides_width
+\newdimen \d_page_sides_hsize
+\newdimen \d_page_sides_vsize
+\newdimen \d_page_sides_vsize_reset \d_page_sides_vsize_reset -\onepoint % could be a \let
+\newdimen \d_page_sides_progress
+\newdimen \d_page_sides_page_total
+\newdimen \d_page_sides_saved_depth
+\newdimen \d_page_sides_grid_shift
+
+\newbox \b_page_sides_bottom
+
+\newcount \c_page_sides_lines_done
+\newcount \c_page_sides_checks_done
+\newcount \c_page_sides_n_of_lines
+\newcount \c_page_sides_n_of_hang
+\newconstant \c_page_sides_float_type
+
+\newconditional \c_page_sides_short
+\newconditional \c_page_sides_flag
+
+\newconditional \c_page_sides_r_eq % messy, needs checking anyway
+\newconditional \c_page_sides_l_eq % messy, needs checking anyway
+
+\newdimen \d_page_sides_shift
+\newdimen \d_page_sides_extrashift
+\newdimen \d_page_sided_leftshift
+\newdimen \d_page_sided_rightshift
+\newdimen \d_page_sides_leftskip
+\newdimen \d_page_sides_rightskip
+\newdimen \d_page_sides_maximum
+\newdimen \d_page_sides_topskip
+\newdimen \d_page_sides_bottomskip
+\newdimen \d_page_sides_downshift
+
+\setnewconstant \c_page_sides_align \zerocount
+\setnewconstant \c_page_sides_method \plusone % 0=raw 1=safe (.99) 2=tight (-1pt)
+
+% begin of public variables, this will change
%
-% namen aangepast: \float... enz. i.p.v. \pic
-
-% Pas op: \EveryPar{\EveryPar{}\margetitel{whatever}}
-% \plaatsfiguur[links]{}{} moet goed gaan. In dat geval
-% begint de tekst terecht wat lager.
-
-\newdimen\sidefloatheight % includes the topskip
-\newdimen\sidefloatwidth
-\newdimen\sidefloathsize
-\newdimen\sidefloatshift
-\newdimen\sidefloatextrashift
-\newdimen\sidefloatvsize \def\nofloatvsize{-1pt }
-\newdimen\sidefloatprogress
-\newdimen\sidefloatpagetotal
-
-\newbox\floatbottom
-
-\newcount\sidefloatsidelines
-\newcount\sidefloatlinesdone
-
-% 1 = backspace
-% 2 = leftedge
-% 3 = leftmargin
-% 4 = leftside
-% 5 = rightside
-% 6 = rightmargin
-% 7 = rightedge
-% 8 = cutspace
-
-\newconstant\sidefloattype
-
-\def\backspacefloat {\global\sidefloattype1 \putsidefloat}
-\def\leftedgefloat {\global\sidefloattype2 \putsidefloat}
-\def\leftmarginfloat {\global\sidefloattype3 \putsidefloat}
-\def\leftfloat {\global\sidefloattype4 \putsidefloat}
-\def\rightfloat {\global\sidefloattype5 \putsidefloat}
-\def\rightmarginfloat {\global\sidefloattype6 \putsidefloat}
-\def\rightedgefloat {\global\sidefloattype7 \putsidefloat}
-\def\cutspacefloat {\global\sidefloattype8 \putsidefloat}
-
-\let\marginfloat \cutspacefloat
-
-\newif\ifroomforfloat
-\newif\iffloatshort
-\newif\iffloatflag
-\newif\iffloatrighteqo
-\newif\iffloatlefteqo
-
-\newdimen\sidefloatleftskip
-\newdimen\sidefloatrightskip
-\newdimen\sidefloatmaximum
-
-\def\checksidefloatshift
- {\ifdim\sidefloatmaximum>\zeropoint
- \ifcase\sidefloattype
+% we need a setter and resetter .. or maybe a \placesidefloat[settings] to
+% keep variables separated
+
+\let\sidefloatshift \d_page_sides_shift
+\let\sidefloatextrashift\d_page_sides_extrashift
+\let\sidefloatleftshift \d_page_sided_leftshift
+\let\sidefloatrightshift\d_page_sided_rightshift
+\let\sidefloatleftskip \d_page_sides_leftskip
+\let\sidefloatrightskip \d_page_sides_rightskip
+\let\sidefloatmaximum \d_page_sides_maximum
+\let\sidefloattopskip \d_page_sides_topskip
+\let\sidefloatbottomskip\d_page_sides_bottomskip
+\let\sidefloatdownshift \d_page_sides_downshift
+
+\let\sidefloatsidelines \c_page_sides_n_of_lines
+
+\let\sidefloatalign \c_page_sides_align
+\let\sidefloatmethod \c_page_sides_method
+
+\def\page_sides_process_float_backspace {\global\c_page_sides_float_type\plusone \page_sides_handle_float}
+\def\page_sides_process_float_leftedge {\global\c_page_sides_float_type\plustwo \page_sides_handle_float}
+\def\page_sides_process_float_leftmargin {\global\c_page_sides_float_type\plusthree\page_sides_handle_float}
+\def\page_sides_process_float_left {\global\c_page_sides_float_type\plusfour \page_sides_handle_float}
+\def\page_sides_process_float_right {\global\c_page_sides_float_type\plusfive \page_sides_handle_float}
+\def\page_sides_process_float_rightmargin{\global\c_page_sides_float_type\plussix \page_sides_handle_float}
+\def\page_sides_process_float_rightedge {\global\c_page_sides_float_type\plusseven\page_sides_handle_float}
+\def\page_sides_process_float_cutspace {\global\c_page_sides_float_type\pluseight\page_sides_handle_float}
+\def\page_sides_process_float_margin {\global\c_page_sides_float_type\pluseight\page_sides_handle_float}
+
+\let\logsidefloat \relax
+
+\newif\ifroomforfloat % shared (will change)
+\newif\iftracesidefloats % public (might change)
+
+% end of public variables
+
+\def\page_sides_insert_info
+ {\doinsertfloatinfo}
+
+\def\page_sides_apply_horizontal_shift
+ {\ifdim\d_page_sides_maximum>\zeropoint
+ \ifcase\c_page_sides_float_type
% invalid
\or
% backspace
\or
- \global\sidefloatshift\dimexpr
- -\sidefloatmaximum
+ \global\d_page_sides_shift\dimexpr
+ -\d_page_sides_maximum
-\rightorleftpageaction \leftedgedistance \rightedgedistance
-\rightorleftpageaction \leftmarginwidth \rightmarginwidth
-\rightorleftpageaction \leftmargindistance \rightmargindistance
-\compensatedinnermakeupmargin
\relax
\or
- \global\sidefloatshift\dimexpr
- -\sidefloatmaximum
+ \global\d_page_sides_shift\dimexpr
+ -\d_page_sides_maximum
-\rightorleftpageaction \leftmargindistance \rightmargindistance
-\compensatedinnermakeupmargin
\relax
@@ -132,14 +137,14 @@
\or
% right
\or
- \global\sidefloatshift\dimexpr
- -\sidefloatmaximum
+ \global\d_page_sides_shift\dimexpr
+ -\d_page_sides_maximum
-\rightorleftpageaction \leftmargindistance \rightmargindistance
-\compensatedinnermakeupmargin
\relax
\or
- \global\sidefloatshift\dimexpr
- -\sidefloatmaximum
+ \global\d_page_sides_shift\dimexpr
+ -\d_page_sides_maximum
-\rightorleftpageaction \leftedgedistance \rightedgedistance
-\rightorleftpageaction \leftmarginwidth \rightmarginwidth
-\rightorleftpageaction \leftmargindistance \rightmargindistance
@@ -148,433 +153,444 @@
\or
% cutspace
\fi
+ \fi
+ \ifdim\d_page_sides_shift=\zeropoint \relax
+ \ifnum\c_page_sides_float_type=\plusfour
+ \global\advance\d_page_sides_shift\d_page_sides_extrashift
+ \global\d_page_sides_extrashift\zeropoint
+ \else\ifnum\c_page_sides_float_type=\plusfive
+ \global\advance\d_page_sides_shift\d_page_sides_extrashift
+ \global\d_page_sides_extrashift\zeropoint
+ \fi\fi
+ \else
+ \ifnum\c_page_sides_float_type<\plusfour
+ \global\c_page_sides_float_type\plusfour
+ \else\ifnum\c_page_sides_float_type>\plusfive
+ \global\c_page_sides_float_type\plusfive
+ \fi\fi
\fi}
-\def\setsidefloatskips
- {\global\sidefloatrightskip\zeropoint
- \global\sidefloatleftskip \zeropoint
- \ifcase\sidefloattype
+\def\page_sides_set_skips
+ {\global\d_page_sides_rightskip\zeropoint
+ \global\d_page_sides_leftskip \zeropoint
+ \ifcase\c_page_sides_float_type
\or % backspace
- \global\sidefloatleftskip\dimexpr
+ \global\d_page_sides_leftskip\dimexpr
+\rightorleftpageaction \backspace \cutspace
+\compensatedinnermakeupmargin
\relax
\or % leftedge
- \global\sidefloatleftskip\dimexpr
+ \global\d_page_sides_leftskip\dimexpr
+\rightorleftpageaction \leftmargindistance \rightmargindistance
+\rightorleftpageaction \leftmarginwidth \rightmarginwidth
+\rightorleftpageaction \leftedgedistance \rightedgedistance
+\compensatedinnermakeupmargin
\relax
\or % leftmargin
- \global\sidefloatleftskip\dimexpr
+ \global\d_page_sides_leftskip\dimexpr
+\rightorleftpageaction \leftmargindistance \rightmargindistance
+\compensatedinnermakeupmargin
\relax
\or % leftside
\or % rightside
\or % rightmargin
- \global\sidefloatrightskip\dimexpr
+ \global\d_page_sides_rightskip\dimexpr
+\rightorleftpageaction \rightmargindistance \leftmargindistance
+\compensatedinnermakeupmargin
\relax
\or % rightedge
- \global\sidefloatrightskip\dimexpr
+ \global\d_page_sides_rightskip\dimexpr
+\rightorleftpageaction \rightmargindistance \leftmargindistance
+\rightorleftpageaction \rightmarginwidth \leftmarginwidth
+\rightorleftpageaction \rightedgedistance \leftedgedistance
+\compensatedinnermakeupmargin
\relax
\or % cutspace
- \global\sidefloatrightskip\dimexpr
+ \global\d_page_sides_rightskip\dimexpr
+\rightorleftpageaction \cutspace \backspace
+\compensatedinnermakeupmargin
\relax
\fi
- \ifdim\sidefloatrightskip>\zeropoint \doglobal\advance\sidefloatrightskip\rightskip \fi
- \ifdim\sidefloatleftskip >\zeropoint \doglobal\advance\sidefloatleftskip \leftskip \fi}
-
-% eq is still crap
+ \ifdim\d_page_sides_rightskip>\zeropoint \doglobal\advance\d_page_sides_rightskip\rightskip \fi
+ \ifdim\d_page_sides_leftskip >\zeropoint \doglobal\advance\d_page_sides_leftskip \leftskip \fi}
-\ifx\normalleqno\undefined
-
- \let\floatrighteqo=\eqno
- \let\floatleftleqo=\leqno
-
-\else
-
- \let\floatrighteqo=\normaleqno
- \let\floatleftleqo=\normalleqno
-
-\fi
-
-% Watch it even more! In inner, gaat't mis omdat daar
-% pagetotal enz niet zijn aangepast. Inner kan overigens niet
-% betrouwbaar worden getest!
-
-\newif\iftracesidefloats
-
-\def\flushsidefloats
+\def\page_sides_flush_floats
{\par
- \!!heighta\sidefloatvsize
- \advance\!!heighta -\pagetotal
- \ifnum\!!heighta>\zeropoint
- \global\advance\sidefloatvsize -\sidefloatbottomskip
- \ifdim\!!heighta>\zeropoint
- \bgroup
- \let\flushsidefloats\relax
- \forgetall
- \doloop
- {\strut
- \iftracesidefloats
- \color[darkgray]%
- {\baselinerulefalse
- \boxrulewidth.5\points
- \ruledhbox{\strut\kern\sidefloatwidth}}%
- \fi
- \par
- \!!heighta\sidefloatvsize
- \advance\!!heighta -\pagetotal
- \ifdim\!!heighta>\zeropoint
- \ifnum\recurselevel>\plushundred
- \exitloop
- \fi
- \else
- \exitloop
- \fi}%
- \egroup
- \ifdim\parskip>\zeropoint
- \ifdim\sidefloatbottomskip>\parskip
- \nowhitespace
- \vskip\sidefloatbottomskip
- \fi
- \fi
- \else\ifdim\sidefloatbottomskip>\parskip
- \vskip\sidefloatbottomskip
- \fi\fi
+ \ifnum\dimexpr\d_page_sides_vsize-\pagetotal\relax>\zeropoint
+ \page_sides_flush_floats_indeed
\fi
- % not entirely the same as \forgetsidefloats
- \global\sidefloatvsize\nofloatvsize
- % \global\sidefloatsidelines\zerocount % no, we flush before a side float
- \global\floatshortfalse % so this will get lost
% also here if used at all \global\holdinginserts\zerocount
- \global\floatflagfalse}
+ \global\d_page_sides_vsize\d_page_sides_vsize_reset
+ \global\setfalse\c_page_sides_short
+ \global\setfalse\c_page_sides_flag}
+
+\def\page_sides_flush_floats_indeed
+ {\global\advance\d_page_sides_vsize-\d_page_sides_bottomskip
+ \begingroup
+ \let\page_sides_flush_floats\relax
+ \forgetall
+ \doloop
+ {\strut
+ \iftracesidefloats
+ \color[darkgray]%
+ {\baselinerulefalse
+ \boxrulewidth.5\points
+ \ruledhbox{\strut\kern\d_page_sides_width}}%
+ \fi
+ \par
+ \ifdim\dimexpr\d_page_sides_vsize-\pagetotal\relax>\zeropoint
+ \ifnum\recurselevel>\plushundred % safeguard, sort of deadcycles
+ \exitloop
+ \fi
+ \else
+ \exitloop
+ \fi}%
+ \endgroup
+ \ifdim\parskip>\zeropoint % why this test ?
+ \ifdim\d_page_sides_bottomskip>\parskip
+ \nowhitespace
+ \vskip\d_page_sides_bottomskip
+ \fi
+ \fi}
-\def\dochecksidefloatafterpar
- {\dochecksidefloat
+\def\page_sides_check_floats_after_par
+ {\page_sides_check_floats_indeed
\ifdim\oldpagetotal=\pagetotal \else
- \global\let\checksidefloat\dochecksidefloat
- \flushsidefloats
- \global\sidefloatsidelines\zerocount % here !
+ \global\let\page_sides_check_floats\page_sides_check_floats_indeed
+ \page_sides_flush_floats
+ \global\c_page_sides_n_of_lines\zerocount % here !
\fi}
-\def\flushsidefloatsafterpar
+\unexpanded\def\page_sides_flush_floats_after_par
{\xdef\oldpagetotal{\the\pagetotal}%
- \global\let\checksidefloat\dochecksidefloatafterpar}
+ \global\let\page_sides_check_floats\page_sides_check_floats_after_par}
-\def\forgetsidefloats
- {\global\sidefloatvsize\nofloatvsize
- \global\sidefloatsidelines\zerocount
+\unexpanded\def\page_sides_forget_floats
+ {\global\d_page_sides_vsize\d_page_sides_vsize_reset
+ \global\c_page_sides_n_of_lines\zerocount
% also here if used at all \global\holdinginserts\zerocount
- \global\floatshortfalse
- \global\floatflagfalse}
-
-\let\logsidefloat=\relax
-
-\def\pushpenalties % needed ? and right
- {\widowpenalty\plusone
- \clubpenalty\plustwo
- \brokenpenalty\plusone
- \let\pushpenalties\relax
- \edef\poppenalties
- {\widowpenalty \the\widowpenalty
- \clubpenalty \the\clubpenalty
- \brokenpenalty\the\brokenpenalty
- \let\poppenalties\relax}}
-
-% shouldn;t that be:
+ \global\setfalse\c_page_sides_short
+ \global\setfalse\c_page_sides_flag}
+
+\let\page_otr_sides_pop_penalties \relax
+\let\page_otr_sides_push_penalties\relax
+
+% \def\page_otr_sides_push_penalties % needed ? and right
+% {\widowpenalty\plusone
+% \clubpenalty\plustwo
+% \brokenpenalty\plusone
+% \let\page_otr_sides_push_penalties\relax
+% \edef\page_otr_sides_pop_penalties
+% {\widowpenalty \the\widowpenalty
+% \clubpenalty \the\clubpenalty
+% \brokenpenalty\the\brokenpenalty
+% \let\page_otr_sides_pop_penalties\relax}}
+%
+% shouldn't that be:
%
-% \def\pushpenalties % needed?
-% {\let\pushpenalties\relax
-% \edef\poppenalties
+% \def\page_otr_sides_push_penalties % needed?
+% {\let\page_otr_sides_push_penalties\relax
+% \edef\page_otr_sides_pop_penalties
% {\widowpenalty \the\widowpenalty
% \clubpenalty \the\clubpenalty
% \brokenpenalty\the\brokenpenalty
-% \let\poppenalties\relax}%
+% \let\page_otr_sides_pop_penalties\relax}%
% \widowpenalty\plusone
% \clubpenalty\plustwo
% \brokenpenalty\plusone}
-\let\poppenalties=\relax
-
-\def\restorepenalties
- {\ifnum\outputpenalty=\!!tenthousand\else
+\def\page_sides_restore_output_penalty
+ {\ifnum\outputpenalty=\plustenthousand \else
\penalty\outputpenalty
\fi}
-\def\sidefloatoutput
- {\iffloatshort
- \unvbox\normalpagebox
- \setbox\floatbottom\lastbox
- \ifdim\wd\floatbottom>\sidefloathsize
- \penalty-201
- \box\floatbottom
- \else
- \ifvoid\floatbottom
+\def\page_sides_output_routine
+ {\ifconditional\c_page_sides_short
+ \page_sides_output_routine_yes
+ \else
+ \page_sides_output_routine_nop
+ \fi}
+
+\def\page_sides_output_routine_nop
+ {\page_otr_command_side_float_output % otr specific
+ \global\d_page_sides_vsize\d_page_sides_vsize_reset
+ \global\c_page_sides_n_of_lines\zerocount
+ % we can end up in fig lock, so \global\holdinginserts\zerocount here too ?
+ \page_otr_sides_pop_penalties}
+
+\def\page_sides_output_routine_yes % we need to rework this ... add pagediscards and such
+ {\unvbox\normalpagebox
+ \setbox\b_page_sides_bottom\lastbox
+ \ifdim\wd\b_page_sides_bottom>\d_page_sides_hsize
+ \penalty-201
+ \box\b_page_sides_bottom
+ \else\ifvoid\b_page_sides_bottom
+ \else
+ \page_sides_restore_left_indent
+ \ifdim\wd\b_page_sides_bottom<\d_page_sides_hsize
+ \parskip\zeropoint
+ %\noindent
+ \ifinner\else\vadjust{\penalty\minusone}\fi
+ \ifconditional\c_page_sides_l_eq
+ \global\setfalse\c_page_sides_l_eq
\else
- \restoreleftindent
- \ifdim\wd\floatbottom<\sidefloathsize
- \parskip\zeropoint
- %\noindent
- \ifinner\else\vadjust{\penalty\minusone}\fi
- \iffloatlefteqo
- \global\floatlefteqofalse
- \else
- \global\advance\sidefloathsize -\wd\floatbottom
- \iffloatrighteqo
- \global\floatrighteqofalse
- \else
- \global\divide\sidefloathsize \plustwo
- \fi
- \hskip\sidefloathsize
- \fi
+ \global\advance\d_page_sides_hsize -\wd\b_page_sides_bottom
+ \ifconditional\c_page_sides_r_eq
+ \global\setfalse\c_page_sides_r_eq
+ \else
+ \global\divide\d_page_sides_hsize \plustwo
\fi
- \box\floatbottom
- \restorepenalties
+ \hskip\d_page_sides_hsize % \kern
\fi
\fi
- % why was this \global\holdinginserts\zerocount
- \global\floatshortfalse
- \else
- \finalsidefloatoutput % new
- \global\sidefloatvsize\nofloatvsize
- \global\sidefloatsidelines\zerocount
- % we can end up in fig lock, so \global\holdinginserts\zerocount here too ?
- \poppenalties
- \fi}
-
-\def\finalsidefloatoutput% new
- {\finaloutput\unvbox\normalpagebox}
+ \box\b_page_sides_bottom
+ \page_sides_restore_output_penalty
+ \fi\fi
+ % why was this \global\holdinginserts\zerocount
+ \global\setfalse\c_page_sides_short}
-\def\restoreleftindent
- {\relax \ifnum\sidefloattype>4 \else
+\def\page_sides_restore_left_indent
+ {\relax
+ \ifnum\c_page_sides_float_type>\plusfour \else
\parskip\zeropoint % here ?
- \ifdim\sidefloatwidth>\zeropoint % new, see prikkels
+ \ifdim\d_page_sides_width>\zeropoint % new, see prikkels
\noindent
- \ifinner\else\vadjust{\penalty\minusone}\fi
- \hskip\sidefloatwidth\relax
+ \ifinner \else
+ \vadjust{\penalty\minusone}%
+ \fi
+ \hskip\d_page_sides_width\relax % \kern
%\else
% we have a margin or edge float
\fi
\fi}
-\ifx\normaleqno\undefined
-
- \def\normaleqno
- {\iffloatshort
- \global\floatrighteqotrue
- \fi
- \floatrighteqo}
-
-\else
-
- \def\eqno
- {\iffloatshort
- \global\floatrighteqotrue
- \fi
- \floatrighteqo}
-
-\fi
-
-% externfiguur -> grid =ja|hoogte|diepte|halveregel|passend -> helemaal in details
-% stelplaatsblokin -> zijuitlijnen=hoogte|diepte|regel|halveregel|grid -> halveregel in 'details'
-
-% replacement for below
+% The clean way:
%
-% \global\setbox\floatbox\hbox % no \hskip, but \kern here
-% {\ifcase\sidefloattype
-% \vbox{#1}%
-% \or % 1
-% \hskip\sidefloatleftshift
-% \hskip\sidefloatshift
-% \vbox{#1}%
-% \kern-\sidefloatextrashift
-% \or % 2
-% \hskip\sidefloatshift
-% \vbox{#1}%
-% \kern-\sidefloatextrashift
-% \or % 3
-% \hskip\sidefloatshift
-% \vbox{#1}%
-% \kern-\sidefloatextrashift
-% \or % 4
-% \hskip\sidefloatleftshift
-% \hskip\sidefloatshift
-% \vbox{#1\removedepth}%
-% \kern-\sidefloatextrashift
-% \or % 5
-% \hskip-\sidefloatextrashift
-% \vbox{#1}%
-% \kern\sidefloatshift
-% \kern\sidefloatrightshift
-% \or % 6
-% \hskip-\sidefloatextrashift
-% \vbox{#1}%
-% \kern\sidefloatshift
-% \or % 7
-% \hskip-\sidefloatextrashift
-% \vbox{#1}%
-% \kern\sidefloatshift
-% \or % 8
-% \hskip-\sidefloatextrashift
-% \vbox{#1}%
-% \kern\sidefloatshift
-% \kern\sidefloatrightshift
-% \fi}%
+% \global\setbox\floatbox\hbox
+% {\ifcase\c_page_sides_float_type
+% \vbox{#1}%
+% \or % 1
+% \kern\d_page_sided_leftshift
+% \kern\d_page_sides_shift
+% \vbox{#1}%
+% \kern-\d_page_sides_extrashift
+% \or % 2
+% \kern\d_page_sides_shift
+% \vbox{#1}%
+% \kern-\d_page_sides_extrashift
+% \or % 3
+% \kern\d_page_sides_shift
+% \vbox{#1}%
+% \kern-\d_page_sides_extrashift
+% \or % 4
+% \kern\d_page_sided_leftshift
+% \kern\d_page_sides_shift
+% \vbox{#1\removedepth}%
+% \kern-\d_page_sides_extrashift
+% \or % 5
+% \kern-\d_page_sides_extrashift
+% \vbox{#1}%
+% \kern\d_page_sides_shift
+% \kern\d_page_sided_rightshift
+% \or % 6
+% \kern-\d_page_sides_extrashift
+% \vbox{#1}%
+% \kern\d_page_sides_shift
+% \or % 7
+% \kern-\d_page_sides_extrashift
+% \vbox{#1}%
+% \kern\d_page_sides_shift
+% \or % 8
+% \kern-\d_page_sides_extrashift
+% \vbox{#1}%
+% \kern\d_page_sides_shift
+% \kern\d_page_sided_rightshift
+% \fi}
%
-% keep this ^
-
-\def\repositionsidefloat#1%
- {\global\setbox\floatbox\hbox % no \hskip, but \kern here
- {\ifnum\sidefloattype=\plusfour
- \hskip\sidefloatleftshift
- \else\ifnum\sidefloattype=\plusone
- \hskip\sidefloatleftshift
+% The compact way:
+
+\def\page_sides_relocate_float#1%
+ {\global\setbox\floatbox\hbox
+ {\ifnum\c_page_sides_float_type=\plusfour
+ \kern\d_page_sided_leftshift
+ \else\ifnum\c_page_sides_float_type=\plusone
+ \kern\d_page_sided_leftshift
\fi\fi
- \ifnum\sidefloattype>\plusfour
- \hskip-\sidefloatextrashift
+ \ifnum\c_page_sides_float_type>\plusfour
+ \kern-\d_page_sides_extrashift
\else
- \hskip\sidefloatshift
+ \kern\d_page_sides_shift
\fi
- \vbox{#1\ifnum\sidefloatalign=\plusfour \removedepth\fi}%
- \ifnum\sidefloattype>\plusfour
- \kern\sidefloatshift
+ \vbox{#1\ifnum\c_page_sides_align=\plusfour \removedepth\fi}%
+ \ifnum\c_page_sides_float_type>\plusfour
+ \kern\d_page_sides_shift
\else
- \kern-\sidefloatextrashift
+ \kern-\d_page_sides_extrashift
\fi
- \ifnum\sidefloattype=8
- \kern\sidefloatrightshift
- \else\ifnum\sidefloattype=\plusfive
- \kern\sidefloatrightshift
+ \ifnum\c_page_sides_float_type=\pluseight
+ \kern\d_page_sided_rightshift
+ \else\ifnum\c_page_sides_float_type=\plusfive
+ \kern\d_page_sided_rightshift
\fi\fi}}
-\def\putsidefloat#1% grid (4) is rather experimental
- {\par
- \whitespace
- % moved here dec 2001
- {\everypar\emptytoks\forgetall\verticalstrut\vskip-\struttotal}% moved
- \checksidefloatshift
- \ifdim\sidefloatshift=\zeropoint \relax
- \ifnum\sidefloattype=\plusfour
- \global\advance\sidefloatshift\sidefloatextrashift
- \global\sidefloatextrashift\zeropoint
- \else\ifnum\sidefloattype=\plusfive
- \global\advance\sidefloatshift\sidefloatextrashift
- \global\sidefloatextrashift\zeropoint
- \fi\fi
- \else
- \ifnum\sidefloattype<\plusfour
- \global\sidefloattype\plusfour
- \else\ifnum\sidefloattype>\plusfive
- \global\sidefloattype\plusfive
- \fi\fi
- \fi
- \previoussidefloat
- \stallsidefloat
- \repositionsidefloat{#1}%
- \ifnum\sidefloatalign=\plusfour
+\def\page_sides_apply_vertical_shift
+ {\ifnum\c_page_sides_align=\plusfour
\getnoflines{\ht\floatbox}%
- \scratchdimen\noflines\lineheight
- \advance\scratchdimen-\strutdepth
- \getrawnoflines\sidefloattopskip
+ \scratchdimen\dimexpr\noflines\lineheight-\strutdepth\relax
+ \getrawnoflines\d_page_sides_topskip
\advance\scratchdimen\noflines\lineheight
% todo: maybe rounding problem here
% \global\setbox\floatbox\hbox{\lower\lineheight\box\floatbox}%
\global\setbox\floatbox\hbox{\lower\strutdepth\box\floatbox}%
- \global\ht\floatbox\scratchdimen
- \global\dp\floatbox\zeropoint
+ \ht\floatbox\scratchdimen
+ \dp\floatbox\zeropoint
\fi
- \ifcase\sidefloatalign \else
- \global\sidefloattopskip\zeropoint
+ \ifcase\c_page_sides_align \else
+ \global\d_page_sides_topskip\zeropoint
\fi
\scratchdimen
- \ifnum\sidefloattype<\plusfour
- \sidefloattopskip
- \else\ifnum\sidefloattype>\plusfive
- \sidefloattopskip
+ \ifnum\c_page_sides_float_type<\plusfour
+ \d_page_sides_topskip
+ \else\ifnum\c_page_sides_float_type>\plusfive
+ \d_page_sides_topskip
\else
\zeropoint
\fi\fi
% the top of the box is at the previous baseline
- \ifcase\sidefloatalign
+ \ifcase\c_page_sides_align
% 0 normal
- \advance\scratchdimen\strutdepth % == \sidefloattopoffset
+ \advance\scratchdimen\strutdepth % or \openstrutdepth
\or % 1 height
- \advance\scratchdimen\strutdepth % == \sidefloattopoffset
+ \advance\scratchdimen\strutdepth % or \openstrutdepth
\or % 2 line
\or % 3 depth
- \advance\scratchdimen\lineheight
- \advance\scratchdimen\strutdepth
+ \advance\scratchdimen\lineheight % or \openlineheight
+ \advance\scratchdimen\strutdepth % or \openstrutdepth
\or % 4 grid
\scratchdimen\zeropoint
\or
- \advance\scratchdimen\strutheight
+ \advance\scratchdimen\strutheight % or \openstrutheight
\fi
% new
- \global\sidefloatlinesdone\zerocount
- \ifnum\sidefloatsidelines>\zerocount
- \advance\scratchdimen\sidefloatsidelines\lineheight
+ \global\c_page_sides_lines_done\zerocount
+ \ifnum\c_page_sides_n_of_lines>\zerocount
+ \advance\scratchdimen\c_page_sides_n_of_lines\lineheight
\fi
- % new
- \global\setbox\floatbox\hbox
+ \global\setbox\floatbox\hbox % why extra box
{\vbox
{\vskip\scratchdimen
\nointerlineskip
\box\floatbox
- \ifnum\sidefloatalign=\plusfive \vskip-\lineheight \fi}}%
- \ifnum\sidefloattype<\plusfour
- \global\sidefloattopskip\zeropoint
- \else\ifnum\sidefloattype>\plusfive
- \global\sidefloattopskip\zeropoint
+ \ifnum\c_page_sides_align=\plusfive \vskip-\lineheight \fi}}%
+ \ifnum\c_page_sides_float_type<\plusfour
+ \global\d_page_sides_topskip\zeropoint
+ \else\ifnum\c_page_sides_float_type>\plusfive
+ \global\d_page_sides_topskip\zeropoint
\fi\fi
- \global\sidefloatdownshift\zeropoint
- \measuresidefloat
- \ifroomforfloat \else
- \vfill\eject % inline \tosssidefloat
- \measuresidefloat
- \stallsidefloat
+ \global\d_page_sides_downshift\zeropoint}
+
+\def\page_sides_place_float
+ {\ifnum\c_page_sides_float_type=\plusfour \kern\d_page_sides_topskip \fi
+ \ifnum\c_page_sides_float_type=\plusfive \kern\d_page_sides_topskip \fi
+ \d_page_sides_saved_depth\prevdepth
+ \nointerlineskip
+ \ifgridsnapping
+ \page_sides_place_float_grid
+ \else
+ \page_sides_place_float_normal
+ \fi
+ \par
+ \kern-\d_page_sides_height
+ \penalty10001 % oeps, this will change
+ \normalbaselines
+ \prevdepth\d_page_sides_saved_depth}
+
+\def\page_sides_place_float_normal
+ {\d_page_sides_grid_shift\zeropoint % be nice
+ \page_sides_push_float_inline\firstofoneargument}
+
+% The following needs some more work .. consider this a quick hack. We
+% probably need an mkiv hanging grid option.
+
+\def\page_sides_place_snap_to_grid#1%
+ {\snaptogrid[\v!line,\v!offset:\the\d_page_sides_grid_shift]\hbox{#1}}
+
+% this will be a grid option in float placement:
+
+\newconstant\c_page_sides_place_grid_shift \c_page_sides_place_grid_shift\plustwo
+
+\def\page_sides_place_float_grid
+ {\getrawnoflines\d_page_sides_height % raw ?
+ \d_page_sides_height\noflines\lineheight
+ \d_page_sides_grid_shift\the\dimexpr \plustwo\lineheight
+ \ifcase\c_page_sides_place_grid_shift
+ -3\lineheight % high
+ \or
+ -2.5\lineheight % half (does not work currently)
+ \else
+ -2\lineheight % low
+ \fi
+ \relax
+ \page_sides_push_float_inline\page_sides_place_snap_to_grid}
+
+\def\page_sides_push_float_inline#1%
+ {\begingroup
+ \everypar\emptytoks % needed !
+ \parskip\zeropoint % needed !
+ \page_sides_set_skips
+ \page_sides_insert_info
+ \relax
+ \lefttoright % \textdir TLT\relax % or \ifconditional\displaylefttoright below (more work)
+ \ifcase\c_page_sides_float_type
+ % invalid
+ \or % backspace
+ \noindent#1{\llap{\rlap{\box\floatbox}\kern\d_page_sides_leftskip}}\hfill
+ \or % leftedge
+ \noindent#1{\llap{\box\floatbox\kern\d_page_sides_leftskip}}\hfill
+ \or % leftmargin
+ \noindent#1{\llap{\box\floatbox\kern\d_page_sides_leftskip}}\hfill
+ \or % leftside
+ \noindent#1{\box\floatbox}\hfill
+ \or % rightside
+ \hfill#1{\box\floatbox}%
+ \or % rightmargin
+ \hfill#1{\rlap{\kern\d_page_sides_rightskip\box\floatbox}}%
+ \or % rightedge
+ \hfill#1{\rlap{\kern\d_page_sides_rightskip\box\floatbox}}%
+ \or % cutspace
+ \hfill#1{\rlap{\kern\d_page_sides_rightskip\llap{\box\floatbox}}}%
\fi
- \setsidefloat}
-
-\def\progresssidefloat
- {\sidefloatprogress\sidefloatvsize
- \advance\sidefloatprogress-\iffloatflag\sidefloatpagetotal\global\floatflagfalse\else\pagetotal\fi}
-
-\def\measuresidefloat
- {\global\floatflagtrue
- \global\sidefloatpagetotal \pagetotal % global
- \ifnum\sidefloattype<\plusfour
- \global \sidefloatwidth \zeropoint
- \else\ifnum\sidefloattype>\plusfive
- \global \sidefloatwidth \zeropoint
+ \endgroup}
+
+\def\page_sides_analyse_progress
+ {\d_page_sides_progress\d_page_sides_vsize
+ \ifconditional\c_page_sides_flag
+ \advance\d_page_sides_progress-\d_page_sides_page_total
+ \global\setfalse\c_page_sides_flag
+ \else
+ \advance\d_page_sides_progress-\pagetotal
+ \fi}
+
+\def\page_sides_analyse_space
+ {\global\settrue\c_page_sides_flag
+ \global\d_page_sides_page_total \pagetotal % global
+ \ifnum\c_page_sides_float_type<\plusfour
+ \global\d_page_sides_width \zeropoint
+ \else\ifnum\c_page_sides_float_type>\plusfive
+ \global\d_page_sides_width\zeropoint
\else
- \global \sidefloatwidth \wd\floatbox
- \global\advance\sidefloatwidth \floatsideskip
+ \global\d_page_sides_width\dimexpr\wd\floatbox+\floatsideskip\relax
\fi\fi
- \ifdim\sidefloatwidth<\zeropoint
- \global\sidefloatwidth\zeropoint
+ \ifdim\d_page_sides_width<\zeropoint
+ \global\d_page_sides_width\zeropoint
\fi
- \global \sidefloathsize \hsize
- \global\advance\sidefloathsize -\sidefloatwidth
- \global \sidefloatheight \ht\floatbox
- \global\advance\sidefloatheight \dp\floatbox
- \global\advance\sidefloatheight \sidefloattopskip
- \global \sidefloatvsize \sidefloatheight
- \global\advance\sidefloatvsize \sidefloatpagetotal
- \dimen0\sidefloatvsize
+ \global\d_page_sides_hsize \dimexpr\hsize-\d_page_sides_width\relax
+ \global\d_page_sides_height\dimexpr\ht\floatbox+\dp\floatbox+\d_page_sides_topskip\relax
+ \global\d_page_sides_vsize \dimexpr\d_page_sides_height+\d_page_sides_page_total\relax
+ \dimen0\d_page_sides_vsize
\dimen2\pagegoal
\relax
- \ifcase\sidefloatmethod
+ \ifcase\c_page_sides_method
% method 0 : raw
\or
% method 1 : safe
@@ -587,209 +603,194 @@
\ifdim\dimen0>\dimen2
\global\roomforfloatfalse
\else
- \dimen0=\pagegoal
- \advance\dimen0 -\sidefloatvsize
- \ifdim\dimen0<\sidefloatbottomskip
- \global\advance\sidefloatvsize \dimen0
- \global\floatshorttrue
- \pushpenalties
+ \ifdim\dimexpr\pagegoal-\d_page_sides_vsize\relax<\d_page_sides_bottomskip
+ \global\advance\d_page_sides_vsize \dimen0
+ \global\settrue\c_page_sides_short
+ \page_otr_sides_push_penalties
% why was this \global\holdinginserts\plusone
\else
- \global\advance\sidefloatvsize \sidefloatbottomskip
- \global\floatshortfalse
+ \global\advance\d_page_sides_vsize \d_page_sides_bottomskip
+ \global\setfalse\c_page_sides_short
\fi
\global\roomforfloattrue
\fi}
-\def\setsidefloat% nilling everypar saves time and redudant pos's
- {% removed here dec 2001
- % {\everypar\emptytoks\forgetall\verticalstrut\vskip-\struttotal}%
- \ifnum\sidefloattype=\plusfour \kern\sidefloattopskip \fi
- \ifnum\sidefloattype=\plusfive \kern\sidefloattopskip \fi
- \edef\presidefloatdepth{\the\prevdepth}%
- \nointerlineskip
- \bgroup
+\def\page_sides_prepare_space
+ {\par
+ \whitespace
+ \begingroup
\everypar\emptytoks
- \parskip\zeropoint
- \setsidefloatskips
- \logsidefloat
- \relax
- \ifcase\sidefloattype
- % invalid
- \or % backspace
- \noindent\llap{\rlap{\box\floatbox}\hskip\sidefloatleftskip}\hfill
- \or % leftedge
- \noindent\llap{\box\floatbox\hskip\sidefloatleftskip}\hfill
- \or % leftmargin
- \noindent\llap{\box\floatbox\hskip\sidefloatleftskip}\hfill
- \or % leftside
- \noindent\box\floatbox\hfill
- \or % rightside
- \hfill\box\floatbox
- \or % rightmargin
- \hfill\rlap{\hskip\sidefloatrightskip\box\floatbox}%
- \or % rightedge
- \hfill\rlap{\hskip\sidefloatrightskip\box\floatbox}%
- \or % cutspace
- \hfill\rlap{\hskip\sidefloatrightskip\llap{\box\floatbox}}%
+ \forgetall
+ \verticalstrut
+ \vskip-\struttotal
+ \endgroup}
+
+\def\page_sides_handle_float#1% grid (4) is rather experimental
+ {\page_sides_prepare_space
+ \page_sides_apply_horizontal_shift
+ \page_sides_check_previous_float
+ \page_sides_inject_dummy_lines
+ \page_sides_relocate_float{#1}%
+ \page_sides_apply_vertical_shift
+ \page_sides_analyse_space
+ \ifroomforfloat \else
+ \page_otr_fill_and_eject_page
+ \page_sides_analyse_space
+ \page_sides_inject_dummy_lines
\fi
- \egroup
- \par
-\ifgridsnapping
- \getrawnoflines\sidefloatheight
- \sidefloatheight=\noflines\lineheight
-\fi
- \kern-\sidefloatheight
- \penalty10001 % oeps, this will change
- \normalbaselines
- \prevdepth\presidefloatdepth
- % \noindent
- \resetsidefloatparagraph
+ \page_sides_place_float
+ \page_sides_check_floats_reset
\ignorespaces} % not really needed
-
-\newcount\sidefloatparagraph
-\def\iffirstsidefloatparagraph
- {\ifcase\sidefloatparagraph\or}
+\def\page_sides_check_floats_indeed
+ {\page_sides_analyse_progress
+ \ifdim\d_page_sides_progress>\zeropoint
+ \page_sides_check_floats_set
+ \else
+ \page_sides_check_floats_reset
+ \fi
+ \parskip\s_spac_whitespace_parskip}
-% without sidefloat lines
-%
-% \def\setsidefloatparagraph
-% {%\advance\sidefloatprogress \sidefloatbottomskip
-% %\!!counta\sidefloatprogress
-% \scratchdimen\sidefloatprogress
-% \advance\scratchdimen \strutht
-% \advance\scratchdimen -\roundingeps % new, needed in prikkels, prevent rounding errors
-% \!!counta\scratchdimen
-% \divide\!!counta \baselineskip
-% \ifnum\!!counta>0
-% \hangindent \ifnum\sidefloattype>4 -\fi\sidefloatwidth
-% \hangafter-\!!counta
-% \fi
-% \global\advance\sidefloatparagraph \plusone
-% \iftracesidefloats
-% \hskip-\sidefloatwidth
-% \color[darkgray]%
-% {\vrule\!!height.5\points\!!depth.5\points\!!width\sidefloatwidth
-% %\hskip-.25\bodyfontsize\showstruts\strut\hskip.25\bodyfontsize}%
-% \llap{\showstruts\strut\hskip.25\bodyfontsize}}%
-% \fi}
+\let\page_sides_check_floats\page_sides_check_floats_indeed
-\def\setsidefloatparagraph
- {%\advance\sidefloatprogress \sidefloatbottomskip
- %\!!counta\sidefloatprogress
- \scratchdimen\sidefloatprogress
- \advance\scratchdimen \strutht
- \advance\scratchdimen -\roundingeps % new, needed in prikkels, prevent rounding errors
- \!!counta\scratchdimen
- \divide\!!counta \baselineskip\relax
- \ifnum\!!counta>0
- % new from here
- \ifcase\sidefloatsidelines\else
- \ifcase\sidefloatlinesdone
- \global\sidefloatlinesdone\!!counta
+\def\iffirstsidefloatparagraph
+ {\ifcase\c_page_sides_checks_done\or}
+
+\unexpanded\def\page_sides_check_floats_set
+ {\scratchdimen\dimexpr\d_page_sides_progress+\strutht-\roundingeps\relax
+ \c_page_sides_n_of_hang\scratchdimen
+ \divide\c_page_sides_n_of_hang \baselineskip\relax
+ \ifnum\c_page_sides_n_of_hang>\zerocount
+ % new from here (needs test case, old code)
+ \ifcase\c_page_sides_n_of_lines
+ \else
+ \ifcase\c_page_sides_lines_done
+ \global\c_page_sides_lines_done\c_page_sides_n_of_hang
\else
- \scratchcounter\sidefloatlinesdone
- \advance\scratchcounter-\!!counta
- \global\advance\sidefloatsidelines-\scratchcounter
+ \scratchcounter\c_page_sides_lines_done
+ \advance\scratchcounter-\c_page_sides_n_of_hang
+ \global\advance\c_page_sides_n_of_lines-\scratchcounter
\fi
\fi
- \ifnum\sidefloatsidelines>\zerocount
+ % hm, when do we get the parshape branch? needs testing
+ \ifnum\c_page_sides_n_of_lines>\zerocount
\scratchtoks\emptytoks
- \scratchcounter\sidefloatsidelines
- \scratchdimen\hsize
- \advance\scratchdimen-\sidefloatwidth
- \dorecurse\sidefloatsidelines
+ \scratchcounter\c_page_sides_n_of_lines
+ \scratchdimen\dimexpr\hsize-\d_page_sides_width\relax
+ \dorecurse\c_page_sides_n_of_lines
{\appendtoks \zeropoint \hsize \to \scratchtoks}%
- \ifnum\!!counta>\sidefloatsidelines
- \advance\!!counta -\sidefloatsidelines\relax
- \advance\scratchcounter\!!counta
- \dorecurse\!!counta
- {\ifnum\sidefloattype>\plusfour
- \appendtoks \zeropoint \scratchdimen \to \scratchtoks
+ \ifnum\c_page_sides_n_of_hang>\c_page_sides_n_of_lines
+ \advance\c_page_sides_n_of_hang -\c_page_sides_n_of_lines\relax
+ \advance\scratchcounter\c_page_sides_n_of_hang
+ \dorecurse\c_page_sides_n_of_hang % weird, shouldn't that be scratchcounter
+ {\ifnum\c_page_sides_float_type>\plusfour
+ \appendtoks \zeropoint \scratchdimen \to \scratchtoks
\else
- \appendtoks \sidefloatwidth \scratchdimen \to \scratchtoks
+ \appendtoks \d_page_sides_width\scratchdimen \to \scratchtoks
\fi}%
\fi
- \advance\scratchcounter \plusone
- \parshape \scratchcounter \the\scratchtoks \zeropoint \hsize\relax
+ \parshape
+ \numexpr\scratchcounter+\plusone\relax
+ \the\scratchtoks % \scratchcounter
+ \zeropoint \hsize % \plusone
+ \relax
\else
% new till here
- \hangindent \ifnum\sidefloattype>\plusfour -\fi\sidefloatwidth
- \hangafter-\!!counta
+ \hangindent \ifnum\c_page_sides_float_type>\plusfour -\fi\d_page_sides_width
+ \hangafter-\c_page_sides_n_of_hang
\fi
\fi
- \global\advance\sidefloatparagraph \plusone
+ \global\advance\c_page_sides_checks_done \plusone
\iftracesidefloats
- \hskip-\sidefloatwidth
+ \hskip-\d_page_sides_width % kern
\color[darkgray]%
- {\vrule\!!height.5\points\!!depth.5\points\!!width\sidefloatwidth
- %\hskip-.25\bodyfontsize\showstruts\strut\hskip.25\bodyfontsize}%
- \llap{\showstruts\strut\hskip.25\bodyfontsize}}%
+ {\vrule\!!height.5\points\!!depth.5\points\!!width\d_page_sides_width
+ \llap{\showstruts\strut\kern.25\bodyfontsize}}%
\fi}
-\def\resetsidefloatparagraph
- {\global\sidefloatparagraph\zerocount}
-
-\def\dochecksidefloat
- {\progresssidefloat
- \ifdim\sidefloatprogress>\zeropoint
- \setsidefloatparagraph
- \else
- \resetsidefloatparagraph
- \fi
- \parskip\ctxparskip}
-
-\let\checksidefloat\dochecksidefloat
+\unexpanded\def\page_sides_check_floats_reset
+ {\global\c_page_sides_checks_done\zerocount}
-\def\synchronizesidefloats
- {\ifinner \else \checksidefloat \fi}
-
-\def\doadjustsidefloatdisplaylines
- {\par
- % not in mkiv: \vskip-\parskip
- \noindent
- \ignorespaces}
-
-\def\adjustsidefloatdisplaylines
- {\aftergroup\doadjustsidefloatdisplaylines}
+\unexpanded\def\page_sides_synchronize_floats
+ {\ifinner \else
+ \page_sides_check_floats
+ \fi}
-\def\previoussidefloat
- {\progresssidefloat
- \ifdim\sidefloatprogress>\zeropoint \relax
- \iffloatshort
- \global\floatshortfalse
- \vfill\eject % inline \tosssidefloat
+\unexpanded\def\page_sides_check_previous_float
+ {\page_sides_analyse_progress
+ \ifdim\d_page_sides_progress>\zeropoint \relax
+ \ifconditional\c_page_sides_short
+ \global\setfalse\c_page_sides_short
+ \page_otr_fill_and_eject_page
\else
- \kern\sidefloatprogress
+ \kern\d_page_sides_progress
\fi
\fi}
-\def\stallsidefloat
- {\!!counta\pageshrink
- \divide\!!counta \baselineskip
- \advance\!!counta \plusone
+\def\page_sides_inject_dummy_lines
+ {\scratchcounter\pageshrink
+ \divide\scratchcounter \baselineskip
+ \advance\scratchcounter \plusone
\parskip\zeropoint
- \dorecurse\!!counta{\line{}}%
- \kern-\!!counta\baselineskip
- \penalty\zerocount }
+ \dorecurse\scratchcounter{\hbox to \hsize{}}%
+ \kern-\scratchcounter\baselineskip
+ \penalty\zerocount}
-% We need to hook it into the other otr's. This code will move.
+% Display math
+%
+% If we need this, it will be redone but redefining
+% these macros does not really work out in the current
+% situation.
+%
+% \ifx\normalleqno\undefined
+%
+% \let\floatrighteqo=\eqno
+% \let\floatleftleqo=\leqno
+%
+% \else
+%
+% \let\floatrighteqo=\normaleqno
+% \let\floatleftleqo=\normalleqno
+%
+% \fi
+%
+% \ifx\normaleqno\undefined
+%
+% \def\normaleqno
+% {\ifconditional\c_page_sides_short
+% \global\settrue\c_page_sides_r_eq
+% \fi
+% \floatrighteqo}
+%
+% \else
+%
+% \def\eqno
+% {\ifconditional\c_page_sides_short
+% \global\settrue\c_page_sides_r_eq
+% \fi
+% \floatrighteqo}
+%
+% \fi
-\let\OTRONEflushsidefloats \flushsidefloats
-\let\OTRONEsynchronizesidefloats\synchronizesidefloats
+\def\adjustsidefloatdisplaylines % public, will change
+ {\aftergroup\page_sides_adjust_display_lines}
-% page-set
-%
-% \let\OTRSETflushsidefloats \forgetsidefloats
-% \let\OTRSETsynchronizesidefloats\forgetsidefloats
+\def\page_sides_adjust_display_lines
+ {\par
+ \noindent
+ \ignorespaces}
-% page-mul
-%
-% \let\OTRMULflushsidefloats \forgetsidefloats
-% \let\OTRMULsynchronizesidefloats\forgetsidefloats
+% We need to hook it into the other otr's. This code will be adapted
+% once we rename the callers.
+
+% \def as they can be redefined!
+
+% some will become obsolete
-\registerotrcommand\synchronizesidefloats % \def\synchronizesidefloats{\OTRcommand\synchronizesidefloats}
-\registerotrcommand\flushsidefloats % \def\flushsidefloats {\OTRcommand\flushsidefloats}
+\def\checksidefloat {\page_sides_check_floats}
+%def\flushsidefloats {\page_sides_flush_floats}
+\def\flushsidefloatsafterpar{\page_sides_flush_floats_after_par}
+%def\forgetsidefloats {\page_sides_forget_floats}
+%def\synchronizesidefloats {\page_sides_synchronize_floats}
\protect \endinput