Open main menu

Changes

m
Minor grammatical corrections.
< [[Tables Overview]] | [[Tabulate]] | [[Tables]] >
This is ConTeXts ConTeXt's oldest table module. It uses the same formatting as [[Tabulate]] (see [[Tables Overview]]).
This mode is based on Michael Wichura's TaBlE package for PlainTeXPlain TeX. The official manual for it is commercial (about 40 18 USD), see [http://www.pctex.com/books.html PCTeX] -- but note that the TaBlE manual only talks about the original syntax, which does not use {{cmd|NC}}, {{cmd|HL}} , cum suis.
The only ConTeXt docs are in [[manual:ms-cb-en.pdf|ConTeXt - an excursion]]. There is are also two introductory articles in tugboat TUGboat [http://tug.org/TUGboat/Articles/tb28-3/tb90mahajan.pdf ConTeXt basics for users: Table macros] [http://www.tug.org/TUGboat/Articles/tb29-1/tb91mahajan.pdf Table macros II] by Aditya Mahajan (2007 and 2008).
== Basic Commands ==
The table is defined by the template enclosed in square brackets after {{cmd|starttable}}. The template has the form
<br><tt>|keys for the first column|keys for the second column|...|keys for the last column|</tt>. <br>Please note that each column is surrounded by <tt>|</tt> signs. These are necessary. The formatting keys for each column can be a choice of
<context>\switchtobodyfont[ss, 8pt]\starttable[{|l|lp(.5\textwidth)|]class="wikitable"\HL ! Key\NC \bf Key \VL \bf ! Meaning \SR\HL |-\NC \NC ! colspan="2" | Primitive Keys \SR\HL |-\NC \type{| <code>a{<em>tokens</em>}}\VL </code> | Adds \type{<code><em>tokens} {\</em></code> <em >after} </em> the column content\AR\NC \type{|- |- | <code>b{<em>tokens</em>}}\VL </code> | Adds \type{<code><em>tokens} '''</em></code> <em>before''' </em> the column content\AR\NC {\tt \backslash|- | <code>\{ } \VL </code> | Enclose the column in braces (grouping)\AR\NC \type{|- | <code>*{<em>n</em>}{<em>keys</em>}}\VL </code> | Equivalent to repeating the formatting keys \type{<code><i>keys} \type{</i></code> <code><i>n} </i></code> times\NC\LR\HL |-\NC \NC ! colspan="2" | Positioning Keys\SR\HL |-\NC \type{| <code>\LeftGlue} \VL </code> | Specifies the left glue to be used before the column\AR\NC \type{|- | <code>\RightGlue} \VL </code> | Specifies the right glue to be used after the column\AR\NC \type{|- | <code>l} \VL </code> | left-aligned column\AR\NC \type{|- | <code>c} \VL </code> | centered column\AR\NC \type{|- | <code>r} \VL </code> | right-aligned column\AR\NC \type{|- | <code>p(<em>width</em>)} \VL </code> | Set each cell as a paragraph\AR\NC \type{|- | <code>s(<em>width</em>)} \VL </code> | Specify the inter-column width\AR\NC \type{|- | <code>w} \VL </code> | Set minimum column width\AR\NC \type{|- | <code>k} \VL </code> | Insert a kern both left and right of the column\AR\NC \type{|- | <code>i} \VL </code> | Add a kern to the left of the column\AR\NC \type{|- | <code>j} \VL </code> | Add a kern to the right of the column\LR\HL |-\NC \NC ! colspan="2" | Numeric and Math Item Keys \SR\HL |-\NC \type{| <code>n} \VL </code> | Numeric item not in math mode\AR\NC \type{|- | <code>N} \VL </code> | Numeric item in math mode\AR\NC \type{|- | <code>m} \VL </code> | Each cell is in (inline) math mode. Equivalent to \type{<code>b$ a$}\AR</code> |-\NC \type{| <code>M} \VL </code> | Each cell is in display math mode. Equivalent to \type{<code>\{b{$\displaystyle}a$}} \AR</code> |-\NC \type{| <code>\m} \VL </code> | Equivalent to \type{1 <code>l b{{}}m}\AR</code> |-\NC \type{| <code>\M} \VL </code> | Equivalent to \type{1 <code>l b{{}}M}\LR</code>\HL |-\NC \NC ! colspan="2" | Style Keys \SR\HL |-\NC \type{| <code>f\<em>command} \VL </em></code> | Set font according to following \tex{<code><em>command}\AR</em></code> |-\NC \type{| <code>B} \VL </code> | Bold. Equivalent to \type{<code>f\bf}\AR</code> |-\NC \type{| <code>I} \VL </code> | Italic. Equivalent to \type{<code>f\it}\AR</code> |-\NC \type{| <code>S} \VL </code> | Slanted. Equivalent to \type{<code>f\sl}\AR</code> |-\NC \type{| <code>R} \VL </code> | Roman. Equivalent to \type{<code>f\rm}\AR</code> |-\NC \type{| <code>T} \VL </code> | Teletype. Equivalent to \type{<code>f\tt}\AR</code> |-\NC \type{| <code>C} \VL </code> | Color. Use it in combination with \backslash<code>\{ </code> (e.g. \backslash<code>\{C\{<em>red\</em>} </code>)\LR\HL |-\NC \NC ! colspan="2" | Tabskip Keys \SR\HL |-\NC \type{| <code>s} \VL </code> | Set the tabskip to the right of this column and of all following columns up to the next \type{<code>s} </code> or \type{<code>o} </code> key\AR\NC \type{|- | <code>o} \VL </code> | Set the tabskip to the right of this column only\LR\HL |-\stoptable</context> |}
=== Column definition examples===
==Column Spans==
It's possible to create columnspans (i.e. , cells that span more than one column) with the command {{cmd|use|{<i>N</i>}}} where ''N'' is the number of columns spanned by the cell. It's often necessary to use {{cmd|ReFormat|[<i>new keys</i>]{}}} to reformat this specific cell according to the ''new keys''.
== Row Spans==
It's also possible to create rowspans (i.e. cells that span more than one row) with the command {{cmd|Raise|(<i>dimen</i>){<i>content</i>}}} or {{cmd|Lower|(<i>dimen</i>){</i>content</i>}}} that raise or lower ''content'' by ''dimen''.
<table cols="2"><tr valign="top"><td>
</td></tr></table>
({{cmd|Lower|(.5\lineheight){a}}} can be abbreviated {{cmd|LOW|{a}}} for brevity.)
An alternative means of spanning rows by a tall object makes use of a bit of TeX magic:
{{cmd|smash|{tall object}}}:
<table cols="2"><tr valign="top"><td>
<!-- It makes no sense to typeset this here. -->
Since the table module has been under [http://www.ntg.nl/pipermail/ntg-context/2010/055004.html reconstruction] this approach works only for MKII. In MKIV one can use
<texcode>
== Booktabs ==
Latex has an excellent package called booktabs for typesetting tables. The main features of that package is that you can have top, mid, and bottom rules of different thickness. It is possible to achieve similar effects using tablestable. For example, to match the default settings of booktabs (Well well almost, this gives a top and bottom rules of 0.09em while booktabs sets it to 0.08em).
<table cols="2"><tr valign="top"><td>
38

edits