Changes

Jump to navigation Jump to search
3,671 bytes added ,  11:54, 21 December 2018
m
Document that [] is required for \starttabulatehead in MkIV. Email by Wolfgang Schuster 2018-11-12.
=Summary=
[[{{cmd:|starttabulate|Tabulate]] }} is a versatile table environment.
It supports ''paragraphs'' in cells, ''vertical rules'' (for
those typographically less demanding jobs …), and
''colorization'' of those rules, the background of fields as well
as the text itself.
 
'''Warning''': When you want to use tables with macros use {{cmd|starttable}} and \stoptable. {{cmd|starttabulate}} and \stoptabulate does not work correctly with macros.
=Basic commands=
The control sequence <tt>\{{cmd|starttabulate|[#1]</tt> }} takes a layout
string as optional argument.
As is common with tables in TeX-based typesetting, this string
- wtf this listing was full of <tab> chars‽ Was this supposed
- to be a bad pun on *tabulate*?
- - No, I formatted it readably in my text editor. --HR
-->
{|
|-
| <texcode>
\starttabulate[|r|l|lB|]
\HL
\NC {\bf format} \NC {\bf meaning} \NC Mk \NC\NR
\HL
\NC c \NC centered \NC \NC\NR\NC l \NC left aligned \NC \NC\NR\NC r \NC right aligned \NC \NC\NR\NC w(1cm) \NC one line, fixed width \NC \NC\NR\NC p(2cm) \NC paragraph, lines broken to fixed width \NC \NC\NR\NC cg(.) \NC align on a character \NC IV: cg{.} \NC\NR\NC m \NC math mode \NC IV only \NC\NR\NC b \NC before e.g. b{\star} \NC IV only \NC\NR\NC a \NC after, e.g. a{\percent} \NC IV only \NC\NR
\HL
\stoptabulate
|
|<context>
\setuppapersize[A5]\starttabulate[|r|l|lB|]
\HL
\NC {\bf format} \NC {\bf meaning} \NC Mk \NC\NR
\HL
\NC c \NC centered \NC\NR
\NC w(1cm) \NC one line, fixed width \NC\NR
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR
\NC cg(.) \NC align on a character \NC\NR
\HL
\stoptabulate
|}
* <ttcmd>HL</ttcmd> draws a horizontal rule,* <ttcmd>NC</ttcmd> marks a new column (or new cell),* <ttcmd>NN</cmd> marks a new math column/cell (see below),* <cmd>NR</ttcmd> starts a new row,* <cmd>NB</cmd> starts a new rowas a block (avoids page breaking inside of a block, to keep some lines together<!--; available since beta of 2011-12-21-->);* <cmd>TB</cmd> (= "Table Blank") adds some vertical space between rows -- see an example bellow,* <cmd>VL</cmd> (instead of <cmd>NC</cmd>) draws a vertical rule -- for more info see below. When using fixed width, you can use values relative to thecurrent page-width. For example: if you want the previous tabletake up all the width and having the second column taking threequarters of the space, change the {{cmd|starttabulate}} to:<texcode>\starttabulate[|rw(.25\textwidth)|lw(.75\textwidth)|]</texcode>(Mistake: This doesn’t account for the width of the column distance!) =Horizontal centering table on the page= <!--(Solution from the mailing list)--> <context source=yes>This is a very long text, longer than the width of the table.It must be long enough to flow to the next line to see the effect. \placetable[force,none]{}{% \starttabulate[|r|l|] \HL \NC I want this table \NC aligned in the center.\NC\NR \HL \stoptabulate}</context>
It is generally This can also be done with the start/stop syntax (showing only source here, since it does not necessary to conclude lines withcompile on the wiki): <ttcontext source=yes>This is a very long text, longer than the width of the table.It must be long enough to flow to the next line to see the effect. \startplacetable[location=force,number=no] \starttabulate[|r|l|] \HL \NC I want this table \NC aligned in the center.\NC\NR</tt> as <tt> \HL \stoptabulate\ARstopplacetable</ttcontext> (for <em>a</em>uto<em>r</em>ow)will do the job as well.
=Spanning Multiple Pages=
To achieve this the argument <tt>split</tt> must be set to
''true''.
 
''NB'': the difference between setting and unsetting this
argument may not be visible on the first few pages. Rather, it
seems to affect the ''end'' of the environment.
<context source="yes">\setuppapersize [XYA10, landscape][A4A8, landscape]\setuppaper [nx=2,ny=2]\setuparranging [XY]\setupbodyfont[10pt]
\starttextswitchtobodyfont[5pt]\setuppagenumbering[location={header,inright}]\showframe[edge]
\setuptabulate [split=yes, header=text, title={\color[red] Fenchurch St. Paul}, frame=on]
\starttabulate[|p(1.2cm)|p(1.2cm)|]\dorecurse{26}{ \NC test Bells: \NC \input tufte \relax Tin tan din dan bim bam bom bo \NC \NR \HL \NC test Name: \NC \input dawkins \relax Tailor Paul \NC \NR \HL
}
\stoptabulate
</context>
\stoptext \endinput
</context>
==Titles==
repeated above at every page break that occurs inside the table.
This name needs to be specified as the argument of the
<tt>title</tt> key of <tt>\{{cmd|setuptabulate</tt>}}.
The <tt>header</tt> key has to be set to <em>text</em> for this
to work.
<texcodecontext source=yes>\setuptabulatesetuppapersize[A10, landscape][split=yesA8,headerlandscape]\setuppaper[nx=text2,titleny={2]\sc Table Titles Undisclosed!}setuparranging[XY]
\starttabulateswitchtobodyfont[5pt]\dorecursesetuppagenumbering[location={2header,inright}{ \NC Ed Tufte \NC \input tufte \relax \NC \NR] \NC Dick Dawkins \NC \input dawkins \relax \NC \NR}</texcode>showframe[edge]
<context>\setuptabulate\setuppapersize [XY][A4]split=yes,\setuppaper [nxheader=2text,ny title=2{\color[red]Fenchurch St. Paul},\setuparranging [XY frame=on]
\starttext \setuptabulatestarttabulate[split=yes,header=text,title={\sc Table Titles Undisclosed!}|p(1.2cm)|p(1.2cm)|\starttabulate\dorecurse{26}{ \NC Ed Tufte Bells: \NC \input tufte \relax Tin tan din dan bim bam bom bo \NC \NR \HL \NC Dick Dawkins Name: \NC \input dawkins \relax Tailor Paul \NC \NR \HL
}
\stoptabulate
 
\stoptext \endinput
</context>
- “\setuptabulate” but I couldn’t notice any effect.
-->
 
==Headers==
Tabulate supports header rows that can be repeated over new table
pages instead of the title.
There is a separate environment <tt>\starttablehead</tt> {{cmd|starttabulatehead}} where
this header row has to be specified in advance of its use in a
tabulation.
 
In ConTeXt MkIV the command requires an additional [], thus you need
to write {{cmd|starttabulatehead}}[] instead.
{|
\starttabulatehead
\HLFL \NC {\bf format char} \NC {\bf meaning} \NC \AR \HLLL
\stoptabulatehead
\starttabulate[|r|l|]
\NC c \NC centered \NC \AR \NC l \NC left aligned \NC \AR \NC r \NC right aligned \NC \AR
\stoptabulate
</texcode>
|
| <context>
\setuppapersize[A5]
 
\setuptabulate[split=yes,header=repeat]
\starttabulatehead
\HLFL
\NC {\bf format char} \NC {\bf meaning} \AR
\HLLL
\stoptabulatehead
</context>
|}
 
Note the use of <tt>\FL</tt> and <tt>\LL</tt> in the tabulate header rather than <tt>\HL</tt> which is a standard rule command (see below) that tries to guess automatically its position.
=Individualizing the Tabulate Look=
Hans initially announced support for vertical lines and colors on
the mailing list.[http://archive.contextgarden.net/message/20101117.123950.739657a7.en.html]
==Rules==
Context supports different categories of rules that can be
configured individually in order to discern various applications.
Their behaviour accounts for the designated use, e.&nbsp;g.
<tt>\ML</tt> (mid rules) are intended to be deployed between
ordinary rows of the table body and will prevent page breaks
|}
Additionally, there is an options option <tt>rulecolor</tt> for<tt>\{{cmd|setuptabulate</tt> }} that allows for those rules to be tinted.
<texcode>
===Vertical Rules===
The <ttcmd>\VL</ttcmd> command serves as a replacement for <ttcmd>\NC</ttcmd>
to mark a cell border wherever a vertical rule may be desired (if
they are to be desired at all from a typographical point of
For ''horizontal rules'' see above.
For ''vertical rules'', <ttcmd>\VL</ttcmd> takes a defined color as an
optional argument.
</texcode>
===Colorizing Backgrounds& Text===''Backgrounds'' and text can be colorized either on column basis or
individually by cell.
There are four five color-specific control sequences:
{|
|<ttcmd>CR</ttcmd> || color is applied to the background of the text and the remaining space on the right;.|-|<cmd>CC</cmd> || color is applied to the background of the text only.
|-
|<ttcmd>CCCM</ttcmd> || color is applied to the background of the text only; and the remaining space on both sides.
|-
|<ttcmd>CMCL</ttcmd> || color is applied to the background of the text and the remaining space on both sides;the left.
|-
|<ttcmd>CLCT</ttcmd> || color is applied to the background of the text and itself - in other words, the remaining space on the left"foreground color."
|}
These are to complement the normal table layout expression (the
first argument to <tt>\{{cmd|starttabulate</tt>}.
Thus, in order to colorize a four column table with the initial
layout <tt>|c|c|c|c|</tt> it will have to be modified as follows:
Those control sequences, if applied within the table body, can
replace the ordinary <ttcmd>\NC</ttcmd>, allowing individual cells to
be colorized.
<texcode>
</texcode>
'''caveat emptor'''! The background coloring does apply only to
the ''first'' row of a paragraph cell. Any other cell will come
out colorless. If you need to color an entire multi-line cell,
you will need to switch to another
[[Tables Overview|tabulation variant]].
===Colorizing Cell Text===
''Normal text'' inside cells gets its color via the
[[ColorsColor|standard coloring commands]], or by the shorter variant described above.
<texcode>
</texcode>
=Column Spans= Vertical Distance Between Rows ==
Tabulate has no support <!--There does not seem to be an official interface for column spans but you could add thisfunction yourselfvertical skips.The Manually placed <code to do this depends >\blank</code>s are<code>\unskipped</code> on the tabulate setting and you havepurpose.However, as expected there is a token list<code>\t_tabl_tabulate_every_after_row</code> that isplaced after a line is finished.So, in order to know what content what column setting get a vertical spacing of half a baselinedistance you need.can use this code:
==Single row columns==<texcode>\unprotect\appendtoks \blank[halfline]\to \t_tabl_tabulate_every_after_row\protect</texcode>
To span columns in cells with <code-->l</code>, <code>r</code> or <code>c</code>you could use <code>\span\omit\span\omit\span\omit</code> for each cell.You could prevent these values you could them in a macro and use it with<code>\use{2}</code> or <code>\TWO</code> in the tabulate environment.
{|<context mode=mkiv source=yes>\starttabulate \NC one \NC two \NC\NR \NC two \NC three \NC\NR \TB[halfline] \NC four ! width="45%"|\NC five ! width="10%"|\NC\NR ! width="45%"| \TB[line] \NC four |-\NC five | <texcode>\NC\NR \def\tabulateuse#1%TB[1cm] {\dorecurse{NC eight \numexpr2*#1-1NC nine \relax}{NC\spanNR \omit}}stoptabulate</context>
\appendtoks \let\use\tabulateuse \defineTABLEshorthands\to \everytabulate=Using math mode=
\starttextIf you want to display numerics, you can simply use <cmd>NN</cmd> for a new column instead of <cmd>NC</cmd>. This command works similar to the [http://www.pragma-ade.com/general/magazines/mag-0003.pdf digit-module]. Therefore you can also abbreviate:
<texcode>\starttabulate[|l|Br|l|l|]\NC a HL\NC b NN 10e-3 \NC c \NC d NN 10e+3 \NR\NC 1 \NC 2 \TWO \NC 4 \NRHL
\stoptabulate
</texcode>
instead of <texcode>\stoptextstarttabulate[|l|l|]\HL\NC $10\cdot 10^{-3}$ \NC $10 \cdot 10^3$ \NR\HL\stoptabulate
</texcode>
|
|<context>
\def\tabulateuse#1%
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}}
\appendtoks \let\use\tabulateuse \defineTABLEshorthands\to \everytabulatealthough both variants do work.
\starttextIf you always need math in one column, consider math mode columns:
<texcode>\starttabulate[|lm|Br|l|lm|]\NC a HL\NC b 10e-3 \NC c \NC d 10e+3 \NR\NC 1 \NC 2 \TWO \NC 4 \NRHL
\stoptabulate
</texcode>
\stoptext
</context>
|}
== Paragraph columns =Itemization or framed objects inside a tabulation=
For spanned columns in cells with paragraphs you need a different<!--(added by Willi Egger 04-08-2011, edited by Hraban 2015-10-06)-->implementation. The following issue is related to MkIV:
To use When using an itemization inside a tabulation where one uses also the {{cmd|head}} command, there occurs a snapping problem. This is related to penalties which force a twoline split whereas the snapping mechanism prevents this macro you have . As a result two lines are typeset on top of each other. The solution is to take care about a few thingsadd the following statement to the preamble:<texcode>\tabulatesplitlinemode \plustwo</texcode>
* You have to set a width for each cellThe following code provided by Wolfgang Schuster demonstrates the problem: Compile with and without the line <tt>\tabulatesplitlinemode\plustwo</tt>
* The format for the spanned column is fixed and you have to change it in the macro<texcode>\tabulatesplitlinemode \plustwo\starttabulate[|p|]\NCone \par\blank[penalty:10000]two \par\blank[penalty:10000]three\NC\NR\stoptabulate</texcode>
The same is true if you use {{cmd| ! width="45%"| ! width="10%"| ! width="45%"| |- | <texcode>\def\tabulateuse#1% {\dorecurse{\numexpr2*#1-1\relax}{\span\omitframed}\raggedright\ignorespaces}or something that uses it internally, like [[Widgets]], within Tabulate.
\appendtoks \let\use\tabulateuse \defineTABLEshorthands\to \everytabulate=Combining enumerations and tabulations=
\starttext{{cmd|NI}} (new item) exists since 2017-09-25. {{cmd|itemtag}} is old, but undocumented. Source: http://source.contextgarden.net/tex/context/base/mkiv/strc-itm.mkvi?search=itemtag
<context mode=mkiv source=yes>\startitemize[n]\starttabulate[|p(2cm)|p(3cm)|p(4cm)||]\NC p \dorecurse{10}{text } NC \itemtag \NC q \dorecurse{4}{Lorem Ipsum } NC r \NC\NR\dorecurse{18}{text } NC p \NC \itemtag \NC q \NC r \NC\NR\NC p \TWO Short text spanning two tabulate paragraphs. NC \itemtag \NCq \NC r \NC \NR\dorecurse{17}{text } NC p \NC \itemtag \NC q \NC r \NC\NR
\stoptabulate
\stopitemize
</context>
\stoptext</texcode>\startitemize[n]\starttabulate[|||||<context>]\defNI x \NC y \tabulateuse#1% {NC z \dorecurse{NC \numexpr2*#1-1NR\relax}{NI x \spanNC y \omit}NC z \raggedrightNC \ignorespaces}NR\appendtoks NI x \NC y \letNC z \useNC \tabulateuseNR \defineTABLEshorthandsNI x \NC y \NC z \to NC \everytabulateNR\starttextstoptabulate\switchtobodyfont[8pt]stopitemize
\startitemize[n]\starttabulate[|p(2cm)|p(3cm)|p(4cm)||]\NI b \NC c \dorecurse{10}{text } NC d \NC \dorecurse{4}{Lorem Ipsum } NR\NCa \NI c \dorecurse{18}{text } NC d \NC\NR\NC a \TWO Short text spanning two tabulate paragraphs. NC b \NI d \NC\NR\dorecurse{17}{text } NC a \NCb \NC c \NI \NR
\stoptabulate
\stopitemize
</texcode>
\stoptext
</context>
|}
=See also=
* More features are constantly added and documented only in the [[source:{{src|tabl-tbl.mkiv|source]]}}. * [[{{cmd:|starttabulate}}, {{cmd|Command description]]setuptabulate}}
* [[TABLE|Natural Tables]]
 * [[{{cmd:|starttable}}, <s>{{cmd|Table environment]]setuptable}}</s>
[[Category:Tables]]
4

edits

Navigation menu