summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/tabl-tab.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/tabl-tab.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/tabl-tab.mkiv3473
1 files changed, 1623 insertions, 1850 deletions
diff --git a/Master/texmf-dist/tex/context/base/tabl-tab.mkiv b/Master/texmf-dist/tex/context/base/tabl-tab.mkiv
index d926dab989a..24bbb4dd607 100644
--- a/Master/texmf-dist/tex/context/base/tabl-tab.mkiv
+++ b/Master/texmf-dist/tex/context/base/tabl-tab.mkiv
@@ -3,9 +3,9 @@
%D version=1997.10.10,
%D title=\CONTEXT\ Table Macros,
%D subtitle=\TABLE\ Embedding,
-%D author=Hans Hagen,
+%D author=Hans Hagen with copied and patched code from MJ Wichura,
%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%D copyright=PRAGMA-ADE (patched and extensions)]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
@@ -13,85 +13,1132 @@
\writestatus{loading}{ConTeXt Table Macros / TaBlE Embedding}
-% By now it makes more sense to merge the patches into the original
-% and clean that one up too.
+% Todo: consistent namespace and get rid of not used code
-% \starttable[|||]
-% \HL
-% \VL test \VS test \VL \FR
-% \VL test \VD test \VL \MR
-% \VL test \VT test \VL \LR
-% \HL
-% \stoptable
-
-% Don't change the splitter:
+% In \MKIV\ the old table macros are sort of obsolete. The
+% color extensions have been removed and some code is stripped.
+% For practical reasons the \TABLE\ macros that are used are
+% embedded in this file.
%
-% ... \NR
-% \TABLEnoalign{\page}\TABLEhead
-% \NC ...
-
-% e-tex: reverse rows or vadjust or ... in tables
-% \ifalign
-% \xhrule : calls for 'special' with width
-% BUG:
+% The following code is based on TABLE 1.0 by Michael J. Wichura
+% (August 1988. We used a patched version with many overloads
+% and extensions. The documented (and larger) source can be found
+% in \type {thrd-tab.tex}.
%
-% \starttable[|l|l|]
-% \HL
-% \RL\FR \VL Head 1 \VL Head 2 \VL\FR
-% \RL\LR \VL Head A \VL Head B \VL\LR % niet grijs ??
-% \HL
-% \VL 1 \VL 2 \VL\FR
-% \VL a \VL b \VL\LR
-% \HL
-% \stoptable
+% Some code has been stripped. Some color has been added. Some macros
+% have been renamed. Registers have been replaces. And probably much
+% more can be cleaned up.
-% melden als in kleur conflict, uitgestelde test op \SR\SR
+\unprotect
-% verengelsen
-% interface
+\newconditional\tablehasleftspacing
+\newconditional\tablehasrightspacing
-% footnotes flushen
-% \......TABLE........ namen
-% kolommen testen
-% unbreakable kop definieren
-% voetnoten
-% meldingen
-% als direct \use{max} dan fout
-% \BREAKPOINT
-% breedte lijn telt
-% errors: ook gray in handle
+\newdimen\tablelinethicknessunit
+\newdimen\tablestrutunit
+\newskip \tableintercolumnspaceunit
+\newdimen\tablecolumnwidthunit
+\newdimen\tablekernunit
-% \AR -> als in DL dan \DR
+\def\tablestrutheightfactor {8}
+\def\tablestrutdepthfactor {3}
+\def\tableintercolumnspacefactor {3}
+\def\tablecolumnwidthfactor {10}
+\def\tablevspacefactor {2}
+\def\tablekernfactor {1}
+\def\tablelinethicknessfactor {4}
-% nieuw:
-%
-% \NL / \NL[blanko] is skip, nog default?
-% geen \HL in a row
-% \HL[n]
-% \VL[n] + remembers
-% c{colorspec} key
-% \HC[color][width]
-% \VC[color]
-% meldingen row, column, use, advise
-% \AR: UITSTELLEN / EXPERIMENTEEL
-
-% WAARDELOZE ERROR HANDLER
-% THIS RENEWED MODULE WORKS OK BUT STILL LOOKS BAD
-
-%D We felt no need to write our own table building macros,
-%D simply because Michael Wichura made a terrific one. This
-%D package is quite complete and well documented. In \CONTEXT\
-%D we provide a shell for consistent spacing as well as color
-%D support. Implementing these features without adapting the
-%D original macros is not trivial. One easilly gets conflicts
-%D with \type{\omit}, \type{\span} and \type{\noalign}, which
-%D means that we end up postponing and overloading macros,
-%D mostly global. Now, let's start with loading the main
-%D macros:
-
-\doifundefined{BeginTable}{\doinputonce{table.tex}}
+\newtoks\everytable
+\newtoks\everytableparbox
-\unprotect
+\unexpanded\def\dotablebeginparbox#1%
+ {\setbox\scratchbox\vtop\bgroup % \setbox added
+ \hsize#1\relax
+ \dontcomplain
+ \dorestoretablelineskips
+ \normalbaselines
+ \let~\fixedspace
+ \blank[\v!disable]% % added
+ \the\everytableparbox}
+
+\unexpanded\def\dotableendparbox
+ {\removelastskip % itemize or so
+ \endgraf
+ \ifnum\prevgraf>\zerocount % we want at least
+ \verticalstrut \nowhitespace \vskip-\struttotal % one line of text
+ \egroup
+ \ifdim\dp\scratchbox>\lineheight % see (*) for an
+ \getnoflines{\dp\scratchbox}% % example of where
+ \dp\scratchbox\zeropoint % saving can go
+ \setbox\scratchbox % terrible wrong
+ \vtop to \noflines\lineheight{\box\scratchbox}%
+ \fi % esp between rows
+ \else % of paragraphs
+ \egroup
+ \fi
+ \box\scratchbox}
+
+\appendtoks
+ \parindent\zeropoint
+ \raggedright
+ \rightskip\zeropoint \!!plus 4em \relax
+\to \everytableparbox
+
+\newskip \tablelefttabskip
+\newskip \tablerighttabskip
+
+\newcount\!taColumnNumber
+\newcount\!taRecursionLevel % (Initially 0)
+
+\newdimen\!taDimenA % used by \Enlarge
+\newdimen\!taDimenB % used by \Enlarge
+\newdimen\!taDimenC % used by numeric.tex
+\newdimen\!taMinimumColumnWidth
+
+\newtoks \!taTableSpread
+\newtoks \!taPreamble
+\newtoks \!taDataColumnTemplate
+\newtoks \!taRuleColumnTemplate
+\newtoks \!taOldRuleColumnTemplate
+\newtoks \!taLeftGlue
+\newtoks \!taRightGlue
+
+\newskip \!taLastRegularTabskip
+
+\newif \if!taBeginFormat
+\newif \if!taOnceOnlyTabskip
+
+\def\!thToksEdef#1#2%
+ {\edef\!ttemp{#2}%
+ #1\expandafter{\!ttemp}%
+ \ignorespaces}
+
+\def\!thLoop#1\repeat
+ {\def\!thIterate{#1\expandafter \!thIterate\fi}%
+ \!thIterate
+ \let\!thIterate\relax}
+
+\def\dobegintableformat
+ {\!taPreamble\emptytoks
+ \!taColumnNumber\zerocount
+ \scratchskip\tableintercolumnspaceunit
+ \multiply\scratchskip\tableintercolumnspacefactor
+ \divide\scratchskip\plustwo
+ \!taRuleColumnTemplate\expandafter{\expandafter\tabskip\the\scratchskip}%
+ \!taLastRegularTabskip\scratchskip
+ \!taOnceOnlyTabskipfalse
+ \!taBeginFormattrue
+ \let\!tfRowOfWidths\empty
+ \doreadtableformatkeys}
+
+\def\!tfSetWidth
+ {\ifx\!tfRowOfWidths\empty % true if no prior "w" keys
+ \ifnum\!taColumnNumber>\zerocount % true if "w" key is to right of first "|"
+ \begingroup % RowOfWidths={&\omit || n copies of &\omit&\omit}, where n = number of column to the left of this one
+ \scratchcounter\plusone
+ \aftergroup \edef \aftergroup \!tfRowOfWidths \aftergroup {%
+ \aftergroup &\aftergroup \omit
+ \!thLoop
+ \ifnum \scratchcounter<\!taColumnNumber
+ \advance\scratchcounter\plusone
+ \aftergroup \!tfAOAO
+ \repeat
+ \aftergroup}%
+ \endgroup
+ \fi
+ \fi
+ \ifx[\!ttemp % \!tgGetValue sets \!ttemp = token after w
+ \expandafter\!tfSetWidthText
+ \else
+ \expandafter\!tfSetWidthValue
+ \fi}
+
+\def\!tfAOAO{&\omit&\omit}
+
+\def\!tfSetWidthText[#1]%
+ {\def\!tfWidthText{#1}%
+ \doreadtableformatkeys}
+
+\def\!tfSetWidthValue
+ {\!taMinimumColumnWidth=
+ \ifnum\!tgCode=\plusone
+ \ifx\!tgValue\empty \tablecolumnwidthfactor \else \!tgValue \fi \tablecolumnwidthunit
+ \else
+ \!tgValue
+ \fi
+ \let\!tfWidthText\empty % Override possible prior `w[sample entry]'
+ \doreadtableformatkeys}
+
+\def\!tfSetTabskip
+ {\ifnum\!tgCode=\plusone
+ \scratchskip\tableintercolumnspaceunit
+ \multiply\scratchskip \ifx\!tgValue\empty\tableintercolumnspacefactor\else\!tgValue\fi
+ \else
+ \scratchskip\!tgValue
+ \fi
+ \divide\scratchskip\plustwo
+ \ifnum\!taColumnNumber=\zerocount
+ %\!thToksEdef\!taRuleColumnTemplate{\the\!taRuleColumnTemplate\tabskip\the\scratchskip}%
+ \normalexpanded{\!taRuleColumnTemplate{\the\!taRuleColumnTemplate\tabskip\the\scratchskip}}%
+ \else
+ %\!thToksEdef\!taDataColumnTemplate{\the\!taDataColumnTemplate\tabskip\the\scratchskip}%
+ \normalexpanded{\!taDataColumnTemplate{\the\!taDataColumnTemplate\tabskip\the\scratchskip}}%
+ \fi
+ \if!taOnceOnlyTabskip\else
+ \!taLastRegularTabskip\scratchskip % Remember this Tabskip, for possible
+ \fi % restoration after a subsequent"OnceOnly"
+ \doreadtableformatkeys}
+
+\def\!tfSetVrule
+ {\!thToksEdef\!taRuleColumnTemplate
+ {\hfil
+ \vrule
+ \noexpand\!!width
+ \ifnum\!tgCode=\plusone
+ \ifx\!tgValue\empty
+ \tablevrulethicknessfactor
+ \else
+ \!tgValue
+ \fi
+ \tablelinethicknessunit
+ \else
+ \!tgValue
+ \fi
+ ####%
+ \hfil
+ \the\!taRuleColumnTemplate}%
+ \!tfAdjoinPriorColumn}
+
+\def\!tfSetAlternateVrule
+ {\afterassignment\!tfSetAlternateA
+ \scratchtoks}
+
+\def\!tfSetAlternateA
+ {\!thToksEdef\!taRuleColumnTemplate{\the\scratchtoks\the\!taRuleColumnTemplate}%
+ \!tfAdjoinPriorColumn}
+
+\def\!tfAdjoinPriorColumn
+ {\ifnum \!taColumnNumber=0
+ \!taPreamble=\!taRuleColumnTemplate % New \tabskip may have been added
+ \else
+ \ifx\!tfRowOfWidths\empty % no "w" keys specified yet, not even this col
+ \else
+ \!tfUpdateRowOfWidths
+ \fi
+ \!thToksEdef\!taDataColumnTemplate{\the\!taLeftGlue\the\!taDataColumnTemplate\the\!taRightGlue}%
+ \!thToksEdef\!taPreamble{\the\!taPreamble&\the\!taDataColumnTemplate&\the\!taRuleColumnTemplate}%
+ \fi
+ \advance \!taColumnNumber \plusone
+ \if!taOnceOnlyTabskip
+ \!thToksEdef\!taDataColumnTemplate{####\tabskip \the\!taLastRegularTabskip}%
+ \else
+ \!taDataColumnTemplate{##}%
+ \fi
+ \!taRuleColumnTemplate\emptytoks
+ \!taLeftGlue{\hfil}%
+ \!taRightGlue{\hfil}%
+ \!taMinimumColumnWidth\zeropoint
+ \let\!tfWidthText\empty
+ \!taOnceOnlyTabskipfalse
+ \doreadtableformatkeys}
+
+\def\!tfUpdateRowOfWidths
+ {\ifx\!tfWidthText\empty \else
+ \!tfComputeMinColWidth
+ \fi
+ \edef\!tfRowOfWidths
+ {\!tfRowOfWidths
+ &%
+ \omit
+ \ifdim \!taMinimumColumnWidth>\zeropoint
+ \hskip \the\!taMinimumColumnWidth
+ \fi
+ &
+ \omit}}
+
+\def\!tfComputeMinColWidth
+ {\setbox0\vbox
+ {\ialign{% Plain's initialized \halign; \tabskip=0pt \everycr={}
+ \span\the\!taDataColumnTemplate\cr
+ \!tfWidthText\cr}}%
+ \!taMinimumColumnWidth=\wd0 }
+
+\def\!tfFinishFormat
+ {\!thToksEdef\!taPreamble{####\tabskip\tablelefttabskip&\the\!taPreamble \tabskip\tablerighttabskip&####\tabskip\zeropoint\cr}
+ \!taBeginFormatfalse
+ \!ttDoHalign}
+
+\def\dotablereformat[#1]% will become local
+ {\omit
+ \!taDataColumnTemplate{##}%
+ \!taLeftGlue\emptytoks
+ \!taRightGlue\emptytoks
+ \begingroup
+ \@@useotherbar
+ \expanded{\endgroup\noexpand\doreadtableformatkeys#1]}}% appear in a \dotablereformat cmd; this is here as a safeguard.
+
+\appendtoks
+ \let\ReFormat\dotablereformat
+\to \everytable
+
+\def\!tfEndReFormat
+ {\!tfReFormat}
+
+\appendtoks \dotableparalignment \to \everytableparbox
+
+\def\!tfReFormat#1%
+ {\the \!taLeftGlue
+ \vbox{\forgetall\ialign{\span\the\!taDataColumnTemplate\cr#1\cr}}%
+ \the \!taRightGlue
+ \kern\zeropoint} % prevents \unskip / really needed
+
+\def\!tgGetValue#1%
+ {\def\!tgReturn{#1}%
+ \futurelet\!ttemp\!tgCheckForParen}
+
+\def\!tgCheckForParen%
+ {\ifx\!ttemp (%
+ \expandafter \!tgDoParen
+ \else
+ \expandafter \!tgCheckForSpace
+ \fi}
+
+\def\!tgDoParen(#1)%
+ {\def\!tgCode{2}% will be expanded
+ \def\!tgValue{#1}%
+ \!tgReturn}
+
+\def\!tgCheckForSpace
+ {\def\!tgCode{1}%
+ \let\!tgValue\empty
+ \ifx\!ttemp\!thSpaceToken
+ \expandafter \!tgReturn
+ \else
+ \expandafter \!tgCheckForDigit
+ \fi}
+
+% \def\!tgCheckForDigit
+% {\donefalse
+% \ifx 0\!ttemp \donetrue
+% \else\ifx 1\!ttemp \donetrue
+% \else\ifx 2\!ttemp \donetrue
+% \else\ifx 3\!ttemp \donetrue
+% \else\ifx 4\!ttemp \donetrue
+% \else\ifx 5\!ttemp \donetrue
+% \else\ifx 6\!ttemp \donetrue
+% \else\ifx 7\!ttemp \donetrue
+% \else\ifx 8\!ttemp \donetrue
+% \else\ifx 9\!ttemp \donetrue
+% \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+% \ifdone
+% \expandafter \!tgGetNumber
+% \else
+% \expandafter \!tgReturn
+% \fi}
+
+\def\!tgCheckForDigit % less tokens:
+ {\donetrue
+ \ifx 0\!ttemp \else \ifx 1\!ttemp \else
+ \ifx 2\!ttemp \else \ifx 3\!ttemp \else
+ \ifx 4\!ttemp \else \ifx 5\!ttemp \else
+ \ifx 6\!ttemp \else \ifx 7\!ttemp \else
+ \ifx 8\!ttemp \else \ifx 9\!ttemp \else
+ \donefalse
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \ifdone
+ \expandafter \!tgGetNumber
+ \else
+ \expandafter \!tgReturn
+ \fi}
+
+% \def\!tgCheckForDigit % does not work
+% {\relax\doifnumberelse\!ttemp\!tgGetNumber\!tgReturn}
+
+\def\!tgGetNumber {\afterassignment\!tgGetNumberA\scratchcounter=}
+\def\!tgGetNumberA{\edef\!tgValue{\the\scratchcounter}\!tgReturn}
+
+\def\!tgSetUpParBox
+ {\normalexpanded
+ {\noexpand \doreadtableformatkeys
+ b{\dotablebeginparbox
+ {\ifnum\!tgCode=\plusone
+ \ifx\!tgValue\empty
+ \tablecolumnwidthfactor
+ \else
+ \!tgValue
+ \fi
+ \tablecolumnwidthunit
+ \else
+ \!tgValue
+ \fi}}%
+ a{\dotableendparbox}}}
+
+\def\!tgInsertKern
+ {\edef\!ttemp
+ {\kern
+ \ifnum \!tgCode=\plusone
+ \ifx \!tgValue\empty
+ \tablekernfactor
+ \else
+ \!tgValue
+ \fi
+ \tablekernunit
+ \else
+ \!tgValue
+ \fi}%
+ \edef\!ttemp
+ {\noexpand\doreadtableformatkeys
+ \ifconditional\tablehasleftspacing
+ b{\!ttemp}
+ \fi
+ \ifconditional\tablehasrightspacing
+ a{\!ttemp}
+ \fi}%
+ \!ttemp}
+
+\def\newtableformatkey #1{\setvalue{!tk<\string#1>}}
+\def\doreadtableformatkeys#1{\getvalue{!tk<\string#1>}}
+
+% Key "b": b{TOKENS} adds TOKENS to the left of (before) the template
+
+\newtableformatkey b#1%
+ {\expandafter\!tkJoin\expandafter{\the\!taDataColumnTemplate}{#1}%
+ \doreadtableformatkeys}
+
+\def\!tkJoin#1#2%
+ {\!taDataColumnTemplate{#2#1}}%
+
+% Key "a": a{TOKENS} adds TOKENS to the right of (after) the template
+
+\newtableformatkey a#1%
+ {\!taDataColumnTemplate\expandafter{\the\!taDataColumnTemplate #1}%
+ \doreadtableformatkeys}
+
+% Key "\{": Enclose template in braces.
+
+\newtableformatkey \{%
+ {\!taDataColumnTemplate=\expandafter{\expandafter{\the\!taDataColumnTemplate}}%
+ \doreadtableformatkeys}
+
+% Key "*": "*{N}{KEY LETTERS}" is equivalent to specifying
+% <KEY LETTERS> N times.
+% KEY LETTERS may contain further * specifications
+
+\newtableformatkey *#1#2%
+ {\scratchcounter=#1\relax
+ \scratchtoks\emptytoks
+ \!thLoop
+ \ifnum\scratchcounter>\zerocount
+ \scratchtoks\expandafter{\the\scratchtoks#2}%
+ \advance\scratchcounter\minusone
+ \repeat
+ \expandafter\doreadtableformatkeys\the\scratchtoks}
+
+% Key "\LeftGlue": Specifies the glue (usually \hfil, or nothing) to be
+% added to extreme left of the template to position a column
+
+\newtableformatkey \LeftGlue#1%
+ {\!taLeftGlue{#1}%
+ \doreadtableformatkeys}
+
+\newtableformatkey \RightGlue#1%
+ {\!taRightGlue{#1}%
+ \doreadtableformatkeys}
+
+\newtableformatkey c%
+ {\prependtoks\raggedcenter\to\!taDataColumnTemplate
+ \doreadtableformatkeys \LeftGlue\hfil \RightGlue\hfil}
+
+\newtableformatkey l%
+ {\prependtoks\raggedright\to\!taDataColumnTemplate
+ \doreadtableformatkeys \LeftGlue\empty \RightGlue\hfil}
+
+\newtableformatkey r%
+ {\prependtoks\raggedleft\to\!taDataColumnTemplate
+ \doreadtableformatkeys \LeftGlue\hfil \RightGlue\empty}
+
+\newtableformatkey x%
+ {\prependtoks\notragged\to\!taDataColumnTemplate
+ \doreadtableformatkeys \LeftGlue\hfil \RightGlue\empty}
+
+% Key "k": Adds kerns to left and right of "#"
+% This key and the two below use Plain TeX's \if@h as if it were \if@left,
+% and \if@v as if it were \if@right. Table making goes on in a group,
+% so even in the unlikely circumstance that a \phantom is currently under
+% construction, there's no problem.
+
+\newtableformatkey k%
+ {\settrue\tablehasleftspacing
+ \settrue\tablehasrightspacing
+ \!tgGetValue{\!tgInsertKern}}
+
+% Key "i": Adds a kern to the left of "#"
+
+\newtableformatkey i%
+ {\settrue\tablehasleftspacing
+ \setfalse\tablehasrightspacing
+ \!tgGetValue{\!tgInsertKern}}
+
+% Key "j": Adds a kern to the right of "#"
+
+\newtableformatkey j%
+ {\setfalse\tablehasleftspacing
+ \settrue\tablehasrightspacing
+ \!tgGetValue{\!tgInsertKern}}
+
+% Key "n": numeric item , non-math mode.
+
+\newtableformatkey n%
+ {\def\!tnStyle{}%
+ \futurelet\!tnext\!tnTestForBracket}
+
+% Key "N": numeric item, math mode.
+
+\newtableformatkey N%
+ {\def\!tnStyle{$}%
+ \futurelet\!tnext\!tnTestForBracket}
+
+% Key "m": Math mode.
+
+\newtableformatkey m%
+ {\doreadtableformatkeys b$ a$}
+
+% Key "M": Displaymath mode.
+
+\newtableformatkey M%
+ {\doreadtableformatkeys \{ b{$\displaystyle} a$}
+
+% Key "\m": Template ${}#\hfil$
+\newtableformatkey \m%
+ {\doreadtableformatkeys l b{{}} m}
+
+% Key "\M": Template $\displaystyle{{}#\hfil}$
+
+\newtableformatkey \M%
+ {\doreadtableformatkeys l b{{}} M}
+
+% Key "f": Set font (E.g., f\it sets up italic font (assuming \it
+% has its usual meaning)
+
+\newtableformatkey f#1%
+ {\doreadtableformatkeys b{#1}}
+
+\newtableformatkey B{\doreadtableformatkeys f\bf} % Key "B": abbreviation for f\bf
+\newtableformatkey I{\doreadtableformatkeys f\it} % Key "I": abbreviation for f\it
+\newtableformatkey S{\doreadtableformatkeys f\sl} % Key "S": abbreviation for f\sl
+\newtableformatkey R{\doreadtableformatkeys f\rm} % Key "R": abbreviation for f\rm
+\newtableformatkey T{\doreadtableformatkeys f\tt} % Key "T": abbreviation for f\tt
+
+% Key "p": ParBox
+
+\newtableformatkey p%
+ {\!tgGetValue{\!tgSetUpParBox}}
+
+% Key "w": minimum column width
+
+\newtableformatkey w%
+ {\!tkTestForBeginFormat w{\!tgGetValue{\!tfSetWidth}}}
+
+% Key "s": Set tabskip for the inter-column space to the right
+% of the current column, and all subsequent spaces, until overriden
+% by a new "s" or "o" key.
+
+\newtableformatkey s%
+ {\!taOnceOnlyTabskipfalse % in case same column has a prior "o" key
+ \!tkTestForBeginFormat t{\!tgGetValue{\!tfSetTabskip}}}
+
+% Key "o": Apply the \tabskip stated for this column ONLY to the
+% inter-column space just to the right of this column; restore the
+% the previous \tabskip for subsequent columns.
+
+\newtableformatkey o%
+ {\!taOnceOnlyTabskiptrue
+ \!tkTestForBeginFormat o{\!tgGetValue{\!tfSetTabskip}}}
+
+% Key "|": Standard rule column designator
+
+\newtableformatkey |%
+ {\!tkTestForBeginFormat |{\!tgGetValue{\!tfSetVrule}}}
+
+% Key "\|": Non-standard rule column designator
+
+\newtableformatkey \|%
+ {\!tkTestForBeginFormat \|{\!tfSetAlternateVrule}}
+
+% Key ".": PERIOD -- end of \dobegintableformat section.
+
+\newtableformatkey .%
+ {\!tkTestForBeginFormat.{\!tfFinishFormat}}
+
+% Key "\doendtableformat": Equivalent to "."
+
+\newtableformatkey \doendtableformat
+ {\!tkTestForBeginFormat\doendtableformat{\!tfFinishFormat}}
+
+% Key "]": End of \dotablereformat section
+
+\newtableformatkey ]%
+ {\!tkTestForReFormat ] \!tfEndReFormat}
+
+% TEST FOR BEGIN FORMAT{<Key>}{Intended Action}: This test is run
+% on keys that can only be used by \dobegintableformat --- "s", "o",
+% "|", "\|", "w", ".", and "\doendtableformat".
+
+\def\!tkTestForBeginFormat#1#2%
+ {\if!taBeginFormat
+ \def\!ttemp{#2}%
+ \expandafter\!ttemp
+ \else
+ \toks0={#1}%
+ \toks2=\expandafter{\string\dotablereformat}%
+ \expandafter\!tkImproperUse
+ \fi}
+
+% TEST FOR RE FORMAT{<Key>}{Intended Action}: This test is run
+% on the key "]", which can only be used by \dotablereformat.
+
+\def\!tkTestForReFormat#1#2%
+ {\if!taBeginFormat
+ \toks0={#1}%
+ \toks2=\expandafter{\string\dobegintableformat}%
+ \expandafter\!tkImproperUse
+ \else
+ \def\!ttemp{#2}%
+ \expandafter\!ttemp
+ \fi}
+
+% NOTE: THE SPACE BETWEEN A NUMERIC ENTRY AND THE FOLLOWING '|', '"',
+% OR '\|' IS MANDATORY.
+% EMPTY NUMERIC ENTRIES ARE NOT ALLOWED: USE '{}' OR '\omit' INSTEAD.
+
+\def\!tnTestForBracket
+ {\ifx[\!tnext
+ \expandafter\!tnGetArgument
+ \else
+ \expandafter\!tnGetCode
+ \fi}
+
+% GET CODE: E.g. "4", or "4.0", "0.4", or "10.2"
+
+\def\!tnGetCode#1 %
+ {\!tnConvertCode #1..!}
+
+% CONVERT CODE: E.g. converts above to [0000], [0000.], [.0000],
+% [0000000000.00]
+
+\def\!tnConvertCode #1.#2.#3!%
+ {\begingroup
+ \aftergroup\edef \aftergroup\!ttemp \aftergroup{%
+ \aftergroup[%
+ \scratchcounter#1\relax
+ \!thLoop
+ \ifnum \scratchcounter>\zerocount
+ \advance\scratchcounter\minusone
+ \aftergroup0
+ \repeat
+ \def\!ttemp{#3}%
+ \ifx\!ttemp \empty
+ \else
+ \aftergroup.
+ \scratchcounter#2\relax
+ \!thLoop
+ \ifnum \scratchcounter>\zerocount
+ \advance\scratchcounter\minusone
+ \aftergroup0
+ \repeat
+ \fi
+ \aftergroup]\aftergroup}%
+ \endgroup\relax
+ \expandafter\!tnGetArgument\!ttemp}
+
+% GET ARGUMENT: [<sample left field> <optional .<sample right field>>
+
+\def\!tnGetArgument[#1]%
+ {\!tnMakeNumericTemplate\!tnStyle#1..!}
+
+% MAKE NUMERIC TEMPLATE
+
+\def\!tnMakeNumericTemplate#1#2.#3.#4!% #1=<empty> or $
+ {\def\!ttemp{#4}%
+ \ifx\!ttemp\empty
+ \!taDimenC\zeropoint
+ \else
+ \setbox\scratchbox=\hbox{\mathsurround\zeropoint #1.#3#1}%
+ \!taDimenC\wd\scratchbox
+ \fi
+ \setbox\scratchbox\hbox{\mathsurround\zeropoint #1#2#1}%
+ \!thToksEdef\!taDataColumnTemplate
+ {\noexpand\!tnSetNumericItem{\the\wd\scratchbox}{\the\!taDimenC}{#1}%
+ \the\!taDataColumnTemplate}% Might have tabskip glue in here
+ \doreadtableformatkeys}
+
+% SET NUMERIC ITEM
+
+\def\!tnSetNumericItem #1#2#3#4 %
+ {\!tnSetNumericItemA {#1}{#2}{#3}#4..!}
+
+\def\!tnSetNumericItemA #1#2#3#4.#5.#6!%
+ {\def\!ttemp{#6}%
+ \hbox to #1{\hss \mathsurround\zeropoint #3#4#3}%
+ \hbox to #2{\ifx\!ttemp\empty\else\mathsurround\zeropoint #3.#5#3\fi\hss}}
+
+% extensions
+
+\newtableformatkey q%
+ {\letempty\!tqStyle
+ \futurelet\!tnext\!tqTestForBracket}
+
+\newtableformatkey Q%
+ {\def\!tqStyle{$}%
+ \futurelet\!tnext\!tqTestForBracket}
+
+\def\!tqTestForBracket
+ {\ifx[\!tnext
+ \!thx\!tqGetArgument
+ \else
+ \!thx\!tqGetCode
+ \fi}
+
+\def\!tqGetCode#1 % note the blank
+ {\!tqConvertCode #1,,!}
+
+\def\!tqConvertCode #1,#2,#3!%
+ {\begingroup
+ \aftergroup\edef
+ \aftergroup\!ttemp
+ \aftergroup{%
+ \aftergroup[%
+ \scratchcounter#1\relax
+ \!thLoop
+ \ifnum \scratchcounter>\zerocount
+ \advance\scratchcounter\minusone
+ \aftergroup0
+ \repeat
+ \def\!ttemp{#3}%
+ \ifx\!ttemp\empty
+ \else
+ \aftergroup,
+ \scratchcounter#2\relax
+ \!thLoop
+ \ifnum\scratchcounter>\zerocount
+ \advance\scratchcounter\minusone
+ \aftergroup0
+ \repeat
+ \fi
+ \aftergroup]\aftergroup}%
+ \endgroup\relax
+ \!thx\!tqGetArgument\!ttemp}
+
+\def\!tqGetArgument[#1]%
+ {\!tqMakeQuantityTemplate\!tqStyle#1,,!}
+
+\def\!tqMakeQuantityTemplate#1#2,#3,#4!% #1=<empty> or $
+ {\def\!ttemp{#4}%
+ \ifx\!ttemp\empty
+ \!taDimenC\zeropoint
+ \else
+ \setbox\scratchbox\hbox{\mathsurround\zeropoint #1,#3#1}%
+ \!taDimenC\wd\scratchbox
+ \fi
+ \setbox\scratchbox\hbox{\mathsurround\zeropoint #1#2#1}%
+ \!thToksEdef\!taDataColumnTemplate
+ {\noexpand\!tqSetQuantityItem{\the\wd\scratchbox}{\the\!taDimenC}{#1}%
+ \the\!taDataColumnTemplate}%
+ \doreadtableformatkeys}
+
+\def\!tqSetQuantityItem #1#2#3#4 %
+ {\!tqSetQuantityItemA{#1}{#2}{#3}#4,,!}
+
+\def\!tqSetQuantityItemA #1#2#3#4,#5,#6!%
+ {\def\!ttemp{#6}%
+ \hbox to #1{\hss\mathsurround\zeropoint#3#4#3}%
+ \hbox to #2{\ifx\!ttemp\empty\else\mathsurround\zeropoint#3,#5#3\fi\hss}}
+
+% \Enlarge<extra height><extra depth><original>
+% \enlarge<multiple for extra height><multiple for extra depth><original>
+
+\def\dotableEnlarge#1#2%
+ {% 3rd argument is picked up later
+ % #1=extra height
+ % #2=extra depth
+ \!taDimenA=#1\relax
+ \!taDimenB=#2\relax
+ \let\!TsSpaceFactor\empty
+ \ifmmode
+ \expandafter\mathpalette
+ \expandafter\!TsEnlargeMath
+ \else
+ \expandafter\!TsEnlargeOther
+ \fi}
+
+\def\!TsEnlargeOther#1%
+ {\ifhmode
+ \setbox\scratchbox\hbox{#1\xdef\!TsSpaceFactor{\spacefactor\the\spacefactor}}%
+ \else
+ \setbox\scratchbox\hbox{#1}%
+ \fi
+ \!TsFinishEnlarge}
+
+\def\!TsEnlargeMath#1#2%
+ {\setbox\scratchbox\hbox{$\mathsurround\zeropoint#1{#2}$}%
+ \!TsFinishEnlarge}
+
+\def\!TsFinishEnlarge
+ {\ht\scratchbox\dimexpr\ht\scratchbox+\!taDimenA\relax
+ \dp\scratchbox\dimexpr\dp\scratchbox+\!taDimenB\relax
+ \box\scratchbox
+ \!TsSpaceFactor\relax}
+
+\def\dotableenlarge#1#2% 3rd argument is picked up later
+ {\dotableEnlarge{#1\tablestrutunit}{#2\tablestrutunit}}
+
+\appendtoks
+ \let\enlarge\dotableenlarge
+ \let\Enlarge\dotableEnlarge
+\to \everytable
+
+% BEGIN TABLE
+
+\let\dotablestandardend\relax
+
+\def\dotablestandardbegin[#1]% \!ttBeginTable (always argument)
+ {\if#1u% unboxed table
+ \ifmmode
+ \let\dotablestandardend\relax % user had better be in display math mode and have only one table at the outer level
+ \else % user had better be in vertical mode
+ \bgroup
+ \let\dotablestandardend\egroup
+ \fi
+ \else
+ \hbox\bgroup
+ \def\dotablestandardend{\egroup\egroup}%
+ \if#1t%
+ \vtop
+ \else\if#1b%
+ \vbox
+ \else
+ \def\dotablestandardend{\egroup$\egroup}%
+ %$\vcenter
+ \scratchtoks\everymath\everymath\emptytoks$\everymath\scratchtoks\vcenter
+ \fi\fi
+ \bgroup % for the \vtop, \vbox, or \vcenter
+ \fi
+ \advance\!taRecursionLevel\plusone
+ \let\!ttRightGlue\relax
+ \everycr\emptytoks
+ \ifnum\!taRecursionLevel=\plusone
+ \the\everytable
+ \fi}
+
+\bgroup \catcode\tildeasciicode\activecatcode
+
+ \appendtoks
+ \catcode\barasciicode\activecatcode
+ \def~{\kern.5em}%
+ \def\\{\ifhmode\space\else\par\fi}%
+ \to \everytable
+
+\egroup
+
+\let\!ttRightGlue\relax % This may be changed, in a group, by \JustCenter, etc
+
+% DO HALIGN: Invoked by END FORMAT (or the key ".")
+
+\def\!ttDoHalign
+ {\edef\dorestoretablelineskips
+ {\baselineskip \the\baselineskip
+ \lineskiplimit\the\lineskiplimit
+ \lineskip \the\lineskip
+ \tabskip \the\tabskip
+ \relax}%
+ \baselineskip \zeropoint
+ \lineskiplimit\zeropoint
+ \lineskip \zeropoint
+ \tabskip \zeropoint
+ \doifelsenothing\@@titextwidth
+ {\halign}
+ {\doifelse\@@titextwidth\v!max
+ {\halign to \hsize}
+ {\halign to \@@titextwidth}}%
+% \the\!taTableSpread
+ \bgroup
+ \span
+ \the\!taPreamble
+ \ifx\!tfRowOfWidths\empty\else
+ \!tfRowOfWidths\cr
+ \fi}
+
+% END TABLE
+
+\def\dotablenormalend
+ {\egroup % finishes the \halign
+ \dotablestandardend} % closes off the table envirnoment set up by \tablestandardbegin
+
+\def\donormaltablelineending
+ {\cr}
+
+\def\donormaltablelineformat#1#2%
+ {\vrule
+ \!!width \zeropoint
+ \!!height\dimexpr\tablestrutheightfactor\tablestrutunit+#1\tablestrutunit\relax
+ \!!depth \dimexpr\tablestrutdepthfactor \tablestrutunit+#2\tablestrutunit\relax
+ \relax
+ \cr}
+
+% INSERT VRULE
+
+\newcount\noftablevrules \noftablevrules\plusone
+
+\let\tablecurrentvrulecolor\empty
+\let\tablecurrenthrulecolor\empty
+
+\def\@VLd{.125em}
+
+\def\do!ttInsertVrule % will be merged in 2005
+ {\vrule\!!width
+ \ifnum\!tgCode=\plusone
+ \ifx\!tgValue\empty
+ \tablevrulethicknessfactor
+ \else
+ \!tgValue
+ \fi
+ \tablelinethicknessunit
+ \else
+ \!tgValue
+ \fi
+ \hskip\@VLd}
+
+\def\donormaltablesimplebar
+ {\unskip\!ttRightGlue&&}
+
+\def\donormaltablecomplexbar
+ {\unskip\!ttRightGlue&\omit
+ \hfil
+ \ifx\tablecurrentvrulecolor\empty\else
+ \switchtocolor[\tablecurrentvrulecolor]%
+ \fi
+ \ifcase\noftablevrules\or
+ \do!ttInsertVrule
+ \unskip
+ \else
+ \dorecurse\noftablevrules\do!ttInsertVrule
+ \global\noftablevrules\plusone
+ \unskip
+ \fi
+ \global\let\tablecurrentvrulecolor\empty
+ \hfil
+ &}
+
+\def\donormaltablenobar
+ {\unskip\!ttRightGlue&\omit&}
+
+\def\donormaltablesinglerule
+ {&\donormaltablelongrule&}
+
+\def\donormaltablemultirule
+ {&\!ttuse\tabledrulespan\donormaltablelongrule&}
+
+% USE
+
+\def\!ttuse#1%
+ {\ifnum#1>\plusone
+ \omit
+ \global\setfalse\istabledivision % added
+ \scratchcounter\currenttablecolumn % added
+ \advance\scratchcounter #1% % added
+ \advance\scratchcounter \minusone % added
+ \def\next % added
+ {\global\advance\currenttablecolumn #1% % added
+ \global\advance\currenttablecolumn \minusone % added
+ \scratchcounter#1%
+ \advance\scratchcounter \minusone
+ \advance\scratchcounter \scratchcounter
+ \!thLoop
+ \ifnum\scratchcounter>\plusone
+ \spanomit \advance\scratchcounter\minusone
+ \repeat
+ \span}%
+ \else % added
+ \def\next % conflicts with possible next \omit % added
+ {\global\advance\currenttablecolumn \plusone}%% added
+ \fi
+ \next} % added
+
+\def\!ttUse#1[%
+ {\!ttuse{#1}%
+ \dotablereformat[}
+
+\appendtoks
+ \let\use\!ttuse
+ \let\Use\!ttUse
+\to \everytable
+
+% rules
+
+\def\donormaltablefullrule
+ {\starttablenoalign
+ \!ttGetHalfRuleThickness
+ \hrule\!!height\scratchdimen\!!depth\scratchdimen
+ \stoptablenoalign}
+
+\def\donormaltableshortrule % was: \!ttShortHrule
+ {\omit
+ \!ttGetHalfRuleThickness
+ \leaders\hrule\!!height\scratchdimen\!!depth\scratchdimen\hfill
+ \emptyhbox
+ \ignorespaces}
+
+\def\donormaltablelongrule % was: \!ttLongHrule
+ {\omit\span
+ \omit\span
+ \donormaltableshortrule}
+
+\def\!ttGetHalfRuleThickness
+ {\scratchdimen\dimexpr
+ \ifnum\!tgCode=\plusone
+ \ifx\!tgValue\empty
+ \tablehrulethicknessfactor
+ \else
+ \!tgValue % user-specified integer
+ \fi
+ \tablelinethicknessunit
+ \else
+ \!tgValue % user-specified dimension
+ \fi
+ \divide\scratchdimen\plustwo}
+
+% \emptyhbox prevents \unskip
+
+\def\dotableLeft #1{#1\hfill\emptyhbox}
+\def\dotableCenter#1{\hfill#1\hfill\emptyhbox}
+\def\dotableRight #1{\hfill#1}
+
+\def\dotableOpenUp#1#2%
+ {\edef\tablestrutheightfactor{\withoutpt\the\dimexpr\tablestrutheightfactor\points+#1\points}%
+ \edef\tablestrutdepthfactor {\withoutpt\the\dimexpr\tablestrutdepthfactor \points+#2\points}}
+
+% SetTableToWidth -> textwidth=dimension [to dimension]
+% Expand -> textwidth=max [to \hsize]
+% WidenTableBy -> [spread #1]
+% \tablelefttabskip\zeropoint\!!plus1fill
+% \tablerighttabskip\tablelefttabskip
+% LongLines -> [spread \hsize]
+
+\def\dotableJustLeft {\omit\let\!ttRightGlue\hfill}
+\def\dotableJustCenter{\omit\hfill\emptyhbox\let\!ttRightGlue\hfill}
+\def\dotableJustRight {\omit\hfill\emptyhbox}
+
+\def\dotableSmash
+ {\relax
+ \ifmmode
+ \expandafter\mathpalette
+ \expandafter\!thDoMathVCS
+ \else
+ \expandafter\!thDoVCS
+ \fi}
+
+\def\!thDoVCS#1%
+ {\setbox\zerocount\hbox{#1}%
+ \!thFinishVCS}
+
+\def\!thDoMathVCS#1#2%
+ {\setbox\zerocount\hbox{$\mathsurround\zeropoint#1{#2}$}%
+ \!thFinishVCS}
+
+\def\!thFinishVCS
+ {\vbox to\zeropoint{\vss\box\zerocount\vss}}
+
+\def\dotableRaise
+ {\def\!thSign{+}%
+ \!tgGetValue\!thSetDimen}
+
+\def\dotableLower
+ {\def\!thSign{-}%
+ \!tgGetValue\!thSetDimen}
+
+\def\!thSetDimen
+ {\ifnum\!tgCode=\plusone
+ \ifx\!tgValue\empty
+ \!taDimenA\tablestrutheightfactor\tablestrutunit
+ \advance\!taDimenA\tablestrutdepthfactor\tablestrutunit
+ \divide\!taDimenA\plustwo
+ \else
+ \!taDimenA\!tgValue\tablestrutunit
+ \fi
+ \else
+ \!taDimenA\!tgValue
+ \fi
+ \!taDimenA\!thSign\!taDimenA\relax
+ \ifmmode
+ \expandafter\mathpalette
+ \expandafter\!thDoMathRaise
+ \else
+ \expandafter\!thDoSimpleRaise
+ \fi}
+
+\def\!thDoSimpleRaise#1%
+ {\setbox\zerocount\hbox{\raise \!taDimenA\hbox{#1}}%
+ \!thFinishRaise} % From Plain TeX: \ht0=0pt \dp0=0pt \box0
+
+\def\!thDoMathRaise#1#2%
+ {\setbox\zerocount\hbox{\raise \!taDimenA\hbox{$\mathsurround\zeropoint#1{#2}$}}%
+ \!thFinishRaise}
+
+\def\!thFinishRaise
+ {\ht\zerocount\zeropoint
+ \dp\zerocount\zeropoint
+ \box\zerocount}
+
+\def\dotableBackSpace
+ {\!tgGetValue\!thKernBack}
+
+\def\!thKernBack
+ {\kern -
+ \ifnum\!tgCode=\plusone
+ \ifx\!tgValue\empty
+ \tablekernfactor
+ \else
+ \!tgValue % user-specified integer
+ \fi
+ \tablekernunit
+ \else
+ \!tgValue % user-specified dimension
+ \fi
+ \ignorespaces}
+
+\def\dotableVspace
+ {\noalign
+ \bgroup
+ \!tgGetValue\!thVspace}
+
+\def\!thVspace
+ {\vskip
+ \ifnum\!tgCode=\plusone
+ \ifx\!tgValue\empty
+ \tablevspacefactor
+ \else
+ \!tgValue % user-specified integer
+ \fi
+ \tablestrutunit
+ \else
+ \!tgValue % user-specified skip
+ \fi
+ \egroup} % Ends the \noalign
+
+\appendtoks
+ \let\JustLeft \dotableJustLeft
+ \let\JustCenter \dotableJustCenter
+ \let\JustRight \dotableJustRight
+ \let\Smash \dotableSmash
+ \let\Raise \dotableRaise
+ \let\Lower \dotableLower
+ \let\BackSpace \dotableBackSpace
+ \let\Vspace \dotableVspace
+ \let\OpenUp \dotableOpenUp
+ \let\TableLeft \dotableLeft
+ \let\TableCenter \dotableCenter
+ \let\TableRight \dotableRight
+\to \everytable
%D \macros
%D {inintable, ifsplittables}
@@ -104,16 +1151,7 @@
\newif\ifintable
\newif\ifsplittables
-%D \macros
-%D {tracetablestrue}
-%D
-%D When I documented this module, I felt the need for tracing
-%D options. After implementing this feature, I also added
-%D warnings, error recovery and automatic spacing.
-
-\newif\iftracetables
-
-%D We show this feature in an eample that also shows some of
+%D We show this feature in an example that also shows some of
%D the basic table typesetting commands.
%D
%D \startbuffer
@@ -184,416 +1222,63 @@
%D in the last row.
%D
%D \getbuffer
-
-%D Bringing color into tables is complicated by the mere fact
-%D that color is not part of \TEX. The main complication is
-%D that we don't know in advance how wide a column will be. I
-%D implemented color support in tables in the early 90's
-%D because I needed it for some articles on color. I have to
-%D admit that I seldom use the mechanism.
-%D
-%D Most color support in \CONTEXT\ makes use of colored rules.
-%D At first sight, one is tempted to implement colors in tables
-%D in a similar way, but as said, we don't know the dimensions
-%D in advance. It turns out however that we don't have to,
-%D simply because alignments take care of stretching rules to
-%D the appropritate dimensions. This means that we can provide
-%D backgrounds by coloring rules with the height of a row,
-%D skipping upwards and finally drawing the content, like in:
%D
-%D \gdef\ShowExample
-%D {\startfiguretext
-%D {none}
-%D {\getbuffer}
-%D \typebuffer
-%D \stopfiguretext}
+%D Some simple color support is provided:
%D
%D \startbuffer
%D \starttable[|c|c|]
%D \HL
-%D \BL[2] \SR
-%D \VL test \VL test \VL\SR
-%D \HL
-%D \VL test \VL test \VL\FR
-%D \VL test \VL test \VL\MR
-%D \VL test \VL test \VL\LR
-%D \HL
-%D \stoptable
-%D \stopbuffer
-%D
-%D \ShowExample
-%D
-%D Just to be complete we show how the other columns can be
-%D given a background. Later we will provide more details over
-%D the commands used.
-%D
-%D \startbuffer
-%D \starttable[|c|c|c|]
-%D \HL
-%D \BL[3] \SR
-%D \VL test \VL test \VL test \VL\SR
-%D \HL
-%D \stoptable
-%D \stopbuffer
-%D
-%D \ShowExample
-%D
-%D \startbuffer
-%D \starttable[|c|c|c|]
-%D \HL
-%D \BC \BL[2] \SR
-%D \VL test \VL test \VL test \VL\SR
-%D \HL
-%D \stoptable
-%D \stopbuffer
-%D
-%D \ShowExample
-%D
-%D \startbuffer
-%D \starttable[|c|c|c|]
-%D \HL
-%D \BC \BC \BL \SR
-%D \VL test \VL test \VL test \VL\SR
-%D \HL
-%D \stoptable
-%D \stopbuffer
-%D
-%D \ShowExample
-%D
-%D \startbuffer
-%D \starttable[|c|c|c|]
-%D \HL
-%D \BC \BL \SR
-%D \VL test \VL test \VL test \VL\SR
-%D \HL
-%D \stoptable
-%D \stopbuffer
-%D
-%D \ShowExample
-%D
-%D \startbuffer
-%D \starttable[|c|c|c|]
-%D \BL \BL \SR
-%D \HL
-%D \VL test \VL test \VL test \VL\SR
+%D \VL test \VL test \VL \SR
+%D \HL[green,5]
+%D \VL[red] test \VL test \VL \FR
+%D \VL test \VL[10,red] test \VL \MR
+%D \VL test \VL test \VL[10] \LR
%D \HL
%D \stoptable
%D \stopbuffer
%D
-%D \ShowExample
+%D \typebuffer \getbuffer
-%D In these examples we can clearly see that for being a real
-%D background, the color or gray specification has to precede
-%D the content. Just to keep things simple, we can recall this
-%D specification later on:
-%D
-%D \startbuffer
-%D \starttable[|c|c|c|]
-%D \BC \BL \SR
-%D \HL
-%D \VL test \VL test \VL test \VL\SR
-%D \HL
-%D \BR\FR
-%D \VL test \VL test \VL test \VL\FR
-%D \BR\MR
-%D \VL test \VL test \VL test \VL\MR
-%D \BR\LR
-%D \VL test \VL test \VL test \VL\LR
-%D \HL
-%D \stoptable
-%D \stopbuffer
-%D
-%D \ShowExample
-%D
-%D Close study learns that we can put the specification
-%D before or after the \type{\HL}, whatever suits best. Keeping
-%D track of these specifications is taken care of by the next
-%D variables:
-
-\newif \ifTABLEgrayline % executing gray line
-\newif \ifTABLEgraydone % gray line executed
-\newtoks \TABLEgraytoks % gray line specification
-
-\newif\ifTABLEinbreak
-
-%D Nog vervangen:
-
-\def\c!Table{Table}
+\def\s!TaBlE{TaBlE}
\def\m!TABLE{TABLE}
-
+
%D We already saw that the table macros report errors and
%D provide automatic spacing. These features can only be
%D implemented by keeping track of the state, often the last
%D command on a row.
-\chardef\TABLEunknown = 0
+\newconstant\tableforcestate
+\newconstant\tableactionstate
+
+\setnewconstant\tableunknownstate 0
-\chardef\TABLEseparaterow = 1
-\chardef\TABLEfirstrow = 2
-\chardef\TABLEmidrow = 3
-\chardef\TABLElastrow = 4
-\chardef\TABLErule = 5
-\chardef\TABLEskip = 6
-\chardef\TABLEautorow = 7
+\setnewconstant\tableseparaterowstate 1
+\setnewconstant\tablefirstrowstate 2
+\setnewconstant\tablemidrowstate 3
+\setnewconstant\tablelastrowstate 4
+\setnewconstant\tablerulestate 5
+%setnewconstant\tableskipstate 6
+%setnewconstant\tableautorowstate 7
-\chardef\TABLEforcefirstrow = 1
-\chardef\TABLEforcelastrow = 2
+\setnewconstant\tableforcefirstrowstate 1
+\setnewconstant\tableforcelastrowstate 2
-\chardef\TABLEmissingrow = 1
-\chardef\TABLEmissingcolumn = 2
-\chardef\TABLEspanoverflow = 3
-\chardef\TABLEdivisionoverflow = 4
+\newconstant\tablerowfactor
+\newconstant\TABLEendofrowdepth
+\newconstant\TABLEendofrowheight
+\newconstant\TABLEcr
+\newconstant\tablerowzero
+\newconstant\TABLEn
-%D We store these states using efficient \type {\chardef}'s.
-%D Like most variables, these are global ones. When needed,
+%D We store these states using \type {constants}'s and
+%D like most variables, these are global ones. When needed,
%D especially when we flush the backgrounds, we can temporary
%D disable the assignment.
-\newif\ifsetTABLEaction
-
-\def\setTABLEaction#1%
- {\ifsetTABLEaction\global\chardef\TABLEaction#1\fi}
-
-\def\setTABLEforce#1%
- {\ifsetTABLEaction\global\chardef\TABLEforce#1\fi}
-
-\def\setTABLEerror#1%
- {\global\chardef\TABLEerror#1}
-
-%D Before we come to using these variables, we redefine and/or
-%D adapt some \TABLE\ macros. Within \TABLE's the \type{|} and
-%D \type{"} have special meanings in templates and are active
-%D during. Their meaning can therefore conflict with those
-%D elsewhere defined. To be compatible with traditional \TABLE\
-%D as well as \CONTEXT's \type{||} and the active \type{"}
-%D extensions for my german friends, we do some catcode magic.
-
-\newif\ifForgetTableBarAndQuote \ForgetTableBarAndQuotetrue
-
-% \bgroup
+\newconditional\tableactionstatepermitted
-% \catcode`\|=\@@active
-% \catcode`\"=\@@active
-%
-% \gdef\pushouterbarandquote
-% {\ifForgetTableBarAndQuote
-% \ifnum\catcode`\|=\@@active \let\outertablebar |\else\let\outertablebar \relax\fi
-% \ifnum\catcode`\"=\@@active \let\outertablequote"\else\let\outertablequote\relax\fi
-% \let|\letterbar
-% \let"\letterdoublequote
-% \fi}
-%
-% \gdef\popouterbarandquote
-% {\ifForgetTableBarAndQuote
-% \ifx\outertablebar \relax\else\let|\outertablebar \fi
-% \ifx\outertablequote\relax\else\let"\outertablequote\fi
-% \else
-% \redefinetablebarandquote
-% \fi}
-%
-% \egroup
-%
-% \def\ObeyTableBarAndQuote
-% {\ForgetTableBarAndQuotefalse
-% \ifintable
-% \redefinetablebarandquote
-% \fi}
-
-\let\ActivateBarAndQuote \relax
-\let\ObeyTableBarAndQuote\relax
-\let\pushouterbarandquote\relax
-\let\popouterbarandquote \relax
-
-%D \macros
-%D {ObeyTableBarAndQuote}
-%D
-%D As said, the \type{|} and \type{"} active characters are
-%D often used for other purposes. By default, the outside
-%D meanings are therefore preserved and available inside
-%D tables. If for some reason one wants to use the \TABLE\
-%D primitives, one can say:
-%D
-%D \starttyping
-%D \ObeyTableBarAndQuote
-%D \stoptyping
-%D
-%D To keep things verbose, as well as to show what \TABLE\
-%D commands we affect, we show some meanings.
-
-\def\normalTABLEshortrule {\!ttShortHrule} % \-
-\def\normalTABLElongrule {\!ttLongHrule} % \=
-\def\normalTABLEfullrule {\!ttFullHrule} % \_
-\def\normalTABLEendofrow {\!ttEndOfRow} % \\
-\def\normalTABLEsimplebar {\unskip\!ttRightGlue&&} % |
-\def\normalTABLEcomplexbar {\unskip\!ttRightGlue&\omit\!ttAlternateVrule} % \|
-\def\normalTABLEquote {\unskip\!ttRightGlue&\omit&} % "
-\def\normalTABLElineformat {\normalTABLEendofrow+}
-\def\normalTABLElineending {\normalTABLEendofrow0 }
-\def\normalTABLEsinglerule {&\normalTABLElongrule&}
-\def\normalTABLEmultirule#1{&\use{#1}\normalTABLElongrule&}
-
-%D The next hack is dedicated to Tobias, who found out that
-%D paragraph entries don't break well.
-
-\def\TABLEhack{\hskip\zeropoint}
-
-%D The first attemp to solve this problem was:
-%D
-%D \starttyping
-%D \def\normalTABLEquote%
-%D {\unskip\TABLEhack\!ttRightGlue&\omit&\TABLEhack}
-%D \stoptyping
-%D
-%D But, as usual, this interfered with \type {\omit}.
-%D
-%D The next attempt is redefining some core \TABLE\ macro:.
-%D This works ok, but breaks for instance the~\type{b}
-%D key handling.
-%D
-%D \starttyping
-%D \def\!tfAdjoinPriorColumn%
-%D {\ifnum\!taColumnNumber=0
-%D \!taPreamble=\!taRuleColumnTemplate
-%D ...
-%D \if!taOnceOnlyTabskip
-%D \!thToksEdef\!taDataColumnTemplate=
-%D {\TABLEhack####\TABLEhack\tabskip\the\!taLastRegularTabskip}
-%D \else
-%D \!taDataColumnTemplate{\TABLEhack##\TABLEhack}%
-%D \fi
-%D ...
-%D \ReadFormatKeys}
-%D \stoptyping
-
-% \newdimen\TABLEparheight
-
-\def\BeginTableParBox#1%
- {\setbox\scratchbox\vtop\bgroup % \setbox added
- \hsize#1\relax
- \dontcomplain
- \restoretablelineskips
- \normalbaselines
- \let~\!ttTie
- \let\-\!ttDH
- \blank[\v!disable]% % added
- \the\EveryTableParBox}
-
-\def\EndTableParBox
- {\removelastskip % itemize or so
- \endgraf
- \ifnum\prevgraf>\zerocount % we want at least
- \verticalstrut \nowhitespace \vskip-\struttotal % one line of text
- \egroup
- \ifdim\dp\scratchbox>\lineheight % see (*) for an
- \getnoflines{\dp\scratchbox}% % example of where
- \dp\scratchbox\zeropoint % saving can go
- \setbox\scratchbox % terrible wrong
- \vtop to \noflines\lineheight{\box\scratchbox}%
- \fi % esp between rows
- \else % of paragraphs
- \egroup
- \fi
-% \getboxheight\scratchdimen\of\box\scratchbox\relax% compensate for
-% \ifdim\scratchdimen>\TABLEparheight % funny depth of
-% \global\TABLEparheight\scratchdimen % multi-line box
-% \fi % i.e. vtop
- \box\scratchbox}
-
-% We also need to patch away the interfering math switch:
-
-% \mathpunctuationtrue
-
-% test, test
-% \starttable[|c|]
-% \NC1,,10\NC\AR
-% \stoptable
-% test, test
-
-\def\!ttBeginTableA[#1]{%
- \if #1u% % "unboxed" table
- \ifmmode
- \def\!ttEndTable{% % user had better be in display math mode
- \relax}% % and have only one table at the outer level
- \else % user had better be in vertical mode
- \bgroup
- \def\!ttEndTable{%
- \egroup}%
- \fi
- \else
- %\hbox\bgroup $
- %\def\!ttEndTable{%
- % \egroup % for the \vtop, \vbox, or \vcenter, yet to come
- % $% for math mode
- % \egroup}% for the \hbox
- %\if #1t%
- % \vtop
- %\else
- % \if #1b%
- % \vbox
- % \else
- % \vcenter % math mode was essential for this
- % \fi
- %\fi
- %
- \hbox\bgroup
- \def\!ttEndTable{\egroup\egroup}%
- \if#1t%
- \vtop
- \else\if#1b%
- \vbox
- \else
- \def\!ttEndTable{\egroup$\egroup}%
- %$\vcenter
- \scratchtoks\everymath\everymath\emptytoks$\everymath\scratchtoks\vcenter
- \fi\fi
- %
- \bgroup % for the \vtop, \vbox, or \vcenter
- \fi
- \advance\!taRecursionLevel 1 % RecursionLevel governs initialization
- \let\!ttRightGlue=\relax % This may be changed by \JustCenter, etc
- \everycr\emptytoks % ={}
- \ifnum \!taRecursionLevel=1
- \!ttInitializeTable
- \fi}
-
-%D The next redefinition is more robust than the original:
-
-\def\SetTableToWidth#1%
- {\doifelsenothing{#1}{\!taTableSpread\emptytoks}{\!taTableSpread{to #1}}}
-
-% (*) Try this one with \type {direction} and {girection};
-% the \PPCHTEX\ manual is a nice testcase.
-%
-% \startoverlay
-% {\starttable[ | l w(2cm) | w(8cm) | ]
-% \HL
-% \VL direction \VL \showbaselines \dorecurse{3}{direction }\VL \FR
-% \VL direction \VL \showbaselines \dorecurse{3}{direction }\VL \MR
-% \VL direction \VL \showbaselines \dorecurse{3}{direction }\VL \LR
-% \HL
-% \stoptable}
-% {\starttable[ | l w(2cm) | p(8cm) | ]
-% \HL
-% \VL direction \VL \showbaselines \dorecurse{3}{direction }\VL \FR
-% \VL direction \VL \showbaselines \dorecurse{3}{direction }\VL \MR
-% \VL direction \VL \showbaselines \dorecurse{3}{direction }\VL \LR
-% \HL
-% \stoptable}
-% \stopoverlay
-% \vskip2cm
-% \starttable[ | l w(2cm) | p(8cm) | ]
-% \HL
-% \VL direction \VL \showbaselines \dorecurse{3}{direction }\VL \FR
-% \VL direction \VL \showbaselines \dorecurse{8}{direction }\VL \LR
-% \HL
-% \stoptable
-% \vskip2cm
-% \starttable[ | l w(2cm) | p(8cm) | ]
-% \HL
-% \VL direction \VL \showbaselines \dorecurse{8}{direction }\VL \FR
-% \VL direction \VL \showbaselines \dorecurse{8}{direction }\VL \LR
-% \HL
-% \stoptable
+\def\dosettableaction#1{\ifconditional\tableactionstatepermitted\global\tableactionstate#1\fi}
+\def\dosettableforce #1{\ifconditional\tableactionstatepermitted\global\tableforcestate #1\fi}
%D To give an impression of what the (well documented) source
%D of \TABLE\ looks like, we first implement an alternative for
@@ -624,326 +1309,10 @@
%D of the numeric ones. To permit double loading of this
%D module, we check for the existence of one of the macros.
-\letvalue{!tk<\string q>}=\undefined
-\letvalue{!tk<\string Q>}=\undefined
-
-%D We just copy the original {\em comments}.
-%D
-%D \em Key \type{q}: quantity item, non||math mode.
-
-\NewFormatKey q%
- {\letempty\!tqStyle
- \futurelet\!tnext\!tqTestForBracket}
-
-%D \em Key \type{Q}: quantity item, math mode.
-
-\NewFormatKey Q%
- {\def\!tqStyle{$}%
- \futurelet\!tnext\!tqTestForBracket}
-
-%D \em Note: the space between a quantity entry and the
-%D following \type{|}, \type{"}, or \type{\|} is mandatory.
-%D empty quantity entries are not allowed: use \type{{}} or
-%D \type{\omit} instead.
-%D
-%D \em Test for bracket: invoked by the keys \type{q} and
-%D \type{Q}.
-
-\def\!tqTestForBracket
- {\ifx[\!tnext
- \!thx\!tqGetArgument
- \else
- \!thx\!tqGetCode
- \fi}
-
-%D \em Get code: e.g. \type{4}, or \type{4,0}, \type{0,4}, or
-%D \type{10,2}.
-
-\def\!tqGetCode#1 % note the blank
- {\!tqConvertCode #1,,!}
-
-%D \em Convert code: e.g. converts above to \type{[0000]},
-%D \type{[0000,]}, \type{[,0000]}, \type{[0000000000,00]}.
-
-\def\!tqConvertCode #1,#2,#3!%
- {\begingroup
- \aftergroup\edef
- \aftergroup\!ttemp
- \aftergroup{%
- \aftergroup[%
- \!taCountA #1
- \!thLoop
- \ifnum \!taCountA>\zerocount
- \advance\!taCountA \minusone
- \aftergroup0
- \repeat
- \def\!ttemp{#3}%
- \ifx\!ttemp\empty
- \else
- \aftergroup,
- \!taCountA #2
- \!thLoop
- \ifnum\!taCountA>\zerocount
- \advance\!taCountA \minusone
- \aftergroup0
- \repeat
- \fi
- \aftergroup]\aftergroup}%
- \endgroup\relax
- \!thx\!tqGetArgument\!ttemp}
-
-%D \em Get argument:
-%D
-%D \starttyping
-%D <sample left field> <optional, sample right field>
-%D \stoptyping
-
-\def\!tqGetArgument[#1]%
- {\!tqMakeQuantityTemplate\!tqStyle#1,,!}
-
-%D \em Make quantity template.
-
-\def\!tqMakeQuantityTemplate#1#2,#3,#4!% #1=<empty> or $
- {\def\!ttemp{#4}%
- \ifx\!ttemp\empty
- \!taDimenC\zeropoint
- \else
- \setbox0\hbox{\mathsurround\zeropoint #1,#3#1}%
- \!taDimenC\wd0
- \fi
- \setbox0\hbox{\mathsurround\zeropoint #1#2#1}%
- \!thToksEdef\!taDataColumnTemplate
- ={\noexpand\!tqSetQuantityItem{\the\wd0 }{\the\!taDimenC}{#1}%
- \the\!taDataColumnTemplate}%
- \ReadFormatKeys}
-
-%D \em Set numeric item.
-
-\def\!tqSetQuantityItem #1#2#3#4 %
- {\!tqSetQuantityItemA{#1}{#2}{#3}#4,,!}
-
-\def\!tqSetQuantityItemA #1#2#3#4,#5,#6!%
- {\def\!ttemp{#6}%
- \hbox to #1{\hss\mathsurround\zeropoint#3#4#3}%
- \hbox to #2{\ifx\!ttemp\empty\else\mathsurround\zeropoint#3,#5#3\fi\hss}}
-
-%D Here ends the Q||extension. Did you watch the clever use
-%D of aftergroup in \type{\!tqConvertCode}.
-
-% %D We also (have to) define a key for \type{\cap}:
-%
-% \letvalue{!tk<\string K>}=\undefined
-%
-% \NewFormatKey K%
-% {\ReadFormatKeys b\smallcapped}
-
-%D A few pages back we saw backgrounds, further on we will see
-%D colored rules, and here we provide a means to color the
-%D entries in a column. (We can of course always use the normal
-%D color commands for individual entries.) We could not use the
-%D lowercase~\type{c}, because that one is used to force {\em
-%D centering}.
-%D
-%D \startbuffer
-%D \starttable[|C{red}|C{green}|C{blue}|]
-%D \VL R(ed) \VL G(reen) \VL B(lue) \VL\SR
-%D \stoptable
-%D \stopbuffer
-%D
-%D \ShowExample
-
-\letvalue{!tk<\string C>}=\undefined
-
-\NewFormatKey C#1%
- {\ReadFormatKeys b{\startcolor[#1]} a{\stopcolor}}
-
-%D So now we have three new keys:
-%D
-%D \starttable[|||]
-%D \HL
-%D \NC \bf key \NC \bf meaning \NC\AR
-%D \HL
-%D \NC Q[x,y] \NC math mode formatted numbers \NC\AR
-%D \NC q[x,y] \NC text mode formatted numbers \NC\AR
-%D \NC C{identifier} \NC column entry color \NC\AR
-%D \HL
-%D \stoptable
-
%D To be compatible with the tabulate environment, we also
%D support the \type {l}, \type {c} and \type {r} keys for
%D paragraph entries.
-\letvalue{!tk<\string l>}=\undefined
-\letvalue{!tk<\string c>}=\undefined
-\letvalue{!tk<\string r>}=\undefined
-\letvalue{!tk<\string x>}=\undefined % not that needed
-
-\NewFormatKey c%
- {\prependtoks\raggedcenter\to\!taDataColumnTemplate
- \ReadFormatKeys \LeftGlue\hfil \RightGlue\hfil}
-
-\NewFormatKey l%
- {\prependtoks\raggedright\to\!taDataColumnTemplate
- \ReadFormatKeys \LeftGlue\empty \RightGlue\hfil}
-
-\NewFormatKey r%
- {\prependtoks\raggedleft\to\!taDataColumnTemplate
- \ReadFormatKeys \LeftGlue\hfil \RightGlue\empty}
-
-\NewFormatKey x%
- {\prependtoks\notragged\to\!taDataColumnTemplate
- \ReadFormatKeys \LeftGlue\hfil \RightGlue\empty}
-
-\appendtoks \TABLEparalignment \to \EveryTableParBox
-
-\def\!tfReFormat#1%
- {\the \!taLeftGlue
- \vbox{\forgetall\ialign{\span\the\!taDataColumnTemplate\cr#1\cr}}%
- \the \!taRightGlue
- \kern\zeropoint} % prevents \unskip / really needed
-
-%D Later on, we're going to implement multiple page table
-%D support, therefore the next \TABLE\ macro needs to be
-%D slightly adapted, i.c. the penalty is removed. We also
-%D add basic color support.
-
-\def\!ttFullHruleA
- {\!ttGetHalfRuleThickness
- \startglobalTABLEcolor % added
- \hrule\!thHeight\dimen0\!thDepth\dimen0
- \stopglobalTABLEcolor % added
- %\penalty0 % removed
- \egroup}
-
-%D We'll see that when we want to give a vertical rule a color,
-%D we have to set and reset states. After heavy testing it
-%D proved most useful to extend a \TABLE\ primitive with some
-%D hooks. One thing to keep in mind is that \type{&} keeps
-%D assignments local. Again, we add basic color support.
-
-\let\TABLEbeforebar\empty
-\let\TABLEafterbar \empty
-
-\def\@VLn{1}
-\def\@VLd{.125em}
-
-\def\do!ttInsertVrule % will be merged in 2005
- {\vrule \!thWidth
- \ifnum\!tgCode=\plusone
- \ifx\!tgValue\empty
- \LineThicknessFactor
- \else
- \!tgValue
- \fi
- \LineThicknessUnit
- \else
- \!tgValue
- \fi
- \hskip\@VLd}
-
-\def\!ttInsertVrule
- {\hfil
- \TABLEbeforebar % added
- \startglobalTABLEcolor % added
- % we could do without this speedup, some day merge 'm
- \ifcase\@VLn\or
- \do!ttInsertVrule
- \unskip
- \else
- \dorecurse\@VLn\do!ttInsertVrule
- \gdef\@VLn{1}%
- \unskip
- \fi
- \stopglobalTABLEcolor % added
- \TABLEafterbar % added
- \hfil
- &}
-
-%D The next two macros are only adapted to basis rule
-%D color support.
-
-\def\!tfSetVrule
- {\!thToksEdef\!taRuleColumnTemplate=
- {\noexpand\hfil
- \noexpand\startglobalTABLEcolor % added
- \noexpand\vrule
- \noexpand\!thWidth
- \ifnum\!tgCode=\plusone
- \ifx\!tgValue\empty
- \the\LineThicknessFactor
- \else
- \!tgValue
- \fi
- \!taLTU
- \else
- \!tgValue
- \fi
- ####%
- \noexpand\hfil
- \noexpand\stopglobalTABLEcolor % added
- \the\!taRuleColumnTemplate}%
- \!tfAdjoinPriorColumn}
-
-\def\!ttShortHruleA
- {\!ttGetHalfRuleThickness
- \startglobalTABLEcolor % added
- \leaders\hrule\!thHeight\dimen0\!thDepth\dimen0\hfill
- \stopglobalTABLEcolor % added
- \null
- \ignorespaces}
-
-%D We already showed the next one, but here we slightly adapt
-%D the macro by adding an \type{\expandafter}. The space after
-%D \type{#1} is crucial!
-
-\def\normalTABLEcomplexbar#1%
- {\unskip\!ttRightGlue&\omit\expandafter\!ttAlternateVrule#1 }
-
-%D To get rid of interfering \type{\omit}'s when we are
-%D checking the number of columns and reporting problems. The
-%D extensions concern the second level check, the first
-%D subbranch and advancing the column.
-
-\ifx\mscount\undefined \newcount\mscount \fi
-
-\def\!ttuse#1%
- {\ifnum#1>\plusone
- \omit
- \global\TABLEdivisionfalse
- \scratchcounter\currentTABLEcolumn % added
- \advance\scratchcounter #1% % added
- \advance\scratchcounter \minusone % added
- \ifnum\scratchcounter>\maxTABLEcolumn % added
- \def\next % added
- {\setTABLEerror\TABLEspanoverflow % added
- \handleTABLEerror}% % added
- \else % added
- \def\next % added
- {\global\advance\currentTABLEcolumn #1% % added
- \global\advance\currentTABLEcolumn \minusone % added
- \mscount#1% \mscount is in Plain
- \advance\mscount \minusone
- \advance\mscount \mscount
- \!thLoop
- \ifnum\mscount>\plusone
- \spanomit \advance\mscount\minusone
- \repeat
- \span}%
- \fi % added
- \else % added
- \def\next % conflicts with possible next \omit % added
- {\global\advance\currentTABLEcolumn \plusone}% % added
- \fi
- \next} % added
-
-% \starttable[|c|c|c|c|]
-% \HL
-% \VL {test} \VL \TWO{} \VL test \VL\FR
-% \DL \DC \DL\DR
-% \VL {test} \VL \TWO{} \VL test \VL\LR
-% \HL
-% \stoptable
-
%D All commands that are executed between rows are to be put in
%D \type {\noalign}. We can however not verify if we (that is
%D \TABLE) does or did not enter this mode. A moderate dirty
@@ -952,9 +1321,18 @@
%D such hacks become a second nature. However, redefining \type
%D {\omit} and \type{\span} is not that easy.}
-\def\TABLEnoalign
- {\noalign\bgroup\let\noalign\relax\let\next=}
-
+\def\tablenoalign
+ {\noalign
+ \bgroup
+ \let\noalign\relax
+ \let\tablenoalign\relax
+ \let\next=}
+
+\def\starttablenoalign
+ {\tablenoalign\bgroup}
+
+\let\stoptablenoalign\egroup
+
%D \macros
%D {starttable}
%D
@@ -980,8 +1358,15 @@
\newconditional\tablerepeathead
\newconditional\tablerepeattail
+
\unexpanded\def\starttable
{\bgroup
+ \dodoubleempty\dostarttable}
+
+\unexpanded\def\dostarttable[#1][#2]% preamble optional-settings
+ {\ifsecondargument
+ \getparameters[\??ti][#2]%
+ \fi
\let\stoptable\dostoptable
\doif\@@tisplit\v!auto
{\ifinsidesplitfloat\let\@@tisplit\v!yes\fi}%
@@ -992,7 +1377,8 @@
{\ifinsidefloat\else\startbaselinecorrection\fi}
{\startframedcontent[\@@tiframe]}%
\postponenotes
- \firststagestartTABLE}}
+ \firststagestarttable}%
+ [#1]}
% We cannot define \unexpanded\def\dostoptable a ssomehow lookahead
% in alignments fail then, so we relax it and define it locally.
@@ -1000,11 +1386,13 @@
\let\stoptabel\relax
\def\dostoptable
- {\chuckTABLEautorow % before the tail, else noalign problem
- \insertTABLEtail
- \TABLEnoalign{\globalletempty\@@TABLEhead}%
- \TABLEnoalign{\globalletempty\@@TABLEtail}%
- \finishTABLE
+ {\dochucktableautorow % before the tail, else noalign problem
+ \doinserttabletail
+ \starttablenoalign
+ \globalletempty\dotablehead
+ \globalletempty\dotabletail
+ \stoptablenoalign
+ \dofinishtable
\doifelsenothing\@@tiframe
{\ifinsidefloat\else
\stopbaselinecorrection
@@ -1016,15 +1404,10 @@
%D Before we can grab the argument, we have to make sure that
%D the \CATCODES\ are set. The first stage takes care of that.
-\def\firststagestartTABLE
- {\bgroup % kan-ie weg?
+\def\firststagestarttable%
+ {\bgroup
\global\intabletrue
- \pushouterbarandquote
- %catcode`\|=\@@other
- \complexorsimple\secondstagestartTABLE}
-
-\def\simplesecondstagestartTABLE#1%
- {\complexsecondstagestartTABLE[{#1}]}
+ \secondstagestarttable}
%D \macros
%D {definetabletemplate}
@@ -1047,19 +1430,19 @@
\unexpanded\def\definetabletemplate % to be redone
{\bgroup
- \catcode`\|=\@@other
+ \catcode\barasciicode\othercatcode
\doquadrupleempty\dodefinetabletemplate}
\def\dodefinetabletemplate[#1][#2][#3][#4]%
{\ifsecondargument
- \setgvalue{\c!Table#1}{\douseTABLEtemplate{#2}{#3}{#4}}%
+ \setgvalue{\s!TaBlE#1}{\dousetabletemplate{#2}{#3}{#4}}%
\fi
\egroup}
-\def\douseTABLEtemplate#1#2#3%
- {\gdef\TABLEhead{\getvalue{@@TABLEhead#2}}%
- \gdef\TABLEtail{\getvalue{@@TABLEtail#3}}%
- \complexsecondstagestartTABLE[#1]}
+\def\dousetabletemplate#1#2#3%
+ {\gdef\dotablehead{\getvalue{@@tablehead#2}}%
+ \gdef\dotabletail{\getvalue{@@tabletail#3}}%
+ \secondstagestarttable[#1]}
%D The optional third and fourth arguments define which table
%D head and tail to use.
@@ -1085,69 +1468,70 @@
%D The second half of the next macro prepares table
%D splitting.
-\def\insertTABLEhead
- {\TABLEnoalign{\global\settrue \preventTABLEbreak \global\setfalse\someTABLEhead}%
- \TABLEhead
- \TABLEnoalign{\global\setfalse\preventTABLEbreak}}
-
-\def\insertTABLEtail
- {\TABLEnoalign{\global\settrue \preventTABLEbreak \global\setfalse\someTABLEtail}%
- \TABLEtail
- \TABLEnoalign{\global\setfalse\preventTABLEbreak}}
-
-% \def\dorestartTABLE#1%
-% {\gdef\restartTABLE{#1}%
-% \restartTABLE
-% \insertTABLEhead
-% \ifsplittables \ifconditional \tablerepeattail
-% \TABLEnoalign{\goodbreak}%
-% \insertTABLEtail
-% \TABLEnoalign{\goodbreak}%
-% \fi \fi}
-
-\def\verysimpleTableHL
- {\TABLEnoalign{\expandafter\normalTABLEfullrule\@@tiHLheight}}
-
-\def\dorestartTABLE#1%
- {\gdef\restartTABLE{#1}%
- \restartTABLE
- \TABLEnoalign{\globalpushmacro\simpleTableHL\global\let\simpleTableHL\verysimpleTableHL}%
- \insertTABLEhead
+\def\doinserttablehead
+ {\starttablenoalign
+ \global\settrue\preventtablebreak
+ \global\setfalse\hassometablehead
+ \stoptablenoalign
+ \dotablehead
+ \starttablenoalign
+ \global\setfalse\preventtablebreak
+ \stoptablenoalign}
+
+\def\doinserttabletail
+ {\starttablenoalign
+ \global\settrue\preventtablebreak
+ \global\setfalse\hassometabletail
+ \stoptablenoalign
+ \dotabletail
+ \starttablenoalign
+ \global\setfalse\preventtablebreak
+ \stoptablenoalign}
+
+% \def\doverysimpletableHL % todo
+% {\starttablenoalign
+% \expandafter\donormaltablefullrule\@@tiHLheight
+% \stoptablenoalign}
+
+\def\dorestarttable#1%
+ {\gdef\restarttable{#1}%
+ \restarttable
+% \starttablenoalign
+% \globalpushmacro\simpletableHL
+% \global\let\simpletableHL\doverysimpletableHL
+% \stoptablenoalign
+ \doinserttablehead
\ifsplittables \ifconditional \tablerepeattail
- \TABLEnoalign{\goodbreak}%
- \insertTABLEtail
- \TABLEnoalign{\goodbreak}%
+ \tablenoalign{\goodbreak}%
+ \doinserttabletail
+ \tablenoalign{\goodbreak}%
\fi \fi
- \TABLEnoalign{\globalpopmacro\simpleTableHL}}
+% \starttablenoalign
+% \globalpopmacro\simpletableHL
+% \stoptablenoalign
+ }
-\bgroup \catcode`|=\@@other \catcode`"=\@@other
+\bgroup \catcode\barasciicode\othercatcode
-\gdef\complexsecondstagestartTABLE#1[#2]% brr nested mess
+\gdef\secondstagestarttable[#1]% brr nested mess
{\bgroup
\@@useotherbar
- \@@useotherquote
- \global\setfalse\someTABLEhead
- \global\setfalse\someTABLEtail
- \expanded{\doifinstringelse{|}{#2}}
- {\xdef\restartTABLE{\noexpand\dorestartTABLE{\noexpand\thirdstagestartTABLE{#2}}}}
- {\doifdefinedelse{\c!Table#2}
- {\gdef\restartTABLE{\getvalue{\c!Table#2}}}
- {\gdef\restartTABLE{\dorestartTABLE{\getvalue{#2}}}}}%
+ \global\setfalse\tableactionstatepermitted
+ \global\setfalse\hassometablehead
+ \global\setfalse\hassometabletail
+ \expanded{\doifinstringelse{|}{#1}}
+ {\xdef\restarttable{\noexpand\dorestarttable{\noexpand\thirdstagestarttable{#1}}}}
+ {\doifdefinedelse{\s!TaBlE#1}
+ {\gdef\restarttable{\getvalue{\s!TaBlE#1}}}
+ {\gdef\restarttable{\dorestartable{\getvalue{#1}}}}}%
\egroup
- \restartTABLE}
+ \restarttable}
\egroup
%D The third stage involves a lot of (re)sets, which we will
%D explain later.
-%D The next definition is convenient and more in tune with
-%D \CONTEXT.
-
-\let \everytable \EveryTable
-
-%D We immediately use this register:
-
\appendtoks
\fixedspaces
\let\_\normalunderscore
@@ -1155,39 +1539,27 @@
%D Now we can start the table.
-\def\thirdstagestartTABLE#1%
- {\global\setTABLEactiontrue
- \setTABLEaction\TABLEunknown
- \setTABLEforce\TABLEunknown
- \setTABLEerror\TABLEunknown
- \global\TABLEgraylinefalse
- \global\TABLEgraydonefalse
- \globalletempty\TABLEgrayline
- \globalletempty\nextTABLEgrayline
- \globalletempty\TABLEgraylineerror
- \globalletempty\TABLEgraylinestatus
- \resetVLvalues
- \appendtoks\popouterbarandquote\to\EveryTable
- \appendtoks\localTABLEsetup\to\EveryTable
- \BeginTable[\ifsplittables u\else b\fi]%
- \defineTABLEunits
- \defineTABLEsteps
- \defineTABLErules
- \defineTABLEdivisions
- \defineTABLEshorthands
- \defineTABLEbackgrounds
- \defineTABLEendings
+\newtoks \localtabledefinitions
+
+\def\thirdstagestarttable#1%
+ {\global\settrue\tableactionstatepermitted
+ \dosettableaction\tableunknownstate
+ \dosettableforce\tableunknownstate
+ \dotableresetVLvalues
+ \appendtoks\dolocaltablesetup\to\everytable
+ \dotablestandardbegin[\ifsplittables u\else b\fi]%
+ \the\localtabledefinitions
\forgetall % added
- \doifsomething{#1}
- {\def\TABLEformat{#1}%
- \getTABLEnofcolumns\TABLEformat
+ \edef\currenttableformat{#1}%
+ \doifsomething\currenttableformat
+ {\dogettablenofcolumns\currenttableformat
% more modern is to use catcode tables
- \expandafter\BeginFormat\TABLEformat\EndFormat}}
+ \expandafter\dobegintableformat\currenttableformat\doendtableformat}}
-\def\finishTABLE
- {\chuckTABLEautorow
+\def\dofinishtable
+ {\dochucktableautorow
\unskip\crcr
- \EndTable
+ \dotablenormalend
\global\intablefalse
\egroup}
@@ -1224,33 +1596,30 @@
\flushnotes
\setbox\tablecontentbox\vbox\bgroup
\forgetall
- \global\TABLEinbreakfalse
- \firststagestartTABLE}
+ \firststagestarttable}
\let\stoptables\relax % needed for \noalign
\def\dostoptables
- {\chuckTABLEautorow % AM: before the tail, else noalign problem
- \ifconditional\tablerepeattail\else\insertTABLEtail\fi
- \finishTABLE
+ {\dochucktableautorow % AM: before the tail, else noalign problem
+ \ifconditional\tablerepeattail\else\doinserttabletail\fi
+ \dofinishtable
\egroup
\dontcomplain
\dosplittablebox\tablecontentbox
\flushnotes
\egroup}
-\newdimen\TABLEcaptionheight % obsolete
-
\def\dosplittablebox#1%
{\resettsplit
\def\tsplitminimumfreelines{2}%
- \def\tsplitminimumfreespace{\TABLEcaptionheight}%
+ \def\tsplitminimumfreespace{\zeropoint}%
\setbox\tsplitcontent\box#1%
- \ifconditional\tablerepeathead \ifconditional\someTABLEhead
+ \ifconditional\tablerepeathead \ifconditional\hassometablehead
\setbox\tsplithead\vsplit\tsplitcontent to \lineheight
\setbox\tsplithead\vbox{\unvbox\tsplithead}%
\fi \fi
- \ifconditional\tablerepeattail \ifconditional\someTABLEtail
+ \ifconditional\tablerepeattail \ifconditional\hassometabletail
\setbox\tsplittail\vsplit\tsplitcontent to \lineheight
\setbox\tsplittail\vbox{\unvbox\tsplittail}%
\fi \fi
@@ -1265,15 +1634,15 @@
%D something like:
%D
%D \starttyping
-%D \starttablekop
+%D \starttablehead
%D \HL
%D \VL element \VL atom weight \VL\AR
%D \HL
-%D \stoptablekop
+%D \stoptablehead
%D
-%D \starttablestaart
+%D \starttabletail
%D \HL
-%D \stoptablestaart
+%D \stoptabletail
%D
%D \starttables[|||]
%D \VL ....... \VL ........... \VL\AR
@@ -1288,113 +1657,52 @@
%D the fact that the stopcondition is interface language
%D dependant.
-\let\@@TABLEhead\empty \def\TABLEhead{\@@TABLEhead}
-\let\@@TABLEtail\empty \def\TABLEtail{\@@TABLEtail}
+\let\dotablehead\empty % needs checking
+\let\dotabletail\empty % needs checking
-\letvalue{\e!start\v!tablehead}=\undefined
-\letvalue{\e!stop \v!tablehead}=\undefined
-\letvalue{\e!start\v!tabletail}=\undefined
-\letvalue{\e!stop \v!tabletail}=\undefined
+\letbeundefined{\e!start\v!tablehead}
+\letbeundefined{\e!stop \v!tablehead}
+\letbeundefined{\e!start\v!tabletail}
+\letbeundefined{\e!stop \v!tabletail}
\expanded
{\long\def\csname\e!start\v!tablehead\endcsname##1\csname\e!stop\v!tablehead\endcsname%
- {\noexpand\setTABLEhead##1\noexpand\end}}
+ {\noexpand\settablehead##1\noexpand\end}}
\expanded
{\long\def\csname\e!start\v!tabletail\endcsname##1\csname\e!stop\v!tabletail\endcsname%
- {\noexpand\setTABLEtail##1\noexpand\end}}
+ {\noexpand\settabletail##1\noexpand\end}}
%D The second argument is a dummy one, by scanning for it, we
%D get rid of interfering spaces.
-\def\setTABLEhead{\dodoubleempty\dosetTABLEhead}
-\def\setTABLEtail{\dodoubleempty\dosetTABLEtail}
+\newconditional\preventtablebreak
+\newconditional\hassometablehead
+\newconditional\hassometabletail
-\newconditional\preventTABLEbreak
-\newconditional\someTABLEhead
+\def\settablehead{\dodoubleempty\dosettablehead}
+\def\settabletail{\dodoubleempty\dosettabletail}
-\long\def\dosetTABLEhead[#1][#2]#3\end{\setvalue{@@TABLEhead#1}{\TABLEnoalign{\global\settrue\someTABLEhead}#3}}
-\long\def\dosetTABLEtail[#1][#2]#3\end{\setvalue{@@TABLEtail#1}{\TABLEnoalign{\global\settrue\someTABLEtail}#3}}
+\long\def\dosettablehead[#1][#2]#3\end{\setvalue{@@tablehead#1}{\tablenoalign{\global\settrue\hassometablehead}#3}}
+\long\def\dosettabletail[#1][#2]#3\end{\setvalue{@@tabletail#1}{\tablenoalign{\global\settrue\hassometabletail}#3}}
%D Redudant \type{\HL}'s are removed automatically, so
%D mid||lines can be used without problems.
-%D We need an alternative for the normal complex or simple
-%D commands, because assignments in these system commands
-%D conflict with \type{\noalign}. This alternative is about
-%D as efficient as possible.
-
-\def\complexorsimpleTable#1#2%
- {\csname\if[\noexpand#2\s!complex\else\s!simple\fi\c!Table#1\endcsname#2}
-
-%D The next one is used in \type{\VL} cum suis and honours
-%D the next grouping.
-
-\def\docomplexorsimpleTable#1#2%
- {\ifx\next\bgroup\@EA#2\else\@EA\dodocomplexorsimpleTable\@EA#1\@EA#2\fi}
-
-\def\dodocomplexorsimpleTable#1#2#3%
- {\if[\noexpand#3\@EA#1\else\@EA#2\fi#3}
-
%D The order of the next macros is more or less random. First
%D we implement error recovery. Errors are reported to the
%D screen and log file as well as visualized in the table in
%D teletype.
-\def\handleTABLEerror
- {\ifTABLEgrayline \else
- \ifnum\TABLEerror=\TABLEunknown \else
- \setTABLEaction\TABLEunknown
- \globalletempty\checkTABLEautorow
- \globalletempty\chuckTABLEautorow
- \fi
- \ifcase\TABLEerror
- % no error
- \or
- % \TABLEmissingrow
- \tttf [missing row]%
- \writestatus\m!TABLE{missing row}%
- \SR
- \or
- % \TABLEmissingcolumn
- \fillTABLEcolumns
- \tttf [missing column]%
- \writestatus\m!TABLE{missing column}%
- \SR
- \or
- % \TABLEspanoverflow
- \fillTABLEcolumns
- \tttf [columnspan too large]%
- \writestatus\m!TABLE{columnspan too large}%
- \SR
- \or
- % \TABLEdivisionoverflow
- \fillTABLEcolumns
- \tttf [division line too long]%
- \writestatus\m!TABLE{division line too long}%
- \SR
- \fi
- \fi
- \ifnum\TABLEerror=\TABLEunknown \else
- \finishTABLErow
- \fi}
-
-\def\finishTABLErow
+\def\dofinishtablerow
{\crcr
- \TABLEnoalign
- {\nobreak
- \setTABLEaction\TABLEunknown
- \setTABLEerror\TABLEunknown
- \globalletempty\checkTABLEautorow
- \globalletempty\chuckTABLEautorow
- \global\currentTABLEcolumn\zerocount}}
-
-\def\fillTABLEcolumns
- {\ifnum\currentTABLEcolumn>\maxTABLEcolumn \else
- \global\advance\currentTABLEcolumn \plusone
- \normalTABLEquote
- \expandafter\fillTABLEcolumns
- \fi}
+ \starttablenoalign
+ \nobreak
+ \dosettableaction\tableunknownstate
+ \globalletempty\dochecktableautorow
+ \globalletempty\dochucktableautorow
+ \global\currenttablecolumn\zerocount
+ \stoptablenoalign}
%D Next we enter the more complicated area of column and row
%D switching. I won't go into much detail from now on, but just
@@ -1439,72 +1747,47 @@
%D handles alignments, we cannot automate spacing for colored
%D rows and columns.
-\chardef\TABLErowzero=0
-
-\def\checkTABLErow#1% pure for message purposes
- {\unskip % added
- \ifTABLEgraydone
- \defconvertedargument\asciia{#1}%
- \defconvertedcommand \asciib\TABLEendBCL
- \ifx\asciia\asciib \else
- \writestatus\m!TABLE{confusing \asciia\space and \asciib}%
- \gdef\TABLEgraylineerror%
- {\globalletempty\TABLEgraylineerror
- [\asciia\unskip<->\asciib\unskip]}%
- \fi
- \global\TABLEgraydonefalse
- \fi}
+\setnewconstant\tablerowzero\zerocount
-\unexpanded\def\defineTABLEendings
- {\let\SR\TableSR
- \let\FR\TableFR
- \let\MR\TableMR
- \let\LR\TableLR
- \let\AR\TableAR}
-
-\def\TableSR
- {\ifTABLEgrayline \else
- \ifnum\TABLEaction=\TABLEfirstrow
- \writestatus\m!TABLE{change \string\SR\space into \string\MR/\string\LR}%
- \else\ifnum\TABLEaction=\TABLEmidrow
- \writestatus\m!TABLE{change \string\SR\space into \string\MR/\string\LR}%
- \else\ifnum\TABLEaction=\TABLEmidrow
- \writestatus\m!TABLE{change \string\SR\space into \string\MR/\string\LR}%
- \fi\fi\fi
- \fi
- \checkTABLErow\SR
- \endTABLErow\TABLEseparaterow\TABLErowfactor\TABLErowfactor}
-
-\def\TableFR
- {\ifTABLEgrayline \else
- \ifnum\TABLEaction=\TABLEmidrow
- \writestatus\m!TABLE{change \string\FR\space into \string\MR/\string\LR}%
- \else\ifnum\TABLEaction=\TABLElastrow
- \writestatus\m!TABLE{change \string\FR\space into \string\MR/\string\LR}%
- \fi\fi
- \fi
- \checkTABLErow\FR
- \endTABLErow\TABLEfirstrow\TABLErowfactor\TABLErowzero}
-
-\def\TableMR
- {\ifTABLEgrayline \else
- \ifnum\TABLEaction=\TABLErule
- \writestatus\m!TABLE{change \string\MR\space into \string\FR/\string\SR}%
- \else\ifnum\TABLEaction=\TABLElastrow
- \writestatus\m!TABLE{change \string\MR\space into \string\FR}%
- \fi\fi
- \fi
- \checkTABLErow\MR
- \endTABLErow\TABLEmidrow00}
+\appendtoks
+ \let\SR\dotableSR
+ \let\FR\dotableFR
+ \let\MR\dotableMR
+ \let\LR\dotableLR
+ \let\AR\dotableAR
+\to \localtabledefinitions
+
+\unexpanded\def\dotableSR
+ {\ifnum\tableactionstate=\tablefirstrowstate
+ \writestatus\m!TABLE{change \string\SR\space into \string\MR/\string\LR}%
+ \else\ifnum\tableactionstate=\tablemidrowstate
+ \writestatus\m!TABLE{change \string\SR\space into \string\MR/\string\LR}%
+ \else\ifnum\tableactionstate=\tablemidrowstate
+ \writestatus\m!TABLE{change \string\SR\space into \string\MR/\string\LR}%
+ \fi\fi\fi
+ \doendtablerow\tableseparaterowstate\tablerowfactor\tablerowfactor}
+
+\unexpanded\def\dotableFR
+ {\ifnum\tableactionstate=\tablemidrowstate
+ \writestatus\m!TABLE{change \string\FR\space into \string\MR/\string\LR}%
+ \else\ifnum\tableactionstate=\tablelastrowstate
+ \writestatus\m!TABLE{change \string\FR\space into \string\MR/\string\LR}%
+ \fi\fi
+ \doendtablerow\tablefirstrowstate\tablerowfactor\tablerowzero}
-\def\TableLR
- {\ifTABLEgrayline \else
- \ifnum\TABLEaction=\TABLErule
- \writestatus\m!TABLE{change \string\LR\space into \string\FR/\string\SR}%
- \fi
+\unexpanded\def\dotableMR
+ {\ifnum\tableactionstate=\tablerulestate
+ \writestatus\m!TABLE{change \string\MR\space into \string\FR/\string\SR}%
+ \else\ifnum\tableactionstate=\tablelastrowstate
+ \writestatus\m!TABLE{change \string\MR\space into \string\FR}%
+ \fi\fi
+ \doendtablerow\tablemidrowstate00}
+
+\unexpanded\def\dotableLR
+ {\ifnum\tableactionstate=\tablerulestate
+ \writestatus\m!TABLE{change \string\LR\space into \string\FR/\string\SR}%
\fi
- \checkTABLErow\LR
- \endTABLErow\TABLElastrow\TABLErowzero\TABLErowfactor}
+ \doendtablerow\tablelastrowstate\tablerowzero\tablerowfactor}
%D \macros
%D {ifcheckTABLEcolums}
@@ -1517,122 +1800,69 @@
%D determine the available space are shown (in color). By default
%D checking is off.
-\newif\ifcheckTABLEcolumns
-
-\let\beforeTABLEline\empty
-\let\afterTABLEline \empty
-
-\def\doendTABLErow#1#2#3%
- {\handleTABLEbreak#2#3%
- \beforeTABLEline
+\def\doendtablerow#1#2#3%
+ {\dosettableaction#1%
\ifcase#1\relax
% unknown
\or
- \endofTABLEline[blue][\SR->\SR]\TABLErowfactor\TABLErowfactor
- \or
- \endofTABLEline[red][\FR->\FR]\TABLErowfactor\TABLErowzero
+ \doendoftableline\SR\SR\tablerowfactor\tablerowfactor
\or
- \ifnum\TABLEforce=\TABLEforcelastrow
- \endofTABLEline[red][\MR->\LR]\TABLErowzero\TABLErowfactor
- \else\ifnum\TABLEforce=\TABLEforcefirstrow
- \endofTABLEline[red][\MR->\FR]\TABLErowfactor\TABLErowzero
- \else
- \endofTABLEline[green][\MR->\MR]\TABLErowzero\TABLErowzero
- \fi\fi
- \or
- \endofTABLEline[red][\LR->\LR]\TABLErowzero\TABLErowfactor
- \fi
- \TABLEnoalign
- {\setTABLEforce\TABLEunknown
- \global\currentTABLEcolumn\zerocount}%
- \afterTABLEline}
-
-\def\endTABLErow#1#2#3%
- {\setTABLEaction#1%
- \ifTABLEgrayline
- \finishTABLErow
+ \doendoftableline\FR\FR\tablerowfactor\tablerowzero
+ \or\ifnum\tableforcestate=\tableforcelastrowstate
+ \doendoftableline\MR\LR\tablerowzero\tablerowfactor
+ \else\ifnum\tableforcestate=\tableforcefirstrowstate
+ \doendoftableline\MR\FR\tablerowfactor\tablerowzero
\else
- \ifnum\currentTABLEcolumn>\maxTABLEcolumn
- \doendTABLErow{#1}{#2}{#3}%
- \else\ifcheckTABLEcolumns
- \setTABLEerror\TABLEmissingcolumn
- \handleTABLEerror
+ \doendoftableline\MR\MR\tablerowzero\tablerowzero
+ \fi\fi\or
+ \doendoftableline\LR\LR\tablerowzero\tablerowfactor
+ \fi
+ \starttablenoalign
+ \dosettableforce\tableunknownstate
+ \global\currenttablecolumn\zerocount
+ \ifconditional\preventtablebreak
+ \nobreak
\else
- \doendTABLErow{#1}{#2}{#3}%
- \fi\fi
- \fi}
+ \goodbreak
+ \fi
+ \stoptablenoalign}
%D Handling \type{\AR} is postponed till the next row. The
%D check takes care of the first and mid rows, the chuck macro
%D |<|how about that name|>| handles the last row.
-\def\TableAR
- {\ifTABLEgraydone
- \globalletempty\checkTABLEautorow
- \globalletempty\chuckTABLEautorow
- \global\TABLEgraydonefalse
- \TABLEendBCL
- \else
- \globallet\checkTABLEautorow\docheckTABLEautorow
- \globallet\chuckTABLEautorow\dochuckTABLEautorow
- \fi}
+\unexpanded\def\dotableAR
+ {\globallet\dochecktableautorow\dodochecktableautorow
+ \globallet\dochucktableautorow\dodochucktableautorow}
-\let\checkTABLEautorow\empty
-\let\chuckTABLEautorow\empty
+\let\dochecktableautorow\empty
+\let\dochucktableautorow\empty
-\def\docheckTABLEautorow
- {\globallet\checkTABLEautorow\empty
- \ifnum\TABLEaction=\TABLErule \FR
- \else\ifnum\TABLEaction=\TABLEunknown \FR
- \else \MR
- \fi\fi}
+\def\dodochecktableautorow
+ {\globallet\dochecktableautorow\empty
+ \ifnum\tableactionstate=\tablerulestate \FR\else
+ \ifnum\tableactionstate=\tableunknownstate\FR\else
+ \MR\fi\fi}
+
+\def\dodochucktableautorow
+ {\globalletempty\dochecktableautorow
+ \globalletempty\dochucktableautorow
+ \ifnum\tableactionstate=\tablerulestate \SR\else
+ \ifnum\tableactionstate=\tableunknownstate\SR\else
+ \LR\fi\fi}
-\def\dochuckTABLEautorow
- {\globalletempty\checkTABLEautorow
- \globalletempty\chuckTABLEautorow
- \ifnum\TABLEaction=\TABLErule \SR
- \else\ifnum\TABLEaction=\TABLEunknown \SR
- \else \LR
- \fi\fi}
-
%D When a table is split, we also add a tail and when present
%D we repeat the table head.
-\def\handleTABLEbreak#1#2%
- {\globalletempty\beforeTABLEline
- \gdef\afterTABLEline{\TABLEnoalign{\ifconditional\preventTABLEbreak\nobreak\else\goodbreak\fi}}}
-
%D When tables are split, the spacing before and after a
%D horizontal rule is corrected according to what we expect.
-\def\endofTABLEline[#1][#2->#3]#4#5%
- {\ifx#2#3\else
- \writestatus\m!TABLE{\string#2\space changed into \string#3}%
+\def\doendoftableline#1#2#3#4%
+ {\ifx#1#2\else
+ \writestatus\m!TABLE{\string#1\space changed into \string#2}%
\fi
- \iftracetables
- \bgroup
- \tttf\space
- \ifnum\TABLEerror=\TABLEunknown
- \ifx#2#3\else\string#2->\fi
- \else
- ->%
- \fi
- \color[#1]{\string#3}%
- \ifx\TABLEgraylineerror\empty
- \space\TABLEgraylinestatus
- \else
- \space\TABLEgraylineerror
- \fi
- \egroup
- \else\ifx\TABLEgraylineerror\empty \else
- % \bgroup
- % \tttf\space\TABLEgraylineerror
- % \egroup
- \fi\fi
- \globalletempty\TABLEgraylinestatus
- \globalletempty\TABLEgraylineerror
- \expandafter\normalTABLElineformat#4#5\crcr % \crcr nodig ?
- \TABLEnoalign{\nobreak\global\setTABLEactiontrue}}
+ \expandafter\donormaltablelineformat#3#4\crcr % \crcr nodig ?
+ \tablenoalign{\nobreak\global\settrue\tableactionstatepermitted}}
%D In order to prevent (as good as possible) alignment overflow
%D and therefore \TEX\ error messages, we check the maximum
@@ -1641,8 +1871,7 @@
%D the number of \type{|}'s and \type{\VL}'s or alike is always
%D one more than the number of columns.
-\newcount\currentTABLEcolumn
-\newcount\maxTABLEcolumn
+\newcount\currenttablecolumn
%D While defining this macro we change the \CATCODE\ of
%D \type{|}. When counting the bars, we use a non active
@@ -1651,43 +1880,20 @@
%D \TABLE\ changes the catcode when needed.}
\bgroup
- \catcode`\|=\@@other \gdef\@@otherbar {|}
- \catcode`\"=\@@other \gdef\@@otherquote {"}
- \catcode`\|=\@@active \gdef\@@useotherbar {\let|\@@otherbar}
- \catcode`\"=\@@active \gdef\@@useotherquote{\let"\@@otherquote}
+ \catcode\barasciicode\othercatcode \gdef\@@otherbar {|}
+ \catcode\barasciicode\activecatcode \gdef\@@useotherbar {\let|\@@otherbar}
\egroup
-\bgroup \catcode`\|=\@@other
+\bgroup \catcode\barasciicode\othercatcode
-\gdef\getTABLEnofcolumns#1%
+\gdef\dogettablenofcolumns#1% todo: also divert this to lua as with tabulate
{\bgroup
\cleanupfeatures % needed !
\@@useotherbar
- \@@useotherquote
- \expanded{\defconvertedargument\noexpand\ascii{#1}}%
- \@EA\doglobal\@EA\counttoken\@EA|\@EA\in\ascii\to\maxTABLEcolumn
- \global\advance\maxTABLEcolumn \minusone
- % in case of & counting, divide by 2
\egroup}
\egroup
-\def\!ttDoHalign
- {\edef\restoretablelineskips
- {\baselineskip \the\baselineskip
- \lineskiplimit\the\lineskiplimit
- \lineskip \the\lineskip
- \tabskip \the\tabskip}%
- \baselineskip \zeropoint
- \lineskiplimit\zeropoint
- \lineskip \zeropoint
- \tabskip \zeropoint
- % does not work in normal tex
- % \expanded{\getTABLEnofcolumns{\the\!taPreamble}}% added
- \halign \the\!taTableSpread \bgroup
- \span\the\!taPreamble
- \ifx \!tfRowOfWidths \empty \else \!tfRowOfWidths \cr \fi}
-
%D \startitemize[3*ruim]
%D \sym{\type{\VL}} a vertical line
%D \sym{\type{\VC}} a vertical colored line
@@ -1695,56 +1901,46 @@
%D \sym{\type{\HC}} a horizontal colored line
%D \stopitemize
-% \unexpanded\def\defineTABLErules
-% {\let\VL\TableVL
-% \let\VC\TableVC
-% \let\HL\TableHL
-% \let\HC\TableHC}
-
-\unexpanded\def\defineTABLErules
- {\let\VL\TableVL
- \let\VC\TableVC
- \let\HL\TableHL
- \let\HC\TableHC
- \let\VS\TableVS
- \let\VD\TableVD
- \let\VT\TableVT
- \let\VN\TableVN}
-
-\def\TableVL
- {\checkTABLEautorow
- \nextTABLEgrayline
- \ifnum\currentTABLEcolumn>\maxTABLEcolumn
- \setTABLEerror\TABLEmissingrow
- \handleTABLEerror
- \else
- \global\advance\currentTABLEcolumn \plusone
- \expandafter\doTableVL
- \fi}
+\newcount\tablevrulethicknessfactor
+\newcount\tablehrulethicknessfactor
+\newcount\tabledrulespan
+\let \tablecurrentvrulecolor \empty
+\let \tablecurrenthrulecolor \empty
-\def\doTableVL
- {\futurelet\next\dodoTableVL}
-
-\def\dodoTableVL
- {\docomplexorsimpleTable\complexTableVL\simpleTableVL}
-
-\def\complexTableVL[#1]%
- {\scratchcounter=0#1%
- \multiply\scratchcounter \@@tiVLwidth
- \setxvalue{wVL\the\currentTABLEcolumn}{\the\scratchcounter}%
- \simpleTableVL}
-
-\def\simpleTableVL
- {\doifundefined{wVL\the\currentTABLEcolumn}%
- {\setgvalue{wVL\the\currentTABLEcolumn}{\@@tiVLwidth}}%
- \gdef\TABLEbeforebar
- {\getvalue{bVL\the\currentTABLEcolumn}%
- \letgvalueempty{bVL\the\currentTABLEcolumn}}%
- \gdef\TABLEafterbar
- {\getvalue{eVL\the\currentTABLEcolumn}%
- \letgvalueempty{eVL\the\currentTABLEcolumn}}%
- \edef\@@tiVLwidth{\getvalue{wVL\the\currentTABLEcolumn}}%
- \expanded{\normalTABLEcomplexbar\@@tiVLwidth\space}}% \relax breaks \use
+\appendtoks
+ \let\VL\dotableVL
+ \let\VC\dotableVC
+ \let\HL\dotableHL
+ \let\HC\dotableHC
+ \let\VS\dotableVS
+ \let\VD\dotableVD
+ \let\VT\dotableVT
+ \let\VN\dotableVN
+\to \localtabledefinitions
+
+\def\dotableresetVLvalues
+ {\global\currenttablecolumn\zerocount}
+
+\def\dotablevrulecommand#1% global assignments
+ {\doifnumberelse{#1}
+ {\global\tablevrulethicknessfactor#1\relax
+ \global\multiply\tablevrulethicknessfactor\@@tiVLwidth\relax}
+ {\xdef\tablecurrentvrulecolor{#1}}}
+
+\unexpanded\def\dotableVL
+ {\dochecktableautorow
+ \global\advance\currenttablecolumn\plusone
+ \dosingleempty\dodotableVL}
+
+\def\dodotableVL[#1]%
+ {\global\let\tablecurrentvrulecolor\empty
+ \global\tablevrulethicknessfactor\@@tiVLwidth\relax
+ \iffirstargument
+ \rawprocesscommalist[#1]\dotablevrulecommand
+ \fi
+ \donormaltablecomplexbar}% \relax breaks \use
+
+\let\dotableVC\dotableVL % for mojca
% \starttable[|||]
% \HL
@@ -1754,106 +1950,51 @@
% \HL
% \stoptable
-\def\TableVS {\VN1}
-\def\TableVD {\VN2}
-\def\TableVT {\VN3}
-\def\TableVN#1{\gdef\@VLn{#1}\VL}
-
-\def\resetVLvalues
- {\dostepwiserecurse\zerocount\maxTABLEcolumn\plusone
- {\setgvalue{wVL\recurselevel}{\@@tiVLwidth}%
- \letgvalueempty{bVL\recurselevel}%
- \letgvalueempty{eVL\recurselevel}}%
- \global\currentTABLEcolumn\zerocount}
-
-\def\TableVC
- {\checkTABLEautorow
- \nextTABLEgrayline
- \ifnum\currentTABLEcolumn>\maxTABLEcolumn
- \setTABLEerror\TABLEmissingrow
- \handleTABLEerror
- \else
- \global\advance\currentTABLEcolumn \plusone
- \expandafter\doTableVC
- \fi}
-
-\def\doTableVC
- {\futurelet\next\dodoTableVC}
-
-\def\dodoTableVC
- {\docomplexorsimpleTable\complexTableVC\simpleTableVC}
-
-\def\complexTableVC[#1]%
- {\global\setvalue{bVC\the\currentTABLEcolumn}{\startcolor[#1]}%
- \global\setvalue{eVC\the\currentTABLEcolumn}{\stopcolor}%
- \simpleTableVC}
-
-\def\simpleTableVC
- {\global\setvalue{bVL\the\currentTABLEcolumn}%
- {\getvalue{bVC\the\currentTABLEcolumn}}%
- \global\setvalue{eVL\the\currentTABLEcolumn}%
- {\getvalue{eVC\the\currentTABLEcolumn}}%
- \doTableVL}
-
-\def\TableHL
- {\ifnum\currentTABLEcolumn>\maxTABLEcolumn
- \chuckTABLEautorow
- \else\ifnum\currentTABLEcolumn=\zerocount
- %\chuckTABLEautorow
- \TABLEnoalign
- {\globalletempty\checkTABLEautorow
- \globalletempty\chuckTABLEautorow}%
+\unexpanded\def\dotableVS {\VN1}
+\unexpanded\def\dotableVD {\VN2}
+\unexpanded\def\dotableVT {\VN3}
+\unexpanded\def\dotableVN#1{\global\noftablevrules#1\relax\VL}
+
+\def\dotablehrulecommand#1% global assignments
+ {\doifnumberelse{#1}
+ {\global\tablehrulethicknessfactor#1\relax
+ \global\multiply\tablehrulethicknessfactor\@@tiHLheight\relax}
+ {\xdef\tablecurrenthrulecolor{#1}}}
+
+\unexpanded\def\dotableHL
+ {\dochucktableautorow
+ \dofinishtablerow
+ \starttablenoalign
+ \dosingleempty\dodotableHL}
+
+\def\dodotableHL[#1]%
+ {\nobreak
+ \ifnum\tableactionstate=\tablerulestate
+ \writestatus\m!TABLE{skipping \string\HL}% \statusmessage
\else
- \setTABLEerror\TABLEmissingcolumn
- \handleTABLEerror
- \fi\fi
- \complexorsimpleTable{HL}}
-
-\def\complexTableHL[#1]%
- {\TABLEnoalign
- {\scratchcounter0#1%
- \multiply\scratchcounter \@@tiHLheight
- \edef\@@tiHLheight{\the\scratchcounter}%
- \simpleTableHL}}
-
-\def\simpleTableHL
- {\TABLEnoalign
- {\nobreak
- \ifnum\TABLEaction=\TABLErule
- \writestatus\m!TABLE{skipping \string\HL}% \statusmessage
- \else
- \ifnum\TABLEaction=\TABLEmidrow
- \writestatus\m!TABLE{change \string\MR\space into \string\LR/\string\SR}%
- \else\ifnum\TABLEaction=\TABLEfirstrow
- \writestatus\m!TABLE{change \string\MR\space into \string\SR}%
- \fi\fi
- \startHLcommand
- \expandafter\normalTABLEfullrule\@@tiHLheight
- \stopHLcommand
- \globalletempty\startHLcommand
- \globalletempty\stopHLcommand
- \accountTABLElinewidth
- \fi
- \setTABLEaction\TABLErule
- \nobreak}}
-
-\let\startHLcommand\empty
-\let\stopHLcommand \empty
-
-\def\TableHC
- {\complexorsimpleTable{HC}}
-
-\def\complexTableHC[#1]%
- {\TABLEnoalign
- {\gdef\startHCcommand{\startcolor[#1]}%
- \gdef\stopHCcommand {\stopcolor}}%
- \simpleTableHC}
+ \ifnum\tableactionstate=\tablemidrowstate
+ \writestatus\m!TABLE{change \string\MR\space into \string\LR/\string\SR}%
+ \else\ifnum\tableactionstate=\tablefirstrowstate
+ \writestatus\m!TABLE{change \string\MR\space into \string\SR}%
+ \fi\fi
+ \bgroup
+ \global\tablehrulethicknessfactor\@@tiHLheight\relax
+ \iffirstargument
+ \global\let\tablecurrenthrulecolor\empty
+ \rawprocesscommalist[#1]\dotablehrulecommand
+ \ifx\tablecurrenthrulecolor\empty\else
+ \switchtocolor[\tablecurrenthrulecolor]%
+ \fi
+ \fi
+ \donormaltablefullrule
+ \egroup
+ \doaccounttablelinewidth
+ \fi
+ \dosettableaction\tablerulestate
+ \nobreak
+ \stoptablenoalign}
-\def\simpleTableHC
- {\TABLEnoalign
- {\globallet\startHLcommand\startHCcommand
- \globallet\stopHLcommand \stopHCcommand}%
- \HL}
+\let\dotableHC\dotableHL % for mojca
%D \startitemize[3*ruim]
%D \sym{\type{\NL}} a vertical skip
@@ -1864,508 +2005,177 @@
%D \sym{\type{\LC}} a last column
%D \stopitemize
-% n+1 uitleggen
-
-\unexpanded\def\defineTABLEsteps
- {\let\NL\TableNL
- \let\NR\TableNR
- \let\NC\TableNC
- \let\FC\TableNC
- \let\MC\TableNC
- \let\LC\TableNC}
-
-\def\TableNL
- {\complexorsimpleTable{NL}}
-
-\def\complexTableNL[#1]%
- {\TABLEnoalign
- {\edef\@@tiNL{#1}%
- \simpleTableNL}}%
-
-\def\simpleTableNL
- {\TABLEnoalign
- {\nobreak
- \setbox0\vbox{\blank[\@@tiNL]}%
- \vskip\ht0
- \nobreak}}
-
-\def\TableNR
- {\ifnum\currentTABLEcolumn>\maxTABLEcolumn
- \global\currentTABLEcolumn\zerocount
- \normalTABLElineending
- \else
- \setTABLEerror\TABLEmissingcolumn
- \handleTABLEerror
- \fi
- \TABLEnoalign
- {\nobreak
- \setTABLEaction\TABLEunknown}}
-
-\def\TableNC
- {\checkTABLEautorow
- \nextTABLEgrayline
- \ifnum\currentTABLEcolumn>\maxTABLEcolumn
- \setTABLEerror\TABLEmissingrow
- \handleTABLEerror
- \else
- \global\advance\currentTABLEcolumn \plusone
- \normalTABLEquote
- \fi}
+% \starttable[|||]
+% \VL text \VL text \VL \AR
+% \TB[small]
+% \VL text \VL text \VL \AR
+% \TB[4*big]
+% \VL text \VL text \VL \AR
+% \stoptable
-% \bgroup
-% \catcode`\|=\@@active
-% \catcode`\"=\@@active
-% \gdef\redefinetablebarandquote
-% {\def|{\VL}% % \normalTABLEsimplebar
-% \def\|##1{\VL[##1]}% % \normalTABLEcomplexbar
-% \def"{\NC}} % \normalTABLEquote
-% \egroup
+% n+1 uitleggen
-\let\redefinetablebarandquote\relax
+\appendtoks
+ \let\TB\dotableTB
+ \let\NL\dotableNL % old
+ \let\NR\dotableNR
+ \let\NC\dotableNC
+ \let\FC\dotableNC
+ \let\MC\dotableNC
+ \let\LC\dotableNC
+\to \localtabledefinitions
+
+\unexpanded\def\dotableTB
+ {\dochucktableautorow
+ \dofinishtablerow
+ \starttablenoalign
+ \dosingleempty\dotableTB}
+
+\def\dotableTB[#1]%
+ {\blank[\iffirstargument#1\else\@@tiNL\fi]%
+ \nobreak
+ \stoptablenoalign}
+
+\let\dotableNL\dotableTB
+
+\unexpanded\def\dotableNR
+ {\global\currenttablecolumn\zerocount
+ \donormaltablelineending
+ \starttablenoalign
+ \nobreak
+ \dosettableaction\tableunknownstate
+ \stoptablenoalign}
+
+\unexpanded\def\dotableNC
+ {\dochecktableautorow
+ \global\advance\currenttablecolumn \plusone
+ \donormaltablenobar}
-%D \startitemize[3*ruim]
+%D \startitemize[3*broad]
%D \sym{\type{\DL}}
%D \sym{\type{\DV}} (\type{\VD})
%D \sym{\type{\DC}}
%D \sym{\type{\DR}}
%D \stopitemize
-\newif\ifTABLEdivision
-
-% \unexpanded\def\defineTABLEdivisions
-% {\global\TABLEdivisionfalse % in start
-% \let\DL\TableDL
-% \let\DC\TableDC
-% \let\DV\TableDV
-% \let\VD\TableDV
-% \let\DR\TableDR}
-
-\unexpanded\def\defineTABLEdivisions
- {\global\TABLEdivisionfalse % in start
- \let\DL\TableDL
- \let\DC\TableDC
- \let\DV\TableDV
- \let\DR\TableDR}
-
-\def\checkTABLEdivision
- {\ifTABLEdivision \else
- \chuckTABLEautorow
- \global\currentTABLEcolumn\zerocount
- \global\TABLEdivisiontrue
+\newconditional\istabledivision
+
+\appendtoks
+ \global\setfalse\istabledivision
+ \let\DL\dotableDL
+ \let\DC\dotableDC
+ \let\DV\dotableDV
+ \let\DR\dotableDR
+\to \localtabledefinitions
+
+\def\dochecktabledivision
+ {\ifconditional\istabledivision\else
+ \dochucktableautorow
+ \global\currenttablecolumn\zerocount
+ \global\settrue\istabledivision
\fi}
-\def\TableDL
- {\checkTABLEdivision
- \complexorsimpleTable{DL}}
+\def\dotabledrulecommand#1% global assignments
+ {\doifnumberelse{#1}
+ {\ifcase\tabledrulespan
+ \global\tabledrulespan#1\relax
+ \else
+ \global\tablehrulethicknessfactor#1\relax
+ \global\multiply\tablehrulethicknessfactor\@@tiVLwidth\relax
+ \fi}
+ {\xdef\tablecurrenthrulecolor{#1}}}
-\def\simpleTableDL
- {\complexTableDL[1]}
+\unexpanded\def\dotableDL
+ {\dochecktabledivision
+ \dosingleempty\dotableDL}
-\def\complexTableDL[#1]%
- {\ifnum\TABLEaction=\TABLErule
+\def\dotableDL[#1]%
+ {\ifnum\tableactionstate=\tablerulestate
\writestatus\m!TABLE{skipping \string\DL}%
\else
- \ifnum\TABLEaction=\TABLEmidrow
+ \ifnum\tableactionstate=\tablemidrowstate
\writestatus\m!TABLE{change \string\MR\space into \string\LR/\string\SR}%
- \else\ifnum\TABLEaction=\TABLEfirstrow
+ \else\ifnum\tableactionstate=\tablefirstrowstate
\writestatus\m!TABLE{change \string\MR\space into \string\SR}%
\fi\fi
- \setTABLEaction=\TABLEunknown
- \ifnum\currentTABLEcolumn>\maxTABLEcolumn
- \setTABLEerror\TABLEmissingrow
- \handleTABLEerror
- \fi
- %\startHLcommand
- \ifnum#1=\plusone
- \global\advance\currentTABLEcolumn \plustwo
- \let\next\normalTABLEsinglerule
- \else
- \ifnum#1<\maxTABLEcolumn
- \global\advance\currentTABLEcolumn \plusone
- \def\next{\normalTABLEmultirule{#1}}%
- \else
- \setTABLEerror\TABLEdivisionoverflow
- \let\next\handleTABLEerror
+ \dosettableaction\tableunknownstate
+ \global\tablehrulethicknessfactor\@@tiHLheight\relax
+ \global\tabledrulespan\zerocount
+ \iffirstargument
+ \global\let\tablecurrenthrulecolor\empty
+ \rawprocesscommalist[#1]\dotabledrulecommand
+ \ifx\tablecurrenthrulecolor\empty\else
+ \switchtocolor[\tablecurrenthrulecolor]%
\fi
\fi
- \next
- %\stopHLcommand
- %\globalletempty\startHLcommand
- %\globalletempty\stopHLcommand
- \fi}
-
-\def\TableDV
- {\TableDCV\normalTABLEsimplebar}
-
-\def\TableDC
- {\TableDCV\normalTABLEquote}
-
-\def\TableDCV#1%
- {\checkTABLEdivision
- \checkTABLEautorow
- \ifnum\currentTABLEcolumn>\maxTABLEcolumn
- \setTABLEerror\TABLEmissingrow
- \handleTABLEerror
- \else
- \global\advance\currentTABLEcolumn \plusone
- #1%
- \fi}
-
-\def\TableDR
- {\ifnum\currentTABLEcolumn<\maxTABLEcolumn % silent recovery
- %\setTABLEerror\TABLEmissingcolumn % some day warning
- %\handleTABLEerror
- \finishTABLErow
- \else
- \global\currentTABLEcolumn\zerocount % nog check
- \normalTABLElineending
- \fi
- \TABLEnoalign
- {\nobreak
- \global\TABLEdivisionfalse
- \accountTABLElinewidth % temporary solution
- \setTABLEaction\TABLErule}}
-
-\def\accountTABLElinewidth
- {\scratchdimen\LineThicknessUnit}
-
-%D \startitemize[3*ruim]
-%D \sym{\type{\BC}}
-%D \sym{\type{\BR}}
-%D \sym{\type{\BACKGROUND}}
-%D \sym{\type{\CL}}
-%D \sym{\type{\RL}}
-%D \sym{\type{\BL}}
-%D \sym{\type{\RASTER}}
-%D \sym{\type{\COLOR}}
-%D \stopitemize
-
-% definieer: \BC \BL
-% herhaal: \BR
-% definieer: \CL \RL (eerste \CL[green] = hele row! / \CL[1,green])
-% dus: \CL en \RL mix tussen \HL en \BL
-
-\unexpanded\def\defineTABLEbackgrounds
- {\let\BC \TableBC
- \let\BL \TableBL
- \let\BR \TableBR
- \let\BACKGROUND\TableBR
- \let\CL \TableCL
- \let\RL \TableRL
- \let\COLOR \TableCOLOR
- \let\RASTER \TableRASTER
- \globallet\lastTABLEc\@@tibackgroundcolor
- \globallet\lastTABLEr\@@tibackgroundscreen
- \doifinsetelse\@@tibackground{c,color} % \v!color
- {\global\chardef\TABLEcr\plusone}
- {\global\chardef\TABLEcr\plustwo}}
-
-\def\TableBC
- {\ifTABLEgrayline
- \normalTABLEquote
- \else
- \TABLEnoalign\bgroup
- \globallet\nextTABLEgrayline\executeTABLEgrayline
- \globalletempty\TABLEgrayline % new
- \let\BL\doTableBL
- \let\BC\doTableBC
- \expandafter\doTableBC
- \fi}
-
-\def\doTableBC
- {\addtoTABLEgrayline{\BC}%
- \gobbleTableBCL}
-
-\def\TableBL
- {\TABLEnoalign\bgroup
- \globallet\nextTABLEgrayline\executeTABLEgrayline
- \globalletempty\TABLEgrayline % new
- \let\BL\doTableBL
- \let\CL\doTableCL
- \let\RL\doTableRL
- \let\BC\doTableBC
- \doTableBL}
-
-\def\doTableBL
- {\complexorsimpleTable{BL}}
-
-\def\simpleTableBL
- {\complexTableBL[,]}
-
-\def\complexTableBL[#1]%
- {\analyzeTABLEcr[#1]%
- \handleTABLEcr}
-
-\def\TableBR#1%
- {\TABLEnoalign
- {\globallet\nextTABLEgrayline\executeTABLEgrayline
- \checkTABLEgrayline#1\BR
- \global\TABLEgraylinetrue}}
-
-\def\analyzeTABLEcr[#1]%
- {\doanalyzeTABLEcr[#1,,]}
-
-\def\doanalyzeTABLEcr[#1,#2,#3]%
- {\doifnumberelse{#1x} % Is the x still needed here?
- {\dodoanalyzeTABLEcr[#1,#2,#3]}
- {\dodoanalyzeTABLEcr[1,#1,#2]}}
-
-\def\dodoanalyzeTABLEcr[#1,#2,#3]%
- {\global\chardef\TABLEn#1\relax
- \processaction
- [#2]
- [ c=>\global\chardef\TABLEcr1,%
- color=>\global\chardef\TABLEcr1,%
- r=>\global\chardef\TABLEcr2,%
- raster=>\global\chardef\TABLEcr2]%
- \ifcase\TABLEcr \or
- \doifsomething{#3}{\xdef\lastTABLEc{#3}}%
- \or
- \doifsomething{#3}{\xdef\lastTABLEr{#3}}%
- \fi}
-
-\def\handleTABLEcr
- {\relax % else funny side effect
- \ifcase\TABLEcr
- % Can't happen!
- \or
- \addtoTABLEgrayline{\complexTableCOLOR[\the\TABLEn,\lastTABLEc]}%
- \else
- \addtoTABLEgrayline{\complexTableRASTER[\the\TABLEn,\lastTABLEr]}%
- \fi
- \gobbleTableBCL}
-
-\def\analyzeTABLEcrl#1[#2]%
- {\doanalyzeTABLEcrl#1[#2,,]}
-
-\def\doanalyzeTABLEcrl#1[#2,#3,#4]%
- {\doifnumberelse{#2x} % x ????????????????????
- {\dodoanalyzeTABLEcr[#2,#1,#3]}
- {\dodoanalyzeTABLEcr[\ifTABLEgrayline1\else\maxTABLEcolumn\fi,#1,#2]}}
-
-\def\TableCL
- {\TABLEnoalign\bgroup
- \globallet\nextTABLEgrayline\executeTABLEgrayline
- \globalletempty\TABLEgrayline % new
- \let\BL\doTableBL
- \let\CL\doTableCL
- \let\RL\doTableRL
- \let\BC\doTableBC
- \doTableCL}
-
-\def\doTableCL
- {\complexorsimpleTable{CL}}
-
-\def\simpleTableCL% nog eens \'e\'en lijn van maken
- {\BL[\the\maxTABLEcolumn,c,\lastTABLEc]}
-
-\def\complexTableCL[#1]%
- {\analyzeTABLEcrl{c}[#1]%
- \handleTABLEcr}
-
-\def\TableRL
- {\TABLEnoalign\bgroup
- \globallet\nextTABLEgrayline\executeTABLEgrayline
- \globalletempty\TABLEgrayline % new
- \let\BL\doTableBL
- \let\CL\doTableCL
- \let\RL\doTableRL
- \let\BC\doTableBC
- \doTableRL}
-
-\def\doTableRL
- {\complexorsimpleTable{RL}}
-
-\def\simpleTableRL
- {\BL[\the\maxTABLEcolumn,r,\lastTABLEr]}
-
-\def\complexTableRL[#1]%
- {\analyzeTABLEcrl{r}[#1]%
- \handleTABLEcr}
-
-\def\checkTABLEgrayline#1#2%
- {\!!doneatrue
- \ifx#1\AR
- \!!doneafalse
- \else\ifx#1\SR\else\ifx#1\FR\else\ifx#1\MR\else\ifx#1\LR\else
- \!!doneafalse
- \fi\fi\fi\fi\fi
- \if!!donea
- \gdef\TABLEgraylinestatus
- {[\string#1]}%
- \gdef\TABLEendBCL
- {#1}%
- \else
- \gdef\TABLEgraylineerror
- {[\string#2\string#1->\string#2\string\SR]}%
- \gdef\TABLEendBCL
- {\SR}%
- \fi}
-
-\def\endTABLErowGL#1#2#3%
- {\ifcase#1\relax
- % unknown
- \or
- \doPreTableGL\TABLErowfactor\TABLErowfactor
- \or
- \doPreTableGL\TABLErowfactor\TABLErowzero
- \or
- \ifnum\TABLEforce=\TABLEforcelastrow
- \doPreTableGL\TABLErowzero\TABLErowfactor
- \else\ifnum\TABLEforce=\TABLEforcefirstrow
- \doPreTableGL\TABLErowfactor\TABLErowzero
+ \ifcase\tabledrulespan
+ \global\advance\currenttablecolumn \plusone
+ \donormaltablesinglerule
+ \or
+ \global\advance\currenttablecolumn \plustwo
+ \donormaltablesinglerule
\else
- \doPreTableGL\TABLErowzero\TABLErowzero
- \fi\fi
- \or
- \doPreTableGL\TABLErowzero\TABLErowfactor
+ \global\advance\currenttablecolumn \plusone
+ \donormaltablemultirule
+ \fi
\fi}
-\def\doPreTableGL#1#2% betere namen
- {\xdef\OldLineThicknessFactor{\the\LineThicknessFactor}%
- \xdef\OldLineThicknessUnit{\the\LineThicknessUnit}%
- \global\LineThicknessFactor\plusone
- \setbox0\hbox{\AugmentedTableStrut{#1}{#2}}%
- \getboxheight\dimen0\of\box0\relax
- \xdef\TABLEgraylineHeight{\the\dimen0}%
- \global\LineThicknessUnit\TABLEgraylineHeight}
-
-\def\doPostTableGL
- {\global\LineThicknessFactor\OldLineThicknessFactor
- \global\LineThicknessUnit \OldLineThicknessUnit}
+\unexpanded\def\dotableDV
+ {\dotableDCV\donormaltablesimplebar}
+
+\unexpanded\def\dotableDC
+ {\dotableDCV\donormaltablenobar}
+
+\unexpanded\def\dotableDCV#1%
+ {\dochecktabledivision
+ \dochecktableautorow
+ \global\advance\currenttablecolumn \plusone
+ #1}
+
+\unexpanded\def\dotableDR
+ {\global\currenttablecolumn\zerocount % nog check
+ \donormaltablelineending
+ \starttablenoalign
+ \nobreak
+ \global\setfalse\istabledivision
+ \doaccounttablelinewidth % temporary solution
+ \dosettableaction\tablerulestate
+ \stoptablenoalign}
+
+\def\doaccounttablelinewidth
+ {\scratchdimen\tablelinethicknessunit}
-% kan simpeler
-
-\def\docomplexTableCOLOR[#1]%
- {\dodocomplexTableGL\startcolor \stopcolor [#1,\lastTABLEc,,]}
+\def\dotableTWO {\use\plustwo}
+\def\dotableTHREE {\use\plusthree}
+\def\dotableFOUR {\use\plusfour}
+\def\dotableFIVE {\use\plusfive}
+\def\dotableSIX {\use\plussix}
-\gdef\docomplexTableRASTER[#1]%
- {\dodocomplexTableGL\startraster\stopraster[#1,\lastTABLEr,,]}
-
-\def\dodocomplexTableGL#1#2[#3,#4,#5,#6]%
- {\doifelsenothing{#4}{#1[#5]}{#1[#4]}%
- \doPreTableGL\TABLEendofrowheight\TABLEendofrowdepth
- \ifnum#3=\plusone % else conflict with \omit in \=
- \let\next\normalTABLEsinglerule
- \else
- \def\next{\normalTABLEmultirule{#3}}%
- \fi
- \next
- \doPostTableGL
- #2}
-
-\def\TableBACKGROUND
- {\TableBR}
-
-\def\simpleTableRASTER #1{\docomplexTableRASTER[1]#1}
-\def\complexTableRASTER[#1]{\docomplexTableRASTER[#1]}
-\def\simpleTableCOLOR {\docomplexTableCOLOR [1]}
-\def\complexTableCOLOR [#1]{\docomplexTableCOLOR [#1]}
+\appendtoks
+ \let\TWO \dotableTWO
+ \let\THREE\dotableTHREE
+ \let\FOUR \dotableFOUR
+ \let\FIVE \dotableFIVE
+ \let\SIX \dotableSIX
+ \let\SPAN \use
+ \let\REF \dotablereformat
+\to \localtabledefinitions
+
+\setvalue{\??ti:\c!distance:\v!none }{\dotableOpenUp00\def\LOW{\Lower6 }}
+\setvalue{\??ti:\c!distance:\v!small }{\dotableOpenUp00\def\LOW{\Lower6 }} % == baseline
+\setvalue{\??ti:\c!distance:\v!medium}{\dotableOpenUp11\def\LOW{\Lower7 }}
+\setvalue{\??ti:\c!distance:\v!big }{\dotableOpenUp22\def\LOW{\Lower8 }}
-\def\TableRASTER{\complexorsimpleTable{RASTER}}
-\def\TableCOLOR {\complexorsimpleTable{COLOR}}
+\appendtoks
+ \getvalue{\??ti:\c!distance:\@@tidistance}%
+\to \localtabledefinitions
-\def\addtoTABLEgrayline#1%
- {\TABLEgraytoks\expandafter{\TABLEgrayline}%
- \xdef\TABLEgrayline{\the\TABLEgraytoks\noexpand#1}}
-
-\def\setTableBCL#1#2%
- {\ifx#1#2%
- \gdef\TABLEgraylinestatus{[\string#1]}%
- \gdef\TABLEendBCL{#1}%
- \addtoTABLEgrayline{#1}%
- \else
- \gdef\TABLEgraylineerror{[\string#1->\string#2]}%
- \gdef\TABLEendBCL{#2}%
- \addtoTABLEgrayline{#2}%
- \fi}
+\appendtoks
+ \doifelse\@@tidistance\v!none
+ {\tablerowfactor\zerocount}
+ {\tablerowfactor\plustwo }%
+\to \localtabledefinitions
-\def\gobbleTableBCL#1%
- {\ifx#1\BC \let\next\doTableBC \else
- \ifx#1\BL \let\next\doTableBL \else
- \ifx#1\SR \setTableBCL\SR\SR \let\next\egroup \else
- \ifx#1\FR \setTableBCL\FR\FR \let\next\egroup \else
- \ifx#1\MR \setTableBCL\MR\MR \let\next\egroup \else
- \ifx#1\LR \setTableBCL\LR\LR \let\next\egroup \else
- \setTableBCL #1\SR \let\next\egroup
- \fi\fi\fi\fi\fi\fi
- \next}
-
-\def\executeTABLEgrayline
- {\TABLEnoalign
- {\def\BC
- {\advance\currentTABLEcolumn \plusone}%
- \def\dodocomplexTableGL##1##2[##3,##4,##5,##6]%
- {\BC\advance\currentTABLEcolumn ##3 }%
- \let\endTABLErow\endTABLEgrayrow
- \currentTABLEcolumn\zerocount
- \TABLEgrayline\TABLEendBCL % determine n of columns and height
- \advance\currentTABLEcolumn \minusone
- \ifnum\currentTABLEcolumn>\maxTABLEcolumn
- % error message too long line
- \globalletempty\TABLEgrayline
- \else
- % \message{n of color columns: \the\currentTABLEcolumn}\wait
- \global\TABLEgraylinetrue % vanaf hier nog checken
- \fi
- \global\currentTABLEcolumn\zerocount}%
- \unskip\TABLEgrayline\TABLEendBCL
- \TABLEnoalign
- {\nobreak
- \vskip-\TABLEgraylineHeight
- \nobreak
- \global\setTABLEactiontrue
- \global\currentTABLEcolumn\zerocount
- \globalletempty\nextTABLEgrayline
- \global\TABLEgraydonetrue
- \global\TABLEgraylinefalse}}
-
-\def\endTABLEgrayrow#1#2#3%
- {\ifcase#1\relax
- \global\chardef\TABLEendofrowheight\TABLErowfactor
- \global\chardef\TABLEendofrowdepth \TABLErowfactor
- \or
- \global\chardef\TABLEendofrowheight\TABLErowfactor
- \global\chardef\TABLEendofrowdepth \TABLErowfactor
- \or
- \global\chardef\TABLEendofrowheight\TABLErowfactor
- \global\chardef\TABLEendofrowdepth \TABLErowzero
- \or
- \ifnum\TABLEforce=\TABLEforcelastrow
- \global\chardef\TABLEendofrowheight\TABLErowzero
- \global\chardef\TABLEendofrowdepth \TABLErowfactor
- \else\ifnum\TABLEforce=\TABLEforcefirstrow
- \global\chardef\TABLEendofrowheight\TABLErowfactor
- \global\chardef\TABLEendofrowdepth \TABLErowzero
- \else
- \global\chardef\TABLEendofrowheight\TABLErowzero
- \global\chardef\TABLEendofrowdepth \TABLErowzero
- \fi\fi
- \or
- \global\chardef\TABLEendofrowheight\TABLErowzero
- \global\chardef\TABLEendofrowdepth \TABLErowfactor
- \fi}
-
-\unexpanded\def\defineTABLEshorthands%
- {\def\SPAN##1{\use{##1}}%
- \def\TWO {\use2}%
- \def\THREE {\use3}%
- \def\FOUR {\use4}%
- \def\FIVE {\use5}%
- \def\SIX {\use6}%
- \def\REF {\ReFormat}}
-
-\unexpanded\def\defineTABLEunits
- {\processaction
- [\@@tidistance]
- [ \v!none=>\OpenUp00\def\LOW{\Lower6 },
- \v!small=>\OpenUp00\def\LOW{\Lower6 }, % == baseline
- \v!medium=>\OpenUp11\def\LOW{\Lower7 },
- \v!big=>\OpenUp22\def\LOW{\Lower8 }]%
- \doifelse\@@tidistance\v!none
- {\chardef\TABLErowfactor\zerocount}
- {\chardef\TABLErowfactor\plustwo }}
-
\def\dohandlebar % here ?
{\ifmmode
\@EA\domathmodebar
@@ -2374,74 +2184,38 @@
\else
\@EAEAEA\dotextmodebar
\fi\fi}
-
-% De macro's t.b.v. instellingen.
\unexpanded\def\setuptables
{\dosingleargument\dosetuptables}
\def\dosetuptables[#1]%
{\getparameters[\??ti][#1]%
- \processaction
+ \processaction % we have a command for this
[\@@tialign]
- [ \v!right=>\def\TABLEparalignment{\raggedright},
- \v!left=>\def\TABLEparalignment{\raggedleft},
- \v!middle=>\def\TABLEparalignment{\raggedcenter},
- \s!default=>\def\TABLEparalignment{\notragged},
- \s!unknown=>\def\TABLEparalignment{\notragged}]%
+ [ \v!right=>\def\dotableparalignment{\raggedright},
+ \v!left=>\def\dotableparalignment{\raggedleft},
+ \v!middle=>\def\dotableparalignment{\raggedcenter},
+ \s!default=>\def\dotableparalignment{\notragged},
+ \s!unknown=>\def\dotableparalignment{\notragged}]%
\assignalfadimension\@@tiVL\@@tiVLwidth 246%
\assignalfadimension\@@tiHL\@@tiHLheight246}
-\def\localTABLEsetup
- {\@@ticommands\relax
- \expanded{\switchtobodyfont[\@@tibodyfont]}%
- \StrutHeightFactor 8
- \StrutDepthFactor 4
- \LineThicknessFactor4
- \NormalTLTU {.1pt}%
- \NormalTSU {\normalbaselineskip\divide\StrutUnit 12 }%
- \NormalTableUnits}
-
-%D And then I wrote the tabulate environment. That
-%D alternative supports setting the rule thickness and color,
-%D so here is the table alternative.
-
-\let\startglobalTABLEcolor\empty
-\let\stopglobalTABLEcolor \empty
-
-\def\localTABLEsetup
+\def\dolocaltablesetup
{\@@ticommands\relax
- % bodyfont
- \expanded{\switchtobodyfont[\@@tibodyfont]}%
- % linecolor
- \doifsomething\@@tirulecolor
- {\unexpanded\def\startglobalTABLEcolor{\startcolor[\@@tirulecolor]}%
- \unexpanded\def\stopglobalTABLEcolor {\stopcolor}}%
- % linethickness
- \LineThicknessFactor4
- \scratchdimen\@@tirulethickness
- \divide\scratchdimen \LineThicknessFactor
- \expanded{\NormalTLTU{\the\scratchdimen}}%
- % spacing, was depth=4 height=8 (counters, sigh, now macros)
+ \expanded{\switchtobodyfont[\@@tibodyfont]}% expanded ?
+ \tablelinethicknessunit\dimexpr\@@tirulethickness/\tablelinethicknessfactor\relax
\doifelse\@@tiheight\v!strut
- {\let\StrutHeightFactor\strutheightfactor}
- {\let\StrutHeightFactor\@@tiheight}%
+ {\let\tablestrutheightfactor\tablestrutheightfactor}
+ {\let\tablestrutheightfactor\@@tiheight}%
\doifelse\@@tidepth\v!strut
- {\let\StrutDepthFactor\strutdepthfactor}
- {\let\StrutDepthFactor\@@tidepth}%
- \scratchdimen\StrutHeightFactor\points \multiply\scratchdimen 10%
- \edef\StrutHeightFactor{\withoutpt\the\scratchdimen}%
- \scratchdimen\StrutDepthFactor \points \multiply\scratchdimen 10%
- \edef\StrutDepthFactor{\withoutpt\the\scratchdimen}%
- % units
- \NormalTSU{\normalbaselineskip\divide\StrutUnit 12 }%
- \NormalTableUnits}
-
-\def\OpenUp#1#2%
- {\scratchdimen\StrutHeightFactor \points \advance\scratchdimen #1\points
- \edef\StrutHeightFactor{\withoutpt\the\scratchdimen}%
- \scratchdimen\StrutDepthFactor \points \advance\scratchdimen #2\points
- \edef\StrutDepthFactor{\withoutpt\the\scratchdimen}}
+ {\let\tablestrutdepthfactor\tablestrutdepthfactor}
+ {\let\tablestrutdepthfactor\@@tidepth}%
+ \edef\tablestrutheightfactor{\withoutpt\the\dimexpr10\dimexpr\tablestrutheightfactor\points}%
+ \edef\tablestrutdepthfactor {\withoutpt\the\dimexpr10\dimexpr\tablestrutdepthfactor \points}%
+ \tablestrutunit\dimexpr\normalbaselineskip/12\relax % 12 is default bodyfont
+ \tableintercolumnspaceunit.5em plus 1fil minus .25em\relax
+ \tablecolumnwidthunit .5em\relax
+ \tablekernunit .5em\relax}
%D As one can see, we didn't only add color, but also more
%D control over spacing.
@@ -2492,7 +2266,7 @@
%D {$\vcenter{\getbuffer[b]}$}
%D {\hbox{tabulate}}
%D \stopcombination
-
+
\setuptables
[HL=\v!medium,
VL=\v!medium,
@@ -2501,6 +2275,7 @@
\c!align=\v!right,
\c!depth=.40, % \v!strut
\c!height=.80, % \v!strut
+ \c!textwidth=,
\c!rulethickness=\linewidth,
\c!rulecolor=,
\c!distance=\v!medium,
@@ -2511,6 +2286,4 @@
\c!backgroundcolor=,
\c!split=\v!auto]
-\def\ifintabel{\ifintable} % upward compatible
-
\protect \endinput