summaryrefslogtreecommitdiff
path: root/tex/context/base/page-set.tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/page-set.tex')
-rw-r--r--tex/context/base/page-set.tex1488
1 files changed, 1488 insertions, 0 deletions
diff --git a/tex/context/base/page-set.tex b/tex/context/base/page-set.tex
new file mode 100644
index 000000000..560cd6438
--- /dev/null
+++ b/tex/context/base/page-set.tex
@@ -0,0 +1,1488 @@
+%D \module
+%D [ file=page-set,
+%D version=2000.10.20,
+%D title=\CONTEXT\ OTR Macros,
+%D subtitle=Column Sets,
+%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 OTR Macros / Column Sets}
+
+% todo : last longer than previous
+% todo : block span over last column if footnotes
+% todo : diagnosis balancing run
+% todo : separate footnote placement
+% todo : go on on same page with colset
+% todo : test page areas per page
+
+\unprotect
+
+\newcount\tofcolumns % total
+\newcount\lofcolumns % left
+\newcount\rofcolumns % right
+
+\newcount\columnfirstcell \columnfirstcell=1
+\newcount\columnlastcell
+\newcount\columnfreecells
+\newcount\currenthcell
+\newcount\currentvcell
+\newcount\columnhcells
+\newcount\columnvcells
+
+\newif\ifenoughcolumncells
+\newif\ifsomefreecolumncells
+\newif\ifcolumnspread
+\newif\iftracecolumnset % \tracecolumnsettrue
+
+\def\columnmaxcells {75} % runtime
+\def\columnmaxfreecells {0} % runtime
+\def\columngaplimit {0} % {5}
+
+\def\@otr@{otr}
+
+\def\OTRSETgridcell#1#2%
+ {\csname\@otr@:\number#1:\number#2\endcsname}
+
+\def\OTRSETgetgridcell#1#2%
+ {\box\csname\@otr@:\number#1:\number#2\endcsname}
+
+\def\OTRSETsetgridcell#1#2%
+ {\global\setbox\csname\@otr@:\number#1:\number#2\endcsname}
+
+\long\def\OTRSETdoifcellelse#1#2#3#4%
+ {\relax\ifvoid\csname\@otr@:\number#1:\number#2\endcsname#4\else#3\fi}
+
+\beginETEX \ifcsname
+
+\def\columnerasegridboxes%
+ {\bgroup
+ \increment\columnmaxcells
+ \ifodd\realpageno \else % we are on the other page
+ \columnspreadfalse
+ \fi
+ \ifcolumnspread
+ \dorecurse{\nofcolumns}
+ {\let\!!stringa\recurselevel
+ \scratchcounter=\recurselevel \advance\scratchcounter\lofcolumns
+ \edef\!!stringb{\the\scratchcounter}%
+ \dostepwiserecurse{0}{\columnmaxcells}{1}
+ {\ifcsname\@otr@:\!!stringa:\recurselevel\endcsname
+ \global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box
+ \ifcsname\@otr@:\!!stringb:\recurselevel\endcsname
+ \csname\@otr@:\!!stringb:\recurselevel\endcsname
+ %\global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box\csname\@otr@:\!!stringb:\recurselevel\endcsname
+ \else
+ \voidb@x
+ %\global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box\voidb@x
+ \expandafter\newbox\csname\@otr@:\!!stringb:\recurselevel\endcsname
+ \fi
+ \else
+ \expandafter\newbox\csname\@otr@:\!!stringa:\recurselevel\endcsname
+ \ifcsname\@otr@:\!!stringb:\recurselevel\endcsname
+ \global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box\csname\@otr@:\!!stringb:\recurselevel\endcsname
+ \else
+ \expandafter\newbox\csname\@otr@:\!!stringb:\recurselevel\endcsname
+ \fi
+ \fi}}%
+ \else
+ \dorecurse{\tofcolumns}
+ {\let\!!stringa\recurselevel
+ \dostepwiserecurse{0}{\columnmaxcells}{1}
+ {\ifcsname\@otr@:\!!stringa:\recurselevel\endcsname
+ \global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box\voidb@x
+ \else
+ \expandafter\newbox\csname\@otr@:\!!stringa:\recurselevel\endcsname
+ \fi}}%
+ \fi
+ \dorecurse{\tofcolumns}
+ {\global\setbox\csname\@otr@:\recurselevel:\columnmaxcells\endcsname\copy\placeholderboxa}%
+ \global\columnfirstcell=0
+ \global\columnlastcell=\columnfirstcell
+ \global\columnfreecells=\columnfirstcell
+ \egroup}
+
+\endETEX
+
+\beginTEX
+
+\def\columnerasegridboxes%
+ {\bgroup
+ \increment\columnmaxcells
+ \ifodd\realpageno \else % we are on the other page
+ \columnspreadfalse
+ \fi
+ \ifcolumnspread
+ \dorecurse{\nofcolumns}
+ {\let\!!stringa\recurselevel
+ \scratchcounter=\recurselevel \advance\scratchcounter\lofcolumns
+ \edef\!!stringb{\the\scratchcounter}%
+ \dostepwiserecurse{0}{\columnmaxcells}{1}
+ {\expandafter\ifx\csname\@otr@:\!!stringa:\recurselevel\endcsname\relax
+ \expandafter\newbox\csname\@otr@:\!!stringa:\recurselevel\endcsname
+ \expandafter\ifx\csname\@otr@:\!!stringb:\recurselevel\endcsname\relax
+ \expandafter\newbox\csname\@otr@:\!!stringb:\recurselevel\endcsname
+ \else
+ \global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box\csname\@otr@:\!!stringb:\recurselevel\endcsname
+ \fi
+ \else
+ \global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box
+ \expandafter\ifx\csname\@otr@:\!!stringb:\recurselevel\endcsname\relax
+ \voidb@x
+ %\global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box\voidb@x
+ \expandafter\newbox\csname\@otr@:\!!stringb:\recurselevel\endcsname
+ \else
+ \csname\@otr@:\!!stringb:\recurselevel\endcsname
+ %\global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box\csname\@otr@:\!!stringb:\recurselevel\endcsname
+ \fi
+ \fi}}%
+ \else
+ \dorecurse{\tofcolumns}
+ {\let\!!stringa\recurselevel
+ \dostepwiserecurse{0}{\columnmaxcells}{1}
+ {\expandafter\ifx\csname\@otr@:\!!stringa:\recurselevel\endcsname\relax
+ \expandafter\newbox\csname\@otr@:\!!stringa:\recurselevel\endcsname
+ \else
+ \global\setbox\csname\@otr@:\!!stringa:\recurselevel\endcsname\box\voidb@x
+ \fi}}%
+ \fi
+ \dorecurse{\tofcolumns}
+ {\global\setbox\csname\@otr@:\recurselevel:\columnmaxcells\endcsname\copy\placeholderboxa}%
+ \global\columnfirstcell=0
+ \global\columnlastcell=\columnfirstcell
+ \global\columnfreecells=\columnfirstcell
+ \egroup}
+
+\endTEX
+
+\def\doOTRSETsetgridcells#1#2#3#4#5#6% placeholder col row wid hei {data}
+ {\!!countd=#2\advance\!!countd#4\advance\!!countd-1
+ \!!counte=#3\advance\!!counte#5\advance\!!counte-1
+ \dostepwiserecurse{#2}{\!!countd}{1}
+ {\!!countf=\recurselevel
+ \dostepwiserecurse{#3}{\!!counte}{1}
+ {\OTRSETsetgridcell\!!countf\recurselevel#1}}%
+ \dostepwiserecurse{#3}{\!!counte}{1}
+ {\global\wd\OTRSETgridcell{#2}\recurselevel=\hsize}%
+ \OTRSETsetgridcell{#2}\!!counte#6}
+
+\def\OTRSETsetgridcells%
+ {\doOTRSETsetgridcells{\copy\placeholderboxb}}
+
+\def\OTRSETerasegridcells#1#2#3#4%
+ {\doOTRSETsetgridcells{\box\voidb@x}{#1}{#2}{#3}{#4}{\box\voidb@x}}
+
+\def\OTRSETsetfreecells#1#2% col start
+ {\global\columnfirstcell=\ifnum#2=0 1\else#2\fi\relax
+ \ifnum\columnfirstcell>\columnmaxcells
+ \global\columnfreecells=0
+ \global\columnfirstcell=1
+ \global\columnlastcell=0
+ \global\somefreecolumncellsfalse
+ %\message{no cells a}%
+ \else
+ \doloop
+ {\ifnum\columnfirstcell>\columnmaxcells
+ \exitloop
+ \else
+ \OTRSETdoifcellelse{#1}\columnfirstcell
+ {\global\advance\columnfirstcell 1 }
+ {\exitloop}
+ \fi}%
+ \global\columnlastcell=\columnfirstcell
+ \doloop
+ {\ifnum\columnlastcell>\columnmaxcells
+ \exitloop
+ \else
+ \OTRSETdoifcellelse{#1}\columnlastcell
+ {\global\advance\columnlastcell -1 \exitloop}
+ {\global\advance\columnlastcell 1 }
+ \fi}%
+ \ifnum\columnfirstcell>\columnmaxcells
+ \global\columnfreecells=0
+ \global\columnfirstcell=1
+ \global\columnlastcell=0
+ \global\somefreecolumncellsfalse
+ %\message{no cells b}%
+ \else
+ \ifnum\columnlastcell>\columnmaxcells
+ \global\columnlastcell=\columnmaxcells
+ \fi
+ \global\columnfreecells=\columnlastcell
+ \global\advance\columnfreecells -\columnfirstcell
+ \global\advance\columnfreecells 1
+ \global\somefreecolumncellstrue
+ %\message{\number\columnfirstcell-\number\columnlastcell=\number\columnfreecells}%
+ \fi
+ \fi}
+
+\def\OTRSETgetmaxfreecells#1#2% col start
+ {\scratchcounter=0
+ \edef\columnmaxfreecells{0}%
+ \edef\columnfrmfreecells{0}%
+ \dostepwiserecurse{#2}{\columnmaxcells}{1}
+ {\OTRSETdoifcellelse{#1}{\recurselevel}
+ {\ifnum\columnmaxfreecells<\scratchcounter
+ \edef\columnmaxfreecells{\the\scratchcounter}%
+ \let\columnfrmfreecells\recurselevel
+ \fi
+ \scratchcounter=0 }
+ {\advance\scratchcounter 1 }}}
+
+\long\def\OTRSETrecurseRL#1%
+ {\dostepwiserecurse{\nofcolumns}{1}{-1}
+ {#1\hskip\OTRSETgetparameter\c!afstand\recurselevel}}
+
+\def\OTRSETmakegridbox%
+ {\ifcase\columndirection
+ \OTRSETdomakegridbox{1}{\nofcolumns}{+1}%
+ \else
+ \OTRSETdomakegridbox{\nofcolumns}{1}{-1}%
+ \fi}
+
+\def\OTRSETdomakegridbox#1#2#3%
+ {\hbox\bgroup
+ % test first !
+ \hbox to \zetbreedte
+ {\dostepwiserecurse{#1}{#2}{#3}
+ {\mofcolumns=\recurselevel
+ \localcolumnwidth=\OTRSETlocalwidth\mofcolumns
+ \setbox\scratchbox=\hbox\localframed
+ [\??mc\OTRSETidentifier\number\mofcolumns]%
+ [\c!breedte=\localcolumnwidth,\c!hoogte=\teksthoogte]%
+ {}%
+ \ifcase\columndirection
+ \hskip\OTRSETgetparameter\c!afstand\recurselevel\box\scratchbox
+ \else
+ \box\scratchbox\hskip\OTRSETgetparameter\c!afstand\recurselevel
+ \fi}}%
+ \hskip-\zetbreedte
+ % main text
+ \hbox to \zetbreedte
+ {\dostepwiserecurse{#1}{#2}{#3}
+ {\mofcolumns=\recurselevel
+ \localcolumnwidth=\OTRSETlocalwidth\mofcolumns
+ \offinterlineskip
+ \setbox\scratchbox=\vbox to \teksthoogte
+ {\topskipcorrection
+ \dorecurse{\columnmaxcells}
+ {\setbox\scratchbox=\hbox{\OTRSETgetgridcell\mofcolumns\recurselevel}%
+ \ht\scratchbox=\ht\strutbox
+ \dp\scratchbox=\dp\strutbox
+ \ifcase\columndirection
+ \box\scratchbox
+ \else
+ \hbox to \localcolumnwidth
+ {\hskip\localcolumnwidth\llap{\box\scratchbox}}
+ \fi
+ \par}}%
+ \wd\scratchbox=\localcolumnwidth % \tekstbreedte
+ \ifcase\columndirection
+ \hskip\OTRSETgetparameter\c!afstand\recurselevel\box\scratchbox
+ \else
+ \box\scratchbox\hskip\OTRSETgetparameter\c!afstand\recurselevel
+ \fi}}%
+ \egroup}
+
+\def\OTRSETflushfinalfootnotes
+ {\ifcase\lastcolumnlastcell \else
+ \setbox\scratchbox=\hbox
+ {\placefootnotes}%
+ \ifdim\ht\scratchbox>\zeropoint
+ \setbox\scratchbox=\hbox
+ {\hbox to \zeropoint{\OTRSETgetgridcell\nofcolumns\lastcolumnlastcell}%
+ \box\scratchbox}%
+ \ht\scratchbox\ht\strutbox
+ \dp\scratchbox\dp\strutbox
+ \OTRSETsetgridcell\nofcolumns\lastcolumnlastcell\box\scratchbox
+ \fi
+ \global\lastcolumnlastcell=0
+ \fi}
+
+\def\OTRSETdoflush
+ {\ifcollectingcontent
+ \global\mofcolumns=1
+ \else
+ \OTRSETdofinalflush
+ \OTRSETinitializecolumns
+ \OTRSETmanualbalance % or after \gotonextpage
+ %\OTRSETdoflushfloats
+ \OTRSETgotonextpage
+ \fi}
+
+\def\OTRSETdofinalflush % see \OTRSETdoflush
+ {\OTRSETflushfinalfootnotes
+ \placecolumntextareas
+ \OTRSETcentergridcells
+ \setbox\scratchbox=\OTRSETmakegridbox
+ \global\mofcolumns=\nofcolumns % otherwise problems in finaloutput
+ \finaloutput\box\scratchbox}
+
+\let\OTRSETbalancinglist\empty
+
+\appendtoks \OTRSETflushbalancinglist \to \everystoptext
+
+\def\OTRSETflushbalancinglist%
+ {\scratchcounter=0
+ \def\docommando##1%
+ {\advance\scratchcounter 1
+ \immediatewriteutilitycommand
+ {\twopassentry{\s!colset}{\the\scratchcounter}{##1}}}%
+ \processcommacommand[\OTRSETbalancinglist]\docommando}
+
+\definesystemvariable {mc}
+\definesystemvariable {mt}
+\definesystemconstant {colset}
+
+\definetwopasslist\s!colset
+
+\newdimen \OTRSETtextswidth
+\newdimen \OTRSETtextsheight
+\let \OTRSETidentifier=\empty
+
+\newtoks \OTRSEToutput
+
+\def\OTRSETgetparameter#1#2{\getvalue{\??mc\OTRSETidentifier\number#2#1}}
+\def\OTRSETsetparameter#1#2{\setvalue{\??mc\OTRSETidentifier\number#2#1}}
+
+\def\OTRSETsetvsize% snap per sectie (gap here?)
+ {\ifcollectingcontent \else % can be assigndimen
+ \OTRSETcheckinsert % added
+ \OTRSETsetfreecells\mofcolumns\columnfirstcell
+ \ifsomefreecolumncells
+ \global\vsize=\columnfreecells\lineheight
+ %\global\pagegoal=\vsize % niet nodig, tenzij binnen otr
+ \dosynchronizeoutput
+ \allowbreak % hm
+ \fi
+ \ifdim\ht\footins>\zeropoint % updates vsize
+ \insert\footins{\unvbox\footins}
+ \fi
+ \fi}
+
+\def\OTRSETsethsize%
+ {%\OTRSETassignwidth\OTRSETidentifier\to\localcolumnwidth
+ \localcolumnwidth=\OTRSETlocalwidth\mofcolumns
+ \tekstbreedte\localcolumnwidth
+ \hsize\localcolumnwidth}
+
+\def\OTRSETcheckfreelines%
+ {\OTRSETsetvsize}
+
+\def\doOTRSETcolumnseparator%
+ {\hbox to \zeropoint{\hss\red\vl\hss}}
+
+\let\OTRSETcolumnseparator\relax
+
+\def\showbreaks%
+ {\let\OTRSETcolumnseparator\doOTRSETcolumnseparator}
+
+\def\OTRSETnextcolumn%
+ {\ifhmode
+ \bgroup
+ \unskip\unskip\unskip
+ \parfillskip\!!zeropoint
+ \OTRSETcolumnseparator
+ \par
+ \egroup
+ \fi
+ \page\relax
+ \OTRSETsethsize}
+
+\newtoks\OTRSETeverystartofcolumn
+
+\newbox\OTRSETsavedfootnotes
+
+% \installoutput\OTRSETflushtextsofar goes wrong
+
+\def\OTRSETflushtextsofar
+ {\ifvoid\normalpagebox \else
+ \setbox\scratchbox=\vbox{\unvbox\normalpagebox}%
+ \OTRSETsavefootnotes
+ \OTRSEThandleflushedtext0
+ \fi}
+
+\def\OTRSETplacefootnotes
+ {\iflastcolumnfootnotes
+ \ifnum\nofcolumns=\mofcolumns
+ \ifintermediatefootnotes \placefootnotes \fi
+ \fi
+ \else
+ \placefootnotes
+ \fi}
+
+\def\OTRSETflushfootnotes
+ {\ifvoid\OTRSETsavedfootnotes \else
+ \iflastcolumnfootnotes
+ \ifnum\nofcolumns=\mofcolumns
+ \insert\footins{\unvbox\OTRSETsavedfootnotes}%
+ \fi
+ \else
+ \insert\footins{\unvbox\OTRSETsavedfootnotes}%
+ \fi
+ \fi}
+
+\def\OTRSETsavefootnotes
+ {\iflastcolumnfootnotes
+ \ifnum\nofcolumns=\mofcolumns
+ \else
+ \global\setbox\OTRSETsavedfootnotes=\vbox
+ {\unvbox\OTRSETsavedfootnotes\box\footins}%
+ \fi
+ \fi}
+
+\appendtoks \OTRSETflushfootnotes \to \OTRSETeverystartofcolumn
+
+\def\OTRSETnaturalflush%
+ {\setbox0=\vbox to \columnfreecells\lineheight
+ {\vskip-\topskip
+ \vskip\lineheight
+ \prevdepth\dp\strutbox
+ \unvbox\normalpagebox
+ \vfill}
+ \setbox2=\hbox
+ {\OTRSETplacefootnotes}
+ \setbox\scratchbox=\hbox
+ {\wd0=\!!zeropoint\box0\box2}
+ \dp\scratchbox=\dp\strutbox
+ \OTRSEThandleflushedtext1}
+
+\newcount\lastcolumnlastcell
+
+\def\OTRSEThandleflushedtext#1%
+ {\getnoflines{\ht\scratchbox}%
+ \wd\scratchbox=\hsize
+ \doOTRSETsetgridcells
+ {\copy\placeholderboxf}
+ {\mofcolumns}{\columnfirstcell}{1}{\noflines}
+ {\copy\scratchbox}% \box
+ \global\columnlastcell=\columnfirstcell
+ \global\advance\columnlastcell \noflines
+\global\lastcolumnlastcell\columnlastcell
+\global\advance\lastcolumnlastcell -1
+ % find next (acceptable) gap, todo: deadcycle
+\ifcase#1\else
+ \OTRSETfillgapsbetweencells\mofcolumns\columnlastcell
+\fi
+ \OTRSETfindnextgap
+ %\message{\the\mofcolumns,\the\columnfirstcell,\the\columnfreecells}\wait
+ \OTRSETsethsize
+ \OTRSETsetvsize}
+
+\def\OTRSETfindnextgap%
+ {\OTRSETsetfreecells\mofcolumns\columnlastcell
+ \ifsomefreecolumncells
+ % okay
+ \else
+ \global\advance\mofcolumns 1 \relax
+ \ifnum\mofcolumns>\nofcolumns
+ \OTRSETdoflush
+ \global\columnlastcell=1
+ \global\columnfirstcell=0
+ \OTRSETdoflushfloats
+ \else
+ \the\OTRSETeverystartofcolumn
+ \global\columnlastcell=1
+ \global\columnfirstcell=0
+ \fi
+ \fi}
+
+\def\OTRSETcheckfreelines{}
+
+\def\OTRSETfillgapsbetweencells#1#2% col
+ {\ifnum\columngaplimit>0
+ \donefalse
+ \dostepwiserecurse{#2}{\columnmaxcells}{1}
+ {\OTRSETdoifcellelse{#1}{\recurselevel}
+ {\ifdone
+ \!!countb=\recurselevel \advance\!!countb -\!!counta\relax
+ \ifnum\!!countb>1
+ \advance\!!countb -1
+ \ifnum\!!countb<\columngaplimit\relax
+ \!!countb=\recurselevel \advance\!!countb -1
+ \dostepwiserecurse{\!!counta}{\!!countb}{1}
+ {\OTRSETsetgridcell{#1}\recurselevel\copy\placeholderboxc}%
+ %\message{[gap]}%
+ \fi
+ \fi
+ \fi
+ \donefalse}
+ {\ifdone \else
+ \donetrue
+ \!!counta=\recurselevel
+ \fi}}%
+ \fi}
+
+\appendtoks
+ \OTRSETfillgapsbetweencells\mofcolumns1
+\to \OTRSETeverystartofcolumn
+
+%\def\OTRSETfreezeminimumgap#1%
+% {\OTRSETgetmaxfreecells{#1}{1}%
+% \ifnum\columnmaxfreecells>0
+% \!!countb=\columnfrmfreecells
+% \!!counta=\!!counta \advance\!!counta -\columnmaxfreecells
+% \dorecurse{\columnmaxcells}
+% {\ifnum\recurselevel<\!!counta\relax
+% \donetrue
+% \else\ifnum\recurselevel>\!!countb
+% \donetrue
+% \else
+% \donefalse
+% \fi\fi
+% \ifdone
+% \OTRSETdoifcellelse{#1}{\recurselevel}
+% {}{\OTRSETsetgridcell{#1}\recurselevel\copy\placeholderboxc}%
+% \fi}%
+% \fi}
+%
+%\def\OTRSETfillgaps#1#2#3% col from to
+% {\dostepwiserecurse{#2}{#3}{1}
+% {\OTRSETdoifcellelse{#1}{\recurselevel}
+% {}{\OTRSETsetgridcell{#1}\recurselevel\copy\placeholderboxc}}}
+%
+%\def\OTRSETfillbotgaps#1#2% col first
+% {\OTRSETfillgaps{#1}{#2}{\columnmaxcells}}
+%
+%\def\OTRSETfilltopgaps#1#2% col last
+% {\OTRSETfillgaps{#1}{1}{#2}}
+
+\newif\ifspancolumnslots \spancolumnslotstrue
+
+\def\OTRSETcheckcolumnslot#1%
+ {\enoughcolumncellstrue
+ \ifspancolumnslots \else \ifdim\wd#1>\hsize
+ \enoughcolumncellsfalse
+ \fi \fi
+ \ifenoughcolumncells
+ \getnoflines\pagetotal
+ \scratchcounter=\noflines
+ \getnoflines{\ht#1}%
+ \columnvcells=\noflines
+ \columnhcells=1
+ \advance\scratchcounter \columnvcells \relax
+ \ifnum\scratchcounter>\columnfreecells
+ \enoughcolumncellsfalse
+ \fi
+ \fi}
+
+\def\OTRSETstoreincolumnslotPAGE#1%
+ {\ifenoughcolumncells
+ % to do
+ \OTRSETsavebox{#1}%
+ \else
+ \OTRSETsavebox{#1}%
+ \fi}
+
+\def\OTRSETstoreincolumnslotHERE%
+ {\OTRSETflushtextsofar\OTRSETstoreincolumnslotTOPS}
+
+\def\OTRSETstoreincolumnslotTOPS#1%
+ {\OTRSETcheckcolumnslot{#1}%
+ \ifenoughcolumncells
+ \OTRSETcheckcolumnspace\mofcolumns\columnfirstcell{#1}%
+ \fi
+ \ifenoughcolumncells
+ \OTRSETsetgridcells\mofcolumns\columnfirstcell\columnhcells\columnvcells
+ {\hbox{\copy#1}}
+ \OTRSETsetvsize
+ \else
+ \OTRSETsavebox{#1}%
+ \fi}
+
+\def\OTRSETstoreincolumnslotBOTS#1%
+ {\edef\savedcolumnlastcell{\the\columnlastcell}%
+ \OTRSETcheckcolumnslot{#1}%
+ \ifenoughcolumncells
+ \advance\columnlastcell -\columnvcells \advance\columnlastcell 1
+% \OTRSETcheckcolumnspace\mofcolumns\columnfirstcell{#1}%
+ \OTRSETcheckcolumnspace\mofcolumns\columnlastcell{#1}%
+ \fi
+ \ifenoughcolumncells
+ \OTRSETsetgridcells\mofcolumns\columnlastcell\columnhcells\columnvcells
+ {\copy#1}
+ \OTRSETfillgapsbetweencells\mofcolumns\savedcolumnlastcell % -)
+ \OTRSETsetvsize
+ \else
+ \columnlastcell=\savedcolumnlastcell
+ \OTRSETsavebox{#1}%
+ \fi}
+
+\newdimen\totalcolumnspace
+
+\def\columnspacetopoffset{0}
+\def\columnspacebotoffset{0}
+
+\def\OTRSETcheckcolumnspace#1#2#3% col row box
+ {\columnhcells=1
+ \totalcolumnspace=\!!zeropoint
+ \scratchcounter=#1%
+ \enoughcolumncellstrue
+ \doloop
+% {\advance\totalcolumnspace \hsize
+ {\advance\totalcolumnspace \OTRSETlocalwidth\scratchcounter\relax % needed
+ \ifnum\wd#3>\totalcolumnspace\relax
+ \ifnum\scratchcounter=\nofcolumns
+ \enoughcolumncellsfalse
+ \exitloop
+ \else
+ \advance\columnhcells 1
+ \advance\scratchcounter 1
+ \advance\totalcolumnspace \OTRSETgetparameter\c!afstand\scratchcounter
+ \fi
+ \else
+ \exitloop
+ \fi}%
+ \ifenoughcolumncells
+ \getnoflines{\ht#3}%
+ \columnvcells=\noflines
+ \OTRSETcheckcolumncells{#1}{#2}\columnhcells\columnvcells
+ \fi}
+
+\def\OTRSETcheckcolumncells#1#2#3#4% col row wid hei
+ {\!!countd=#1\advance\!!countd#3\advance\!!countd-1\relax
+ \!!counte=#2\advance\!!counte#4\advance\!!counte-1\relax
+ \ifnum\!!counte>\columnmaxcells\relax
+ \enoughcolumncellsfalse
+ \else
+ \enoughcolumncellstrue
+%\def\columnspacetopoffset{0}%
+%\scratchcounter=#2\advance\scratchcounter-1\relax
+%\ifnum\scratchcounter>0
+% \dostepwiserecurse{#1}{\!!countd}{1}
+% {\ifdim\wd\OTRSETgridcell\recurselevel\scratchcounter>\!!zeropoint
+% \def\columnspacetopoffset{1}%
+% \else\ifdim\dp\OTRSETgridcell\recurselevel\scratchcounter>\!!zeropoint
+% \def\columnspacetopoffset{1}%
+% \fi\fi}%
+% \advance\!!counte \columnspacetopoffset \relax
+% \advance\columnvcells \columnspacetopoffset \relax
+%\fi
+%\def\columnspacebotoffset{0}%
+%\scratchcounter=\!!counte
+%\advance\scratchcounter \columnvcells \relax
+%\ifnum\scratchcounter>\columnmaxcells\else
+% \dostepwiserecurse{#1}{\!!countd}{1}
+% {\ifdim\wd\OTRSETgridcell\recurselevel\scratchcounter>\!!zeropoint
+% \def\columnspacebotoffset{1}%
+% \else\ifdim\dp\OTRSETgridcell\recurselevel\scratchcounter>\!!zeropoint
+% \def\columnspacebotoffset{1}%
+% \fi\fi}%
+% \advance\!!counte \columnspacebotoffset \relax
+% \advance\columnvcells \columnspacebotoffset \relax
+%\fi
+ \dostepwiserecurse{#1}{\!!countd}{1} % cols
+ {\ifenoughcolumncells
+ \!!countf=\recurselevel\relax
+ \dostepwiserecurse{#2}{\!!counte}{1} % rows
+ {\ifenoughcolumncells
+ \OTRSETdoifcellelse\!!countf\recurselevel
+ {\enoughcolumncellsfalse}{}%
+ \fi}%
+ \fi}%
+ \fi}
+
+\def\OTRSETsetpreferedcolumnslot#1%
+ {\doifsomething{#1}{\edef\preferedcolumn{#1}}}
+
+\OTRSETsetpreferedcolumnslot{\nofcolumns} % default ?
+
+\let\pofcolumns\mofcolumns
+\let\qofcolumns\mofcolumns
+
+\newif\ifquitincurrentcolumn
+
+\def\OTRSETstoreincolumnslotFXTB% fixed column
+ {\OTRSETstoreincolumnslotindeed
+ \pofcolumns\pofcolumns+\currenthcell1\columnmaxcells+\currentvcell}
+
+\def\OTRSETstoreincolumnslotFXBT% fixed column
+ {\OTRSETstoreincolumnslotindeed
+ \pofcolumns\pofcolumns+\currenthcell\columnmaxcells1-\currentvcell}
+
+\def\OTRSETstoreincolumnslotLRTB%
+ {\OTRSETstoreincolumnslotindeed
+ \mofcolumns\nofcolumns+\currenthcell1\columnmaxcells+\currentvcell}
+
+\def\OTRSETstoreincolumnslotLRBT%
+ {\OTRSETstoreincolumnslotindeed
+ \mofcolumns\nofcolumns+\currenthcell\columnmaxcells1-\currentvcell}
+
+\def\OTRSETstoreincolumnslotRLTB%
+ {\OTRSETstoreincolumnslotindeed
+ \nofcolumns\qofcolumns-\currenthcell1\columnmaxcells+\currentvcell}
+
+\def\OTRSETstoreincolumnslotRLBT%
+ {\OTRSETstoreincolumnslotindeed
+ \nofcolumns\qofcolumns-\currenthcell\columnmaxcells1-\currentvcell}
+
+\def\OTRSETstoreincolumnslotTBLR%
+ {\OTRSETstoreincolumnslotindeed
+ 1\columnmaxcells+\currentvcell\mofcolumns\nofcolumns+\currenthcell}
+
+\def\OTRSETstoreincolumnslotTBRL%
+ {\OTRSETstoreincolumnslotindeed
+ 1\columnmaxcells+\currentvcell\nofcolumns\qofcolumns-\currenthcell}
+
+\def\OTRSETstoreincolumnslotBTLR%
+ {\OTRSETstoreincolumnslotindeed
+ \columnmaxcells1-\currentvcell\mofcolumns\nofcolumns+\currenthcell}
+
+\def\OTRSETstoreincolumnslotBTRL%
+ {\OTRSETstoreincolumnslotindeed
+ \columnmaxcells1-\currentvcell\nofcolumns\qofcolumns-\currenthcell}
+
+\def\OTRSETstoreincolumnslotindeed#1#2#3#4#5#6#7#8#9%
+ {\OTRSETflushtextsofar
+ \ifnum\preferedcolumn<\mofcolumns
+ \let\pofcolumns\mofcolumns
+ \else
+ \let\pofcolumns\preferedcolumn
+ \fi
+ \ifquitincurrentcolumn
+ \ifnum\mofcolumns=\nofcolumns
+ \def\qofcolumns{\mofcolumns}%
+ \else
+ \scratchcounter=\mofcolumns
+ \advance\scratchcounter 1
+ \edef\qofcolumns{\the\scratchcounter}%
+ \fi
+ \else
+ \let\qofcolumns=\mofcolumns
+ \fi
+ \enoughcolumncellsfalse
+ \donefalse
+ \dostepwiserecurse{#1}{#2}{#31}
+ {\ifdone\else
+ #4=\recurselevel
+ \dostepwiserecurse{#5}{#6}{#71}
+ {\ifdone\else
+ #8=\recurselevel
+ \OTRSETcheckcolumnspace\currenthcell\currentvcell{#9}%
+ \ifenoughcolumncells \donetrue \fi
+ \fi}%
+ \fi}%
+ \ifdone
+ \enoughcolumncellstrue
+ \else
+ \enoughcolumncellsfalse
+ \fi
+ \ifenoughcolumncells
+% \ifnum\columnspacetopoffset>0\message{[+++]}\fi
+% \ifnum\columnspacebotoffset>0\message{[---]}\fi
+% \OTRSETsetgridcells\currenthcell\currentvcell\columnhcells\columnvcells
+% {\vbox
+% {\ifcase\columnspacetopoffset\else\ruledvskip\columnspacetopoffset\lineheight\fi
+% \copy#9
+% \ifcase\columnspacebotoffset\else\ruledvskip\columnspacebotoffset\lineheight\fi}}%
+ \OTRSETsetgridcells\currenthcell\currentvcell\columnhcells\columnvcells
+ {\copy#9}%
+ \ifnum\currenthcell=\mofcolumns\relax
+ \ifdim\ht\OTRSETsavedfootnotes>\zeropoint % \footins
+ \OTRSETsetfreecells\mofcolumns\columnfirstcell
+ \ifsomefreecolumncells
+ \getnoflines{\ht\OTRSETsavedfootnotes}% \footins
+ \ifnum\columnfreecells<\noflines
+ \global\somefreecolumncellsfalse
+ \else
+ %\message{[flt]}% float
+ \fi
+ \fi
+ \ifsomefreecolumncells
+ % ok, enough room for notes
+ %\message{[flt]}% float
+ \else % ?
+ \OTRSETsavebox{#9}%
+ \OTRSETerasegridcells\currenthcell\currentvcell\columnhcells\columnvcells
+ %\message{[clr]}% save box
+ \fi
+ \else
+ %\message{[flt]}% float
+ \fi
+ \else
+ %\message{[flt]}% float
+ \fi
+ \OTRSETsetvsize
+ %\message{[fnt]}% float
+ %\OTRSETflushfootnotes % not here, better a hook into \everypar
+ \else
+ %\message{[rej]}% save box
+ \OTRSETsavebox{#9}%
+ \fi}
+
+% \appendtoks \OTRSETflushfootnotes \to \everypar
+
+\def\columnslotspacing{2}
+
+\def\OTRSETstoreincolumnslot#1#2% {method} {box} % alleen last
+ {\dp#2=\!!zeropoint
+ \ifcase\columnslotspacing\else
+ \setbox#2=\vbox spread \columnslotspacing\lineheight
+ {\vss\box#2\vss}
+ \fi
+%\dp#2=\!!zeropoint
+ \doifdefinedelse{\strippedcsname\OTRSETstoreincolumnslot#1}
+ {\getvalue{\strippedcsname\OTRSETstoreincolumnslot#1}{#2}}
+ {\copy#2}}
+
+%\def\OTRSETsavebox#1%
+% {\setbox\floatbox=\box#1\dosavefloat}
+
+\def\OTRSETsavebox#1% clean up the skips
+ {\setbox\scratchbox=\vbox
+ {\unvbox#1\unskip\unskip\unskip
+ \global\setbox\floatbox\lastbox
+ }%\unskip\unskip\unskip\box\floatbox}%
+ \dosavefloat}
+
+\def\OTRSETflushfloatbox% nog verder doorvoeren en meer info in marge
+ {\iftestfloatbox\ruledhbox\fi{\box\floatbox}}
+
+\def\OTRSETdoflushfloats%
+ {\bgroup
+ \def\OTRSETsavebox##1{\!!doneafalse}%
+ \doloop
+ {\ifsomefloatwaiting
+ \dogetfloat
+ \ifdim\wd\floatbox>\zeropoint
+ \!!doneatrue
+ \dp\floatbox=\!!zeropoint
+ \OTRSETstoreincolumnslot{TBLR}\floatbox
+ \if!!donea
+ %\message{[flu]}%
+ \else
+ \doresavefloat
+ \exitloop
+ \fi
+ \else
+ %\message{[err]}% happens but why?
+ \fi
+ \else
+ \exitloop
+ \fi}
+ \egroup}
+
+\newif\ifcentergridcells \centergridcellstrue
+
+\def\OTRSETcentergridcells%
+ {\ifcentergridcells
+ \dorecurse{\nofcolumns}
+ {\currenthcell=\recurselevel
+ \dorecurse{\columnmaxcells}
+ {\currentvcell=\recurselevel\relax
+ \ifdim\ht\OTRSETgridcell\currenthcell\currentvcell>\zeropoint
+ \ifdim\dp\OTRSETgridcell\currenthcell\currentvcell=\zeropoint
+ \bgroup
+ \setbox\scratchbox=\OTRSETgetgridcell\currenthcell\currentvcell
+ \getnoflines{\ht\scratchbox}%
+ \!!counta=\currentvcell
+ \advance\!!counta -\noflines
+ \advance\!!counta 1
+ % first col always ok
+ \!!countb=\currenthcell
+ \!!countc=\currenthcell \advance\!!countc 1
+ \!!donebtrue
+ \dostepwiserecurse{\!!countc}{\nofcolumns}{1}
+ {\if!!doneb
+ \let\xrecurselevel\recurselevel
+ \dostepwiserecurse{\!!counta}{\currentvcell}{1}
+ {\ifdim\ht\OTRSETgridcell\xrecurselevel\recurselevel>\zeropoint
+ \!!donebfalse
+ \else\ifdim\wd\OTRSETgridcell\xrecurselevel\recurselevel>\zeropoint
+ \!!donebfalse
+ \fi\fi}%
+ \if!!doneb
+ \!!countb=\xrecurselevel
+ \fi
+ \fi}%
+% \totalcolumnspace=\hsize
+\totalcolumnspace=\OTRSETlocalwidth\currenthcell
+ \dostepwiserecurse{\!!countc}{\!!countb}{1}
+% {\advance\totalcolumnspace \hsize\relax
+{\advance\totalcolumnspace \OTRSETlocalwidth\recurselevel
+ \advance\totalcolumnspace \OTRSETgetparameter\c!afstand\recurselevel}%
+ \ifdim\totalcolumnspace>\wd\scratchbox
+ \setbox\scratchbox=\hbox to \totalcolumnspace{\hss\box\scratchbox\hss}%
+ % \wd\scratchbox=\hsize
+ \fi
+ \OTRSETsetgridcell\currenthcell\currentvcell\box\scratchbox
+ \egroup
+ \fi
+ \fi}}%
+ \fi}
+
+\def\OTRSETinitializecolumns%
+ {\columnspreadtrue % todo
+ \ifcolumnspread
+ \global\rofcolumns=\getvalue{\??mc\OTRSETidentifier\c!nrechts}
+ \global\lofcolumns=\getvalue{\??mc\OTRSETidentifier\c!nlinks}
+ \global\tofcolumns=\rofcolumns \relax
+ \ifodd\realpageno\relax
+ \global\nofcolumns=\rofcolumns
+ \else
+ \global\advance\tofcolumns\lofcolumns
+ \global\nofcolumns=\lofcolumns
+ \fi
+ \else
+ \global\nofcolumns=\getvalue{\??mc\OTRSETidentifier\c!n}
+ \global\rofcolumns=\nofcolumns
+ \global\lofcolumns=\nofcolumns
+ \global\tofcolumns=\nofcolumns
+ \fi
+\OTRSETassignwidths
+ \global\mofcolumns=1
+ \columnerasegridboxes
+ \initializecolumntextareas}
+
+% vanaf hier:
+
+\def\definecolumnset%
+ {\dodoubleargument\dodefinecolumnset}
+
+\def\dodefinecolumnset[#1][#2]%
+ {\getparameters[\??mc#1]
+ [\c!richting=\v!rechts,
+ \c!n=2,
+ \c!breedte=\v!passend,
+ \c!balanceren=\v!nee,
+ \c!afstand=1.5\bodyfontsize, % controleren
+ \c!nlinks=\getvalue{\??mc#1\c!n},
+ \c!nrechts=\getvalue{\??mc#1\c!n},
+ #2]%
+ \dorecurse{\getvalue{\??mc#1\c!nlinks}} % todo
+ {\dododefinecolumnset[#1][\recurselevel]}%
+ \dorecurse{\getvalue{\??mc#1\c!nrechts}} % todo
+ {\dododefinecolumnset[#1][\recurselevel]}%
+ \setupcolumnset[#1][1][\c!afstand=\!!zeropoint]}
+
+\def\dododefinecolumnset[#1][#2]%
+ {\presetlocalframed
+ [\??mc#1#2]%
+ \setupcolumnset
+ [#1][#2]
+ [\c!offset=\v!overlay,
+ \c!kader=\v!uit,
+ \c!uitlijnen=,
+ \c!afstand=1.5\bodyfontsize]}
+
+\def\setupcolumnset%
+ {\dotripleargument\dosetupcolumnset}
+
+\def\dosetupcolumnset[#1][#2][#3]%
+ {\ifthirdargument
+ \def\docommando##1%
+ {\doifelse{##1}{\v!elk}
+ {\dorecurse{\getvalue{\??mc#1\c!n}}{\docommando{\recurselevel}}}
+ {\getparameters[\??mc#1##1][#3]}}%
+ \processcommalist[#2]\docommando
+ \else
+ \getparameters[\??mc#1][#2]%
+ \fi}
+
+\def\OTRSETgotocolumn%
+ {\dosingleempty\doOTRSETgotocolumn}
+
+\def\doOTRSETgotocolumn[#1]% first|last|yes|<number>
+ {\doifnumberelse{#1}
+ {\OTRSETdummycolumn
+ \doloop
+ {\ifnum\mofcolumns<#1
+ \OTRSETdummycolumn
+ \else
+ \exitloop
+ \fi}}
+ {\processaction
+ [#1]
+ [ \v!ja=>\OTRSETdummycolumn,
+ \v!eerste=>{\doOTRSETgotocolumn[1]},
+ \v!laatste=>{\doOTRSETgotocolumn[\nofcolumns]},
+ \v!default=>\OTRSETdummycolumn]}}
+
+\def\OTRSETdummycolumn
+ {\vbox{\strut}
+ \vskip-\lineheight
+ \vfill
+ \eject}
+
+\newcounter\columnsetlevel
+\let\currentcolumnset\empty
+
+\def\startcolumnset%
+ {\dodoubleempty\dostartcolumnset}
+
+\def\dostartcolumnset[#1][#2]%
+ {\increment\columnsetlevel\relax
+ \ifnum\columnsetlevel=1
+ \OTRSETgetmanualbalance
+ \edef\savedfootnotedimen{\the\dimen\footins}% ugly
+ \bgroup
+ \def\currentcolumnset{#2}%
+ \binnenkolommentrue % will be different flag
+ %\let\redofloatorder\gobbleoneargument % will also be a flag
+ \let\kolom\OTRSETgotocolumn%
+ \activateotr{SET}{ONE} % andere naam, activate or so
+ \xdef\OTRSETlist{#1}
+ \OTRSETgotonextpage
+ \OTRSETassignwidths
+ \else
+ \bgroup
+ \fi}
+
+\def\stopcolumnset%
+ {\ifnum\columnsetlevel=1
+ \par
+ \OTRSETsetmanualbalance
+ \dostopcolumnset
+ \egroup
+ \global\footnotelimittrue
+ \dimen\footins\savedfootnotedimen % ugly
+ \ifsomefloatwaiting \setvsize \pagina \setvsize \fi
+ \else
+ \egroup
+ \fi
+ \decrement\columnsetlevel\relax}
+
+\def\dostopcolumnset%
+ {%\OTRSETdofinalflushfloats % yes/no
+ \ifbalancecolumns
+ \OTRSETdobalance
+ \else
+ \OTRSETnobalance
+ \fi}
+
+\def\OTRSETdobalance
+ {\OTRSETnobalance}
+
+\def\OTRSETmanualbalance
+ {\ifbalancecolumns
+ \ifnum\realpageno=\balancingpageno\relax
+ \ifnum\mofcolumns=1
+ \dorecurse\nofcolumns
+ {\!!counta=\recurselevel
+ \!!countb=\balancingcolumnmaxcells\!!counta
+ \advance\!!countb 1
+ \dostepwiserecurse\!!countb\columnmaxcells1
+ {\OTRSETsetgridcell\!!counta\recurselevel\copy\placeholderboxe}}%
+ \fi
+ \fi
+ \fi}
+
+\def\balancingcolumnmaxcells#1%
+ {\ifcsname\??mc\currentcolumnset\number#1\c!regels\endcsname
+ \csname\??mc\currentcolumnset\number#1\c!regels\endcsname
+ \else\ifcsname\??mc\currentcolumnset\c!regels\endcsname
+ \csname\??mc\currentcolumnset\c!regels\endcsname
+ \else
+ \savedcolumnmaxcells
+ \fi\fi}
+
+\def\OTRSETsetmanualbalance
+ {\doglobal\addtocommalist{\realfolio}\OTRSETbalancinglist}
+
+\def\OTRSETgetmanualbalance
+ {\gettwopassdata\s!colset
+ \iftwopassdatafound
+ \global\let\balancingpageno\twopassdata
+ \else
+ \doglobal\newcounter\balancingpageno
+ \fi
+ \global\balancingcolumnsfalse}
+
+
+\def\OTRSETnobalance
+ {\iflastcolumnfootnotes % testen ! optie
+ % inhibit flush of floats !
+ \dostepwiserecurse{\mofcolumns}{\nofcolumns}{1}
+ {\vskip-\lineheight\vbox{\strut}\vfill\eject}%
+ \else
+ \ifdim\pagetotal>\zeropoint
+ \vfill \eject \OTRSETdofinalflush
+ \fi
+ \fi}
+
+\def\OTRSETgotonextpage%
+ {\doifsomething{\OTRSETlist}
+ {\getfromcommacommand[\OTRSETlist][1]%
+ \global\let\OTRSETidentifier\commalistelement
+ \let\newcommalistelement\empty
+ \doglobal\replaceincommalist\OTRSETlist1%
+ \OTRSETrestart}}
+
+\def\OTRSETrestart% % weed
+ {\OTRSETinitializefeatures
+ \OTRSETflushpreposttext
+ \OTRSETinitializecolumns
+ \OTRSETcheckinsert
+ \OTRSETcheckgrid
+ \OTRSETsetvsize
+ \OTRSETsethsize
+ \OTRSETsetplaceholders
+ \OTRSEThandlepreposttext
+ \OTRSETsetvsize}
+
+\OTRSEToutput
+ {\OTRSETnaturalflush
+% \OTRSETgotonextpage
+ \OTRSETcheckfreelines
+ \OTRSETchecksidefloat}
+
+\def\OTRSETinitializefeatures%
+ {% number of lines
+ \getnoflines\teksthoogte\xdef\columnmaxcells{\the\noflines}
+ % direction
+ \doifelsevalue{\??mc\OTRSETidentifier\c!richting}{\v!rechts}
+ {\chardef\columndirection=0}
+ {\chardef\columndirection=1}
+ % balancing
+ \doifelsevalue{\??mc\OTRSETidentifier\c!balanceren}{\v!ja}
+ {\balancecolumnstrue}
+ {\balancecolumnsfalse}}
+
+\installoutput\OTRSETflushpreposttext
+ {\global\setbox\precolumnbox=\vbox{\unvbox\normalpagebox}%
+ \ifcarryoverfootnotes \else
+ \global\setbox\postcolumnbox=\vbox{\placefootnotes}%
+ \fi}
+
+\def\OTRSEThandlepreposttext%
+ {\getnoflines{\ht\precolumnbox}
+ \doOTRSETsetgridcells
+ {\copy\placeholderboxe}
+ 11\nofcolumns\noflines
+ {\box\precolumnbox}
+ \getnoflines{\ht\postcolumnbox}
+ \advance\columnfreecells -\noflines
+ \advance\columnfreecells 1
+ \doOTRSETsetgridcells
+ {\copy\placeholderboxe}
+ 1\columnfreecells\nofcolumns\noflines
+ {\box\postcolumnbox}}
+
+\def\OTRSETchecksidefloat%
+ {} % {\sidefloatoutput}
+
+\def\OTRSETfinalsidefloatoutput%
+ {}
+
+\def\OTRSETcheckgrid%
+ {\topskip=1\topskip
+ \ifforcecolumngrid
+ \widowpenalty=0
+ \clubpenalty=0
+ \brokenpenalty=0
+ \fi}
+
+\def\OTRSETcheckinsert%
+ {\iflastcolumnfootnotes
+ \ifnum\nofcolumns=\mofcolumns
+ \OTRSETforceinserts
+ \else
+ \OTRSETinhibitinserts
+ \fi
+ \else
+ \OTRSETforceinserts
+ \fi}
+
+\def\OTRSETforceinserts%
+ {\global\count\footins=1000
+ \global\skip\footins=1\baselineskip\relax}% plus 4\baselineskip\relax }
+
+\def\OTRSETinhibitinserts%
+ {\global\count\footins=0
+ \global\skip\footins=\!!zeropoint}
+
+% interface to footnotes
+
+%\def\OTRSETassignwidth#1\to#2%
+% {\doifelsevalue{\??mc#1\c!breedte}{\v!passend}
+% {#2=\zetbreedte
+% \scratchcounter=\getvalue{\??mc#1\c!nlinks}\relax
+%\ifnum\getvalue{\??mc#1\c!nrechts}>\scratchcounter
+% \scratchcounter=\getvalue{\??mc#1\c!nrechts}%
+%\fi
+% \dorecurse{\scratchcounter}
+% {\advance#2 -\getvalue{\??mc#1\recurselevel\c!afstand}}%
+% \divide#2 \scratchcounter}
+% {#2=\getvalue{\??mc#1\c!breedte}}}
+
+%\def\OTRSETassignwidth#1\to#2% assumes mofcolumns
+% {\doifelsevalue{\??mc#1\number\mofcolumns\c!breedte}{\v!passend}
+% {#2=\zetbreedte
+% \scratchcounter=0
+% \dorecurse{\getvalue{\??mc#1\c!n}}
+% {\doifelsevalue{\??mc#1\number\recurselevel\c!breedte}{\v!passend}
+% {\advance\scratchcounter by 1 }
+% {\advance#2 by -\getvalue{\??mc#1\recurselevel\c!breedte}}%
+% \advance#2 by -\getvalue{\??mc#1\recurselevel\c!afstand}}%
+% \divide#2 by \scratchcounter}
+% {#2=\getvalue{\??mc#1\number\mofcolumns\c!breedte}}}
+%
+% replaced by
+%
+%\def\OTRSETassignwidth#1\to#2% assumes mofcolumns
+% {#2=\OTRSETlocalwidth\mofcolumns}
+
+\def\OTRSETassignwidths%
+ {\scratchdimen=\zetbreedte
+ \scratchcounter=0
+ \dorecurse\nofcolumns
+ {\doifelsevalue{\??mc\OTRSETidentifier\recurselevel\c!breedte}{\v!passend}
+ {\advance\scratchcounter by 1 }
+ {\advance\scratchdimen by -\getvalue{\??mc\OTRSETidentifier\recurselevel\c!breedte}}%
+ \advance\scratchdimen by -\getvalue{\??mc\OTRSETidentifier\recurselevel\c!afstand}}%
+ \divide\scratchdimen by \scratchcounter
+ \dorecurse\nofcolumns
+ {\doifelsevalue{\??mc\OTRSETidentifier\recurselevel\c!breedte}{\v!passend}
+ {\dimen0=\scratchdimen}
+ {\dimen0=\getvalue{\??mc\OTRSETidentifier\recurselevel\c!breedte}}%
+ \setxvalue{\??mc\recurselevel\??mc\c!breedte}{\the\dimen0}}}
+
+\def\OTRSETlocalwidth#1%
+ {\getvalue{\??mc\number#1\??mc\c!breedte}}
+
+\def\OTRSETsetfootnotehsize%
+ {%\ifcarryoverfootnotes
+ % \doifdefinedelse{\??mc\@@vnbreedte\c!n} % inherits from columnset
+ % {\OTRSETassignwidth\@@vnbreedte\to\hsize}
+ % {\hsize\@@vnbreedte}%
+ }%\fi}
+
+\newbox\placeholderboxa
+\newbox\placeholderboxb
+\newbox\placeholderboxc
+\newbox\placeholderboxd
+\newbox\placeholderboxe
+\newbox\placeholderboxf
+
+\def\columnplaceholder#1#2%
+ {\hbox
+ {\localcolortrue
+ \setbox\scratchbox\hbox to \hsize
+ {\iftracecolumnset
+ #2\hskip-.5ex\vrule\!!width1ex\!!height.5ex\!!depth.5ex\hss
+ \fi
+ \hss}%
+ \ifcase#1\relax
+ \ht\scratchbox\!!zeropoint
+ \dp\scratchbox\!!zeropoint
+ \wd\scratchbox\!!zeropoint
+ \else
+ \wd\scratchbox\hsize
+ \ht\scratchbox\ht\strutbox
+ \dp\scratchbox\dp\strutbox
+ \fi
+ \box\scratchbox}}
+
+\def\OTRSETsetplaceholders%
+ {\global\setbox\placeholderboxa\columnplaceholder0\cyan
+ \global\setbox\placeholderboxb\columnplaceholder0\green
+ \global\setbox\placeholderboxc\columnplaceholder0\blue
+ \global\setbox\placeholderboxd\columnplaceholder0\red
+ \global\setbox\placeholderboxe\columnplaceholder0\magenta
+ \global\setbox\placeholderboxf\columnplaceholder1\darkgray}
+
+\def\OTRSETshowstatus
+ {\iftracecolumnset
+ \llap{\tt\tfxx\blue(\number\columnfirstcell\#\number\columnfreecells)}%
+ \fi}
+
+\appendtoks \OTRSETshowstatus \to \everypar
+
+% page contents
+
+\def\OTRSETdopagecontents#1#2% takes two args: \box<n> \unvbox<n>
+ {\vbox to \teksthoogte
+ {\forgetall#1#2\pushcolor}}
+
+\def\OTRSETsomepagefloat {\def\floatmethod{PAGE}\OTRSETsomeslotfloat} % check
+\def\OTRSETsomeherefloat {\def\floatmethod{HERE}\OTRSETsomeslotfloat} % check
+\def\OTRSETsomeelsefloat {\def\floatmethod{HERE}\OTRSETsomeslotfloat} % check
+\def\OTRSETsometopfloat {\def\floatmethod{TOPS}\OTRSETsomeslotfloat} % check
+\def\OTRSETsomebottomfloat{\def\floatmethod{BOTS}\OTRSETsomeslotfloat} % check
+
+\def\OTRONEsomeslotfloat {\let\floatmethod\v!hier\OTRONEsomeelsefloat}
+
+\def\OTRSETflushfloatbox% nog verder doorvoeren en meer info in marge
+ {\iftestfloatbox\ruledhbox\fi{\box\floatbox}}
+
+\def\OTRSETsomeslotfloat[#1]%
+ {\setbox\floatbox=\vbox{\flushfloatbox}%
+ \dp\floatbox=\dp\strutbox
+ \@EA\uppercasestring\floatmethod\to\floatmethod
+ \OTRSETstoreincolumnslot\floatmethod\floatbox
+ \doinsertfloatinfo}
+
+% \def\definecolumnsetarea%
+% {\doquadrupleempty\dodefinecolumnsetarea}
+%
+% \def\dodefinecolumnsetarea[#1][#2][#3][#4]% test top n source
+% {\ifsecondargument
+% \doifundefinedelse{#4box}
+% {\@EA\newbox\csname#4box\endcsname}
+% {\@EA\setbox\csname#4box\endcsname=\box\voidb@x}%
+% \setvalue{\??mc#1#2\v!tekst#3}{\OTRSETflusharea{#1}{#2}{#3}}%
+% \setxvalue{#1#2#3source}{#4}%
+% \setgvalue{#4setup}%
+% {\OTRSETassignwidth#1\to\tekstbreedte
+% \getcolumnsettextssize[#1][#2][#3]}%
+% \fi}
+%
+% \def\startcolumnsetarea[#1]%
+% {\doifdefinedelse{#1box}
+% {\scratchcounter=\getvalue{#1box}%
+% \global\setbox\scratchcounter=\vbox\bgroup
+% \unvbox\scratchcounter
+% \getvalue{#1setup}
+% \hsize\OTRSETtextswidth}
+% {\setbox\scratchbox=\vbox\bgroup}}
+%
+% \def\stopcolumnsetarea%
+% {\endgraf
+% \vfill
+% \egroup}
+%
+% \def\OTRSETflusharea#1#2#3%
+% {\doifdefined{#1#2#3source}
+% {\scratchcounter=\getvalue{\getvalue{#1#2#3source}box}\relax
+% \ifvoid\scratchcounter\else
+% \ifdim\ht\scratchcounter>\vsize
+% \setbox\scratchbox=\vsplit\scratchcounter to \vsize
+% \unvbox\scratchbox
+% \else
+% \unvbox\scratchcounter
+% \fi
+% \fi}}
+
+% set ipv text
+
+% left right 1 2 3 +1 +2 +3
+
+\let\columnleftareas \empty
+\let\columnrightareas\empty
+
+% links rechts => odd, even, n, named
+
+\def\definecolumntextarea%
+ {\dotripleempty\dodefinecolumntextarea}
+
+\def\dodefinecolumntextarea[#1][#2][#3]%
+ {\ifthirdargument
+ \doifelse{#2}{\v!beide}
+ {\definecolumntextarea[#1][\v!links ][#3]%
+ \definecolumntextarea[#1][\v!rechts][#3]}
+ {\presetlocalframed
+ [\??mt#1#2]%
+ \processaction[#2]
+ [ \v!links=>\addtocommalist{#1}\columnleftareas,
+ \v!rechts=>\addtocommalist{#1}\columnrightareas]%
+ \getparameters[\??mt#1#2]
+ [\c!x=1,\c!y=1,\c!nx=1,\c!ny=1,
+ \c!offset=\v!overlay,\c!strut=\v!nee,\c!kader=\v!uit,
+ \c!status=\v!stop,#3]}%
+ \else
+ \definecolumntextarea[#1][\v!beide][#2]%
+ \fi}
+
+\def\setupcolumntextarea%
+ {\dotripleempty\dosetupcolumntextarea}
+
+\def\dosetupcolumntextarea[#1][#2]%
+ {\getparameters[\??mt#1#2]}
+
+\def\doinitializecolumntextareas#1#2%
+ {\def\docommando##1%
+ {\doifvalue{\??mt##1#2\c!status}{\v!start}
+ {\doOTRSETsetgridcells
+ {\copy\placeholderboxd}
+ {\getvalue{\??mt##1#2\c!x }}{\getvalue{\??mt##1#2\c!y }}
+ {\getvalue{\??mt##1#2\c!nx}}{\getvalue{\??mt##1#2\c!ny}}
+ {\copy\placeholderboxd}}}%
+ \processcommacommand[#1]\docommando}
+
+\def\initializecolumntextareas%
+ {\ifodd\realpageno
+ \doinitializecolumntextareas\columnrightareas\v!rechts
+ \else
+ \doinitializecolumntextareas\columnleftareas\v!links
+ \fi}
+
+\def\doplacecolumntextareas#1#2%
+ {\bgroup
+ \forgetall
+ \def\docommando##1%
+ {\doifvalue{\??mt##1#2\c!status}{\v!start}
+ {\!!counta=\getvalue{\??mt##1#2\c!x}%
+ \!!countb=\getvalue{\??mt##1#2\c!nx}%
+ \!!widtha=\!!countb\hsize
+ \!!heighta=\getvalue{\??mt##1#2\c!ny}\lineheight
+ \advance\!!countb \!!counta \advance\!!countb -1 \relax
+ \ifnum\!!countb>\nofcolumns
+ \!!countc=\!!countb
+ \advance\!!countc -\nofcolumns
+ \!!countb=\nofcolumns
+ \else
+ \!!countc=0
+ \fi
+ \advance\!!counta 1
+ \dostepwiserecurse{\!!counta}{\!!countb}{1}
+ {\advance\!!widtha\OTRSETgetparameter\c!afstand\recurselevel}%
+ \!!widthc=\!!widtha
+ \advance\!!widthc -\!!countc\hsize
+\!!widthb=\!!widthc
+ \ifodd\realpageno \else
+ \ifcase\!!countc\else
+ \advance\!!widtha 2\rugwit
+ \advance\!!widthc \rugwit
+ \dorecurse{\!!countc}
+ {\advance\!!widtha\OTRSETgetparameter\c!afstand\recurselevel}%
+ \fi
+ \fi
+% option
+\advance\!!heighta -\lineheight
+ \setbox\scratchbox=\vbox
+ {\localframed
+ [\??mt##1#2]
+ [\c!breedte=\!!widtha,\c!hoogte=\!!heighta]
+ {\getvalue{\??mt##1#2}}}%
+ \!!counta=\getvalue{\??mt##1#2\c!x}%
+ \!!countb=\getvalue{\??mt##1#2\c!y}%
+ \advance\!!countb \getvalue{\??mt##1#2\c!ny}%
+ \advance\!!countb -1
+ \OTRSETsetgridcell
+ {\!!counta}{\!!countb}
+ \hbox{\clip
+ [\c!breedte=\!!widthc,\c!hoogte=\!!heighta]
+ {\copy\scratchbox}}%
+ \ifcase\!!countc\else
+ \advance\!!counta \getvalue{\??mt##1#2\c!nx}%
+ \advance\!!counta -\!!countc
+ \advance\!!widtha -\!!widthc
+ \OTRSETsetgridcell
+ {\!!counta}{\!!countb}
+ \hbox{\hskip-\rugwit
+ \clip
+ [\c!breedte=\!!widtha,\c!hoogte=\!!heighta,
+ \c!hoffset=\!!widthc]
+ {\copy\scratchbox}}%
+ \fi}}%
+ \processcommacommand[#1]\docommando
+ \egroup}
+
+\def\placecolumntextareas%
+ {\ifodd\realpageno
+ \doplacecolumntextareas\columnrightareas\v!rechts
+ \else
+ \doplacecolumntextareas\columnleftareas\v!links
+ \fi}
+
+\def\setupcolumntextareatext%
+ {\dotripleempty\dosetupcolumntextareatext}
+
+\def\dosetupcolumntextareatext[#1][#2][#3]%
+ {\setvalue{\??mt#1#2}{#3}}
+
+\protect \endinput