summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/tabl-tbl.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/tabl-tbl.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/tabl-tbl.mkiv1480
1 files changed, 1480 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/tabl-tbl.mkiv b/Master/texmf-dist/tex/context/base/tabl-tbl.mkiv
new file mode 100644
index 00000000000..bfff978ab70
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/tabl-tbl.mkiv
@@ -0,0 +1,1480 @@
+%D \module
+%D [ file=core-tbl,
+%D version=1998.11.03,
+%D title=\CONTEXT\ Table Macros,
+%D subtitle=Text Flow Tabulation,
+%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 Table Macros / Tabulation}
+
+% \processbetween gebruiken in head/tail macros
+
+\unprotect
+
+%D I can probably reimplement this using a \LUA||\TEX\ combination
+%D but it does not pay of in development time. If I need something
+%D else I will write it from scratch anyway.
+
+% watch out: don't change this model else trialtypesetting
+% compatibility problems
+
+% watch out, cells expand pretty late on a per row basis
+
+% |p2|p3| 2:3
+% spanning
+
+% Be careful with changing the hsize calculation in p mode;
+% the following code works quite well:
+%
+% \setupfield [line][location=low,height=1.2\lineheight,width=\hsize]
+% \definefield [test] [line] [line] []
+%
+% \starttabulate[|l|p|]
+% \NC test \NC \field [test] \NC \NR
+% \stoptabulate
+
+% In-text tabbing environment
+%
+% \starttabulate[| separated template] % eg [|l|p|] or [|l|p|p|]
+% \NC ... \NC ... \NC\NR
+% \stoptabulate
+%
+% with: two pass auto width calculation when no p-width
+% specified, even with multiple p's, see examples.
+
+% TaBlE compatible specifications:
+%
+% l align column/paragraph left
+% r align column/paragraph right
+% c align column/paragraph center
+% p p(dimen) of automatisch als alleen p
+% w column width
+% f font#1
+% B bold
+% I italic
+% S slanted
+% T type
+% R roman
+% m math
+% M display math
+% h hook (inner level or par lines)
+% b before (may be command#1)
+% a after
+% i i<n> skip left of column
+% j i<n> skip right of column
+% k i<n> skip around column
+
+% s setups
+
+% g g{char} align at char
+% . align at .
+% , align at ,
+
+% Still to be done
+
+% N math numbers (best hook into existing digits mechanism)
+% n numbers (best hook into existing digits mechanism)
+% Q math numbers (best hook into existing digits mechanism)
+% q numbers (best hook into existing digits mechanism)
+% ~ \hskip.5em
+% | check
+
+% nesting
+
+% 10 evt auto stack; dan wel andere signal dan void nodig
+
+% present but not yet 100% ok
+%
+% \FL top hrule
+% \ML mid hrule (with auto split)
+% \LL bottom hrule
+% \HL
+
+% \VL as soon as needed
+% color as soon as needed
+
+% \EQ \RQ \HQ equal (raw, hook)
+% \NC \RC \HC normal (raw, hook)
+%
+% \NR
+
+% \HR : rule with lineheight
+
+% \autotabulaterule : with lineheight, not first/last
+% \autotabulateline : spaced, not first/last
+% \tabulaterule : with lineheight
+% \tabulateline : spaced
+
+% tricky: align scans ahead, over # and expands ones before
+% while doing
+
+% new:
+%
+% \starttabulate[|cg{.}|cg{,}|cg{,}|]
+% \NC period \NC comma \NC comma \NC\NR
+% \NG 100.000,00 \NG 100.000,00 \NG 100,00 \NC\NR
+% \NG 10.000,00 \NG 10.000,00 \NG 1000,00 \NC\NR
+% \NG 100,00 \NG 100,00 \NG 10,00 \NC\NR
+% \NG 10 \NG 10 \NG 0,00 \NC\NR
+% \stoptabulate
+%
+% \starttabulate[|c.|c,|c,|]
+% \NC period \NC comma \NC comma \NC\NR
+% \NG 100.000,00 \NG 100.000,00 \NG 100,00 \NC\NR
+% \NG 10.000,00 \NG 10.000,00 \NG 1000,00 \NC\NR
+% \NG 100,00 \NG 100,00 \NG 10,00 \NC\NR
+% \NG 10 \NG 10 \NG 0,00 \NC\NR
+% \stoptabulate
+
+% nice demo (for BG)
+%
+% \starttabulate[|r|b{$\star$}|ra{\percent}|b{=}|r|]
+% \NC 500 \NC \NC 60 \NC \NC 300 \NC \NR
+% \NC 500 \NC \NC 55 \NC \NC 275 \NC \NR
+% \NC 500 \NC \NC 50 \NC \NC 250 \NC \NR
+% \NC 500 \NC \NC 45 \NC \NC 225 \NC \NR
+% \NC 500 \NC \NC 40 \NC \NC 200 \NC \NR
+% \NC 500 \NC \NC 35 \NC \NC 175 \NC \NR
+% \NC 500 \NC \NC 30 \NC \NC 150 \NC \NR
+% \NC 500 \NC \NC 25 \NC \NC 125 \NC \NR
+% \NC 500 \NC \NC 20 \NC \NC 100 \NC \NR
+% \stoptabulate
+
+\newtoks \tabulatepreamble
+\newtoks \tabulatebefore
+\newtoks \tabulateafter
+\newtoks \tabulatebmath
+\newtoks \tabulateemath
+\newtoks \tabulatefont
+\newtoks \tabulatesettings
+\newtoks \tabulatedummy
+
+\newcount \nofautotabulate
+\newcount \tabulatecolumns
+\newcount \tabulatecolumn
+
+\newcount \tabulateminplines
+\newcount \tabulatemaxplines
+
+\newif \ifautotabulate
+\newif \ifsplittabulate \splittabulatetrue
+
+\newif \ifhandletabulatepbreak \handletabulatepbreaktrue
+\newif \iftabulatenopbreak \tabulatenopbreakfalse
+
+\newif \iftabulateequal
+\newif \iftracetabulate
+\newif \ifframedtabulate
+
+\newdimen \tabulatepwidth
+\newdimen \tabulatewidth
+\newdimen \tabulateunit
+\newdimen \tabulatemaxpheight
+
+\newbox \tabulatebox
+
+% [|lg{.}|] => \NG 12.34 \NC
+
+\gdef\handletabulatecharalign#1 % space delimited !
+ {\edef\alignmentclass{\the\tabulatecolumn}%
+ \edef\alignmentcharacter{\csname\??tt:a:\the\tabulatecolumn\endcsname}%
+ \ifcase\tabulatepass\or
+ \setfirstpasscharacteralign\checkalignment{#1}%
+ \fi % force hsize
+ \setsecondpasscharacteralign\checkalignment{#1}}
+
+\def\noftabcolumns{16}
+
+\def\tablebox#1%
+ {\csname\??tt:b:\number#1\endcsname}
+
+\def\initializetablebox#1% also used elsewhere
+ {\ifcsname\??tt:b:\number#1\endcsname
+ \global\setbox\csname\??tt:b:\number#1\endcsname\emptybox
+ \else
+ \expandafter\newbox\csname\??tt:b:\number#1\endcsname
+ \fi}
+
+\def\initializetableboxes#1%
+ {\scratchcounter#1\relax
+ \doinitializetableboxes}
+
+\def\doinitializetableboxes
+ {\ifnum\scratchcounter>\zerocount
+ \initializetablebox\scratchcounter
+ \advance\scratchcounter\minusone
+ \expandafter\doinitializetableboxes
+ \fi}
+
+\initializetableboxes\noftabcolumns
+
+\def\dodotabulatenobreak
+ {\nobreak
+ \iftracetabulate
+ \red\hrule\!!height.5\linewidth\!!depth.5\linewidth
+ \par
+ \kern-\linewidth
+ \nobreak
+ \fi}
+
+\def\dotabulatenobreak
+ {\noalign{\dodotabulatenobreak}}
+
+\unexpanded\def\notabulatehook
+ {}
+
+\unexpanded\def\checktabulatehook
+ {\ifnum\tabulatetype<\plustwo
+ \glet\tabulatehook\notabulatehook
+ \else
+ \glet\tabulatehook\dotabulatehook
+ \fi}
+
+\unexpanded\def\checktabulatesetups
+ {\csname\??tt:s:\the\tabulatecolumn\endcsname}
+
+\let\pretabrule \donothing
+\let\posttabrule\donothing
+
+% 0 = NC column next EQ equal column
+% 1 = RC column raw RQ equal column raw
+% 2 = HC column hook HQ equal column hook
+% some entries can be left out if we test for them being set
+
+% \def\dodosettabulatepreamble#1#2%
+% {\ifzeropt\tabulatewidth
+% \ifcase\tabulatemodus\relax
+% \let\preamblebox\empty
+% \else
+% \def\preamblebox{\autotabulatetrue}%
+% \fi
+% \else
+% \ifcase\tabulatemodus\relax
+% \edef\preamblebox{\hbox to \the\tabulatewidth}%
+% \else
+% \edef\preamblebox{\hsize\the\tabulatewidth}%
+% \fi
+% \fi
+% %
+% % less bytes
+% %
+% %\edef\preamblebox%
+% % {\ifcase\tabulatewidth
+% % \ifcase\tabulatemodus\relax\else\noexpand\autotabulatetrue\fi
+% % \els
+% % \ifcase\tabulatemodus\relax\hbox to\else\hsize\fi\the\tabulatewidth
+% % \fi}%
+% %
+% \@EA\appendtoks \@EA&\@EA\hskip\pretabskip\pretabrule##&\to\!!toksa
+% \appendtoks \ignorespaces\to\!!toksa
+% \@EA\appendtoks\@EA\global\@EA\tabulatecolumn\the\tabulatecolumns\relax\to\!!toksa
+% \appendtoks \checktabulatesetups\to\!!toksa
+% \appendtoks \checktabulatehook\to\!!toksa
+% \@EA\appendtoks \preamblebox\to\!!toksa
+% \appendtoks \bgroup\bbskip\bgroup#1\to\!!toksa
+% \appendtoks\ifnum\tabulatetype=\plusone \else \to\!!toksa
+% \@EA\appendtoks \the\tabulatebmath\to\!!toksa
+% \@EA\appendtoks \the\tabulatefont\to\!!toksa
+% \@EA\appendtoks \the\tabulatesettings\to\!!toksa
+% \@EA\appendtoks \the\tabulatebefore\to\!!toksa
+% \appendtoks\fi \to\!!toksa
+% \appendtoks \bgroup\ignorespaces\to\!!toksa
+% %
+% \appendtoks \tabulatehook##\to\!!toksa
+% %
+% %%\doifdefinedelse{\??tt:a:\tabulatecolumns}
+% %\doifdefinedelse{\??tt:a:\the\tabulatecolumns}
+% % {\appendtoks\handletabulatecharalign## \to\!!toksa}
+% % {\appendtoks\tabulatehook ##\to \!!toksa}%
+% % waarom kan ik hier geen \xx{##} geven, om een of
+% % andere reden passeert dan tex de hele regel (incl \NC's)
+% % als argument; elke delimiter <> space gaat trouwens fout
+% \appendtoks \unskip\unskip\ifmmode\else\endgraf\fi\egroup\to\!!toksa
+% \appendtoks\ifnum\tabulatetype=1 \else \to\!!toksa
+% \@EA\appendtoks \the\tabulateafter\to\!!toksa
+% \@EA\appendtoks \the\tabulateemath\to\!!toksa
+% \appendtoks\fi \to\!!toksa
+% \appendtoks #2\egroup\egroup\to\!!toksa
+% \@EA\appendtoks \@EA&\@EA\posttabrule\@EA\hskip\postabskip##\to\!!toksa
+% \appendtoks\NC\to\tabulatedummy
+% \let\bbskip\empty
+% \def\pretabskip{.5\tabulateunit}%
+% \let\postabskip\pretabskip
+% \let\gettabulateexit\dogettabulateexit
+% \tabulatewidth\zeropoint}
+%
+% speedup:
+
+% is grouping really needed here?
+
+\unexpanded\def\beforetabulateentry{\ignorespaces\tabulatehook}
+\unexpanded\def\aftertabulateentry {\unskip\unskip\ifmmode\else\endgraf\fi}
+
+\def\dodosettabulatepreamble#1#2% only makes sense for many tabulates
+ {\normalexpanded{\!!toksa{\the\!!toksa
+ &\hskip\pretabskip\noexpand\pretabrule##&%
+ % \ignorespaces
+ \global\tabulatecolumn\the\tabulatecolumns\relax
+ \checktabulatesetups % unexpandable
+ \checktabulatehook % unexpandable
+ \ifzeropt\tabulatewidth
+ \ifcase\tabulatemodus\else
+ \noexpand\autotabulatetrue
+ \fi
+ \else
+ \ifnum\tabulatemodus=\zeropoint
+ \hbox to
+ \else
+ \hsize
+ \fi
+ \the\tabulatewidth
+ \fi
+ \bgroup
+ \noexpand\bbskip
+ \bgroup % we cannot combine the if because a cell may have only one ##
+ \noexpand#1%
+ \noexpand\ifnum\noexpand\tabulatetype=\plusone\noexpand\else
+ \the\tabulatebmath
+ \the\tabulatefont
+ \the\tabulatesettings
+ \the\tabulatebefore
+ \noexpand\fi
+ % grouping needs to be outside macros (or expandable), nice test
+ % example \NC \string & \NC which will fail otherwise (mk)
+ \bgroup
+ \beforetabulateentry
+ ##%
+ \aftertabulateentry
+ \egroup
+ \noexpand\ifnum\noexpand\tabulatetype=\plusone\noexpand\else
+ \the\tabulateafter
+ \the\tabulateemath
+ \noexpand\fi
+ \noexpand#2%
+ \egroup
+ \egroup
+ &\noexpand\posttabrule\hskip\postabskip##%
+ }}%
+ \appendtoks\NC\to\tabulatedummy
+ \let\bbskip\empty % ?
+ \def\pretabskip{.5\tabulateunit}%
+ \let\postabskip\pretabskip
+ \let\gettabulateexit\dogettabulateexit
+ \tabulatewidth\zeropoint}
+
+\setvalue{\??tt>\meaning x}{\let\tabulatealign\zerocount\settabulatepreamble} % internal
+\setvalue{\??tt>\meaning l}{\let\tabulatealign\plusone\settabulatepreamble}
+\setvalue{\??tt>\meaning r}{\let\tabulatealign\plustwo\settabulatepreamble}
+\setvalue{\??tt>\meaning c}{\let\tabulatealign\plusthree\settabulatepreamble}
+\setvalue{\??tt>\meaning p}{\gettabulateparagraph}
+\setvalue{\??tt>\meaning s}{\gettabulatesetups}
+\setvalue{\??tt>\meaning w}{\gettabulatewidth}
+\setvalue{\??tt>\meaning f}{\gettabulatefont}
+\setvalue{\??tt>\meaning B}{\tabulatefont{\bf}\settabulatepreamble}
+\setvalue{\??tt>\meaning I}{\tabulatefont{\it}\settabulatepreamble}
+\setvalue{\??tt>\meaning S}{\tabulatefont{\sl}\settabulatepreamble}
+\setvalue{\??tt>\meaning T}{\tabulatefont{\tt}\settabulatepreamble}
+\setvalue{\??tt>\meaning R}{\tabulatefont{\rm}\settabulatepreamble}
+\setvalue{\??tt>\meaning m}{\tabulatebmath{$}\tabulateemath{$}\settabulatepreamble}
+\setvalue{\??tt>\meaning M}{\tabulatebmath{$\displaystyle}\tabulateemath{$}\settabulatepreamble}
+\setvalue{\??tt>\meaning h}{\gettabulatehook}
+\setvalue{\??tt>\meaning b}{\gettabulatebefore}
+\setvalue{\??tt>\meaning a}{\gettabulateafter}
+\setvalue{\??tt>\meaning i}{\gettabulatepreskip}
+\setvalue{\??tt>\meaning j}{\gettabulateposskip}
+\setvalue{\??tt>\meaning k}{\gettabulatepreposskip}
+\setvalue{\??tt>\meaning X}{\gettabulateexit} % internal
+\setvalue{\??tt>\meaning e}{\appendtoks\global\tabulateequaltrue\to\tabulatesettings\settabulatepreamble}
+\setvalue{\??tt>\meaning ~}{\appendtoks\fixedspaces\to\tabulatesettings\settabulatepreamble}
+\setvalue{\??tt>\meaning g}{\gettabulatealign}
+\setvalue{\??tt>\meaning .}{\gettabulatealign.}
+\setvalue{\??tt>\meaning ,}{\gettabulatealign,}
+
+\setvalue{\??tt>\s!unknown}{\message{unknown preamble key [\meaning\next]}\settabulatepreamble}
+\letvalue{\??tt>\meaning\relax}\donothing
+
+\def\dosettabulatepreamble
+ {\csname\??tt>\ifcsname\??tt>\meaning\next\endcsname\meaning\next\else\s!unknown\fi\endcsname}
+
+\def\dogettabulateexit
+ {\let\postabskip\!!zeropoint
+ \settabulatepreamble}
+
+\let\gettabulateexit\dogettabulateexit
+
+\def\gettabulatepreskip#1%
+ {\doifnumberelse{#1}
+ {\edef\pretabskip{\the\dimenexpr#1\tabulateunit}\let\next\empty}
+ {\edef\pretabskip{\the\dimenexpr.5\tabulateunit}\def\next{#1}}%
+ \@EA\settabulatepreamble\next}
+
+\def\gettabulateposskip#1%
+ {\doifnumberelse{#1}
+ {\edef\postabskip{\the\dimexpr#1\tabulateunit}\let\next\empty}
+ {\edef\postabskip{\the\dimexpr.5\tabulateunit}\def\next{#1}}%
+ \let\gettabulateexit\settabulatepreamble
+ \@EA\settabulatepreamble\next}
+
+\def\gettabulatepreposskip#1%
+ {\doifnumberelse{#1}
+ {\edef\pretabskip{\the\dimenexpr#1\tabulateunit}\let\next\empty}
+ {\edef\pretabskip{\the\dimenexpr.5\tabulateunit}\def\next{#1}}%
+ \let\postabskip\pretabskip
+ \let\gettabulateexit\settabulatepreamble
+ \@EA\settabulatepreamble\next}
+
+\def\gettabulatesetups#1%
+ {\setvalue{\??tt:s:\the\tabulatecolumns}{\setups[#1]}%
+ \settabulatepreamble}
+
+\def\gettabulatehook#1%
+ {\setvalue{\??tt:h:\the\tabulatecolumns}{#1}%
+ \settabulatepreamble}
+
+\def\gettabulatealign#1%
+ {\setvalue{\??tt:a:\the\tabulatecolumns}{#1}%
+ \settabulatepreamble}
+
+\def\gettabulatebefore#1%
+ {\tabulatebefore{#1}%
+ \settabulatepreamble}
+
+\def\gettabulateafter#1%
+ {\tabulateafter{#1}%
+ \settabulatepreamble}
+
+\def\gettabulatefont#1%
+ {\tabulatefont{#1}%
+ \settabulatepreamble}
+
+\def\gettabulatewidth
+ {\let\tabulatemodus\zerocount
+ \let\tabulatedimen\zerocount
+ \doifnextparenthesiselse\dogettabulatewidth\settabulatepreamble}
+
+\def\gettabulateparagraph
+ {\doifnextparenthesiselse
+ {\let\tabulatemodus\plusone
+ \let\tabulatedimen\plusone
+ \dogettabulatewidth}
+ {\let\tabulatemodus\plustwo
+ \let\tabulatedimen\zerocount
+ \settabulatepreamble}}
+
+% \startbuffer
+% \toplinebox{\framed[width=3cm,height=2cm]{tufte}}
+% \stopbuffer
+% \starttabulate[|p(fixed)|p|]
+% \dorecurse{100}{\NC \getbuffer \NC test \par test \par \NC \NR}
+% \stoptabulate
+% \starttabulate[|p(fit)|p|]
+% \dorecurse{100}{\NC \getbuffer \NC test \par test \par \NC \NR}
+% \stoptabulate
+
+\def\dogettabulatewidth(#1)%
+ {\processallactionsinset % can be made faster
+ [#1]%
+ [ \v!fit=>\let\tabulatemodus\plusthree,
+ \v!fixed=>\let\tabulatemodus\plusthree
+ \tabulatenopbreaktrue,
+ \s!unknown=>\tabulatewidth#1\relax]%
+ \ifnum\tabulatedimen=\plusone
+ \global\advance\tabulatepwidth\tabulatewidth
+ \fi
+ \settabulatepreamble}
+
+\def\settabulatepreamble
+ {\afterassignment\dosettabulatepreamble\let\next=}
+
+\def\tabulateraggedright {\ifnum\tabulatetype=\plusone \else\raggedright \fi}
+\def\tabulateraggedcenter{\ifnum\tabulatetype=\plusone \else\raggedcenter\fi}
+\def\tabulateraggedleft {\ifnum\tabulatetype=\plusone \else\raggedleft \fi}
+\def\tabulatenotragged {\ifnum\tabulatetype=\plusone \else\notragged \fi}
+\def\tabulatehss {\ifnum\tabulatetype=\plusone \else\hss \fi} % never change this to a fill
+
+\def\tabulatebskipraggedright {\bskip\tabulateraggedright }
+\def\tabulatebskipraggedleft {\bskip\tabulateraggedleft }
+\def\tabulatebskipraggedcenter{\bskip\tabulateraggedcenter}
+
+\def\tabulatesetpreamblewidthnormal
+ {\ifcase\tabulatealign\relax
+ \dodosettabulatepreamble\empty \tabulatehss \or
+ \dodosettabulatepreamble\empty \tabulatehss \or
+ \dodosettabulatepreamble\tabulatehss\empty \or
+ \dodosettabulatepreamble\tabulatehss\tabulatehss \fi}
+
+\def\tabulatesetpreamblewidthfixed
+ {\ifcase\tabulatealign\relax
+ \dodosettabulatepreamble\bskip \eskip \or
+ \dodosettabulatepreamble\tabulatebskipraggedright \eskip \or
+ \dodosettabulatepreamble\tabulatebskipraggedleft \eskip \or
+ \dodosettabulatepreamble\tabulatebskipraggedcenter\eskip \fi}
+
+\def\tabulatesetpreamblewidthauto
+ {\global\advance\nofautotabulate\plusone
+ \ifcase\tabulatealign\relax
+ \dodosettabulatepreamble\bskip \eskip \or
+ \dodosettabulatepreamble\tabulatebskipraggedright \eskip \or
+ \dodosettabulatepreamble\tabulatebskipraggedleft \eskip \or
+ \dodosettabulatepreamble\tabulatebskipraggedcenter\eskip \fi}
+
+\def\tabulatesetpreamblewidthsimple
+ {\dodosettabulatepreamble\xbskip\xeskip}
+
+\bgroup \catcode`\|=\@@other
+
+\gdef\nexttabulate#1|%
+ {\let\tabulatealign\@@tabulatealign
+ \let\tabulatemodus\zerocount
+ \let\tabulatedimen\zerocount
+ \tabulatebefore \emptytoks
+ \tabulateafter \emptytoks
+ \tabulatebmath \emptytoks
+ \tabulateemath \emptytoks
+ \tabulatefont \emptytoks
+ \tabulatesettings\emptytoks
+ \global\advance\tabulatecolumns\plusone
+ \expandafter\let\csname\??tt:s:\the\tabulatecolumns\endcsname\donothing
+ \settabulatepreamble#1\relax\relax % permits i without n
+ \ifcase\tabulatemodus\relax
+ \tabulatesetpreamblewidthnormal
+ \or % fixed width
+ \tabulatesetpreamblewidthfixed
+ \or % auto width
+ \tabulatesetpreamblewidthauto
+ \or % simple
+ \tabulatesetpreamblewidthsimple
+ \fi
+ \futurelet\next\donexttabulate}
+
+\egroup
+
+\def\donexttabulate
+ {\ifx\next\relax\else
+ \expandafter\nexttabulate
+ \fi}
+
+\def\splitofftabulatebox % overloaded in anch-pgr
+ {\dontcomplain
+ \global\setbox\tabulatebox % % % global ? % % %
+ \vsplit\tablebox\tabulatecolumn to \lineheight
+ \setbox\tabulatebox\normalvbox
+ {\unvbox\tabulatebox}%
+ \setbox\tabulatebox\hbox to \wd\tabulatebox
+ {\hss\dotabulatehook{\box\tabulatebox}\hss}%
+ \ht\tabulatebox\strutht
+ \dp\tabulatebox\strutdp
+ \box\tabulatebox}
+
+\def\dotabulatehook {\csname\??tt:h:\the\tabulatecolumn\endcsname}
+\def\dotabulatealign{\csname\??tt:a:\the\tabulatecolumn\endcsname}
+
+\def\resettabulatepheight
+ {\global\tabulateminplines\plusone
+ \ifdim\tabulatemaxpheight>\zeropoint
+ \getnoflines\tabulatemaxpheight
+ \global\tabulatemaxplines\noflines
+ \else
+ \global\tabulatemaxplines\zerocount
+ \fi
+ \global\tabulatemaxpheight\zeropoint}
+
+\def\settabulatepheight
+ {\scratchdimen\ht\tablebox\tabulatecolumn\relax
+ \ifdim\scratchdimen>\tabulatemaxpheight
+ \global\tabulatemaxpheight\scratchdimen
+ \fi}
+
+% \def\handletabulatepbreak
+% {\TABLEnoalign
+% {\ifhandletabulatepbreak
+% \iftabulatenopbreak
+% \dotabulatenobreak
+% \else\ifnum\tabulatemaxplines>\plusone
+% \ifnum\tabulateminplines=\plusone
+% \dotabulatenobreak
+% \fi
+% \global\advance\tabulateminplines\plusone
+% \ifnum\tabulateminplines=\tabulatemaxplines\relax
+% \dotabulatenobreak
+% \fi
+% \fi \fi
+% \fi}}
+
+\def\dohandletabulatepbreak
+ {\ifhandletabulatepbreak
+ \iftabulatenopbreak
+ \dotabulatenobreak
+ \else\ifnum\tabulatemaxplines>\plusone
+ \ifnum\tabulateminplines=\plusone
+ \dotabulatenobreak
+ \fi
+ \global\advance\tabulateminplines\plusone
+ \ifnum\tabulateminplines=\tabulatemaxplines\relax
+ \dotabulatenobreak
+ \fi
+ \fi \fi
+ \fi}
+
+\def\handletabulatepbreak
+ {\TABLEnoalign{\dohandletabulatepbreak}}
+
+%D \startbuffer
+%D \starttabulate[|c|p|p|]
+%D \NC \bf Alpha \NC \bf Beta \NC \bf Gamma \NC\NR
+%D \NC 1 \NC right indeed \NC definitely wrong \NC\NR
+%D \NC 2 \NC \thinrules[n=3] \NC \thinrules[n=3] \NC\NR
+%D \NC 3 \NC oh yes \NC simply no \NC\NR
+%D \NC 4 \NC very true \NC as false as can be \NC\NR
+%D \NC 5 \NC \thinrules[n=5] \NC \thinrules[n=5] \NC\NR
+%D \NC 6 \NC \thinrules[n=3] \NC \thinrules[n=4] \NC\NR
+%D \stoptabulate
+%D \stopbuffer
+%D
+%D \typebuffer {\tracetabulatetrue\getbuffer}
+%D
+%D \startbuffer
+%D \starttabulate[|c|p|p|]
+%D \NC \bf Alpha \NC \bf Beta \NC \bf Gamma \NC\NR
+%D \NC 1 \NC right indeed \NC definitely wrong \NC\NR
+%D \NC 2 \NC oh yes \NC simply no \NC\NR
+%D \NC 3 \NC very true \NC as false as can be \NC\NR
+%D \NC 4 \NC the whole truth \NC but the truth \NC\NR
+%D \stoptabulate
+%D \stopbuffer
+%D
+%D \typebuffer {\tracetabulatetrue\getbuffer}
+
+% \definetabulate
+% \redefinetabulate
+% \starttabulate[preamble]
+% \starttabulate -> \starttabulate[|l|p|]
+
+\bgroup \catcode`\|=\@@other
+
+\gdef\definetabulate
+ {\dotripleempty\dodefinetabulate}
+
+\gdef\dodefinetabulate[#1][#2][#3]%
+ {\ifthirdargument
+ \ifcsname\??tt#1::\c!unit\endcsname \else
+ \copyparameters
+ [\??tt#1::][\??tt\v!tabulate::]%
+ [\c!frame,\c!distance,\c!unit,\c!before,\c!bodyfont,\c!after,
+ \c!inner,\c!indenting,\c!margin,\c!align,\c!header,\c!title,
+ \c!rulecolor,\c!rulethickness,\c!split,EQ]%
+ \fi
+ \copyparameters
+ [\??tt#1::#2][\??tt#1::]%
+ [\c!unit,\c!distance,\c!before,\c!bodyfont,\c!after,
+ \c!inner,\c!indenting,\c!frame,\c!split,\c!header,\c!title,
+ \c!margin,\c!align,\c!rulecolor,\c!rulethickness,EQ]%
+ \setvalue{\e!start#1::#2}{\dofinalstarttabulate[#1][#2][#3]}%
+ \setvalue{\e!start#1}{\bgroup\dosubstarttabulate[#1]}%
+ \letvalue{\??tt#1-\v!header}\empty
+ \letvalue{\??tt#1-\v!footer }\empty
+ \else\ifsecondargument
+ \definetabulate[#1][][#2]%
+ \else
+ \definetabulate[#1][][|l|p|]%
+ \fi\fi}
+
+\egroup
+
+\let\tabulateheadcontent\empty
+\let\tabulatetailcontent\empty
+
+\newconditional\tabulatesomeamble
+
+\def\processtabulateheadcontent
+ {\TABLEnoalign{\global\settrue\tabulatesomeamble}%
+ \csname\??tt\currenttabulate-\v!header\endcsname
+ \TABLEnoalign{\global\setfalse\tabulatesomeamble}}%
+
+\def\processtabulatetailcontent
+ {\TABLEnoalign{\global\settrue\tabulatesomeamble}%
+ \csname\??tt\currenttabulate-\v!footer\endcsname
+ \TABLEnoalign{\global\setfalse\tabulatesomeamble}}%
+
+\def\checkfulltabulatecontent % - needed, else confusion with \c!header
+ {\ifcsname\??tt\currenttabulate-\v!header\endcsname
+ \let\tabulateheadcontent\processtabulateheadcontent
+ \else
+ \let\tabulateheadcontent\empty
+ \fi
+ \ifcsname\??tt\currenttabulate-\v!footer\endcsname
+ \let\tabulatetailcontent\processtabulatetailcontent
+ \else
+ \let\tabulatetailcontent\empty
+ \fi}
+
+% \def\fulltabulatecontent
+% {\tabulateheadcontent
+% \tabulatecontent
+% \tabulatetailcontent}
+
+\def\fulltabulatecontent
+ {\tabulateheadcontent
+ \tabulatecontent
+ \tabulatetailcontent
+ \removefunnytabulateline}
+
+\def\removefunnytabulateline
+ {\ifhmode
+ \strut\crcr
+ \TABLEnoalign{\kern-\lineheight}%
+ \fi}
+
+\setvalue{\e!start\v!tabulatehead}%
+ {\dosingleempty\dostartstarttabulatehead}
+
+\def\dostartstarttabulatehead[#1]%
+ {\processcontent{\e!stop\v!tabulatehead}\next
+ {\letvalue{\??tt\iffirstargument#1\else\v!tabulate\fi::-\v!header}\next}}
+
+\setvalue{\e!start\v!tabulatetail}%
+ {\dosingleempty\dostartstarttabulatetail}
+
+\def\dostartstarttabulatetail[#1]%
+ {\processcontent{\e!stop\v!tabulatetail}\next
+ {\letvalue{\??tt\iffirstargument#1\else\v!tabulate\fi::-\v!footer}\next}}
+
+\def\dosubstarttabulate
+ {\dodoubleempty\dodosubstarttabulate}
+
+\def\dodosubstarttabulate[#1][#2]%
+ {\csname\e!start#1::\ifcsname\e!start#1::#2\endcsname#2\fi\endcsname}
+
+\setvalue{\e!start\v!tabulate}%
+ {\bgroup\dodoubleempty\donormalstarttabulate}
+
+\bgroup
+
+\gdef\donormalstarttabulate[#1][#2]%
+ {\ifsecondargument
+ \getparameters[\??tt\v!tabulate::][#2]%
+ \fi
+ \iffirstargument
+ \def\next{\dofinalstarttabulate[\v!tabulate][][#1]}%
+ \else
+ \def\next{\dofinalstarttabulate[\v!tabulate][][|l|p|]}%
+ \fi
+ \next}
+
+\egroup
+
+% The much neede hook:
+
+\newtoks\everytabulate
+
+% An example of its usage:
+
+\appendtoks \optimizeverbatimfalse \to \everytabulate
+\appendtoks \let\recodeverbatimmode\plustwo \to \everytabulate
+
+% A status variable:
+
+\chardef\tabulatepass=0
+
+\def\tabulateparameter#1{\csname\??tt\currenttabulate#1\endcsname}
+
+\bgroup
+ \catcode`\|=\@@other \gdef\@@otherbar{|}
+ \catcode`\|=\@@active \gdef\@@useotherbar{\let|\@@otherbar}
+\egroup
+
+\def\doparsetabulate
+ {\futurelet\next\dodoparsetabulate}
+
+% \def\dodoparsetabulate % \@EAEAEA gebruiken
+% {\ifx\next\relax
+% % exit
+% \else\ifx*\next
+% \let\next\dorepeatparsetabulate
+% \else\ifx\bgroup\next
+% \let\next\dododoparsetabulate
+% \else
+% \let\next\dodododoparsetabulate
+% \fi\fi\fi
+% \next}%
+
+\def\dorepeatparsetabulate*#1#2%
+ {\dorecurse{#1}{\!!toksb\expandafter{\the\!!toksb#2}}% \dorecurse{#1}{\appendtoks#2\to\!!toksb}%
+ \doparsetabulate}
+
+\def\dododoparsetabulate#1%
+ {\!!toksb\expandafter{\the\!!toksb{#1}}% \appendtoks{#1}\to\!!toksb
+ \doparsetabulate}
+
+\def\dodododoparsetabulate#1%
+ {\!!toksb\expandafter{\the\!!toksb#1}% \appendtoks#1\to\!!toksb
+ \doparsetabulate}
+
+\letvalue{\??tt<\meaning *}\dorepeatparsetabulate
+\letvalue{\??tt<\meaning \bgroup}\dododoparsetabulate
+\letvalue{\??tt<\meaning \relax}\donothing
+\letvalue{\??tt<\s!unknown }\dodododoparsetabulate
+
+\def\dodoparsetabulate
+ {\csname\??tt<\ifcsname\??tt<\meaning\next\endcsname\meaning\next\else\s!unknown\fi\endcsname}
+
+\setvalue{\??tt:\c!split:\v!yes }{\splittabulatetrue}
+\setvalue{\??tt:\c!split:\v!repeat}{\splittabulatetrue}
+\setvalue{\??tt:\c!split:\v!no }{\splittabulatefalse}
+\setvalue{\??tt:\c!split:\v!auto }{\ifinsidefloat\ifinsidesplitfloat\else\splittabulatefalse\fi\fi}
+
+\def\dofinalstarttabulate[#1][#2][#3]% identifier sub preamble
+ {\edef\currenttabulate{#1::#2}%
+ \ifinsidefloat \else
+ \whitespace
+ \tabulateparameter\c!before
+ \fi
+ \bgroup
+ \resetcharacteralign
+ % todo: spacing around tabulate when bodyfont is set
+ % expansion en test needed ?
+ \splittabulatetrue
+ \csname\??tt:\c!split:\tabulateparameter\c!split\endcsname
+ \doifvaluesomething{\??tt\currenttabulate\c!bodyfont}
+ {\expanded{\switchtobodyfont[\tabulateparameter\c!bodyfont]}}%
+ \postponenotes % new, to be tested / will be configurable
+ \let\tabulatepass\plusone
+ \widowpenalty\zerocount % otherwise lines are not broken
+ \clubpenalty \zerocount % but overlap in funny ways
+ \the\everytabulate
+ \tabulateparameter\c!inner
+ \doifelsevalue{\??tt\currenttabulate\c!indenting}\v!yes
+ {\edef\tabulateindent{\the\dimexpr\leftskip+\hangindent+\parindent}}% \ctxparindent
+ {\edef\tabulateindent{\the\dimexpr\leftskip+\hangindent }}%
+ \global\tabulatecolumn\zerocount
+ \!!toksb\emptytoks
+ \bgroup
+ \@@useotherbar
+ \normalexpanded{\egroup\noexpand\doparsetabulate#3\relax}%
+ \processcontent
+ {\e!stop#1}% \currenttabulate}
+ \tabulatecontent
+ {\@EA\processtabulate\@EA[\the\!!toksb]}}
+
+\chardef\tabulatetype=0
+
+% 0 = NC column next EQ equal column
+% 1 = RC column raw RQ equal column raw
+% 2 = HC column hook HQ equal column hook
+
+\newif\iftabulatefirstflushed
+
+\def\tabulateEQ
+ {\iftabulatefirstflushed\else\tabulateparameter{EQ}\fi
+ \global\tabulateequalfalse}
+
+% \def\tabulatenormalcolumn#1%
+% {&\iftabulateequal\tabulateEQ\fi&\global\chardef\tabulatetype#1&}
+%
+% \def\tabulateequalcolumn#1%
+% {&\tabulateEQ&\global\chardef\tabulatetype#1&}
+%
+% however, \unskip en \ignorespaces permit usage in complex XML/\starttabulate
+
+\def\tabulatenormalcolumn#1%
+ {\unskip&\iftabulateequal\tabulateEQ\fi&\global\chardef\tabulatetype#1&%
+ \ignorespaces}
+
+\def\tabulateequalcolumn#1%
+ {\unskip&\tabulateEQ&\global\chardef\tabulatetype#1&%
+ \ignorespaces}
+
+\def\tabulateautocolumn
+ {\tabulatenormalcolumn\zerocount
+ \ifnum\tabulatecolumn>\tabulatecolumns\relax
+ \expandafter\NR
+ \else
+ \expandafter\ignorespaces % interferes with the more tricky hooks
+ \fi}
+
+\def\setquicktabulate#1% see \startlegend \startgiven
+ {\let#1\tabulateautocolumn
+ \let\\\tabulateautocolumn}
+
+\def\dotabulateruleseperator % can be sped up (will do when used frequently)
+ {\bgroup
+ \let\factor\!!plusone
+ \scratchskip\strutdp
+ \ExpandFirstAfter\processallactionsinset
+ [\tabulateparameter\c!distance]
+ [ \v!blank=>\scratchskip\bigskipamount,
+ \v!depth=>\scratchskip\strutdp,
+ \v!small=>\def\factor{.25},
+ \v!medium=>\def\factor{.5},
+ \v!big=>,
+ \v!none=>\scratchskip\zeropoint\def\factor{0},
+ \v!grid=>\scratchskip\zeropoint\def\factor{0},
+ \s!unknown=>\scratchskip\commalistelement]%
+ \scratchdimen\factor\scratchskip
+ \ifconditional\tabulatesomeamble\kern\else\vskip\fi\scratchdimen % new
+ \egroup}
+
+\def\dodotabulaterule#1%
+ {\color
+ [\tabulateparameter\c!rulecolor]
+ {\scratchdimen\tabulateparameter\c!rulethickness#1}}
+
+\def\dotabulaterule
+ {\dodotabulaterule
+ {\hrule\!!height.5\scratchdimen\!!depth.5\scratchdimen\relax
+ \doifvalue{\??tt\currenttabulate\c!distance}\v!grid
+ {\kern-\scratchdimen}}} % experimental tm-prikkels
+
+\def\dotabulatelinerule
+ {\multispan\totaltabulatecolumns % \multispan is a plain macro
+ % for the moment this one
+ \strut\hskip\tabulateparameter\c!margin
+ % neg values are ok !
+ \hskip\tabulateindent % new august 2003
+ \dodotabulaterule
+ {\!!heighta.5\lineheight
+ \advance\!!heighta-\strutdepth
+ \!!deptha-\!!heighta
+ \advance\!!deptha\scratchdimen
+ \leaders\hrule\!!height\!!heighta\!!depth\!!deptha\hfill}%
+ \cr}
+
+%D When set to true, no (less) break optimization is done.
+
+\newif\iftolerantTABLEbreak
+
+%D The main processing macro is large but splitting it up
+%D would make things less clear.
+
+\def\doregistertabulateparoptions
+ {\iftrialtypesetting \else
+ \registerparoptions
+ \ifinsidefloat
+ % that is, an unbreakable one
+ \glet\registertabulateparoptions\empty
+ \else
+ % unsafe in crossing pages, at each b...
+ % \glet\registertabulateparoptions\empty
+ \fi
+ \fi}
+
+\appendtoks
+ \glet\registertabulateparoptions\doregistertabulateparoptions
+\to \everytabulate
+
+\newtoks\everytabulaterow
+
+\appendtoks
+ \registertabulateparoptions
+\to \everytabulaterow
+
+\def\flushtabulateindent
+ {\ifnum\tabulatecolumn=\zerocount
+ \hbox to \tabulateindent
+ {% we now have a local hsize, and since we want to
+ % register positional info (i.e. real hsizes) we
+ % need to reconstitute the original hsize
+ \advance\hsize\tabulateindent
+ % this is indeed rather messy and took a few hours
+ % to dis/uncover
+ \the\everytabulaterow
+ \hss}%
+ \fi}
+
+\def\totaltabulatecolumns{0}
+
+\def\handletabulatedigits{\digits}
+
+%D Beware, we cannot use \type {\unexpanded} on \type {\HL}
+%D cum suis, since \TEX's hard coded noalign lookahead fails
+%D on it! I mistakenly added this for a while.
+
+\chardef\tabulaterepeathead\zerocount
+
+\newcount\noftabulatelines
+\newcount\totalnoftabulatelines
+\newcount\minusnoftabulatelines
+
+\setvalue{\??tt:\c!align:\v!normal}{0}
+\setvalue{\??tt:\c!align:\v!right }{1}
+\setvalue{\??tt:\c!align:\v!left }{2}
+\setvalue{\??tt:\c!align:\v!middle}{3}
+
+\setvalue{\??tt:\c!header:\v!repeat}{\plusone}
+\setvalue{\??tt:\c!header:\v!text }{\plustwo}
+
+\newtoks\everyaftertabulaterow
+
+\def\tabulatebskipone {\setbox\tabulatebox\vbox\bgroup\glet\tabulatehook\notabulatehook}
+\def\tabulateeskipone {\par\egroup\glet\tabulatehook\dotabulatehook}
+\def\tabulatexbskipone{\hbox\bgroup\vbox\bgroup\glet\tabulatehook\notabulatehook}
+\def\tabulatexeskipone{\par\egroup\egroup\glet\tabulatehook\dotabulatehook}
+
+\def\tabulatebaselinecorrection
+ {\def\dobaselinecorrection
+ {\vskip-\prevdepth
+ \vskip\strutdp
+ \vskip\strutdp}%
+ \baselinecorrection}
+
+\unexpanded\def\tabulateNCone{\tabulatenormalcolumn0}
+\unexpanded\def\tabulateRCone{\tabulatenormalcolumn1}
+\unexpanded\def\tabulateHCone{\tabulatenormalcolumn2}
+\unexpanded\def\tabulateEQone{\tabulateequalcolumn 0}
+\unexpanded\def\tabulateRQone{\tabulateequalcolumn 1}
+\unexpanded\def\tabulateHQone{\tabulateequalcolumn 2}
+\unexpanded\def\tabulateNGone{\NC\handletabulatecharalign}
+\unexpanded\def\tabulateNNone{\NC\handletabulatedigits} % new, undocumented, test first
+\unexpanded\def\tabulateNDone{\NC\handletabulatedigits} % same, for old times sake
+\unexpanded\def\tabulateHRone{\doHR\zerocount}
+\unexpanded\def\tabulateHLone{\doHL\zerocount}
+
+\unexpanded\def\tabulateNRone % next row
+ {\global\advance\noftabulatelines\plusone
+ \global\tabulatefirstflushedfalse
+ \global\tabulateequalfalse
+ \global\tabulatecolumn\zerocount
+ \resettabulatepheight
+ \unskip\unskip\crcr\flushtabulated
+ \TABLEnoalign
+ {\the\everyaftertabulaterow}%
+ \TABLEnoalign
+ {\iftolerantTABLEbreak\else
+ \ifconditional\tabulatesomeamble \ifcase\tabulaterepeathead \else
+ \allowbreak
+ \fi \fi
+ \ifnum\noftabulatelines=\plusone
+ \dotabulatenobreak
+ \else\ifnum\noftabulatelines=\minusnoftabulatelines
+ \ifnum\tabulatemaxplines<\plustwo
+ \dotabulatenobreak
+ \else
+ \allowbreak % needed with pbreak prevention
+ \fi
+ \else
+ \allowbreak % needed with pbreak prevention
+ \fi\fi
+ \fi
+ \global\tabulatefirstflushedfalse}}
+
+\def\tabulatebbskiptwo
+ {\ifvoid\tablebox\tabulatecolumn
+ \ifx\flushtabulatedindeed\empty\else
+ \setbox0\hbox
+ \fi
+ \fi}
+
+\def\tabulatebskiptwoeskip
+ {\par\egroup
+ \settabulatepheight
+ \glet\tabulatehook\dotabulatehook
+ \splitofftabulatebox}
+
+\def\tabulatebskiptwo
+ {\ifvoid\tablebox\tabulatecolumn
+ \global\setbox\tablebox\tabulatecolumn\vbox
+ \bgroup
+ \glet\tabulatehook\notabulatehook
+ \ifautotabulate\hsize\tabulatewidth\fi
+ % \begstrut % interferes with pre-\pars
+ % evt: \appendtoks\begstrut\to\everypar
+ \ignorespaces
+ \let\eskip\tabulatebskiptwoeskip
+ \else
+ \let\eskip\empty
+ \dontcomplain
+ \glet\tabulatehook\dotabulatehook
+ \expandafter\splitofftabulatebox
+ \fi}
+
+\def\tabulatexbskiptwo{\bskip}
+\def\tabulatexeskiptwo{\eskip}
+
+% \def\tabulateflushtabulatedtwo
+% {\TABLEnoalign % noalign % no interference !
+% {\glet\flushtabulatedindeed\empty
+% \global\tabulatecolumn\zerocount
+% \handletabulatepbreak
+% \dorecurse\tabulatecolumns % was: \noftabcolumns
+% {\ifvoid\tablebox\recurselevel\else
+% \gdef\flushtabulatedindeed{\the\tabulatedummy}%
+% \fi}%
+% \global\tabulatefirstflushedtrue}%
+% \flushtabulatedindeed}
+
+\def\dotabulateflushtabulatedtwo
+ {\glet\flushtabulatedindeed\empty
+ \global\tabulatecolumn\zerocount
+ \handletabulatepbreak
+ \dorecurse\tabulatecolumns % was: \noftabcolumns
+ {\ifvoid\tablebox\recurselevel\else
+ \gdef\flushtabulatedindeed{\the\tabulatedummy}%
+ \fi}%
+ \global\tabulatefirstflushedtrue}
+
+\def\tabulateflushtabulatedtwo
+ {\TABLEnoalign{\dotabulateflushtabulatedtwo}%
+ \flushtabulatedindeed}
+
+\def\tabulatebskipthree
+ {\vtop\bgroup
+ \ifautotabulate\hsize\tabulatewidth\fi
+ % \begstrut % interferes with pre-\pars
+ % evt: \appendtoks\begstrut\to\everypar
+ \ignorespaces}
+
+\def\tabulateeskipthree % vertical strut added august 2003
+ {\par\verticalstrut\vskip-\struttotal\egroup}
+
+\def\tabulatedoHLfour#1% #1 ignored
+ {\TABLEnoalign
+ {\csname
+ \ifnum\noftabulatelines=\zerocount F\else
+ \ifnum\noftabulatelines=\totalnoftabulatelines L\else
+ M\fi\fi
+ L\endcsname}}%
+
+\def\tabulatedoHRfour#1% horizontal rule line (break untested)
+ {\TABLEnoalign
+ {\globallet\TABLEautoline\dotabulatelinerule
+ \ifcase#1\or
+ \ifnum\noftabulatelines=\zerocount
+ \gdef\TABLEautoline{\TABLEnoalign{}}%
+ \else\ifnum\noftabulatelines=\totalnoftabulatelines
+ \gdef\TABLEautoline{\TABLEnoalign{}}%
+ \fi\fi
+ \fi
+ \dotabulatenobreak}%
+ \TABLEautoline
+ \TABLEnoalign
+ {\nobreak
+ \ifx\TABLEautoline\dotabulatelinerule\kern-\lineheight\fi
+ \ifnum\noftabulatelines=\totalnoftabulatelines
+ \@EA\dotabulatenobreak
+ \else
+ \@EA\allowbreak
+ \fi}%
+ \TABLEautoline
+ \TABLEnoalign
+ {\dotabulatenobreak}}
+
+\def\tabulateFLfive{\TABLEnoalign
+ {\ifinsidefloat\else
+ \doifemptyvalue{\??tt\currenttabulate\c!before} % no expansion
+ {\tabulatebaselinecorrection}%
+ \fi
+ \dotabulaterule
+ \dotabulatenobreak
+ \dotabulateruleseperator
+ \prevdepth\strutdp
+ \dotabulatenobreak}}
+
+\def\tabulateMLfive{\TABLEnoalign
+ {\dotabulateruleseperator
+ \dotabulaterule
+ \ifnum\noftabulatelines>\plusone
+ \ifnum\noftabulatelines<\minusnoftabulatelines
+ \vskip\topskip\allowbreak\vskip-\topskip
+ \vskip-\tabulateparameter\c!rulethickness
+ \dotabulaterule
+ \fi
+ \fi
+ \dotabulateruleseperator}}
+
+\def\tabulateLLfive{\TABLEnoalign
+ {\dotabulatenobreak
+ \dotabulateruleseperator
+ \dotabulatenobreak
+ \dotabulaterule
+ \ifinsidefloat\else
+ \doifemptyvalue{\??tt\currenttabulate\c!after} % no expansion
+ {\vskip\strutdp
+ \verticalstrut
+ \vskip-\struttotal}%
+ \fi}}
+
+\def\tabulateHLfive
+ {\doHL\zerocount}
+
+\def\tabulaterule {\HR}% a rule with lineheight
+\def\tabulateline {\HL}% just a spaced rule
+\def\tabulateautorule{\doHR\plusone}%
+\def\tabulateautoline{\doHL\plusone}%
+
+\bgroup \catcode`\|=\@@other
+
+\gdef\processtabulate[|#1|]% in the process of optimizing
+ {\tabulateunit\tabulateparameter\c!unit
+ \checkfulltabulatecontent
+ \globallet\tabulateruledepth \!!zeropoint
+ \globallet\tabulateruleheight\!!zeropoint
+ \edef\@@tabulatealign{\executeifdefined{\??tt:\c!align:\tabulateparameter\c!align}0}%
+ \let\pretabskip\!!zeropoint
+ \def\postabskip{.5\tabulateunit}%
+ \global\tabulatecolumns\zerocount
+ \global\nofautotabulate\zerocount
+ \global\noftabulatelines\zerocount
+ \totalnoftabulatelines\noftabulatelines
+ \minusnoftabulatelines\noftabulatelines
+ \global\tabulatepwidth\zeropoint
+ \global\tabulateequalfalse
+ \resettabulatepheight
+ \ifinsidesplitfloat
+ \donetrue
+ \else\ifinsidefloat
+ \donefalse
+ \else
+ \donetrue
+ \fi\fi
+ \ifdone
+ \chardef\tabulaterepeathead\executeifdefined{\??tt:\c!header:\tabulateparameter\c!header}\zerocount
+ \fi
+ \let\NC\tabulateNCone
+ \let\RC\tabulateRCone
+ \let\HC\tabulateHCone
+ \let\EQ\tabulateEQone
+ \let\RQ\tabulateRQone
+ \let\HQ\tabulateHQone
+ \let\NG\tabulateNGone
+ \let\NN\tabulateNNone
+ \let\ND\tabulateNDone
+ \let\HR\tabulateHRone
+ \let\HL\tabulateHLone
+ \let\NR\tabulateNRone
+ \let\HL\empty % not needed ? ? ?
+ \let\SR\NR \let\AR\NR
+ \let\FL\empty \let\FR\NR
+ \let\ML\empty \let\MR\NR
+ \let\LL\empty \let\LR\NR
+ \let\doHR\gobbleoneargument
+ \let\doHL\gobbleoneargument
+ \glet\flushtabulated\empty
+ \tabskip\zeropoint
+ \ifdim\tabulateparameter\c!margin>\zeropoint
+ \!!toksa{&\flushtabulateindent\strut##\tabskip\tabulateparameter\c!margin\strut&##\tabskip\zeropoint}%
+ \else
+ \!!toksa{&\flushtabulateindent\strut##&##\tabskip\zeropoint}%
+ \fi
+ \tabulatewidth\zeropoint
+ \nexttabulate #1X|\relax
+ \edef\totaltabulatecolumns{\the\numexpr3*\tabulatecolumns+4}%
+ \tabulatewidth\zeropoint
+ \initializetableboxes\tabulatecolumns
+ \appendtoks&##\global\advance\tabulatecolumn\plusone\to\!!toksa
+ \appendtoks\NC\unskip\unskip\crcr\flushtabulated\to\tabulatedummy % no count
+ \global\tabulatecolumn\zerocount
+ \resettabulatepheight
+ \let\bskip \tabulatebskipone
+ \let\eskip \tabulateeskipone
+ \let\xbskip\tabulatexbskipone
+ \let\xeskip\tabulatexeskipone
+ \glet\tabulatehook\dotabulatehook
+ \doifvalue{\??tt\currenttabulate\c!indenting}\v!no\forgetparindent
+ \ifinsidefloat
+ \let\tabulateindent\!!zeropoint
+ \else
+ \setlocalhsize \hsize\localhsize
+ \fi
+ \dontcomplain
+ \forgetall % hm, interference with \forgetparindent ^^^ probably bug, to be solved
+ \setbox0\vbox % outside \if because of line counting
+ {\notesenabledfalse
+ \let\tabulateindent\!!zeropoint
+ \trialtypesettingtrue % very important
+ \@EA\halign\@EA{\the\!!toksa\crcr\fulltabulatecontent\crcr}}%
+ \ifnum\nofautotabulate>\zerocount
+ % so, even if the natural size is larger, in the final
+ % run, we force the calculated width
+ \tabulatewidth\dimexpr\hsize-\wd0-\tabulatepwidth\relax
+ \ifnum\nofautotabulate>\zerocount
+ \divide\tabulatewidth \nofautotabulate\relax
+ \fi
+ \fi
+ \let\xbskip\tabulatexbskiptwo
+ \let\xeskip\tabulatexeskiptwo
+ \ifsplittabulate
+ \splittopskip\strutht
+ \glet\flushtabulatedindeed\empty
+ \let\bbskip\tabulatebbskiptwo
+ \let\bskip\tabulatebskiptwo
+ \glet\flushtabulated\tabulateflushtabulatedtwo
+ \else
+ % tabhook op alles ?
+ \let\bskip\tabulatebskipthree
+ \let\eskip\tabulateeskipthree
+ \fi
+ \totalnoftabulatelines\noftabulatelines
+ \minusnoftabulatelines\numexpr\noftabulatelines+\minusone\relax
+ \global\noftabulatelines\zerocount
+ \let\doHL\tabulatedoHLfour
+ \let\doHR\tabulatedoHRfour
+ \doifelsevalue{\??tt\currenttabulate\c!rule}\v!line
+ {\let\HL\HR
+ \let\tabulateautoline\tabulateautorule
+ \let\tabulateline\tabulaterule}%
+ {\let\HL\tabulateHLfive}%
+ \let\FL\tabulateFLfive
+ \let\ML\tabulateMLfive
+ \let\LL\tabulateLLfive
+ \let\tabulatepass\plustwo
+ %
+ \ifcase\tabulaterepeathead
+ \ifinsidesplitfloat
+ \setbox\tabulatebox\vbox \bgroup
+ \else
+ \startframedcontent[\tabulateparameter\c!frame]%
+ \fi
+ \else
+ \setbox\tabulatebox\vbox \bgroup
+ \fi
+ %
+ \@EA\halign\@EA{\the\!!toksa\crcr\fulltabulatecontent\crcr}%
+ \prevdepth\strutdp % nog eens beter, temporary hack
+ \doifvalue{\??tt\currenttabulate\c!distance}\v!grid{\vskip-\strutdp}% experimental tm-prikkels
+ %
+ \ifcase\tabulaterepeathead
+ \ifinsidesplitfloat
+ \egroup \splittabulatebox\tabulatebox
+ \else
+ \stopframedcontent
+ \fi
+ \else
+ \egroup \splittabulatebox\tabulatebox
+ \fi
+ %
+ \egroup
+ \ifinsidefloat \else
+ \tabulateparameter\c!after
+ \fi
+ \egroup}
+
+\egroup
+
+% \setuptabulate[split=yes,header=text,title=Vervolg van Tabel]
+%
+% % \starttabulatehead
+% % \NC test \NC hans\NC \NR
+% % \stoptabulatehead
+%
+% \starttabulate
+% \NC test \NC \input tufte \relax \NC \NR
+% \NC test \NC \input knuth \relax \NC \NR
+% \NC test \NC \input knuth \relax \NC \NR
+% \NC test \NC \input tufte \relax \NC \NR
+% \NC test \NC \input tufte \relax \NC \NR
+% \NC test \NC \input tufte \relax \NC \NR
+% \stoptabulate
+
+\def\splittabulatebox#1% #1 <> 0/2 / derived from the one in core-ntb.tex
+ {\ifinsidesplitfloat
+ \dosplittabulatebox#1%
+ \else\ifinsidefloat
+ \unvbox#1%
+ \else
+ \dosplittabulatebox#1%
+ \fi\fi}
+
+\def\dosplittabulatebox#1%
+ {\resettsplit
+ \def\tsplitminimumfreelines{2}%
+ \def\tsplitminimumfreespace{0pt}%
+ \setbox\tsplitcontent\box#1%
+ \ifcase\tabulaterepeathead\or
+ \setbox\tsplithead\vsplit\tsplitcontent to \lineheight
+ \setbox\tsplithead\vbox{\unvbox\tsplithead}%
+ \or
+ \setbox\tsplithead\vbox{\hbox{\strut\tabulateparameter\c!title}}%
+ \fi
+ \handletsplit}
+
+%D \starttyping
+%D \setuptabulate[split=no,rule=line]
+%D
+%D \starttabulate
+%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
+%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
+%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
+%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
+%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
+%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
+%D \stoptabulate
+%D \stoptyping
+
+% \starttabulatie[|mc|]
+% \NC \digits{100.000,00} \NC\NR
+% \NC \digits{@10.000,00} \NC\NR
+% \NC \digits{@@@.100,00} \NC\NR
+% \NC \digits{@@@.@10,@@} \NC\NR
+% \NC \digits{@@@.@@1,@@} \NC\NR
+% \stoptabulatie
+%
+% \starttabulatie[|mc|]
+% \ND 100.000,00 \NC\NR
+% \ND @10.000,00 \NC\NR
+% \ND @@@.100,00 \NC\NR
+% \ND @@@.@10,@@ \NC\NR
+% \ND @@@.@@1,@@ \NC\NR
+% \stoptabulatie
+%
+% \starttabulatie[|c|]
+% \ND $100.000,00$ \NC\NR
+% \ND $@10.000,00$ \NC\NR
+% \ND $@@@.100,00$ \NC\NR
+% \ND $@@@.@10,@@$ \NC\NR
+% \ND $@@@.@@1,@@$ \NC\NR
+% \stoptabulatie
+%
+% \starttabulatie[|c|]
+% \NC $\digits 100.000,00 $ \NC\NR
+% \NC $\digits @10.000,00 $ \NC\NR
+% \NC $\digits @@@.100,00 $ \NC\NR
+% \NC $\digits @@@.@10,@@ $ \NC\NR
+% \NC $\digits @@@.@@1,@@ $ \NC\NR
+% \stoptabulatie
+%
+% \starttabulatie[|c|]
+% \NC \digits $100.000,00$ \NC\NR
+% \NC \digits $@10.000,00$ \NC\NR
+% \NC \digits $@@@.100,00$ \NC\NR
+% \NC \digits $@@@.@10,@@$ \NC\NR
+% \NC \digits $@@@.@@1,@@$ \NC\NR
+% \stoptabulatie
+
+\def\setuptabulate
+ {\dotripleempty\dosetuptabulate}
+
+\def\dosetuptabulate[#1][#2][#3]%
+ {\ifthirdargument
+ \getparameters[\??tt#1::#2][#3]%
+ \else\ifsecondargument
+ \getparameters[\??tt#1::][#2]%
+ \else
+ \getparameters[\??tt\v!tabulate::][#1]%
+ \fi\fi}
+
+\setuptabulate
+ [\c!unit=1em,
+ EQ={:},
+ \c!frame=\v!off,
+ \c!bodyfont=,
+ \c!rule=\v!normal,
+ \c!rulecolor=,
+ \c!rulethickness=\linewidth,
+ \c!inner=,
+ \c!before=\blank,
+ \c!after=\blank,
+ \c!distance={\v!depth,\v!medium},
+ \c!align=\v!normal,
+ \c!margin=\!!zeropoint,
+ \c!split=\v!auto,
+ \c!header=\v!yes,
+ \c!title=,
+ \c!indenting=\v!no]
+
+\protect \endinput