%D \module %D [ file=page-one, %D version=2000.10.20, %D title=\CONTEXT\ Page Macros, %D subtitle=Default Routine, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. \writestatus{loading}{ConTeXt Page Macros / Default Routine} %D This is just the good old \CONTEXT\ output routine, which %D has been there right from the start. \unprotect % OTRONE: basic single column \activateotr{ONE}{} % the default one \newtoks\OTRONEoutput \def\OTRONEgotonextpage {\ejectpage} \def\OTRONEgotonextpageX % will become obsolete {\superejectpage} \def\OTRONEsethsize {\global\hsize\textwidth} \newdimen\oldvsize \def\OTRONEsetvsize {\ifgridsnapping \ifcase\layoutlines \getrawnoflines\textheight \else \noflines\layoutlines \fi \global\vsize\noflines\openlineheight \else \global\vsize\textheight \fi \ifdim\pagegoal<\maxdimen \ifdim\oldvsize=\vsize % let's assume that the layout didn't change \else \bgroup \global\oldvsize\vsize \advance\vsize-\topinserted \advance\vsize-\botinserted \global\pagegoal\vsize \egroup \fi \fi} \chardef\kindofpagetextareas=2 % whole page (public variable! never change) % can we avoind the extra vboxing here? \def\OTRONEregisteredtextarea#1% {\ifregistertextareas \setbox0\vbox{#1}% \wd0\makeupwidth % somehow a space creeps in \vbox{\registeredtextarea000}% \else #1% \fi} % \chardef\kindofpagetextareas\plusone \def\doOTRONEregisteredtextareaA#1% {\ifregistertextareas \xypos{pbd:\realfolio:b}% we could save bytes by only saving the y \endgraf \begingroup \scratchdimen\dimexpr\MPy{pbd:\realfolio:b}-\MPy{pbd:\realfolio:e}\relax \setbox\scratchbox\null \wd\scratchbox\makeupwidth \ht\scratchbox\scratchdimen \vsmash{\registeredtextarea00\scratchbox}% \endgroup #1% \endgraf \xypos{pbd:\realfolio:e}% \else #1% \fi} \def\doOTRONEregisteredtextareaB#1% {\ifregistertextareas \setbox0\vbox{#1}% \wd0\makeupwidth % somehow a space creeps in \vbox{\registeredtextarea000}% \else #1% \fi} \let\OTRONEregisteredtextareaA\firstofoneargument \let\OTRONEregisteredtextareaB\firstofoneargument \def\OTRONEdopagecontents#1#2% \box \unvbox {\bgroup % niet breedte zetten, kan fractie zijn! \ifcase\kindofpagetextareas \or % partial page (experimental) \let\OTRONEregisteredtextareaA\doOTRONEregisteredtextareaA \or % whole page (default) \let\OTRONEregisteredtextareaB\doOTRONEregisteredtextareaB \or % partial page (only works well with no stretch!) \let\OTRONEregisteredtextareaA\doOTRONEregisteredtextareaB \fi \setbox0\vbox \ifbottomnotes to \textheight \fi {\edef\currentpagedepth{\the\dp#2}% still to be derived from #1 \dotopinsertions \ifgridsnapping \OTRONEregisteredtextareaA{#1#2}% \vskip-\currentpagedepth\vskip\openstrutdepth \prevdepth\openstrutdepth \dobotinsertions \vfil \else\ifr@ggedbottom \OTRONEregisteredtextareaA{#1#2}% \vskip-\currentpagedepth\vskip\openstrutdepth \prevdepth\openstrutdepth \dobotinsertions \vfil \else\ifb@selinebottom \OTRONEregisteredtextareaA{#1#2}% \kern-\currentpagedepth\kern\maxdepth \dobotinsertions \else \OTRONEregisteredtextareaA{#1#2}% \dobotinsertions % added \fi\fi\fi \fakepagenotes}% was \fakenotes, but wrong! (check with \setupalign[height]) \ifbottomnotes \ifgridsnapping \ifcase\layoutlines % todo: make macro of this \getrawnoflines\textheight \else \noflines\layoutlines \fi \advance\noflines \minusone \scratchdimen\noflines\lineheight \advance\scratchdimen \topskip \else \scratchdimen\ht0 \fi \else \scratchdimen\zeropoint \fi \setbox2\hbox {\checksinglecolumnfootnotes \lower\scratchdimen\vbox{\placebottomnotes}}% \smashbox2% % needed here \ifbottomnotes \ht0\zeropoint \fi \OTRONEregisteredtextareaB {\vbox to \textheight {\box0\box2\ifbottomnotes\else\vfill\fi}}% \egroup} \def\OTRONEfinalsidefloatoutput {\finaloutput\unvbox\normalpagebox} \OTRONEoutput {\sidefloatoutput} %D Insertions \newif\iftopofinsert \def\OTRONEdosettopinserts {\bgroup \ifsomefloatwaiting \noffloatinserts\zerocount \let\totaltopinserted\!!zeropoint \OTRONEdodosettopinserts \ifnum\@@bknbottom=\zerocount \ifnum\@@bknlines>\zerocount \ifdim\totaltopinserted>\zeropoint\relax \ifdim\dimexpr\@@bknlines\lineheight+\totaltopinserted\relax>\textheight \showmessage\m!floatblocks8\@@bknlines \vfilll\eject \fi \fi \fi \fi \fi \egroup} \def\OTRONEdodosettopinserts {\ifnum\noffloatinserts<\noftopfloats \dogetfloat \ifdim\topinserted=\zeropoint \topofinserttrue \else \topofinsertfalse \fi \global\advance\topinserted\dimexpr\ht\floatbox+\dp\floatbox+\floatbottomskip\relax \ifdim\topinserted<\textheight\relax \xdef\totaltopinserted{\the\topinserted}% \insert\topins {\forgetall \iftopofinsert \topskipcorrection % [xx] new: see icare topbleed \kern-\lineskip\par \prevdepth\maxdimen \else %\blank[-\@@bkspaceafter,\@@bkspacebefore]% inserts can't look back \betweenfloatblanko \fi \flushfloatbox \blank[\@@bkspaceafter]}% \ifsomefloatwaiting \advance\noffloatinserts \plusone \else \noffloatinserts\noftopfloats\relax \fi \dofloatflushedinfo \else \doresavefloat \noffloatinserts\noftopfloats\relax \fi \else \ifsomefloatwaiting \showmessage\m!floatblocks6{\the\noftopfloats}% \fi \let\OTRONEdodosettopinserts\relax \fi \OTRONEdodosettopinserts} \def\OTRONEdosetbotinserts {\bgroup \ifsomefloatwaiting \noffloatinserts\zerocount \OTRONEdodosetbotinserts \fi \egroup} \def\OTRONEdodosetbotinserts {\ifnum\noffloatinserts<\nofbotfloats\relax \dogetfloat \global\advance\botinserted \ht\floatbox\relax \global\advance\botinserted \dp\floatbox\relax \global\advance\botinserted \floattopskip\relax \ifdim\botinserted<\pagegoal\relax \insert\botins {\forgetall \blank[\@@bkspacebefore]% \flushfloatbox}% \ifsomefloatwaiting \advance\noffloatinserts \plusone \else \noffloatinserts\nofbotfloats \fi \dofloatflushedinfo \else \doresavefloat \noffloatinserts\nofbotfloats\relax \fi \global\nofloatpermittedtrue % vgl topfloats s! \else \ifsomefloatwaiting \showmessage\m!floatblocks7{\the\nofbotfloats}% \fi \let\OTRONEdodosetbotinserts\relax \fi \OTRONEdodosetbotinserts} \def\OTRONEdosetbothinserts {\global\topinserted\zeropoint \global\botinserted\zeropoint \ifflushingfloats \else \OTRONEdosettopinserts \OTRONEdosetbotinserts \ifsomefloatwaiting \doif\@@bkcache\v!no\doflushfloats \fi \fi} \chardef\topinserttopskipmode=0 % 1 no topskip \def\OTRONEdotopinsertions {\ifvoid\topins\else \ifgridsnapping \box\topins \vskip-\topskip \vskip\strutheight % [xx] new: see icare topbleed \else \ifcase\topinserttopskipmode % 0: default, do nothing \or % 1: no topskip (crossed fingers) \vskip-\topskip \vskip\strutheight \fi \unvbox\topins \fi \fi \global\topinserted\zeropoint} \def\OTRONEdobotinsertions {\ifvoid\botins\else \ifgridsnapping % \floatparameter\c!bottombefore \snaptogrid\hbox{\box\botins}% % \floatparameter\c!bottomafter \else \floatparameter\c!bottombefore \unvbox\botins \floatparameter\c!bottomafter \fi \fi \global\botinserted\zeropoint \global\nofloatpermittedfalse} \def\OTRONEdoflushfloats {\global\flushingfloatstrue \ifsomefloatwaiting \par % if kept, then option and definitely off in gridmode ! ! ! ! % \ifvmode \prevdepth\maxdimen \fi % prevents whitespace; problematic in icare tests \OTRONEdodoflushfloats \fi \global\savednoffloats\zerocount \global\somefloatwaitingfalse \global\flushingfloatsfalse} \def\OTRONEflushfloatbox % nog verder doorvoeren en meer info in marge {\ifcenterfloatbox \ifdim\wd\floatbox<\hsize \global\setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}% \fi \fi \snaptogrid\hbox{\iftestfloatbox\ruledhbox\fi{\box\floatbox}}} % was copy \def\OTRONEdodoflushfloats % much in common with OTRSET {\ifsomefloatwaiting \ifpackflushedfloats \centerfloatboxfalse % not needed as we do call directly \dofloatscollect{text}{\hsize}{1em}% \OTRONEsetvsize \global\setbox\floatbox\hbox to \hsize {\hfil \dorecurse\nofcollectedfloats {\ifcase\columndirection % nog document wide \dofloatsflush{text}{1}% \else \dofloatsflushn{text}{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}% \fi \ifdim\wd\floatbox>\makeupwidth % \hsize \hbox to \makeupwidth{\hss\box\floatbox\hss}% \else \box\floatbox \fi \ifnum\recurselevel<\nofcollectedfloats \hfil \fi}% \hfil}% \else \dogetfloat \fi % there is a chance that due to rounding errors, the float % fits on a page where it was first rejected, in which case % the prevdepth is -maxdimen and we cannot obey the grid \doplacefloatbox \expandafter\OTRONEdodoflushfloats \fi} \def\OTRONEdocheckiffloatfits % vervangen ivm downward comp {\ifnofloatpermitted \global\roomforfloatfalse \else % new per 31/5/2004, should be an option, only one column mode \begingroup \scratchdimen\dimexpr\pagetotal+\lineheight\relax \ifdim\scratchdimen>\pagegoal \goodbreak % hack ? needed in icare-az \fi % should be an option \endgroup \dimen0\dimexpr\pagetotal+\floatheight+\floattopskip-\pageshrink\relax \dimen2\pagegoal \relax % needed \ifcase\textfloatmethod % method 0 : raw \or % method 1 : safe \dimen2 .99\pagegoal \or % method 2 : tight \advance\dimen0 -\onepoint \fi \relax % really needed ! ! ! ! \ifdim\dimen0>\dimen2 \global\roomforfloatfalse \else \global\roomforfloattrue \fi \fi} \def\OTRONEflushsavedfloats {\dosetbothinserts} % TODO: TEST FIRST, NO CORRECTION NEEDED IN GRID MODE, EVT OPTION \def\OTRONEsomeherefloat[#1]% spacing between two successive must be better {\baselinecorrection % not really needed in grid mode: %\ifgridsnapping \else \baselinecorrection \fi % ! ! ! test test test ! ! ! ! \doplacefloatbox \doinsertfloatinfo \dohandlenextfloatindent} % \def\OTRONEsomefixdfloat % [#1] % {\docheckiffloatfits % \ifroomforfloat\else % \goodbreak % \fi % \showmessage\m!floatblocks9\empty % \someherefloat} % [#1] % % better: % % \dorecurse{50} % {[before normal] \input thuan % \placefigure{normal}{\framed[height=1cm,width=8cm]{}} % \placefigure{normal}{\framed[height=2cm,width=8cm]{}} % [before force] \input thuan % \placefigure[force]{force}{\framed[height=8cm,width=8cm]{}}} \chardef\fixedfloatmethod=3 % \def\OTRONEsomefixdfloat % [#1] % {\docheckiffloatfits % \ifroomforfloat\else % \ifzeropt\pagetotal % % let's assume that there is room % \else % \ifcase\fixedfloatmethod % % disabled % \or % 1 (old method) % \goodbreak % \or % 2 (safe method) % \page % \or % 3 (keeps in stream) % \vskip\textheight % \vskip-\textheight % \or % 4 (also keeps in place) % \dosomebreak\nobreak % \fi % \fi % \fi % \showmessage\m!floatblocks9\empty % \someherefloat} % [#1] \def\OTRONEsomefixdfloat % [#1] {% there is (in mkii) no good way to prevent a break % so better fail than mess, we can get loose from % heads, so be it \showmessage\m!floatblocks9\empty \OTRONEsomeherefloat} % [#1] \def\OTRONEsomesidefloat[#1]% links, rechts NOG TESTEN EN AANPASSEN {\ifinsidecolumns \someelsefloat[\v!here]% \else %\checkwaitingfloats{#1}% \def\logsidefloat {\doinsertfloatinfo}% \setbox\floatbox\vbox{\box\floatbox}% \wd\floatbox\floatwidth \processfirstactioninset [#1] [ \v!left=>\leftfloat {\box\floatbox}, \v!right=>\rightfloat {\box\floatbox}, \v!inleft=>\leftmarginfloat {\box\floatbox}, \v!inright=>\rightmarginfloat{\box\floatbox}, \v!leftmargin=>\leftmarginfloat {\box\floatbox}, \v!rightmargin=>\rightmarginfloat{\box\floatbox}, \v!leftedge=>\leftedgefloat {\box\floatbox}, \v!rightedge=>\rightedgefloat {\box\floatbox}, \v!backspace=>\backspacefloat {\box\floatbox}, \v!cutspace=>\cutspacefloat {\box\floatbox}, \v!inmargin=>\cutspacefloat {\box\floatbox}]% \doifinset\v!tall{#1}\flushsidefloatsafterpar \fi} \def\OTRONEsomepagefloat [#1]{\dofloatssavepagefloat{page} {#1}} \def\OTRONEsomeleftpagefloat [#1]{\dofloatssavepagefloat{leftpage} {#1}} \def\OTRONEsomerightpagefloat[#1]{\dofloatssavepagefloat{rightpage}{#1}} \def\OTRONEsometopsfloat[#1]% {\ifdim\topinserted=\zeropoint \topofinserttrue \else \topofinsertfalse \fi \global\advance\topinserted\dimexpr\ht\floatbox+\dp\floatbox+\floatbottomskip\relax \insert\topins {\forgetall \iftopofinsert \topskipcorrection % [xx] new: see icare topbleed \kern-\lineskip\par\prevdepth\maxdimen \else %\blank[-\@@bkspaceafter,\@@bkspacebefore]% inserts can't look back \betweenfloatblanko \fi \flushfloatbox \blank[\@@bkspaceafter]}% \doinsertfloatinfo} \def\OTRONEsomebotsfloat[#1]% {\global\advance\botinserted\dimexpr\ht\floatbox+\dp\floatbox+\floattopskip\relax \insert\botins {\forgetall \blank[\@@bkspacebefore]% \flushfloatbox}% %\global\nofloatpermittedtrue \doinsertfloatinfo} \def\OTRONEsomefacefloat[#1]% untested {\startopposite\flushfloatbox\stopopposite} \def\OTRONEnextcolumn[#1]% {} \protect \endinput