Changes

Jump to navigation Jump to search
5,162 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
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 row as 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 the
current page-width. For example: if you want the previous table
take up all the width and having the second column taking three
quarters 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[|rw(r|l|] \HL \NC I want this table \NC aligned in the center.25\textwidth)|lw(.75NC\NR \HL \textwidth)|]stoptabulate}</context>
This can also be done with the start/stop syntax (showing only source here, since it does not compile on the wiki):
<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.<tt>\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\AR</tt> (for <em>a</em>uto<em>rstopplacetable</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.
<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;.
|-
|<ttcmd>CC</ttcmd> || color is applied to the background of the text only; .
|-
|<ttcmd>CM</ttcmd> || color is applied to the background of the text and the remaining space on both sides;.
|-
|<ttcmd>CL</ttcmd> || color is applied to the background of the text and the remaining space on the left.|-|<cmd>CT</cmd> || 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 <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>
\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=
</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>  =Itemization or framed objects inside a tabulation= <!--(added by Willi Egger 04-08-2011, edited by Hraban 2015-10-06)--> The following issue is related to MkIV: 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. 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
=See also=\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>
* More features are constantly added and documented only in the [[source:tabl-tbl.mkiv|source]].
* [[cmd:starttabulate|Command description]]=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]]
3

edits

Navigation menu