%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 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 Table Macros / Tabulation} \unprotect \registerctxluafile{tabl-tbl.lua}{1.001} % experiment %D I can probably reimplement this using a \LUATEX\ combination %D but it does not pay of in development time. If I need something %D else I will write it from scratch anyway. %D %D I never really looked at the preamble code of TaBlE (at that time %D I simply didn't look into alignments too much) but there seem to %D be some similarities with the following code. So, maybe it's not %D too much work to rewrite that package in a more contexty style. If %D it makes sense to do that remains to be seen. We might as well %D drop it. %D %D Be careful with changing the hsize calculation in p mode; %D the following code works quite well: %D %D \starttyping %D \setupfield [line][location=low,height=1.2\lineheight,width=\hsize] %D \definefield [test] [line] [line] [] %D %D \starttabulate[|l|p|] %D \NC test \NC \field [test] \NC \NR %D \stoptabulate %D \stoptyping % |p2|p3| 2:3 -> spanning % % 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 skip left of column % j i skip right of column % k i skip around column % % C [C\L\M\R] {color} % % | {color,n} % % 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 % % \TL [width,color] bottom hrule % \FL [width,color] first hrule % \ML [width,color] mid hrule (with auto split) % \LL [width,color] bottom hrule % \BL [width,color] last hrule % % \HL [width,color] top rule % \VL [width,color] % % \CC \CL \CM \CR color % % \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 \noftabulatecolumns % set by parser \newcount \tabulateminplines \newcount \tabulatemaxplines \newif \iftracetabulate \newconditional \tabulatenopbreak \newconditional \tabulatefirstflushed \newconditional \tabulateequal \newconditional \tabulatesplit \settrue\tabulatesplit \newconditional \tabulateautomode \newconditional \tabulatehandlepbreak \settrue\tabulatehandlepbreak \newdimen \tabulatepwidth \newdimen \tabulatexwidth \newdimen \tabulatewidth \newdimen \tabulateunit \newdimen \tabulatemaxpheight \newskip \tabulatepreskip \newskip \tabulateposskip \newskip \firstpretabskip \newskip \lastposttabskip \newbox \tabulatebox \newtoks \everytabulaterow \newtoks \everytabulatepar \newtoks \everyaftertabulaterow \newtoks \everytabulate \newconditional \tabulateautorulespacing \settrue\tabulateautorulespacing \newcount \tabulatehasfirstrulespec % for the moment a count \newcount \tabulatehaslastrulespec % for the moment a count \newconditional \tabulatesomeamble \newconstant \tabulatepass \setnewconstant \tabulatesplitlinemode \plusone \newconstant \tabulatecolorspan \newconstant \tabulatelocalcolorspan \newdimen \defaulttabulatevrulethickness \newdimen \defaulttabulatehrulethickness \newdimen \tabulatevrulethickness \newdimen \tabulatehrulethickness \newdimen \tabulatelocalvrulethickness \newdimen \tabulatelocalhrulethickness \newskip \tabulateseparatorskip \newcount \maxtabularcolorcolumn \newif \iftolerantTABLEbreak % used in styles ! \newcount \tabulaterepeathead \newcount \noftabulatelines \newcount \totalnoftabulatelines \newcount \minusnoftabulatelines \newconstant \tabulatetype % 0 = NC column next EQ equal column % 1 = RC column raw RQ equal column raw % 2 = HC column hook HQ equal column hook % for old times sake: \def\handletabulatepbreakfalse{\setfalse\tabulatehandlepbreak} % depricated % handy helper \def\tabulatenoalign {\noalign \bgroup \let\noalign\relax \let\tabulatenoalign\relax \let\next=} \def\starttabulatenoalign {\tabulatenoalign\bgroup} \let\stoptabulatenoalign\egroup % [|lg{.}|] => \NG 12.34 \NC \gdef\handletabulatecharalign#1 % space delimited ! (will be redone in lua) {\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 {\tabulatenoalign{\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} \unexpanded\def\beforetabulateentry{\ignorespaces\tabulatehook} \unexpanded\def\aftertabulateentry {\unskip\unskip\ifmmode\else\endgraf\fi} \unexpanded\def\beginreshapedtabulatepar {\dowithnextbox {\ctxcommand{doreshapeframedbox(\number\nextbox)}\ifvmode\unvbox\else\box\fi\nextbox} \vbox\bgroup} \let\endreshapedtabulatepar\egroup \ifdefined\dotagtabulatecell \else \let\dotagtabulatecell \relax \fi \ifdefined\dotagtabulatesignal \else \let\dotagtabulatesignal\relax \fi \unexpanded\def\dochecklocaltabulatecolor#1#2% {\relax \ifx\currenttabulatelocalcolor\empty \gdef\currenttabulatecolor{#1}% \else \global\let\currenttabulatecolor\currenttabulatelocalcolor \global\let\currenttabulatelocalcolor\empty \fi \ifcase\tabulatelocalcolorspan \global\tabulatecolorspan#2\relax \else \global\tabulatecolorspan\tabulatelocalcolorspan \global\tabulatelocalcolorspan\zerocount \fi} \unexpanded\def\dochecklocaltabulatevrulecolor#1#2% {\relax \ifx\currenttabulatelocalvrulecolor\empty \gdef\currenttabulatevrulecolor{#1}% \else \global\let\currenttabulatevrulecolor\currenttabulatelocalvrulecolor \global\let\currenttabulatelocalvrulecolor\empty \fi \ifcase\tabulatelocalvrulethickness \global\tabulatevrulethickness#2\relax \else \global\tabulatevrulethickness\tabulatelocalvrulethickness \global\tabulatelocalvrulethickness\zeropoint \fi} \unexpanded\def\dotabulatepreskip#1% {\ifdim#1>\zeropoint \hskip#1\relax \else\ifnum\tabulatecolumn=\zerocount \ifconditional\tabulateautorulespacing \ifcase\tabulatehasfirstrulespec\else \hskip\firstpretabskip\relax \fi \fi \fi\fi} \unexpanded\def\dotabulatepostskip#1% {\ifdim#1>\zeropoint \hskip#1\relax \else\ifnum\tabulatecolumns=\noftabulatecolumns \ifconditional\tabulateautorulespacing \ifcase\tabulatehaslastrulespec\else \hskip\lastposttabskip\relax \fi \fi \fi\fi} \def\dodosettabulatepreamble#1#2#3% only makes sense for many tabulates {\normalexpanded{\tabulatepreamble{\the\tabulatepreamble \dochecklocaltabulatevrulecolor{\currenttabulatevrulecolor}{\the\tabulatevrulethickness}% \dochecklocaltabulatecolor{\currenttabulatecolor}{\number\tabulatecolorspan}% \dorightsidetabulatecolor \aligntab \dotabulatevrule \doleftsidetabulatecolor \dotabulatepreskip{\the\tabulatepreskip}% \alignmark\alignmark \aligntab \dobothsidetabulatecolor \global\tabulatecolorspan\zerocount \global\tabulatecolumn\the\tabulatecolumns\relax \checktabulatesetups % unexpandable \checktabulatehook % unexpandable \ifzeropt\tabulatewidth \ifcase\tabulatemodus\else \noexpand\settrue\noexpand\tabulateautomode \fi \else \ifnum\tabulatemodus=\zerocount \hbox to \else \hsize \fi \the\tabulatewidth \fi \bgroup \noexpand\bbskip \bgroup % we cannot combine the if because a cell may have only one ## \tabulatealign\number#1\relax % needed in tag passing \noexpand\dostarttagged\noexpand\t!tabulatecell\noexpand\empty \noexpand\dotagtabulatecell \noexpand#2% \ifcase\tabulatereshape\else \beginreshapedtabulatepar \fi \dotagtabulatesignal % empty cells .. todo (can be removed as soon as build) \noexpand\ifnum\noexpand\tabulatetype=\plusone\noexpand\else \the\tabulatebmath % maybe later? can interfere with char 0 \the\tabulatefont \the\tabulatesettings \the\tabulatebefore \noexpand\fi % grouping needs to be outside macros (or expandable), nice test % example \NC \string \aligntab \NC which will fail otherwise (mk) \bgroup \beforetabulateentry \alignmark\alignmark \aftertabulateentry \egroup \noexpand\ifnum\noexpand\tabulatetype=\plusone\noexpand\else \the\tabulateafter \the\tabulateemath \noexpand\fi \ifcase\tabulatereshape\else \endreshapedtabulatepar \fi \noexpand#3% % \noexpand\dostoptagged \egroup \egroup \aligntab \noexpand\dostoptagged \dotabulatepostskip{\the\tabulateposskip}% \alignmark\alignmark }}% \appendtoks\NC\to\tabulatedummy \tabulatepreskip.5\tabulateunit\relax \ifnum\tabulatecolumns<\numexpr\noftabulatecolumns-\plusone\relax \tabulateposskip\tabulatepreskip \else \tabulateposskip\zeropoint \fi %\let\gettabulateexit\dogettabulateexit % still needed ? \tabulatewidth\zeropoint} \newcount\tabulatealign \setvalue{\??tt>\meaning x}{\tabulatealign\zerocount\settabulatepreamble} % internal \setvalue{\??tt>\meaning l}{\tabulatealign\plusone\settabulatepreamble} \setvalue{\??tt>\meaning r}{\tabulatealign\plustwo\settabulatepreamble} \setvalue{\??tt>\meaning c}{\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 e}{\appendtoks\global\settrue\tabulateequal\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>\meaning C}{\doparsecolortabulate} \setvalue{\??tt>\s!unknown }{\message{unknown preamble key [\meaning\next]}\settabulatepreamble} \setvalue{\??tt>\meaning\relax}{} \def\dosettabulatepreamble {\csname\??tt>\ifcsname\??tt>\meaning\next\endcsname\meaning\next\else\s!unknown\fi\endcsname} \def\gettabulatepreskip#1% {\doifnumberelse{#1} {\tabulatepreskip#1\tabulateunit\let\next\empty} {\tabulatepreskip.5\tabulateunit\def\next{#1}}% \@EA\settabulatepreamble\next} \def\gettabulateposskip#1% {\doifnumberelse{#1} {\tabulateposskip#1\tabulateunit\let\next\empty} {\tabulateposskip.5\tabulateunit\def\next{#1}}% \@EA\settabulatepreamble\next} \def\gettabulatepreposskip#1% {\doifnumberelse{#1} {\tabulatepreskip#1\tabulateunit\let\next\empty} {\tabulatepreskip.5\tabulateunit\def\next{#1}}% \tabulateposskip\tabulatepreskip \@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 \settrue\tabulatenopbreak, \v!auto=>\let\tabulatemodus\plusthree \let\tabulatereshape\plusone, \s!unknown=>\tabulatewidth#1\relax]% \ifnum\tabulatedimen=\plusone \global\advance\tabulatepwidth\tabulatewidth % accumulated parwidth \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\tabulatealign\empty \tabulatehss \or \dodosettabulatepreamble\tabulatealign\empty \tabulatehss \or \dodosettabulatepreamble\tabulatealign\tabulatehss\empty \or \dodosettabulatepreamble\tabulatealign\tabulatehss\tabulatehss \fi} \def\tabulatesetpreamblewidthfixed {\ifcase\tabulatealign\relax \dodosettabulatepreamble\tabulatealign\bskip \eskip \or \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedright \eskip \or \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedleft \eskip \or \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedcenter\eskip \fi} \def\tabulatesetpreamblewidthauto {\global\advance\nofautotabulate\plusone \ifcase\tabulatealign\relax \dodosettabulatepreamble\tabulatealign\bskip \eskip \or \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedright \eskip \or \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedleft \eskip \or \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedcenter\eskip \fi} \def\tabulatesetpreamblewidthsimple {\dodosettabulatepreamble\tabulatealign\xbskip\xeskip} \def\doparsecolortabulate#1#2% {\gdef\currenttabulatecolor{#2}% \global\tabulatecolorspan\if#1L\plusone\else\if#1M\plustwo\else\if#1R\plusthree\else\zerocount\fi\fi\fi\relax \settabulatepreamble} \def\dotabulatevrulecommand#1% {\doifnumberelse{#1} {\global\tabulatevrulethickness#1\defaulttabulatevrulethickness} {\xdef\currenttabulatevrulecolor{#1}}} \def\settabulateentry#1#2% rulespec template {\tabulatealign\@@tabulatealign \let\tabulatemodus\zerocount \let\tabulatedimen\zerocount \let\tabulatereshape\zerocount \tabulatebefore\emptytoks \tabulateafter\emptytoks \tabulatebmath\emptytoks \tabulateemath\emptytoks \tabulatefont\emptytoks \tabulatesettings\emptytoks \global\let\currenttabulatecolor\empty \global\let\currenttabulatevrulecolor\empty \global\tabulatecolorspan\zerocount \global\advance\tabulatecolumns\plusone % == #1 \expandafter\let\csname\??tt:s:\the\tabulatecolumns\endcsname\donothing \edef\currenttabulatetrulespec{#1}% \ifx\currenttabulatetrulespec\empty \global\tabulatevrulethickness\zeropoint \else \global\tabulatevrulethickness\defaulttabulatevrulethickness \rawprocesscommalist[#1]\dotabulatevrulecommand \fi \settabulatepreamble#2\relax\relax % permits i without n \ifcase\tabulatemodus\relax \tabulatesetpreamblewidthnormal \or % fixed width \tabulatesetpreamblewidthfixed \or % auto width \tabulatesetpreamblewidthauto \or % simple \tabulatesetpreamblewidthsimple \fi} \def\setlasttabulateentry#1% rulespec {\global\let\currenttabulatevrulecolor\empty \rawprocesscommalist[#1]\dotabulatevrulecommand \ifx\currenttabulatetrulespec\empty \global\tabulatevrulethickness\zeropoint \else \global\tabulatevrulethickness\defaulttabulatevrulethickness \rawprocesscommalist[#1]\dotabulatevrulecommand \fi \normalexpanded{\tabulatepreamble{\the\tabulatepreamble \dochecklocaltabulatevrulecolor{\currenttabulatevrulecolor}{\the\tabulatevrulethickness}% \dotabulatevrule}}} \def\donormalizetabulatesplitline {\ifcase\tabulatesplitlinemode % nothing \or \ht\tabulatebox\strutht \dp\tabulatebox\strutdp \or \ifdim\ht\tabulatebox<\strutht \ht\tabulatebox\strutht \fi \ifdim\dp\tabulatebox<\strutdp \dp\tabulatebox\strutdp \fi \fi} \def\flushtabulatesplitbox {\box\tabulatebox} \newconditional\splitofftabulatewhitespace \newdimen\splitofftabulatebetweenskip \def\flushtabulatewhitespace {\ifdim\splitofftabulatebetweenskip>\zeropoint \vskip\splitofftabulatebetweenskip \global\splitofftabulatebetweenskip\zeropoint \fi} \def\checktabulatewhitespace {\setbox\scratchbox\vbox {\splitdiscards \unskip \ifdim\lastskip>\splitofftabulatebetweenskip \global\splitofftabulatebetweenskip\lastskip \fi}} \def\splitofftabulatebox {\dontcomplain \global\setbox\tabulatebox\vsplit\tablebox\tabulatecolumn to \lineheight % % % global ? % % % \setbox\tabulatebox\vbox {\unvbox\tabulatebox}% \ifconditional\splitofftabulatewhitespace \checktabulatewhitespace \fi \setbox\tabulatebox\hbox to \wd\tabulatebox {\iftrialtypesetting\else\ifconditional\tabulatehascolors\repeatsettabulatecolor\fi\fi \hss\dotabulatehook{\box\tabulatebox}\hss}% \donormalizetabulatesplitline \flushtabulatesplitbox} \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\dohandletabulatepbreak {\ifconditional\tabulatehandlepbreak \ifconditional\tabulatenopbreak \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 % overloads previous {\starttabulatenoalign \dohandletabulatepbreak \ifconditional\splitofftabulatewhitespace \flushtabulatewhitespace \fi \stoptabulatenoalign} %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|] % todo: commandhandler \def\definetabulate {\dotripleempty\dodefinetabulate} \def\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!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]% \setuvalue{\e!start#1::#2}{\dofinalstarttabulate[#1][#2][#3]}% \setuvalue{\e!start#1}{\bgroup\dosubstarttabulate[#1]}% \letvalueempty{\??tt#1-\v!header}% \letvalueempty{\??tt#1-\v!footer}% \else\ifsecondargument \definetabulate[#1][][#2]% \else \definetabulate[#1][][|l|p|]% \fi\fi} \let\tabulateheadcontent\empty \let\tabulatetailcontent\empty \def\processtabulateheadcontent {\tabulatenoalign{\global\settrue\tabulatesomeamble}% \csname\??tt\currenttabulate-\v!header\endcsname \tabulatenoalign{\global\setfalse\tabulatesomeamble}}% \def\processtabulatetailcontent {\tabulatenoalign{\global\settrue\tabulatesomeamble}% \csname\??tt\currenttabulate-\v!footer\endcsname \tabulatenoalign{\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 \removefunnytabulateline} \def\removefunnytabulateline {\ifhmode \strut\crcr \tabulatenoalign{\kern-\lineheight}% \fi} \setuvalue{\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}} \setuvalue{\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} \setuvalue{\e!start\v!tabulate}% {\bgroup % whole thing \dodoubleempty\donormalstarttabulate} \def\doinhibitnestedtabulate {\setuvalue{\e!start\v!tabulate}% {\em Nested tabulate is not (yet) supported.\relax \expandafter\gobbleuntil\csname\e!stop\v!tabulate\endcsname}} \appendtoks \doinhibitnestedtabulate \to \everytabulate \setuvalue{\e!stop\v!tabulate }{} \setuvalue{\e!stop\v!tabulatehead}{} \setuvalue{\e!stop\v!tabulatetail}{} \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} % The much needed hook: % \appendtoks \optimizeverbatimfalse \to \everytabulate % Todo: proper inheritance \def\tabulateparameter#1{\csname\??tt\currenttabulate#1\endcsname} \setvalue{\??tt:\c!split:\v!yes }{\settrue\tabulatesplit} \setvalue{\??tt:\c!split:\v!repeat}{\settrue\tabulatesplit} \setvalue{\??tt:\c!split:\v!no }{\setfalse\tabulatesplit} \setvalue{\??tt:\c!split:\v!auto }{\ifinsidefloat\ifinsidesplitfloat\else\setfalse\tabulatesplit\fi\fi} \def\dofinalstarttabulate[#1][#2][#3]% identifier sub preamble {\edef\currenttabulate{#1::#2}% \ifinsidefloat \else \whitespace \tabulateparameter\c!before \fi \bgroup % settings \resetcharacteralign % todo: spacing around tabulate when bodyfont is set % expansion en test needed ? \settrue\tabulatesplit \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 \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 \processcontent{\e!stop#1}\tabulatecontent{\processtabulate[#3]}} % \currenttabulate \def\tabulateEQ {\ifconditional\tabulatefirstflushed\else\tabulateparameter{EQ}\fi \global\setfalse\tabulateequal} % The next ones will be token registers \let\tabulatenormalpos\relax \let\tabulateequalpos \relax % color columns \glet\previoustabulatecolor \empty \glet\currenttabulatecolor \empty \glet\currenttabulatelocalcolor \empty \glet\currenttabulatevrulecolor \empty \glet\currenttabulatelocalvrulecolor\empty \appendtoks \glet\previoustabulatecolor \empty \glet\currenttabulatecolor \empty \glet\currenttabulatelocalcolor \empty \glet\currenttabulatevrulecolor \empty \glet\currenttabulatelocalvrulecolor\empty \global\tabulatelocalvrulethickness \zeropoint \to \everytabulaterow \unexpanded\def\dorightsidetabulatecolor {\iftrialtypesetting\else \ifx\previoustabulatecolor\empty \else \settabulatecolor\previoustabulatecolor \glet\previoustabulatecolor\empty \fi \fi} \unexpanded\def\doleftsidetabulatecolor {\iftrialtypesetting\else \ifx\currenttabulatecolor\empty \else \ifcase\tabulatecolorspan \or \settabulatecolor\currenttabulatecolor \or \settabulatecolor\currenttabulatecolor \fi \fi \fi} \unexpanded\def\dobothsidetabulatecolor {\iftrialtypesetting\else \ifx\currenttabulatecolor\empty \else \settabulatecolor\currenttabulatecolor \ifcase\tabulatecolorspan %\glet\previoustabulatecolor\empty \or \glet\previoustabulatecolor\empty \or \glet\previoustabulatecolor\currenttabulatecolor \or \glet\previoustabulatecolor\currenttabulatecolor \fi \fi \fi} \def\tabulatecolorcolumn#1% overloaded {\unskip \doiffastoptionalcheckelse{\tabulatecolorcolumnyes#1}{\tabulatecolorcolumnnop#1}} \def\tabulatecolorcolumnnop {\tabulatenormalcolumn} \def\tabulatecolorcolumnyes#1[#2]% {\xdef\currenttabulatelocalcolor{#2}% \tabulatenormalcolumn#1} % normal columns: \def\tabulatenormalcolumn#1% {\unskip \aligntab \ifconditional\tabulateequal\tabulateequalpos\else\tabulatenormalpos\fi \aligntab \global\tabulatetype#1% \aligntab} % equal columns \def\tabulateequalcolumn#1% overloaded {\unskip \aligntab \tabulateequalpos \aligntab\global\tabulatetype#1% \aligntab} % ruled columns \def\tabulatevruledcolumn#1% {\unskip % 0-n \ifnum\tabulatecolumn=\plusone \global\tabulatehasfirstrulespec\plusone \else\ifnum\tabulatecolumn=\noftabulatecolumns \global\tabulatehaslastrulespec\plusone \fi\fi \global\let\currenttabulatelocalvrulecolor\defaulttabulatevrulecolor \global\tabulatelocalvrulethickness\defaulttabulatevrulethickness \doiffastoptionalcheckelse{\tabulatevruledcolumnyes#1}{\tabulatevruledcolumnnop#1}} \def\tabulatevruledcolumnnop {\tabulatenormalcolumn} \def\dotabulatevrulelocalcommand#1% {\doifnumberelse{#1} {\global\tabulatelocalvrulethickness#1\defaulttabulatevrulethickness} {\xdef\currenttabulatelocalvrulecolor{#1}}} \def\tabulatevruledcolumnyes#1[#2]% {\rawprocesscommalist[#2]\dotabulatevrulelocalcommand \tabulatenormalcolumn#1} \def\donormaltabulatevrule {\vrule\!!width\tabulatevrulethickness\relax} \def\docoloredtabulatevrule {\faststartcolor[\currenttabulatevrulecolor]% \vrule\!!width\tabulatevrulethickness\relax \faststopcolor} \unexpanded\def\dotabulatevrule {\ifcase\tabulatevrulethickness\else \iftrialtypesetting \donormaltabulatevrule \else\ifx\currenttabulatevrulecolor\empty \donormaltabulatevrule \else \docoloredtabulatevrule \fi\fi \fi \global\tabulatevrulethickness\zeropoint} % nils second one % auto columns \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} \setvalue{\??tt:rs:\v!blank }{\tabulateseparatorskip\bigskipamount} \setvalue{\??tt:rs:\v!depth }{\tabulateseparatorskip\strutdp} \setvalue{\??tt:rs:\v!small }{\def\factor{.25}} \setvalue{\??tt:rs:\v!medium}{\def\factor{.5}} \setvalue{\??tt:rs:\v!big }{} \setvalue{\??tt:rs:\v!none }{\tabulateseparatorskip\zeropoint\def\factor{0}} \setvalue{\??tt:rs:\v!grid }{\tabulateseparatorskip\zeropoint\def\factor{0}} \def\dodotabulateruleseparator#1% {\ifcsname\??tt:rs:#1\endcsname \csname\??tt:rs:#1\endcsname \else \tabulateseparatorskip#1\relax \fi} \def\dotabulateruleseparator % can be sped up (will do when used frequently) {\bgroup \edef\tabulateseparatordistance{\tabulateparameter\c!distance}% \tabulateseparatorskip\strutdp \ifx\tabulateseparatordistance\empty\else \let\factor\!!plusone \normalexpanded{\processcommalist[\tabulateparameter\c!distance]}\dodotabulateruleseparator \tabulateseparatorskip\factor\tabulateseparatorskip \fi \ifconditional\tabulatesomeamble\kern\else\vskip\fi\tabulateseparatorskip % new \egroup} \def\tabulateignorehrulespec#1% {%\global\let\currenttabulatelocalhrulecolor\empty %\global\tabulatelocalhrulethickness\defaulttabulatehrulethickness \doiffastoptionalcheckelse#1#1} \def\tabulatepickuphrulespec#1% {\global\let\currenttabulatelocalhrulecolor\defaulttabulatehrulecolor \global\tabulatelocalhrulethickness\defaulttabulatehrulethickness \doiffastoptionalcheckelse{\tabulatepresethrule#1}#1} \def\dotabulatehrulelocalcommand#1% {\doifnumberelse{#1} {\global\tabulatelocalhrulethickness#1\defaulttabulatehrulethickness} {\xdef\currenttabulatelocalhrulecolor{#1}}} \def\tabulatepresethrule#1[#2]% {\rawprocesscommalist[#2]\dotabulatehrulelocalcommand #1} \def\donormaltabulatehrule {\hrule \!!height.5\tabulatelocalhrulethickness \!!depth .5\tabulatelocalhrulethickness \relax} \def\docoloredtabulatehrule {\faststartcolor[\currenttabulatelocalhrulecolor]% \donormaltabulatehrule \faststopcolor} \unexpanded\def\dotabulatehrule {\ifcase\tabulatelocalhrulethickness\else \iftrialtypesetting % does not happen as we nil the caller \donormaltabulatehrule \else\ifx\currenttabulatelocalhrulecolor\empty \donormaltabulatehrule \else \docoloredtabulatehrule \fi\fi \fi} \def\donormaltabulatehlinerule {\leaders \hrule \!!height\dimexpr.5\lineheight-\strutdepth \!!depth-\dimexpr.5\lineheight-\strutdepth+\tabulatelocalhrulethickness \hfill} \def\docoloredtabulatehlinerule {\faststartcolor[\currenttabulatelocalhrulecolor]% \donormaltabulatehlinerule \faststopcolor} \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\relax % new august 2003 \ifcase\tabulatelocalhrulethickness\else \iftrialtypesetting % does not happen as we nil the caller \donormaltabulatehlinerule \else\ifx\currenttabulatelocalhrulecolor\empty \donormaltabulatehlinerule \else \docoloredtabulatehlinerule \fi\fi \fi \cr} %D Color: % \starttabulate[||p||] % \NC test \NC test \NC test \NC \NR % \NC test \NC[green] \input tufte \NC[yellow] test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC[blue] test \NC[red] test \NC test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC test \NC[gray] test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC[blue] test \NC test \NC test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC test \NC[magenta] test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC[cyan] \dorecurse{10}{\input ward }\NC test \NC \NR % \NC test \NC test \NC test \NC \NR % \NC test \NC[yellow] test \NC test \NC \NR % \stoptabulate \unexpanded\def\settabulatecolor#1% we could store the attributes at the cost of a lua call {\begingroup \doinitializeboxbackgrounds \global\settrue\tabulatehascolors \ifnum\tabulatecolumn>\maxtabularcolorcolumn \global\maxtabularcolorcolumn\tabulatecolumn \fi \setxvalue{\??tt:c:\the\tabulatecolumn}{#1}% \attribute\backgroundattribute\plusone \faststartcolor[#1]\strut\char0\faststopcolor \endgroup} \def\repeatsettabulatecolor {\begingroup \ifcsname\??tt:c:\the\tabulatecolumn\endcsname \attribute\backgroundattribute\plusone \faststartcolor[\csname\??tt:c:\the\tabulatecolumn\endcsname]\strut\char0\faststopcolor \fi \endgroup} \def\resettabulatecolors {\ifcase\maxtabularcolorcolumn\else \doresettabulatecolors \fi} \def\doresettabulatecolors {\dorecurse\maxtabularcolorcolumn{\letgvalue{\??tt:c:\recurselevel}\undefined}} % slow \appendtoks \resettabulatecolors \to \everyaftertabulaterow \appendtoks \global\setfalse\tabulatehascolors \to \everytabulate %D When set to true, no (less) break optimization is done. %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 \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. \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} \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 % todo: mkiv {\vskip-\prevdepth+\strutdp+\strutdp\relax}% \baselinecorrection} \unexpanded\def\tabulateVLone{\tabulatevruledcolumn\zerocount} \unexpanded\def\tabulateNCone{\tabulatenormalcolumn\zerocount} \unexpanded\def\tabulateRCone{\tabulatenormalcolumn\plusone} \unexpanded\def\tabulateHCone{\tabulatenormalcolumn\plustwo} \unexpanded\def\tabulateEQone{\tabulateequalcolumn \zerocount} \unexpanded\def\tabulateRQone{\tabulateequalcolumn \plusone} \unexpanded\def\tabulateHQone{\tabulateequalcolumn \plustwo} \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\tabulateCCone{\global\tabulatelocalcolorspan\zerocount\tabulatecolorcolumn\zerocount} \unexpanded\def\tabulateCLone{\global\tabulatelocalcolorspan\plusone \tabulatecolorcolumn\zerocount} \unexpanded\def\tabulateCMone{\global\tabulatelocalcolorspan\plustwo \tabulatecolorcolumn\zerocount} \unexpanded\def\tabulateCRone{\global\tabulatelocalcolorspan\plusthree\tabulatecolorcolumn\zerocount} \unexpanded\def\tabulateNRone % next row {\global\advance\noftabulatelines\plusone \global\setfalse\tabulatefirstflushed \global\setfalse\tabulateequal \global\tabulatecolumn\zerocount \resettabulatepheight \unskip\unskip\crcr\flushtabulated \starttabulatenoalign \the\everyaftertabulaterow \checktabulatepenaltiesa \stoptabulatenoalign} \def\checktabulatepenaltiesa {\iftolerantTABLEbreak\else \ifnum\totalnoftabulatelines=\plusone % \allowbreak \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 \fi \global\setfalse\tabulatefirstflushed} \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 % first line \global\setbox\tablebox\tabulatecolumn\vbox \bgroup \glet\tabulatehook\notabulatehook \ifconditional\tabulateautomode\hsize\tabulatewidth\fi % \begstrut % interferes with pre-\pars % evt: \appendtoks\begstrut\to\everypar \ignorespaces \let\eskip\tabulatebskiptwoeskip \else % successive lines \let\eskip\empty \dontcomplain \glet\tabulatehook\dotabulatehook \expandafter\splitofftabulatebox \fi} \def\tabulatexbskiptwo{\bskip} \def\tabulatexeskiptwo{\eskip} \def\dotabulateflushtabulatedtwo {\glet\flushtabulatedindeed\empty \global\tabulatecolumn\zerocount \handletabulatepbreak \dorecurse\tabulatecolumns % was: \noftabcolumns {\ifvoid\tablebox\recurselevel\else \gdef\flushtabulatedindeed{\the\tabulatedummy}% \fi}% \global\settrue\tabulatefirstflushed} \def\tabulateflushtabulatedtwo {\tabulatenoalign{\dotabulateflushtabulatedtwo}% \flushtabulatedindeed} \def\tabulatebskipthree {\vtop\bgroup \ifconditional\tabulateautomode\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} % see *** % % \enabletrackers[nodes.page_vspacing] % \starttext % \starttabulate[||] \dorecurse{100}{\NC Eins \NC \NR \HL} \stoptabulate % \stoptext % old crap: % % \ifnum\noftabulatelines>\plusone % \ifnum\noftabulatelines<\minusnoftabulatelines % % *** somehow topskip messes up as it's intercepted % % \vskip \topskip\allowbreak\vskip- \topskip % % messy anyhow so this needs to be improved, so for % % the moment we keep this bugged variant % \vskip1\topskip % \allowbreak % \vskip-1\topskip \def\tabulateXXnone{\starttabulatenoalign\tabulateignorehrulespec\stoptabulatenoalign} \def\tabulateFLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateFLfive} \def\tabulateMLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateMLfive} \def\tabulateLLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateLLfive} \def\tabulateTLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateTLfive} \def\tabulateBLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateBLfive} %def\tabulateHLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateHLfive} % we can use one common spec: (saves 4 macros) % % \def\dotabulatecheckhrulespec#1% % {\iftrialtypesetting % \expandafter\tabulateignorehrulespec\expandafter\stoptabulatenoalign % \else % \expandafter\tabulatepickuphrulespec\expandafter\dotabulateFLfive % \fi} \unexpanded\def\dotabulateFLfive {\ifinsidefloat\else \doifemptyvalue{\??tt\currenttabulate\c!before} % no expansion {\tabulatebaselinecorrection}% \fi \dotabulatehrule \dotabulatenobreak \dotabulateruleseparator \prevdepth\strutdp \dotabulatenobreak \stoptabulatenoalign} \unexpanded\def\dotabulateMLfive {\dotabulateruleseparator \dotabulatehrule \vskip-\tabulateparameter\c!rulethickness \dotabulatehrule \nobreak \dotabulateruleseparator \stoptabulatenoalign} \unexpanded\def\dotabulateLLfive {\dotabulatenobreak \dotabulateruleseparator \dotabulatenobreak \dotabulatehrule \ifinsidefloat\else \doifemptyvalue{\??tt\currenttabulate\c!after} % no expansion {\vskip\strutdp \verticalstrut \vskip-\struttotal}% \fi \stoptabulatenoalign} \unexpanded\def\dotabulateTLfive {\dotabulatenobreak \dotabulateruleseparator \dotabulatenobreak \dotabulatehrule \dotabulatenobreak \dotabulateruleseparator %\prevdepth\strutdp % todo, might differ between TL and BL \dotabulatenobreak \stoptabulatenoalign} \let\dotabulateBLfive\dotabulateTLfive \def\tabulateHLfive {\csname \ifnum\noftabulatelines=\zerocount F\else \ifnum\noftabulatelines=\totalnoftabulatelines L\else M\fi\fi L\endcsname} \def\tabulatedoHRfive % horizontal rule line (break untested) {\starttabulatenoalign \globallet\dotabulateautoline\dotabulatelinerule %\ifcase#1\or % todo: check what this does \ifnum\noftabulatelines=\zerocount \glet\dotabulateautoline\donothing \else\ifnum\noftabulatelines=\totalnoftabulatelines \glet\dotabulateautoline\donothing \fi\fi %\fi \dotabulatenobreak \stoptabulatenoalign \dotabulateautoline \starttabulatenoalign \nobreak \ifx\dotabulateautoline\dotabulatelinerule\kern-\lineheight\fi \ifnum\noftabulatelines=\totalnoftabulatelines \@EA\dotabulatenobreak \else \@EA\allowbreak \fi \stoptabulatenoalign \dotabulateautoline \starttabulatenoalign \dotabulatenobreak \stoptabulatenoalign} % \dorecurse{10}{ % \starttabulate[|l|] % \FL % \NC first line, bound to next rule \NC \NR % \TL % \NC bound to previous rule \NC \NR % \NC some line \NC \NR % \NC some line \NC \NR % \NC some line \NC \NR % \NC bound to next rule \NC \NR % \ML % \NC bound to previous rule \NC \NR % \NC bound to next rule \NC \NR % \BL % \NC last line, bound to previous rule \NC \NR % \LL % \stoptabulate % } % to be redone \def\tabulaterule {\HR} % a rule with lineheight \def\tabulateline {\HL} % just a spaced rule \def\tabulateautorule{\HR}% \def\tabulateautoline{\HL} % no longer different (to be looked into) % When support for vertical rules we needed a way to pick up the % specification for the final rule and a \type {|{}} interface was % chosen. As a result parsing had to become more complex and I was % not in the mood for messing up the code too much. Therefore from % now on the preamble is split by \LUA. There are definitely more % places where we can use \LUA\ code (for instance in alignment of % numbers. The repeat parser is replace at the \LUA\ end as well. \gdef\processtabulate[#1]% in the process of optimizing {\tabulateunit\tabulateparameter\c!unit \checkfulltabulatecontent \defaulttabulatevrulethickness\tabulateparameter\c!rulethickness \defaulttabulatehrulethickness\tabulateparameter\c!rulethickness \edef\defaulttabulatevrulecolor{\tabulateparameter\c!rulecolor}% \edef\defaulttabulatehrulecolor{\tabulateparameter\c!rulecolor}% \edef\@@tabulatealign{\executeifdefined{\??tt:\c!align:\tabulateparameter\c!align}0}% \tabulateposskip.5\tabulateunit \tabulatepreskip\zeropoint \firstpretabskip\tabulateposskip \lastposttabskip\tabulateposskip \global\tabulatecolumns\zerocount \global\nofautotabulate\zerocount \global\noftabulatelines\zerocount \totalnoftabulatelines\noftabulatelines \minusnoftabulatelines\noftabulatelines \global\tabulatepwidth\zeropoint \global\tabulatexwidth\zeropoint \global\setfalse\tabulateequal \resettabulatepheight \ifinsidesplitfloat \donetrue \else\ifinsidefloat \donefalse \else \donetrue \fi\fi \ifdone \tabulaterepeathead\executeifdefined{\??tt:\c!header:\tabulateparameter\c!header}\zerocount \fi \let\VL\tabulateVLone \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\NR\tabulateNRone \let\CC\tabulateCCone \let\CL\tabulateCLone \let\CM\tabulateCMone \let\CR\tabulateCRone \let\SR\NR \let\FR\NR \let\MR\NR \let\LR\NR \let\AR\NR \let\FL\tabulateXXnone \let\ML\tabulateXXnone \let\LL\tabulateXXnone \let\TL\tabulateXXnone \let\BL\tabulateXXnone \let\HL\tabulateXXnone \let\HR\tabulateXXnone \glet\flushtabulated\empty \tabskip\zeropoint \ifdim\tabulateparameter\c!margin>\zeropoint \tabulatepreamble{\aligntab\flushtabulateindent\strut\alignmark\alignmark\tabskip\tabulateparameter\c!margin\strut\aligntab\alignmark\alignmark\tabskip\zeropoint}% \else \tabulatepreamble{\aligntab\flushtabulateindent\strut\alignmark\alignmark\aligntab\alignmark\alignmark\tabskip\zeropoint}% \fi \tabulatewidth\zeropoint \ctxcommand{presettabulate(\!!bs\detokenize{#1}\!!es)}% \edef\totaltabulatecolumns{\the\numexpr3*\tabulatecolumns+4}% \tabulatewidth\zeropoint \initializetableboxes\tabulatecolumns \appendtoks\aligntab\alignmark\alignmark\global\advance\tabulatecolumn\plusone\to\tabulatepreamble \appendtoks\NC\unskip\unskip\crcr\flushtabulated\to\tabulatedummy % no count \global\tabulatecolumn\zerocount \resettabulatepheight \let\bbskip\empty %\let\eeskip\empty \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 preceding \forgetparindent probably bug, to be solved \everypar\everytabulatepar \setbox0\vbox % outside \if because of line counting {\notesenabledfalse \let\tabulateindent\!!zeropoint \settrialtypesetting % very important \@EA\halign\@EA{\the\tabulatepreamble\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-\tabulatexwidth\relax \ifnum\nofautotabulate>\zerocount \divide\tabulatewidth \nofautotabulate\relax \fi \fi \let\xbskip\tabulatexbskiptwo \let\xeskip\tabulatexeskiptwo \ifconditional\tabulatesplit \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\FL\tabulateFLfive \let\ML\tabulateMLfive \let\LL\tabulateLLfive \let\TL\tabulateTLfive \let\BL\tabulateBLfive \let\HL\tabulateHLfive \let\HR\tabulateHRfive \doifvalue{\??tt\currenttabulate\c!rule}\v!line {\let\HL\HR \let\tabulateautoline\tabulateautorule \let\tabulateline\tabulaterule}% \tabulatepass\plustwo % \ifcase\tabulaterepeathead \ifinsidesplitfloat \global\setbox\tabulatebox\vbox \bgroup \else \startframedcontent[\tabulateparameter\c!frame]% \fi \else \global\setbox\tabulatebox\vbox \bgroup \fi % \dostarttagged\t!tabulate\empty \dostarttagged\t!tabulaterow\empty \appendtoks\dostoptagged\dostarttagged\t!tabulaterow\empty\to\everycr \@EA\halign\@EA{\the\tabulatepreamble\crcr\fulltabulatecontent\crcr}% \dostoptagged \dostoptagged \ifhmode\par\prevdepth\strutdp\fi % nog eens beter, temporary hack \doifvalue{\??tt\currenttabulate\c!distance}\v!grid{\vskip-\strutdp}% experimental tm-prikkels % \ifcase\tabulaterepeathead \ifinsidesplitfloat \egroup % box \egroup % settings \splittabulatebox\tabulatebox \else \stopframedcontent \egroup \fi \else \egroup % box \egroup % settings \splittabulatebox\tabulatebox \fi % \ifinsidefloat \else \tabulateparameter\c!after \fi \egroup} % whole thing % \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 %D Spacing: % % \starttabulate % \NC text \NC text \NC \NR % \TB[small] % \NC text \NC text \NC \NR % \TB[4*big] % \NC text \NC text \NC \NR % \stoptabulate \def\TabulateTB {\starttabulatenoalign \dosingleempty\doTabulateTB} \def\doTabulateTB[#1]% {\iffirstargument \blank[#1] \else \blank \fi \stoptabulatenoalign} % to be tested: % % \def\TabulateTB % {\starttabulatenoalign % \doiffastoptionalcheckelse\doTabulateTByes\doTabulateTBnop} % % \def\doTabulateTByes[#1]% % {\blank[#1] % \stoptabulatenoalign} % % \def\doTabulateTBnop[#1]% % {\blank % \stoptabulatenoalign} \appendtoks\let\TB\TabulateTB\to\everytabulate %D Some new trickery: %D %D \startbuffer %D \settrue\splitofftabulatewhitespace %D %D \starttabulate[|p(2cm)|p(2cm)|p(2cm)|] %D \NC test 1a \NC test 2a \NC test 3a %D \par %D test 3b \NC \NR %D \NC test 1a \NC test 2a \NC test 3a %D \blank[line] %D test 3b \NC \NR %D \NC test 1a \NC test 2a \NC test 3a %D \blank[halfline] %D test 3b %D \blank[halfline] %D test 3c \NC \NR %D \NC \blank \NC \blank \NC \blank \NC \NR %D \NC test 1a \NC test 2a \NC test 3a %D \blank[halfline] %D test 3b %D \blank[halfline] %D test 3c \NC \NR %D \NC \blank \NC \blank \NC \NC \NR %D \NC test 1a %D \par %D test 1b %D \par %D test 1b \NC test 2a %D \par %D test 2b %D \par %D test 2b \NC test 3a \NC \NR %D \NC test 1a %D \blank %D test 1b %D \par %D test 1b \NC test 2a %D \par %D test 2b %D \blank %D test 2b \NC test 3a \NC \NR %D \stoptabulate %D \stopbuffer %D %D \typebuffer \start \getbuffer \stop % \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 \unexpanded\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