Changes

Jump to navigation Jump to search
8,630 bytes added ,  12:50, 8 December 2010
general overaul
< [[Tables Overview]] | [[Table]] >
== Basic commands ==
Rather simple tabulating. You ''need'' the bars in the formatting field of <cmd>starttabulate</cmd>! '''If you want vertical lines, you need another table mode''' (see [[Tables]]).=Summary=
This [[cmd:starttabulate|Tabulate]] is especially suited if you want to have a versatile table environment.It supports ''paragraphs '' in one cells, ''vertical rules'' (or moreforthose typographically less demanding jobs&nbsp;…) , and''colorization'' of those rules, the tabulate columnsbackground of fields as wellas the text itself.
=Basic commands= The sample describes control sequence <tt>\starttabulate[#1]</tt> takes a layoutstring as optional argument.As is common with tables in TeX-based typesetting, this string(in its basic variant) consists primarily of the formatting characters''bar''character (“<tt>|</tt>”) as delimiter for columns,and of the letters <tt>c</tt>, <tt>l</tt>, as well as <tt>r</tt>,denoting the ''alignment'' within cells of this row. For instance consider a two-column table: if any text in thefirst column should be right aligned (''real''[[right and left|<tt>flushright</tt>]]) and the second columnleft aligned, the corresponding format string would be<tt>|l|r|</tt>.''NB'':those bars, as stated above, denote cell limits only&ndash; ''not'' vertical lines. <!-- - wtf this listing was full of <tab> chars‽ Was this supposed - to be a bad pun on *tabulate*?-->
{|
! width="55%"|
|-
| <texcode>
\starttabulate[|lr|l|]
\HL
\NC {\bf format } \NC {\bf meaning } \NC\NR
\HL
\NC c \NC centered \NC\NR\NC l \NC left aligned \NC\NR\NC r \NC right aligned \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
|
|<context>
\starttabulate[|lr|l|]
\HL
\NC {\bf format } \NC {\bf meaning } \NC\NR
\HL
\NC c \NC centered \NC\NR\NC l \NC left aligned \NC\NR\NC r \NC right aligned \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>HL is </tt> draws a horizontal linerule,* <tt>NC is </tt> marks a new column (or new cell),* <tt>NR is </tt> starts new row. It is generally not necessary to conclude lines with<tt>\NC\NR</tt> as <tt>\AR</tt> (for <em>a</em>uto<em>r</em>ow)will do the job as well. =Spanning Multiple Pages= Tabulate may extend to adjacient pages if needed.To achieve this the argument <tt>split</tt> must be set to''true''.''NB'': the difference between setting and unsetting thisargument may not be visible on the first few pages. Rather, itseems to affect the ''end'' of the environment. <context source="yes">\setuppapersize [XY][A4]\setuppaper [nx=2,ny=2]\setuparranging [XY]\setupbodyfont[10pt] \starttext \setuptabulate[split=yes] \starttabulate\dorecurse{2}{ \NC test \NC \input tufte \relax \NC \NR \NC test \NC \input dawkins \relax \NC \NR }\stoptabulate \stoptext \endinput</context> ==Titles== A tabulating environment can have an optional name which will berepeated 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>\setuptabulate</tt>.The <tt>header</tt> key has to be set to <em>text</em> for thisto work. <texcode>\setuptabulate[split=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 [XY][A4]\setuppaper [nx=2,ny=2]\setuparranging [XY] \starttext \setuptabulate[split=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}\stoptabulate
== Headers and Footers ==\stoptext \endinput</context>
In long tabulations you'd like <!-- - ==Headers and Footers== - As I couldn’t get footers running I just comment this and - leave it to whoever discovers the trick to get your headers activate them. - (and perhaps footers) The <tt>footer=</tt> key seems to be implemented for - “\setuptabulate” but I couldn’t notice any effect.-->==Headers==Tabulate supports header rows that can be repeated on every page:over new tablepages instead of the title.There is a separate environment <tt>\starttablehead</tt> wherethis header row has to be specified in advance of its use in atabulation.
{|
|-
| <texcode>
\setuptabulate[headerssplit=yes,header=repeat] % same for footers 
\starttabulatehead
\HL \NC {\bf format char} \NC {\bf meaning } \NC\NRAR \HL
\stoptabulatehead
 \starttabulate[|lr|l|] \NC c \NC centered \NC\NRAR \NC l \NC left aligned \NC\NRAR \NC r \NC right aligned \NC\NRAR
\stoptabulate
</texcode>
|
| <context>
\setuptabulate[headerssplit=yes,header=repeat] % same for footers 
\starttabulatehead
\HL
\NC {\bf format char} \NC {\bf meaning} \AR
\HL
\stoptabulatehead
 
\starttabulate[|r|l|]
\NC c \NC centered \AR
\NC l \NC left aligned \AR
\NC r \NC right aligned \AR
\stoptabulate
</context>
|}
 
=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==
 
===Horizontal Rules===
 
As already demonstrated above, the <tt>\HL</tt> statement inserts
a hairline after the current line.
This particularly useful when demarking header and footer rows or
separated parts of a table that should not be as closely
associated as the rows between the rules.
 
{|
! width="55%"|
! width="10%"|
! width="35%"|
|-
| <texcode>
\starttabulate[|r|c|l|]
\NC test \NC test \NC test \NC\NR
\HL
\NC test \NC test \NC test \NC\NR
\NC test \NC test \NC test \NC\NR
\HL
\NC test \NC test \NC test \NC\NR
\HL
\stoptabulate
</texcode>
| <context>
\starttabulate[|r|c|l|]
\NC test \NC test \NC test \NC\NR
\HL
\NC test \NC test \NC test \NC\NR
\NC test \NC test \NC test \NC\NR
\HL
\NC format test \NC meaning test \NC test \NC\NR
\HL
\stoptabulatehead
\starttabulate[|l|l|]
\NC c \NC centered \NC\NR
\NC l \NC left aligned \NC\NR
\NC r \NC right aligned \NC\NR
\stoptabulate
</context>
|}
Context supports different categories of rules that can beconfigured 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 betweenordinary rows of the table body and will prevent page breaks&ndash; no way you’d end up with a rogue hairline desecratingthe bottom of your page’s text area.{|cellpadding="10" style= Column Spans "border:2px solid #addeff"! style="background:#addeff;" | Type !! Description|-|<tt>\HL</tt> || standard horizontal rule;|-|<tt>\FL</tt> || first rule;|-|<tt>\ML</tt> || mid rule;|-|<tt>\LL</tt> || bottom rule;|-|<tt>\LL</tt> and <tt>\TL</tt> || bottom rule;|-|<tt>\BL</tt> || last rule.|} Additionally, there is an options <tt>rulecolor</tt> for<tt>\setuptabulate</tt> that allows for those rules to be tinted. <texcode>\setuptabulate[rulecolor=red] \starttabulate[|r|c|l|] \FL \NC first row \NC test \NC test \NC\NR \ML \NC rows in \NC test \NC test \NC\NR \NC between \NC test \NC test \NC\NR \LL \NC last row \NC test \NC test \NC\NR \BL\stoptabulate</texcode> Other types can be discovered in the source([[source:tabl-tbl.mkiv|tabl-tbl.mkiv]]). ===Vertical Rules=== The <tt>\VL</tt> command serves as a replacement for <tt>\NC</tt>to mark a cell border wherever a vertical rule may be desired (ifthey are to be desired at all from a typographical point ofview). <texcode>\starttabulate[||||] \NC test \VL test \VL test \VL\NR \VL test \NC test \VL test \VL\NR \VL test \VL test \NC test \VL\NR \VL test \VL test \VL test \NC\NR \stoptabulate</texcode> ==Coloring== The following elements can be colorized: rules, cell backgrounds,and, obviously, common text. ===Colorizing Rules=== For ''horizontal rules'' see above. For ''vertical rules'', <tt>\VL</tt> takes a defined color as anoptional argument. <texcode>\starttabulate[|r|c|l|] \VL test \VL[red] red rule \VL test \VL \NR \VL test \VL[green] green rule \VL test \VL \NR \VL test \VL[blue] blue rule \VL test \VL \NR \stoptabulate</texcode> ===Colorizing Backgrounds===''Backgrounds'' can be colorized either on column basis orindividually by cell. There are four color-specific control sequences:{||<tt>CR</tt> || color is applied to the background of the text and the remaining space on the right;|-|<tt>CC</tt> || color is applied to the background of the text only; |-|<tt>CM</tt> || color is applied to the background of the text and the remaining space on both sides;|-|<tt>CL</tt> || color is applied to the background of the text and the remaining space on the left.|}These are to complement the normal table layout expression (thefirst argument to <tt>\starttabulate</tt>.Thus, in order to colorize a four column table with the initiallayout <tt>|c|c|c|c|</tt> it will have to be modified as follows:<texcode>\starttabulate[|CR{red}c|CC{yellow}c|CM{green}c|CL{blue}c|] \NC test \NC test \NC test \NC test \NC \NR \NC test \NC test \NC test \NC test \NC \NR \NC test \NC test \NC test \NC test \NC \NR \NC test \NC test \NC test \NC test \NC \NR \stoptabulate</texcode> Those control sequences, if applied within the table body, canreplace the ordinary <tt>\NC</tt>, allowing individual cells tobe colorized.<texcode>\starttabulate[|c|c|c|c|c|c|] \NC g \NC l \NC i \NC d \NC e \NC r \NC \NR \NC g \NC l \NC i \CM[blue] d \NC e \NC r \NC \NR \NC g \NC l \NC i \NC d \CM[blue] e \NC r \NC \NR \NC g \NC l \CM[blue] i \CM[blue] d \CM[blue] e \NC r \NC \NR \NC g \NC l \NC i \NC d \NC e \NC r \NC \NR \stoptabulate</texcode>  ===Colorizing Cell Text===''Normal text'' inside cells gets its color via the[[colors|standard coloring commands]]. <texcode>\starttabulate[|r|c|l|] \NC test \NC {\colored[red] test} \NC test \NC\NR \NC test \NC {\colored[green] test} \NC test \NC\NR \NC test \NC {\colored[blue] test} \NC test \NC\NR \NC test \NC {\colored[cyan] test} \NC test \NC\NR \stoptabulate</texcode> 
Tabulate has no support for column spans but you could add this function yourself.=Column Spans=
Tabulate has no support for column spans but you could add thisfunction yourself.The code to do this depends on the tabulate setting and you have to know whatcontent what column setting you need.
=== Single row columns ===
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.
|}
=== Paragraph columns ===
For spanned columns in cells with paragraphs you need a different implementation.
To use this macro you have to take care about a few things:
* You have to set a width for each cell
 * The format for the spanned column is fixed and you have to change it in the macro
{|
|}
=See also=  * More Features ==features are constantly added and documented only in the [[source:tabl-tbl.mkiv|source]]. * [[cmd:starttabulate|Command description]] * [[TABLE|Natural Tables]]
... are documented only in the * [[sourcecmd:tabl-tbl.mkiistarttable|sourceTable environment]].
[[Category:Tables]]
188

edits

Navigation menu