%D \module %D [ file=page-mis, %D version=2008.11.17, % was part of page-flt.tex / 2000.10.20 %D title=\CONTEXT\ Page Macros, %D subtitle=Misc Float Things, %D author=Hans Hagen, %D date=\currentdate, %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 %C details. \writestatus{loading}{ConTeXt Page Macros / Misc Float Things} \registerctxluafile{page-mis}{1.001} \unprotect \newif\ifmarginblocks \def\dosetupmarginblocks[#1]% {\getparameters[\??mb][#1]% \doifelse\@@mbstate\v!start {\showmessage\m!layouts4\empty \marginblockstrue \let\somenextfloat\dosomenextfloat \let\startmarginblock\dostartmarginblock \let\stopmarginblock\dostopmarginblock}% {\showmessage\m!layouts5\empty \marginblocksfalse \def\somenextfloat[##1]% {\someelsefloat[##1,\v!here]}% \let\startmarginblock\dontstartmargeblok \let\stopmarginblock\dontstopmargeblok}} \unexpanded\def\setupmarginblocks {\dosingleargument\dosetupmarginblocks} \newbox\marginbox \def\dosomenextfloat[#1]% {\global\setbox\marginbox\vbox {\hsize\@@mbwidth \unvcopy\marginbox \ifvoid\marginbox\else\expandafter\@@mbinbetween\fi \box\floatbox\filbreak}% \ifdim\ht\marginbox>\textheight % \dosavefloatinfo \else \doinsertfloatinfo \fi} \newbox\preparedmarginbox \def\reshapemargin {\ifdim\ht\preparedmarginbox>\zeropoint \beginofshapebox \unvbox\preparedmarginbox \endofshapebox \reshapebox {\box\shapebox}% \setbox\preparedmarginbox\vbox to \textheight {\@@mbtop \flushshapebox \@@mbbottom}% \fi} \unexpanded\def\placerightmarginblock {\hskip\rightmarginwidth} \unexpanded\def\placeleftmarginblock {\hskip\leftmarginwidth} \def\checkmarginblocks {\ifvoid\marginbox\else\docheckmarginblocks\fi} \def\docheckmarginblocks % erg inefficient {\setbox\preparedmarginbox\vbox {\forgetall \splittopskip\topskip \ifvoid\marginbox\else \ifdim\ht\marginbox>\textheight \vsplit\marginbox to \textheight \else \unvbox\marginbox \fi \fi}% \reshapemargin \setbox\preparedmarginbox\vbox {\@@mbbefore\box\preparedmarginbox\@@mbafter}% \def\rightmarginbox {\unexpanded\def\placerightmarginblock {\setbox\preparedmarginbox\hbox to \rightmarginwidth {\@@mbleft\box\preparedmarginbox\@@mbright}% \vsmashbox\preparedmarginbox \box\preparedmarginbox}}% \def\leftmarginbox {\unexpanded\def\placeleftmarginblock {\setbox\preparedmarginbox\hbox to \leftmarginwidth {\@@mbright\box\preparedmarginbox\@@mbleft}% \vsmashbox\preparedmarginbox \box\preparedmarginbox}}% \processaction % traag [\@@mblocation] [ \v!inmargin=>\doifbothsidesoverruled\rightmarginbox\rightmarginbox\leftmarginbox, \v!middle=>\doifbothsidesoverruled\rightmarginbox\leftmarginbox\rightmarginbox, \v!left=>\leftmarginbox, \v!right=>\rightmarginbox, \s!unknown=>\setbox\preparedmarginbox\emptyhbox]} \def\dostartmarginblock % 2 maal \vbox ivm \unvbox elders {\global\setbox\marginbox\vtop\bgroup\vbox\bgroup \hsize\@@mbwidth \ifvoid\marginbox\else \unvbox\marginbox \@@mbinbetween \fi \setupalign[\@@mbalign]% \dostartattributes\??mb\c!style\c!color{}% \begstrut\ignorespaces} \def\dostopmarginblock {\unskip\endstrut \dostopattributes \egroup \egroup} \def\dontstartmargeblok {\@@mbbefore \bgroup \dostartattributes\??mb\c!style\c!color\empty} \def\dontstopmargeblok {\dostopattributes \egroup \@@mbafter} \setupmarginblocks [\c!state=\v!start, \c!location=\v!inmargin, \c!width=\rightmarginwidth, \c!style=, \c!color=, \c!align=, \c!left=, \c!right=, \c!top=, \c!inbetween=\blank, \c!bottom=\vfill, \c!before=, \c!after=] % postponing \newevery\everytopofpage\relax \appendtoks \the\everytopofpage \to\everystarttext \appendtoks\global\everytopofpage\emptytoks\to\everystoptext % \startpostponing [pagenumber] [+pageoffset] % % \startpostponing[2] % PAGE 2 \blank % \stoppostponing % % \startpostponing[+1] % PAGE +1 \blank % \stoppostponing % % \startpostponing[+2] % PAGE +2 \blank % \stoppostponing % % \starttext \dorecurse{4}{\input tufte \page} \stoptext %D There is no real need to use \LUA\ here but the bookkeeping %D is somewhat easier and we also can erase buffers easier when %D we keep a local cache, especially as we can flush per page. \newif \ifinpostponing % prevents nesting \newcount\postponed_page_blocks_next_page % set at the lua end \unexpanded\setvalue{\e!start\v!postponing}% {\bgroup \obeylines \doifnextoptionalelse{\egroup\postponed_page_block_start}{\egroup\postponed_page_block_start[0]}} \unexpanded\setvalue{\e!stop\v!postponing}% {\ctxcommand{registerpostponedblock("\currentpostponedpage")}\relax} \def\postponed_page_block_start[#1]% {\edef\currentpostponedpage{#1}% \dostartbuffer[postponedblock][\e!start\v!postponing][\e!stop\v!postponing]} % officially we should flush again after a flush as there can be new future pages % but that will be looked into when we run into it \unexpanded\def\postponed_page_block_flush {\bgroup \inpostponingtrue % for old times sake \global\pagetotal\zeropoint % here? still needed? (was after flush pagefloats) \the\everytopofpage\relax %\flushrestfloats \doflushpagefloats \setnormalcatcodes % postponing in verbatim \restoreglobalbodyfont % otherwise problems inside split verbatim \ctxcommand{flushpostponedblocks()}% \relax \doflushfloats % new but potential dangerous, maybe we need a classification \egroup} % of blocks: with and without flush \def\doflushpostponedblocks {\ifinpostponing % probably a nested flush \else\ifnum\postponed_page_blocks_next_page=\zerocount % nothing in cache \else\ifnum\postponed_page_blocks_next_page<\zerocount % generic cache \postponed_page_block_flush \else\ifnum\postponed_page_blocks_next_page>\realpageno % future content \else % pending content \postponed_page_block_flush \fi\fi\fi\fi} \def\doflushpostponedcontent % called in page-one {\bgroup \setsystemmode\v!postponing \the\everytopofpage %\flushrestfloats \doflushpagefloats \doflushpostponedblocks \egroup} \protect \endinput