Changes

Jump to navigation Jump to search
5,784 bytes added ,  10:38, 23 August 2020
m
removed some old comments
=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
For instance consider a two-column table: if any text in the
first column should be right aligned (''real''
[[right Right and left|<tt>flushright</tt>]]) and the second column
left aligned, the corresponding format string would be
<tt>|l|r|</tt>.
- 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
|}
* <tt>{{cmd|HL</tt> }} draws a horizontal rule,* <tt>{{cmd|NC</tt> }} marks a new column (or new cell),* {{cmd|NN}} marks a new math column/cell (see below),* {{cmd|NR}} starts a new row,* {{cmd|NB}} starts a new row as a block (avoids page breaking inside of a block, to keep some lines together),* {{cmd|TB}} (= "Table Blank") adds some vertical space between rows -- see an example below,* {{cmd|VL}} (instead of {{cmd|NC}}) 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:<tttexcode>NR\starttabulate[|rw(.25\textwidth)|lw(.75\textwidth)|]</tttexcode> starts new row.(Mistake: This doesn’t account for the width of the column distance!)
=Horizontal centering table on the page= <context source=yes>This is a very long text, longer than the width of the table.It is generally not necessary must be long enough to flow to the next line to conclude lines withsee the effect. \placetable[force,none]{}{% \starttabulate[|r|l|] \HL<tt> \NC I want this table \NC aligned in the center.\NC\NR \HL \stoptabulate}</ttcontext> as <tt>\AR< This can also be done with the start/tt> (for stop syntax: <emcontext source=yes>This is a</em>uto<em>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 \HL \stoptabulate\stopplacetable</emcontext>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.
<texcode>\setuptabulate[splitcontext source=yes,header=text,title={\sc Table Titles Undisclosed!}] \starttabulate\dorecurse{2}{ \NC Ed Tufte \NC \input tufte \relax \NC \NR \NC Dick Dawkins \NC \input dawkins \relax \NC \NR}</texcode> <context>\setuppapersize [XYA10, landscape][A4A8, landscape]\setuppaper [nx=2,ny=2]\setuparranging [XY]
\starttextswitchtobodyfont[5pt]\setuppagenumbering[location={header,inright}]\showframe[edge]
\setuptabulate [split=yes, header=text, title={\sc Table Titles Undisclosed!color[red] Fenchurch St. Paul}, frame=on]
\starttabulate[|p(1.2cm)|p(1.2cm)|]\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 <tt>\{{cmd|VL</tt> }} command serves as a replacement for <tt>\{{cmd|NC</tt>}}
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'', <tt>\{{cmd|VL</tt> }} 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:
{|
|<tt>{{cmd|CR</tt> }} || color is applied to the background of the text and the remaining space on the right;.
|-
|<tt>{{cmd|CC</tt> }} || color is applied to the background of the text only; .
|-
|<tt>{{cmd|CM</tt> }} || color is applied to the background of the text and the remaining space on both sides;.
|-
|<tt>{{cmd|CL</tt> }} || color is applied to the background of the text and the remaining space on the left.|-|{{cmd|CT}} || color is applied to the text itself - in other words, the "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 <tt>\{{cmd|NC</tt>}}, 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>
\stoptabulate
</texcode>
 
== Vertical Distance Between Rows ==
 
<!--
There does not seem to be an official interface for
vertical skips.
Manually placed <code>\blank</code>s are
<code>\unskipped</code> on purpose.
However, as expected there is a token list
<code>\t_tabl_tabulate_every_after_row</code> that is
placed after a line is finished.
So, in order to get a vertical spacing of half a baseline
distance you can use this code:
 
<texcode>
\unprotect
\appendtoks
\blank[halfline]
\to \t_tabl_tabulate_every_after_row
\protect
</texcode>
 
-->
 
<context mode=mkiv source=yes>
\starttabulate
\NC one \NC two \NC\NR
\NC two \NC three \NC\NR
\TB[halfline]
\NC four \NC five \NC\NR
\TB[line]
\NC four \NC five \NC\NR
\TB[1cm]
\NC eight \NC nine \NC\NR
\stoptabulate
</context>
=Using math mode=
If 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|l|]
</texcode>
although both variants does do work.
If you always need math in one column, consider math mode columns: <texcode>\starttabulate[|m|m|]\HL\NC 10e-3 \NC 10e+3 \NR\HL\stoptabulate</texcode>  =See Itemization or framed objects inside a tabulation= The following issue is related to MkIV: When using an itemization inside a tabulation where one uses alsothe {{cmd|head}} command, there occurs a snapping problem. This is related to penalties which force a twoline split whereas the snapping mechanism prevents this. As a result two lines are typeset on top of each other. The solution is to add the following statement to the preamble:<texcode>\tabulatesplitlinemode \plustwo</texcode> The following code provided by Wolfgang Schuster demonstrates the problem: Compile with and without the line <tt>\tabulatesplitlinemode\plustwo</tt> <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|framed}} or something that uses it internally, like [[Widgets]], within Tabulate. =Combining enumerations and tabulations= {{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[|||||]\NC p \NC \itemtag \NC q \NC r \NC \NR\NC p \NC \itemtag \NC q \NC r \NC \NR\NC p \NC \itemtag \NC q \NC r \NC \NR\NC p \NC \itemtag \NC q \NC r \NC \NR\stoptabulate\stopitemize</context> <texcode>\startitemize[n]\starttabulate[|||||]\NI x \NC y \NC z \NC \NR\NI x \NC y \NC z \NC \NR\NI x \NC y \NC z \NC \NR\NI x \NC y \NC z \NC \NR\stoptabulate\stopitemize \startitemize[n]\starttabulate[|||||]\NI b \NC c \NC d \NC \NR\NC a \NI c \NC d \NC \NR\NC a \NC b \NI d \NC \NR\NC a \NC b \NC c \NI \NR\stoptabulate\stopitemize</texcode> =EQ option within table=
* More features are constantly added and documented only in the [[sourceEQ option defines text which will be placed by \EQ column separator.Source:tablhttps://www.mail-archive.com/ntg-tblcontext@ntg.mkiv|source]]nl/msg95207.html
* <context mode=mkiv source=yes> \starttabulate[[cmd:starttabulate|Command descriptionl|r|r|][EQ={=}] \NC DC \EQ 3.20 bbl \EQ 420 ft \NC\NR \NC HWDP \EQ 3.90 bbl \EQ 450 ft \NC\NR \NC DP \EQ 34.63 bbl \EQ 2.037 ft \NC\NR \NC DC \EQ 41.73 bbl \EQ 2.907 ft \NC\NR \stoptabulate</context>
=See also=
 
* More features are constantly added and documented in the {{src|tabl-tbl.mkiv|source}}.
* {{cmd|starttabulate}}, {{cmd|setuptabulate}}
* [[TABLE|Natural Tables]]
 * [[{{cmd:|starttable}}, <s>{{cmd|Table environment]]setuptable}}</s>
[[Category:Tables]]

Navigation menu