https://wiki.contextgarden.net/api.php?action=feedcontributions&user=LuP&feedformat=atomWiki - User contributions [en]2024-03-29T08:02:06ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Tabulate&diff=30016Tabulate2020-07-31T13:27:48Z<p>LuP: </p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
<br />
=Summary=<br />
<br />
{{cmd|starttabulate}} is a versatile table environment.<br />
It supports ''paragraphs'' in cells, ''vertical rules'' (for<br />
those typographically less demanding jobs&nbsp;…), and<br />
''colorization'' of those rules, the background of fields as well<br />
as the text itself.<br />
<br />
'''Warning''': When you want to use tables with macros use {{cmd|starttable}} and \stoptable. {{cmd|starttabulate}} and \stoptabulate does not work correctly with macros.<br />
<br />
=Basic commands=<br />
<br />
The control sequence {{cmd|starttabulate|[#1]}} takes a layout<br />
string as optional argument.<br />
As is common with tables in TeX-based typesetting, this string<br />
(in its basic variant) consists primarily of the ''bar''<br />
character (“<tt>|</tt>”) as delimiter for columns,<br />
and of the letters <tt>c</tt>, <tt>l</tt>, as well as <tt>r</tt>,<br />
denoting the ''alignment'' within cells of this row.<br />
<br />
For instance consider a two-column table: if any text in the<br />
first column should be right aligned (''real''<br />
[[Right and left|<tt>flushright</tt>]]) and the second column<br />
left aligned, the corresponding format string would be<br />
<tt>|l|r|</tt>.<br />
''NB'': those bars, as stated above, denote cell limits only<br />
&ndash; ''not'' vertical lines.<br />
<br />
<!--<br />
- wtf this listing was full of <tab> chars‽ Was this supposed<br />
- to be a bad pun on *tabulate*?<br />
- - No, I formatted it readably in my text editor. --HR<br />
--><br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|l|lB|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC Mk \NC\NR<br />
\HL<br />
\NC c \NC centered \NC \NC\NR<br />
\NC l \NC left aligned \NC \NC\NR<br />
\NC r \NC right aligned \NC \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC \NC\NR<br />
\NC cg(.) \NC align on a character \NC IV: cg{.} \NC\NR<br />
\NC m \NC math mode \NC IV only \NC\NR<br />
\NC b \NC before e.g. b{\star} \NC IV only \NC\NR<br />
\NC a \NC after, e.g. a{\percent} \NC IV only \NC\NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
|<br />
|<context><br />
\setuppapersize[A5]<br />
\starttabulate[|r|l|lB|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning}\NC Mk \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
* <cmd>HL</cmd> draws a horizontal rule,<br />
* <cmd>NC</cmd> marks a new column (or new cell),<br />
* <cmd>NN</cmd> marks a new math column/cell (see below),<br />
* <cmd>NR</cmd> starts a new row,<br />
* <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-->);<br />
* <cmd>TB</cmd> (= "Table Blank") adds some vertical space between rows -- see an example bellow,<br />
* <cmd>VL</cmd> (instead of <cmd>NC</cmd>) draws a vertical rule -- for more info see below.<br />
<br />
When using fixed width, you can use values relative to the<br />
current page-width. For example: if you want the previous table<br />
take up all the width and having the second column taking three<br />
quarters of the space, change the {{cmd|starttabulate}} to:<br />
<texcode><br />
\starttabulate[|rw(.25\textwidth)|lw(.75\textwidth)|]<br />
</texcode><br />
(Mistake: This doesn’t account for the width of the column distance!)<br />
<br />
=Horizontal centering table on the page=<br />
<br />
<!--(Solution from the mailing list)--><br />
<br />
<context source=yes><br />
This is a very long text, longer than the width of the table.<br />
It must be long enough to flow to the next line to see the effect.<br />
<br />
\placetable[force,none]{}{%<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC I want this table \NC aligned in the center.\NC\NR<br />
\HL<br />
\stoptabulate<br />
}</context><br />
<br />
This can also be done with the start/stop syntax (showing only source here, since it does not compile on the wiki):<br />
<br />
<context source=yes><br />
This is a very long text, longer than the width of the table.<br />
It must be long enough to flow to the next line to see the effect.<br />
<br />
\startplacetable[location=force,number=no]<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC I want this table \NC aligned in the center.\NC\NR<br />
\HL<br />
\stoptabulate<br />
\stopplacetable<br />
</context><br />
<br />
=Spanning Multiple Pages=<br />
<br />
Tabulate may extend to adjacient pages if needed.<br />
To achieve this the argument <tt>split</tt> must be set to<br />
''true''.<br />
<br />
''NB'': the difference between setting and unsetting this<br />
argument may not be visible on the first few pages. Rather, it<br />
seems to affect the ''end'' of the environment.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<br />
==Titles==<br />
<br />
A tabulating environment can have an optional name which will be<br />
repeated above at every page break that occurs inside the table.<br />
This name needs to be specified as the argument of the<br />
<tt>title</tt> key of {{cmd|setuptabulate}}.<br />
The <tt>header</tt> key has to be set to <em>text</em> for this<br />
to work.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<!--<br />
- ==Headers and Footers==<br />
- As I couldn’t get footers running I just comment this and<br />
- leave it to whoever discovers the trick to activate them.<br />
- (The <tt>footer=</tt> key seems to be implemented for<br />
- “\setuptabulate” but I couldn’t notice any effect.<br />
--><br />
<br />
==Headers==<br />
Tabulate supports header rows that can be repeated over new table<br />
pages instead of the title.<br />
There is a separate environment {{cmd|starttabulatehead}} where<br />
this header row has to be specified in advance of its use in a<br />
tabulation.<br />
<br />
In ConTeXt MkIV the command requires an additional [], thus you need<br />
to write {{cmd|starttabulatehead}}[] instead.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\FL<br />
\NC {\bf format char} \NC {\bf meaning} \NC \AR<br />
\LL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \NC \AR<br />
\NC l \NC left aligned \NC \AR<br />
\NC r \NC right aligned \NC \AR<br />
\stoptabulate<br />
</texcode><br />
|<br />
| <context><br />
\setuppapersize[A5]<br />
<br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\FL<br />
\NC {\bf format char} \NC {\bf meaning} \AR<br />
\LL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \AR<br />
\NC l \NC left aligned \AR<br />
\NC r \NC right aligned \AR<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
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.<br />
<br />
=Individualizing the Tabulate Look=<br />
<br />
Hans initially announced support for vertical lines and colors on<br />
the mailing list. [http://archive.contextgarden.net/message/20101117.123950.739657a7.en.html]<br />
<br />
==Rules==<br />
<br />
===Horizontal Rules===<br />
<br />
As already demonstrated above, the <tt>\HL</tt> statement inserts<br />
a hairline after the current line.<br />
This particularly useful when demarking header and footer rows or<br />
separated parts of a table that should not be as closely<br />
associated as the rows between the rules.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</texcode><br />
| <context><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
Context supports different categories of rules that can be<br />
configured individually in order to discern various applications.<br />
Their behaviour accounts for the designated use, e.g.<br />
<tt>\ML</tt> (mid rules) are intended to be deployed between<br />
ordinary rows of the table body and will prevent page breaks<br />
&ndash; no way you’d end up with a rogue hairline desecrating<br />
the bottom of your page’s text area.<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Type !! Description<br />
|-<br />
|<tt>\HL</tt> || standard horizontal rule;<br />
|-<br />
|<tt>\FL</tt> || first rule;<br />
|-<br />
|<tt>\ML</tt> || mid rule;<br />
|-<br />
|<tt>\LL</tt> || bottom rule;<br />
|-<br />
|<tt>\LL</tt> and <tt>\TL</tt> || bottom rule;<br />
|-<br />
|<tt>\BL</tt> || last rule.<br />
|}<br />
<br />
Additionally, there is an option <tt>rulecolor</tt> for<br />
{{cmd|setuptabulate}} that allows for those rules to be tinted.<br />
<br />
<texcode><br />
\setuptabulate[rulecolor=red]<br />
<br />
\starttabulate[|r|c|l|] <br />
\FL<br />
\NC first row \NC test \NC test \NC\NR <br />
\ML<br />
\NC rows in \NC test \NC test \NC\NR <br />
\NC between \NC test \NC test \NC\NR <br />
\LL <br />
\NC last row \NC test \NC test \NC\NR <br />
\BL<br />
\stoptabulate<br />
</texcode><br />
<br />
Other types can be discovered in the source<br />
([[source:tabl-tbl.mkiv|tabl-tbl.mkiv]]).<br />
<br />
===Vertical Rules===<br />
<br />
The <cmd>VL</cmd> command serves as a replacement for <cmd>NC</cmd><br />
to mark a cell border wherever a vertical rule may be desired (if<br />
they are to be desired at all from a typographical point of<br />
view).<br />
<br />
<texcode><br />
\starttabulate[||||] <br />
\NC test \VL test \VL test \VL\NR <br />
\VL test \NC test \VL test \VL\NR <br />
\VL test \VL test \NC test \VL\NR <br />
\VL test \VL test \VL test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
==Coloring==<br />
<br />
The following elements can be colorized: rules, cell backgrounds,<br />
and, obviously, common text.<br />
<br />
===Colorizing Rules===<br />
<br />
For ''horizontal rules'' see above.<br />
<br />
For ''vertical rules'', <cmd>VL</cmd> takes a defined color as an<br />
optional argument.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\VL test \VL[red] red rule \VL test \VL \NR <br />
\VL test \VL[green] green rule \VL test \VL \NR <br />
\VL test \VL[blue] blue rule \VL test \VL \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
===Colorizing Backgrounds & Text===<br />
Backgrounds and text can be colorized either on column basis or<br />
individually by cell.<br />
<br />
There are five color-specific control sequences:<br />
{|<br />
|<cmd>CR</cmd> || color is applied to the background of the text and the remaining space on the right.<br />
|-<br />
|<cmd>CC</cmd> || color is applied to the background of the text only.<br />
|-<br />
|<cmd>CM</cmd> || color is applied to the background of the text and the remaining space on both sides.<br />
|-<br />
|<cmd>CL</cmd> || color is applied to the background of the text and the remaining space on the left.<br />
|-<br />
|<cmd>CT</cmd> || color is applied to the text itself - in other words, the "foreground color."<br />
|}<br />
These are to complement the normal table layout expression (the<br />
first argument to {{cmd|starttabulate}.<br />
Thus, in order to colorize a four column table with the initial<br />
layout <tt>|c|c|c|c|</tt> it will have to be modified as follows:<br />
<texcode><br />
\starttabulate[|CR{red}c|CC{yellow}c|CM{green}c|CL{blue}c|] <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
Those control sequences, if applied within the table body, can<br />
replace the ordinary <cmd>NC</cmd>, allowing individual cells to<br />
be colorized.<br />
<texcode><br />
\starttabulate[|c|c|c|c|c|c|]<br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \CM[blue] d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \CM[blue] i \CM[blue] d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
'''caveat emptor'''! The background coloring does apply only to<br />
the ''first'' row of a paragraph cell. Any other cell will come<br />
out colorless. If you need to color an entire multi-line cell,<br />
you will need to switch to another<br />
[[Tables Overview|tabulation variant]].<br />
<br />
===Colorizing Cell Text===<br />
''Normal text'' inside cells gets its color via the<br />
[[Color|standard coloring commands]], or by the <br />
shorter variant described above.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC {\colored[red] test} \NC test \NC\NR <br />
\NC test \NC {\colored[green] test} \NC test \NC\NR <br />
\NC test \NC {\colored[blue] test} \NC test \NC\NR <br />
\NC test \NC {\colored[cyan] test} \NC test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
== Vertical Distance Between Rows ==<br />
<br />
<!--<br />
There does not seem to be an official interface for<br />
vertical skips.<br />
Manually placed <code>\blank</code>s are<br />
<code>\unskipped</code> on purpose.<br />
However, as expected there is a token list<br />
<code>\t_tabl_tabulate_every_after_row</code> that is<br />
placed after a line is finished.<br />
So, in order to get a vertical spacing of half a baseline<br />
distance you can use this code:<br />
<br />
<texcode><br />
\unprotect<br />
\appendtoks<br />
\blank[halfline]<br />
\to \t_tabl_tabulate_every_after_row<br />
\protect<br />
</texcode><br />
<br />
--><br />
<br />
<context mode=mkiv source=yes><br />
\starttabulate<br />
\NC one \NC two \NC\NR <br />
\NC two \NC three \NC\NR <br />
\TB[halfline]<br />
\NC four \NC five \NC\NR <br />
\TB[line]<br />
\NC four \NC five \NC\NR <br />
\TB[1cm]<br />
\NC eight \NC nine \NC\NR <br />
\stoptabulate<br />
</context><br />
<br />
=Using math mode=<br />
<br />
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:<br />
<br />
<texcode>\starttabulate[|l|l|]<br />
\HL<br />
\NN 10e-3 \NN 10e+3 \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
instead of<br />
<br />
<texcode><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC $10\cdot 10^{-3}$ \NC $10 \cdot 10^3$ \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
although both variants do work.<br />
<br />
If you always need math in one column, consider math mode columns:<br />
<br />
<texcode><br />
\starttabulate[|m|m|]<br />
\HL<br />
\NC 10e-3 \NC 10e+3 \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
<br />
=Itemization or framed objects inside a tabulation=<br />
<br />
<!--(added by Willi Egger 04-08-2011, edited by Hraban 2015-10-06)--><br />
<br />
The following issue is related to MkIV:<br />
<br />
When using an itemization inside a tabulation where one uses also the <br />
{{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:<br />
<texcode>\tabulatesplitlinemode \plustwo</texcode><br />
<br />
The following code provided by Wolfgang Schuster demonstrates the problem: Compile with and without the line <tt>\tabulatesplitlinemode\plustwo</tt><br />
<br />
<texcode><br />
\tabulatesplitlinemode \plustwo<br />
\starttabulate[|p|]<br />
\NC<br />
one \par<br />
\blank[penalty:10000]<br />
two \par<br />
\blank[penalty:10000]<br />
three<br />
\NC\NR<br />
\stoptabulate<br />
</texcode><br />
<br />
The same is true if you use {{cmd|framed}} or something that uses it internally, like [[Widgets]], within Tabulate.<br />
<br />
=Combining enumerations and tabulations=<br />
<br />
{{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<br />
<br />
<context mode=mkiv source=yes><br />
\startitemize[n]<br />
\starttabulate[|||||]<br />
\NC p \NC \itemtag \NC q \NC r \NC \NR<br />
\NC p \NC \itemtag \NC q \NC r \NC \NR<br />
\NC p \NC \itemtag \NC q \NC r \NC \NR<br />
\NC p \NC \itemtag \NC q \NC r \NC \NR<br />
\stoptabulate<br />
\stopitemize<br />
</context><br />
<br />
<texcode><br />
\startitemize[n]<br />
\starttabulate[|||||]<br />
\NI x \NC y \NC z \NC \NR<br />
\NI x \NC y \NC z \NC \NR<br />
\NI x \NC y \NC z \NC \NR<br />
\NI x \NC y \NC z \NC \NR<br />
\stoptabulate<br />
\stopitemize<br />
<br />
\startitemize[n]<br />
\starttabulate[|||||]<br />
\NI b \NC c \NC d \NC \NR<br />
\NC a \NI c \NC d \NC \NR<br />
\NC a \NC b \NI d \NC \NR<br />
\NC a \NC b \NC c \NI \NR<br />
\stoptabulate<br />
\stopitemize<br />
</texcode><br />
<br />
=EQ option within table=<br />
<br />
EQ option defines text which will be placed by \EQ column separator.<br />
Source: https://www.mail-archive.com/ntg-context@ntg.nl/msg95207.html<br />
<br />
<context mode=mkiv source=yes><br />
\starttabulate[|l|r|r|][EQ={=}]<br />
\NC DC \EQ 3.20 bbl \EQ 420 ft \NC\NR<br />
\NC HWDP \EQ 3.90 bbl \EQ 450 ft \NC\NR<br />
\NC DP \EQ 34.63 bbl \EQ 2.037 ft \NC\NR<br />
\NC DC \EQ 41.73 bbl \EQ 2.907 ft \NC\NR<br />
\stoptabulate<br />
</context><br />
<br />
=See also=<br />
<br />
* More features are constantly added and documented in the {{src|tabl-tbl.mkiv|source}}.<br />
* {{cmd|starttabulate}}, {{cmd|setuptabulate}}<br />
* [[TABLE|Natural Tables]]<br />
* {{cmd|starttable}}, <s>{{cmd|setuptable}}</s><br />
<br />
[[Category:Tables]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupcolumns&diff=26055Command/setupcolumns2020-05-22T13:32:55Z<p>LuP: /* Example */</p>
<hr />
<div>{{Reference<br />
|name=setupcolumns<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setupcolumns</syntax><br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupcolumns<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:ntop|ntop]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:rule|rule]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] – DEPRECATED - use "separator=rule" instead </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:height|height]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:tolerance|tolerance]]</td><br />
<td>[[Command/value:verystrict|verystrict]] [[Command/value:strict|strict]] [[Command/value:tolerant|tolerant]] [[Command/value:verytolerant|verytolerant]] [[Command/value:stretch|stretch]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:balance|balance]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:blank|blank]]</td><br />
<td>[[Command/value:fixed|fixed]] [[Command/value:halfline|halfline]] [[Command/value:line|line]] [[Command/value:flexible|flexible]] [[Command/value:big|big]] [[Command/value:medium|medium]] [[Command/value:small|small]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:option|option]]</td><br />
<td>[[Command/value:background|background]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:direction|direction]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setupframed|\setupframed]] </td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
Consider using paragraphs ({{cmd|defineparagraphs}} or column sets ({{cmd|startcolumnset}} instead of ‘simple’ columns.<br />
<br />
{| class="wikitable"<br />
|-<br />
| n <br />
| Number of columns. Default is n=2.<br />
|-<br />
| rule <br />
| DEPRECATED: Draw a line between the columns. Default is off.<br />
|-<br />
| separator=rule<br />
| Add vertical line between columns.<br />
|-<br />
| tolerance <br />
| Affects spacing. Narrow columns should be set tolerant, verytolerant or stretch<br />
|- <br />
| distance <br />
| Size of the gap between the columns.<br />
|- <br />
| balance <br />
| Should the columns be balanced, i.e. should they get the same number of lines?<br />
|- <br />
| align <br />
| Left, right (raggedleft, raggedright).<br />
|- <br />
| blank <br />
| Amount of whitespace between paragraphs set in columns. Also accepts a dimension as an argument. Column equivalent of {{cmd|setupwhitespace}}.<br />
|- <br />
| option <br />
| With option=background you can use everything that \setupframed offers.<br />
|- <br />
| direction <br />
| Default is right, i.e. the first column is on the left; 'left' means the first column is the rightmost.<br />
|- <br />
| height <br />
| height is unclear to me.<br />
|- <br />
| ntop <br />
| ntop contains the minimum number of lines a column should have. If, when a new set of columns starts (e.g. at the start of a page), there are 12 lines to distribute and <code>ntop=7</code>, then ConTeXt will produce one 12-line column rather than two 6-line columns. Note that <code>ntop=6</code> will result in one 7-line column and one 5-line column: ConTeXt seems to prefer that the last column be shorter, as long as its length is at least <code>ntop - n + 1</code>.<br />
|}<br />
<br />
== Example ==<br />
<context source=yes><br />
\setupcolumns<br />
[n=3,<br />
rule=on, % DEPRECATED<br />
separator=rule, % need newly instead "rule=on"<br />
ntop=4,background=color,backgroundcolor=green,<br />
]<br />
<br />
\startcolumns<br />
% 12 lines, please<br />
\dorecurse{12}{line\crlf}<br />
\stopcolumns<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|startcolumns}} to start a columnar environment.<br />
* {{cmd|column}} to move to the next column.<br />
* {{cmd|setupparagraphs}} for the analogous command for side-by-side paragraphs<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
{{Columns navbox}}<br />
<br />
[[Category:Command/Columns|setupcolumns]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupcolumns&diff=26054Command/setupcolumns2020-05-22T13:29:37Z<p>LuP: /* Description */</p>
<hr />
<div>{{Reference<br />
|name=setupcolumns<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setupcolumns</syntax><br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupcolumns<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:ntop|ntop]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:rule|rule]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] – DEPRECATED - use "separator=rule" instead </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:height|height]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:tolerance|tolerance]]</td><br />
<td>[[Command/value:verystrict|verystrict]] [[Command/value:strict|strict]] [[Command/value:tolerant|tolerant]] [[Command/value:verytolerant|verytolerant]] [[Command/value:stretch|stretch]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:balance|balance]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:blank|blank]]</td><br />
<td>[[Command/value:fixed|fixed]] [[Command/value:halfline|halfline]] [[Command/value:line|line]] [[Command/value:flexible|flexible]] [[Command/value:big|big]] [[Command/value:medium|medium]] [[Command/value:small|small]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:option|option]]</td><br />
<td>[[Command/value:background|background]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:direction|direction]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setupframed|\setupframed]] </td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
Consider using paragraphs ({{cmd|defineparagraphs}} or column sets ({{cmd|startcolumnset}} instead of ‘simple’ columns.<br />
<br />
{| class="wikitable"<br />
|-<br />
| n <br />
| Number of columns. Default is n=2.<br />
|-<br />
| rule <br />
| DEPRECATED: Draw a line between the columns. Default is off.<br />
|-<br />
| separator=rule<br />
| Add vertical line between columns.<br />
|-<br />
| tolerance <br />
| Affects spacing. Narrow columns should be set tolerant, verytolerant or stretch<br />
|- <br />
| distance <br />
| Size of the gap between the columns.<br />
|- <br />
| balance <br />
| Should the columns be balanced, i.e. should they get the same number of lines?<br />
|- <br />
| align <br />
| Left, right (raggedleft, raggedright).<br />
|- <br />
| blank <br />
| Amount of whitespace between paragraphs set in columns. Also accepts a dimension as an argument. Column equivalent of {{cmd|setupwhitespace}}.<br />
|- <br />
| option <br />
| With option=background you can use everything that \setupframed offers.<br />
|- <br />
| direction <br />
| Default is right, i.e. the first column is on the left; 'left' means the first column is the rightmost.<br />
|- <br />
| height <br />
| height is unclear to me.<br />
|- <br />
| ntop <br />
| ntop contains the minimum number of lines a column should have. If, when a new set of columns starts (e.g. at the start of a page), there are 12 lines to distribute and <code>ntop=7</code>, then ConTeXt will produce one 12-line column rather than two 6-line columns. Note that <code>ntop=6</code> will result in one 7-line column and one 5-line column: ConTeXt seems to prefer that the last column be shorter, as long as its length is at least <code>ntop - n + 1</code>.<br />
|}<br />
<br />
== Example ==<br />
<context source=yes><br />
\setupcolumns[n=3,rule=on,ntop=4,background=color,backgroundcolor=green,]<br />
<br />
\startcolumns<br />
% 12 lines, please<br />
\dorecurse{12}{line\crlf}<br />
\stopcolumns<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|startcolumns}} to start a columnar environment.<br />
* {{cmd|column}} to move to the next column.<br />
* {{cmd|setupparagraphs}} for the analogous command for side-by-side paragraphs<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
{{Columns navbox}}<br />
<br />
[[Category:Command/Columns|setupcolumns]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupcolumns&diff=26053Command/setupcolumns2020-05-22T13:28:06Z<p>LuP: /* Syntax */</p>
<hr />
<div>{{Reference<br />
|name=setupcolumns<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setupcolumns</syntax><br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupcolumns<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:ntop|ntop]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:rule|rule]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] – DEPRECATED - use "separator=rule" instead </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:height|height]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:tolerance|tolerance]]</td><br />
<td>[[Command/value:verystrict|verystrict]] [[Command/value:strict|strict]] [[Command/value:tolerant|tolerant]] [[Command/value:verytolerant|verytolerant]] [[Command/value:stretch|stretch]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:balance|balance]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:blank|blank]]</td><br />
<td>[[Command/value:fixed|fixed]] [[Command/value:halfline|halfline]] [[Command/value:line|line]] [[Command/value:flexible|flexible]] [[Command/value:big|big]] [[Command/value:medium|medium]] [[Command/value:small|small]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:option|option]]</td><br />
<td>[[Command/value:background|background]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:direction|direction]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setupframed|\setupframed]] </td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
Consider using paragraphs ({{cmd|defineparagraphs}} or column sets ({{cmd|startcolumnset}} instead of ‘simple’ columns.<br />
<br />
{| class="wikitable"<br />
|-<br />
| n <br />
| Number of columns. Default is n=2.<br />
|-<br />
| rule <br />
| Draw a line between the columns. Default is off.<br />
|-<br />
| tolerance <br />
| Affects spacing. Narrow columns should be set tolerant, verytolerant or stretch<br />
|- <br />
| distance <br />
| Size of the gap between the columns.<br />
|- <br />
| balance <br />
| Should the columns be balanced, i.e. should they get the same number of lines?<br />
|- <br />
| align <br />
| Left, right (raggedleft, raggedright).<br />
|- <br />
| blank <br />
| Amount of whitespace between paragraphs set in columns. Also accepts a dimension as an argument. Column equivalent of {{cmd|setupwhitespace}}.<br />
|- <br />
| option <br />
| With option=background you can use everything that \setupframed offers.<br />
|- <br />
| direction <br />
| Default is right, i.e. the first column is on the left; 'left' means the first column is the rightmost.<br />
|- <br />
| height <br />
| height is unclear to me.<br />
|- <br />
| ntop <br />
| ntop contains the minimum number of lines a column should have. If, when a new set of columns starts (e.g. at the start of a page), there are 12 lines to distribute and <code>ntop=7</code>, then ConTeXt will produce one 12-line column rather than two 6-line columns. Note that <code>ntop=6</code> will result in one 7-line column and one 5-line column: ConTeXt seems to prefer that the last column be shorter, as long as its length is at least <code>ntop - n + 1</code>.<br />
|}<br />
<br />
== Example ==<br />
<context source=yes><br />
\setupcolumns[n=3,rule=on,ntop=4,background=color,backgroundcolor=green,]<br />
<br />
\startcolumns<br />
% 12 lines, please<br />
\dorecurse{12}{line\crlf}<br />
\stopcolumns<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|startcolumns}} to start a columnar environment.<br />
* {{cmd|column}} to move to the next column.<br />
* {{cmd|setupparagraphs}} for the analogous command for side-by-side paragraphs<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
{{Columns navbox}}<br />
<br />
[[Category:Command/Columns|setupcolumns]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Columns&diff=26051Columns2020-05-22T13:24:44Z<p>LuP: /* Columns */</p>
<hr />
<div>< [[Visuals]] | [[Layout]] ><br />
<br />
(This page is a mess. The variety of column modes is just confusing. Have a look at the [[manual:columnsets.pdf|Columnsets manual]] and the [[manual:pagecolumns.pdf|Page Columns manual]].)<br />
<br />
= Overview =<br />
<br />
There are different possibilities to typeset text in two or more columns:<br />
* columns : for simple cases of multi column text<br />
* paragraphs : if you need a table-like structure (translations, questionaires etc.)<br />
* column sets : the flexible way for varying columns or other complex tasks<br />
* page columns : new column sets implementation<br />
* streams : set different text synchronized side-by-side (e.g. bilingual editions)<br />
<br />
Columns and columnsets are different mechanisms to produce a document<br />
with two or more columns of text. <br />
* The <code>columns</code> mechanism is the older one with limited control about the placement of figures but allows you to mix one column and multicolumns text on a page. <br />
* <code>columnsets</code> are meant for magazine-like layouts with more control about the placement of figures and other features like spanned columns etc. (look at the [[Columns#Column_Sets|manual]] for more).<br />
<br />
Additionally, there’s still the old columns and columnsets code available as a module.<br />
<br />
=Columns=<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startcolumns[n=3]<br />
\input knuth<br />
\stopcolumns<br />
</context><br />
<br />
You can add all the options of {{cmd|setupcolumns}} to {{cmd|startcolumns}}. For example, simple ruled columns are easy:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startcolumns[n=2,separator=rule] % [rule=on] seems to be deprecated<br />
\input knuth<br />
\stopcolumns<br />
</context><br />
<br />
Normally, columns are automatically balanced with the text distributed over the number of requested columns. You can provoke a column switch using {{cmd|column}}.<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startcolumns[n=2]<br />
\input ward<br />
\column<br />
\input weisman<br />
\stopcolumns<br />
</context><br />
<br />
Column balancing fails in "lines" mode (e.g. for poetry).<br />
<br />
<br />
Influencing the color of the separator rule is somewhat tricky:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\setupcolors[textcolor=blue]<br />
<br />
\color[red] % rule color, but might influence also the color of other elements<br />
\startcolumns[n=3,separator=rule] % [rule=on] seems to be deprecated<br />
\input knuth<br />
\stopcolumns<br />
</context><br />
<br />
=Paragraphs=<br />
<br />
Paragraphs are useful in collecting text to be displayed together.<br />
For example:<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\defineparagraphs[TwoThird][n=2]<br />
<br />
% The width of the second paragraph is automatically calculated if unspecified.<br />
\setupparagraphs[TwoThird][1][width=.66\textwidth]<br />
<br />
\startTwoThird<br />
\quotation{...{\it why is there something rather than nothing?}<br />
For nothing is simpler and easier than something.<br />
Furthermore, assuming that things must exist,<br />
one must be able to explain<br />
{\it why they must exist thus,}<br />
and not otherwise.}<br />
\nextTwoThird<br />
G. W. Leibniz, {\it\fr Principes de la nature et de la grâce fondés en raison,} 1714.<br />
\stopTwoThird<br />
</context><br />
<br />
See "Paragraphs in Columns" section in the [http://pmrb.free.fr/contextref.pdf ConTeXt reference manual][[manual:contextref.pdf]] for further details.<br />
<br />
=(Simple)Columns in a narrow frame=<br />
To put multiple columns in a frame, this works:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\framed[width=0.9\hsize,location=middle]\bgroup<br />
\startnarrower[2*middle]<br />
\setlocalhsize \hsize\localhsize <br />
\startsimplecolumns<br />
\input tufte<br />
\stopsimplecolumns<br />
\stopnarrower<br />
\egroup<br />
</context><br />
<br />
Another possibility is to use [[TextBackground|textbackground]] around the text.<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\setupcolors[state=start]<br />
\definetextbackground [book]<br />
[state=start, topoffset=.5ex, location=paragraph,<br />
leftoffset=1ex,bottomoffset=1ex]<br />
<br />
\starttextbackground[book]<br />
Tufte again<br />
\startcolumns[n=2]<br />
\input tufte<br />
\stopcolumns<br />
\stoptextbackground<br />
</context><br />
<br />
=Column Sets=<br />
<br />
An alternative method of typesetting text into columns uses columnsets.<br />
This method offers more possibilities than simple columns,<br />
in particular in placing floats such as figures and in creating columnspans.<br />
See [[manual:columnsets.pdf|Columnsets manual]] or [[source:page-set.mkiv|column sets source]] for many examples.<br />
<br />
If you don't need much more than the "normal" columns, but e.g. "lines" mode, try this:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\definecolumnset[TwoColumns][n=2]<br />
<br />
\startcolumnset[TwoColumns]<br />
<br />
\startlines % enforce line breaks<br />
Starlight, star bright,<br />
first star I see tonight;<br />
\stoplines<br />
<br />
\column<br />
<br />
\startlines<br />
I wish I may, I wish I might<br />
have the wish I wish tonight.<br />
\stoplines<br />
<br />
\stopcolumnset<br />
</context><br />
<br />
For more details (layout grid features, spreads, different column widths etc.) please refer to the [[manual:columnsets.pdf|manual]]!<br />
<br />
==Vertical lines between columnsets (rules)==<br />
<br />
Sometimes it is required to have a vertical line between the columns of your columnset. This code draws MetaPost lines in the right place:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startuseMPgraphic{verticalrule}<br />
if CurrentColumn < NOfColumns :<br />
draw rightboundary OverlayBox shifted (4mm,0);<br />
setbounds currentpicture to OverlayBox enlarged 2.5mm;<br />
fi<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[verticalrule]<br />
[\useMPgraphic{verticalrule}]<br />
<br />
\definecolumnset[TwoColumns][n=2,background=verticalrule]<br />
<br />
\starttext<br />
\startcolumnset[TwoColumns]<br />
<br />
\startlines % enforce line breaks<br />
Starlight, star bright,<br />
first star I see tonight;<br />
\stoplines<br />
<br />
\column<br />
<br />
\startlines<br />
I wish I may, I wish I might<br />
have the wish I wish tonight.<br />
\stoplines<br />
<br />
\stopcolumnset<br />
\stoptext<br />
</context><br />
<br />
=Page Columns=<br />
<br />
Page columns are a new implementation of columnsets, intended to replace the old mechanism.<br />
[[manual:pagecolumns.pdf|Page Columns manual]]<br />
<br />
From the [[source:page-cst.mkiv|source]]:<br />
<br />
Columnsets are kind of special. They are mostly meant for special products with<br />
magazine like properties. They are normally not mixed with single column layouts<br />
and not all features of ConTeXt might cooperate well with a mechanism like<br />
this. We use the name page grid because (as with other reimplementations of<br />
MkII features in MkIV, we need another namespace in order to migrate stepwise.<br />
This implementation is not neccessarily better than the previous one but it might<br />
be easier to extend it. It should be a bit more efficient.<br />
<br />
=Streams=<br />
<br />
From the [[http://archive.contextgarden.net/message/20060331.175831.414d087b.en.html announcement mail]] by Thomas Schmitz:<br />
<br />
We have streams for even and odd pages that can be synchronized at certain points. <br />
This is useful for, e.g., typesetting bilingual books: have the original on the even pages, the translation on the odd pages, and synchronize at certain points.<br />
<br />
Hans later re-implemented that mechanism in the core. For details see [[source:page-str.mkiv|the source]].<br />
<br />
The module provides a rather low-level interface. Hans suggested some handy shortcuts:<br />
<texcode><br />
\usemodule[streams] <br />
<br />
\def\StartCouple{\page\SwitchToNormal} <br />
\def\StopCouple {\SwitchToNormal \SynchronizeLeftAndRight \FlushLeftAndRight} <br />
\def\Original {\SwitchToNormal\SynchronizeLeftAndRight\SwitchToLeft} <br />
\def\Translation{\SwitchToRight} <br />
<br />
\StartCouple<br />
\Original\en<br />
Are you sleeping, brother John?<br />
<br />
\Translation\de<br />
Bruder Jakob, schläfst du noch?<br />
\StopCouple<br />
</texcode><br />
<br />
So you put the part of your document where synchronization should take place between <cmd>StartCouple</cmd> and <cmd>StopCouple</cmd>. After that , <cmd>Original</cmd> and <cmd>Translation</cmd> switches between even and odd pages. <br />
<br />
Beware, streams don’t work in columns and not very good in columnsets.<br />
<br />
==Examples of MkIV streams==<br />
<br />
(copied from the source)<br />
<br />
<texcode><br />
\enabletrackers[streams.flushing]<br />
<br />
\setuplayout[grid=yes] \showgrid<br />
<br />
\starttext<br />
<br />
\input tufte<br />
<br />
\startoutputstream[nl]<br />
<br />
Wat doen we hier?<br />
<br />
\enableoutputstream[en]<br />
<br />
Are you sleeping, brother John?\footnote{xxx}<br />
<br />
\dorecurse{4}{x \footnote{note \recurselevel}\input tufte \par \pushoutputstream}<br />
<br />
\enableoutputstream[de]<br />
<br />
Bruder Jakob, schläfst du noch?\footnote{yyy}<br />
<br />
\dorecurse{4}{x \footnote{note \recurselevel}\input ward \par \pushoutputstream}<br />
<br />
\disableoutputstream<br />
<br />
\stopoutputstream<br />
<br />
Vader Jacob, slaap je nog?\footnote{zzz}<br />
<br />
\input tufte<br />
<br />
\synchronizestreams[en,de,nl]<br />
<br />
\page \flushoutputstream[en] \input knuth<br />
\page \flushoutputstream[de] \input knuth<br />
\page \flushoutputstream[nl] \input knuth<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Posting by Wolfgang to the mailing list (2016-11-27):<br />
<br />
<texcode><br />
\starttext<br />
<br />
\startoutputstream[one]<br />
\setupalign[flushleft]<br />
\dorecurse{3}{Line \recurselevel\par}\pushoutputstream<br />
\blank<br />
\dorecurse{6}{Line \recurselevel\par}\pushoutputstream<br />
\blank<br />
\dorecurse{4}{Line \recurselevel\par}\pushoutputstream<br />
\stopoutputstream<br />
<br />
\startoutputstream[two]<br />
\setupalign[flushright]<br />
\dorecurse{5}{Line \recurselevel\par}\pushoutputstream<br />
\blank<br />
\dorecurse{2}{Line \recurselevel\par}\pushoutputstream<br />
\blank<br />
\dorecurse{7}{Line \recurselevel\par}\pushoutputstream<br />
\stopoutputstream<br />
<br />
\synchronizestreams[one,two]<br />
<br />
\startoverlay<br />
{\outputstreambox[one]}<br />
{\raise2\strutdp\outputstreambox[two]}<br />
\stopoverlay<br />
<br />
\stoptext<br />
</texcode><br />
<br />
(Wolfgang continued:)<br />
<br />
The mechanism to create pages/columns for the stream content is<br />
missing.<br />
You can save text and flush it afterwards but there is no command which<br />
places the content side by side (or in columns). Below is a simple example<br />
but I had to write the splitter myself.<br />
<br />
<texcode><br />
\starttext<br />
<br />
\startoutputstream[one]<br />
\startcolor[red]<br />
\dorecurse{10}{\input knuth\par}<br />
\stopcolor<br />
\stopoutputstream<br />
<br />
\startoutputstream[two]<br />
\startcolor[green]<br />
\dorecurse{10}{\input zapf\par}<br />
\stopcolor<br />
\stopoutputstream<br />
<br />
\synchronizestreams[one,two]<br />
<br />
\setbox\scratchboxone\outputstreambox[one]<br />
\setbox\scratchboxtwo\outputstreambox[two]<br />
<br />
\doloop<br />
{\ifvoid\scratchboxone<br />
\exitloop<br />
\else<br />
\setbox\scratchboxfour\vsplit\scratchboxone to \textheight<br />
\vbox to \vsize{\box\scratchboxfour\vss}%<br />
\setbox\scratchboxfive\vsplit\scratchboxtwo to \textheight<br />
\vbox to \vsize{\box\scratchboxfive\vss}%<br />
\fi}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
{{todo|We need documentation and samples for Paragraphs, Streams and Column Sets}}<br />
<br />
=Floats and other limitations of columns=<br />
<br />
Columns and one-column floats don’t work well together in TeX. It seems that you can't have a float that spans one column automatically put at the top or the bottom and have the columns balanced automatically at the end. Neither ConTeXt nor LaTeX can do it in a automatized way (like with floats that span more than a column). Here you have some tricks to make it work more or less:<br />
<br />
==Columnsets==<br />
<br />
With columnsets you can put floats that span one, two or any number of columns and in any position (top, bottom, middle of the text). The price for this is that you have to balance the columns manually at the end (see [[manual:columnsets.pdf|Columnset manual]]).<br />
<br />
Columnsets have a limitation, however: they are very strongly grid-based, and you can't change the interlinespace within the columnset (e.g., if some paragraphs are typed in a smaller font). You can change the interlinespace if the entire text with a smaller interlinespace fits in one column, like a float or a section title (putting it between <code>\startlinecorrection\stoplinecorrection</code>), but if the text with a smaller interlinespace starts in one column and has to continue in the following one, nothing will work, and the layout will be completely messed.<br />
<br />
Changing the font weight or shape inbetween <cmd>startcolumnset</cmd> and <cmd>stopcolumnset</cmd> may cause some columns to be shifted vertically. Then you must use <cmd>restoreinterlinespace</cmd> after the font switch (<cmd>bf</cmd>, <cmd>ss</cmd>) to correct the interline spacing. See [http://thread.gmane.org/gmane.comp.tex.context/20932].<br />
<br />
So, if you want columns and one-column floats and don’t have to change the interlinespacing, use Columnsets. If not, you can use Columns with some tricks.<br />
<br />
==Columns and Floats ==<br />
<br />
With Columns you have the columns automatically balanced at the end, but only certain floats are "officially" supported:<br />
<br />
* '''Floats that span more than a column at the top of the following page'''<br />
* '''Floats that span one column in the middle of the text, accidentally at the top of the following page'''<br />
<br />
Here, the optional argument <code>placefloat[here, top, bottom, etc.]</code> does nothing. When you place a float, if its width is larger than the column width (<code>\textwidth</code>), that float will be automatically put at the top of the following page, spanning the columns needed. If its width is shorter than the column width, the float will be put in the middle of the text, spanning one column. If there is not enough space left in the column, it will float until the top of the following column. You can use this method to put floats at the top of a column, but it's not recommended, because it is tedious and if you change the text before the float, you will probably find it then in the middle of the column.<br />
<br />
There is a semi-automatic way to put:<br />
<br />
* '''Floats that span one column at the top of the left column of a page'''<br />
* '''Any float in a separated page, without text'''<br />
<br />
with the possibility of changing the text and having the float always correctly put, like with "officially" supported floats, using <code>\startpostponing\stoppostponing</code>. Everything that goes into this environment will be put at the beginning of the next page, or in the page indicated in the optional argument (e.g., <code>\startpostponing[34]</code>; see [[Latex_Packages#afterpage|this wiki entry]]). If we write<br />
<br />
<texcode><br />
\startpostponing[35]<br />
\vbox{\vskip-\baselineskip<br />
\placefigure{caption}{\externalfigure[file][width=\textwidth]}<br />
}<br />
\stoppostponing<br />
</texcode><br />
<br />
the figure will be put at the top of the first column at page 35, or four pages further on, if we put [+4], or on the following page, with no optional argument. The figure has to be enclosed in a box, or the grid will be broken. Putting the figure in a box lowers it a line (why?), so it has to be corrected with the <code>\vskip-\baselineskip</code>.<br />
<br />
You can put more than a float in the same column, but they have to be into the same box, or the grid will be broken<br />
<br />
<texcode><br />
\startpostponing<br />
\vbox{\vskip-\baselineskip<br />
\placefigure{caption}{\externalfigure[file][width=\textwidth]}<br />
\placefigure{caption2}{\externalfigure[file2][width=\textwidth]}<br />
}<br />
\stoppostponing<br />
</texcode><br />
<br />
With this method you can put a float in a separated page, without any text<br />
<br />
<texcode><br />
\startpostponing[+5]<br />
\vbox{<br />
\placefigure{caption}{\externalfigure[file][width=\makeupwidth]}<br />
}<br />
\page<br />
\stoppostponing<br />
</texcode><br />
<br />
And you can use it to put a float that span more than a column in a page other than the one chosen by the algorithm (without <code>\vbox</code>):<br />
<br />
<texcode><br />
\startpostponing[67]<br />
\placefigure{caption}{\externalfigure[file][width=\makeupwidth]}<br />
\stoppostponing<br />
</texcode><br />
<br />
This has some limitations, too. If you put a float at the top of a column and there is another float that spans more than a column over all, the grid will be broken, so you have to put it in another page, but you can put more than one float of the same type together, as seen above.<br />
<br />
{{Columns navbox}}</div>LuPhttps://wiki.contextgarden.net/index.php?title=Columns&diff=26050Columns2020-05-22T13:23:23Z<p>LuP: /* Columns */</p>
<hr />
<div>< [[Visuals]] | [[Layout]] ><br />
<br />
(This page is a mess. The variety of column modes is just confusing. Have a look at the [[manual:columnsets.pdf|Columnsets manual]] and the [[manual:pagecolumns.pdf|Page Columns manual]].)<br />
<br />
= Overview =<br />
<br />
There are different possibilities to typeset text in two or more columns:<br />
* columns : for simple cases of multi column text<br />
* paragraphs : if you need a table-like structure (translations, questionaires etc.)<br />
* column sets : the flexible way for varying columns or other complex tasks<br />
* page columns : new column sets implementation<br />
* streams : set different text synchronized side-by-side (e.g. bilingual editions)<br />
<br />
Columns and columnsets are different mechanisms to produce a document<br />
with two or more columns of text. <br />
* The <code>columns</code> mechanism is the older one with limited control about the placement of figures but allows you to mix one column and multicolumns text on a page. <br />
* <code>columnsets</code> are meant for magazine-like layouts with more control about the placement of figures and other features like spanned columns etc. (look at the [[Columns#Column_Sets|manual]] for more).<br />
<br />
Additionally, there’s still the old columns and columnsets code available as a module.<br />
<br />
=Columns=<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startcolumns[n=3]<br />
\input knuth<br />
\stopcolumns<br />
</context><br />
<br />
You can add all the options of {{cmd|setupcolumns}} to {{cmd|startcolumns}}. For example, simple ruled columns are easy:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startcolumns[n=2,separator=rule] % [rule=on] seems to be deprecated<br />
\input knuth<br />
\stopcolumns<br />
</context><br />
<br />
Normally, columns are automatically balanced with the text distributed over the number of requested columns. You can provoke a column switch using {{cmd|column}}.<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startcolumns[n=2]<br />
\input ward<br />
\column<br />
\input weisman<br />
\stopcolumns<br />
</context><br />
<br />
Column balancing fails in "lines" mode (e.g. for poetry).<br />
<br />
<br />
Influencing the color of the separator rule is somewhat tricky:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\setupcolors[textcolor=blue]<br />
<br />
\color[red] % rule color, but might influence also the color of other elements<br />
\startcolumns[n=3,rule=on]<br />
\input knuth<br />
\stopcolumns<br />
</context><br />
<br />
=Paragraphs=<br />
<br />
Paragraphs are useful in collecting text to be displayed together.<br />
For example:<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\defineparagraphs[TwoThird][n=2]<br />
<br />
% The width of the second paragraph is automatically calculated if unspecified.<br />
\setupparagraphs[TwoThird][1][width=.66\textwidth]<br />
<br />
\startTwoThird<br />
\quotation{...{\it why is there something rather than nothing?}<br />
For nothing is simpler and easier than something.<br />
Furthermore, assuming that things must exist,<br />
one must be able to explain<br />
{\it why they must exist thus,}<br />
and not otherwise.}<br />
\nextTwoThird<br />
G. W. Leibniz, {\it\fr Principes de la nature et de la grâce fondés en raison,} 1714.<br />
\stopTwoThird<br />
</context><br />
<br />
See "Paragraphs in Columns" section in the [http://pmrb.free.fr/contextref.pdf ConTeXt reference manual][[manual:contextref.pdf]] for further details.<br />
<br />
=(Simple)Columns in a narrow frame=<br />
To put multiple columns in a frame, this works:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\framed[width=0.9\hsize,location=middle]\bgroup<br />
\startnarrower[2*middle]<br />
\setlocalhsize \hsize\localhsize <br />
\startsimplecolumns<br />
\input tufte<br />
\stopsimplecolumns<br />
\stopnarrower<br />
\egroup<br />
</context><br />
<br />
Another possibility is to use [[TextBackground|textbackground]] around the text.<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\setupcolors[state=start]<br />
\definetextbackground [book]<br />
[state=start, topoffset=.5ex, location=paragraph,<br />
leftoffset=1ex,bottomoffset=1ex]<br />
<br />
\starttextbackground[book]<br />
Tufte again<br />
\startcolumns[n=2]<br />
\input tufte<br />
\stopcolumns<br />
\stoptextbackground<br />
</context><br />
<br />
=Column Sets=<br />
<br />
An alternative method of typesetting text into columns uses columnsets.<br />
This method offers more possibilities than simple columns,<br />
in particular in placing floats such as figures and in creating columnspans.<br />
See [[manual:columnsets.pdf|Columnsets manual]] or [[source:page-set.mkiv|column sets source]] for many examples.<br />
<br />
If you don't need much more than the "normal" columns, but e.g. "lines" mode, try this:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\definecolumnset[TwoColumns][n=2]<br />
<br />
\startcolumnset[TwoColumns]<br />
<br />
\startlines % enforce line breaks<br />
Starlight, star bright,<br />
first star I see tonight;<br />
\stoplines<br />
<br />
\column<br />
<br />
\startlines<br />
I wish I may, I wish I might<br />
have the wish I wish tonight.<br />
\stoplines<br />
<br />
\stopcolumnset<br />
</context><br />
<br />
For more details (layout grid features, spreads, different column widths etc.) please refer to the [[manual:columnsets.pdf|manual]]!<br />
<br />
==Vertical lines between columnsets (rules)==<br />
<br />
Sometimes it is required to have a vertical line between the columns of your columnset. This code draws MetaPost lines in the right place:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startuseMPgraphic{verticalrule}<br />
if CurrentColumn < NOfColumns :<br />
draw rightboundary OverlayBox shifted (4mm,0);<br />
setbounds currentpicture to OverlayBox enlarged 2.5mm;<br />
fi<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[verticalrule]<br />
[\useMPgraphic{verticalrule}]<br />
<br />
\definecolumnset[TwoColumns][n=2,background=verticalrule]<br />
<br />
\starttext<br />
\startcolumnset[TwoColumns]<br />
<br />
\startlines % enforce line breaks<br />
Starlight, star bright,<br />
first star I see tonight;<br />
\stoplines<br />
<br />
\column<br />
<br />
\startlines<br />
I wish I may, I wish I might<br />
have the wish I wish tonight.<br />
\stoplines<br />
<br />
\stopcolumnset<br />
\stoptext<br />
</context><br />
<br />
=Page Columns=<br />
<br />
Page columns are a new implementation of columnsets, intended to replace the old mechanism.<br />
[[manual:pagecolumns.pdf|Page Columns manual]]<br />
<br />
From the [[source:page-cst.mkiv|source]]:<br />
<br />
Columnsets are kind of special. They are mostly meant for special products with<br />
magazine like properties. They are normally not mixed with single column layouts<br />
and not all features of ConTeXt might cooperate well with a mechanism like<br />
this. We use the name page grid because (as with other reimplementations of<br />
MkII features in MkIV, we need another namespace in order to migrate stepwise.<br />
This implementation is not neccessarily better than the previous one but it might<br />
be easier to extend it. It should be a bit more efficient.<br />
<br />
=Streams=<br />
<br />
From the [[http://archive.contextgarden.net/message/20060331.175831.414d087b.en.html announcement mail]] by Thomas Schmitz:<br />
<br />
We have streams for even and odd pages that can be synchronized at certain points. <br />
This is useful for, e.g., typesetting bilingual books: have the original on the even pages, the translation on the odd pages, and synchronize at certain points.<br />
<br />
Hans later re-implemented that mechanism in the core. For details see [[source:page-str.mkiv|the source]].<br />
<br />
The module provides a rather low-level interface. Hans suggested some handy shortcuts:<br />
<texcode><br />
\usemodule[streams] <br />
<br />
\def\StartCouple{\page\SwitchToNormal} <br />
\def\StopCouple {\SwitchToNormal \SynchronizeLeftAndRight \FlushLeftAndRight} <br />
\def\Original {\SwitchToNormal\SynchronizeLeftAndRight\SwitchToLeft} <br />
\def\Translation{\SwitchToRight} <br />
<br />
\StartCouple<br />
\Original\en<br />
Are you sleeping, brother John?<br />
<br />
\Translation\de<br />
Bruder Jakob, schläfst du noch?<br />
\StopCouple<br />
</texcode><br />
<br />
So you put the part of your document where synchronization should take place between <cmd>StartCouple</cmd> and <cmd>StopCouple</cmd>. After that , <cmd>Original</cmd> and <cmd>Translation</cmd> switches between even and odd pages. <br />
<br />
Beware, streams don’t work in columns and not very good in columnsets.<br />
<br />
==Examples of MkIV streams==<br />
<br />
(copied from the source)<br />
<br />
<texcode><br />
\enabletrackers[streams.flushing]<br />
<br />
\setuplayout[grid=yes] \showgrid<br />
<br />
\starttext<br />
<br />
\input tufte<br />
<br />
\startoutputstream[nl]<br />
<br />
Wat doen we hier?<br />
<br />
\enableoutputstream[en]<br />
<br />
Are you sleeping, brother John?\footnote{xxx}<br />
<br />
\dorecurse{4}{x \footnote{note \recurselevel}\input tufte \par \pushoutputstream}<br />
<br />
\enableoutputstream[de]<br />
<br />
Bruder Jakob, schläfst du noch?\footnote{yyy}<br />
<br />
\dorecurse{4}{x \footnote{note \recurselevel}\input ward \par \pushoutputstream}<br />
<br />
\disableoutputstream<br />
<br />
\stopoutputstream<br />
<br />
Vader Jacob, slaap je nog?\footnote{zzz}<br />
<br />
\input tufte<br />
<br />
\synchronizestreams[en,de,nl]<br />
<br />
\page \flushoutputstream[en] \input knuth<br />
\page \flushoutputstream[de] \input knuth<br />
\page \flushoutputstream[nl] \input knuth<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Posting by Wolfgang to the mailing list (2016-11-27):<br />
<br />
<texcode><br />
\starttext<br />
<br />
\startoutputstream[one]<br />
\setupalign[flushleft]<br />
\dorecurse{3}{Line \recurselevel\par}\pushoutputstream<br />
\blank<br />
\dorecurse{6}{Line \recurselevel\par}\pushoutputstream<br />
\blank<br />
\dorecurse{4}{Line \recurselevel\par}\pushoutputstream<br />
\stopoutputstream<br />
<br />
\startoutputstream[two]<br />
\setupalign[flushright]<br />
\dorecurse{5}{Line \recurselevel\par}\pushoutputstream<br />
\blank<br />
\dorecurse{2}{Line \recurselevel\par}\pushoutputstream<br />
\blank<br />
\dorecurse{7}{Line \recurselevel\par}\pushoutputstream<br />
\stopoutputstream<br />
<br />
\synchronizestreams[one,two]<br />
<br />
\startoverlay<br />
{\outputstreambox[one]}<br />
{\raise2\strutdp\outputstreambox[two]}<br />
\stopoverlay<br />
<br />
\stoptext<br />
</texcode><br />
<br />
(Wolfgang continued:)<br />
<br />
The mechanism to create pages/columns for the stream content is<br />
missing.<br />
You can save text and flush it afterwards but there is no command which<br />
places the content side by side (or in columns). Below is a simple example<br />
but I had to write the splitter myself.<br />
<br />
<texcode><br />
\starttext<br />
<br />
\startoutputstream[one]<br />
\startcolor[red]<br />
\dorecurse{10}{\input knuth\par}<br />
\stopcolor<br />
\stopoutputstream<br />
<br />
\startoutputstream[two]<br />
\startcolor[green]<br />
\dorecurse{10}{\input zapf\par}<br />
\stopcolor<br />
\stopoutputstream<br />
<br />
\synchronizestreams[one,two]<br />
<br />
\setbox\scratchboxone\outputstreambox[one]<br />
\setbox\scratchboxtwo\outputstreambox[two]<br />
<br />
\doloop<br />
{\ifvoid\scratchboxone<br />
\exitloop<br />
\else<br />
\setbox\scratchboxfour\vsplit\scratchboxone to \textheight<br />
\vbox to \vsize{\box\scratchboxfour\vss}%<br />
\setbox\scratchboxfive\vsplit\scratchboxtwo to \textheight<br />
\vbox to \vsize{\box\scratchboxfive\vss}%<br />
\fi}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
{{todo|We need documentation and samples for Paragraphs, Streams and Column Sets}}<br />
<br />
=Floats and other limitations of columns=<br />
<br />
Columns and one-column floats don’t work well together in TeX. It seems that you can't have a float that spans one column automatically put at the top or the bottom and have the columns balanced automatically at the end. Neither ConTeXt nor LaTeX can do it in a automatized way (like with floats that span more than a column). Here you have some tricks to make it work more or less:<br />
<br />
==Columnsets==<br />
<br />
With columnsets you can put floats that span one, two or any number of columns and in any position (top, bottom, middle of the text). The price for this is that you have to balance the columns manually at the end (see [[manual:columnsets.pdf|Columnset manual]]).<br />
<br />
Columnsets have a limitation, however: they are very strongly grid-based, and you can't change the interlinespace within the columnset (e.g., if some paragraphs are typed in a smaller font). You can change the interlinespace if the entire text with a smaller interlinespace fits in one column, like a float or a section title (putting it between <code>\startlinecorrection\stoplinecorrection</code>), but if the text with a smaller interlinespace starts in one column and has to continue in the following one, nothing will work, and the layout will be completely messed.<br />
<br />
Changing the font weight or shape inbetween <cmd>startcolumnset</cmd> and <cmd>stopcolumnset</cmd> may cause some columns to be shifted vertically. Then you must use <cmd>restoreinterlinespace</cmd> after the font switch (<cmd>bf</cmd>, <cmd>ss</cmd>) to correct the interline spacing. See [http://thread.gmane.org/gmane.comp.tex.context/20932].<br />
<br />
So, if you want columns and one-column floats and don’t have to change the interlinespacing, use Columnsets. If not, you can use Columns with some tricks.<br />
<br />
==Columns and Floats ==<br />
<br />
With Columns you have the columns automatically balanced at the end, but only certain floats are "officially" supported:<br />
<br />
* '''Floats that span more than a column at the top of the following page'''<br />
* '''Floats that span one column in the middle of the text, accidentally at the top of the following page'''<br />
<br />
Here, the optional argument <code>placefloat[here, top, bottom, etc.]</code> does nothing. When you place a float, if its width is larger than the column width (<code>\textwidth</code>), that float will be automatically put at the top of the following page, spanning the columns needed. If its width is shorter than the column width, the float will be put in the middle of the text, spanning one column. If there is not enough space left in the column, it will float until the top of the following column. You can use this method to put floats at the top of a column, but it's not recommended, because it is tedious and if you change the text before the float, you will probably find it then in the middle of the column.<br />
<br />
There is a semi-automatic way to put:<br />
<br />
* '''Floats that span one column at the top of the left column of a page'''<br />
* '''Any float in a separated page, without text'''<br />
<br />
with the possibility of changing the text and having the float always correctly put, like with "officially" supported floats, using <code>\startpostponing\stoppostponing</code>. Everything that goes into this environment will be put at the beginning of the next page, or in the page indicated in the optional argument (e.g., <code>\startpostponing[34]</code>; see [[Latex_Packages#afterpage|this wiki entry]]). If we write<br />
<br />
<texcode><br />
\startpostponing[35]<br />
\vbox{\vskip-\baselineskip<br />
\placefigure{caption}{\externalfigure[file][width=\textwidth]}<br />
}<br />
\stoppostponing<br />
</texcode><br />
<br />
the figure will be put at the top of the first column at page 35, or four pages further on, if we put [+4], or on the following page, with no optional argument. The figure has to be enclosed in a box, or the grid will be broken. Putting the figure in a box lowers it a line (why?), so it has to be corrected with the <code>\vskip-\baselineskip</code>.<br />
<br />
You can put more than a float in the same column, but they have to be into the same box, or the grid will be broken<br />
<br />
<texcode><br />
\startpostponing<br />
\vbox{\vskip-\baselineskip<br />
\placefigure{caption}{\externalfigure[file][width=\textwidth]}<br />
\placefigure{caption2}{\externalfigure[file2][width=\textwidth]}<br />
}<br />
\stoppostponing<br />
</texcode><br />
<br />
With this method you can put a float in a separated page, without any text<br />
<br />
<texcode><br />
\startpostponing[+5]<br />
\vbox{<br />
\placefigure{caption}{\externalfigure[file][width=\makeupwidth]}<br />
}<br />
\page<br />
\stoppostponing<br />
</texcode><br />
<br />
And you can use it to put a float that span more than a column in a page other than the one chosen by the algorithm (without <code>\vbox</code>):<br />
<br />
<texcode><br />
\startpostponing[67]<br />
\placefigure{caption}{\externalfigure[file][width=\makeupwidth]}<br />
\stoppostponing<br />
</texcode><br />
<br />
This has some limitations, too. If you put a float at the top of a column and there is another float that spans more than a column over all, the grid will be broken, so you have to put it in another page, but you can put more than one float of the same type together, as seen above.<br />
<br />
{{Columns navbox}}</div>LuPhttps://wiki.contextgarden.net/index.php?title=Modes&diff=25747Modes2020-04-08T09:05:17Z<p>LuP: </p>
<hr />
<div>< [[The ConTeXt Way]] | [[Inside ConTeXt]] | [[Project structure]] ><br />
<br />
Very often, you want to generate multiple versions of the same document:<br />
one version for printing and one for viewing on the screen, one version for<br />
students and one version for the instructor, and so on. You can do this in a<br />
simple but naive way: create different files set up for the different versions and<br />
<code>\input</code> the common material, or create some new conditional flags using<br />
<code>\newif</code> and set them appropriately for conditional processing. Or you<br />
could use <em>modes</em>&mdash;the ConTeXt way of doing conditional processing.<br />
<br />
= Introduction =<br />
<br />
A mode is similar to a conditional flag, but with a few advantages: new modes<br />
need not be explicitly defined (no need for something like <code>\newif</code>),<br />
multiple modes can be simultaneously enabled or disabled, and the status of multiple<br />
modes can be checked easily. Moreover, modes can be set from a command line<br />
switch. As a result, multiple versions of a document can be generated without changing<br />
the source file.<br />
<br />
The name or identifier of a mode can be any combination of letters, digits, or<br />
spaces. Names starting with <code>*</code> are reserved for system modes. <br />
<br />
In this article I explain how to activate a mode and how to check if a mode is<br />
active or not. <br />
<br />
= Setting modes =<br />
<br />
ConTeXt has three commands for setting modes:<br />
<br />
* <code>{{cmd|enablemode }}[...]</code><br />
* <code>{{cmd|disablemode}}[...]</code><br />
* <code>{{cmd|preventmode}}[...]</code><br />
<br />
The names are self-descriptive. {{cmd|enablemode}} activates a mode,<br />
{{cmd|disablemode}} deactivates a mode, and {{cmd|preventmode}} permanently<br />
deactivates a mode. All three commands take a list of modes as an argument. For<br />
example, you can activate modes named <code>screen</code> and <code>solution</code> with<br />
<texcode><br />
\enablemode[screen,solution]<br />
</texcode><br />
<br />
Modes can also be activated by a command line switch <code>--modes</code> to<br />
<code>texexec</code> or <code>context</code>. For example, another way to activate the <code>screen</code> and<br />
<code>solution</code> modes, to run ConTeXt using one of:<br />
<br />
texexec --mode=screen,solution ...<br />
context --mode=screen,solution ...<br />
<br />
== Pre-defining modes ==<br />
<br />
Normally, the overhead for testing modes is negligible, but it can add up if modes are tested multiple times in a document (for example, as part of a macro). In such cases, you can ''define'' a mode before using them, to speed up the processing. Modes are defined using:<br />
<br />
<texcode><br />
\definemode[...][...]<br />
</texcode><br />
<br />
The first argument is a list of modes; the second argument may be `yes`, `no`, or `keep`. For example,<br />
<br />
* <code>\definemode[screen][yes]</code> defines a mode and enables it; <br />
* <code>\definemode[screen][no]</code> defines a mode and disables it; <br />
* <code>\definemode[screen][keep]</code> defines a mode and keeps its previous status.<br />
<br />
Typically, it is better to use <code>\definemode[...][keep]</code> so that the modes may be enabled or disabled from command line as well.<br />
<br />
= Conditional processing based on modes =<br />
<br />
You may want to process or ignore a chunk of code if a particular mode is enabled<br />
or disabled. Such a chunk of code is specified using <code>\startmode</code> and<br />
<code>\startnotmode</code> environments. Their use is best explained by an example.<br />
<br />
Suppose you want to change the paper size of a document depending on whether it<br />
is for print or screen. This can be done in multiple ways. You could set<br />
the default paper size for print and change it in screen mode:<br />
<texcode><br />
\setuppapersize[letter][letter]<br />
\startmode[screen]<br />
\setuppapersize[S6][S6]<br />
\stopmode<br />
</texcode><br />
(S6 is one of the screen-optimized paper sizes in ConTeXt; the paper size has a<br />
4:3 aspect ratio and a width equal to the width of A4 paper.)<br />
<br />
Alternatively, you<br />
could set a default paper size for the screen and change it if screen mode is<br />
not enabled:<br />
<texcode><br />
\setuppapersize[S6][S6]<br />
\startnotmode[screen]<br />
\setuppapersize[letter][letter]<br />
\stopnotmode<br />
</texcode><br />
<br />
<code>\startmode</code> (and <code>\startnotmode</code>) checks the value of the mode '''at the time it is executed'''. This is important when you are setting the modes using <code>\enablemode</code> or <code>\disablemode</code>. For example,<br />
<texcode><br />
\enablemode[foo]<br />
\startmode[foo]<br />
...<br />
\stopmode<br />
</texcode><br />
the contents of the mode environment are executed because <code>foo</code> is enabled when <code>\startmode</code> is encountered. However, in<br />
<texcode><br />
\startmode[foo]<br />
...<br />
\stopmode<br />
\enablemode[foo]<br />
</texcode><br />
the contents of the mode environment are not execited because <code>foo</code> is not enabled when <code>\startmode</code> is encountered. <br />
<br />
<br />
== Checking for multiple modes (<code>or</code>/<code>and</code> statements for modes) ==<br />
<code>\startmode</code> and <code>\startnotmode</code> can check for multiple modes,<br />
by giving a list of modes as their arguments. <code>\startmode</code><br />
processes its contents (everything until the next<br />
<code>\stopmode</code>, thus <code>\startmode</code> cannot be<br />
nested.) if any of the modes are enabled, otherwise (i.e., when all<br />
the modes are disabled) <code>\startmode</code> ignores its<br />
contents. The opposite is <code>\startnotmode</code>: it processes its<br />
contents (everything until the next <code>\stopnotmode</code>) if any of the<br />
modes are disabled, otherwise&mdash;when all the modes are enabled&mdash;the contents are ignored.<br />
<br />
<code>\startmode</code> and <code>\startnotmode</code> are "<em>or</em>" environments. They<br />
process their contents if any of the modes satisfy the required condition. Their<br />
"<em>and</em>" counterparts are also available: <code>\startallmodes</code> and <code>\startnotallmodes</code><br />
process their contents only if all the given modes satisfy the required<br />
condition. For example, suppose you want to enable interaction (e.g., hyperlinks)<br />
only when both <code>screen</code> and <code>solution</code> modes are enabled. Then you can<br />
use:<br />
<texcode><br />
\startallmodes[screen,solution]<br />
\setupinteraction[state=start]<br />
\stopallmodes<br />
</texcode><br />
<br />
To summarize, the four start-stop environments for checking modes are:<br />
<texcode><br />
\startmode[mode1, mode2, ...]<br />
% Processed if any of the modes is enabled<br />
\stopmode<br />
<br />
\startnotmode[mode1, mode2, ...]<br />
% Processed if any of the modes is disabled<br />
\stopnotmode<br />
<br />
\startallmodes[mode1, mode2, ...]<br />
% Processed if all the modes are enabled<br />
\stopallmodes<br />
<br />
\startnotallmodes[mode1, mode2, ...]<br />
% Processed if all the modes are disabled<br />
\stopnotallmodes<br />
</texcode><br />
<br />
These environments have <code>\doif...</code> alternatives that are useful for short<br />
setups. Also, they can be nested.<br />
<br />
<texcode><br />
\doifmode {mode1, mode2, ...} {Processed if any mode is enabled}<br />
\doifnotmode {mode1, mode2, ...} {Processed if any mode is disabled}<br />
\doifallmodes {mode1, mode2, ...} {Processed if all modes are enabled}<br />
\doifnotallmodes {mode1, mode2, ...} {Processed if all modes are disabled}<br />
</texcode><br />
The logic for determining when the content is processed is exactly the same as<br />
for the <code>start</code>-<code>stop</code> commands.<br />
<br />
These <code>\doif</code> commands each have a variant to process alternative code if<br />
the conditions are not satisfied (like the <code>\else</code> branch of <code>\if</code>).<br />
<texcode><br />
\doifmodeelse {mode1, mode2, ...} {Processed if any mode is enabled} {else this is processed} <br />
\doifallmodeselse {mode1, mode2, ...} {Processed if all modes are enabled} {else this is processed} <br />
\doifnotallmodeselse {mode1, mode2, ...} {Processed if all modes are disabled} {else this is processed}<br />
</texcode><br />
<br />
Note that there is no command <code>\doifnotmodeelse</code> because there is no need for it; <code>\doifmodeelse</code> may be used for the same effect (with the <code>if</code> and <code>else</code> branches switched).<br />
<br />
== Checking multiple modes in parallel (<code>case</code> statement for modes) ==<br />
<br />
In addition to the above <em>"or"</em> and <em>"and"</em> environment which check modes is sequence, you can also check multiple modes in parallel. The syntax for such a <em>"case"</em> environment is as follows:<br />
<br />
<texcode><br />
\startmodeset<br />
[mode1, mode2, ...] {Processed if either mode is enabled}<br />
% NOTE: Empty lines are not allowed here!<br />
[mode3, mode4, ...] {Processed if either mode is enabled}<br />
[default] {Processed if none of the above modes match}<br />
\stopmodeset<br />
</texcode><br />
<br />
The same mode can be referenced multiple times, and '''all''' matching branches are executed. <br />
The {{cmd|startmodeset}} ... {{cmd|stopmodeset}} environments can be nested. So, you can use <br />
<br />
<texcode><br />
\startmodeset<br />
[mode1, mode2] {<br />
Processed when either mode1 or mode2 is enabled<br />
} <br />
[mode3] {<br />
\startmodeset<br />
[mode1] {Processed when mode1 and mode3 are enabled}<br />
[mode2] {Processed when mode2 and mode3 are enabled}<br />
[default] {Processed when mode3 is enabled and mode1 and mode2 are disabled}<br />
\stopmodeset<br />
}<br />
[default] {<br />
Processed when mode1, mode2, and mode3 are disabled.:<br />
}<br />
\stopmodeset<br />
</texcode><br />
<br />
== Checking modes in Lua ==<br />
<br />
In MkIV, the state of any mode is accessible at the Lua end as <code>tex.modes</code> table. Specifically,<br />
<br />
<texcode><br />
tex.modes["screen"]<br />
</texcode><br />
<br />
returns <code>true</code> if mode <code>screen</code> is enabled and <code>false</code> otherwise. Thus, specific combinations of modes can be checked using boolean expressions. For example<br />
<texcode><br />
if (tex.modes["mode1"] and tex.modes["mode2"]) then<br />
...<br />
end<br />
</texcode><br />
checks if both <code>mode1</code> and <code>mode2</code> are enabled.<br />
<br />
<br />
= System modes =<br />
<br />
Besides allowing user-definable modes, ConTeXt provides some system<br />
modes. These modes start with a <code>*</code> character. Here <br />
only the more commonly used system modes are explained; see the ConTeXt [http://pragma-ade.com/general/manuals/mmodes.pdf modes manual]<br />
for a complete list.<br />
<br />
<br />
{|cellpadding="5" style="border-collapse: collapse;border-width: 1px; border-style: solid;"<br />
|'''*mkii'''<br />
| Enabled when running [[MkII]] <br />
|-<br />
| '''*mkiv''' <br />
| Enabled when running [[MkIV]]<br />
|} <br />
<br />
<br />
Perhaps the most useful system modes are <code>*mkii</code> and <code>*mkiv</code> which<br />
determine whether MKII or MKIV is being used. These modes are handy when you<br />
want different setups for MKII and MKIV.<br />
<br />
Other modes are useful for very specific situations. Some of these are described<br />
below.<br />
<br />
<br />
<br />
{|cellpadding="5" style="border-collapse: collapse;border-width: 1px; border-style: solid;"<br />
| '''*first'''<br />
| Enabled during the first compile run<br />
|}<br />
<br />
A document must be run multiple times to get the cross referencing,<br />
table of contents, etc.<br />
right. However, sometimes you need to do some external processing (e.g., graphic<br />
conversion) that only needs to be done once. In such cases, the<br />
<code>*first</code> mode is handy&mdash;it is active only on the first run of the<br />
document.<br />
<br />
<br />
<br />
<br />
{|cellpadding="5" style="border-collapse: collapse;border-width: 1px; border-style: solid;"<br />
| '''*export'''<br />
| Enabled when <code>\setupbackend[export=yes]</code> is set<br />
|}<br />
<br />
You may want to use different images for XML [Export]. The <code>*export</code> mode is useful in such cases. <br />
<br />
<br />
<br />
<br />
{|cellpadding="5" style="border-collapse: collapse;border-width: 1px; border-style: solid;"<br />
|'''*project'''<br />
| Enabled when inside <code>\startproject</code> ... <code>\stopproject</code><br />
|-<br />
|'''*component'''<br />
| Enabled when inside <code>\startcomponent</code>...<code>\stopcomponent</code><br />
|-<br />
| '''*environment'''<br />
| Enabled when inside <code>\startenvironment</code> ... <code>\stopenvironment</code><br />
|-<br />
| '''*text'''<br />
| Enabled when inside <code>\starttext</code> ... <code>\stoptext</code>.<br />
|}<br />
<br />
You can use the project-product-component structure for managing large projects<br />
like a book series. See [[Project structure]]<br />
for details of this approach. A product or its components may be compiled<br />
separately, and you may want to do something different when a product is<br />
compiled or when a component is compiled. To do so, you need to check for<br />
modes <code>*project</code>, <code>*product</code>, <code>*component</code>, and<br />
<code>*environment</code>; these modes are set when the corresponding structure file<br />
is processed. For example, the <code>*product</code> mode is set whenever a<br />
product file is read; more specifically, when <code>\startproduct</code> is<br />
encountered. Similarly, a mode <code>*text</code> is enabled when<br />
<code>\starttext</code> is encountered, and likewise for the others.<br />
<br />
<br />
<br />
{|cellpadding="5" style="border-collapse: collapse;border-width: 1px; border-style: solid;"<br />
|'''*frontpart''' <br />
| Enabled when inside <code>\startfrontmatter</code> ... <code>\stopfrontmatter</code><br />
|-<br />
| '''*bodypart'''<br />
| Enabled when inside <code>\startbodymatter</code> ... <code>\stopbodymatter</code><br />
|-<br />
| '''*backpart'''<br />
| Enabled when inside <code>\startbackmatter</code> ... <code>\stopbackmatter</code><br />
|}<br />
<br />
A large document is typically broken down into different section blocks:<br />
frontmatter, bodymatter, appendices, and backmatter. Internally, these section<br />
blocks are referred to as <code>frontpart</code>, <code>bodypart</code>, <code>appendix</code>, and<br />
<code>backpart</code>. Each section block sets a system mode with the same name. So,<br />
if you want macros that work differently in different section blocks, you can<br />
check for modes <code>*frontpart</code>, <code>*bodypart</code>, and so on.<br />
<br />
<br />
<br />
{|cellpadding="5" style="border-collapse: collapse;border-width: 1px; border-style: solid;"<br />
|'''*list'''<br />
| Enabled inside a list entry<br />
|-<br />
|'''*marking'''<br />
| Enabled inside a marking<br />
|-<br />
|'''*register'''<br />
| Enabled inside a register<br />
|-<br />
|'''*chapter''', '''*section''', etc.<br />
| Enabled inside the corresponding section head.<br />
|}<br />
<br />
<br />
Sometimes you want a macro to behave differently if it is part of a section head, a section number, a list, a marking, or a register. For section heads, you can check for modes <code>*chapter</code>, <code>*section</code>, <code>*subsection</code>, etc. Similarly, <code>*list</code> is enabled inside a list, <code>*marking</code> is enabled inside a marking, and <code>*register</code> is enabled inside a register.<br />
<br />
<br />
<br />
{|cellpadding="5" style="border-collapse: collapse;border-width: 1px; border-style: solid;"<br />
|'''*en-us''', '''*nl''', etc.<br />
| Enabled when the current <code>\language</code> is <code>en-us</code>, <code>nl</code>, etc.<br />
|-<br />
|'''**en-us''', '''**nl''', etc.<br />
| Enabled when the <code>\mainlanguage</code> is <code>en-us</code>, <code>nl</code>, etc.<br />
|}<br />
<br />
ConTeXt provides support for multiple languages. Languages are recognized by<br />
their IETF language tags, like <code>en-us</code> for US<br />
English, <code>en-gb</code><br />
for British English, <code>nl</code> for Dutch, <code>de</code> for German, etc. A document<br />
has a main language, set with the command <code>\mainlanguage[...]</code>,<br />
that is used for<br />
translated labels like <em>chapter</em> and <em>figure</em>. You can also switch the<br />
current language using <code>\language[...]</code> to change the hyphenation rules.<br />
Whenever a language is chosen, its identifier is set as a mode. The mode for the main<br />
language starts with two <code>*</code>. For example, when the main language<br />
is US<br />
English and the current language is Dutch, the modes <code>**en-us</code> and<br />
<code>*nl</code> are set (notice the extra <code>*</code> in <code>**en-us</code>). <br />
<br />
<br />
<br />
{|cellpadding="5" style="border-collapse: collapse;border-width: 1px; border-style: solid;"<br />
|'''*figure'''<br />
| Enabled when a graphic is found<br />
|-<br />
|'''*interaction'''<br />
| Enabled when interaction is enabled<br />
|-<br />
|'''*grid'''<br />
| Enabled when grid typesetting is enabled<br />
|}<br />
<br />
{|cellpadding="5" style="border-collapse: collapse;border-width: 1px; border-style: solid;"<br />
|'''*pdf'''<br />
| Enabled when the main output is pdf<br />
|-<br />
|'''*dvi'''<br />
| Enabled when the main output is dvi<br />
|}<br />
<br />
Other system modes: <code>*figure</code> is set when a graphic is found,<br />
<code>*interaction</code> is set when interaction is enabled, <code>*grid</code><br />
is set when grid typesetting is enabled, and <code>*pdf</code> and <code>*dvi</code> <br />
are set when the output is PDF or DVI. Others<br />
are too esoteric to describe here. If you are interested, see the <br />
modes manual mentioned earlier.<br />
<br />
= Specific Examples =<br />
<br />
== Different fonts ==<br />
<br />
Suppose you want to generate two versions of a document, one with times font and one with palatino. One way to do this is as follows:<br />
<br />
<texcode><br />
\startmode[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
\stopmode<br />
<br />
\startmode[times]<br />
\setupbodyfont[postscript,12pt]<br />
\stopmode<br />
<br />
\starttext<br />
\input knuth<br />
\stoptext<br />
</texcode><br />
and run with one of the following:<br />
<br />
context --mode=palatino filename<br />
context --mode=times filename<br />
<br />
== Running external commands once ==<br />
<br />
Suppose you want to run some external program, say to generate a figure. Unfortunately, the program only generates postscript figure. So you want to convert it to pdf. This can be done as follows:<br />
<texcode><br />
\startmode[*first]<br />
% external program which creates a file fig-1.ps<br />
\executesystemcommand{some_external_program ...}<br />
% convert PS into PDF<br />
\executesystemcommand{texmfstart pstopdf fig-1.ps}<br />
\stopmode<br />
<br />
% include the resulting PDF<br />
\externalfigure[fig-1]<br />
</texcode><br />
<br />
{{Getting started navbox}}<br />
<br />
[[Category:ConTeXt programming]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupcolumns&diff=25613Command/setupcolumns2020-01-14T12:51:05Z<p>LuP: /* Example */</p>
<hr />
<div>{{Reference<br />
|name=setupcolumns<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setupcolumns</syntax><br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupcolumns<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:ntop|ntop]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:rule|rule]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:height|height]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:tolerance|tolerance]]</td><br />
<td>[[Command/value:verystrict|verystrict]] [[Command/value:strict|strict]] [[Command/value:tolerant|tolerant]] [[Command/value:verytolerant|verytolerant]] [[Command/value:stretch|stretch]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:balance|balance]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:blank|blank]]</td><br />
<td>[[Command/value:fixed|fixed]] [[Command/value:halfline|halfline]] [[Command/value:line|line]] [[Command/value:flexible|flexible]] [[Command/value:big|big]] [[Command/value:medium|medium]] [[Command/value:small|small]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:option|option]]</td><br />
<td>[[Command/value:background|background]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:direction|direction]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setupframed|\setupframed]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
Consider using paragraphs ({{cmd|defineparagraphs}} or column sets ({{cmd|startcolumnset}} instead of ‘simple’ columns.<br />
<br />
{| class="wikitable"<br />
|-<br />
| n <br />
| Number of columns. Default is n=2.<br />
|-<br />
| rule <br />
| Draw a line between the columns. Default is off.<br />
|-<br />
| tolerance <br />
| Affects spacing. Narrow columns should be set tolerant, verytolerant or stretch<br />
|- <br />
| distance <br />
| Size of the gap between the columns.<br />
|- <br />
| balance <br />
| Should the columns be balanced, i.e. should they get the same number of lines?<br />
|- <br />
| align <br />
| Left, right (raggedleft, raggedright).<br />
|- <br />
| blank <br />
| Amount of whitespace between paragraphs set in columns. Also accepts a dimension as an argument. Column equivalent of {{cmd|setupwhitespace}}.<br />
|- <br />
| option <br />
| With option=background you can use everything that \setupframed offers.<br />
|- <br />
| direction <br />
| Default is right, i.e. the first column is on the left; 'left' means the first column is the rightmost.<br />
|- <br />
| height <br />
| height is unclear to me.<br />
|- <br />
| ntop <br />
| ntop contains the minimum number of lines a column should have. If, when a new set of columns starts (e.g. at the start of a page), there are 12 lines to distribute and <code>ntop=7</code>, then ConTeXt will produce one 12-line column rather than two 6-line columns. Note that <code>ntop=6</code> will result in one 7-line column and one 5-line column: ConTeXt seems to prefer that the last column be shorter, as long as its length is at least <code>ntop - n + 1</code>.<br />
|}<br />
<br />
== Example ==<br />
<context source=yes><br />
\setupcolumns[n=3,rule=on,ntop=4,background=color,backgroundcolor=green,]<br />
<br />
\startcolumns<br />
% 12 lines, please<br />
\dorecurse{12}{line\crlf}<br />
\stopcolumns<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|startcolumns}} to start a columnar environment.<br />
* {{cmd|column}} to move to the next column.<br />
* {{cmd|setupparagraphs}} for the analogous command for side-by-side paragraphs<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
{{Columns navbox}}<br />
<br />
[[Category:Command/Columns|setupcolumns]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Indentation&diff=24113Indentation2019-04-12T08:09:33Z<p>LuP: </p>
<hr />
<div>< [[Visuals]]<br />
<br />
In plain TeX, controlling indentation is simple: The user sets a value for <tt>parindent</tt>, and each new paragraph is indented by that value, unless explicitly begun with <tt>noindent</tt>. Environments can provide a <tt>noindent</tt> at the end of their definitions, and if the user wants to overrule that, he can add an explicit <tt>indent</tt> at the beginning of the next paragraph. For the most part, LaTeX follows the same convention.<br />
<br />
Indentation in ConTeXt are a bit different: it mostly does not rely on the presence of blank lines, but uses {{cmd|setupindenting}} to manage general indentation, the <code>indentnext=yes/no/auto</code> key on environments to enable/disable indentation after them, and {{cmd|indentation}} and {{cmd|noindentation}} to manually force/disable an indentation. <br />
<br />
The commands {{cmd|indent}}, {{cmd|noindent}}, {{cmd|indenting}}, and {{cmd|noindenting}} are present for historical reasons, but should not be used. Especially, they should not be confused with {{cmd|indentation}} and {{cmd|noindentation}}<br />
<br />
== Setting up indentation for the whole document ==<br />
<br />
Indentation involves two things: when to indent, and how much to indent. In ConTeXt, these can be specified using {{cmd|setupindenting}}<tt>[...]</tt>. There are three types of keys for this command:<br />
<br />
* <code>''no'' yes</code>: turn indentation on/off'<br />
* <code>''none'' small medium big ''dimension''</code>: size of indents<br />
* <code>''first'' next</code>: turn indentation of first paragraph on/off. Can be overridden by environments with <code>indentnext=yes/no/auto</code>.<br />
* <code>odd even</code>: indent odd/even lines in \obeylines scopes<br />
* <code>normal</code>: what does this do?<br />
<br />
== Setting up indentation after an environment ==<br />
<br />
{{cmd|setupindenting}} does not take care of indenting after environments, such as ConTeXt's itemizes, enumerations, definitions, formulas and floats. It also does not take care of indenting after heads such as chapters, sections, and subsections. <br />
<br />
The setup command of these environments provides an '''<code>indentnext</code>''' key to configure the indentation behaviour after the environment. The <code>indentnext</code> key can take one of three values: <br />
* <code>yes</code> declares the first paragraph following the environment should always be indented.<br />
* <code>no</code> declares the first paragraph following the environment should never be indented.<br />
* <code>auto</code> declares <code>indentnext=auto</code> the next paragraph should be indented only if there is a blank space after the environment. Setting <code>indentnext=auto</code> is equivalent to the default plain TeX and LaTeX behaviour. <br />
<br />
Some examples:<br />
<texcode><br />
% Do not indent paragraphs after \stopitemize<br />
\setupitemgroup[itemize][indentnext=no]<br />
<br />
% indent paragraphs after section heads<br />
\setuphead[section][indentnext=yes]<br />
<br />
% indent the paragraphs after all sectioning heads <br />
\setupheads[indentnext=yes] <br />
<br />
% indent paragraphs after formulas if there is a blank space in between<br />
\setupformulas[indentnext=auto] <br />
</texcode><br />
<br />
== Setting up indentation inside environments ==<br />
<br />
There is one case that is not taken care of by {{cmd|setupindenting}} and the <code>indentnext</code> key: indentation of paragraphs inside multi-paragraph environments such as itemizes, descriptions, and enumerations. By default ConTeXt does not indent such paragraphs. The setup commands of these environments provides an <code>indenting=</code> key to configure the indentation behaviour of paragraphs inside these environments. This key takes the same arguments as the {{cmd|setupindenting}} command does. An example using {{cmd|setupitemgroup}}:<br />
<br />
<context source="yes" text="gives"><br />
\setuppapersize[A5]<br />
<br />
\setupindenting[medium,yes]<br />
\setupitemgroup[itemize][indenting={40pt,next}]<br />
\startitemize<br />
\item This is an example of a multi|-|paragraph <br />
item inside an itemize environment.<br />
<br />
This second paragraph is indented by 40pt<br />
(double the normal indentation).<br />
\stopitemize<br />
</context><br />
<br />
== "indentnext=auto" demo ==<br />
<br />
<context source = "yes" text="gives:"><br />
\setupindenting[medium,yes]<br />
\setupitemize[indentnext=auto]<br />
<br />
\startitemize<br />
\item One<br />
\stopitemize<br />
<br />
This paragraph should be indented - due to the blank line after \type{\stopitemize}.<br />
<br />
\startitemize<br />
\item Two<br />
\stopitemize<br />
This paragraph should not be indented.<br />
</context><br />
<br />
== Manual indentation ==<br />
<br />
No matter how careful we are with all the settings, there are some cases which cannot be taken care of by automatic indentation, and we have to tell ConTeXt how to indent. This is done with {{cmd|indentation}} and {{cmd|noindentation}}. The Plain TeX (and LaTeX) commands <tt>\indent</tt> and <tt>\noindent</tt> are defined in ConTeXt, but are not hooked into the indentation mechanism.<br />
<br />
Suppose the default setup for an article is<br />
<texcode><br />
\setupitemgroup [itemize] [indentnext=no]<br />
</texcode><br />
<br />
Now, if we want to indent after an itemize, starting the next paragraph with {{cmd|indent}} does not work; to get indentation we have to say {{cmd|indentation}}. For example,<br />
<br />
<context source="yes" text="gives"><br />
\setuppapersize[A5]<br />
<br />
\setupindenting [big,yes]<br />
\setupitemgroup [itemize] [indentnext=no]<br />
<br />
\startitemize[n]<br />
\item A dummy list with \type{indentnext=no}...<br />
\item ...to test the \tex{indent} command<br />
\stopitemize<br />
<br />
\indent This paragraph is not indented, because \tex{indent} does not work.<br />
<br />
\startitemize[n]<br />
\item Another dummy list with \type{indentnext=no}...<br />
\item ...to test the \tex{indentation} command<br />
\stopitemize<br />
<br />
\indentation This paragraph will be indented, because we used \tex{indentation}.<br />
</context><br />
<br />
{{Getting started navbox}}</div>LuPhttps://wiki.contextgarden.net/index.php?title=TABLE&diff=24090TABLE2019-04-01T14:23:00Z<p>LuP: </p>
<hr />
<div>< [[Tables Overview]] | [[XML]] ><br />
<br />
=Introduction=<br />
<br />
The preferred way to typeset tables is to use what are called &ldquo;natural tables&rdquo; (also known as &ldquo;automatic tables&rdquo; or &ldquo;HTML tables&rdquo;). They are especially suited for [[XML]] conversions. See the [[manual:enattab.pdf|enattab.pdf]] manual for many examples.<br />
<br />
To place a table use:<br />
<br />
<texcode><br />
\placetable{Caption}<br />
{\bTABLE<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\eTABLE}<br />
</texcode><br />
<br />
A more elaborate example:<br />
<br />
<context source=yes><br />
This is our red-coloured table.<br />
\setupcolors[state=start]<br />
<br />
\setupTABLE[row][odd][background=color,backgroundcolor=red, width=.2\textwidth]<br />
\bTABLE[split=yes] % allow splitting over page boundaries<br />
\bTR \bTD[nr=3] 1 \eTD \bTD[nc=2] 2/3 \eTD \bTD[nr=3] 4 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD[nc=3] 1/2/3 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 2 \eTD \bTD 3 \eTD \bTD 4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
Note that every element must use <tt>\b</tt> ... <tt>\e</tt>.<br />
<br />
Willi Egger wrote a [[My Way]] how he set a typesetter's lead type case: [http://dl.contextgarden.net/myway/NaturalTables.pdf Use of natural tables]<br />
<br />
= Multipage TABLEs =<br />
<br />
Try to divide your table into...<br />
* {{cmd|bTABLEhead}} (table header)<br />
* {{cmd|bTABLEnext}} (alternate table header on following pages)<br />
* {{cmd|bTABLEbody}} (table body)<br />
* {{cmd|bTABLEfoot}} (table footer)<br />
and {{cmd|setupTABLE}}<tt>[split=yes]</tt> or <tt>[split=repeat]</tt><br />
<br />
see also [[source:tabl-ntb.mkiv|tabl-ntb.mkiv]]<br />
<br />
If you must <b>split</b> a natural table over several pages, you can<br />
simply do this by adding <tt>\setupTABLE[split=yes]</tt> to your TABLE<br />
definition. Another way is to define it right at the TABLE start<br />
by adding the parameter <tt>[split=yes]</tt> (see example).<br />
However,<br />
{{cmd|startlinecorrection}}<br />
can lead to unpredictable vertical spaces between rows [http://archive.contextgarden.net/message/20100912.112605.8a1aaf13.en.html].<br />
<br />
In this case the <b>table head</b><br />
(all between {{cmd|bTABLEhead}} and {{cmd|eTABLEhead}})<br />
is printed only once at the beginning of the table. But if you use <tt>[split=repeat]</tt>,<br />
it is printed on top of every new page, that contains parts of<br />
your multipage table. Please take account of the fact, that the<br />
head cells are enclosed by {{cmd|bTH}} and {{cmd|eTH}} (and not \[be]TC).<br />
<br />
If you want to use an alternative table header for all following pages,<br />
you can do this by defining an additional header. Just add the second header<br />
between {{cmd|bTABLEnext}}...{{cmd|eTABLEnext}},<br />
right after your normal head definition.<br />
Now every additional page of the multipage table starts with the<br />
<b>next table head</b>.<br />
<br />
The <b>table foot</b> is declared between {{cmd|bTABLEfoot}} and<br />
{{cmd|eTABLEfoot}}. It defines the concluding row of your natural table.<br />
<br />
'''Beware:''' Split tables often begin not on the page (or in the column, if you use them) where they ''could'' start, but on/in the next one.<br />
This is a known limitation due to the complicated calculation of remaining space on the page.<br />
That won't become better before this calculations are newly written in Lua. (Said Hans on 2010-09-24.)<br />
<br />
The following standalone example deals with all the mentioned aspects of natural tables.<br />
Just <i>copy&paste</i> it as a starting point for further experiments...<br />
<br />
<texcode><br />
\starttext<br />
<br />
\setupcolors[state=start]<br />
<br />
% setup for all cells<br />
\setupTABLE[r][each][style=\tfx\it, align=center]<br />
<br />
% setup table head<br />
\setupTABLE[r][first]<br />
[background=color,<br />
backgroundcolor=yellow]<br />
% setup table footer<br />
\setupTABLE[r][last]<br />
[style=bold,<br />
background=color,<br />
backgroundcolor=green]<br />
<br />
\bTABLE[split=repeat,option=stretch]% head on every page, stretch columns<br />
%<br />
% IMPORTANT: use \bTH ... \eTH to enclose the head|next cells<br />
\bTABLEhead<br />
\bTR<br />
\bTH head1 \eTH<br />
\bTH head2 \eTH<br />
\bTH head3 \eTH<br />
\eTR<br />
\eTABLEhead<br />
% <br />
\bTABLEnext % setup for next table head<br />
\bTR [background=color,backgroundcolor=cyan]<br />
\bTH next1 \eTH<br />
\bTH next2 \eTH<br />
\bTH next3 \eTH<br />
\eTR<br />
\eTABLEnext<br />
%<br />
% the table body (main part)<br />
%<br />
\bTABLEbody<br />
%<br />
\dorecurse{100}{% 100 rows<br />
\bTR<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\eTR<br />
}%<br />
%<br />
\eTABLEbody<br />
%<br />
% the table foot<br />
%<br />
\bTABLEfoot<br />
\bTR<br />
\bTC foot1 \eTC<br />
\bTC foot2 \eTC<br />
\bTC foot3 \eTC<br />
\eTR<br />
\eTABLEfoot<br />
%<br />
\eTABLE<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Changing split location ==<br />
<br />
Sometimes in multipage tables you have cells that have to stay together:<br />
<br />
<texcode><br />
\bTABLE[split=yes]<br />
\dorecurse{10}{\bTR \bTD xxx \eTD \eTR}<br />
\bTR[after=\page] \bTD yyy \eTD \eTR<br />
\dorecurse{10}{\bTR \bTD xxx \eTD \eTR}<br />
\eTABLE<br />
</texcode><br />
<br />
Note that the table is split after the yyy row.<br />
<br />
= Tables in multiple columns =<br />
<br />
... just work (at least in luaTeX and not here...). See the following example.<br />
<br />
<texcode><br />
\starttext<br />
\startcolumns[n=3]<br />
\bTABLE<br />
\dorecurse{21}<br />
{\bTR \bTD a\eTD \bTD b \eTD \eTR}<br />
\eTABLE<br />
\stopcolumns<br />
\stoptext<br />
</texcode><br />
<br />
= Creating tables from CSV data (Comma Separated Values) =<br />
<br />
See also [[m-database|the database module]]!<br />
<br />
and [http://dl.contextgarden.net/myway/csv.pdf Creating Tables using CSV (Comma-separated values)] by Mojca Miklavec<br />
<br />
<br />
<!-- Maybe some other place or a separate page is more appropriate for this section --><br />
<br />
An interesting example of creating a table using comma separated values was posted to the [http://archive.contextgarden.net/message/20050923.193302.f2110c93.en.html mailing list] by [[User:ChristopherCreutzig|Christopher Creutzig]]<br />
<br />
The following macros take care of processing CSV data:<br />
<texcode><br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
</texcode><br />
<br />
The next lines are an example of transforming the data into a natural table, but can be easily adapted to any type of the table or perhaps (mis)used in even more strange ways:<br />
<br />
<texcode><br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
</texcode><br />
<br />
The following lines will then finally result in a desired table:<br />
<br />
<texcode><br />
% some additional settings for the table may be made as well<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style=bold] % how to override the \tt in the second column?<br />
<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A5]<br />
<br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
<br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style={\rm\bf}]<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</context><br />
<br />
Some remarks: the (tentative) code ignores the fact that<br />
* csv data may optionally be enclosed in "" quotes that have to be removed (to be done in \TBLentry) <br />
* quoted strings may contain commas themselves (which means writing a custom version of \processcommalist instead).<br />
<br />
See also {{cmd|processseparatedlist}}.<br />
<br />
= Designing complex TABLEs =<br />
<br />
Everything is easy when a simple grid is enough. Unfortunately, this<br />
is not the case most of the time, tables tend to have information<br />
which should flow accross cell boundaries either vertically<br />
or horizontally. One of the reasons to use TABLE instead of the<br />
table environment is that TABLE provides an easy (relatively speaking, <br />
at least) way to make merged cells to both directions.<br />
<br />
There are probably as many ways to design TABLEs as there are<br />
users, but a simple one to begin with is to start with a<br />
grid:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\bTABLE<br />
\bTR \bTD r1c1 \eTD \bTD r1c2 \eTD \bTD r1c3 \eTD \bTD r1c4 \eTD \bTD r1c5 \eTD \bTD r1c6 \eTD \eTR<br />
\bTR \bTD r2c1 \eTD \bTD r2c2 \eTD \bTD r2c3 \eTD \bTD r2c4 \eTD \bTD r2c5 \eTD \bTD r2c6 \eTD \eTR<br />
\bTR \bTD r3c1 \eTD \bTD r3c2 \eTD \bTD r3c3 \eTD \bTD r3c4 \eTD \bTD r3c5 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD r4c2 \eTD \bTD r4c3 \eTD \bTD r4c4 \eTD \bTD r4c5 \eTD \bTD r4c6 \eTD \eTR<br />
\bTR \bTD r5c1 \eTD \bTD r5c2 \eTD \bTD r5c3 \eTD \bTD r5c4 \eTD \bTD r5c5 \eTD \bTD r5c6 \eTD \eTR<br />
\bTR \bTD r6c1 \eTD \bTD r6c2 \eTD \bTD r6c3 \eTD \bTD r6c4 \eTD \bTD r6c5 \eTD \bTD r6c6 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The desired table layout is then drawn onto this grid, and the top left corner cell<br />
of each cell in the final layout identified:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nc=2,nr=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The cells are listed from left to right and up to down. Each larger cell is then given<br />
it size by using <tt>nc=...</tt> and <tt>nr=...</tt> parameters with <tt>\bTD</tt>. The<br />
code producing the table above is:<br />
<br />
<texcode><br />
\setupTABLE[r][each][height=1cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nr=2,nc=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
<br />
N.B. There is an ugly hack in the code. An empty first row with zero height and no borders<br />
is added. If the row is omitted, then something odd happens to the number of<br />
columns. The table should have all cells, so this may be a bug. (Or then I have<br />
blundered something with this example, possibly.)<br />
<br />
Everything rectangular can be done with TABLE, as long as it can be fit in the grid. The grid<br />
does not have to be equidistant, and if its dimensions are omitted, the program<br />
will fit the data in. L-shaped or other complex cell shapes are not possible.<br />
Using them would be a bit odd, in any case, as alignment and text flow problems<br />
would be quite interesting.<br />
<br />
<br />
== Cell Addressing and Frames ==<br />
<br />
The setup commands for TABLE do not seem to be very verbosedly commented.<br />
There are, however, a few shorthands, which are useful to understand.<br />
First of all, there are several ways to address cells. This is a brief<br />
summary of some of them:<br />
<br />
<texcode><br />
\setupTABLE[r][(list of rows)][...]<br />
\setupTABLE[c][(list of columns)][...]<br />
\setupTABLE[(list of columns)][(list of rows)][...]<br />
</texcode><br />
<br />
A list contains one or more numbers separated by commas.<br />
Word "last" is equivalent to the number of the last row or<br />
column. The complete list can be replaced by the word "each"<br />
to address all cells on the row/column.<br />
<br />
Let us consider the following table:<br />
<br />
<texcode><br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=1.0cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
...<br />
</texcode><br />
<br />
In plain language the rows are interpreted as follows:<br />
<br />
* Align each cell in each column (i.e. all cells) horizontally in the middle<br />
and vertically in the middle (lohi), and remove all frames (borders)<br />
* The height of rows 2 -- 6 is 1.0 cm<br />
* Draw a line on top of rows 2 and 4<br />
* Draw a line to the right side of columns 1 -- 3<br />
<br />
In this case the table is slightly complicated, there are some split cells,<br />
as shown below:<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
The cell numbering is well worth noting. It is very logical (upper<br />
leftmost part of a combined cell), but sometimes the results are<br />
surprising in the beginning.<br />
<br />
The important point about cell numbering is that there is really<br />
a difference between "bottom border of row 3" and "top border of<br />
row 4". To illustrate this, let us change the frame setups:<br />
<br />
<texcode><br />
\setupTABLE[r][2,4][topframe=on]<br />
</texcode><br />
<br />
is changed to<br />
<br />
<texcode><br />
\setupTABLE[r][1,3][bottomframe=on]<br />
</texcode><br />
<br />
At first sight this is exactly the same thing. But...<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][1,3][bottomframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
Where did the horizontal line in column 3 disappear? Nowhere. There is no<br />
row 3 in column 3, so there cannot be a frame under it. This problem<br />
can be overcome by using topframe and leftframe instead of bottom and<br />
right, as the cells below and to the right of a border have to exist.<br />
<br />
However, this solution leaves the problem of bottom and rightmost borders.<br />
How to draw a line in the bottom of the table? Using <br />
<tt>\setupTABLE[r][6][bottomframe=on]</tt> will leave the gap in columns 3 and 4, <br />
and <tt>\setupTABLE[r][7][topframe=on]</tt> is not possible, as there is no <br />
row 7. The clever idea of using "last" instead of the row number (6) will fail, <br />
as "last" seems to behave exactly the same way as number 6.<br />
<br />
One useful method is to switch on the borders cell by<br />
cell by adding <tt>\setupTABLE[3,4][4][bottomframe=on]</tt>, i.e.<br />
draw a border under cells r4c3 and r4c4.<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\setupTABLE[r][6][bottomframe=on]<br />
\setupTABLE[3,4][4][bottomframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Column Offset/Gap ==<br />
<br />
From the mailing list at 2005-11-09 by Vit Zyka, modified by Hans Hagen:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
% distance mechanism, per column (H)<br />
<br />
\start<br />
\setupTABLE[c][1][distance=2em]<br />
\setupTABLE[c][2][distance=3em]<br />
<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
<br />
\bTABLE[option=stretch]<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
\stop<br />
<br />
% distance mechanism, per table (V)<br />
<br />
\framed[offset=none]{%<br />
\setupTABLE[column][2][align=left]<br />
\setupTABLE[column][3][align=right]<br />
\bTABLE[columndistance=2cm,leftmargindistance=.3cm,rightmargindistance=.5cm]<br />
\bTR<br />
\bTH[nc=3] Table head\eTH<br />
\eTR<br />
\bTR\bTD[nc=2] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=left] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=middle] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD A\eTD\bTD B\eTD\bTD C\eTD\eTR<br />
\bTR\bTD Aa\eTD\bTD Bb\eTD\bTD Cccc\eTD\eTR<br />
\bTR\bTD[nc=3,align=middle] ABC\eTD\eTR<br />
\eTABLE<br />
}<br />
</context><br />
<br />
== Row Offset/Gap ==<br />
<br />
Rows, just like columns, can be drawn with a gap.<br />
As above, this can be achieved using:<br />
<texcode><br />
\bTABLE[spaceinbetween=2cm]<br />
...<br />
\eTABLE<br />
</texcode><br />
<br />
A gap differs from an offset as can be seen when drawing<br />
cells using a background and/or a frame.<br />
<br />
Note that offsets can be uniform <tt>[offset=dimension]</tt>,<br />
or asymmetric<br />
<tt>[toffset=dimension,boffset=dimension,loffset=dimension,roffset=dimension]</tt><br />
<br />
=== Gaps for individual cells ===<br />
<br />
One might want to produce gaps between specific rows and/or specific columns.<br />
This can be achieved using a white frame, for example,<br />
as shown in the following (incomplete) fragment:<br />
<br />
<texcode><br />
\bTABLE[frame=off,columndistance=.5em]<br />
...<br />
\bTR[topframe=on,framecolor=white,rulethickness=.5em]<br />
...<br />
\eTR<br />
...<br />
\eTABLE<br />
</texcode><br />
<br />
Note that the <tt>rulethickness</tt> was set for the particular row<br />
and not for the entire table; otherwise, it would enter into the<br />
calculation of the cell dimensions (and interplay with other parameters<br />
such as <tt>columndistance</tt>).<br />
<br />
More complicated situations, for example, mixing frames, colored cell backgrounds, special gaps, ..., can be achieved using MetaPost graphics as a <tt>background</tt>.<br />
<br />
== Make a cell bold ==<br />
<br />
Drawing bold lines around a cell is done using the<br />
<tt>[rulethickness=''dim'']</tt> key on a cell. The thicker rules will<br />
offset the text inside the cell both downwards and sideways, so care<br />
should be taken that the cell's increased rulethickness is offset by an<br />
equal decrease in offset.<br />
<br />
<context source="yes" text="produces"><br />
\setupTABLE[row][each][rulethickness=.25pt,offset=\dimexpr1mm+1.75pt] <br />
\bTABLE<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2/3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD[rulethickness=2pt,offset=1mm] 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
== Rules ==<br />
<br />
=== Example: an invoice with thick rules ===<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
{\bfa Invoice}<br />
\switchtobodyfont[6pt]<br />
\blank<br />
\bTABLE<br />
\setupTABLE[frame=off,offset=1mm]<br />
\setupTABLE[row][*][height=7.25mm]<br />
\setupTABLE[column][1,2] [width=20mm,offset=\dimexpr1mm+2pt,align=flushleft]<br />
\setupTABLE[column][3,4,5][width=20mm,offset=\dimexpr1mm+2pt,align=flushright]<br />
\bTR[bottomframe=on, rulethickness=2pt,offset=1mm]<br />
\bTD\bf Date \eTD<br />
\bTD\bf Description \eTD<br />
\bTD\bf Quantity \eTD<br />
\bTD\bf Price \eTD<br />
\bTD\bf Total \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 1 \eTD<br />
\bTD 10.0 \eTD<br />
\bTD 6.00 \eTD<br />
\bTD 60.00 \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 2 \eTD<br />
\bTD 2.0 \eTD<br />
\bTD 3.00 \eTD<br />
\bTD 6.00 \eTD<br />
\eTR<br />
\bTR[topframe=on,rulethickness=2pt,offset=1mm]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] Subtotal \eTD<br />
\bTD 66.00 \eTD<br />
\eTR<br />
\bTR[offset=\dimexpr1mm+2pt]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] VAT 19\% \eTD<br />
\bTD 12.54 \eTD<br />
\eTR<br />
\bTR<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] \bf Total \eTD<br />
\bTD 78.54 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
=== Rules with different thickness ===<br />
<br />
There is only one value for all four borders. However, MetaPost can be used as a workaround until the separate "rulethickness" values are implemented.<br />
<br />
The following example (mkiv only!) by Wolfgang Schuster shows a table using MetaPost for the rules:<br />
<br />
<context source=yes mode=mkiv text="gives:"><br />
\startuseMPgraphic{tableborders}<br />
<br />
draw leftboundary OverlayBox withpen pensquare scaled \frameddimension {leftrulethickness} ;<br />
draw rightboundary OverlayBox withpen pensquare scaled \frameddimension {rightrulethickness} ;<br />
draw topboundary OverlayBox withpen pensquare scaled \frameddimension {toprulethickness} ;<br />
draw bottomboundary OverlayBox withpen pensquare scaled \frameddimension{bottomrulethickness} ;<br />
<br />
clip currentpicture to OverlayBox<br />
leftenlarged (\frameddimension {leftrulethickness}/2)<br />
rightenlarged (\frameddimension {rightrulethickness}/2)<br />
topenlarged (\frameddimension {toprulethickness}/2)<br />
bottomenlarged (\frameddimension{bottomrulethickness}/2) ;<br />
<br />
setbounds currentpicture to OverlayBox ;<br />
<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay[tableborders][\useMPgraphic{tableborders}]<br />
<br />
\startsetups tableborders<br />
<br />
\setupTABLE<br />
[ background={color,tableborders},<br />
frame=off,<br />
backgroundoffset=0pt,<br />
leftrulethickness=\framedparameter{rulethickness},<br />
rightrulethickness=\framedparameter{rulethickness},<br />
toprulethickness=\framedparameter{rulethickness},<br />
bottomrulethickness=\framedparameter{rulethickness}]<br />
<br />
\setupTABLE[row] [odd] [backgroundcolor=lightgray]<br />
\setupTABLE[row] [first][backgroundcolor=gray,bottomrulethickness=2pt]<br />
\setupTABLE[row] [last] [toprulethickness=2pt,bottomrulethickness=2pt]<br />
\setupTABLE[first][last] [leftrulethickness=2pt]<br />
\setupTABLE[last] [last] [rightrulethickness=2pt]<br />
<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\bTABLE<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\blank<br />
<br />
\bTABLE[setups=tableborders]<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\stoptext<br />
</context><br />
<br />
See the corresponding thread on the list: [http://www.ntg.nl/pipermail/ntg-context/2011/058549.html rules with different thickness]<br />
<br />
=== Thick bottom rules ===<br />
<br />
This is a simplified version of the example above (corresponding mailing thread - [http://www.ntg.nl/pipermail/ntg-context/2012/069541.html TABLE: header with a thick bottom line]).<br />
<br />
<context source=yes mode=mkiv text="Gives:"><br />
\startuseMPgraphic{MP:thickBtm}<br />
draw bottomboundary OverlayBox withpen pensquare scaled \frameddimension{bottomrulethickness};<br />
clip currentpicture to OverlayBox;<br />
setbounds currentpicture to OverlayBox;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay[OL:thickBtm][\useMPgraphic{MP:thickBtm}]<br />
<br />
\starttext<br />
\bTABLE<br />
\setupTABLE[align=middle]<br />
\setupTABLE[header][background={OL:thickBtm},bottomrulethickness=4pt]<br />
\setupTABLE[row][4][background={OL:thickBtm},bottomrulethickness=2pt]<br />
%<br />
\bTABLEhead\bTR\dorecurse{3}{\bTH#1\eTH}\eTR\eTABLEhead<br />
\bTABLEbody\dorecurse{6}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}\eTABLEbody<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
=== Diagonal rules ===<br />
<br />
Sometimes a diagonal rule is required in the top left corner cell of a table to create two fields, one for the left column and one for the top row.<br />
<br />
<br />
<context mode="mkiv" source="yes" text="Gives:"><br />
\startuseMPgraphic{DiagonalRule}<br />
rulethickness := \frameddimension{rulethickness};<br />
<br />
drawoptions(<br />
withpen pencircle scaled rulethickness<br />
withcolor \MPcolor{\framedparameter{framecolor}});<br />
<br />
pair leftcorner, rightcorner;<br />
leftcorner := (rulethickness, \overlayheight-rulethickness);<br />
rightcorner := (\overlaywidth-rulethickness, rulethickness);<br />
<br />
draw leftcorner -- rightcorner;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[DiagonalRule]<br />
[\useMPgraphic{DiagonalRule}]<br />
<br />
\define[2]\DiagonalLabel{%<br />
\setuptabulate [after={\blank[\frameddimension{offset}]}]<br />
\starttabulate [|p|r|]<br />
\NC \NC #2 \NC\NR<br />
\NC #1 \NC \NC\NR<br />
\stoptabulate<br />
}<br />
<br />
\starttext<br />
\setupTABLE [row] [1] [width=2cm]<br />
\bTABLE<br />
\bTR<br />
\bTD [background=DiagonalRule]<br />
\DiagonalLabel{Foo}{Bar}<br />
\eTD<br />
\bTD Second \eTD<br />
\bTD Third \eTD<br />
\eTR<br />
\bTR<br />
\bTD Alpha \eTD<br />
\bTD Beta \eTD<br />
\bTD Gamma \eTD<br />
\eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
This solution has (at least) one caveat: Because the first<br />
tabulate column is set in paragraph mode, it will eat up as much<br />
space as <em>possible</em>, in contrast to occupying as much space as<br />
</em>necessary</em>. That is why the width of the column has to be set<br />
explicitly.<br />
<br />
== Using character alignment ==<br />
<br />
ConTeXt can align columns of numbers on a character (often a decimal point to align accounting data) automatically, removing the need to add fixed spaces into your document. For any such column you need to specify the character on which to align. You use the <tt>aligncharacter=yes</tt> parameter to set up character alignment, <tt>alignmentcharacter={.}</tt> to say what the character should be (in this case a full stop) and <tt>align=middle</tt> to set the overall alignment of the column.<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},<br />
aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
You'll note that the final line, because it has no <code>.</code> in the number, gets aligned under the right-hand side of the numbers. In most circumstances you would want such a number aligned with the left-hand set of digits. To so do, issue the following command in your preamble:<br />
<br />
<texcode><br />
\chardef\characteralignmentmode=2<br />
</texcode><br />
<br />
and now the table above will turn out like this:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\chardef\characteralignmentmode=2<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
If there's no <code>alignmentcharacter</code> in the cell, the content will be aligned in the following way depending on the value of <code>\characteralignmentmode</code>:<br />
<table style="border:1px solid #DDDDDD;"><br />
<tr style="background-color:#DDDDDD; font-weight: bold;"><td>mode</td><td width="200"></td><td>.</td><td width="200"></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">0</td><td colspan="3" align="center">centered</td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">1</td><td align="left">left in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">2</td><td align="right">right in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">3</td><td></td><td style="background-color:#DDDDDD">.</td><td align="left">left in after</td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">4</td><td></td><td style="background-color:#DDDDDD">.</td><td align="right">right in after</td></tr><br />
</table><br />
<br />
=== Character alignment methods ===<br />
MkIV (starting in late June 2014) offers two methods for character alignment. The first, "number", attempts to identify the number from preceding and trailing text, align the number on the separator and separately vertically align preceding or trailing text by paddind in-between the number and the preceding/trailing text. This looks very nice when the preceding or trailing text is all of the same width (for example, a currency symbol or % sign), but will mis-align if the preceding or trailing text has varying widths. Number mode is the default for most separators, but can be forced by specifying <code>alignmentcharacter={number->-}</code>.<br />
<br />
Note that the below examples will not render properly until the wiki supports this feature; this file shows the expected output. [[File:character_alignment_methods_example.pdf]]<br />
<br />
<context source="yes" mode="mkiv"><br />
% mode=mkiv<br />
\setuppapersize[A5]<br />
\bTABLE<br />
\setupTABLE[c][1,2,3,4][alignmentcharacter={number->.},aligncharacter=yes,align=middle]<br />
\bTABLEhead<br />
\bTR<br />
\bTH Same-Width Prefix \eTH \bTH Varying-Width Prefix \eTH<br />
\bTH Same-Width Suffix \eTH \bTH Varying-Width Suffix \eTH<br />
\eTR<br />
\eTABLEhead<br />
\bTABLEbody<br />
\bTR \bTD \$1.00 \eTD \bTD \$1.00 \eTD \bTD 1.00\% \eTD \bTD 1.00\% \eTD \eTR<br />
\bTR \bTD \$10.00 \eTD \bTD \$\$10.00 \eTD \bTD 10.00\% \eTD \bTD 10.00\%\% \eTD \eTR<br />
\bTR \bTD \$1.0 \eTD \bTD \$1.0 \eTD \bTD 1.0\% \eTD \bTD 1.0\% \eTD \eTR<br />
\bTR \bTD \$10.0 \eTD \bTD \$\$10.0 \eTD \bTD 10.0\% \eTD \bTD 10.0\%\% \eTD \eTR<br />
\eTABLEbody<br />
\eTABLE<br />
</context><br />
<br />
In the above example the "varying-width" columns do not align on the alignment character. For these cases the "text" method is provided. The logic simpler&mdash;it does not attempt to pad space in-between the number and any preceding or trailing text, so the text will always align on the alignment character, but forgoes the attempt to vertically align preceding and trailing text. This is the default mode for the "-" separator, but can be forced by specifying <code>alignmentcharacter={text->.}</code>. The below example shows that all four columns align on the ".", but the "$" and "%" are no longer stacked.<br />
<br />
<context source="yes" mode="mkiv"><br />
% mode=mkiv<br />
\setuppapersize[A5]<br />
\bTABLE<br />
\setupTABLE[c][1,2,3,4][alignmentcharacter={text->.},aligncharacter=yes,align=middle]<br />
\bTABLEhead<br />
\bTR<br />
\bTH Same-Width Prefix \eTH \bTH Varying-Width Prefix \eTH<br />
\bTH Same-Width Suffix \eTH \bTH Varying-Width Suffix \eTH<br />
\eTR<br />
\eTABLEhead<br />
\bTABLEbody<br />
\bTR \bTD \$1.00 \eTD \bTD \$1.00 \eTD \bTD 1.00\% \eTD \bTD 1.00\% \eTD \eTR<br />
\bTR \bTD \$10.00 \eTD \bTD \$\$10.00 \eTD \bTD 10.00\% \eTD \bTD 10.00\%\% \eTD \eTR<br />
\bTR \bTD \$1.0 \eTD \bTD \$1.0 \eTD \bTD 1.0\% \eTD \bTD 1.0\% \eTD \eTR<br />
\bTR \bTD \$10.0 \eTD \bTD \$\$10.0 \eTD \bTD 10.0\% \eTD \bTD 10.0\%\% \eTD \eTR<br />
\eTABLEbody<br />
\eTABLE<br />
</context><br />
<br />
Entering <code>\nocharacteralign</code> disables character alignment in a cell.<br />
<br />
== Specifying the cell column ==<br />
<br />
When writing a table you can omit empty cells and define only cells for specified columns. To have this feature fully available you need to have a beta or a quite fresh ConTeXt version.<br />
<br />
Two methods are available:<br />
<br />
* With the TD "n" option, the undefined cells are merged into a single spanned cell.<br />
* With the TD "m" option, the undefined cells appear as empty normal cells.<br />
<br />
Here is an example using the "n" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[n=2] d2 \eTD\bTD[n=5] d5 \eTD\bTD[n=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[n=4] f4 \eTD\bTD[n=5] f5 \eTD\bTD[n=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
Here is an example using the "m" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[m=2] d2 \eTD\bTD[m=5] d5 \eTD\bTD[m=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[m=4] f4 \eTD\bTD[m=5] f5 \eTD\bTD[m=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Round corners ==<br />
<br />
For a different approach for round corners and colored background follow the text after this example.<br />
<br />
It is possible to round the corners of the table if you turn off the main frame of the table and frame the table in {{cmd|framed}}. Compare two different approaches in the first and second example.<br />
<br />
You can't color the background of the table with round corners unless the frame rulethickness is not big enough to cover the rectangular corners of the background (second example). Well, you can if you frame the table twice. Once in the thick white frame and then in the thin frame with negative offset and slightly smaller corner radius (third example). Be aware of other complications -- notice that the thick white frame is still visible in the text above it.<br />
<br />
<context source="yes"><br />
\starttext<br />
\setupcolors[state=start] <br />
%\showstruts<br />
\setupTABLE[background=color,backgroundcolor=yellow]<br />
\setupframed[framecolor=darkgreen]<br />
<br />
\defineparagraphs[ThreeCols]<br />
<br />
\startThreeCols<br />
<br />
First<br />
<br />
\def\StartTable<br />
{\setupTABLE[row] [first][topframe=off]%<br />
\setupTABLE[row] [last] [bottomframe=off]%<br />
\setupTABLE[column][first][leftframe=off]%<br />
\setupTABLE[column][last] [rightframe=off]%<br />
\framed[strut=no,corner=round,offset=.5\linewidth]<br />
\bgroup}<br />
<br />
\def\StopTable<br />
{\egroup}<br />
<br />
\StartTable<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\StopTable<br />
<br />
\nextThreeCols<br />
<br />
Second<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,offset=.5\linewidth,,rulethickness=1mm]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
<br />
\nextThreeCols<br />
<br />
Third<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,<br />
radius=1.4mm,offset=-1mm,,rulethickness=.1mm]\bgroup<br />
\framed[strut=no,corner=round,<br />
radius=1.5mm,offset=0mm,,rulethickness=1mm,framecolor=white]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
\egroup<br />
<br />
\stopThreeCols<br />
<br />
\stoptext<br />
</context><br />
<br />
From 2006-10-11 on, ConTeXt contains one more mechanism for round corners. Watch the example:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\starttext<br />
\setupcolors[state=start]<br />
\setupTABLE [y] [first][background=color,backgroundcolor=blue,frame=off,bottomframe=on,topframe=on,framecolor=white]<br />
\setupTABLE [first][first][backgroundcorner=2,corner=10,frame=on]<br />
\setupTABLE [last] [first][backgroundcorner=4,corner=12,frame=on]<br />
\setupTABLE [row] [each] [background=color,backgroundcolor=blue,frame=on,framecolor=white]<br />
\setupTABLE [first][2] [corner=8]<br />
\setupTABLE [last] [2] [corner=5]<br />
\setupTABLE [first][last] [corner=7]<br />
\setupTABLE [last] [last] [corner=6]<br />
<br />
\bTABLE[frame=off,align=middle]<br />
\bTR \bTD one \eTD \bTD two \eTD \bTD three \eTD \eTR<br />
\bTR \bTD first \eTD \bTD second \eTD \bTD third \eTD \eTR<br />
\bTR \bTD alpha \eTD \bTD beta \eTD \bTD gamma \eTD \eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
== Other options ==<br />
<br />
Some other useful options that were not covered above:<br />
* <tt>align=yes</tt> will align the text both left and right justified<br />
* <tt>loffset</tt>, <tt>roffset</tt>, <tt>toffset</tt>, <tt>boffset</tt> can be used in addition to <tt>offset</tt> to specify cell content offsets in each direction separately, see also {{cmd|framed}}<br />
<br />
= TABLEs with old table syntax =<br />
<br />
From the mailing list in March 2009, by Wolfgang Schuster and Hans Hagen:<br />
<br />
<texcode><br />
\def\startTABLE<br />
{\dosingleempty\dostartTABLE}<br />
<br />
\def\dostartTABLE[#1]%<br />
{\bgroup<br />
\bTABLE[#1]%<br />
\let\NC\doTABLENC<br />
\let\NR\doTABLENR<br />
\let\bTR\relax<br />
\let\bTD\relax<br />
\let\bTH\relax<br />
\let\bTN\relax}<br />
<br />
\def\stopTABLE<br />
{\eTABLE<br />
\egroup}<br />
<br />
\newconditional\inTABLEnc<br />
<br />
\unexpanded\def\doTABLENR<br />
{\eTR<br />
\setfalse\inTABLEnc}<br />
<br />
\unexpanded\def\doTABLENC<br />
{\futurelet\next\dodoTABLENC}<br />
<br />
\def\dodoTABLENC<br />
{\ifx\next\doTABLENR \else<br />
\expandafter\dododoTABLENC<br />
\fi}<br />
<br />
\long\def\dododoTABLENC#1\NC<br />
{\ifconditional\inTABLEnc\else\settrue\inTABLEnc\parseTR[][]\fi<br />
\dodoubleempty\parseTD#1\eTD\NC}<br />
</texcode><br />
<br />
This is now part of the core as the [[source:tabl-nte.tex|NTE module]]. Quoting its internal documentation:<br />
<br />
This module is suggested by Wolfgang Schuster who also prototyped it and came up with the rationale:<br />
<br />
This module provides an easy way to use natural in a similiar way as the older table module (based on the [[TABLE]] macros) and the newer [[tabulate]] module.<br />
<br />
You can see the advantage in the following table, once created with the new macros and once with the normal macros provided with the natural table module.<br />
<br />
Let us start with the original macros:<br />
<br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD Text 1 \eTD<br />
\bTD Text 2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD Text 3 \pasteeTD<br />
\bTD Text 4 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
<br />
Watch how the new macros use less code:<br />
<br />
<texcode><br />
\startTABLE<br />
\NC Text 1 \NC Text 2 \NC\NR<br />
\NC Text 3 \NC Text 4 \NC\NR<br />
\stopTABLE<br />
</texcode><br />
<br />
The actual code differs from the prototype that it does not need to collect whole rows and parse them but looks ahead instead.<br />
<br />
= Get current row/column number =<br />
See for example here: [[Command/currentTABLErow]]<br />
<br />
[[Category:Tables]]<br />
[[Category:XML]]<br />
tt>\bTD<br />
<br />
= An alignment issue =<br />
<br />
In some cases the alignment of cell contents may not behave as you might expect. Here is an illustrative example. The following code<br />
<br />
<context source=yes mode=mkiv text="gives us:"><br />
\define[3]\Glyphbox<br />
{\framed[frame=on,align=middle]\bgroup<br />
#1\\<br />
#2\\<br />
#3%<br />
\egroup}<br />
<br />
\starttext<br />
\setupTABLE[frame=on,align=middle]<br />
\bTABLE<br />
\bTR \bTD \Glyphbox{I}{a}{1} \eTD <br />
\bTD \Glyphbox{I}{a}{1} \eTD <br />
\eTR<br />
\bTR \bTD \Glyphbox{III}{aaa}{111} \eTD<br />
\bTD \Glyphbox{III}{aaa}{111} \eTD<br />
\eTR<br />
\eTABLE<br />
\stoptext <br />
</context><br />
<br />
Note that in the first row the cells are not middle-aligned. As Wolfgang Schuster pointed out on the list, we need *two* things to fix this:<br />
<br />
1. You need <tt>\dontleavehmode</tt> in front of the <tt>\framed</tt>.<br />
<br />
2. You need <tt>\setupTABLE[start][..,..=..,..]</tt> because <tt>\bTABLE</tt> sets a default value for the align key which can’t be overwritten with a simple <tt>\setupTABLE[..,..=..,..]</tt>.<br />
<br />
Implementing this <context source=yes mode=mkiv text="we now get the following correct output with centered cells in the first row:"><br />
\define[3]\Glyphbox<br />
{\dontleavehmode<br />
\framed[frame=on,align=middle]\bgroup<br />
#1\\<br />
#2\\<br />
#3%<br />
\egroup}<br />
<br />
\starttext<br />
\setupTABLE[start][frame=on,align=middle]<br />
\bTABLE<br />
\bTR \bTD \Glyphbox{I}{a}{1} \eTD <br />
\bTD \Glyphbox{I}{a}{1} \eTD <br />
\eTR<br />
\bTR \bTD \Glyphbox{III}{aaa}{111} \eTD<br />
\bTD \Glyphbox{III}{aaa}{111} \eTD<br />
\eTR<br />
\eTABLE<br />
\stoptext <br />
</context><br />
<br />
= Footnotes in TABLEs =<br />
<br />
From this conversation on the mailing list[https://mailman.ntg.nl/pipermail/ntg-context/2017/089097.html]. In order to get global footnotes printing after tables (without using the local footnotes trick):<br />
<br />
<texcode><br />
Text\footnote{Normal Footnote}<br />
\bTABLE[split=repeat,align=normal]<br />
\bTR\bTD Something\postponenotes\footnote[x]{bla bla}\eTD\eTR<br />
\bTR\bTD Foo\note[x] \eTD\eTR<br />
\eTABLE<br />
\flushnotes<br />
More Text\footnote{Another Normal Footnote}<br />
</texcode><br />
<context mode=mkiv source=no><br />
\setupnote[footnote][location=text]<br />
\setupnotations[alternative=serried]<br />
\starttext<br />
Text\footnote{Normal Footnote}<br />
\bTABLE[split=repeat,align=normal]<br />
\bTR\bTD Something\postponenotes\footnote[x]{bla bla}\eTD\eTR<br />
\bTR\bTD Foo\note[x] \eTD\eTR<br />
\eTABLE<br />
\flushnotes<br />
More Text\footnote{Another Normal Footnote}<br />
Note that the context wiki is eating the footnote numbers, but that they are there anyways.<br />
\placefootnotes<br />
\stoptext<br />
<br />
<br />
</context></div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/head&diff=23795Command/head2018-05-23T11:44:21Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=head<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\head<span class="first" style="color:red;">[ref,ref,...]</span></td><br />
</tr><br />
<tr><br />
<td colspan="2" class="cmd">\starthead<span class="first" style="color:red;">[ref,ref,...]</span><span class="second">{Title}</span> ... \stophead</td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[ref,ref,...]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
Used in itemizations. Prints the first paragraph of an item in the <code>headstyle</code> specified in {{cmd|startitemize}}, and prevents a pagebreak from occurring between the head and the next item. By default, the <code>headstyle</code> is simply the normal style. An empty line or a {{cmd|par}} after a <code>\head</code> is required, so that ConTeXt may distinguish between the header line and the rest of the head item.<br />
<br />
Because the occasional bold item in a list still does not look very much like a head, the items under the head are often printed in a nested {{cmd|startitemize}}. <br />
<br />
=== Referring to the head ===<br />
<br />
The syntax \head[ref] probably do not work - it is necessary to use \starthead[ref] ... \stophead<br />
([https://mailman.ntg.nl/pipermail/ntg-context/2018/091593.html])<br />
<br />
== Example ==<br />
<br />
<context source=yes><br />
\startitemize[packed][headstyle=bold]<br />
\head Birds % empty line is required between first par and rest of head <br />
% item, or one will get a very long header<br />
<br />
What is water? This is a difficult question to answer, <br />
because water is impossible to define. One could ask <br />
the same question about birds. What {\em are} birds? <br />
We just don't know.<br />
\startitemize[a]<br />
\item Toucan<br />
\item Quetzal<br />
\item Cassowary<br />
\stopitemize<br />
<br />
\head Mammals \par % The \par has the same function as the empty line<br />
\startitemize[continue]<br />
\item Anteater<br />
\item Sloth<br />
\item Capybara<br />
\stopitemize<br />
\stopitemize<br />
</context><br />
<br />
=== Example of a reference ===<br />
<br />
<context source=yes><br />
\startitemize[i][stopper=),headstyle=bold]<br />
\item[TheItem] Item<br />
<br />
\starthead[TheHead]{Head}<br />
<br />
Some text<br />
<br />
\stophead<br />
\stopitemize<br />
<br />
See point \in[TheItem] or \in[TheHead].<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|startitemize}}<br />
* {{cmd|item}} to print ordinary items<br />
* {{cmd|sym}} to print an item with a custom symbol<br />
* {{cmd|mar}} to print an item with margin text<br />
* {{cmd|sub}} to print an item with a continuation mark<br />
* {{cmd|its}} to print an item with a row of marks (for response ranges)<br />
* {{cmd|ran}} to print a range for the {{cmd|its}} row<br />
* {{cmd|head}} to print a head within the list<br />
* {{cmd|but}} to print an item whose mark is an interactive button<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Itemizations|head]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/head&diff=23794Command/head2018-05-23T10:52:34Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=head<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\head<span class="first" style="color:red;">[ref,ref,...]</span></td><br />
</tr><br />
<tr><br />
<td colspan="2" class="cmd">\starthead<span class="first" style="color:red;">[ref,ref,...]</span> ... \stophead</td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[ref,ref,...]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
Used in itemizations. Prints the first paragraph of an item in the <code>headstyle</code> specified in {{cmd|startitemize}}, and prevents a pagebreak from occurring between the head and the next item. By default, the <code>headstyle</code> is simply the normal style. An empty line or a {{cmd|par}} after a <code>\head</code> is required, so that ConTeXt may distinguish between the header line and the rest of the head item.<br />
<br />
Because the occasional bold item in a list still does not look very much like a head, the items under the head are often printed in a nested {{cmd|startitemize}}. <br />
<br />
=== Referring to the head ===<br />
<br />
The syntax \head[ref] probably do not work - it is necessary to use \starthead[ref] ... \stophead<br />
([https://mailman.ntg.nl/pipermail/ntg-context/2018/091593.html])<br />
<br />
== Example ==<br />
<br />
<context source=yes><br />
\startitemize[packed][headstyle=bold]<br />
\head Birds % empty line is required between first par and rest of head <br />
% item, or one will get a very long header<br />
<br />
What is water? This is a difficult question to answer, <br />
because water is impossible to define. One could ask <br />
the same question about birds. What {\em are} birds? <br />
We just don't know.<br />
\startitemize[a]<br />
\item Toucan<br />
\item Quetzal<br />
\item Cassowary<br />
\stopitemize<br />
<br />
\head Mammals \par % The \par has the same function as the empty line<br />
\startitemize[continue]<br />
\item Anteater<br />
\item Sloth<br />
\item Capybara<br />
\stopitemize<br />
\stopitemize<br />
</context><br />
<br />
=== Example of a reference ===<br />
<br />
<context source=yes><br />
\startitemize[i][stopper=)]<br />
\item[TheItem] Item<br />
<br />
\starthead[TheHead] Head \stophead<br />
<br />
Some text<br />
\stopitemize<br />
<br />
See point \in[TheItem] or \in[TheHead].<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|startitemize}}<br />
* {{cmd|item}} to print ordinary items<br />
* {{cmd|sym}} to print an item with a custom symbol<br />
* {{cmd|mar}} to print an item with margin text<br />
* {{cmd|sub}} to print an item with a continuation mark<br />
* {{cmd|its}} to print an item with a row of marks (for response ranges)<br />
* {{cmd|ran}} to print a range for the {{cmd|its}} row<br />
* {{cmd|head}} to print a head within the list<br />
* {{cmd|but}} to print an item whose mark is an interactive button<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Itemizations|head]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/head&diff=23793Command/head2018-05-23T10:50:02Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=head<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\head<span class="first" style="color:red;">[ref,ref,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[ref,ref,...]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
Used in itemizations. Prints the first paragraph of an item in the <code>headstyle</code> specified in {{cmd|startitemize}}, and prevents a pagebreak from occurring between the head and the next item. By default, the <code>headstyle</code> is simply the normal style. An empty line or a {{cmd|par}} after a <code>\head</code> is required, so that ConTeXt may distinguish between the header line and the rest of the head item.<br />
<br />
Because the occasional bold item in a list still does not look very much like a head, the items under the head are often printed in a nested {{cmd|startitemize}}. <br />
<br />
=== Referring to the head ===<br />
<br />
The syntax \head[ref] probably do not work - it is necessary to use \starthead[ref] ... \stophead<br />
([https://mailman.ntg.nl/pipermail/ntg-context/2018/091593.html])<br />
<br />
== Example ==<br />
<br />
<context source=yes><br />
\startitemize[packed][headstyle=bold]<br />
\head Birds % empty line is required between first par and rest of head <br />
% item, or one will get a very long header<br />
<br />
What is water? This is a difficult question to answer, <br />
because water is impossible to define. One could ask <br />
the same question about birds. What {\em are} birds? <br />
We just don't know.<br />
\startitemize[a]<br />
\item Toucan<br />
\item Quetzal<br />
\item Cassowary<br />
\stopitemize<br />
<br />
\head Mammals \par % The \par has the same function as the empty line<br />
\startitemize[continue]<br />
\item Anteater<br />
\item Sloth<br />
\item Capybara<br />
\stopitemize<br />
\stopitemize<br />
</context><br />
<br />
=== Example of a reference ===<br />
<br />
<context source=yes><br />
\startitemize[i][stopper=)]<br />
\item[TheItem] Item<br />
<br />
\starthead[TheHead] Head \stophead<br />
<br />
Some text<br />
\stopitemize<br />
<br />
See point \in[TheItem] or \in[TheHead].<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|startitemize}}<br />
* {{cmd|item}} to print ordinary items<br />
* {{cmd|sym}} to print an item with a custom symbol<br />
* {{cmd|mar}} to print an item with margin text<br />
* {{cmd|sub}} to print an item with a continuation mark<br />
* {{cmd|its}} to print an item with a row of marks (for response ranges)<br />
* {{cmd|ran}} to print a range for the {{cmd|its}} row<br />
* {{cmd|head}} to print a head within the list<br />
* {{cmd|but}} to print an item whose mark is an interactive button<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Itemizations|head]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/head&diff=23792Command/head2018-05-23T10:48:11Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=head<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\head<span class="first" style="color:red;">[ref,ref,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[ref,ref,...]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
Used in itemizations. Prints the first paragraph of an item in the <code>headstyle</code> specified in {{cmd|startitemize}}, and prevents a pagebreak from occurring between the head and the next item. By default, the <code>headstyle</code> is simply the normal style. An empty line or a {{cmd|par}} after a <code>\head</code> is required, so that ConTeXt may distinguish between the header line and the rest of the head item.<br />
<br />
Because the occasional bold item in a list still does not look very much like a head, the items under the head are often printed in a nested {{cmd|startitemize}}. <br />
<br />
=== Referring to the head ===<br />
<br />
The syntax \head[ref] probably do not work - it is necessary to use \starthead[ref] ... \stophead<br />
([https://mailman.ntg.nl/pipermail/ntg-context/2018/091593.html])<br />
<br />
== Example ==<br />
<br />
<context source=yes><br />
\startitemize[packed][headstyle=bold]<br />
\head Birds % empty line is required between first par and rest of head <br />
% item, or one will get a very long header<br />
<br />
What is water? This is a difficult question to answer, <br />
because water is impossible to define. One could ask <br />
the same question about birds. What {\em are} birds? <br />
We just don't know.<br />
\startitemize[a]<br />
\item Toucan<br />
\item Quetzal<br />
\item Cassowary<br />
\stopitemize<br />
<br />
\head Mammals \par % The \par has the same function as the empty line<br />
\startitemize[continue]<br />
\item Anteater<br />
\item Sloth<br />
\item Capybara<br />
\stopitemize<br />
\stopitemize<br />
</context><br />
<br />
=== Example of a reference ===<br />
<br />
<context source=yes><br />
\startitemize[i][stopper=)]<br />
\starthead[TheHead] Head \stophead<br />
<br />
Some text<br />
\stopitemize<br />
<br />
See point \in[TheHead].<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|startitemize}}<br />
* {{cmd|item}} to print ordinary items<br />
* {{cmd|sym}} to print an item with a custom symbol<br />
* {{cmd|mar}} to print an item with margin text<br />
* {{cmd|sub}} to print an item with a continuation mark<br />
* {{cmd|its}} to print an item with a row of marks (for response ranges)<br />
* {{cmd|ran}} to print a range for the {{cmd|its}} row<br />
* {{cmd|head}} to print a head within the list<br />
* {{cmd|but}} to print an item whose mark is an interactive button<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Itemizations|head]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupheader&diff=23473Command/setupheader2017-09-04T15:19:41Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=setupheader<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupheader<span class="first" style="color:red;">[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td><strong>text</strong> margin edge </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:state|state]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:stop|stop]] [[Command/value:start|start]] [[Command/value:empty|empty]] [[Command/value:high|high]] [[Command/value:none|none]] [[Command/value:nomarking|nomarking]] [[Command/value:name|name]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:strut|strut]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:leftstyle|leftstyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:rightstyle|rightstyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:leftwidth|leftwidth]]</td><br />
<td>[[Command/value:dimension|dimension]]<br /><!--<br />
-->Limit the text inside the header to a certain dimension. <!--<br />
-->Setting this value may interfere with any additional {{cmd|delimitatetext}} or {{cmd|doboundtext}} performed inside the headers<br />
</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:rightwidth|rightwidth]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:before|before]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:after|after]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
The first argument is assumed to be "text" when it is left out. Text sets the position of the header and/or footer directly over or under the pagebody. Margin places the content in the margin of the document.<br />
<br />
The different <tt>state</tt>s and their effects:<br />
{|<br />
|<tt>start</tt>, <tt>stop</tt><br />
|switch headings on and off<br />
|-<br />
|<tt>none</tt><br />
|switch off for whole chapter<br />
|-<br />
|<tt>empty</tt><br />
|no heading on the first chapter page<br />
|-<br />
|<tt>high</tt><br />
|no heading on the first chapter page + expand textarea about space occupied by heading.<br />
|-<br />
|<tt>text</tt><br />
|some 'text' defined by<br />
<texcode><br />
\definetext[text][footer][pagenumber]<br />
</texcode><br />
or<br />
<texcode><br />
\definetext[text][footer][left][right]<br />
</texcode><br />
which is valid on the first chapter page<br />
|}<br />
<br />
Note that when setting the state, before or after each applies to all parts of the page and it is therefore best to set these by themselves as the first example below shows. For this reason state=high also affects the footer in that it removes the footer leaving no whitespace.<br />
<br />
== Examples ==<br />
<texcode>\setupheader[state=empty]</texcode><br />
<texcode>\setupheader[strut=yes,style=bold]</texcode><br />
<texcode>\setupheader[text][after=\vskip 4pt \hrule]</texcode><br />
<br />
=== Header with thin line bellow ===<br />
<br />
This is how to define header with thin line bellow, which does not appear on empty/blank page:<br />
<br />
<context mode=mkiv source=yes><br />
\setupheader<br />
[text]<br />
[before={\startframed[frame=off,bottomframe=on,framecolor=blue,]},<br />
after={\stopframed},<br />
]<br />
\setupheadertexts[Text left][Text right]<br />
<br />
\starttext<br />
Page 1<br />
\page[empty,blank]<br />
Page 2<br />
\stoptext<br />
</context><br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
{{cmd|setupheadertexts}}<br />
{{cmd|setupfooter}}<br />
{{cmd|setupfootertexts}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|setupheader]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Layers&diff=22855Layers2015-06-05T14:54:47Z<p>LuP: </p>
<hr />
<div>< [[Layout]] | [[Columns]] | [[Overlays]] | [[Logos]] | [[Collectors]] ><br />
<br />
'''Layers''' are ConTeXt's mechanism for absolute positioning of elements and other advanced techniques like switching elements on and off.<br />
<br />
There’s still no manual about them.<br />
<br />
==My first Layer==<br />
<br />
Define a layer that takes the whole page<br />
<texcode><br />
\definelayer[mybg] % name of the layer<br />
[x=0mm, y=0mm, % from upper left corner of paper<br />
width=\paperwidth, height=\paperheight] % let the layer cover the full paper<br />
</texcode><br />
<br />
Now you can put something in that layer:<br />
<texcode><br />
\setlayer[mybg] % name of the layer<br />
[hoffset=1cm, voffset=1cm] % placement (from upper left corner of the layer)<br />
{\framed[frame=on, width=3cm, height=2cm]{LAYER}} % the actual contents of the layer<br />
</texcode><br />
<br />
Activate the layer as a background:<br />
<texcode><br />
\setupbackgrounds[page][background=mybg]<br />
</texcode><br />
This command makes the contents of the layer appear only once after the background is activated. If you want to repeat the contents of the layer on each page, use the option <code>repeat=yes</code> in the {{cmd|definelayer}} command. Then the contents of the layer will be shown on every page. You can add to these contents by a new {{cmd|setlayer}}[mybg] command. To clear the accumulated contents use {{cmd|resetlayer}}[mybg]. To make the layer appear on each page, so that it can be populated with different content, set the option <code>state=repeat</code> in {{cmd|setupbackgrounds}}.<br />
<br />
Now you can test the whole thing:<br />
<context source=yes><br />
\setuppapersize[A10][A9,landscape]<br />
\setuparranging[2UP] % two pages side by side<br />
\showframe % show entire pages<br />
<br />
\definelayer[mybg] % name of the layer<br />
[x=0mm, y=0mm, % from upper left corner of paper<br />
width=\paperwidth, height=\paperheight, % let the layer cover the full paper<br />
]<br />
<br />
\setupbackgrounds[page][background=mybg]<br />
<br />
\setlayer[mybg] % name of the layer<br />
[hoffset=0.2cm, voffset=0.2cm] % placement (from upper left corner of the layer)<br />
{\framed[frame=on, width=2cm, height=1cm]{LAYER}} % the actual contents of the layer<br />
<br />
\starttext<br />
<br />
\dorecurse{2}{\page[empty]} % for testing, to get 2 pages, 1st with layer, 2nd without<br />
<br />
\stoptext<br />
<br />
</context><br />
<br />
<br />
==Placement==<br />
<br />
There are several possibilities for defining the placement of layer content:<br />
* x, y : offset from upper left corner of paper [=the current block; can sometimes be the text area instead of the page/paper!]<br />
* hoffset, voffset : offset from upper left corner of layer<br />
* corner : reference point, something like <code>{left, top}</code><br />
* location : alignment of the element relative to the corner, something like <code>{right, bottom}</code><br />
* preset : a named location, see below<br />
<br />
There are some "presets" for paper edge placement:<br />
<texcode><br />
% These four are defined by ConTeXt!<br />
\definelayerpreset [lefttop] [corner={left,top}, location={right,bottom}]<br />
\definelayerpreset [righttop] [corner={right,top}, location={left,bottom}]<br />
\definelayerpreset [leftbottom] [corner={left,bottom}, location={right,top}]<br />
\definelayerpreset [rightbottom] [corner={right,bottom}, location={left,top}]<br />
</texcode><br />
Similarly you can define your own presets.<br />
<br />
===Understanding "location" and "corner"===<br />
<br />
The layer is divided into a 2x2 matrix of squares, where 'x' is the center. <br />
This gets you a total of 3x3=9 different corners.<br />
<br />
o---o---o<br />
| | |<br />
o---x---o<br />
| | |<br />
o---o---o<br />
<br />
Now you choose one 'corner' (the reference point) for the placement of the content. The content is placed in relation to this point. <br />
The chosen 'corner' c is our new 'center point' (only for placement) now.<br />
<br />
With 'location' you define where (in relation to 'corner') the content is placed. <br />
Again you have nine different corners to choose from.<br />
<br />
==== Example: to make this clear ====<br />
<br />
Specifications <code>corner={top,right},location={bottom,right}</code> will place content in the area L (outside the original layer). <br />
Think about the 'corner' c as a magnetic grid point, where the content snaps to. <br />
The 'location' defines, from which direction we approach the point c.<br />
<br />
* x = layer center point<br />
* c = corner 'top,right'<br />
* d = location 'bottom right'<br />
* L = location (area)<br />
<br />
o---o---o<br />
| | |<br />
----o---c---o<br />
| | | L |<br />
----x---o---d<br />
| | |<br />
---------<br />
<br />
==== Example: placing a logo to the top right corner of the page ====<br />
<br />
<context source=yes text="gives:"><br />
\definelayer<br />
[Logo]<br />
[location={left,bottom},<br />
x=\paperwidth,y=0mm,<br />
hoffset=-5mm,voffset=5mm,<br />
]<br />
<br />
\setlayer[Logo]<br />
{\framed[width=3cm,height=1cm,background=color,backgroundcolor=lightgray]{Logo...}}<br />
<br />
\setupbackgrounds[page][background=Logo]<br />
<br />
\starttext<br />
%\showframe<br />
<br />
Some text...<br />
\stoptext<br />
</context><br />
<br />
==State==<br />
<br />
The available options for the "state" of a layer are:<br />
<br />
* start: layer appears only on the current page<br />
* stop: layer doesn't show up<br />
* repeat: layer prints on all pages<br />
* next: layer appears on the following page<br />
* continue: layer appears on all pages except the first<br />
<br />
==Line breaking and fixed size==<br />
<br />
You may experience cases where the defined size of your layer is ignored and you can’t get linebreaking or multiple lines at all.<br />
This is due to <cmd>setlayer</cmd> using <cmd>hbox</cmd> internally. You can work around the problem using <cmd>setlayerframed</cmd>:<br />
<br />
<context source=yes><br />
\setuppapersize[A6]<br />
<br />
\definelayer[AddressBg][<br />
x=20mm, y=30mm, <br />
width=65mm, height=30mm, <br />
state=start] % size is ignored!<br />
\setupbackgrounds[paper][<br />
setups=ALayer, <br />
background=AddressBg, <br />
state=start]<br />
<br />
\starttext<br />
\strut<br />
\startsetups ALayer<br />
\setlayer[AddressBg] % Change this to \setlayerframed to get it to work<br />
[width=65mm, height=30mm,<br />
frame=off,<br />
hoffset=0mm, voffset=0mm,<br />
align=right] % You must set align to get multiple lines!<br />
{<br />
PRAGMA Advanced Document Engineering\crlf<br />
Mr. Hans Hagen (the wizard who wrote it all, \CONTEXT\ and everything else, <br />
with the help of his little elves)\crlf<br />
Ridderstraat 27\crlf<br />
8061GH Hasselt\crlf<br />
THE NETHERLANDS<br />
}<br />
\stopsetups<br />
\stoptext<br />
</context><br />
<br />
<br />
==Place labels on pictures==<br />
<br />
Layers can be used to put labels on pictures, alternative ways can be found in the [[manual:details.pdf| Details]] manual<br />
(see also [[Collectors]]).<br />
<br />
<context source="yes"><br />
\setupexternalfigures[location={local,default}]<br />
% (necessary for the wiki conTeXt live processor)<br />
<br />
\definelayer [figure][width=\overlaywidth,height=\overlayheight]<br />
\defineoverlay[figure][{\directsetup{figure}\tightlayer[figure]}]<br />
<br />
\setupcolors[state=start]<br />
<br />
\starttext<br />
<br />
\startsetups figure<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=rightbottom,<br />
x=.25\layerwidth,<br />
y=.25\layerheight]<br />
{\green HERE}<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=leftbottom,<br />
x=.15\layerwidth,<br />
y=.35\layerheight]<br />
{\red THERE}<br />
<br />
\stopsetups<br />
<br />
\externalfigure[cow][background={foreground,figure},width=4cm,height=3cm]<br />
<br />
\stoptext<br />
</context><br />
<br />
==Use dynamic content==<br />
<br />
The content of layer is fixed after your set it and will appear in the same way on each page.<br />
<br />
<texcode><br />
\definelayer<br />
[pagenumber]<br />
[width=\paperwidth,<br />
height=\paperheight,<br />
preset=middle,<br />
state=repeat]<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\setupbackgrounds[page][background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]} % Every page will say "Page 1"<br />
\stoptext<br />
</texcode><br />
<br />
This is not always what you desire like in the example above, where on each page the current page number should be shown and not the number from the first page.<br />
<br />
To recalculate the content on each new page you have to enclose the <cmd>setlayer</cmd> settings within <cmd>startsetups</cmd> ... <cmd>stopsetups</cmd> and<br />
write <code>\setupbackgrounds[page][setups=setupname,background=layername]</code> in your document.<br />
<br />
<texcode><br />
\definelayer<br />
[pagenumber]<br />
[width=\paperwidth,<br />
height=\paperheight,<br />
preset=middle]<br />
<br />
\startsetups layer<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\stopsetups<br />
<br />
\setupbackgrounds[page][setups=layer,background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]} % You get "Page 1, Page 2" etc.<br />
\stoptext<br />
</texcode><br />
<br />
<br />
Another solution was given by Wolfgang on the mailing list on February 21, 2012. He writes: ''Here is a slightly different version which is better when you need more dynamic layers.''<br />
<br />
<texcode><br />
<br />
\definelayer [pagenumber][width=\overlaywidth,height=\overlayheight,preset=middle]<br />
\defineoverlay[pagenumber][\texsetup{layer}]<br />
<br />
\startsetups layer<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\tightlayer[pagenumber]<br />
<br />
\stopsetups<br />
<br />
\setupbackgrounds[page][setups=layer,background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]}<br />
\stoptext<br />
<br />
</texcode><br />
<br />
== Layers and the delayed font mechanism ==<br />
<br />
Until some years ago the Latin Modern font was always automatically<br />
loaded, regardless of the users choice of font. Font loading takes a<br />
considerable amount of time (check the stats at the end of a context<br />
run to get an idea). This led to the question:<br />
<br />
“Why start loading a big, complex font like Latin Modern before we<br />
know which font the user actually wants to use and waste several<br />
seconds on it, just to start loading the users choice afterwards?”<br />
<br />
The answer was:<br />
<br />
”We delay loading the font until we know which font the user wants<br />
to use. If the user doesn't tell us, then we fall back to Latin<br />
Modern.”<br />
<br />
The body font is set up in the setup area (the part above<br />
<code>\starttext</code>). That, in turn, means that when having reached<br />
<code>\starttext</code>, the users choice of font is known and can be loaded. It<br />
is more efficient if a font other then Latin Modern is used.<br />
<br />
One drawback is that typeset text in the setup area has no font<br />
setup and will fall back to Latin Modern Mono. Usually no text is<br />
typeset in the setup area. However, layers are an exception and<br />
a font needs to be set up beforehand.<br />
<br />
== See Also ==<br />
<br />
* Some applications in the [[manual:details.pdf|Details]] manual<br />
* [[Sample documents]]: [[BusinessCard]] and [[Letter style]]<br />
* Source: [[source:pack-lyr.mkii|pack-lyr.mkii]] or [[source:pack-lyr.mkiv|pack-lyr.mkiv]]<br />
* Example of [[Alternating backgrounds and repeating layers]] and [[Draft Watermark]]<br />
* [http://www.ntg.nl/pipermail/ntg-context/2013/070935.html Layer vs. overlay] by Wolfgang<br />
<br />
{{todo|We need a lot of documentation and samples for this complicated subject.}}<br />
<br />
<br />
[[Category:Graphics]] [[Category:Layers]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupheadertexts&diff=22763Command/setupheadertexts2015-03-17T10:03:52Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=setupheadertexts<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupheadertexts<span class="first" style="color:red;">[...]</span><span class="second" >[...]</span><span class="third" >[...]</span><span class="fourth" style="background-color:yellow;">[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td><strong>text</strong> on the left handed side of odd pages </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td><strong>text</strong> on the right handed side of odd pages </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td><strong>text</strong> on the right handed side of even pages </td><br />
</tr><br />
<tr valign="top" class="fourth" style="background-color:yellow;"><br />
<td class="cmd">[...]</td><br />
<td><strong>text</strong> on the left handed side of even pages </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description ==<br />
Place headers and footers with the commands \setupheadertexts and {{cmd|setupfootertexts}}.<br />
<br />
These commands take 4 arguments. The first is for the left handed side on odd pages, the second for the right handed side on odd pages, the third for the right handed side on even pages, and the fourth for the left handed side on even pages.<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
This example produces the same header on odd and even pages.<br />
<br />
<texcode><br />
\setupheadertexts<br />
[{\getmarking[chapter]}] [{page \pagenumber}]<br />
[{page \pagenumber}] [{\getmarking[chapter]}]<br />
\setuppagenumbering[location=]<br />
</texcode><br />
<br />
'''Note:''' '''\setuppagenumbering[location=]''' supresses the default output (i.e. centered in header) of the page number on every page.<br />
<br />
=== Multiline header ===<br />
<br />
<texcode><br />
\startsetups[headertext]<br />
\startframed[frame=off,align=flushleft,width=fit]<br />
abc\\<br />
def\\<br />
ghi\\<br />
jkl<br />
\stopframed<br />
\stopsetups<br />
<br />
\setupheadertexts[\directsetup{headertext}]<br />
<br />
\starttext<br />
aaa<br />
\stoptext<br />
</texcode><br />
<br />
(The result is not shown as headers - here, on Wiki - are trimmed out from the produced .pdf, so there is nothing to show.)<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
*{{cmd|setupfootertexts}}<br />
*{{cmd|setupheader}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Texts|setupheadertexts]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=File:Item-SpecShape.jpg&diff=22498File:Item-SpecShape.jpg2014-05-30T07:54:36Z<p>LuP: </p>
<hr />
<div></div>LuPhttps://wiki.contextgarden.net/index.php?title=Tabulate&diff=22486Tabulate2014-05-13T09:31:11Z<p>LuP: </p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
<br />
=Summary=<br />
<br />
{{cmd|starttabulate}} is a versatile table environment.<br />
It supports ''paragraphs'' in cells, ''vertical rules'' (for<br />
those typographically less demanding jobs&nbsp;…), and<br />
''colorization'' of those rules, the background of fields as well<br />
as the text itself.<br />
<br />
'''Warning''': When you want to use tables with macros use \starttable and \stoptable. \starttabulate and \stoptabulate does not work correctly with macros.<br />
<br />
=Basic commands=<br />
<br />
The control sequence <tt>\starttabulate[#1]</tt> takes a layout<br />
string as optional argument.<br />
As is common with tables in TeX-based typesetting, this string<br />
(in its basic variant) consists primarily of the ''bar''<br />
character (“<tt>|</tt>”) as delimiter for columns,<br />
and of the letters <tt>c</tt>, <tt>l</tt>, as well as <tt>r</tt>,<br />
denoting the ''alignment'' within cells of this row.<br />
<br />
For instance consider a two-column table: if any text in the<br />
first column should be right aligned (''real''<br />
[[right and left|<tt>flushright</tt>]]) and the second column<br />
left aligned, the corresponding format string would be<br />
<tt>|l|r|</tt>.<br />
''NB'': those bars, as stated above, denote cell limits only<br />
&ndash; ''not'' vertical lines.<br />
<br />
<!--<br />
- wtf this listing was full of <tab> chars‽ Was this supposed<br />
- to be a bad pun on *tabulate*?<br />
--><br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\TB[halfline]<br />
\NC \NC bigger vertical space \NC\NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
|<br />
|<context><br />
\setuppapersize[A5]<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\TB[halfline]<br />
\NC \NC bigger vertical space \NC\NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
* <tt>HL</tt> draws a horizontal rule,<br />
* <tt>NC</tt> marks a new column (or new cell),<br />
* <tt>NR</tt> starts a new row,<br />
* <tt>NB</tt> 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);<br />
* <tt>TB</tt> (= "Table Blank") adds some vertical space between rows -- see an example bellow.<br />
<br />
<br />
When using fixed width, you can use values relative to the<br />
current page-width. For example: if you want the previous table<br />
take up all the width and having the second column taking three<br />
quarters of the space, change the starttabulate to:<br />
<texcode><br />
\starttabulate[|rw(.25\textwidth)|lw(.75\textwidth)|]<br />
</texcode><br />
<br />
=Horizontal centering table on the page=<br />
<br />
(Solution from the mailing list)<br />
<br />
<context source=yes><br />
This is a very long text, longer than the width of the table.<br />
It must be long enough to flow to the next line to see the effect.<br />
<br />
\placetable[force,none]{}{%<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC I want this table \NC aligned in the center.\NC\NR<br />
\HL<br />
\stoptabulate<br />
}</context><br />
<br />
This can also be done with the start/stop syntax (showing only source here, since it does not compile on the wiki):<br />
<br />
<context source=yes><br />
This is a very long text, longer than the width of the table.<br />
It must be long enough to flow to the next line to see the effect.<br />
<br />
\startplacetable[location=force,number=no]<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC I want this table \NC aligned in the center.\NC\NR<br />
\HL<br />
\stoptabulate<br />
\stopplacetable<br />
</context><br />
<br />
=Spanning Multiple Pages=<br />
<br />
Tabulate may extend to adjacient pages if needed.<br />
To achieve this the argument <tt>split</tt> must be set to<br />
''true''.<br />
''NB'': the difference between setting and unsetting this<br />
argument may not be visible on the first few pages. Rather, it<br />
seems to affect the ''end'' of the environment.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<br />
==Titles==<br />
<br />
A tabulating environment can have an optional name which will be<br />
repeated above at every page break that occurs inside the table.<br />
This name needs to be specified as the argument of the<br />
<tt>title</tt> key of <tt>\setuptabulate</tt>.<br />
The <tt>header</tt> key has to be set to <em>text</em> for this<br />
to work.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<!--<br />
- ==Headers and Footers==<br />
- As I couldn’t get footers running I just comment this and<br />
- leave it to whoever discovers the trick to activate them.<br />
- (The <tt>footer=</tt> key seems to be implemented for<br />
- “\setuptabulate” but I couldn’t notice any effect.<br />
--><br />
<br />
==Headers==<br />
Tabulate supports header rows that can be repeated over new table<br />
pages instead of the title.<br />
There is a separate environment <tt>\starttablehead</tt> where<br />
this header row has to be specified in advance of its use in a<br />
tabulation.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \NC \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \NC \AR<br />
\NC l \NC left aligned \NC \AR<br />
\NC r \NC right aligned \NC \AR<br />
\stoptabulate<br />
</texcode><br />
|<br />
| <context><br />
\setuppapersize[A5]<br />
<br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \AR<br />
\NC l \NC left aligned \AR<br />
\NC r \NC right aligned \AR<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
=Individualizing the Tabulate Look=<br />
<br />
Hans initially announced support for vertical lines and colors on<br />
the mailing list.[http://archive.contextgarden.net/message/20101117.123950.739657a7.en.html]<br />
<br />
==Rules==<br />
<br />
===Horizontal Rules===<br />
<br />
As already demonstrated above, the <tt>\HL</tt> statement inserts<br />
a hairline after the current line.<br />
This particularly useful when demarking header and footer rows or<br />
separated parts of a table that should not be as closely<br />
associated as the rows between the rules.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</texcode><br />
| <context><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
Context supports different categories of rules that can be<br />
configured individually in order to discern various applications.<br />
Their behaviour accounts for the designated use, e.&nbsp;g.<br />
<tt>\ML</tt> (mid rules) are intended to be deployed between<br />
ordinary rows of the table body and will prevent page breaks<br />
&ndash; no way you’d end up with a rogue hairline desecrating<br />
the bottom of your page’s text area.<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Type !! Description<br />
|-<br />
|<tt>\HL</tt> || standard horizontal rule;<br />
|-<br />
|<tt>\FL</tt> || first rule;<br />
|-<br />
|<tt>\ML</tt> || mid rule;<br />
|-<br />
|<tt>\LL</tt> || bottom rule;<br />
|-<br />
|<tt>\LL</tt> and <tt>\TL</tt> || bottom rule;<br />
|-<br />
|<tt>\BL</tt> || last rule.<br />
|}<br />
<br />
Additionally, there is an options <tt>rulecolor</tt> for<br />
<tt>\setuptabulate</tt> that allows for those rules to be tinted.<br />
<br />
<texcode><br />
\setuptabulate[rulecolor=red]<br />
<br />
\starttabulate[|r|c|l|] <br />
\FL<br />
\NC first row \NC test \NC test \NC\NR <br />
\ML<br />
\NC rows in \NC test \NC test \NC\NR <br />
\NC between \NC test \NC test \NC\NR <br />
\LL <br />
\NC last row \NC test \NC test \NC\NR <br />
\BL<br />
\stoptabulate<br />
</texcode><br />
<br />
Other types can be discovered in the source<br />
([[source:tabl-tbl.mkiv|tabl-tbl.mkiv]]).<br />
<br />
===Vertical Rules===<br />
<br />
The <tt>\VL</tt> command serves as a replacement for <tt>\NC</tt><br />
to mark a cell border wherever a vertical rule may be desired (if<br />
they are to be desired at all from a typographical point of<br />
view).<br />
<br />
<texcode><br />
\starttabulate[||||] <br />
\NC test \VL test \VL test \VL\NR <br />
\VL test \NC test \VL test \VL\NR <br />
\VL test \VL test \NC test \VL\NR <br />
\VL test \VL test \VL test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
==Coloring==<br />
<br />
The following elements can be colorized: rules, cell backgrounds,<br />
and, obviously, common text.<br />
<br />
===Colorizing Rules===<br />
<br />
For ''horizontal rules'' see above.<br />
<br />
For ''vertical rules'', <tt>\VL</tt> takes a defined color as an<br />
optional argument.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\VL test \VL[red] red rule \VL test \VL \NR <br />
\VL test \VL[green] green rule \VL test \VL \NR <br />
\VL test \VL[blue] blue rule \VL test \VL \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
===Colorizing Backgrounds & Text===<br />
Backgrounds and text can be colorized either on column basis or<br />
individually by cell.<br />
<br />
There are five color-specific control sequences:<br />
{|<br />
|<tt>CR</tt> || color is applied to the background of the text and the remaining space on the right.<br />
|-<br />
|<tt>CC</tt> || color is applied to the background of the text only.<br />
|-<br />
|<tt>CM</tt> || color is applied to the background of the text and the remaining space on both sides.<br />
|-<br />
|<tt>CL</tt> || color is applied to the background of the text and the remaining space on the left.<br />
|-<br />
|<tt>CT</tt> || color is applied to the text itself - in other words, the "foreground color."<br />
|}<br />
These are to complement the normal table layout expression (the<br />
first argument to <tt>\starttabulate</tt>.<br />
Thus, in order to colorize a four column table with the initial<br />
layout <tt>|c|c|c|c|</tt> it will have to be modified as follows:<br />
<texcode><br />
\starttabulate[|CR{red}c|CC{yellow}c|CM{green}c|CL{blue}c|] <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
Those control sequences, if applied within the table body, can<br />
replace the ordinary <tt>\NC</tt>, allowing individual cells to<br />
be colorized.<br />
<texcode><br />
\starttabulate[|c|c|c|c|c|c|]<br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \CM[blue] d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \CM[blue] i \CM[blue] d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
'''caveat emptor'''! The background coloring does apply only to<br />
the ''first'' row of a paragraph cell. Any other cell will come<br />
out colorless. If you need to color an entire multi-line cell,<br />
you will need to switch to another<br />
[[Tables Overview|tabulation variant]].<br />
<br />
===Colorizing Cell Text===<br />
''Normal text'' inside cells gets its color via the<br />
[[Color|standard coloring commands]], or by the <br />
shorter variant described above.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC {\colored[red] test} \NC test \NC\NR <br />
\NC test \NC {\colored[green] test} \NC test \NC\NR <br />
\NC test \NC {\colored[blue] test} \NC test \NC\NR <br />
\NC test \NC {\colored[cyan] test} \NC test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
== Vertical Distance Between Rows ==<br />
<br />
<!--<br />
There does not seem to be an official interface for<br />
vertical skips.<br />
Manually placed <code>\blank</code>s are<br />
<code>\unskipped</code> on purpose.<br />
However, as expected there is a token list<br />
<code>\t_tabl_tabulate_every_after_row</code> that is<br />
placed after a line is finished.<br />
So, in order to get a vertical spacing of half a baseline<br />
distance you can use this code:<br />
<br />
<texcode><br />
\unprotect<br />
\appendtoks<br />
\blank[halfline]<br />
\to \t_tabl_tabulate_every_after_row<br />
\protect<br />
</texcode><br />
<br />
--><br />
<br />
<context mode=mkiv source=yes><br />
\starttabulate<br />
\NC one \NC two \NC\NR <br />
\NC two \NC three \NC\NR <br />
\TB[halfline]<br />
\NC four \NC five \NC\NR <br />
\TB[line]<br />
\NC four \NC five \NC\NR <br />
\TB[1cm]<br />
\NC eight \NC nine \NC\NR <br />
\stoptabulate<br />
</context><br />
<br />
=Using math mode=<br />
<br />
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:<br />
<br />
<texcode>\starttabulate[|l|l|]<br />
\HL<br />
\NN 10e-3 \NN 10e+3 \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
instead of<br />
<br />
<texcode><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC $10\cdot 10^{-3}$ \NC $10 \cdot 10^3$ \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
although both variants do work.<br />
<br />
<br />
=Itemization inside a tabulation=<br />
<br />
<!--(added by Willi Egger 04-08-2011)--><br />
<br />
The following issue is related to MKIV:<br />
<br />
When using an itemization inside a tabulation where one uses also the <br />
<tt>\head</tt> 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:<br />
<texcode>\tabulatesplitlinemode \plustwo</texcode><br />
<br />
The following code provided by Wolfgang Schuster demonstrates the problem: Compile with and without the line <tt>\tabulatesplitlinemode\plustwo</tt><br />
<br />
<texcode><br />
\tabulatesplitlinemode \plustwo<br />
\starttabulate[|p|]<br />
\NC<br />
one \par<br />
\blank[penalty:10000]<br />
two \par<br />
\blank[penalty:10000]<br />
three<br />
\NC\NR<br />
\stoptabulate<br />
</texcode><br />
<br />
<br />
=See also=<br />
<br />
* More features are constantly added and documented in the {{src|tabl-tbl.mkiv|source}}.<br />
* {{cmd|starttabulate}}<br />
* [[TABLE|Natural Tables]]<br />
* {{cmd|starttable}}<br />
<br />
[[Category:Tables]]<br />
tt>\head</div>LuPhttps://wiki.contextgarden.net/index.php?title=Tabulate&diff=22483Tabulate2014-05-13T07:21:02Z<p>LuP: </p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
<br />
=Summary=<br />
<br />
{{cmd|starttabulate}} is a versatile table environment.<br />
It supports ''paragraphs'' in cells, ''vertical rules'' (for<br />
those typographically less demanding jobs&nbsp;…), and<br />
''colorization'' of those rules, the background of fields as well<br />
as the text itself.<br />
<br />
'''Warning''': When you want to use tables with macros use \starttable and \stoptable. \starttabulate and \stoptabulate does not work correctly with macros.<br />
<br />
=Basic commands=<br />
<br />
The control sequence <tt>\starttabulate[#1]</tt> takes a layout<br />
string as optional argument.<br />
As is common with tables in TeX-based typesetting, this string<br />
(in its basic variant) consists primarily of the ''bar''<br />
character (“<tt>|</tt>”) as delimiter for columns,<br />
and of the letters <tt>c</tt>, <tt>l</tt>, as well as <tt>r</tt>,<br />
denoting the ''alignment'' within cells of this row.<br />
<br />
For instance consider a two-column table: if any text in the<br />
first column should be right aligned (''real''<br />
[[right and left|<tt>flushright</tt>]]) and the second column<br />
left aligned, the corresponding format string would be<br />
<tt>|l|r|</tt>.<br />
''NB'': those bars, as stated above, denote cell limits only<br />
&ndash; ''not'' vertical lines.<br />
<br />
<!--<br />
- wtf this listing was full of <tab> chars‽ Was this supposed<br />
- to be a bad pun on *tabulate*?<br />
--><br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\TB[halfline]<br />
\NC \NC bigger vertical space \NC\NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
|<br />
|<context><br />
\setuppapersize[A5]<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\TB[halfline]<br />
\NC \NC bigger vertical space \NC\NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
* <tt>HL</tt> draws a horizontal rule,<br />
* <tt>NC</tt> marks a new column (or new cell),<br />
* <tt>NR</tt> starts a new row,<br />
* <tt>NB</tt> 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);<br />
* <tt>TB</tt> (= "Table Blank") adds some vertical space between rows -- see an example bellow.<br />
<br />
<br />
When using fixed width, you can use values relative to the<br />
current page-width. For example: if you want the previous table<br />
take up all the width and having the second column taking three<br />
quarters of the space, change the starttabulate to:<br />
<texcode><br />
\starttabulate[|rw(.25\textwidth)|lw(.75\textwidth)|]<br />
</texcode><br />
<br />
=Horizontal centering table on the page=<br />
<br />
(Solution by Mikael P. Sundqvist:)<br />
<br />
<context source=yes><br />
This is a very long text, longer than the width of the table.<br />
It must be long enough to flow to the next line to see the effect.<br />
<br />
\placetable[force,none]{none}{%<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC I want this table \NC aligned in the center.\NR<br />
\HL<br />
\stoptabulate<br />
}</context><br />
<br />
=Spanning Multiple Pages=<br />
<br />
Tabulate may extend to adjacient pages if needed.<br />
To achieve this the argument <tt>split</tt> must be set to<br />
''true''.<br />
''NB'': the difference between setting and unsetting this<br />
argument may not be visible on the first few pages. Rather, it<br />
seems to affect the ''end'' of the environment.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<br />
==Titles==<br />
<br />
A tabulating environment can have an optional name which will be<br />
repeated above at every page break that occurs inside the table.<br />
This name needs to be specified as the argument of the<br />
<tt>title</tt> key of <tt>\setuptabulate</tt>.<br />
The <tt>header</tt> key has to be set to <em>text</em> for this<br />
to work.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<!--<br />
- ==Headers and Footers==<br />
- As I couldn’t get footers running I just comment this and<br />
- leave it to whoever discovers the trick to activate them.<br />
- (The <tt>footer=</tt> key seems to be implemented for<br />
- “\setuptabulate” but I couldn’t notice any effect.<br />
--><br />
<br />
==Headers==<br />
Tabulate supports header rows that can be repeated over new table<br />
pages instead of the title.<br />
There is a separate environment <tt>\starttablehead</tt> where<br />
this header row has to be specified in advance of its use in a<br />
tabulation.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \NC \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \NC \AR<br />
\NC l \NC left aligned \NC \AR<br />
\NC r \NC right aligned \NC \AR<br />
\stoptabulate<br />
</texcode><br />
|<br />
| <context><br />
\setuppapersize[A5]<br />
<br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \AR<br />
\NC l \NC left aligned \AR<br />
\NC r \NC right aligned \AR<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
=Individualizing the Tabulate Look=<br />
<br />
Hans initially announced support for vertical lines and colors on<br />
the mailing list.[http://archive.contextgarden.net/message/20101117.123950.739657a7.en.html]<br />
<br />
==Rules==<br />
<br />
===Horizontal Rules===<br />
<br />
As already demonstrated above, the <tt>\HL</tt> statement inserts<br />
a hairline after the current line.<br />
This particularly useful when demarking header and footer rows or<br />
separated parts of a table that should not be as closely<br />
associated as the rows between the rules.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</texcode><br />
| <context><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
Context supports different categories of rules that can be<br />
configured individually in order to discern various applications.<br />
Their behaviour accounts for the designated use, e.&nbsp;g.<br />
<tt>\ML</tt> (mid rules) are intended to be deployed between<br />
ordinary rows of the table body and will prevent page breaks<br />
&ndash; no way you’d end up with a rogue hairline desecrating<br />
the bottom of your page’s text area.<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Type !! Description<br />
|-<br />
|<tt>\HL</tt> || standard horizontal rule;<br />
|-<br />
|<tt>\FL</tt> || first rule;<br />
|-<br />
|<tt>\ML</tt> || mid rule;<br />
|-<br />
|<tt>\LL</tt> || bottom rule;<br />
|-<br />
|<tt>\LL</tt> and <tt>\TL</tt> || bottom rule;<br />
|-<br />
|<tt>\BL</tt> || last rule.<br />
|}<br />
<br />
Additionally, there is an options <tt>rulecolor</tt> for<br />
<tt>\setuptabulate</tt> that allows for those rules to be tinted.<br />
<br />
<texcode><br />
\setuptabulate[rulecolor=red]<br />
<br />
\starttabulate[|r|c|l|] <br />
\FL<br />
\NC first row \NC test \NC test \NC\NR <br />
\ML<br />
\NC rows in \NC test \NC test \NC\NR <br />
\NC between \NC test \NC test \NC\NR <br />
\LL <br />
\NC last row \NC test \NC test \NC\NR <br />
\BL<br />
\stoptabulate<br />
</texcode><br />
<br />
Other types can be discovered in the source<br />
([[source:tabl-tbl.mkiv|tabl-tbl.mkiv]]).<br />
<br />
===Vertical Rules===<br />
<br />
The <tt>\VL</tt> command serves as a replacement for <tt>\NC</tt><br />
to mark a cell border wherever a vertical rule may be desired (if<br />
they are to be desired at all from a typographical point of<br />
view).<br />
<br />
<texcode><br />
\starttabulate[||||] <br />
\NC test \VL test \VL test \VL\NR <br />
\VL test \NC test \VL test \VL\NR <br />
\VL test \VL test \NC test \VL\NR <br />
\VL test \VL test \VL test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
==Coloring==<br />
<br />
The following elements can be colorized: rules, cell backgrounds,<br />
and, obviously, common text.<br />
<br />
===Colorizing Rules===<br />
<br />
For ''horizontal rules'' see above.<br />
<br />
For ''vertical rules'', <tt>\VL</tt> takes a defined color as an<br />
optional argument.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\VL test \VL[red] red rule \VL test \VL \NR <br />
\VL test \VL[green] green rule \VL test \VL \NR <br />
\VL test \VL[blue] blue rule \VL test \VL \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
===Colorizing Backgrounds & Text===<br />
Backgrounds and text can be colorized either on column basis or<br />
individually by cell.<br />
<br />
There are five color-specific control sequences:<br />
{|<br />
|<tt>CR</tt> || color is applied to the background of the text and the remaining space on the right.<br />
|-<br />
|<tt>CC</tt> || color is applied to the background of the text only.<br />
|-<br />
|<tt>CM</tt> || color is applied to the background of the text and the remaining space on both sides.<br />
|-<br />
|<tt>CL</tt> || color is applied to the background of the text and the remaining space on the left.<br />
|-<br />
|<tt>CT</tt> || color is applied to the text itself - in other words, the "foreground color."<br />
|}<br />
These are to complement the normal table layout expression (the<br />
first argument to <tt>\starttabulate</tt>.<br />
Thus, in order to colorize a four column table with the initial<br />
layout <tt>|c|c|c|c|</tt> it will have to be modified as follows:<br />
<texcode><br />
\starttabulate[|CR{red}c|CC{yellow}c|CM{green}c|CL{blue}c|] <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
Those control sequences, if applied within the table body, can<br />
replace the ordinary <tt>\NC</tt>, allowing individual cells to<br />
be colorized.<br />
<texcode><br />
\starttabulate[|c|c|c|c|c|c|]<br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \CM[blue] d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \CM[blue] i \CM[blue] d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
'''caveat emptor'''! The background coloring does apply only to<br />
the ''first'' row of a paragraph cell. Any other cell will come<br />
out colorless. If you need to color an entire multi-line cell,<br />
you will need to switch to another<br />
[[Tables Overview|tabulation variant]].<br />
<br />
===Colorizing Cell Text===<br />
''Normal text'' inside cells gets its color via the<br />
[[Color|standard coloring commands]], or by the <br />
shorter variant described above.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC {\colored[red] test} \NC test \NC\NR <br />
\NC test \NC {\colored[green] test} \NC test \NC\NR <br />
\NC test \NC {\colored[blue] test} \NC test \NC\NR <br />
\NC test \NC {\colored[cyan] test} \NC test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
== Vertical Distance Between Rows ==<br />
<br />
<!--<br />
There does not seem to be an official interface for<br />
vertical skips.<br />
Manually placed <code>\blank</code>s are<br />
<code>\unskipped</code> on purpose.<br />
However, as expected there is a token list<br />
<code>\t_tabl_tabulate_every_after_row</code> that is<br />
placed after a line is finished.<br />
So, in order to get a vertical spacing of half a baseline<br />
distance you can use this code:<br />
<br />
<texcode><br />
\unprotect<br />
\appendtoks<br />
\blank[halfline]<br />
\to \t_tabl_tabulate_every_after_row<br />
\protect<br />
</texcode><br />
<br />
--><br />
<br />
<context mode=mkiv source=yes><br />
\starttabulate<br />
\NC one \NC two \NC\NR <br />
\NC two \NC three \NC\NR <br />
\TB[halfline]<br />
\NC four \NC five \NC\NR <br />
\TB[line]<br />
\NC four \NC five \NC\NR <br />
\TB[1cm]<br />
\NC eight \NC nine \NC\NR <br />
\stoptabulate<br />
</context><br />
<br />
=Using math mode=<br />
<br />
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:<br />
<br />
<texcode>\starttabulate[|l|l|]<br />
\HL<br />
\NN 10e-3 \NN 10e+3 \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
instead of<br />
<br />
<texcode><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC $10\cdot 10^{-3}$ \NC $10 \cdot 10^3$ \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
although both variants do work.<br />
<br />
<br />
=Itemization inside a tabulation=<br />
<br />
<!--(added by Willi Egger 04-08-2011)--><br />
<br />
The following issue is related to MKIV:<br />
<br />
When using an itemization inside a tabulation where one uses also the <br />
<tt>\head</tt> 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:<br />
<texcode>\tabulatesplitlinemode \plustwo</texcode><br />
<br />
The following code provided by Wolfgang Schuster demonstrates the problem: Compile with and without the line <tt>\tabulatesplitlinemode\plustwo</tt><br />
<br />
<texcode><br />
\tabulatesplitlinemode \plustwo<br />
\starttabulate[|p|]<br />
\NC<br />
one \par<br />
\blank[penalty:10000]<br />
two \par<br />
\blank[penalty:10000]<br />
three<br />
\NC\NR<br />
\stoptabulate<br />
</texcode><br />
<br />
<br />
=See also=<br />
<br />
* More features are constantly added and documented in the {{src|tabl-tbl.mkiv|source}}.<br />
* {{cmd|starttabulate}}<br />
* [[TABLE|Natural Tables]]<br />
* {{cmd|starttable}}<br />
<br />
[[Category:Tables]]<br />
tt>\head</div>LuPhttps://wiki.contextgarden.net/index.php?title=Layers&diff=21874Layers2013-06-10T07:47:49Z<p>LuP: </p>
<hr />
<div>< [[Layout]] | [[Columns]] | [[Overlays]] | [[Logos]] | [[Collectors]] ><br />
<br />
'''Layers''' are ConTeXt's mechanism for absolute positioning of elements and other advanced techniques like switching elements on and off.<br />
<br />
There's still no manual about them.<br />
<br />
==My first Layer==<br />
<br />
Define a layer that takes the whole page<br />
<texcode><br />
\definelayer[mybg] % name of the layer<br />
[x=0mm, y=0mm, % from upper left corner of paper<br />
width=\paperwidth, height=\paperheight] % let the layer cover the full paper<br />
</texcode><br />
<br />
Now you can put something in that layer:<br />
<texcode><br />
\setlayer[mybg] % name of the layer<br />
[hoffset=1cm, voffset=1cm] % placement (from upper left corner of the layer)<br />
{\framed[frame=on, width=3cm, height=2cm]{LAYER}} % the actual contents of the layer<br />
</texcode><br />
<br />
Activate the layer as a background:<br />
<texcode><br />
\setupbackgrounds[page][background=mybg]<br />
</texcode><br />
This command makes the contents of the layer appear only once after the background is activated. If you want to repeat the contents of the layer on each page, use the option <code>repeat=yes</code> in the {{cmd|definelayer}} command. Then the contents of the layer will be shown on every page. You can add to these contents by a new {{cmd|setlayer}}[mybg] command. To clear the accumulated contents use {{cmd|resetlayer}}>[mybg]. To make the layer appear on each page, so that it can be populated with different content, set the option <code>state=repeat</code> in {{cmd|setupbackgrounds}}.<br />
<br />
Now you can test the whole thing:<br />
<context source=yes><br />
\setuppapersize[A10][A9,landscape]<br />
\setuparranging[2UP] % two pages side by side<br />
\showframe % show entire pages<br />
<br />
\definelayer[mybg] % name of the layer<br />
[x=0mm, y=0mm, % from upper left corner of paper<br />
width=\paperwidth, height=\paperheight, % let the layer cover the full paper<br />
]<br />
<br />
\setupbackgrounds[page][background=mybg]<br />
<br />
\setlayer[mybg] % name of the layer<br />
[hoffset=0.2cm, voffset=0.2cm] % placement (from upper left corner of the layer)<br />
{\framed[frame=on, width=2cm, height=1cm]{LAYER}} % the actual contents of the layer<br />
<br />
\starttext<br />
<br />
\dorecurse{2}{\page[empty]} % for testing, to get 2 pages, 1st with layer, 2nd without<br />
<br />
\stoptext<br />
<br />
</context><br />
<br />
<br />
==Placement==<br />
<br />
There are several possibilities for defining the placement of layer content:<br />
* x, y : offset from upper left corner of paper [=the current block; can sometimes be the text area instead of the page/paper!]<br />
* hoffset, voffset : offset from upper left corner of layer<br />
* corner : reference point, something like <code>{left, top}</code><br />
* location : alignment of the element relative to the corner, something like <code>{right, bottom}</code><br />
* preset : a named location, see below<br />
<br />
There are some "presets" for paper edge placement:<br />
<texcode><br />
% These four are defined by ConTeXt!<br />
\definelayerpreset [lefttop] [corner={left,top}, location={right,bottom}]<br />
\definelayerpreset [righttop] [corner={right,top}, location={left,bottom}]<br />
\definelayerpreset [leftbottom] [corner={left,bottom}, location={right,top}]<br />
\definelayerpreset [rightbottom] [corner={right,bottom}, location={left,top}]<br />
</texcode><br />
Similarly you can define your own presets.<br />
<br />
===Understanding "location" and "corner"===<br />
<br />
The layer is divided into a 2x2 matrix of squares, where 'x' is the center. <br />
This gets you a total of 3x3=9 different corners.<br />
<br />
o---o---o<br />
| | |<br />
o---x---o<br />
| | |<br />
o---o---o<br />
<br />
Now you choose one 'corner' (the reference point) for the placement of the content. The content is placed in relation to this point. <br />
The chosen 'corner' c is our new 'center point' (only for placement) now.<br />
<br />
With 'location' you define where (in relation to 'corner') the content is placed. <br />
Again you have nine different corners to choose from.<br />
<br />
==== Example: to make this clear ====<br />
<br />
Specifications 'corner={top,right},location={bottom,right}' will place content in the area L (outside the original layer). <br />
Think about the 'corner' c as a magnetic grid point, where the content snaps to. <br />
The 'location' defines, from which direction we approach the point c.<br />
<br />
* x = layer center point<br />
* c = corner 'top,right'<br />
* d = location 'bottom right'<br />
* L = location (area)<br />
<br />
o---o---o<br />
| | |<br />
----o---c---o<br />
| | | L |<br />
----x---o---d<br />
| | |<br />
---------<br />
<br />
==== Example: placing a logo to the top right corner of the page ====<br />
<br />
<context source=yes text="Gives:"><br />
\definelayer<br />
[Logo]<br />
[location={left,bottom},<br />
x=\paperwidth,y=0mm,<br />
hoffset=-5mm,voffset=5mm,<br />
]<br />
<br />
\setlayer[Logo]<br />
{\framed[width=3cm,height=1cm,background=color,backgroundcolor=lightgray]{Logo...}}<br />
<br />
\setupbackgrounds[page][background=Logo]<br />
<br />
\starttext<br />
%\showframe<br />
<br />
Some text...<br />
\stoptext<br />
</context><br />
<br />
==State==<br />
<br />
The available options for the "state" of a layer are:<br />
<br />
* start: layer appears only on the current page<br />
* stop: layer doesn't show up<br />
* repeat: layer prints on all pages<br />
* next: layer appears on the following page<br />
* continue: layer appears on all pages except the first<br />
<br />
==Line breaking and fixed size==<br />
<br />
You may experience cases where the defined size of your layer is ignored and you can’t get linebreaking or multiple lines at all.<br />
This is due to <cmd>setlayer</cmd> using <cmd>hbox</cmd> internally. You can work around the problem using <cmd>setlayerframed</cmd>:<br />
<br />
<context source=yes><br />
\setuppapersize[A6]<br />
<br />
\definelayer[AddressBg][<br />
x=20mm, y=30mm, <br />
width=65mm, height=30mm, <br />
state=start] % size is ignored!<br />
\setupbackgrounds[paper][<br />
setups=ALayer, <br />
background=AddressBg, <br />
state=start]<br />
<br />
\starttext<br />
\strut<br />
\startsetups ALayer<br />
\setlayer[AddressBg] % Change this to \setlayerframed to get it to work<br />
[width=65mm, height=30mm,<br />
frame=off,<br />
hoffset=0mm, voffset=0mm,<br />
align=right] % You must set align to get multiple lines!<br />
{<br />
PRAGMA Advanced Document Engineering\crlf<br />
Mr. Hans Hagen (the wizard who wrote it all, \CONTEXT\ and everything else, <br />
with the help of his little elves)\crlf<br />
Ridderstraat 27\crlf<br />
8061GH Hasselt\crlf<br />
THE NETHERLANDS<br />
}<br />
\stopsetups<br />
\stoptext<br />
</context><br />
<br />
<br />
==Place labels on pictures==<br />
<br />
Layers can be used to put labels on pictures, alternative ways can be found in the [[manual:details.pdf| Details]] manual<br />
(see also [[Collectors]]).<br />
<br />
<context source="yes"><br />
\setupexternalfigures[location={local,default}]<br />
% (necessary for the wiki conTeXt live processor)<br />
<br />
\definelayer [figure][width=\overlaywidth,height=\overlayheight]<br />
\defineoverlay[figure][{\directsetup{figure}\tightlayer[figure]}]<br />
<br />
\setupcolors[state=start]<br />
<br />
\starttext<br />
<br />
\startsetups figure<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=rightbottom,<br />
x=.25\layerwidth,<br />
y=.25\layerheight]<br />
{\green HERE}<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=leftbottom,<br />
x=.15\layerwidth,<br />
y=.35\layerheight]<br />
{\red THERE}<br />
<br />
\stopsetups<br />
<br />
\externalfigure[cow][background={foreground,figure},width=4cm,height=3cm]<br />
<br />
\stoptext<br />
</context><br />
<br />
==Use dynamic content==<br />
<br />
The content of layer is fixed after your set it and will appear in the same way on each page.<br />
<br />
<texcode><br />
\definelayer<br />
[pagenumber]<br />
[width=\paperwidth,<br />
height=\paperheight,<br />
preset=middle,<br />
state=repeat]<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\setupbackgrounds[page][background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]} % Every page will say "Page 1"<br />
\stoptext<br />
</texcode><br />
<br />
This is not always what you desire like in the example above, where on each page the current page number should be shown and not the number from the first page.<br />
<br />
To recalculate the content on each new page you have to enclose the <cmd>setlayer</cmd> settings within <cmd>startsetups</cmd> ... <cmd>stopsetups</cmd> and<br />
write <code>\setupbackgrounds[page][setups=setupname,background=layername]</code> in your document.<br />
<br />
<texcode><br />
\definelayer<br />
[pagenumber]<br />
[width=\paperwidth,<br />
height=\paperheight,<br />
preset=middle]<br />
<br />
\startsetups layer<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\stopsetups<br />
<br />
\setupbackgrounds[page][setups=layer,background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]} % You get "Page 1, Page 2" etc.<br />
\stoptext<br />
</texcode><br />
<br />
<br />
Another solution was given by Wolfgang on the mailing list on February 21, 2012. He writes: ''Here is a slightly different version which is better when you need more dynamic layers.''<br />
<br />
<texcode><br />
<br />
\definelayer [pagenumber][width=\overlaywidth,height=\overlayheight,preset=middle]<br />
\defineoverlay[pagenumber][\texsetup{layer}]<br />
<br />
\startsetups layer<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\tightlayer[pagenumber]<br />
<br />
\stopsetups<br />
<br />
\setupbackgrounds[page][setups=layer,background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]}<br />
\stoptext<br />
<br />
</texcode><br />
<br />
== Layers and the delayed font mechanism ==<br />
<br />
Until some years ago the Latin Modern font was always automatically<br />
loaded, regardless of the users choice of font. Font loading takes a<br />
considerable amount of time (check the stats at the end of a context<br />
run to get an idea). This led to the question:<br />
<br />
“Why start loading a big, complex font like Latin Modern before we<br />
know which font the user actually wants to use and waste several<br />
seconds on it, just to start loading the users choice afterwards?”<br />
<br />
The answer was:<br />
<br />
”We delay loading the font until we know which font the user wants<br />
to use. If the user doesn't tell us, then we fall back to Latin<br />
Modern.”<br />
<br />
The body font is set up in the setup area (the part above<br />
<code>\starttext</code>). That, in turn, means that when having reached<br />
<code>\starttext</code>, the users choice of font is known and can be loaded. It<br />
is more efficient if a font other then Latin Modern is used.<br />
<br />
One drawback is that typeset text in the setup area has no font<br />
setup and will fall back to Latin Modern Mono. Usually no text is<br />
typeset in the setup area. However, layers are an exception and<br />
a font needs to be set up beforehand.<br />
<br />
== See Also ==<br />
<br />
* Some applications in the [[manual:details.pdf|Details]] manual<br />
* [[Sample documents]]: [[BusinessCard]] and [[Letter style]]<br />
* Source: [[source:pack-lyr.mkii|pack-lyr.mkii]] or [[source:pack-lyr.mkiv|pack-lyr.mkiv]]<br />
* Example of [[Alternating backgrounds and repeating layers]] and [[Draft Watermark]]<br />
* [http://www.ntg.nl/pipermail/ntg-context/2013/070935.html Layer vs. overlay] by Wolfgang<br />
<br />
{{todo|We need a lot of documentation and samples for this complicated subject.}}<br />
<br />
<br />
[[Category:Graphics]] [[Category:Layers]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Tabulate&diff=21785Tabulate2013-05-23T09:28:39Z<p>LuP: </p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
<br />
=Summary=<br />
<br />
{{cmd|starttabulate}} is a versatile table environment.<br />
It supports ''paragraphs'' in cells, ''vertical rules'' (for<br />
those typographically less demanding jobs&nbsp;…), and<br />
''colorization'' of those rules, the background of fields as well<br />
as the text itself.<br />
<br />
'''Warning''': When you want to use tables with macros use \starttable and \stoptable. \starttabulate and \stoptabulate does not work correctly with macros.<br />
<br />
=Basic commands=<br />
<br />
The control sequence <tt>\starttabulate[#1]</tt> takes a layout<br />
string as optional argument.<br />
As is common with tables in TeX-based typesetting, this string<br />
(in its basic variant) consists primarily of the ''bar''<br />
character (“<tt>|</tt>”) as delimiter for columns,<br />
and of the letters <tt>c</tt>, <tt>l</tt>, as well as <tt>r</tt>,<br />
denoting the ''alignment'' within cells of this row.<br />
<br />
For instance consider a two-column table: if any text in the<br />
first column should be right aligned (''real''<br />
[[right and left|<tt>flushright</tt>]]) and the second column<br />
left aligned, the corresponding format string would be<br />
<tt>|l|r|</tt>.<br />
''NB'': those bars, as stated above, denote cell limits only<br />
&ndash; ''not'' vertical lines.<br />
<br />
<!--<br />
- wtf this listing was full of <tab> chars‽ Was this supposed<br />
- to be a bad pun on *tabulate*?<br />
--><br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\TB[halfline]<br />
\NC \NC bigger vertical space \NC\NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
|<br />
|<context><br />
\setuppapersize[A5]<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\TB[halfline]<br />
\NC \NC bigger vertical space \NC\NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
* <tt>HL</tt> draws a horizontal rule,<br />
* <tt>NC</tt> marks a new column (or new cell),<br />
* <tt>NR</tt> starts a new row,<br />
* <tt>NB</tt> 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);<br />
* <tt>TB</tt> (= "Table Blank") adds some vertical space between rows -- see an example bellow.<br />
<br />
<br />
When using fixed width, you can use values relative to the<br />
current page-width. For example: if you want the previous table<br />
take up all the width and having the second column taking three<br />
quarters of the space, change the starttabulate to:<br />
<texcode><br />
\starttabulate[|rw(.25\textwidth)|lw(.75\textwidth)|]<br />
</texcode><br />
<br />
=Spanning Multiple Pages=<br />
<br />
Tabulate may extend to adjacient pages if needed.<br />
To achieve this the argument <tt>split</tt> must be set to<br />
''true''.<br />
''NB'': the difference between setting and unsetting this<br />
argument may not be visible on the first few pages. Rather, it<br />
seems to affect the ''end'' of the environment.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<br />
==Titles==<br />
<br />
A tabulating environment can have an optional name which will be<br />
repeated above at every page break that occurs inside the table.<br />
This name needs to be specified as the argument of the<br />
<tt>title</tt> key of <tt>\setuptabulate</tt>.<br />
The <tt>header</tt> key has to be set to <em>text</em> for this<br />
to work.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<!--<br />
- ==Headers and Footers==<br />
- As I couldn’t get footers running I just comment this and<br />
- leave it to whoever discovers the trick to activate them.<br />
- (The <tt>footer=</tt> key seems to be implemented for<br />
- “\setuptabulate” but I couldn’t notice any effect.<br />
--><br />
<br />
==Headers==<br />
Tabulate supports header rows that can be repeated over new table<br />
pages instead of the title.<br />
There is a separate environment <tt>\starttablehead</tt> where<br />
this header row has to be specified in advance of its use in a<br />
tabulation.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \NC \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \NC \AR<br />
\NC l \NC left aligned \NC \AR<br />
\NC r \NC right aligned \NC \AR<br />
\stoptabulate<br />
</texcode><br />
|<br />
| <context><br />
\setuppapersize[A5]<br />
<br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \AR<br />
\NC l \NC left aligned \AR<br />
\NC r \NC right aligned \AR<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
=Individualizing the Tabulate Look=<br />
<br />
Hans initially announced support for vertical lines and colors on<br />
the mailing list.[http://archive.contextgarden.net/message/20101117.123950.739657a7.en.html]<br />
<br />
==Rules==<br />
<br />
===Horizontal Rules===<br />
<br />
As already demonstrated above, the <tt>\HL</tt> statement inserts<br />
a hairline after the current line.<br />
This particularly useful when demarking header and footer rows or<br />
separated parts of a table that should not be as closely<br />
associated as the rows between the rules.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</texcode><br />
| <context><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
Context supports different categories of rules that can be<br />
configured individually in order to discern various applications.<br />
Their behaviour accounts for the designated use, e.&nbsp;g.<br />
<tt>\ML</tt> (mid rules) are intended to be deployed between<br />
ordinary rows of the table body and will prevent page breaks<br />
&ndash; no way you’d end up with a rogue hairline desecrating<br />
the bottom of your page’s text area.<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Type !! Description<br />
|-<br />
|<tt>\HL</tt> || standard horizontal rule;<br />
|-<br />
|<tt>\FL</tt> || first rule;<br />
|-<br />
|<tt>\ML</tt> || mid rule;<br />
|-<br />
|<tt>\LL</tt> || bottom rule;<br />
|-<br />
|<tt>\LL</tt> and <tt>\TL</tt> || bottom rule;<br />
|-<br />
|<tt>\BL</tt> || last rule.<br />
|}<br />
<br />
Additionally, there is an options <tt>rulecolor</tt> for<br />
<tt>\setuptabulate</tt> that allows for those rules to be tinted.<br />
<br />
<texcode><br />
\setuptabulate[rulecolor=red]<br />
<br />
\starttabulate[|r|c|l|] <br />
\FL<br />
\NC first row \NC test \NC test \NC\NR <br />
\ML<br />
\NC rows in \NC test \NC test \NC\NR <br />
\NC between \NC test \NC test \NC\NR <br />
\LL <br />
\NC last row \NC test \NC test \NC\NR <br />
\BL<br />
\stoptabulate<br />
</texcode><br />
<br />
Other types can be discovered in the source<br />
([[source:tabl-tbl.mkiv|tabl-tbl.mkiv]]).<br />
<br />
===Vertical Rules===<br />
<br />
The <tt>\VL</tt> command serves as a replacement for <tt>\NC</tt><br />
to mark a cell border wherever a vertical rule may be desired (if<br />
they are to be desired at all from a typographical point of<br />
view).<br />
<br />
<texcode><br />
\starttabulate[||||] <br />
\NC test \VL test \VL test \VL\NR <br />
\VL test \NC test \VL test \VL\NR <br />
\VL test \VL test \NC test \VL\NR <br />
\VL test \VL test \VL test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
==Coloring==<br />
<br />
The following elements can be colorized: rules, cell backgrounds,<br />
and, obviously, common text.<br />
<br />
===Colorizing Rules===<br />
<br />
For ''horizontal rules'' see above.<br />
<br />
For ''vertical rules'', <tt>\VL</tt> takes a defined color as an<br />
optional argument.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\VL test \VL[red] red rule \VL test \VL \NR <br />
\VL test \VL[green] green rule \VL test \VL \NR <br />
\VL test \VL[blue] blue rule \VL test \VL \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
===Colorizing Backgrounds & Text===<br />
Backgrounds and text can be colorized either on column basis or<br />
individually by cell.<br />
<br />
There are five color-specific control sequences:<br />
{|<br />
|<tt>CR</tt> || color is applied to the background of the text and the remaining space on the right.<br />
|-<br />
|<tt>CC</tt> || color is applied to the background of the text only.<br />
|-<br />
|<tt>CM</tt> || color is applied to the background of the text and the remaining space on both sides.<br />
|-<br />
|<tt>CL</tt> || color is applied to the background of the text and the remaining space on the left.<br />
|-<br />
|<tt>CT</tt> || color is applied to the text itself - in other words, the "foreground color."<br />
|}<br />
These are to complement the normal table layout expression (the<br />
first argument to <tt>\starttabulate</tt>.<br />
Thus, in order to colorize a four column table with the initial<br />
layout <tt>|c|c|c|c|</tt> it will have to be modified as follows:<br />
<texcode><br />
\starttabulate[|CR{red}c|CC{yellow}c|CM{green}c|CL{blue}c|] <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
Those control sequences, if applied within the table body, can<br />
replace the ordinary <tt>\NC</tt>, allowing individual cells to<br />
be colorized.<br />
<texcode><br />
\starttabulate[|c|c|c|c|c|c|]<br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \CM[blue] d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \CM[blue] i \CM[blue] d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
'''caveat emptor'''! The background coloring does apply only to<br />
the ''first'' row of a paragraph cell. Any other cell will come<br />
out colorless. If you need to color an entire multi-line cell,<br />
you will need to switch to another<br />
[[Tables Overview|tabulation variant]].<br />
<br />
===Colorizing Cell Text===<br />
''Normal text'' inside cells gets its color via the<br />
[[Color|standard coloring commands]], or by the <br />
shorter variant described above.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC {\colored[red] test} \NC test \NC\NR <br />
\NC test \NC {\colored[green] test} \NC test \NC\NR <br />
\NC test \NC {\colored[blue] test} \NC test \NC\NR <br />
\NC test \NC {\colored[cyan] test} \NC test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
== Vertical Distance Between Rows ==<br />
<br />
<!--<br />
There does not seem to be an official interface for<br />
vertical skips.<br />
Manually placed <code>\blank</code>s are<br />
<code>\unskipped</code> on purpose.<br />
However, as expected there is a token list<br />
<code>\t_tabl_tabulate_every_after_row</code> that is<br />
placed after a line is finished.<br />
So, in order to get a vertical spacing of half a baseline<br />
distance you can use this code:<br />
<br />
<texcode><br />
\unprotect<br />
\appendtoks<br />
\blank[halfline]<br />
\to \t_tabl_tabulate_every_after_row<br />
\protect<br />
</texcode><br />
<br />
--><br />
<br />
<context mode=mkiv source=yes><br />
\starttabulate<br />
\NC one \NC two \NC\NR <br />
\NC two \NC three \NC\NR <br />
\TB[halfline]<br />
\NC four \NC five \NC\NR <br />
\TB[line]<br />
\NC four \NC five \NC\NR <br />
\TB[1cm]<br />
\NC eight \NC nine \NC\NR <br />
\stoptabulate<br />
</context><br />
<br />
=Using math mode=<br />
<br />
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:<br />
<br />
<texcode>\starttabulate[|l|l|]<br />
\HL<br />
\NN 10e-3 \NN 10e+3 \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
instead of<br />
<br />
<texcode><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC $10\cdot 10^{-3}$ \NC $10 \cdot 10^3$ \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
although both variants do work.<br />
<br />
<br />
=Itemization inside a tabulation=<br />
<br />
<!--(added by Willi Egger 04-08-2011)--><br />
<br />
The following issue is related to MKIV:<br />
<br />
When using an itemization inside a tabulation where one uses also the <br />
<tt>\head</tt> 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:<br />
<texcode>\tabulatesplitlinemode \plustwo</texcode><br />
<br />
The following code provided by Wolfgang Schuster demonstrates the problem: Compile with and without the line <tt>\tabulatesplitlinemode\plustwo</tt><br />
<br />
<texcode><br />
\tabulatesplitlinemode \plustwo<br />
\starttabulate[|p|]<br />
\NC<br />
one \par<br />
\blank[penalty:10000]<br />
two \par<br />
\blank[penalty:10000]<br />
three<br />
\NC\NR<br />
\stoptabulate<br />
</texcode><br />
<br />
<br />
=See also=<br />
<br />
* More features are constantly added and documented in the {{src|tabl-tbl.mkiv|source}}.<br />
* {{cmd|starttabulate}}<br />
* [[TABLE|Natural Tables]]<br />
* {{cmd|starttable}}<br />
<br />
[[Category:Tables]]<br />
tt>\head</div>LuPhttps://wiki.contextgarden.net/index.php?title=Tabulate&diff=21781Tabulate2013-05-23T07:50:50Z<p>LuP: </p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
<br />
=Summary=<br />
<br />
{{cmd|starttabulate}} is a versatile table environment.<br />
It supports ''paragraphs'' in cells, ''vertical rules'' (for<br />
those typographically less demanding jobs&nbsp;…), and<br />
''colorization'' of those rules, the background of fields as well<br />
as the text itself.<br />
<br />
'''Warning''': When you want to use tables with macros use \starttable and \stoptable. \starttabulate and \stoptabulate does not work correctly with macros.<br />
<br />
=Basic commands=<br />
<br />
The control sequence <tt>\starttabulate[#1]</tt> takes a layout<br />
string as optional argument.<br />
As is common with tables in TeX-based typesetting, this string<br />
(in its basic variant) consists primarily of the ''bar''<br />
character (“<tt>|</tt>”) as delimiter for columns,<br />
and of the letters <tt>c</tt>, <tt>l</tt>, as well as <tt>r</tt>,<br />
denoting the ''alignment'' within cells of this row.<br />
<br />
For instance consider a two-column table: if any text in the<br />
first column should be right aligned (''real''<br />
[[right and left|<tt>flushright</tt>]]) and the second column<br />
left aligned, the corresponding format string would be<br />
<tt>|l|r|</tt>.<br />
''NB'': those bars, as stated above, denote cell limits only<br />
&ndash; ''not'' vertical lines.<br />
<br />
<!--<br />
- wtf this listing was full of <tab> chars‽ Was this supposed<br />
- to be a bad pun on *tabulate*?<br />
--><br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\TB[halfline]<br />
\NC \NC bigger vertical space \NC\NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
|<br />
|<context><br />
\setuppapersize[A5]<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\TB[halfline]<br />
\NC \NC bigger vertical space \NC\NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
* <tt>HL</tt> draws a horizontal rule,<br />
* <tt>NC</tt> marks a new column (or new cell),<br />
* <tt>NR</tt> starts a new row,<br />
* <tt>NB</tt> 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);<br />
* <tt>TB</tt> adds some vertical space between rows -- see an example bellow.<br />
<br />
<br />
When using fixed width, you can use values relative to the<br />
current page-width. For example: if you want the previous table<br />
take up all the width and having the second column taking three<br />
quarters of the space, change the starttabulate to:<br />
<texcode><br />
\starttabulate[|rw(.25\textwidth)|lw(.75\textwidth)|]<br />
</texcode><br />
<br />
=Spanning Multiple Pages=<br />
<br />
Tabulate may extend to adjacient pages if needed.<br />
To achieve this the argument <tt>split</tt> must be set to<br />
''true''.<br />
''NB'': the difference between setting and unsetting this<br />
argument may not be visible on the first few pages. Rather, it<br />
seems to affect the ''end'' of the environment.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<br />
==Titles==<br />
<br />
A tabulating environment can have an optional name which will be<br />
repeated above at every page break that occurs inside the table.<br />
This name needs to be specified as the argument of the<br />
<tt>title</tt> key of <tt>\setuptabulate</tt>.<br />
The <tt>header</tt> key has to be set to <em>text</em> for this<br />
to work.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<!--<br />
- ==Headers and Footers==<br />
- As I couldn’t get footers running I just comment this and<br />
- leave it to whoever discovers the trick to activate them.<br />
- (The <tt>footer=</tt> key seems to be implemented for<br />
- “\setuptabulate” but I couldn’t notice any effect.<br />
--><br />
<br />
==Headers==<br />
Tabulate supports header rows that can be repeated over new table<br />
pages instead of the title.<br />
There is a separate environment <tt>\starttablehead</tt> where<br />
this header row has to be specified in advance of its use in a<br />
tabulation.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \NC \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \NC \AR<br />
\NC l \NC left aligned \NC \AR<br />
\NC r \NC right aligned \NC \AR<br />
\stoptabulate<br />
</texcode><br />
|<br />
| <context><br />
\setuppapersize[A5]<br />
<br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\HL<br />
\NC {\bf format char} \NC {\bf meaning} \AR<br />
\HL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \AR<br />
\NC l \NC left aligned \AR<br />
\NC r \NC right aligned \AR<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
=Individualizing the Tabulate Look=<br />
<br />
Hans initially announced support for vertical lines and colors on<br />
the mailing list.[http://archive.contextgarden.net/message/20101117.123950.739657a7.en.html]<br />
<br />
==Rules==<br />
<br />
===Horizontal Rules===<br />
<br />
As already demonstrated above, the <tt>\HL</tt> statement inserts<br />
a hairline after the current line.<br />
This particularly useful when demarking header and footer rows or<br />
separated parts of a table that should not be as closely<br />
associated as the rows between the rules.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</texcode><br />
| <context><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
Context supports different categories of rules that can be<br />
configured individually in order to discern various applications.<br />
Their behaviour accounts for the designated use, e.&nbsp;g.<br />
<tt>\ML</tt> (mid rules) are intended to be deployed between<br />
ordinary rows of the table body and will prevent page breaks<br />
&ndash; no way you’d end up with a rogue hairline desecrating<br />
the bottom of your page’s text area.<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Type !! Description<br />
|-<br />
|<tt>\HL</tt> || standard horizontal rule;<br />
|-<br />
|<tt>\FL</tt> || first rule;<br />
|-<br />
|<tt>\ML</tt> || mid rule;<br />
|-<br />
|<tt>\LL</tt> || bottom rule;<br />
|-<br />
|<tt>\LL</tt> and <tt>\TL</tt> || bottom rule;<br />
|-<br />
|<tt>\BL</tt> || last rule.<br />
|}<br />
<br />
Additionally, there is an options <tt>rulecolor</tt> for<br />
<tt>\setuptabulate</tt> that allows for those rules to be tinted.<br />
<br />
<texcode><br />
\setuptabulate[rulecolor=red]<br />
<br />
\starttabulate[|r|c|l|] <br />
\FL<br />
\NC first row \NC test \NC test \NC\NR <br />
\ML<br />
\NC rows in \NC test \NC test \NC\NR <br />
\NC between \NC test \NC test \NC\NR <br />
\LL <br />
\NC last row \NC test \NC test \NC\NR <br />
\BL<br />
\stoptabulate<br />
</texcode><br />
<br />
Other types can be discovered in the source<br />
([[source:tabl-tbl.mkiv|tabl-tbl.mkiv]]).<br />
<br />
===Vertical Rules===<br />
<br />
The <tt>\VL</tt> command serves as a replacement for <tt>\NC</tt><br />
to mark a cell border wherever a vertical rule may be desired (if<br />
they are to be desired at all from a typographical point of<br />
view).<br />
<br />
<texcode><br />
\starttabulate[||||] <br />
\NC test \VL test \VL test \VL\NR <br />
\VL test \NC test \VL test \VL\NR <br />
\VL test \VL test \NC test \VL\NR <br />
\VL test \VL test \VL test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
==Coloring==<br />
<br />
The following elements can be colorized: rules, cell backgrounds,<br />
and, obviously, common text.<br />
<br />
===Colorizing Rules===<br />
<br />
For ''horizontal rules'' see above.<br />
<br />
For ''vertical rules'', <tt>\VL</tt> takes a defined color as an<br />
optional argument.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\VL test \VL[red] red rule \VL test \VL \NR <br />
\VL test \VL[green] green rule \VL test \VL \NR <br />
\VL test \VL[blue] blue rule \VL test \VL \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
===Colorizing Backgrounds & Text===<br />
Backgrounds and text can be colorized either on column basis or<br />
individually by cell.<br />
<br />
There are five color-specific control sequences:<br />
{|<br />
|<tt>CR</tt> || color is applied to the background of the text and the remaining space on the right.<br />
|-<br />
|<tt>CC</tt> || color is applied to the background of the text only.<br />
|-<br />
|<tt>CM</tt> || color is applied to the background of the text and the remaining space on both sides.<br />
|-<br />
|<tt>CL</tt> || color is applied to the background of the text and the remaining space on the left.<br />
|-<br />
|<tt>CT</tt> || color is applied to the text itself - in other words, the "foreground color."<br />
|}<br />
These are to complement the normal table layout expression (the<br />
first argument to <tt>\starttabulate</tt>.<br />
Thus, in order to colorize a four column table with the initial<br />
layout <tt>|c|c|c|c|</tt> it will have to be modified as follows:<br />
<texcode><br />
\starttabulate[|CR{red}c|CC{yellow}c|CM{green}c|CL{blue}c|] <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
Those control sequences, if applied within the table body, can<br />
replace the ordinary <tt>\NC</tt>, allowing individual cells to<br />
be colorized.<br />
<texcode><br />
\starttabulate[|c|c|c|c|c|c|]<br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \CM[blue] d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \CM[blue] i \CM[blue] d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
'''caveat emptor'''! The background coloring does apply only to<br />
the ''first'' row of a paragraph cell. Any other cell will come<br />
out colorless. If you need to color an entire multi-line cell,<br />
you will need to switch to another<br />
[[Tables Overview|tabulation variant]].<br />
<br />
===Colorizing Cell Text===<br />
''Normal text'' inside cells gets its color via the<br />
[[Color|standard coloring commands]], or by the <br />
shorter variant described above.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC {\colored[red] test} \NC test \NC\NR <br />
\NC test \NC {\colored[green] test} \NC test \NC\NR <br />
\NC test \NC {\colored[blue] test} \NC test \NC\NR <br />
\NC test \NC {\colored[cyan] test} \NC test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
== Vertical Distance Between Rows ==<br />
<br />
<!--<br />
There does not seem to be an official interface for<br />
vertical skips.<br />
Manually placed <code>\blank</code>s are<br />
<code>\unskipped</code> on purpose.<br />
However, as expected there is a token list<br />
<code>\t_tabl_tabulate_every_after_row</code> that is<br />
placed after a line is finished.<br />
So, in order to get a vertical spacing of half a baseline<br />
distance you can use this code:<br />
<br />
<texcode><br />
\unprotect<br />
\appendtoks<br />
\blank[halfline]<br />
\to \t_tabl_tabulate_every_after_row<br />
\protect<br />
</texcode><br />
<br />
--><br />
<br />
<context mode=mkiv source=yes><br />
\starttabulate<br />
\NC one \NC two \NC\NR <br />
\NC two \NC three \NC\NR <br />
\TB[halfline]<br />
\NC four \NC five \NC\NR <br />
\TB[line]<br />
\NC four \NC five \NC\NR <br />
\TB[1cm]<br />
\NC eight \NC nine \NC\NR <br />
\stoptabulate<br />
</context><br />
<br />
=Using math mode=<br />
<br />
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:<br />
<br />
<texcode>\starttabulate[|l|l|]<br />
\HL<br />
\NN 10e-3 \NN 10e+3 \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
instead of<br />
<br />
<texcode><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC $10\cdot 10^{-3}$ \NC $10 \cdot 10^3$ \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
although both variants do work.<br />
<br />
<br />
=Itemization inside a tabulation=<br />
<br />
<!--(added by Willi Egger 04-08-2011)--><br />
<br />
The following issue is related to MKIV:<br />
<br />
When using an itemization inside a tabulation where one uses also the <br />
<tt>\head</tt> 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:<br />
<texcode>\tabulatesplitlinemode \plustwo</texcode><br />
<br />
The following code provided by Wolfgang Schuster demonstrates the problem: Compile with and without the line <tt>\tabulatesplitlinemode\plustwo</tt><br />
<br />
<texcode><br />
\tabulatesplitlinemode \plustwo<br />
\starttabulate[|p|]<br />
\NC<br />
one \par<br />
\blank[penalty:10000]<br />
two \par<br />
\blank[penalty:10000]<br />
three<br />
\NC\NR<br />
\stoptabulate<br />
</texcode><br />
<br />
<br />
=See also=<br />
<br />
* More features are constantly added and documented in the {{src|tabl-tbl.mkiv|source}}.<br />
* {{cmd|starttabulate}}<br />
* [[TABLE|Natural Tables]]<br />
* {{cmd|starttable}}<br />
<br />
[[Category:Tables]]<br />
tt>\head</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/simplealignedbox&diff=21430Command/simplealignedbox2013-03-08T08:27:18Z<p>LuP: Created page with "{{Reference |name={{\simplealignedbox}} |attributes= }} == Syntax == <table cellspacing="4" cellpadding="2" class="cmd"> <tr> <td colspan="2" class="cmd..."</p>
<hr />
<div>{{Reference<br />
|name={{\simplealignedbox}}<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\{{\simplealignedbox}}<!--<br />
--><span class="first">{...}</span><!--<br />
--><span class="second">{...}</span><!--<br />
--><span class="third">{...}</span><!--<br />
--></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td>width</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">{...}</td><br />
<td>alignment: ''left | right | flushleft | flushright | middle''</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">{...}</td><br />
<td>content</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
The command is a simple wrapper around \hbox with a fixed width and the possibility to align the content either to the left, right or centred within the box.<br />
<br />
== Example ==<br />
<context source=yes mode=mkiv><br />
\ruledhbox{\simplealignedbox{3cm}{flushleft}{TEXT}}<br />
\ruledhbox{\simplealignedbox{3cm}{flushright}{TEXT}}<br />
\ruledhbox{\simplealignedbox{3cm}{middle}{TEXT}}<br />
\ruledhbox{\simplealignedbox{3cm}{left}{TEXT}}<br />
\ruledhbox{\simplealignedbox{3cm}{right}{TEXT}}<br />
</context><br />
<br />
== See also ==<br />
<!-- something like this:<br />
* {{cmd|setuphead}}<br />
* {{src|strc-sec.mkiv#l299}}<br />
--><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{\simplealignedbox}}}}<br />
<br />
[[Category:Commands|{{\simplealignedbox}}]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/ctxcommand&diff=21270Command/ctxcommand2012-11-30T11:41:15Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=ctxcommand<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\ctxcommand<!--<br />
--><span class="first">{...}</span><!--<br />
--></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td>''lua command from in the'' command ''table''</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
To quickly access Lua commands in the {{code|command}} table.<br />
<br />
\def\ctxcommand #1{\directlua{commands.#1}} % saves tokens <br />
<br />
You can write e.g.<br />
<texcode><br />
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}<br />
</texcode><br />
instead of<br />
<texcode><br />
\ctxlua{command.doifelse(\userpage < 10)}{early page}{later page}<br />
</texcode><br />
.<br />
<br />
== Example ==<br />
<context source=yes mode=mkiv><br />
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}<br />
</context><br />
<br />
== \ctxcommand vs. \cldcommand ==<br />
<context source=yes mode=mkiv><br />
A<br />
\ctxlua{commands.doif(true)}{one}<br />
B<br />
\cldcommand{doif("a","a","two")}<br />
C<br />
\ctxcommand{doif(true)}{three}<br />
D<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|ctxlua}}<br />
* {{cmd|ctxcommand}}<br />
* {{cmd|cldcontext}}<br />
* {{cmd|cldcommand}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/LuaTeX|ctxcommand]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/cldcontext&diff=21265Command/cldcontext2012-11-29T13:04:40Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=cldcontext<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\cldcontext<!--<br />
--><span class="first">{...}</span><!--<br />
--></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td>''valid argument(s) for Lua's `context()` function''</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
Pass an argument to Lua's {{code|context(...)}} command. The text is<br />
inserted as-is, so you'll want to add quotations marks.<br />
<br />
\def\cldcontext #1{\directlua\zerocount{context(#1)}}<br />
% so \cldcontext{some code} --> \directlua{context(some code)}<br />
% and \cldcontext{"some code"} --> \directlua{context("some code")}<br />
<br />
== Example ==<br />
<context mode=mkiv source=yes><br />
\cldcontext{"\\section{One}"}<br />
\cldcontext{2 * 4}<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|cldcontext}}<br />
* {{cmd|cldcommand}}<br />
* {{cmd|ctxcommand}}<br />
* {{cmd|cldprocessfile}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/LuaTeX|cldcontext]]<br />
[[Category:Command/MkIV only|cldcontext]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/ctxcommand&diff=21264Command/ctxcommand2012-11-29T13:03:15Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=ctxcommand<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\ctxcommand<!--<br />
--><span class="first">{...}</span><!--<br />
--></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td>''lua command from in the'' command ''table''</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
To quickly access Lua commands in the {{code|command}} table, you can write e.g.<br />
<texcode><br />
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}<br />
</texcode><br />
instead of<br />
<texcode><br />
\ctxlua{command.doifelse(\userpage < 10)}{early page}{later page}<br />
</texcode><br />
.<br />
<br />
== Example ==<br />
<context source=yes mode=mkiv><br />
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}<br />
</context><br />
<br />
== \ctxcommand vs. \cldcommand ==<br />
<context source=yes mode=mkiv><br />
A<br />
\ctxlua{commands.doif(true)}{one}<br />
B<br />
\cldcommand{doif("a","a","two")}<br />
C<br />
\ctxcommand{doif(true)}{three}<br />
D<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|ctxlua}}<br />
* {{cmd|ctxcommand}}<br />
* {{cmd|cldcontext}}<br />
* {{cmd|cldcommand}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/LuaTeX|ctxcommand]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/ctxcommand&diff=21263Command/ctxcommand2012-11-29T12:59:06Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=ctxcommand<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\ctxcommand<!--<br />
--><span class="first">{...}</span><!--<br />
--></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td>''lua command from in the'' command ''table''</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
To quickly access Lua commands in the {{code|command}} table, you can write e.g.<br />
<texcode><br />
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}<br />
</texcode><br />
instead of<br />
<texcode><br />
\ctxlua{command.doifelse(\userpage < 10)}{early page}{later page}<br />
</texcode><br />
.<br />
<br />
== Example ==<br />
<context source=yes mode=mkiv><br />
\ctxcommand{doifelse(\userpage < 10)}{early page}{later page}<br />
</context><br />
<br />
== \ctxcommand vs. \cldcommand vs. \cldcommand ==<br />
<context source=yes mode=mkiv><br />
A<br />
\ctxlua{commands.doif(true)}{one}<br />
B<br />
\cldcommand{doif("a","a","two")}<br />
C<br />
\ctxcommand{doif(true)}{three}<br />
D<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|ctxlua}}<br />
* {{cmd|ctxcommand}}<br />
* {{cmd|cldcontext}}<br />
* {{cmd|cldcommand}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/LuaTeX|ctxcommand]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=TABLE&diff=20955TABLE2012-10-24T08:32:46Z<p>LuP: </p>
<hr />
<div>< [[Tables Overview]] | [[XML]] ><br />
<br />
=Introduction=<br />
<br />
This table mode is called &ldquo;natural tables&rdquo; or &ldquo;automatic tables.&rdquo; I'd call it &ldquo;HTML tables,&rdquo; because it's very similar to them. They're especially suited for [[XML]] conversions.<br />
<br />
Beware: every element must use <tt>\b</tt> ... <tt>\e</tt>!<br />
<br />
You find a lot of samples in [[manual:enattab.pdf|enattab.pdf]]<br />
<br />
Willi Egger wrote a [[My Way]] how he set a typesetter's lead type case: [http://dl.contextgarden.net/myway/NaturalTables.pdf Use of natural tables]<br />
<br />
To place a table use:<br />
<br />
<texcode><br />
\placetable{Caption}<br />
{\bTABLE<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\eTABLE}<br />
</texcode><br />
<br />
Here is a more elaborate example:<br />
<br />
<context source=yes><br />
This is our red-coloured table.<br />
\setupTABLE[row][odd][background=color,backgroundcolor=red, width=.2\textwidth]<br />
\bTABLE[split=yes] % allow splitting over page boundaries<br />
\bTR \bTD[nr=3] 1 \eTD \bTD[nc=2] 2/3 \eTD \bTD[nr=3] 4 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD[nc=3] 1/2/3 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 2 \eTD \bTD 3 \eTD \bTD 4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
<br />
= Multipage TABLEs =<br />
<br />
Try to divide your table into...<br />
* <cmd>bTABLEhead</cmd> (table header)<br />
* <cmd>bTABLEnext</cmd> (alternate table header on following pages)<br />
* <cmd>bTABLEbody</cmd> (table body)<br />
* <cmd>bTABLEfoot</cmd> (table footer)<br />
and <cmd>setupTABLE</cmd><tt>[split=yes]</tt> or <tt>[split=repeat]</tt><br />
<br />
see also [[source:core-ntb.tex|core-ntb.tex]]<br />
<br />
If you must <b>split</b> a natural table over several pages, you can<br />
simply do this by adding <tt>\setupTABLE[split=yes]</tt> to your TABLE<br />
definition. Another way is to define it right at the TABLE start<br />
by adding the parameter <tt>[split=yes]</tt> (see example).<br />
However,<br />
{{cmd|startlinecorrection}}<br />
can lead to unpredictable vertical spaces between rows [http://archive.contextgarden.net/message/20100912.112605.8a1aaf13.en.html].<br />
<br />
In this case the <b>table head</b><br />
(all between <cmd>bTABLEhead</cmd> and <cmd>eTABLEhead</cmd>)<br />
is printed only once at the beginning of the table. But if you use <tt>[split=repeat]</tt>,<br />
it is printed on top of every new page, that contains parts of<br />
your multipage table. Please take account of the fact, that the<br />
head cells are enclosed by <cmd>bTH</cmd> and <cmd>eTH</cmd> (and not \[be]TC).<br />
<br />
If you want to use an alternative table header for all following pages,<br />
you can do this by defining an additional header. Just add the second header<br />
between <cmd>bTABLEnext</cmd>...<cmd>eTABLEnext</cmd>,<br />
right after your normal head definition.<br />
Now every additional page of the multipage table starts with the<br />
<b>next table head</b>.<br />
<br />
The <b>table foot</b> is declared between <cmd>bTABLEfoot</cmd> and<br />
<cmd>eTABLEfoot</cmd>. It defines the concluding row of your natural table.<br />
<br />
'''Beware:''' Split tables often begin not on the page (or in the column, if you use them) where they ''could'' start, but on/in the next one.<br />
This is a known limitation due to the complicated calculation of remaining space on the page.<br />
That won't become better before this calculations are newly written in Lua. (Said Hans on 2010-09-24.)<br />
<br />
The following standalone example deals with all the mentioned aspects of natural tables.<br />
Just <i>copy&paste</i> it as a starting point for further experiments...<br />
<br />
<texcode><br />
\starttext<br />
<br />
\setupcolors[state=start]<br />
<br />
% setup for all cells<br />
\setupTABLE[r][each][style=\tfx\it, align=center]<br />
<br />
% setup table head<br />
\setupTABLE[r][first]<br />
[background=color,<br />
backgroundcolor=yellow]<br />
% setup table footer<br />
\setupTABLE[r][last]<br />
[style=bold,<br />
background=color,<br />
backgroundcolor=green]<br />
<br />
\bTABLE[split=repeat,option=stretch]% head on every page, stretch columns<br />
%<br />
% IMPORTANT: use \bTH ... \eTH to enclose the head|next cells<br />
\bTABLEhead<br />
\bTR<br />
\bTH head1 \eTH<br />
\bTH head2 \eTH<br />
\bTH head3 \eTH<br />
\eTR<br />
\eTABLEhead<br />
% <br />
\bTABLEnext % setup for next table head<br />
\bTR [background=color,backgroundcolor=cyan]<br />
\bTH next1 \eTH<br />
\bTH next2 \eTH<br />
\bTH next3 \eTH<br />
\eTR<br />
\eTABLEnext<br />
%<br />
% the table body (main part)<br />
%<br />
\bTABLEbody<br />
%<br />
\dorecurse{100}{% 100 rows<br />
\bTR<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\eTR<br />
}%<br />
%<br />
\eTABLEbody<br />
%<br />
% the table foot<br />
%<br />
\bTABLEfoot<br />
\bTR<br />
\bTC foot1 \eTC<br />
\bTC foot2 \eTC<br />
\bTC foot3 \eTC<br />
\eTR<br />
\eTABLEfoot<br />
%<br />
\eTABLE<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= Tables in multiple columns =<br />
<br />
... just work (at least in luaTeX and not here...). See the following example.<br />
<br />
<texcode><br />
\starttext<br />
\startcolumns[n=3]<br />
\bTABLE<br />
\dorecurse{21}<br />
{\bTR \bTD a\eTD \bTD b \eTD \eTR}<br />
\eTABLE<br />
\stopcolumns<br />
\stoptext<br />
</texcode><br />
<br />
= Creating tables from CSV data (Comma Separated Values) =<br />
<br />
See also [[m-database|the database module]]!<br />
<br />
and [http://dl.contextgarden.net/myway/csv.pdf Creating Tables using CSV (Comma-separated values)] by Mojca Miklavec<br />
<br />
<br />
<!-- Maybe some other place or a separate page is more appropriate for this section --><br />
<br />
An interesting example of creating a table using comma separated values was posted to the [http://archive.contextgarden.net/message/20050923.193302.f2110c93.en.html mailing list] by [[User:ChristopherCreutzig|Christopher Creutzig]]<br />
<br />
The following macros take care of processing CSV data:<br />
<texcode><br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
</texcode><br />
<br />
The next lines are an example of transforming the data into a natural table, but can be easily adapted to any type of the table or perhaps (mis)used in even more strange ways:<br />
<br />
<texcode><br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
</texcode><br />
<br />
The following lines will then finally result in a desired table:<br />
<br />
<texcode><br />
% some additional settings for the table may be made as well<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style=bold] % how to override the \tt in the second column?<br />
<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A5]<br />
<br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
<br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style={\rm\bf}]<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</context><br />
<br />
Some remarks: the (tentative) code ignores the fact that<br />
* csv data may optionally be enclosed in "" quotes that have to be removed (to be done in \TBLentry) <br />
* quoted strings may contain commas themselves (which means writing a custom version of \processcommalist instead).<br />
<br />
See also {{cmd|processseparatedlist}}.<br />
<br />
= Designing complex TABLEs =<br />
<br />
Everything is easy when a simple grid is enough. Unfortunately, this<br />
is not the case most of the time, tables tend to have information<br />
which should flow accross cell boundaries either vertically<br />
or horizontally. One of the reasons to use TABLE instead of the<br />
table environment is that TABLE provides an easy (relatively speaking, <br />
at least) way to make merged cells to both directions.<br />
<br />
There are probably as many ways to design TABLEs as there are<br />
users, but a simple one to begin with is to start with a<br />
grid:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\bTABLE<br />
\bTR \bTD r1c1 \eTD \bTD r1c2 \eTD \bTD r1c3 \eTD \bTD r1c4 \eTD \bTD r1c5 \eTD \bTD r1c6 \eTD \eTR<br />
\bTR \bTD r2c1 \eTD \bTD r2c2 \eTD \bTD r2c3 \eTD \bTD r2c4 \eTD \bTD r2c5 \eTD \bTD r2c6 \eTD \eTR<br />
\bTR \bTD r3c1 \eTD \bTD r3c2 \eTD \bTD r3c3 \eTD \bTD r3c4 \eTD \bTD r3c5 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD r4c2 \eTD \bTD r4c3 \eTD \bTD r4c4 \eTD \bTD r4c5 \eTD \bTD r4c6 \eTD \eTR<br />
\bTR \bTD r5c1 \eTD \bTD r5c2 \eTD \bTD r5c3 \eTD \bTD r5c4 \eTD \bTD r5c5 \eTD \bTD r5c6 \eTD \eTR<br />
\bTR \bTD r6c1 \eTD \bTD r6c2 \eTD \bTD r6c3 \eTD \bTD r6c4 \eTD \bTD r6c5 \eTD \bTD r6c6 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The desired table layout is then drawn onto this grid, and the top left corner cell<br />
of each cell in the final layout identified:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nc=2,nr=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The cells are listed from left to right and up to down. Each larger cell is then given<br />
it size by using <tt>nc=...</tt> and <tt>nr=...</tt> parameters with <tt>\bTD</tt>. The<br />
code producing the table above is:<br />
<br />
<texcode><br />
\setupTABLE[r][each][height=1cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nr=2,nc=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
<br />
N.B. There is an ugly hack in the code. An empty first row with zero height and no borders<br />
is added. If the row is omitted, then something odd happens to the number of<br />
columns. The table should have all cells, so this may be a bug. (Or then I have<br />
blundered something with this example, possibly.)<br />
<br />
Everything rectangular can be done with TABLE, as long as it can be fit in the grid. The grid<br />
does not have to be equidistant, and if its dimensions are omitted, the program<br />
will fit the data in. L-shaped or other complex cell shapes are not possible.<br />
Using them would be a bit odd, in any case, as alignment and text flow problems<br />
would be quite interesting.<br />
<br />
<br />
== Cell Addressing and Frames ==<br />
<br />
The setup commands for TABLE do not seem to be very verbosedly commented.<br />
There are, however, a few shorthands, which are useful to understand.<br />
First of all, there are several ways to address cells. This is a brief<br />
summary of some of them:<br />
<br />
<texcode><br />
\setupTABLE[r][(list of rows)][...]<br />
\setupTABLE[c][(list of columns)][...]<br />
\setupTABLE[(list of columns)][(list of rows)][...]<br />
</texcode><br />
<br />
A list contains one or more numbers separated by commas.<br />
Word "last" is equivalent to the number of the last row or<br />
column. The complete list can be replaced by the word "each"<br />
to address all cells on the row/column.<br />
<br />
Let us consider the following table:<br />
<br />
<texcode><br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=1.0cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
...<br />
</texcode><br />
<br />
In plain language the rows are interpreted as follows:<br />
<br />
* Align each cell in each column (i.e. all cells) horizontally in the middle<br />
and vertically in the middle (lohi), and remove all frames (borders)<br />
* The height of rows 2 -- 6 is 1.0 cm<br />
* Draw a line on top of rows 2 and 4<br />
* Draw a line to the right side of columns 1 -- 3<br />
<br />
In this case the table is slightly complicated, there are some split cells,<br />
as shown below:<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
The cell numbering is well worth noting. It is very logical (upper<br />
leftmost part of a combined cell), but sometimes the results are<br />
surprising in the beginning.<br />
<br />
The important point about cell numbering is that there is really<br />
a difference between "bottom border of row 3" and "top border of<br />
row 4". To illustrate this, let us change the frame setups:<br />
<br />
<texcode><br />
\setupTABLE[r][2,4][topframe=on]<br />
</texcode><br />
<br />
is changed to<br />
<br />
<texcode><br />
\setupTABLE[r][1,3][bottomframe=on]<br />
</texcode><br />
<br />
At first sight this is exactly the same thing. But...<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][1,3][bottomframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
Where did the horizontal line in column 3 disappear? Nowhere. There is no<br />
row 3 in column 3, so there cannot be a frame under it. This problem<br />
can be overcome by using topframe and leftframe instead of bottom and<br />
right, as the cells below and to the right of a border have to exist.<br />
<br />
However, this solution leaves the problem of bottom and rightmost borders.<br />
How to draw a line in the bottom of the table? Using <br />
<tt>\setupTABLE[r][6][bottomframe=on]</tt> will leave the gap in columns 3 and 4, <br />
and <tt>\setupTABLE[r][7][topframe=on]</tt> is not possible, as there is no <br />
row 7. The clever idea of using "last" instead of the row number (6) will fail, <br />
as "last" seems to behave exactly the same way as number 6.<br />
<br />
One useful method is to switch on the borders cell by<br />
cell by adding <tt>\setupTABLE[3,4][4][bottomframe=on]</tt>, i.e.<br />
draw a border under cells r4c3 and r4c4.<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\setupTABLE[r][6][bottomframe=on]<br />
\setupTABLE[3,4][4][bottomframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Column Offset/Gap ==<br />
<br />
From the mailing list at 2005-11-09 by Vit Zyka, modified by Hans Hagen:<br />
<br />
<texcode><br />
\starttext<br />
<br />
% distance mechanism, per column (H)<br />
<br />
\start<br />
\setupTABLE[c][1][distance=2em]<br />
\setupTABLE[c][2][distance=3em]<br />
<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
<br />
\bTABLE[option=stretch]<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
\stop<br />
<br />
% distance mechanism, per table (V)<br />
<br />
\framed[offset=none]{%<br />
\setupTABLE[column][2][align=left]<br />
\setupTABLE[column][3][align=right]<br />
\bTABLE[columndistance=2cm,leftmargindistance=.3cm,rightmargindistance=.5cm]<br />
\bTR<br />
\bTH[nc=3] Table head\eTH<br />
\eTR<br />
\bTR\bTD[nc=2] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=left] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=middle] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD A\eTD\bTD B\eTD\bTD C\eTD\eTR<br />
\bTR\bTD Aa\eTD\bTD Bb\eTD\bTD Cccc\eTD\eTR<br />
\bTR\bTD[nc=3,align=middle] ABC\eTD\eTR<br />
\eTABLE<br />
}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Make a cell bold ==<br />
<br />
Drawing bold lines around a cell is done using the<br />
<tt>[rulethickness=''dim'']</tt> key on a cell. The thicker rules will<br />
offset the text inside the cell both downwards and sideways, so care<br />
should be taken that the cell's increased rulethickness is offset by an<br />
equal decrease in offset.<br />
<br />
<context source="yes" text="produces"><br />
\setupTABLE[row][each][rulethickness=.25pt,offset=\dimexpr1mm+1.75pt] <br />
\bTABLE<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2/3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD[rulethickness=2pt,offset=1mm] 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
== Rules ==<br />
<br />
=== Example: an invoice with thick rules ===<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
{\bfa Invoice}<br />
\switchtobodyfont[6pt]<br />
\blank<br />
\bTABLE<br />
\setupTABLE[frame=off,offset=1mm]<br />
\setupTABLE[row][*][height=7.25mm]<br />
\setupTABLE[column][1,2] [width=20mm,offset=\dimexpr1mm+2pt,align=flushleft]<br />
\setupTABLE[column][3,4,5][width=20mm,offset=\dimexpr1mm+2pt,align=flushright]<br />
\bTR[bottomframe=on, rulethickness=2pt,offset=1mm]<br />
\bTD\bf Date \eTD<br />
\bTD\bf Description \eTD<br />
\bTD\bf Quantity \eTD<br />
\bTD\bf Price \eTD<br />
\bTD\bf Total \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 1 \eTD<br />
\bTD 10.0 \eTD<br />
\bTD 6.00 \eTD<br />
\bTD 60.00 \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 2 \eTD<br />
\bTD 2.0 \eTD<br />
\bTD 3.00 \eTD<br />
\bTD 6.00 \eTD<br />
\eTR<br />
\bTR[topframe=on,rulethickness=2pt,offset=1mm]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] Subtotal \eTD<br />
\bTD 66.00 \eTD<br />
\eTR<br />
\bTR[offset=\dimexpr1mm+2pt]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] VAT 19\% \eTD<br />
\bTD 12.54 \eTD<br />
\eTR<br />
\bTR<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] \bf Total \eTD<br />
\bTD 78.54 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
=== Rules with different thickness ===<br />
<br />
There is only one value for all four borders. However, MetaPost can be used as a workaround until the separate "rulethickness" values are implemented.<br />
<br />
The following example (mkiv only!) by Wolfgang Schuster shows a table using MetaPost for the rules:<br />
<br />
<context source=yes mode=mkiv text="gives:"><br />
\startuseMPgraphic{tableborders}<br />
<br />
draw leftboundary OverlayBox withpen pensquare scaled \frameddimension {leftrulethickness} ;<br />
draw rightboundary OverlayBox withpen pensquare scaled \frameddimension {rightrulethickness} ;<br />
draw topboundary OverlayBox withpen pensquare scaled \frameddimension {toprulethickness} ;<br />
draw bottomboundary OverlayBox withpen pensquare scaled \frameddimension{bottomrulethickness} ;<br />
<br />
clip currentpicture to OverlayBox<br />
leftenlarged (\frameddimension {leftrulethickness}/2)<br />
rightenlarged (\frameddimension {rightrulethickness}/2)<br />
topenlarged (\frameddimension {toprulethickness}/2)<br />
bottomenlarged (\frameddimension{bottomrulethickness}/2) ;<br />
<br />
setbounds currentpicture to OverlayBox ;<br />
<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay[tableborders][\useMPgraphic{tableborders}]<br />
<br />
\startsetups tableborders<br />
<br />
\setupTABLE<br />
[ background={color,tableborders},<br />
frame=off,<br />
backgroundoffset=0pt,<br />
leftrulethickness=\framedparameter{rulethickness},<br />
rightrulethickness=\framedparameter{rulethickness},<br />
toprulethickness=\framedparameter{rulethickness},<br />
bottomrulethickness=\framedparameter{rulethickness}]<br />
<br />
\setupTABLE[row] [odd] [backgroundcolor=lightgray]<br />
\setupTABLE[row] [first][backgroundcolor=gray,bottomrulethickness=2pt]<br />
\setupTABLE[row] [last] [toprulethickness=2pt,bottomrulethickness=2pt]<br />
\setupTABLE[first][last] [leftrulethickness=2pt]<br />
\setupTABLE[last] [last] [rightrulethickness=2pt]<br />
<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\bTABLE<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\blank<br />
<br />
\bTABLE[setups=tableborders]<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\stoptext<br />
</context><br />
<br />
See the corresponding thread on the list: [http://www.ntg.nl/pipermail/ntg-context/2011/058549.html rules with different thickness]<br />
<br />
=== Thick bottom rules ===<br />
<br />
This is a simplified version of the example above (corresponding mailing thread - [http://www.ntg.nl/pipermail/ntg-context/2012/069541.html TABLE: header with a thick bottom line]).<br />
<br />
<context source=yes mode=mkiv text="Gives:"><br />
\startuseMPgraphic{MP:thickBtm}<br />
draw bottomboundary OverlayBox withpen pensquare scaled \frameddimension{bottomrulethickness};<br />
clip currentpicture to OverlayBox;<br />
setbounds currentpicture to OverlayBox;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay[OL:thickBtm][\useMPgraphic{MP:thickBtm}]<br />
<br />
\starttext<br />
\bTABLE<br />
\setupTABLE[align=middle]<br />
\setupTABLE[header][background={OL:thickBtm},bottomrulethickness=4pt]<br />
\setupTABLE[row][4][background={OL:thickBtm},bottomrulethickness=2pt]<br />
%<br />
\bTABLEhead\bTR\dorecurse{3}{\bTH#1\eTH}\eTR\eTABLEhead<br />
\bTABLEbody\dorecurse{6}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}\eTABLEbody<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
=== Diagonal rules ===<br />
<br />
Sometimes a diagonal rule is required in the top left corner cell of a table to create two fields, one for the left column and one for the top row.<br />
<br />
<br />
<context mode="mkiv" source="yes" text="Gives:"><br />
\startuseMPgraphic{DiagonalRule}<br />
rulethickness := \frameddimension{rulethickness};<br />
<br />
drawoptions(<br />
withpen pencircle scaled rulethickness<br />
withcolor \MPcolor{\framedparameter{framecolor}});<br />
<br />
pair leftcorner, rightcorner;<br />
leftcorner := (rulethickness, \overlayheight-rulethickness);<br />
rightcorner := (\overlaywidth-rulethickness, rulethickness);<br />
<br />
draw leftcorner -- rightcorner;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[DiagonalRule]<br />
[\useMPgraphic{DiagonalRule}]<br />
<br />
\define[2]\DiagonalLabel{%<br />
\setuptabulate [after={\blank[\frameddimension{offset}]}]<br />
\starttabulate [|p|r|]<br />
\NC \NC #2 \NC\NR<br />
\NC #1 \NC \NC\NR<br />
\stoptabulate<br />
}<br />
<br />
\starttext<br />
\setupTABLE [row] [1] [width=2cm]<br />
\bTABLE<br />
\bTR<br />
\bTD [background=DiagonalRule]<br />
\DiagonalLabel{Foo}{Bar}<br />
\eTD<br />
\bTD Second \eTD<br />
\bTD Third \eTD<br />
\eTR<br />
\bTR<br />
\bTD Alpha \eTD<br />
\bTD Beta \eTD<br />
\bTD Gamma \eTD<br />
\eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
This solution has (at least) one caveat: Because the first<br />
tabulate column is set in paragraph mode, it will eat up as much<br />
space as <em>possible</em>, in contrast to occupying as much space as<br />
</em>necessary</em>. That is why the width of the column has to be set<br />
explicitly.<br />
<br />
== Using character alignment ==<br />
<br />
ConTeXt can align columns of numbers on a character (often a decimal point to align accounting data) automatically, removing the need to add fixed spaces into your document. For any such column you need to specify the character on which to align. You use the <tt>aligncharacter=yes</tt> parameter to set up character alignment, <tt>alignmentcharacter={.}</tt> to say what the character should be (in this case a full stop) and <tt>align=middle</tt> to set the overall alignment of the column.<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},<br />
aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
You'll note that the final line, because it has no <code>.</code> in the number, gets aligned under the right-hand side of the numbers. In most circumstances you would want such a number aligned with the left-hand set of digits. To so do, issue the following command in your preamble:<br />
<br />
<texcode><br />
\chardef\characteralignmentmode=2<br />
</texcode><br />
<br />
and now the table above will turn out like this:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\chardef\characteralignmentmode=2<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
If there's no <code>alignmentcharacter</code> in the cell, the content will be aligned in the following way depending on the value of <code>\characteralignmentmode</code>:<br />
<table style="border:1px solid #DDDDDD;"><br />
<tr style="background-color:#DDDDDD; font-weight: bold;"><td>mode</td><td width="200"></td><td>.</td><td width="200"></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">0</td><td colspan="3" align="center">centered</td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">1</td><td align="left">left in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">2</td><td align="right">right in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">3</td><td></td><td style="background-color:#DDDDDD">.</td><td align="left">left in after</td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">4</td><td></td><td style="background-color:#DDDDDD">.</td><td align="right">right in after</td></tr><br />
</table><br />
<br />
== Specifying the cell column ==<br />
<br />
When writing a table you can omit empty cells and define only cells for specified columns. To have this feature fully available you need to have a beta or a quite fresh ConTeXt version.<br />
<br />
Two methods are available:<br />
<br />
* With the TD "n" option, the undefined cells are merged into a single spanned cell.<br />
* With the TD "m" option, the undefined cells appear as empty normal cells.<br />
<br />
Here is an example using the "n" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[n=2] d2 \eTD\bTD[n=5] d5 \eTD\bTD[n=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[n=4] f4 \eTD\bTD[n=5] f5 \eTD\bTD[n=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
Here is an example using the "m" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[m=2] d2 \eTD\bTD[m=5] d5 \eTD\bTD[m=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[m=4] f4 \eTD\bTD[m=5] f5 \eTD\bTD[m=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Round corners ==<br />
<br />
For a different approach for round corners and colored background follow the text after this example.<br />
<br />
It is possible to round the corners of the table if you turn off the main frame of the table and frame the table in {{cmd|framed}}. Compare two different approaches in the first and second example.<br />
<br />
You can't color the background of the table with round corners unless the frame rulethickness is not big enough to cover the rectangular corners of the background (second example). Well, you can if you frame the table twice. Once in the thick white frame and then in the thin frame with negative offset and slightly smaller corner radius (third example). Be aware of other complications -- notice that the thick white frame is still visible in the text above it.<br />
<br />
<context source="yes"><br />
\starttext<br />
\setupcolors[state=start] <br />
%\showstruts<br />
\setupTABLE[background=color,backgroundcolor=yellow]<br />
\setupframed[framecolor=darkgreen]<br />
<br />
\defineparagraphs[ThreeCols]<br />
<br />
\startThreeCols<br />
<br />
First<br />
<br />
\def\StartTable<br />
{\setupTABLE[row] [first][topframe=off]%<br />
\setupTABLE[row] [last] [bottomframe=off]%<br />
\setupTABLE[column][first][leftframe=off]%<br />
\setupTABLE[column][last] [rightframe=off]%<br />
\framed[strut=no,corner=round,offset=.5\linewidth]<br />
\bgroup}<br />
<br />
\def\StopTable<br />
{\egroup}<br />
<br />
\StartTable<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\StopTable<br />
<br />
\nextThreeCols<br />
<br />
Second<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,offset=.5\linewidth,,rulethickness=1mm]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
<br />
\nextThreeCols<br />
<br />
Third<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,<br />
radius=1.4mm,offset=-1mm,,rulethickness=.1mm]\bgroup<br />
\framed[strut=no,corner=round,<br />
radius=1.5mm,offset=0mm,,rulethickness=1mm,framecolor=white]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
\egroup<br />
<br />
\stopThreeCols<br />
<br />
\stoptext<br />
</context><br />
<br />
From 2006-10-11 on, ConTeXt contains one more mechanism for round corners. Watch the example:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\starttext<br />
\setupcolors[state=start]<br />
\setupTABLE [y] [first][background=color,backgroundcolor=blue,frame=off,bottomframe=on,topframe=on,framecolor=white]<br />
\setupTABLE [first][first][backgroundcorner=2,corner=10,frame=on]<br />
\setupTABLE [last] [first][backgroundcorner=4,corner=12,frame=on]<br />
\setupTABLE [row] [each] [background=color,backgroundcolor=blue,frame=on,framecolor=white]<br />
\setupTABLE [first][2] [corner=8]<br />
\setupTABLE [last] [2] [corner=5]<br />
\setupTABLE [first][last] [corner=7]<br />
\setupTABLE [last] [last] [corner=6]<br />
<br />
\bTABLE[frame=off,align=middle]<br />
\bTR \bTD one \eTD \bTD two \eTD \bTD three \eTD \eTR<br />
\bTR \bTD first \eTD \bTD second \eTD \bTD third \eTD \eTR<br />
\bTR \bTD alpha \eTD \bTD beta \eTD \bTD gamma \eTD \eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
== Other options ==<br />
<br />
Some other useful options that were not covered above:<br />
* <tt>align=yes</tt> will align the text both left and right justified<br />
* <tt>loffset</tt>, <tt>roffset</tt>, <tt>toffset</tt>, <tt>boffset</tt> can be used in addition to <tt>offset</tt> to specify cell content offsets in each direction separately, see also {{cmd|framed}}<br />
<br />
= TABLEs with old table syntax =<br />
<br />
From the mailing list in March 2009, by Wolfgang Schuster and Hans Hagen:<br />
<br />
<texcode><br />
\def\startTABLE<br />
{\dosingleempty\dostartTABLE}<br />
<br />
\def\dostartTABLE[#1]%<br />
{\bgroup<br />
\bTABLE[#1]%<br />
\let\NC\doTABLENC<br />
\let\NR\doTABLENR<br />
\let\bTR\relax<br />
\let\bTD\relax<br />
\let\bTH\relax<br />
\let\bTN\relax}<br />
<br />
\def\stopTABLE<br />
{\eTABLE<br />
\egroup}<br />
<br />
\newconditional\inTABLEnc<br />
<br />
\unexpanded\def\doTABLENR<br />
{\eTR<br />
\setfalse\inTABLEnc}<br />
<br />
\unexpanded\def\doTABLENC<br />
{\futurelet\next\dodoTABLENC}<br />
<br />
\def\dodoTABLENC<br />
{\ifx\next\doTABLENR \else<br />
\expandafter\dododoTABLENC<br />
\fi}<br />
<br />
\long\def\dododoTABLENC#1\NC<br />
{\ifconditional\inTABLEnc\else\settrue\inTABLEnc\parseTR[][]\fi<br />
\dodoubleempty\parseTD#1\eTD\NC}<br />
</texcode><br />
<br />
This is now part of the core as the [[source:tabl-nte.tex|NTE module]]. Quoting its internal documentation:<br />
<br />
This module is suggested by Wolfgang Schuster who also prototyped it and came up with the rationale:<br />
<br />
This module provides an easy way to use natural in a similiar way as the older table module (based on the [[TABLE]] macros) and the newer [[tabulate]] module.<br />
<br />
You can see the advantage in the following table, once created with the new macros and once with the normal macros provided with the natural table module.<br />
<br />
Let us start with the original macros:<br />
<br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD Text 1 \eTD<br />
\bTD Text 2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD Text 3 \pasteeTD<br />
\bTD Text 4 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
<br />
Watch how the new macros use less code:<br />
<br />
<texcode><br />
\startTABLE<br />
\NC Text 1 \NC Text 2 \NC\NR<br />
\NC Text 3 \NC Text 4 \NC\NR<br />
\stopTABLE<br />
</texcode><br />
<br />
The actual code differs from the prototype that it does not need to collect whole rows and parse them but looks ahead instead.<br />
<br />
[[Category:Tables]]<br />
[[Category:XML]]<br />
tt>\bTD</div>LuPhttps://wiki.contextgarden.net/index.php?title=TABLE&diff=20954TABLE2012-10-23T09:01:57Z<p>LuP: </p>
<hr />
<div>< [[Tables Overview]] | [[XML]] ><br />
<br />
=Introduction=<br />
<br />
This table mode is called &ldquo;natural tables&rdquo; or &ldquo;automatic tables.&rdquo; I'd call it &ldquo;HTML tables,&rdquo; because it's very similar to them. They're especially suited for [[XML]] conversions.<br />
<br />
Beware: every element must use <tt>\b</tt> ... <tt>\e</tt>!<br />
<br />
You find a lot of samples in [[manual:enattab.pdf|enattab.pdf]]<br />
<br />
Willi Egger wrote a [[My Way]] how he set a typesetter's lead type case: [http://dl.contextgarden.net/myway/NaturalTables.pdf Use of natural tables]<br />
<br />
To place a table use:<br />
<br />
<texcode><br />
\placetable{Caption}<br />
{\bTABLE<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\eTABLE}<br />
</texcode><br />
<br />
Here is a more elaborate example:<br />
<br />
<context source=yes><br />
This is our red-coloured table.<br />
\setupTABLE[row][odd][background=color,backgroundcolor=red, width=.2\textwidth]<br />
\bTABLE[split=yes] % allow splitting over page boundaries<br />
\bTR \bTD[nr=3] 1 \eTD \bTD[nc=2] 2/3 \eTD \bTD[nr=3] 4 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD[nc=3] 1/2/3 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 2 \eTD \bTD 3 \eTD \bTD 4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
<br />
= Multipage TABLEs =<br />
<br />
Try to divide your table into...<br />
* <cmd>bTABLEhead</cmd> (table header)<br />
* <cmd>bTABLEnext</cmd> (alternate table header on following pages)<br />
* <cmd>bTABLEbody</cmd> (table body)<br />
* <cmd>bTABLEfoot</cmd> (table footer)<br />
and <cmd>setupTABLE</cmd><tt>[split=yes]</tt> or <tt>[split=repeat]</tt><br />
<br />
see also [[source:core-ntb.tex|core-ntb.tex]]<br />
<br />
If you must <b>split</b> a natural table over several pages, you can<br />
simply do this by adding <tt>\setupTABLE[split=yes]</tt> to your TABLE<br />
definition. Another way is to define it right at the TABLE start<br />
by adding the parameter <tt>[split=yes]</tt> (see example).<br />
However,<br />
{{cmd|startlinecorrection}}<br />
can lead to unpredictable vertical spaces between rows [http://archive.contextgarden.net/message/20100912.112605.8a1aaf13.en.html].<br />
<br />
In this case the <b>table head</b><br />
(all between <cmd>bTABLEhead</cmd> and <cmd>eTABLEhead</cmd>)<br />
is printed only once at the beginning of the table. But if you use <tt>[split=repeat]</tt>,<br />
it is printed on top of every new page, that contains parts of<br />
your multipage table. Please take account of the fact, that the<br />
head cells are enclosed by <cmd>bTH</cmd> and <cmd>eTH</cmd> (and not \[be]TC).<br />
<br />
If you want to use an alternative table header for all following pages,<br />
you can do this by defining an additional header. Just add the second header<br />
between <cmd>bTABLEnext</cmd>...<cmd>eTABLEnext</cmd>,<br />
right after your normal head definition.<br />
Now every additional page of the multipage table starts with the<br />
<b>next table head</b>.<br />
<br />
The <b>table foot</b> is declared between <cmd>bTABLEfoot</cmd> and<br />
<cmd>eTABLEfoot</cmd>. It defines the concluding row of your natural table.<br />
<br />
'''Beware:''' Split tables often begin not on the page (or in the column, if you use them) where they ''could'' start, but on/in the next one.<br />
This is a known limitation due to the complicated calculation of remaining space on the page.<br />
That won't become better before this calculations are newly written in Lua. (Said Hans on 2010-09-24.)<br />
<br />
The following standalone example deals with all the mentioned aspects of natural tables.<br />
Just <i>copy&paste</i> it as a starting point for further experiments...<br />
<br />
<texcode><br />
\starttext<br />
<br />
\setupcolors[state=start]<br />
<br />
% setup for all cells<br />
\setupTABLE[r][each][style=\tfx\it, align=center]<br />
<br />
% setup table head<br />
\setupTABLE[r][first]<br />
[background=color,<br />
backgroundcolor=yellow]<br />
% setup table footer<br />
\setupTABLE[r][last]<br />
[style=bold,<br />
background=color,<br />
backgroundcolor=green]<br />
<br />
\bTABLE[split=repeat,option=stretch]% head on every page, stretch columns<br />
%<br />
% IMPORTANT: use \bTH ... \eTH to enclose the head|next cells<br />
\bTABLEhead<br />
\bTR<br />
\bTH head1 \eTH<br />
\bTH head2 \eTH<br />
\bTH head3 \eTH<br />
\eTR<br />
\eTABLEhead<br />
% <br />
\bTABLEnext % setup for next table head<br />
\bTR [background=color,backgroundcolor=cyan]<br />
\bTH next1 \eTH<br />
\bTH next2 \eTH<br />
\bTH next3 \eTH<br />
\eTR<br />
\eTABLEnext<br />
%<br />
% the table body (main part)<br />
%<br />
\bTABLEbody<br />
%<br />
\dorecurse{100}{% 100 rows<br />
\bTR<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\eTR<br />
}%<br />
%<br />
\eTABLEbody<br />
%<br />
% the table foot<br />
%<br />
\bTABLEfoot<br />
\bTR<br />
\bTC foot1 \eTC<br />
\bTC foot2 \eTC<br />
\bTC foot3 \eTC<br />
\eTR<br />
\eTABLEfoot<br />
%<br />
\eTABLE<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= Tables in multiple columns =<br />
<br />
... just work (at least in luaTeX and not here...). See the following example.<br />
<br />
<texcode><br />
\starttext<br />
\startcolumns[n=3]<br />
\bTABLE<br />
\dorecurse{21}<br />
{\bTR \bTD a\eTD \bTD b \eTD \eTR}<br />
\eTABLE<br />
\stopcolumns<br />
\stoptext<br />
</texcode><br />
<br />
= Creating tables from CSV data (Comma Separated Values) =<br />
<br />
See also [[m-database|the database module]]!<br />
<br />
and [http://dl.contextgarden.net/myway/csv.pdf Creating Tables using CSV (Comma-separated values)] by Mojca Miklavec<br />
<br />
<br />
<!-- Maybe some other place or a separate page is more appropriate for this section --><br />
<br />
An interesting example of creating a table using comma separated values was posted to the [http://archive.contextgarden.net/message/20050923.193302.f2110c93.en.html mailing list] by [[User:ChristopherCreutzig|Christopher Creutzig]]<br />
<br />
The following macros take care of processing CSV data:<br />
<texcode><br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
</texcode><br />
<br />
The next lines are an example of transforming the data into a natural table, but can be easily adapted to any type of the table or perhaps (mis)used in even more strange ways:<br />
<br />
<texcode><br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
</texcode><br />
<br />
The following lines will then finally result in a desired table:<br />
<br />
<texcode><br />
% some additional settings for the table may be made as well<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style=bold] % how to override the \tt in the second column?<br />
<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A5]<br />
<br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
<br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style={\rm\bf}]<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</context><br />
<br />
Some remarks: the (tentative) code ignores the fact that<br />
* csv data may optionally be enclosed in "" quotes that have to be removed (to be done in \TBLentry) <br />
* quoted strings may contain commas themselves (which means writing a custom version of \processcommalist instead).<br />
<br />
See also {{cmd|processseparatedlist}}.<br />
<br />
= Designing complex TABLEs =<br />
<br />
Everything is easy when a simple grid is enough. Unfortunately, this<br />
is not the case most of the time, tables tend to have information<br />
which should flow accross cell boundaries either vertically<br />
or horizontally. One of the reasons to use TABLE instead of the<br />
table environment is that TABLE provides an easy (relatively speaking, <br />
at least) way to make merged cells to both directions.<br />
<br />
There are probably as many ways to design TABLEs as there are<br />
users, but a simple one to begin with is to start with a<br />
grid:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\bTABLE<br />
\bTR \bTD r1c1 \eTD \bTD r1c2 \eTD \bTD r1c3 \eTD \bTD r1c4 \eTD \bTD r1c5 \eTD \bTD r1c6 \eTD \eTR<br />
\bTR \bTD r2c1 \eTD \bTD r2c2 \eTD \bTD r2c3 \eTD \bTD r2c4 \eTD \bTD r2c5 \eTD \bTD r2c6 \eTD \eTR<br />
\bTR \bTD r3c1 \eTD \bTD r3c2 \eTD \bTD r3c3 \eTD \bTD r3c4 \eTD \bTD r3c5 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD r4c2 \eTD \bTD r4c3 \eTD \bTD r4c4 \eTD \bTD r4c5 \eTD \bTD r4c6 \eTD \eTR<br />
\bTR \bTD r5c1 \eTD \bTD r5c2 \eTD \bTD r5c3 \eTD \bTD r5c4 \eTD \bTD r5c5 \eTD \bTD r5c6 \eTD \eTR<br />
\bTR \bTD r6c1 \eTD \bTD r6c2 \eTD \bTD r6c3 \eTD \bTD r6c4 \eTD \bTD r6c5 \eTD \bTD r6c6 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The desired table layout is then drawn onto this grid, and the top left corner cell<br />
of each cell in the final layout identified:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nc=2,nr=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The cells are listed from left to right and up to down. Each larger cell is then given<br />
it size by using <tt>nc=...</tt> and <tt>nr=...</tt> parameters with <tt>\bTD</tt>. The<br />
code producing the table above is:<br />
<br />
<texcode><br />
\setupTABLE[r][each][height=1cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nr=2,nc=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
<br />
N.B. There is an ugly hack in the code. An empty first row with zero height and no borders<br />
is added. If the row is omitted, then something odd happens to the number of<br />
columns. The table should have all cells, so this may be a bug. (Or then I have<br />
blundered something with this example, possibly.)<br />
<br />
Everything rectangular can be done with TABLE, as long as it can be fit in the grid. The grid<br />
does not have to be equidistant, and if its dimensions are omitted, the program<br />
will fit the data in. L-shaped or other complex cell shapes are not possible.<br />
Using them would be a bit odd, in any case, as alignment and text flow problems<br />
would be quite interesting.<br />
<br />
<br />
== Cell Addressing and Frames ==<br />
<br />
The setup commands for TABLE do not seem to be very verbosedly commented.<br />
There are, however, a few shorthands, which are useful to understand.<br />
First of all, there are several ways to address cells. This is a brief<br />
summary of some of them:<br />
<br />
<texcode><br />
\setupTABLE[r][(list of rows)][...]<br />
\setupTABLE[c][(list of columns)][...]<br />
\setupTABLE[(list of columns)][(list of rows)][...]<br />
</texcode><br />
<br />
A list contains one or more numbers separated by commas.<br />
Word "last" is equivalent to the number of the last row or<br />
column. The complete list can be replaced by the word "each"<br />
to address all cells on the row/column.<br />
<br />
Let us consider the following table:<br />
<br />
<texcode><br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=1.0cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
...<br />
</texcode><br />
<br />
In plain language the rows are interpreted as follows:<br />
<br />
* Align each cell in each column (i.e. all cells) horizontally in the middle<br />
and vertically in the middle (lohi), and remove all frames (borders)<br />
* The height of rows 2 -- 6 is 1.0 cm<br />
* Draw a line on top of rows 2 and 4<br />
* Draw a line to the right side of columns 1 -- 3<br />
<br />
In this case the table is slightly complicated, there are some split cells,<br />
as shown below:<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
The cell numbering is well worth noting. It is very logical (upper<br />
leftmost part of a combined cell), but sometimes the results are<br />
surprising in the beginning.<br />
<br />
The important point about cell numbering is that there is really<br />
a difference between "bottom border of row 3" and "top border of<br />
row 4". To illustrate this, let us change the frame setups:<br />
<br />
<texcode><br />
\setupTABLE[r][2,4][topframe=on]<br />
</texcode><br />
<br />
is changed to<br />
<br />
<texcode><br />
\setupTABLE[r][1,3][bottomframe=on]<br />
</texcode><br />
<br />
At first sight this is exactly the same thing. But...<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][1,3][bottomframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
Where did the horizontal line in column 3 disappear? Nowhere. There is no<br />
row 3 in column 3, so there cannot be a frame under it. This problem<br />
can be overcome by using topframe and leftframe instead of bottom and<br />
right, as the cells below and to the right of a border have to exist.<br />
<br />
However, this solution leaves the problem of bottom and rightmost borders.<br />
How to draw a line in the bottom of the table? Using <br />
<tt>\setupTABLE[r][6][bottomframe=on]</tt> will leave the gap in columns 3 and 4, <br />
and <tt>\setupTABLE[r][7][topframe=on]</tt> is not possible, as there is no <br />
row 7. The clever idea of using "last" instead of the row number (6) will fail, <br />
as "last" seems to behave exactly the same way as number 6.<br />
<br />
One useful method is to switch on the borders cell by<br />
cell by adding <tt>\setupTABLE[3,4][4][bottomframe=on]</tt>, i.e.<br />
draw a border under cells r4c3 and r4c4.<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\setupTABLE[r][6][bottomframe=on]<br />
\setupTABLE[3,4][4][bottomframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Column Offset/Gap ==<br />
<br />
From the mailing list at 2005-11-09 by Vit Zyka, modified by Hans Hagen:<br />
<br />
<texcode><br />
\starttext<br />
<br />
% distance mechanism, per column (H)<br />
<br />
\start<br />
\setupTABLE[c][1][distance=2em]<br />
\setupTABLE[c][2][distance=3em]<br />
<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
<br />
\bTABLE[option=stretch]<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
\stop<br />
<br />
% distance mechanism, per table (V)<br />
<br />
\framed[offset=none]{%<br />
\setupTABLE[column][2][align=left]<br />
\setupTABLE[column][3][align=right]<br />
\bTABLE[columndistance=2cm,leftmargindistance=.3cm,rightmargindistance=.5cm]<br />
\bTR<br />
\bTH[nc=3] Table head\eTH<br />
\eTR<br />
\bTR\bTD[nc=2] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=left] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=middle] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD A\eTD\bTD B\eTD\bTD C\eTD\eTR<br />
\bTR\bTD Aa\eTD\bTD Bb\eTD\bTD Cccc\eTD\eTR<br />
\bTR\bTD[nc=3,align=middle] ABC\eTD\eTR<br />
\eTABLE<br />
}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Make a cell bold ==<br />
<br />
Drawing bold lines around a cell is done using the<br />
<tt>[rulethickness=''dim'']</tt> key on a cell. The thicker rules will<br />
offset the text inside the cell both downwards and sideways, so care<br />
should be taken that the cell's increased rulethickness is offset by an<br />
equal decrease in offset.<br />
<br />
<context source="yes" text="produces"><br />
\setupTABLE[row][each][rulethickness=.25pt,offset=\dimexpr1mm+1.75pt] <br />
\bTABLE<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2/3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD[rulethickness=2pt,offset=1mm] 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
== Rules ==<br />
<br />
=== Example: an invoice with thick rules ===<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
{\bfa Invoice}<br />
\switchtobodyfont[6pt]<br />
\blank<br />
\bTABLE<br />
\setupTABLE[frame=off,offset=1mm]<br />
\setupTABLE[row][*][height=7.25mm]<br />
\setupTABLE[column][1,2] [width=20mm,offset=\dimexpr1mm+2pt,align=flushleft]<br />
\setupTABLE[column][3,4,5][width=20mm,offset=\dimexpr1mm+2pt,align=flushright]<br />
\bTR[bottomframe=on, rulethickness=2pt,offset=1mm]<br />
\bTD\bf Date \eTD<br />
\bTD\bf Description \eTD<br />
\bTD\bf Quantity \eTD<br />
\bTD\bf Price \eTD<br />
\bTD\bf Total \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 1 \eTD<br />
\bTD 10.0 \eTD<br />
\bTD 6.00 \eTD<br />
\bTD 60.00 \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 2 \eTD<br />
\bTD 2.0 \eTD<br />
\bTD 3.00 \eTD<br />
\bTD 6.00 \eTD<br />
\eTR<br />
\bTR[topframe=on,rulethickness=2pt,offset=1mm]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] Subtotal \eTD<br />
\bTD 66.00 \eTD<br />
\eTR<br />
\bTR[offset=\dimexpr1mm+2pt]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] VAT 19\% \eTD<br />
\bTD 12.54 \eTD<br />
\eTR<br />
\bTR<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] \bf Total \eTD<br />
\bTD 78.54 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
=== Rules with different thickness ===<br />
<br />
There is only one value for all four borders. However, MetaPost can be used as a workaround until the separate "rulethickness" values are implemented.<br />
<br />
The following example (mkiv only!) by Wolfgang Schuster shows a table using MetaPost for the rules:<br />
<br />
<context source=yes mode=mkiv text="gives:"><br />
\startuseMPgraphic{tableborders}<br />
<br />
draw leftboundary OverlayBox withpen pensquare scaled \frameddimension {leftrulethickness} ;<br />
draw rightboundary OverlayBox withpen pensquare scaled \frameddimension {rightrulethickness} ;<br />
draw topboundary OverlayBox withpen pensquare scaled \frameddimension {toprulethickness} ;<br />
draw bottomboundary OverlayBox withpen pensquare scaled \frameddimension{bottomrulethickness} ;<br />
<br />
clip currentpicture to OverlayBox<br />
leftenlarged (\frameddimension {leftrulethickness}/2)<br />
rightenlarged (\frameddimension {rightrulethickness}/2)<br />
topenlarged (\frameddimension {toprulethickness}/2)<br />
bottomenlarged (\frameddimension{bottomrulethickness}/2) ;<br />
<br />
setbounds currentpicture to OverlayBox ;<br />
<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay[tableborders][\useMPgraphic{tableborders}]<br />
<br />
\startsetups tableborders<br />
<br />
\setupTABLE<br />
[ background={color,tableborders},<br />
frame=off,<br />
backgroundoffset=0pt,<br />
leftrulethickness=\framedparameter{rulethickness},<br />
rightrulethickness=\framedparameter{rulethickness},<br />
toprulethickness=\framedparameter{rulethickness},<br />
bottomrulethickness=\framedparameter{rulethickness}]<br />
<br />
\setupTABLE[row] [odd] [backgroundcolor=lightgray]<br />
\setupTABLE[row] [first][backgroundcolor=gray,bottomrulethickness=2pt]<br />
\setupTABLE[row] [last] [toprulethickness=2pt,bottomrulethickness=2pt]<br />
\setupTABLE[first][last] [leftrulethickness=2pt]<br />
\setupTABLE[last] [last] [rightrulethickness=2pt]<br />
<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\bTABLE<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\blank<br />
<br />
\bTABLE[setups=tableborders]<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\stoptext<br />
</context><br />
<br />
See the corresponding thread on the list: [http://www.ntg.nl/pipermail/ntg-context/2011/058549.html rules with different thickness]<br />
<br />
=== Thick bottom rules ===<br />
<br />
This is a simplified version of the example above.<br />
<br />
<context source=yes mode=mkiv text="Gives:"><br />
\startuseMPgraphic{MP:thickBtm}<br />
draw bottomboundary OverlayBox withpen pensquare scaled \frameddimension{bottomrulethickness};<br />
clip currentpicture to OverlayBox;<br />
setbounds currentpicture to OverlayBox;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay[OL:thickBtm][\useMPgraphic{MP:thickBtm}]<br />
<br />
\starttext<br />
\bTABLE<br />
\setupTABLE[align=middle]<br />
\setupTABLE[header][background={OL:thickBtm},bottomrulethickness=4pt]<br />
\setupTABLE[row][4][background={OL:thickBtm},bottomrulethickness=2pt]<br />
%<br />
\bTABLEhead\bTR\dorecurse{3}{\bTH#1\eTH}\eTR\eTABLEhead<br />
\bTABLEbody\dorecurse{6}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}\eTABLEbody<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
=== Diagonal rules ===<br />
<br />
Sometimes a diagonal rule is required in the top left corner cell of a table to create two fields, one for the left column and one for the top row.<br />
<br />
<br />
<context mode="mkiv" source="yes" text="Gives:"><br />
\startuseMPgraphic{DiagonalRule}<br />
rulethickness := \frameddimension{rulethickness};<br />
<br />
drawoptions(<br />
withpen pencircle scaled rulethickness<br />
withcolor \MPcolor{\framedparameter{framecolor}});<br />
<br />
pair leftcorner, rightcorner;<br />
leftcorner := (rulethickness, \overlayheight-rulethickness);<br />
rightcorner := (\overlaywidth-rulethickness, rulethickness);<br />
<br />
draw leftcorner -- rightcorner;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[DiagonalRule]<br />
[\useMPgraphic{DiagonalRule}]<br />
<br />
\define[2]\DiagonalLabel{%<br />
\setuptabulate [after={\blank[\frameddimension{offset}]}]<br />
\starttabulate [|p|r|]<br />
\NC \NC #2 \NC\NR<br />
\NC #1 \NC \NC\NR<br />
\stoptabulate<br />
}<br />
<br />
\starttext<br />
\setupTABLE [row] [1] [width=2cm]<br />
\bTABLE<br />
\bTR<br />
\bTD [background=DiagonalRule]<br />
\DiagonalLabel{Foo}{Bar}<br />
\eTD<br />
\bTD Second \eTD<br />
\bTD Third \eTD<br />
\eTR<br />
\bTR<br />
\bTD Alpha \eTD<br />
\bTD Beta \eTD<br />
\bTD Gamma \eTD<br />
\eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
This solution has (at least) one caveat: Because the first<br />
tabulate column is set in paragraph mode, it will eat up as much<br />
space as <em>possible</em>, in contrast to occupying as much space as<br />
</em>necessary</em>. That is why the width of the column has to be set<br />
explicitly.<br />
<br />
== Using character alignment ==<br />
<br />
ConTeXt can align columns of numbers on a character (often a decimal point to align accounting data) automatically, removing the need to add fixed spaces into your document. For any such column you need to specify the character on which to align. You use the <tt>aligncharacter=yes</tt> parameter to set up character alignment, <tt>alignmentcharacter={.}</tt> to say what the character should be (in this case a full stop) and <tt>align=middle</tt> to set the overall alignment of the column.<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},<br />
aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
You'll note that the final line, because it has no <code>.</code> in the number, gets aligned under the right-hand side of the numbers. In most circumstances you would want such a number aligned with the left-hand set of digits. To so do, issue the following command in your preamble:<br />
<br />
<texcode><br />
\chardef\characteralignmentmode=2<br />
</texcode><br />
<br />
and now the table above will turn out like this:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\chardef\characteralignmentmode=2<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
If there's no <code>alignmentcharacter</code> in the cell, the content will be aligned in the following way depending on the value of <code>\characteralignmentmode</code>:<br />
<table style="border:1px solid #DDDDDD;"><br />
<tr style="background-color:#DDDDDD; font-weight: bold;"><td>mode</td><td width="200"></td><td>.</td><td width="200"></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">0</td><td colspan="3" align="center">centered</td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">1</td><td align="left">left in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">2</td><td align="right">right in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">3</td><td></td><td style="background-color:#DDDDDD">.</td><td align="left">left in after</td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">4</td><td></td><td style="background-color:#DDDDDD">.</td><td align="right">right in after</td></tr><br />
</table><br />
<br />
== Specifying the cell column ==<br />
<br />
When writing a table you can omit empty cells and define only cells for specified columns. To have this feature fully available you need to have a beta or a quite fresh ConTeXt version.<br />
<br />
Two methods are available:<br />
<br />
* With the TD "n" option, the undefined cells are merged into a single spanned cell.<br />
* With the TD "m" option, the undefined cells appear as empty normal cells.<br />
<br />
Here is an example using the "n" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[n=2] d2 \eTD\bTD[n=5] d5 \eTD\bTD[n=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[n=4] f4 \eTD\bTD[n=5] f5 \eTD\bTD[n=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
Here is an example using the "m" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[m=2] d2 \eTD\bTD[m=5] d5 \eTD\bTD[m=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[m=4] f4 \eTD\bTD[m=5] f5 \eTD\bTD[m=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Round corners ==<br />
<br />
For a different approach for round corners and colored background follow the text after this example.<br />
<br />
It is possible to round the corners of the table if you turn off the main frame of the table and frame the table in {{cmd|framed}}. Compare two different approaches in the first and second example.<br />
<br />
You can't color the background of the table with round corners unless the frame rulethickness is not big enough to cover the rectangular corners of the background (second example). Well, you can if you frame the table twice. Once in the thick white frame and then in the thin frame with negative offset and slightly smaller corner radius (third example). Be aware of other complications -- notice that the thick white frame is still visible in the text above it.<br />
<br />
<context source="yes"><br />
\starttext<br />
\setupcolors[state=start] <br />
%\showstruts<br />
\setupTABLE[background=color,backgroundcolor=yellow]<br />
\setupframed[framecolor=darkgreen]<br />
<br />
\defineparagraphs[ThreeCols]<br />
<br />
\startThreeCols<br />
<br />
First<br />
<br />
\def\StartTable<br />
{\setupTABLE[row] [first][topframe=off]%<br />
\setupTABLE[row] [last] [bottomframe=off]%<br />
\setupTABLE[column][first][leftframe=off]%<br />
\setupTABLE[column][last] [rightframe=off]%<br />
\framed[strut=no,corner=round,offset=.5\linewidth]<br />
\bgroup}<br />
<br />
\def\StopTable<br />
{\egroup}<br />
<br />
\StartTable<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\StopTable<br />
<br />
\nextThreeCols<br />
<br />
Second<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,offset=.5\linewidth,,rulethickness=1mm]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
<br />
\nextThreeCols<br />
<br />
Third<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,<br />
radius=1.4mm,offset=-1mm,,rulethickness=.1mm]\bgroup<br />
\framed[strut=no,corner=round,<br />
radius=1.5mm,offset=0mm,,rulethickness=1mm,framecolor=white]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
\egroup<br />
<br />
\stopThreeCols<br />
<br />
\stoptext<br />
</context><br />
<br />
From 2006-10-11 on, ConTeXt contains one more mechanism for round corners. Watch the example:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\starttext<br />
\setupcolors[state=start]<br />
\setupTABLE [y] [first][background=color,backgroundcolor=blue,frame=off,bottomframe=on,topframe=on,framecolor=white]<br />
\setupTABLE [first][first][backgroundcorner=2,corner=10,frame=on]<br />
\setupTABLE [last] [first][backgroundcorner=4,corner=12,frame=on]<br />
\setupTABLE [row] [each] [background=color,backgroundcolor=blue,frame=on,framecolor=white]<br />
\setupTABLE [first][2] [corner=8]<br />
\setupTABLE [last] [2] [corner=5]<br />
\setupTABLE [first][last] [corner=7]<br />
\setupTABLE [last] [last] [corner=6]<br />
<br />
\bTABLE[frame=off,align=middle]<br />
\bTR \bTD one \eTD \bTD two \eTD \bTD three \eTD \eTR<br />
\bTR \bTD first \eTD \bTD second \eTD \bTD third \eTD \eTR<br />
\bTR \bTD alpha \eTD \bTD beta \eTD \bTD gamma \eTD \eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
== Other options ==<br />
<br />
Some other useful options that were not covered above:<br />
* <tt>align=yes</tt> will align the text both left and right justified<br />
* <tt>loffset</tt>, <tt>roffset</tt>, <tt>toffset</tt>, <tt>boffset</tt> can be used in addition to <tt>offset</tt> to specify cell content offsets in each direction separately, see also {{cmd|framed}}<br />
<br />
= TABLEs with old table syntax =<br />
<br />
From the mailing list in March 2009, by Wolfgang Schuster and Hans Hagen:<br />
<br />
<texcode><br />
\def\startTABLE<br />
{\dosingleempty\dostartTABLE}<br />
<br />
\def\dostartTABLE[#1]%<br />
{\bgroup<br />
\bTABLE[#1]%<br />
\let\NC\doTABLENC<br />
\let\NR\doTABLENR<br />
\let\bTR\relax<br />
\let\bTD\relax<br />
\let\bTH\relax<br />
\let\bTN\relax}<br />
<br />
\def\stopTABLE<br />
{\eTABLE<br />
\egroup}<br />
<br />
\newconditional\inTABLEnc<br />
<br />
\unexpanded\def\doTABLENR<br />
{\eTR<br />
\setfalse\inTABLEnc}<br />
<br />
\unexpanded\def\doTABLENC<br />
{\futurelet\next\dodoTABLENC}<br />
<br />
\def\dodoTABLENC<br />
{\ifx\next\doTABLENR \else<br />
\expandafter\dododoTABLENC<br />
\fi}<br />
<br />
\long\def\dododoTABLENC#1\NC<br />
{\ifconditional\inTABLEnc\else\settrue\inTABLEnc\parseTR[][]\fi<br />
\dodoubleempty\parseTD#1\eTD\NC}<br />
</texcode><br />
<br />
This is now part of the core as the [[source:tabl-nte.tex|NTE module]]. Quoting its internal documentation:<br />
<br />
This module is suggested by Wolfgang Schuster who also prototyped it and came up with the rationale:<br />
<br />
This module provides an easy way to use natural in a similiar way as the older table module (based on the [[TABLE]] macros) and the newer [[tabulate]] module.<br />
<br />
You can see the advantage in the following table, once created with the new macros and once with the normal macros provided with the natural table module.<br />
<br />
Let us start with the original macros:<br />
<br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD Text 1 \eTD<br />
\bTD Text 2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD Text 3 \pasteeTD<br />
\bTD Text 4 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
<br />
Watch how the new macros use less code:<br />
<br />
<texcode><br />
\startTABLE<br />
\NC Text 1 \NC Text 2 \NC\NR<br />
\NC Text 3 \NC Text 4 \NC\NR<br />
\stopTABLE<br />
</texcode><br />
<br />
The actual code differs from the prototype that it does not need to collect whole rows and parse them but looks ahead instead.<br />
<br />
[[Category:Tables]]<br />
[[Category:XML]]<br />
tt>\bTD</div>LuPhttps://wiki.contextgarden.net/index.php?title=TABLE&diff=20874TABLE2012-10-04T07:42:45Z<p>LuP: </p>
<hr />
<div>< [[Tables Overview]] | [[XML]] ><br />
<br />
=Introduction=<br />
<br />
This table mode is called &ldquo;natural tables&rdquo; or &ldquo;automatic tables.&rdquo; I'd call it &ldquo;HTML tables,&rdquo; because it's very similar to them. They're especially suited for [[XML]] conversions.<br />
<br />
Beware: every element must use <tt>\b</tt> ... <tt>\e</tt>!<br />
<br />
You find a lot of samples in [[manual:enattab.pdf|enattab.pdf]]<br />
<br />
Willi Egger wrote a [[My Way]] how he set a typesetter's lead type case: [http://dl.contextgarden.net/myway/NaturalTables.pdf Use of natural tables]<br />
<br />
To place a table use:<br />
<br />
<texcode><br />
\placetable{Caption}<br />
{\bTABLE<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\eTABLE}<br />
</texcode><br />
<br />
Here is a more elaborate example:<br />
<br />
<context source=yes><br />
This is our red-coloured table.<br />
\setupTABLE[row][odd][background=color,backgroundcolor=red, width=.2\textwidth]<br />
\bTABLE[split=yes] % allow splitting over page boundaries<br />
\bTR \bTD[nr=3] 1 \eTD \bTD[nc=2] 2/3 \eTD \bTD[nr=3] 4 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD[nc=3] 1/2/3 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 2 \eTD \bTD 3 \eTD \bTD 4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
<br />
= Multipage TABLEs =<br />
<br />
Try to divide your table into...<br />
* <cmd>bTABLEhead</cmd> (table header)<br />
* <cmd>bTABLEnext</cmd> (alternate table header on following pages)<br />
* <cmd>bTABLEbody</cmd> (table body)<br />
* <cmd>bTABLEfoot</cmd> (table footer)<br />
and <cmd>setupTABLE</cmd><tt>[split=yes]</tt> or <tt>[split=repeat]</tt><br />
<br />
see also [[source:core-ntb.tex|core-ntb.tex]]<br />
<br />
If you must <b>split</b> a natural table over several pages, you can<br />
simply do this by adding <tt>\setupTABLE[split=yes]</tt> to your TABLE<br />
definition. Another way is to define it right at the TABLE start<br />
by adding the parameter <tt>[split=yes]</tt> (see example).<br />
However,<br />
{{cmd|startlinecorrection}}<br />
can lead to unpredictable vertical spaces between rows [http://archive.contextgarden.net/message/20100912.112605.8a1aaf13.en.html].<br />
<br />
In this case the <b>table head</b><br />
(all between <cmd>bTABLEhead</cmd> and <cmd>eTABLEhead</cmd>)<br />
is printed only once at the beginning of the table. But if you use <tt>[split=repeat]</tt>,<br />
it is printed on top of every new page, that contains parts of<br />
your multipage table. Please take account of the fact, that the<br />
head cells are enclosed by <cmd>bTH</cmd> and <cmd>eTH</cmd> (and not \[be]TC).<br />
<br />
If you want to use an alternative table header for all following pages,<br />
you can do this by defining an additional header. Just add the second header<br />
between <cmd>bTABLEnext</cmd>...<cmd>eTABLEnext</cmd>,<br />
right after your normal head definition.<br />
Now every additional page of the multipage table starts with the<br />
<b>next table head</b>.<br />
<br />
The <b>table foot</b> is declared between <cmd>bTABLEfoot</cmd> and<br />
<cmd>eTABLEfoot</cmd>. It defines the concluding row of your natural table.<br />
<br />
'''Beware:''' Split tables often begin not on the page (or in the column, if you use them) where they ''could'' start, but on/in the next one.<br />
This is a known limitation due to the complicated calculation of remaining space on the page.<br />
That won't become better before this calculations are newly written in Lua. (Said Hans on 2010-09-24.)<br />
<br />
The following standalone example deals with all the mentioned aspects of natural tables.<br />
Just <i>copy&paste</i> it as a starting point for further experiments...<br />
<br />
<texcode><br />
\starttext<br />
<br />
\setupcolors[state=start]<br />
<br />
% setup for all cells<br />
\setupTABLE[r][each][style=\tfx\it, align=center]<br />
<br />
% setup table head<br />
\setupTABLE[r][first]<br />
[background=color,<br />
backgroundcolor=yellow]<br />
% setup table footer<br />
\setupTABLE[r][last]<br />
[style=bold,<br />
background=color,<br />
backgroundcolor=green]<br />
<br />
\bTABLE[split=repeat,option=stretch]% head on every page, stretch columns<br />
%<br />
% IMPORTANT: use \bTH ... \eTH to enclose the head|next cells<br />
\bTABLEhead<br />
\bTR<br />
\bTH head1 \eTH<br />
\bTH head2 \eTH<br />
\bTH head3 \eTH<br />
\eTR<br />
\eTABLEhead<br />
% <br />
\bTABLEnext % setup for next table head<br />
\bTR [background=color,backgroundcolor=cyan]<br />
\bTH next1 \eTH<br />
\bTH next2 \eTH<br />
\bTH next3 \eTH<br />
\eTR<br />
\eTABLEnext<br />
%<br />
% the table body (main part)<br />
%<br />
\bTABLEbody<br />
%<br />
\dorecurse{100}{% 100 rows<br />
\bTR<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\eTR<br />
}%<br />
%<br />
\eTABLEbody<br />
%<br />
% the table foot<br />
%<br />
\bTABLEfoot<br />
\bTR<br />
\bTC foot1 \eTC<br />
\bTC foot2 \eTC<br />
\bTC foot3 \eTC<br />
\eTR<br />
\eTABLEfoot<br />
%<br />
\eTABLE<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= Tables in multiple columns =<br />
<br />
... just work (at least in luaTeX and not here...). See the following example.<br />
<br />
<texcode><br />
\starttext<br />
\startcolumns[n=3]<br />
\bTABLE<br />
\dorecurse{21}<br />
{\bTR \bTD a\eTD \bTD b \eTD \eTR}<br />
\eTABLE<br />
\stopcolumns<br />
\stoptext<br />
</texcode><br />
<br />
= Creating tables from CSV data (Comma Separated Values) =<br />
<br />
See also [[m-database|the database module]]!<br />
<br />
and [http://dl.contextgarden.net/myway/csv.pdf Creating Tables using CSV (Comma-separated values)] by Mojca Miklavec<br />
<br />
<br />
<!-- Maybe some other place or a separate page is more appropriate for this section --><br />
<br />
An interesting example of creating a table using comma separated values was posted to the [http://archive.contextgarden.net/message/20050923.193302.f2110c93.en.html mailing list] by [[User:ChristopherCreutzig|Christopher Creutzig]]<br />
<br />
The following macros take care of processing CSV data:<br />
<texcode><br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
</texcode><br />
<br />
The next lines are an example of transforming the data into a natural table, but can be easily adapted to any type of the table or perhaps (mis)used in even more strange ways:<br />
<br />
<texcode><br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
</texcode><br />
<br />
The following lines will then finally result in a desired table:<br />
<br />
<texcode><br />
% some additional settings for the table may be made as well<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style=bold] % how to override the \tt in the second column?<br />
<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A5]<br />
<br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
<br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style={\rm\bf}]<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</context><br />
<br />
Some remarks: the (tentative) code ignores the fact that<br />
* csv data may optionally be enclosed in "" quotes that have to be removed (to be done in \TBLentry) <br />
* quoted strings may contain commas themselves (which means writing a custom version of \processcommalist instead).<br />
<br />
See also {{cmd|processseparatedlist}}.<br />
<br />
= Designing complex TABLEs =<br />
<br />
Everything is easy when a simple grid is enough. Unfortunately, this<br />
is not the case most of the time, tables tend to have information<br />
which should flow accross cell boundaries either vertically<br />
or horizontally. One of the reasons to use TABLE instead of the<br />
table environment is that TABLE provides an easy (relatively speaking, <br />
at least) way to make merged cells to both directions.<br />
<br />
There are probably as many ways to design TABLEs as there are<br />
users, but a simple one to begin with is to start with a<br />
grid:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\bTABLE<br />
\bTR \bTD r1c1 \eTD \bTD r1c2 \eTD \bTD r1c3 \eTD \bTD r1c4 \eTD \bTD r1c5 \eTD \bTD r1c6 \eTD \eTR<br />
\bTR \bTD r2c1 \eTD \bTD r2c2 \eTD \bTD r2c3 \eTD \bTD r2c4 \eTD \bTD r2c5 \eTD \bTD r2c6 \eTD \eTR<br />
\bTR \bTD r3c1 \eTD \bTD r3c2 \eTD \bTD r3c3 \eTD \bTD r3c4 \eTD \bTD r3c5 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD r4c2 \eTD \bTD r4c3 \eTD \bTD r4c4 \eTD \bTD r4c5 \eTD \bTD r4c6 \eTD \eTR<br />
\bTR \bTD r5c1 \eTD \bTD r5c2 \eTD \bTD r5c3 \eTD \bTD r5c4 \eTD \bTD r5c5 \eTD \bTD r5c6 \eTD \eTR<br />
\bTR \bTD r6c1 \eTD \bTD r6c2 \eTD \bTD r6c3 \eTD \bTD r6c4 \eTD \bTD r6c5 \eTD \bTD r6c6 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The desired table layout is then drawn onto this grid, and the top left corner cell<br />
of each cell in the final layout identified:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nc=2,nr=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The cells are listed from left to right and up to down. Each larger cell is then given<br />
it size by using <tt>nc=...</tt> and <tt>nr=...</tt> parameters with <tt>\bTD</tt>. The<br />
code producing the table above is:<br />
<br />
<texcode><br />
\setupTABLE[r][each][height=1cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nr=2,nc=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
<br />
N.B. There is an ugly hack in the code. An empty first row with zero height and no borders<br />
is added. If the row is omitted, then something odd happens to the number of<br />
columns. The table should have all cells, so this may be a bug. (Or then I have<br />
blundered something with this example, possibly.)<br />
<br />
Everything rectangular can be done with TABLE, as long as it can be fit in the grid. The grid<br />
does not have to be equidistant, and if its dimensions are omitted, the program<br />
will fit the data in. L-shaped or other complex cell shapes are not possible.<br />
Using them would be a bit odd, in any case, as alignment and text flow problems<br />
would be quite interesting.<br />
<br />
<br />
== Cell Addressing and Frames ==<br />
<br />
The setup commands for TABLE do not seem to be very verbosedly commented.<br />
There are, however, a few shorthands, which are useful to understand.<br />
First of all, there are several ways to address cells. This is a brief<br />
summary of some of them:<br />
<br />
<texcode><br />
\setupTABLE[r][(list of rows)][...]<br />
\setupTABLE[c][(list of columns)][...]<br />
\setupTABLE[(list of columns)][(list of rows)][...]<br />
</texcode><br />
<br />
A list contains one or more numbers separated by commas.<br />
Word "last" is equivalent to the number of the last row or<br />
column. The complete list can be replaced by the word "each"<br />
to address all cells on the row/column.<br />
<br />
Let us consider the following table:<br />
<br />
<texcode><br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=1.0cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
...<br />
</texcode><br />
<br />
In plain language the rows are interpreted as follows:<br />
<br />
* Align each cell in each column (i.e. all cells) horizontally in the middle<br />
and vertically in the middle (lohi), and remove all frames (borders)<br />
* The height of rows 2 -- 6 is 1.0 cm<br />
* Draw a line on top of rows 2 and 4<br />
* Draw a line to the right side of columns 1 -- 3<br />
<br />
In this case the table is slightly complicated, there are some split cells,<br />
as shown below:<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
The cell numbering is well worth noting. It is very logical (upper<br />
leftmost part of a combined cell), but sometimes the results are<br />
surprising in the beginning.<br />
<br />
The important point about cell numbering is that there is really<br />
a difference between "bottom border of row 3" and "top border of<br />
row 4". To illustrate this, let us change the frame setups:<br />
<br />
<texcode><br />
\setupTABLE[r][2,4][topframe=on]<br />
</texcode><br />
<br />
is changed to<br />
<br />
<texcode><br />
\setupTABLE[r][1,3][bottomframe=on]<br />
</texcode><br />
<br />
At first sight this is exactly the same thing. But...<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][1,3][bottomframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
Where did the horizontal line in column 3 disappear? Nowhere. There is no<br />
row 3 in column 3, so there cannot be a frame under it. This problem<br />
can be overcome by using topframe and leftframe instead of bottom and<br />
right, as the cells below and to the right of a border have to exist.<br />
<br />
However, this solution leaves the problem of bottom and rightmost borders.<br />
How to draw a line in the bottom of the table? Using <br />
<tt>\setupTABLE[r][6][bottomframe=on]</tt> will leave the gap in columns 3 and 4, <br />
and <tt>\setupTABLE[r][7][topframe=on]</tt> is not possible, as there is no <br />
row 7. The clever idea of using "last" instead of the row number (6) will fail, <br />
as "last" seems to behave exactly the same way as number 6.<br />
<br />
One useful method is to switch on the borders cell by<br />
cell by adding <tt>\setupTABLE[3,4][4][bottomframe=on]</tt>, i.e.<br />
draw a border under cells r4c3 and r4c4.<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\setupTABLE[r][6][bottomframe=on]<br />
\setupTABLE[3,4][4][bottomframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Column Offset/Gap ==<br />
<br />
From the mailing list at 2005-11-09 by Vit Zyka, modified by Hans Hagen:<br />
<br />
<texcode><br />
\starttext<br />
<br />
% distance mechanism, per column (H)<br />
<br />
\start<br />
\setupTABLE[c][1][distance=2em]<br />
\setupTABLE[c][2][distance=3em]<br />
<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
<br />
\bTABLE[option=stretch]<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
\stop<br />
<br />
% distance mechanism, per table (V)<br />
<br />
\framed[offset=none]{%<br />
\setupTABLE[column][2][align=left]<br />
\setupTABLE[column][3][align=right]<br />
\bTABLE[columndistance=2cm,leftmargindistance=.3cm,rightmargindistance=.5cm]<br />
\bTR<br />
\bTH[nc=3] Table head\eTH<br />
\eTR<br />
\bTR\bTD[nc=2] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=left] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=middle] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD A\eTD\bTD B\eTD\bTD C\eTD\eTR<br />
\bTR\bTD Aa\eTD\bTD Bb\eTD\bTD Cccc\eTD\eTR<br />
\bTR\bTD[nc=3,align=middle] ABC\eTD\eTR<br />
\eTABLE<br />
}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Make a cell bold ==<br />
<br />
Drawing bold lines around a cell is done using the<br />
<tt>[rulethickness=''dim'']</tt> key on a cell. The thicker rules will<br />
offset the text inside the cell both downwards and sideways, so care<br />
should be taken that the cell's increased rulethickness is offset by an<br />
equal decrease in offset.<br />
<br />
<context source="yes" text="produces"><br />
\setupTABLE[row][each][rulethickness=.25pt,offset=\dimexpr1mm+1.75pt] <br />
\bTABLE<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2/3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD[rulethickness=2pt,offset=1mm] 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
A more realistic example: an invoice with thick rules.<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
{\bfa Invoice}<br />
\switchtobodyfont[6pt]<br />
\blank<br />
\bTABLE<br />
\setupTABLE[frame=off,offset=1mm]<br />
\setupTABLE[row][*][height=7.25mm]<br />
\setupTABLE[column][1]%<br />
[width=18mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=flushleft]<br />
\setupTABLE[column][2]%<br />
[width=20mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=flushleft]<br />
\setupTABLE[column][3]%<br />
[width=18mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=flushright]<br />
\setupTABLE[column][4]%<br />
[width=18mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=flushright]<br />
\setupTABLE[column][5]%<br />
[width=18mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=left]<br />
\bTR[bottomframe=on, rulethickness=2pt,offset=1mm]<br />
\bTD\bf Date \eTD<br />
\bTD\bf Description \eTD<br />
\bTD\bf Quantity \eTD<br />
\bTD\bf Price \eTD<br />
\bTD\bf Total \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 1 \eTD<br />
\bTD 10.0 \eTD<br />
\bTD 6.00 \eTD<br />
\bTD 60.00 \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 2 \eTD<br />
\bTD 2.0 \eTD<br />
\bTD 3.00 \eTD<br />
\bTD 6.00 \eTD<br />
\eTR<br />
\bTR[topframe=on,rulethickness=2pt,offset=1mm]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] Subtotal \eTD<br />
\bTD 66.00 \eTD<br />
\eTR<br />
\bTR[offset=\dimexpr1mm+2pt]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] VAT 19\% \eTD<br />
\bTD 12.54 \eTD<br />
\eTR<br />
\bTR<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] \bf Total \eTD<br />
\bTD 78.54 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Rules with different thickness ==<br />
<br />
There is only one value for all four borders. However, MetaPost can be used as a workaround until the separate "rulethickness" values are implemented.<br />
<br />
The following example (mkiv only!) by Wolfgang Schuster shows a table using MetaPost for the rules:<br />
<br />
<context source=yes mode=mkiv text="gives:"><br />
\startuseMPgraphic{tableborders}<br />
<br />
draw leftboundary OverlayBox withpen pensquare scaled \frameddimension {leftrulethickness} ;<br />
draw rightboundary OverlayBox withpen pensquare scaled \frameddimension {rightrulethickness} ;<br />
draw topboundary OverlayBox withpen pensquare scaled \frameddimension {toprulethickness} ;<br />
draw bottomboundary OverlayBox withpen pensquare scaled \frameddimension{bottomrulethickness} ;<br />
<br />
clip currentpicture to OverlayBox<br />
leftenlarged (\frameddimension {leftrulethickness}/2)<br />
rightenlarged (\frameddimension {rightrulethickness}/2)<br />
topenlarged (\frameddimension {toprulethickness}/2)<br />
bottomenlarged (\frameddimension{bottomrulethickness}/2) ;<br />
<br />
setbounds currentpicture to OverlayBox ;<br />
<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay[tableborders][\useMPgraphic{tableborders}]<br />
<br />
\startsetups tableborders<br />
<br />
\setupTABLE<br />
[ background={color,tableborders},<br />
frame=off,<br />
backgroundoffset=0pt,<br />
leftrulethickness=\framedparameter{rulethickness},<br />
rightrulethickness=\framedparameter{rulethickness},<br />
toprulethickness=\framedparameter{rulethickness},<br />
bottomrulethickness=\framedparameter{rulethickness}]<br />
<br />
\setupTABLE[row] [odd] [backgroundcolor=lightgray]<br />
\setupTABLE[row] [first][backgroundcolor=gray,bottomrulethickness=2pt]<br />
\setupTABLE[row] [last] [toprulethickness=2pt,bottomrulethickness=2pt]<br />
\setupTABLE[first][last] [leftrulethickness=2pt]<br />
\setupTABLE[last] [last] [rightrulethickness=2pt]<br />
<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\bTABLE<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\blank<br />
<br />
\bTABLE[setups=tableborders]<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\stoptext<br />
</context><br />
<br />
See the corresponding thread on the list: [http://www.ntg.nl/pipermail/ntg-context/2011/058549.html rules with different thickness]<br />
<br />
== Diagonal rules ==<br />
<br />
Sometimes a diagonal rule is required in the top left corner cell of a table to create two fields, one for the left column and one for the top row.<br />
<br />
<br />
<context mode="mkiv" source="yes" text="Gives:"><br />
\startuseMPgraphic{DiagonalRule}<br />
rulethickness := \frameddimension{rulethickness};<br />
<br />
drawoptions(<br />
withpen pencircle scaled rulethickness<br />
withcolor \MPcolor{\framedparameter{framecolor}});<br />
<br />
pair leftcorner, rightcorner;<br />
leftcorner := (rulethickness, \overlayheight-rulethickness);<br />
rightcorner := (\overlaywidth-rulethickness, rulethickness);<br />
<br />
draw leftcorner -- rightcorner;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[DiagonalRule]<br />
[\useMPgraphic{DiagonalRule}]<br />
<br />
\define[2]\DiagonalLabel{%<br />
\setuptabulate [after={\blank[\frameddimension{offset}]}]<br />
\starttabulate [|p|r|]<br />
\NC \NC #2 \NC\NR<br />
\NC #1 \NC \NC\NR<br />
\stoptabulate<br />
}<br />
<br />
\starttext<br />
\setupTABLE [row] [1] [width=2cm]<br />
\bTABLE<br />
\bTR<br />
\bTD [background=DiagonalRule]<br />
\DiagonalLabel{Foo}{Bar}<br />
\eTD<br />
\bTD Second \eTD<br />
\bTD Third \eTD<br />
\eTR<br />
\bTR<br />
\bTD Alpha \eTD<br />
\bTD Beta \eTD<br />
\bTD Gamma \eTD<br />
\eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
This solution has (at least) one caveat: Because the first<br />
tabulate column is set in paragraph mode, it will eat up as much<br />
space as <em>possible</em>, in contrast to occupying as much space as<br />
</em>necessary</em>. That is why the width of the column has to be set<br />
explicitly.<br />
<br />
== Using character alignment ==<br />
<br />
ConTeXt can align columns of numbers on a character (often a decimal point to align accounting data) automatically, removing the need to add fixed spaces into your document. For any such column you need to specify the character on which to align. You use the <tt>aligncharacter=yes</tt> parameter to set up character alignment, <tt>alignmentcharacter={.}</tt> to say what the character should be (in this case a full stop) and <tt>align=middle</tt> to set the overall alignment of the column.<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},<br />
aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
You'll note that the final line, because it has no <code>.</code> in the number, gets aligned under the right-hand side of the numbers. In most circumstances you would want such a number aligned with the left-hand set of digits. To so do, issue the following command in your preamble:<br />
<br />
<texcode><br />
\chardef\characteralignmentmode=2<br />
</texcode><br />
<br />
and now the table above will turn out like this:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\chardef\characteralignmentmode=2<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
If there's no <code>alignmentcharacter</code> in the cell, the content will be aligned in the following way depending on the value of <code>\characteralignmentmode</code>:<br />
<table style="border:1px solid #DDDDDD;"><br />
<tr style="background-color:#DDDDDD; font-weight: bold;"><td>mode</td><td width="200"></td><td>.</td><td width="200"></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">0</td><td colspan="3" align="center">centered</td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">1</td><td align="left">left in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">2</td><td align="right">right in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">3</td><td></td><td style="background-color:#DDDDDD">.</td><td align="left">left in after</td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">4</td><td></td><td style="background-color:#DDDDDD">.</td><td align="right">right in after</td></tr><br />
</table><br />
<br />
== Specifying the cell column ==<br />
<br />
When writing a table you can omit empty cells and define only cells for specified columns. To have this feature fully available you need to have a beta or a quite fresh ConTeXt version.<br />
<br />
Two methods are available:<br />
<br />
* With the TD "n" option, the undefined cells are merged into a single spanned cell.<br />
* With the TD "m" option, the undefined cells appear as empty normal cells.<br />
<br />
Here is an example using the "n" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[n=2] d2 \eTD\bTD[n=5] d5 \eTD\bTD[n=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[n=4] f4 \eTD\bTD[n=5] f5 \eTD\bTD[n=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
Here is an example using the "m" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[m=2] d2 \eTD\bTD[m=5] d5 \eTD\bTD[m=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[m=4] f4 \eTD\bTD[m=5] f5 \eTD\bTD[m=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Round corners ==<br />
<br />
For a different approach for round corners and colored background follow the text after this example.<br />
<br />
It is possible to round the corners of the table if you turn off the main frame of the table and frame the table in {{cmd|framed}}. Compare two different approaches in the first and second example.<br />
<br />
You can't color the background of the table with round corners unless the frame rulethickness is not big enough to cover the rectangular corners of the background (second example). Well, you can if you frame the table twice. Once in the thick white frame and then in the thin frame with negative offset and slightly smaller corner radius (third example). Be aware of other complications -- notice that the thick white frame is still visible in the text above it.<br />
<br />
<context source="yes"><br />
\starttext<br />
\setupcolors[state=start] <br />
%\showstruts<br />
\setupTABLE[background=color,backgroundcolor=yellow]<br />
\setupframed[framecolor=darkgreen]<br />
<br />
\defineparagraphs[ThreeCols]<br />
<br />
\startThreeCols<br />
<br />
First<br />
<br />
\def\StartTable<br />
{\setupTABLE[row] [first][topframe=off]%<br />
\setupTABLE[row] [last] [bottomframe=off]%<br />
\setupTABLE[column][first][leftframe=off]%<br />
\setupTABLE[column][last] [rightframe=off]%<br />
\framed[strut=no,corner=round,offset=.5\linewidth]<br />
\bgroup}<br />
<br />
\def\StopTable<br />
{\egroup}<br />
<br />
\StartTable<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\StopTable<br />
<br />
\nextThreeCols<br />
<br />
Second<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,offset=.5\linewidth,,rulethickness=1mm]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
<br />
\nextThreeCols<br />
<br />
Third<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,<br />
radius=1.4mm,offset=-1mm,,rulethickness=.1mm]\bgroup<br />
\framed[strut=no,corner=round,<br />
radius=1.5mm,offset=0mm,,rulethickness=1mm,framecolor=white]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
\egroup<br />
<br />
\stopThreeCols<br />
<br />
\stoptext<br />
</context><br />
<br />
From 2006-10-11 on, ConTeXt contains one more mechanism for round corners. Watch the example:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\starttext<br />
\setupcolors[state=start]<br />
\setupTABLE [y] [first][background=color,backgroundcolor=blue,frame=off,bottomframe=on,topframe=on,framecolor=white]<br />
\setupTABLE [first][first][backgroundcorner=2,corner=10,frame=on]<br />
\setupTABLE [last] [first][backgroundcorner=4,corner=12,frame=on]<br />
\setupTABLE [row] [each] [background=color,backgroundcolor=blue,frame=on,framecolor=white]<br />
\setupTABLE [first][2] [corner=8]<br />
\setupTABLE [last] [2] [corner=5]<br />
\setupTABLE [first][last] [corner=7]<br />
\setupTABLE [last] [last] [corner=6]<br />
<br />
\bTABLE[frame=off,align=middle]<br />
\bTR \bTD one \eTD \bTD two \eTD \bTD three \eTD \eTR<br />
\bTR \bTD first \eTD \bTD second \eTD \bTD third \eTD \eTR<br />
\bTR \bTD alpha \eTD \bTD beta \eTD \bTD gamma \eTD \eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
== Other options ==<br />
<br />
Some other useful options that were not covered above:<br />
* <tt>align=yes</tt> will align the text both left and right justified<br />
* <tt>loffset</tt>, <tt>roffset</tt>, <tt>toffset</tt>, <tt>boffset</tt> can be used in addition to <tt>offset</tt> to specify cell content offsets in each direction separately, see also {{cmd|framed}}<br />
<br />
= TABLEs with old table syntax =<br />
<br />
From the mailing list in March 2009, by Wolfgang Schuster and Hans Hagen:<br />
<br />
<texcode><br />
\def\startTABLE<br />
{\dosingleempty\dostartTABLE}<br />
<br />
\def\dostartTABLE[#1]%<br />
{\bgroup<br />
\bTABLE[#1]%<br />
\let\NC\doTABLENC<br />
\let\NR\doTABLENR<br />
\let\bTR\relax<br />
\let\bTD\relax<br />
\let\bTH\relax<br />
\let\bTN\relax}<br />
<br />
\def\stopTABLE<br />
{\eTABLE<br />
\egroup}<br />
<br />
\newconditional\inTABLEnc<br />
<br />
\unexpanded\def\doTABLENR<br />
{\eTR<br />
\setfalse\inTABLEnc}<br />
<br />
\unexpanded\def\doTABLENC<br />
{\futurelet\next\dodoTABLENC}<br />
<br />
\def\dodoTABLENC<br />
{\ifx\next\doTABLENR \else<br />
\expandafter\dododoTABLENC<br />
\fi}<br />
<br />
\long\def\dododoTABLENC#1\NC<br />
{\ifconditional\inTABLEnc\else\settrue\inTABLEnc\parseTR[][]\fi<br />
\dodoubleempty\parseTD#1\eTD\NC}<br />
</texcode><br />
<br />
This is now part of the core as the [[source:tabl-nte.tex|NTE module]]. Quoting its internal documentation:<br />
<br />
This module is suggested by Wolfgang Schuster who also prototyped it and came up with the rationale:<br />
<br />
This module provides an easy way to use natural in a similiar way as the older table module (based on the [[TABLE]] macros) and the newer [[tabulate]] module.<br />
<br />
You can see the advantage in the following table, once created with the new macros and once with the normal macros provided with the natural table module.<br />
<br />
Let us start with the original macros:<br />
<br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD Text 1 \eTD<br />
\bTD Text 2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD Text 3 \pasteeTD<br />
\bTD Text 4 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
<br />
Watch how the new macros use less code:<br />
<br />
<texcode><br />
\startTABLE<br />
\NC Text 1 \NC Text 2 \NC\NR<br />
\NC Text 3 \NC Text 4 \NC\NR<br />
\stopTABLE<br />
</texcode><br />
<br />
The actual code differs from the prototype that it does not need to collect whole rows and parse them but looks ahead instead.<br />
<br />
[[Category:Tables]]<br />
[[Category:XML]]<br />
tt>\bTD</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupcaptions&diff=20785Command/setupcaptions2012-09-25T08:53:33Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=setupcaptions<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupcaptions<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:location|location]]</td><br />
<td>[[Command/value:top|top]] [[Command/value:bottom|bottom]] [[Command/value:none|none]] [[Command/value:high|high]] [[Command/value:low|low]] [[Command/value:middle|middle]] [[Command/value:left|left]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:width|width]]</td><br />
<td>[[Command/value:fit|fit]] [[Command/value:broad|broad]] [[Command/value:max|max]] [[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:minwidth|minwidth]]</td><br />
<td>[[Command/value:fit|fit]] [[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:headstyle|headstyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:number|number]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:inbetween|inbetween]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:flushleft|flushleft]] [[Command/value:middle|middle]] [[Command/value:flushright|flushright]] [[Command/value:right|right]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:numberconversion|numberconversion]]</td><br />
<td>[[Command/value:numbers|numbers]] [[Command/value:characters|characters]] [[Command/value:Characters|Characters]] [[Command/value:romannumerals|romannumerals]] [[Command/value:Romannumerals|Romannumerals]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:conversion|conversion]]</td><br />
<td>[[Command/value:numbers|numbers]] [[Command/value:characters|characters]] [[Command/value:Characters|Characters]] [[Command/value:romannumerals|romannumerals]] [[Command/value:Romannumerals|Romannumerals]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:way|way]]</td><br />
<td>[[Command/value:bytext|bytext]] [[Command/value:bysection|bysection]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:separator|separator]]</td><br />
<td>[[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:stopper|stopper]]</td><br />
<td>[[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:prefix|prefix]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:suffix|suffix]]</td><br />
<td>[[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:prefixsegments|prefixsegments]]</td><br />
<td>[[Command/value:none|none]] [[Command/value:section|section]] ...</td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:command|command]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:spaceafter|spaceafter]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
</table><br />
<br />
== Description ==<br />
<br />
{| class=wikitable<br />
|- style="vertical-align: top" <br />
| {{key|location}}<br />
| The first option defines the location of the caption relative to the figure itself. The option <code>[location=right]</code> e.g. puts the caption on the right of the figure. The values of the location can be combined, so that <code>[location={right,low}]</code> adjusts the caption position to be to the right of the figure and in a low vertical position. <br />
|- style="vertical-align: top"<br />
| {{key|width}} <br />
| This is the width of the figure caption. If you do not like default captions that are driven by figure (table) width, try: <code>\setupcaptions[minwidth=textwidth, align=middle]</code><br />
|- style="vertical-align: top"<br />
| {{key|headstyle}}<br />
| This defines the formatting of the label, i.e. usually the word ''figure'' or ''table'' and its number. For example, <code>[headstyle=\it]</code> will change it to ''italic''.<br />
|- style="vertical-align: top"<br />
| {{key|style}}<br />
| The formatting of the text of the caption, use <code>[style=\it]</code> to get an ''italic'' text. Several values can be given using curly brackets: <code>[style={\it\tfx}]</code>. Please note, that some formatting (such as font size) will affect the head as well.<br />
|- style="vertical-align: top"<br />
| {{key|number}}<br />
| The option <code>[number=no]</code> suppresses the label and figure number.<br />
|- style="vertical-align: top"<br />
| {{key|inbetween}}<br />
| The macros given here are executed after placing the figure and before placing the caption. To set the space between figure and caption to zero use <code>[inbetween=]</code><br />
|- style="vertical-align: top"<br />
| {{key|align}}<br />
| This can change the alignment of the caption. It can lead to confusion, since ''left'' and ''right'' means ''raggedleft'' and ''raggedright''. So to align a caption ''flush left'', use <code>[align=flushleft]</code>. <br />
|- style="vertical-align: top"<br />
| {{key|numberconversion}}<br />
| Here, it is possible to change the number of the e.g. figure. ''romannumerals'' means, well, roman numerals, the capitalized version capitalizes the number as well. In MkIV, ''numberconversion'' must be used instead of ''conversion''. Example: <code>numberconversion=Romannumerals</code><br />
|- style="vertical-align: top" <br />
| {{key|conversion}}<br />
| This is the MkII version of ''numberconversion''.<br />
|- style="vertical-align: top" <br />
| {{key|way}}<br />
| Using option <code>[way=bysection]</code> resets the numbering to 1 at each new section, but does not prefix the numbers with the section number, to do that, use the following options: <code>\setupcaptions[way=bysection,prefixsegments=section]</code>. If one has only a small number of figures and wishes to label them sequentially from 1 to ''n'', the following works:<code>\setupcaptions[way=bytext, prefixsegments=none]</code>.<br />
|- style="vertical-align: top" <br />
| {{key|suffix'''}}<br />
| If you like to have a colon in your caption, try:<code>\setupcaptions[suffix={:}]</code><br />
|- style="vertical-align: top" <br />
| {{key|prefixsegments}}<br />
| To have a figure number such as ''Figure 2.3'', where 2 is the section number and 3 the figure number, you can use this option. Normally, you want to reset the figure number with every section as well, so that ''Figure 2.1'' follows ''Figure 1.12'' instead of ''Figure 2.13''. Therefore, you have to use <code>\setupcaptions[prefix=yes,way=bysection,prefixsegments=section]</code>.<br />
|-<br />
| {{key|spaceafter}}<br />
| Add some vertical space after the caption.<br />
|}<br />
<br />
== Example ==<br />
<context source=yes><br />
\setuppapersize[A6]<br />
\setupexternalfigures[location=default]<br />
\setupcaptions[<br />
style={\tfx\setupinterlinespace[line=10pt]}, <br />
headstyle=\rm, <br />
stopper={:}]<br />
<br />
\placefigure<br />
{Oh caption, my caption!\crlf<br />
(Apologies to Walt Whitman)}<br />
{\externalfigure[cow][width=2cm]}<br />
<br />
\input linden<br />
</context><br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Floating|setupcaptions]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupdelimitedtext&diff=20361Command/setupdelimitedtext2012-09-03T06:34:32Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=setupdelimitedtext<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd"><!--<br />
-->\setupdelimitedtext<!--<br />
--><span class="first">[''name'']</span><!--<br />
--><span class="second" style="color:red">[''n'']</span><!--<br />
--><span class="third">[...,...=...,...]</span><!--<br />
--></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[''name'']</td><br />
<td>''name of the delimitedtext to set up''</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd" styles="color:red">[''n'']</td><br />
<td>''(optional) nesting level to set up<br /> <br />
(1 = outermost)''</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> location </td><br />
<td> margin text paragraph: ''function unknown'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> spacebefore </td><br />
<td> ''dimension: space above delimitedtext fragment'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> spaceafter </td><br />
<td> ''dimension, spacebefore by default: space below delimitedtext fragment'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> style </td><br />
<td> '''normal''' bold italic, ''etc''</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> color </td><br />
<td> ''color'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> leftmargin </td><br />
<td> ''dimension: distance to edge of the page's left margin area'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> rightmargin </td><br />
<td> ''dimension, leftmargin by default'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> indentnext </td><br />
<td> '''yes''' no </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> before </td><br />
<td> ''command'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> after </td><br />
<td> ''command'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> left </td><br />
<td> ''text'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> right </td><br />
<td> ''text'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> level=0, </td><br />
<td> ''unknown, 0 by default'' </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> repeat </td><br />
<td> '''no''' yes </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd"> method </td><br />
<td> ''unknown'' </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
Set up the appearance of a delimitedtext environment defined earlier with {{cmd|definedelimitedtext}}. {{cmd|quotation}} and {{cmd|quote}} are delimitedtexts, too, so you can also set up those with this command; but for those you can also use the special commands {{cmd|setupquotation}} and {{cmd|setupquote}}.<br />
<br />
Most of the parameters are self-explanatory, but two things should be borne in mind:<br />
<br />
* Nearly all of the parameters apply only if the new kind of text is invoked with <code>\startmydelimitedtext</code>: if one uses <code>\mydelimitedtext{...}</code>, only <code>left</code> and <code>right</code> have any effect.<br />
<br />
* <code>leftmargin</code> contains the distance to the actual left margin, not to the edge of the body text. If the new delimitedtext inherits from <code>quotation</code>, the text will be indented a bit with respect to the body text; if you want to line them up, set the <code>leftmargin</code> to <code>\leftmargindistance</code> rather than to <code>0pt</code>.<br />
<br />
== Example ==<br />
<context mode="mkiv" source="yes"><br />
\definedelimitedtext[mydt]<br />
\setupdelimitedtext[mydt][left=\leftguillemot,right=\rightguillemot]<br />
<br />
\quotation{Clancy of the Overflow}, by Banjo Paterson<br />
<br />
\startmydt<br />
And an answer came directed in a manner unexpected, and I<br />
think the same was written with a thumbnail dipped in tar;<br />
't was his shearing-mate who wrote it, and verbatim I will quote it:<br />
\quotation{Clancy's gone to Queensland droving, and we don't know where he are.}<br />
\stopmydt<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|definedelimitedtext}}<br />
* {{cmd|setupquotation}}<br />
* {{cmd|setupquote}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Delimited text|setupdelimitedtext]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/defineMPinstance&diff=19326Command/defineMPinstance2012-05-10T08:54:28Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=defineMPinstance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\defineMPinstance<span class="first" >[...]</span><span class="second" >[...]</span><span class="third" >[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name for inheritance (optional)</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>see [[Command/setupMPinstance|\setupMPinstance]]</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
This command sets up a custom MetaPost style with particular features that can be selected using the first argument. The instance <code>metafun</code> is the default one and does not need to be created. However, custom styles can inherit from the <code>metafun</code> instance.<br />
<br />
== Predefined Instances ==<br />
<br />
<texcode><br />
\defineMPinstance [metafun] [format=metafun, extensions=yes, initializations=yes]<br />
\defineMPinstance [metapost] [format=mpost]<br />
</texcode><br />
<br />
== Example ==<br />
<context mode="mkiv" source="yes" text="Gives:"><br />
\defineMPinstance<br />
[important]<br />
[metafun] % needs to be inherited from the global metafun instance<br />
[textcolor=red]<br />
<br />
\defineMPinstance<br />
[veryimportant]<br />
[important]<br />
[textstyle=bold]<br />
<br />
\starttext<br />
<br />
% normal black text<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red text<br />
\startMPcode{important}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red bold text<br />
\startMPcode{veryimportant}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
{{cmd|setupMPinstance}}, [[Mpgraphic]]<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|definestartstop]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/doif...&diff=19307Command/doif...2012-05-04T09:47:51Z<p>LuP: </p>
<hr />
<div>{{Reference|name=doif...|attributes=}}<br />
<br />
Block of code depending on a Lua value - example (by WS, 3/2011):<br />
<br />
<context source="yes" text="Gives:"><br />
\starttext<br />
\ctxlua{test = true}<br />
<br />
Test is \ctxlua{commands.testcase(test)}{True}{False}.<br />
<br />
\ctxlua{test = false}<br />
<br />
Test is \ctxlua{commands.testcase(test)}{True}{False}.<br />
\stoptext<br />
</context><br />
<br />
== See also ==<br />
<br />
[[System Macros/Branches and Decisions|Branches and Decisions]]<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|doif...]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/noheaderandfooterlines&diff=19306Command/noheaderandfooterlines2012-05-03T14:33:21Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=noheaderandfooterlines<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table><br />
<tr><br />
<td class="cmd">\noheaderandfooterlines</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
The command disables the header/footer on the page where \noheaderandfooterlines was inserted.<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands/Header & Footer|noheaderandfooterlines]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/noheaderandfooterlines&diff=19305Command/noheaderandfooterlines2012-05-03T14:31:07Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=noheaderandfooterlines<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table><br />
<tr><br />
<td class="cmd">\noheaderandfooterlines</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
The command disables the header/footer on the page where \noheaderandfooterlines was inserted.<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|noheaderandfooterlines]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/defineenumeration&diff=19134Command/defineenumeration2012-04-06T06:58:41Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=defineenumeration<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\defineenumeration<span class="first" >[...,...,...]</span><span class="second" style="color:red;">[...]</span><span class="third" style="color:red;">[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...,...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setupenumerations|\setupenumerations]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
With <code>\defineenumeration</code> you can number text elements like remarks or questions.<br />
<br />
For example, if you want to make numbered remarks in your document you use:<br />
<br />
== setup ==<br />
<texcode><br />
\defineenumeration<br />
[remark]<br />
[location=top,<br />
text=Remark,<br />
inbetween=\blank,<br />
after=\blank]<br />
</texcode><br />
<br />
You can also vary the layout of Remark and Subremark in the example above by:<br />
<br />
<texcode><br />
\setupenumeration[remark][headstyle=bold]<br />
\setupenumeration[subremark][headstyle=slanted]<br />
</texcode><br />
<br />
Now the new commands \remark, \subremark, \resetremark and \nextremark are available. If the remark contains more than one paragraph you will have to use the command<br />
pair \startremark ... \stopremark that becomes available after defining Remark with;<br />
<br />
<texcode>\defineenumeration[remark]</texcode><br />
<br />
=== multiple paragraph ===<br />
So the example above would look like this:<br />
<br />
<texcode><br />
\startremark<br />
In the early medieval times Hasselt was a place of pilgrimage. The<br />
{\em Heilige Stede} (Holy Place) was torn down during the<br />
Reformation.<br />
After 300 years in 1930 the {\em Heilige Stede} was reopened.<br />
Nowadays the {\em Heilige Stede} is closed again but once a year an<br />
open air service is held on the same spot.<br />
\stopremark<br />
</texcode><br />
<br />
== input == <br />
<texcode><br />
\remark In the early medieval times Hasselt was a place of<br />
pilgrimage. The {\em Heilige Stede} (Holy Place) was torn down during<br />
the Reformation. In 1930, after 300 years the {\em Heilige Stede} was<br />
reopened.<br />
\subremark Nowadays the {\em Heilige Stede} is closed again but once<br />
a year an open air service is held on the same spot.<br />
</texcode><br />
<br />
== output ==<br />
<pre><br />
<b>Remark 1</b><br />
In the early medieval times Hasselt was a place of pilgrimage. The Heilige Stede (Holy<br />
Place) was torn down during the Reformation. In 1930, after 300 years the Heilige Stede<br />
was reopened.<br />
<b>Remark 1.1</b><br />
Nowadays the Heilige Stede is closed again but once a year an open air service is held on<br />
the same spot.<br />
</pre><br />
<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<context source="yes" text="Gives:"><br />
\setuppapersize[A5]<br />
\setupbodyfont[8pt]<br />
\setuppagenumbering[location=]<br />
<br />
\setupindenting[yes,medium,first]<br />
<br />
\defineenumeration<br />
[remark]<br />
[location=top,text=Remark,inbetween=\blank,after=\blank,headstyle=bold,margin=1in]<br />
<br />
\starttext<br />
\remark % One paragraph<br />
In the early medieval times Hasselt was a place of pilgrimage.<br />
The {\em Heilige Stede} (Holy Place) was torn down during the Reformation.<br />
In 1930, after 300 years the {\em Heilige Stede} was reopened.<br />
<br />
\remark % The second paragraph IS NOT part of the remark<br />
In the early medieval times Hasselt was a place of pilgrimage.<br />
<br />
The {\em Heilige Stede} (Holy Place) was torn down during the Reformation.<br />
In 1930, after 300 years the {\em Heilige Stede} was reopened.<br />
<br />
\startremark[title={Title},head={Head}] % The second paragraph IS part of the remark<br />
% "title=" and "head=" seem to be meaningless<br />
In the early medieval times Hasselt was a place of pilgrimage.<br />
<br />
The {\em Heilige Stede} (Holy Place) was torn down during the Reformation.<br />
In 1930, after 300 years the {\em Heilige Stede} was reopened.<br />
\stopremark<br />
<br />
\stoptext<br />
</context><br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Numbered objects|defineenumeration]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/defineenumeration&diff=19133Command/defineenumeration2012-04-06T06:56:08Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=defineenumeration<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\defineenumeration<span class="first" >[...,...,...]</span><span class="second" style="color:red;">[...]</span><span class="third" style="color:red;">[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...,...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setupenumerations|\setupenumerations]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
With <code>\defineenumeration</code> you can number text elements like remarks or questions.<br />
<br />
For example, if you want to make numbered remarks in your document you use:<br />
<br />
== setup ==<br />
<texcode><br />
\defineenumeration<br />
[remark]<br />
[location=top,<br />
text=Remark,<br />
inbetween=\blank,<br />
after=\blank]<br />
</texcode><br />
<br />
You can also vary the layout of Remark and Subremark in the example above by:<br />
<br />
<texcode><br />
\setupenumeration[remark][headstyle=bold]<br />
\setupenumeration[subremark][headstyle=slanted]<br />
</texcode><br />
<br />
Now the new commands \remark, \subremark, \resetremark and \nextremark are available. If the remark contains more than one paragraph you will have to use the command<br />
pair \startremark ... \stopremark that becomes available after defining Remark with;<br />
<br />
<texcode>\defineenumeration[remark]</texcode><br />
<br />
=== multiple paragraph ===<br />
So the example above would look like this:<br />
<br />
<texcode><br />
\startremark<br />
In the early medieval times Hasselt was a place of pilgrimage. The<br />
{\em Heilige Stede} (Holy Place) was torn down during the<br />
Reformation.<br />
After 300 years in 1930 the {\em Heilige Stede} was reopened.<br />
Nowadays the {\em Heilige Stede} is closed again but once a year an<br />
open air service is held on the same spot.<br />
\stopremark<br />
</texcode><br />
<br />
== input == <br />
<texcode><br />
\remark In the early medieval times Hasselt was a place of<br />
pilgrimage. The {\em Heilige Stede} (Holy Place) was torn down during<br />
the Reformation. In 1930, after 300 years the {\em Heilige Stede} was<br />
reopened.<br />
\subremark Nowadays the {\em Heilige Stede} is closed again but once<br />
a year an open air service is held on the same spot.<br />
</texcode><br />
<br />
== output ==<br />
<pre><br />
<b>Remark 1</b><br />
In the early medieval times Hasselt was a place of pilgrimage. The Heilige Stede (Holy<br />
Place) was torn down during the Reformation. In 1930, after 300 years the Heilige Stede<br />
was reopened.<br />
<b>Remark 1.1</b><br />
Nowadays the Heilige Stede is closed again but once a year an open air service is held on<br />
the same spot.<br />
</pre><br />
<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<context source="yes" text="Gives:"><br />
\setuppapersize[A5]<br />
\setupbodyfont[8pt]<br />
\setuppagenumbering[state=,location=]<br />
<br />
\setupindenting[yes,medium,first]<br />
<br />
\defineenumeration<br />
[remark]<br />
[location=top,text=Remark,inbetween=\blank,after=\blank,headstyle=bold,margin=1in]<br />
<br />
\starttext<br />
\remark % One paragraph<br />
In the early medieval times Hasselt was a place of pilgrimage.<br />
The {\em Heilige Stede} (Holy Place) was torn down during the Reformation.<br />
In 1930, after 300 years the {\em Heilige Stede} was reopened.<br />
<br />
\remark % The second paragraph IS NOT part of the remark<br />
In the early medieval times Hasselt was a place of pilgrimage.<br />
<br />
The {\em Heilige Stede} (Holy Place) was torn down during the Reformation.<br />
In 1930, after 300 years the {\em Heilige Stede} was reopened.<br />
<br />
\startremark[title={Title},head={Head}] % The second paragraph IS part of the remark<br />
% "title=" and "head=" seem to be meaningless<br />
In the early medieval times Hasselt was a place of pilgrimage.<br />
<br />
The {\em Heilige Stede} (Holy Place) was torn down during the Reformation.<br />
In 1930, after 300 years the {\em Heilige Stede} was reopened.<br />
\stopremark<br />
<br />
\stoptext<br />
</context><br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Numbered objects|defineenumeration]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/defineenumeration&diff=19132Command/defineenumeration2012-04-06T06:51:36Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=defineenumeration<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\defineenumeration<span class="first" >[...,...,...]</span><span class="second" style="color:red;">[...]</span><span class="third" style="color:red;">[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...,...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see [[Command/setupenumerations|\setupenumerations]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
With <code>\defineenumeration</code> you can number text elements like remarks or questions.<br />
<br />
For example, if you want to make numbered remarks in your document you use:<br />
<br />
== setup ==<br />
<texcode><br />
\defineenumeration<br />
[remark]<br />
[location=top,<br />
text=Remark,<br />
inbetween=\blank,<br />
after=\blank]<br />
</texcode><br />
<br />
You can also vary the layout of Remark and Subremark in the example above by:<br />
<br />
<texcode><br />
\setupenumeration[remark][headstyle=bold]<br />
\setupenumeration[subremark][headstyle=slanted]<br />
</texcode><br />
<br />
Now the new commands \remark, \subremark, \resetremark and \nextremark are available. If the remark contains more than one paragraph you will have to use the command<br />
pair \startremark ... \stopremark that becomes available after defining Remark with;<br />
<br />
<texcode>\defineenumeration[remark]</texcode><br />
<br />
=== multiple paragraph ===<br />
So the example above would look like this:<br />
<br />
<texcode><br />
\startremark<br />
In the early medieval times Hasselt was a place of pilgrimage. The<br />
{\em Heilige Stede} (Holy Place) was torn down during the<br />
Reformation.<br />
After 300 years in 1930 the {\em Heilige Stede} was reopened.<br />
Nowadays the {\em Heilige Stede} is closed again but once a year an<br />
open air service is held on the same spot.<br />
\stopremark<br />
</texcode><br />
<br />
== input == <br />
<texcode><br />
\remark In the early medieval times Hasselt was a place of<br />
pilgrimage. The {\em Heilige Stede} (Holy Place) was torn down during<br />
the Reformation. In 1930, after 300 years the {\em Heilige Stede} was<br />
reopened.<br />
\subremark Nowadays the {\em Heilige Stede} is closed again but once<br />
a year an open air service is held on the same spot.<br />
</texcode><br />
<br />
== output ==<br />
<pre><br />
<b>Remark 1</b><br />
In the early medieval times Hasselt was a place of pilgrimage. The Heilige Stede (Holy<br />
Place) was torn down during the Reformation. In 1930, after 300 years the Heilige Stede<br />
was reopened.<br />
<b>Remark 1.1</b><br />
Nowadays the Heilige Stede is closed again but once a year an open air service is held on<br />
the same spot.<br />
</pre><br />
<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<context source="yes" text="Gives:"><br />
\setuppapersize[A5]<br />
\setupbodyfont[8pt]<br />
\setupindenting[yes,medium,first]<br />
\setuppagenumbering[state=,location=]<br />
<br />
\defineenumeration<br />
[remark]<br />
[location=top,text=Remark,inbetween=\blank,after=\blank,headstyle=bold,margin=1in]<br />
<br />
<br />
\starttext<br />
\remark % One paragraph<br />
In the early medieval times Hasselt was a place of pilgrimage.<br />
The {\em Heilige Stede} (Holy Place) was torn down during the Reformation.<br />
In 1930, after 300 years the {\em Heilige Stede} was reopened.<br />
<br />
\remark % The second paragraph IS NOT part of the remark<br />
In the early medieval times Hasselt was a place of pilgrimage.<br />
<br />
The {\em Heilige Stede} (Holy Place) was torn down during the Reformation.<br />
In 1930, after 300 years the {\em Heilige Stede} was reopened.<br />
<br />
\startremark[title={Title},head={Head}] % The second paragraph IS part of the remark<br />
In the early medieval times Hasselt was a place of pilgrimage.<br />
<br />
The {\em Heilige Stede} (Holy Place) was torn down during the Reformation.<br />
In 1930, after 300 years the {\em Heilige Stede} was reopened.<br />
\stopremark<br />
<br />
\stoptext<br />
</context><br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Numbered objects|defineenumeration]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupcombination&diff=13673Command/setupcombination2012-03-08T09:53:54Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=setupcombinations<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupcombinations<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:before|before]]</td><br />
<td>[[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:inbetween|inbetween]]</td><br />
<td>[[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:after|after]]</td><br />
<td>[[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:distance|distance]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:height|height]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] [[Reference/en/value:fit|fit]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:width|width]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] [[Reference/en/value:fit|fit]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:location|location]]</td><br />
<td>[[Reference/en/value:top|top]] [[Reference/en/value:middle|middle]] [[Reference/en/value:bottom|bottom]] [[Reference/en/value:left|left]] [[Reference/en/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:align|align]]</td><br />
<td>[[Reference/en/value:no|no]] [[Reference/en/value:left|left]] [[Reference/en/value:right|right]] [[Reference/en/value:middle|middle]] [[Reference/en/value:normal|normal]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:style|style]]</td><br />
<td>[[Reference/en/value:normal|normal]] [[Reference/en/value:bold|bold]] [[Reference/en/value:slanted|slanted]] [[Reference/en/value:boldslanted|boldslanted]] [[Reference/en/value:type|type]] [[Reference/en/value:cap|cap]] [[Reference/en/value:small... |small]] [[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Reference/en/keyword:color|color]]</td><br />
<td>[[Reference/en/value:name|name]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
* Suppressing both the horizontal and vertical gap between cells:<br />
<texcode>\setupcombinations[distance=0mm,inbetween=]</texcode><br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
<br />
[[Category:Reference/en|setupcombinations]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/definestructureconversionset&diff=13613Command/definestructureconversionset2012-02-22T11:07:54Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=definestrcutureconversionset<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definestrcutureconversionset<span class="first">[name]</span><span class="second">[...,list,...]</span><span class="third">[default]</span><br />
</td><br />
</tr><br />
<!-- --><br />
<tr valign="top" class="first"> <br />
<td>[name]</td><br />
<td><i>Name of the conversion set</i></td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[list,...]</td><br />
<td><i>List with explicit settings for certain headings</i></td><br />
</tr><br />
<tr valign="top" class="third"> <br />
<td class="cmd">[default]</td><br />
<td><i>Default setting if no explicit conversion is set</i></td><br />
</tr><br />
<!-- --><br />
</table><br />
<!--<br />
* <span class="cmd" class="first"> name</span> = name of the conversion set<br />
* <span class="cmd" class="second">list</span> = list with explicit settings for certain headings<br />
* <span class="cmd" class="third">default</span> = default setting if no explicit conversion is set<br />
--><br />
<br />
== Description == <br />
<br />
The command defines conversion of internal counters.<br />
<br />
The first argument is just the name which is used as argument for sectionconverionset in <code>\setuphead</code> for prefixconverionset in <code>\setupcaption</code>, <code>\setupenumeration</code> etc. The name of the conversion can be prefixed with the name of a sectionblock, e.g. <code>\definestructureconverionset[bodypart:myconversion][A,I,n,R][numbers]</code>.<br />
<br />
With the second argument you can set a conversion of the counter for the headings, the list starts always with the <code>\part</code> level and continues with <code>\chapter</code> etc. but it’s possible leave entries empty.<br />
<br />
With the third argument one can set a default value which is used when no value for a heading is set with the second argument.<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
[http://http://www.ntg.nl/pipermail/ntg-context/2012/065245.html Wolfgang's answer in the mail archive]<br />
<br />
[[Category:Reference/en|definestrcutureconversionset]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/definestructureconversionset&diff=13612Command/definestructureconversionset2012-02-22T11:06:42Z<p>LuP: Created page with "{{Reference|name=definestrcutureconversionset|attributes=}} == Syntax == <table cellspacing="4" cellpadding="2" class="cmd"> <tr> <td colspan="2" class=..."</p>
<hr />
<div>{{Reference|name=definestrcutureconversionset|attributes=}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definestrcutureconversionset<span class="first">[name]</span><span class="second">[...,list,...]</span><span class="third">[default]</span><br />
</td><br />
</tr><br />
<!-- --><br />
<tr valign="top" class="first"> <br />
<td>[name]</td><br />
<td><i>Name of the conversion set</i></td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[list,...]</td><br />
<td><i>List with explicit settings for certain headings</i></td><br />
</tr><br />
<tr valign="top" class="third"> <br />
<td class="cmd">[default]</td><br />
<td><i>Default setting if no explicit conversion is set</i></td><br />
</tr><br />
<!-- --><br />
</table><br />
<!--<br />
* <span class="cmd" class="first"> name</span> = name of the conversion set<br />
* <span class="cmd" class="second">list</span> = list with explicit settings for certain headings<br />
* <span class="cmd" class="third">default</span> = default setting if no explicit conversion is set<br />
--><br />
<br />
== Description == <br />
<br />
The command defines conversion of internal counters.<br />
<br />
The first argument is just the name which is used as argument for sectionconverionset in <code>\setuphead</code> for prefixconverionset in <code>\setupcaption</code>, <code>\setupenumeration</code> etc. The name of the conversion can be prefixed with the name of a sectionblock, e.g. <code>\definestructureconverionset[bodypart:myconversion][A,I,n,R][numbers]</code>.<br />
<br />
With the second argument you can set a conversion of the counter for the headings, the list starts always with the <code>\part</code> level and continues with <code>\chapter</code> etc. but it’s possible leave entries empty.<br />
<br />
With the third argument one can set a default value which is used when no value for a heading is set with the second argument.<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
[http://http://www.ntg.nl/pipermail/ntg-context/2012/065245.html Wolfgang's answer in the mail archive]<br />
<br />
[[Category:Reference/en|definestrcutureconversionset]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setupsection&diff=13611Command/setupsection2012-02-22T10:43:06Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=setupsection<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupsection<span class="first" >[...]</span><span class="second" style="color:red;">[...]</span><span class="third" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Reference/en/keyword:conversion|conversion]]</td><br />
<td>[[Reference/en/value:numbers|numbers]] [[Reference/en/value:characters|characters]] [[Reference/en/value:Characters|Characters]] [[Reference/en/value:romannumerals|romannumerals]] [[Reference/en/value:Romannumerals|Romannumerals]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Reference/en/keyword:previousnumber|previousnumber]]</td><br />
<td>[[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
<br />
<br />
== Example ==<br />
<br />
Suppose you want section numbers to appear as A, B, etc, then do<br />
<br />
<texcode><br />
\setuphead[section-3][bodypartconversion=Characters]<br />
</texcode ><br />
<br />
section-1 corresponds to [[cmd:part|\part]] <br /><br />
section-2 corresponds to [[cmd:chapter|\chapter]]<br /><br />
section-3 corresponds to [[cmd:section|\section]],<br /><br />
and so on<br />
<br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
<br />
[[Category:Reference/en|setupsection]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Encodings_and_Regimes_-_Old_Content&diff=13602Encodings and Regimes - Old Content2012-02-17T09:18:25Z<p>LuP: </p>
<hr />
<div>< [[Fonts]] ><br />
<br />
==Introduction==<br />
<br />
The [http://unicode.org/ Unicode] effort clearly shows that 256 characters cannot possibly contain the world's languages. However, traditional TeX is an old system, and will only deal with 256 characters per font. Similarly, "legacy" file encodings on current operating systems (e.g. Latin-1, Mac Roman, Windows 1252, ISO-8859-#) attempt to shoehorn a set of characters into eight bytes.<br />
<br />
As a result, working with [[pdfTeX]] (MkII) you need to make a choice which input encoding ('''regime''') or font/output encoding ('''encoding''') you use. <br />
<br />
Modern TeX variants, from [[Omega]] over [[XeTeX]] to [[LuaTeX]], dropped that limitation and work with full Unicode character sets, in fonts as well as in your source documents.<br />
<br />
==Font Encodings==<br />
<br />
LaTeX users will probably know them under the name '''fontenc''' (<code>\usepackage[T1]{fontenc}</code> for example). <br />
<br />
As TeX can only handle 256 characters at once, it is important to choose the encoding which covers all the characters of your language, otherwise hyphenation won’t work for words with composite characters and most probably you won’t be able to simply extract text from the resulted PDFs.<br />
<br />
To enable ec encoding in [[Latin Modern]] for example, you can type:<br />
<texcode><br />
\usetypescript[modern][ec]<br />
\setupbodyfont[10pt,rm]<br />
</texcode><br />
<br />
Some good choices for encodings are:<br />
<br />
=== in pdfTeX (MkII) ===<br />
* '''texnansi''' for Western European languages with only a small subset of additional accented characters (includes many other important glyphs)<br />
* '''ec''' for European languages with many accented characters<br />
* '''qx''' as a compromise between the two above, supposed to cover most Central European languages (more accented characters than texnansi and more additional glyphs in comparison to ec)<br />
* '''t5''' for [[Vietnamese]]<br />
* '''cyr''', '''t2a''', '''t2b''', '''t2c''', ... (?) for [[Russian|Cyrillic]]<br />
* '''iso-8859-7'''/'''greeek'''/'''grk''' (?) for [[Greek]] (see [[Greek]] for more details)<br />
<br />
Users of '''il2''' and '''pl0''' should consider moving to '''qx'''.<br />
<br />
A simple overview of which characters are present in some of the most common encodings (<b>ec</b>, <b>texnansi</b>, <b>8r</b> and <b>8a</b>):<br />
http://fun.contextgarden.net/encodingtable/enctable.rb?ec,texnansi,8r,8a<br />
<br />
=== in XeTeX (MkII) ===<br />
<br />
* '''uc''' standing for Unicode (the only font encoding supported by [[XeTeX]])<br />
* ('''texnansi''' as the very last resort in [[XeTeX]] - where there are no proper fonts available apart from the old ones)<br />
<br />
=== in LuaTeX (MkIV) ===<br />
<br />
you can normally forget about font encodings.<br />
<br />
=== A note about the ec encoding ===<br />
<br />
Ec encoding is also known under the names '''cork''' or '''T1''' (<code>\usepackage[T1]{fontenc}</code> in LaTeX). Its old version was '''dc''' (should not be used any more). Some of the glyph names in ec are old and deprecated, '''tex256''' uses the same set of glyphs, but the glyph names are compatible with Adobe, see also [ftp://tug.ctan.org/pub/tex-archive/info/fontname/tex256.enc tex256.enc] and [http://partners.adobe.com/public/developer/en/opentype/aglfn13.txt Adobe Glyph List].<br />
<br />
=== Searching for non-ASCII characters in Adobe Reader ===<br />
<br />
Some characters (<code>\ccaron</code> - 'č' being of them for example) are not properly recognized by Adobe (Acrobat) Reader (especially by older versions) when searching or copying text from PDF documents. In order to help Acrobat recognize the glyphs and treat them properly, add this piece of code to your source:<br />
<texcode><br />
\input enco-pfr<br />
\startencoding [ec]<br />
\usepdffontresource ec<br />
\stopencoding<br />
</texcode><br />
<br />
At the time of writing this article, only '''il2''' and '''ec''' were being supported, but support for other encodings can be added.<br />
<br />
See also:<br />
* [http://archive.contextgarden.net/message/20050727.073731.41799d96.html mailing list thread]<br />
* Release notes [[Context 2005.07.27]]<br />
* [http://source.contextgarden.net/tex/context/base/enco-pfr.tex enco-pfr.tex] and all pdfr-*.tex files<br />
<br />
== Input Regimes ==<br />
<br />
(Also known as "input encodings", but in ConTeXt "encoding" refers to fonts, while input is handled by a "regime".)<br />
<br />
If you write ConTeXt source documents and use more than 7-bit ASCII, you must decide on the encoding of your file. That’s a matter of your text editor.<br />
The best choice is normally UTF-8, but if you insist to use an outdated editor that can’t handle Unicode properly or if you’re forced to use legacy code, you have to choose the proper 8-bit encoding, see below.<br />
<br />
===Available Regimes===<br />
<table style="border:1px solid #DDDDDD"><br />
<tr style="background-color:#DDDDDD"><th>ConTeXt name(s)</th><th>Official name(s)</th><th>Remarks</th></tr><br />
<tr><td>[[source:regi-cp1250.tex|cp1250]] = windows-1250</td><td>Windows CP 1250</td><td>East European, see also iso-8859-2</td></tr><br />
<tr style="background-color:#EEEEEE"><td>[[source:regi-cp1251.tex|cp1251]] = windows-1251</td><td>Windows CP 1251</td><td>[[Russian|Cyrillic]]</td></tr><br />
<tr><td>[[source:regi-cp1252.tex|cp1252]] = windows-1252 (= win)</td><td>Windows CP 1252</td><td>West European, see also iso-8859-1,15</td></tr><br />
<tr style="background-color:#EEEEEE"><td>[[source:regi-cp1253.tex|cp1253]] = windows-1253</td><td>Windows CP 1253</td><td>[[Greek]]</td></tr><br />
<tr><td>[[source:regi-cp1254.tex|cp1254]] = windows-1254</td><td>Windows CP 1254</td><td>Turkish</td></tr><br />
<tr style="background-color:#EEEEEE"><td>[[source:regi-cp1257.tex|cp1257]] = windows-1257</td><td>Windows CP 1257</td><td>Windows Baltic</td></tr><br />
<tr><td>[[source:regi-iso-8859-1|iso-8859-1]] = latin1 = il1</td><td>ISO-8859-1, ISO Latin 1</td><td>Western European</td></tr><br />
<tr style="background-color:#EEEEEE"><td>[[source:regi-iso-8859-2|iso-8859-2]] = latin2 = il2</td><td>ISO-8859-2, ISO Latin 2</td><td>East European, see also cp1250</td></tr><br />
<tr><td>[[source:regi-iso-8859-7|iso-8859-7]] = grk</td><td>ISO-8859-7</td><td>[[Greek]]</td></tr><br />
<tr style="background-color:#EEEEEE"><td>[[source:regi-iso-8859-15|iso-8859-15]] = latin9 = il9</td><td>[[ISO-8859-15]], ISO Latin 9</td><td>ISO Latin 1 + Euro</td></tr><br />
<tr><td>mac</td><td>Mac Roman</td><td>western european languages</td></tr><br />
<tr style="background-color:#EEEEEE"><td>ibm</td><td>IBM PC DOS</td><td>western european languages</td></tr><br />
<tr><td>utf</td><td>UTF-8</td><td>[[Unicode]], see below</td></tr><br />
<tr style="background-color:#EEEEEE"><td>vis = viscii</td><td>VISCII</td><td>[[Vietnamese]]</td></tr><br />
<tr><td>cp866, cp866nav</td><td>DOS CP 866</td><td>[[Russian|cyrillic]]</td></tr><br />
<tr style="background-color:#EEEEEE"><td>koi8-r, koi8-u, koi8-ru</td><td>KOI8</td><td>[[Russian|cyrillic]] (russian, ukrainian, mixed)</td></tr><br />
<tr><td>maccyr, macukr</td><td>Mac Cyrillic</td><td>[[Russian|cyrillic]] (russian, ukrainian)</td></tr><br />
<tr style="background-color:#EEEEEE"><td>cp855, cp866av, cp866mav, cp866tat, ctt, dbk, iso88595, isoir111, mik, mls, mnk, mos, ncc</td><td>(several)</td><td>rare cyrillic encodings, see [http://source.contextgarden.net/regi-cyp.tex regi-cyp.tex]</td></tr><br />
</table><br />
Other regimes can be provided on request.<br />
<br />
A list of available language codes is in [http://source.contextgarden.net/mult-sys.tex mult-sys.tex].<br />
You find output/font encodings in <tt>enco-*.tex</tt> files.<br />
<br />
* See [http://czyborra.com/charsets/iso8859.html ISO 8859] for ISO standards.<br />
* [http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/] for Windows<br />
<br />
You enable such a regime with <cmd>enableregime</cmd><code>[some]</code>, preferably in your [[Project_structure|environment file]].<br />
<br />
===Typesetting in UTF-8===<br />
<br />
Use <cmd>enableregime</cmd><code>[utf]</code> in order to be able to typeset in Unicode under ConTeXt MkII. (This is '''not''' necessary in MkIV, as it is enabled by default using LuaTeX.)<br />
<br />
Unfortunately you must save your UTF-8 encoded files '''without BOM''' (byte order mark), because ConTeXt (or pdfTeX) doesn't ignore that but typesets the characters. <br />
This is correct behaviour since UTF-8 doesn’t have a BOM according to the Unicode standard, even if it’s use is widespread.<br />
<br />
===Using non-ASCII characters===<br />
<br />
As a TeX/LaTeX user you were probably told to use the accents in the following way (the example is taken from the TeXbook, page 24):<br />
<texcode><br />
Once upon a time, in a distant<br />
galaxy called \"O\"o\c c<br />
there lived a computer<br />
named R.~J. Drofnats.<br />
</texcode><br />
The galaxy name will be shown as <context>\"O\"o\c c</context>.<br />
<br />
In ConTeXt, please '''try to avoid''' using this backslashed character composition, if possible (there are several good reasons for it - hyphenation, etc.).<br />
<br />
You have two alternatives:<br />
====Type the characters as you do in any other text editor====<br />
<texcode><br />
\enableregime[utf] % or any other supported regime<br />
<br />
...<br />
<br />
Once upon a time, in a distant<br />
galaxy called Ööç<br />
</texcode><br />
<br />
Once you figure out what regime you need, you can simply type the characters as you do in any text editor<br />
(See above for the list of available regimes. If you don't find the one you would like to use, please ask on the mailing list)<br />
<br />
With [[LuaTeX]] engine ([[Mark IV]]) all utf8 characters from your font may be used directly. Typing some characters may require some keyboard setting or may not be possible at all. In this case try to copy/paste them from this [[Symbols/utf8|list of selected utf8 characters]] or use your OS’s character table or a program like [http://live.gnome.org/Gucharmap Gucharmap].<br />
<br />
====Use glyph names====<br />
If you don't have the letter on your keyboard, if you are too lazy to look it up in a table, if your editor font doesn’t show it or if you want some strange letters not supported by the regime/font/editor/OS you use, you can access the glyphs by their names:<br />
<texcode><br />
Once upon a time, in a distant<br />
galaxy called \Odiaeresis\odiaeresis\ccedilla<br />
</texcode><br />
<br />
====How do I know which glyph name to use?====<br />
* use <cmd>showcharacters</cmd><br />
* [http://partners.adobe.com/public/developer/en/opentype/aglfn13.txt Adobe glyph list]<br />
* browse the ConTeXt [[source:enco-acc.tex|source]]<br />
<br />
<context source="yes"><br />
\showcharacters<br />
</context><br />
<br />
==How does it work?==<br />
<br />
'''Robert Ermers''' and '''[[User:adam|Adam]]''' provided a helpful explanation of how characters are constructed in LaTeX and ConTeXt (in some discussion on the mailing list):<br />
<br />
You know that all characters in a font have a number. If you type <code>a</code>, the font mechanism makes sure that you see an <context>a</context>. In reality the font shows you the character that is put on the numerical position of <code>a</code>. In the font Dingbats for example, the character on that position is not an <context>a</context>, but a symbol.<br />
<br />
===In LaTeX=== <br />
<br />
the combination <code>\"{a}</code> can mean two things:<br />
* in most fonts: show the character on the a given numerical position, which means that there is one character <context>\"{a}</context>.<br />
<br />
* in some other fonts <code>\"{a}</code> means: combine <code>¨</code> with <code>a</code> and make an <context>\"{a}</context>. This means that <code>¨</code> is combined with the character on the numerical position of <code>a</code>. TeX does this very well and thus construes very acceptable diacritical signs like <code>\"{q}</code>, <code>\d{o}</code>, <code>\v{o}</code>, which do not exist in regular fonts.<br />
<br />
If you have a font which contains <context>\"{q}</context>(<code>\"{q}</code>), <context>\d{o}</context>(<code>\d{o}</code>) or some other special characters, you may instruct TeX not to create the character, but rather to show the contents of a given numerical position in that font. That's what the <code>.enc</code> and <code>.fd</code> files under LaTeX are for.<br />
<br />
That’s also the reason why there are, or used to be, special fonts for Polish an Czech and other languages: they contain predefined characters in one single numerical position, e.g. <code>\v{s}</code> and <code>\v{c}</code> that TeX does not have to create anew from two glyphs.<br />
<br />
===In ConTeXt=== <br />
<br />
the combination <code>\"{a}</code> means one thing: <code>\adiaeresis</code> (see [[source:enco-acc.tex|enco-acc]]). This <code>\adiaeresis</code> can mean one of two things, depending on the font encoding:<br />
* Numerical position, or <br />
* The fallback case (defined in [[source:enco-def.tex|enco-def]]), where a diaeresis/umlaut is placed atop an <context>a</context> glyph. Hyphenation implications as described.<br />
<br />
The interesting/helpful thing about ConTeXt is that internally, that glyph is given a consistent name, no matter how it is input or output. So, if you type <code>ä</code> in your given input regime, and that encoding is properly set, that numerical <code>ä</code> (e.g., character <code>#228</code> in the windows regime) is mapped to <code>\adiaeresis</code>.<br />
<br />
Wanna know what happens in '''UTF-8'''? Here’s a 'simplified' explanation:<br />
<br />
In a UTF-8 bytestream, that character <context>\"{a}</context> is signified by two bytes:<br />
<code>0xC3</code>, <code>0xA4</code>. That first byte triggers a conversion of both bytes into two<br />
different bytes, the actual Unicode number, <code>0x00 0xE4</code> (or: <code>0, 228</code>). ConTeXt then looks into internal hashes set up (in this case, the [[source:unic-000.tex|unic-000]] vector), looks at the 228<sup>th</sup> element, and sees that it's <code>\adiaeresis</code>. Things then proceed as normal. <tt>:)</tt> <br />
<br />
(It’s also interesting to note that for PostScript and TrueType fonts, that number —> name —> number (glyph) mapping happens yet again in the driver. But all that is outside of TeX proper, so to say any more would be confusing.)<br />
<br />
==Conversion between encodings==<br />
It is possible to convert a string from the current encoding to another using Lua (originally discussed at [http://www.ntg.nl/pipermail/ntg-context/2012/065115.html] and [http://www.ntg.nl/pipermail/ntg-context/2012/065256.html]):<br />
<br />
<code><br />
\startluacode<br />
-- Usage:<br />
-- regimes.toregime(<target-encoding>, <text>, <character-on-failure>))<br />
<br />
regimes.toregime("cp1250", "abcč\192\200žý", "?")) -- Returns "abcč??žý" (one byte per character)<br />
\stopluacode<br />
</code><br />
<br />
==External links==<br />
* [http://en.wikipedia.org/wiki/Alphabets_derived_from_the_Latin Alphabets derived from the Latin] (to be moved to a better place/another page)<br />
* [http://www.eki.ee/letter/ Letter database]: languages, character sets, names etc.<br />
* [http://www.czyborra.com/charsets/iso8859.html Roman Czyborra's ISO 8859 Alphabet Soup]: huge amount of data about the ISO 8859 encodings (and others), character sets, history, etc.<br />
* [http://www.jw-stumpel.nl/stestu.html Multilingual text on Linux] : A good guide on how to configure and use UTF-8 support on linux.<br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/definesorting&diff=13414Command/definesorting2011-10-07T08:31:21Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=definesorting<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definesorting<span class="first" >[...]</span><span class="second" >[...]</span><span class="third" style="color:red;">[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>singular </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>plural </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>command </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
(By WS, 10/2011, mail thread "Alphabetical sort")<br />
<br />
<texcode><br />
\definesorting[song][songs]<br />
<br />
\unexpanded\def\SongEntry#1#2#3%<br />
{\startitemize[packed]<br />
\startitem#2\stopitem<br />
\stopitemize}<br />
<br />
\starttext<br />
\song{Hit the road jack}<br />
\song{Sway}<br />
\song{Fly me to the moon}<br />
<br />
\placelistofsorts[song][criterium=all,command=\SongEntry]<br />
\stoptext<br />
</texcode><br />
<context><br />
\definesorting[song][songs]<br />
<br />
\unexpanded\def\SongEntry#1#2#3%<br />
{\startitemize[packed]<br />
\startitem#2\stopitem<br />
\stopitemize}<br />
<br />
\starttext<br />
\song{Hit the road jack}<br />
\song{Sway}<br />
\song{Fly me to the moon}<br />
<br />
\placelistofsorts[song][criterium=all,command=\SongEntry]<br />
\stoptext<br />
</context><br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
<br />
[[Category:Reference/en|definesorting]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/definesorting&diff=13413Command/definesorting2011-10-07T08:28:57Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=definesorting<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definesorting<span class="first" >[...]</span><span class="second" >[...]</span><span class="third" style="color:red;">[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>singular </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>plural </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>command </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
<texcode><br />
\definesorting[song][songs]<br />
<br />
\unexpanded\def\SongEntry#1#2#3%<br />
{\startitemize[packed]<br />
\startitem#2\stopitem<br />
\stopitemize}<br />
<br />
\starttext<br />
\song{Hit the road jack}<br />
\song{Sway}<br />
\song{Fly me to the moon}<br />
<br />
\placelistofsorts[song][criterium=all,command=\SongEntry]<br />
\stoptext<br />
</texcode><br />
<context><br />
\definesorting[song][songs]<br />
<br />
\unexpanded\def\SongEntry#1#2#3%<br />
{\startitemize[packed]<br />
\startitem#2\stopitem<br />
\stopitemize}<br />
<br />
\starttext<br />
\song{Hit the road jack}<br />
\song{Sway}<br />
\song{Fly me to the moon}<br />
<br />
\placelistofsorts[song][criterium=all,command=\SongEntry]<br />
\stoptext<br />
</context><br />
<br />
== See also ==<br />
<!-- something like [[cmd:goto|\goto]] --><br />
<br />
[[Category:Reference/en|definesorting]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=Command/setuptyping&diff=13084Command/setuptyping2011-06-09T06:16:04Z<p>LuP: </p>
<hr />
<div>{{Reference<br />
|name=setuptyping<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setuptyping<span class="first" style="color:red;">[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>file typing name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:space|space]]</td><br />
<td>[[Reference/en/value:on|on]] [[Reference/en/value:off|off]] [[Reference/en/value:fixed|fixed]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:page|page]]</td><br />
<td>[[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:option|option]]</td><br />
<td>[[Reference/en/value:slanted|slanted]] [[Reference/en/value:normal|normal]] [[Reference/en/value:commands|commands]] [[Reference/en/value:color|color]] [[Reference/en/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:text|text]]</td><br />
<td>[[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:icommand|icommand]]</td><br />
<td>[[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:vcommand|vcommand]]</td><br />
<td>[[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:ccommand|ccommand]]</td><br />
<td>[[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:before|before]]</td><br />
<td>[[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:after|after]]</td><br />
<td>[[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:margin|margin]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] [[Reference/en/value:standard|standard]] [[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:evenmargin|evenmargin]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:oddmargin|oddmargin]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:blank|blank]]</td><br />
<td>[[Reference/en/value:dimension|dimension]] [[Reference/en/value:small|small]] [[Reference/en/value:medium|medium]] [[Reference/en/value:big|big]] [[Reference/en/value:standard|standard]] [[Reference/en/value:halfline|halfline]] [[Reference/en/value:line|line]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:escape|escape]]</td><br />
<td>[[Reference/en/value:character|character]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:tab|tab]]</td><br />
<td>[[Reference/en/value:number|number]] [[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:indentnext|indentnext]]</td><br />
<td>[[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:style|style]]</td><br />
<td>[[Reference/en/value:normal|normal]] [[Reference/en/value:bold|bold]] [[Reference/en/value:slanted|slanted]] [[Reference/en/value:boldslanted|boldslanted]] [[Reference/en/value:type|type]] [[Reference/en/value:cap|cap]] [[Reference/en/value:small...|small...]] [[Reference/en/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:color|color]]</td><br />
<td>[[Reference/en/value:name|name]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:palet|palet]]</td><br />
<td>[[Reference/en/value:name|name]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:lines|lines]]</td><br />
<td>[[Reference/en/value:yes|yes]] [[Reference/en/value:no|no]] [[Reference/en/value:hyphenated|hyphenated]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:empty|empty]]</td><br />
<td>[[Reference/en/value:yes|yes]] [[Reference/en/value:all|all]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Reference/en/keyword:numbering|numbering]]</td><br />
<td>[[Reference/en/value:line|line]] [[Reference/en/value:file|file]] [[Reference/en/value:no|no]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
Changes options for displaying verbatim text. When called with a single argument, this command changes the options for the default typing environment as created with [[cmd:starttyping|\starttyping]]. When the optional argument is given, it identifies a specific typing environment (as created with [[cmd:definetyping|\definetyping]]).<br />
<br />
[[cmd:setuptyping|\setuptyping]] can be used multiple times to change options and options will stay in effect until the end of file.<br />
<br />
Note that [[cmd:setuptyping|\setuptyping]] also affects the display of the [[cmd:typefile|\typefile]] command.<br />
<br />
* space<br />
** fixed: Lines will not be broken, even if too long (may cause "overfull hbox" message)<br />
<br />
* lines<br />
** no (default): no hyphenation<br />
** yes: no hyphenation and left aligned text (align key is ignored)<br />
** hyphenated: hyphenation<br />
<br />
== Example ==<br />
<br />
<texcode><br />
\setuptyping<br />
[before={\startframedtext[width=\makeupwidth,<br />
background=screen,<br />
backgroundscreen=.8]},<br />
after={\stopframedtext}]<br />
<br />
\starttext<br />
\starttyping<br />
test<br />
\stoptyping<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== See also ==<br />
[[cmd:typefile|\typefile]], [[cmd:starttyping|\starttyping]], [[cmd:definetyping|\definetyping]]<br />
<br />
<br />
[[Category:Reference/en|setuptyping]]</div>LuPhttps://wiki.contextgarden.net/index.php?title=TextBackground&diff=12987TextBackground2011-04-08T12:50:13Z<p>LuP: </p>
<hr />
<div>< [[Main Page]] | [[Visuals]] ><br />
<br />
{{todo|Add more examples of usage of textbackgrounds.}}<br />
<br />
Pages, paragraphs, words can have a background: color or screen.<br />
<br />
(See, eventually, the [[manual:details.pdf| details]] manual for further explanations.)<br />
<br />
== What if textbackground doesn't work? ==<br />
<br />
The textbackground commands require [[write18]] to be enabled; see that page for more information.<br />
<br />
== Example: multi-page backgrounded text ==<br />
<br />
Perhaps one might like to offset examples from the running text, or signal to the reader that the following paragraphs contain secondary, detailed information that is of interest only to the specialists. This can be achieved using textbackground.<br />
<br />
In contrast, [[Framed]] creates text blocks that do not span columns or pages.<br />
<br />
In the following example, we also reduce the textwidth and bodyfont size.<br />
<context source="yes"><br />
\setupcolors[state=start]<br />
<br />
\definetextbackground[secondary][<br />
location=paragraph,<br />
background=color,backgroundcolor=middlegray,<br />
leftoffset=.5\bodyfontsize,rightoffset=.5\bodyfontsize,<br />
topoffset=.5\bodyfontsize,bottomoffset=.5\bodyfontsize,<br />
before={\startnarrower\switchtobodyfont[small]},<br />
after={\stopnarrower},<br />
frame=off]<br />
<br />
\starttext<br />
<br />
\input knuth<br />
<br />
\startsecondary<br />
\input knuth<br />
\stopsecondary<br />
<br />
\input knuth<br />
<br />
\stoptext<br />
</context><br />
<br />
{{todo|The background does not show here using the live, online conTeXt processor. Why?}}<br />
<br />
== backgroundoffset ==<br />
<br />
The options left, right, top, bottomoffset can be replaced by backgroundoffset yielding a different result:<br />
<br />
<context source="yes"><br />
\setupcolors[state=start]<br />
<br />
\definetextbackground[secondary][<br />
location=paragraph,<br />
background=color,backgroundcolor=middlegray,<br />
backgroundoffset=.5\bodyfontsize,<br />
before={\startnarrower\switchtobodyfont[small]},<br />
after={\stopnarrower},<br />
frame=off]<br />
<br />
\starttext<br />
<br />
\input knuth<br />
<br />
\startsecondary<br />
\input knuth<br />
\stopsecondary<br />
<br />
\input knuth<br />
<br />
\stoptext<br />
</context><br />
<br />
== Example: dashed underbar (by WS, 4/2011) ==<br />
<br />
<context><br />
\setuppapersize[B5]<br />
\setupbodyfont[10pt]<br />
<br />
\definetextbackground<br />
[dashed]<br />
[ location=text,<br />
framecolor=black,<br />
alternative=1,<br />
voffset=-\strutdp,<br />
background=,<br />
frame=off,<br />
dash=1]<br />
<br />
\starttext<br />
\startdashed\input ward \stopdashed<br />
\stoptext<br />
</context></div>LuPhttps://wiki.contextgarden.net/index.php?title=TextBackground&diff=12986TextBackground2011-04-08T12:41:10Z<p>LuP: </p>
<hr />
<div>< [[Main Page]] | [[Visuals]] ><br />
<br />
{{todo|Add more examples of usage of textbackgrounds.}}<br />
<br />
Pages, paragraphs, words can have a background: color or screen.<br />
<br />
(See, eventually, the [[manual:details.pdf| details]] manual for further explanations.)<br />
<br />
== What if textbackground doesn't work? ==<br />
<br />
The textbackground commands require [[write18]] to be enabled; see that page for more information.<br />
<br />
== Example: multi-page backgrounded text ==<br />
<br />
Perhaps one might like to offset examples from the running text, or signal to the reader that the following paragraphs contain secondary, detailed information that is of interest only to the specialists. This can be achieved using textbackground.<br />
<br />
In contrast, [[Framed]] creates text blocks that do not span columns or pages.<br />
<br />
In the following example, we also reduce the textwidth and bodyfont size.<br />
<context source="yes"><br />
\setupcolors[state=start]<br />
<br />
\definetextbackground[secondary][<br />
location=paragraph,<br />
background=color,backgroundcolor=middlegray,<br />
leftoffset=.5\bodyfontsize,rightoffset=.5\bodyfontsize,<br />
topoffset=.5\bodyfontsize,bottomoffset=.5\bodyfontsize,<br />
before={\startnarrower\switchtobodyfont[small]},<br />
after={\stopnarrower},<br />
frame=off]<br />
<br />
\starttext<br />
<br />
\input knuth<br />
<br />
\startsecondary<br />
\input knuth<br />
\stopsecondary<br />
<br />
\input knuth<br />
<br />
\stoptext<br />
</context><br />
<br />
{{todo|The background does not show here using the live, online conTeXt processor. Why?}}<br />
<br />
== backgroundoffset ==<br />
<br />
The options left, right, top, bottomoffset can be replaced by backgroundoffset yielding a different result:<br />
<br />
<context source="yes"><br />
\setupcolors[state=start]<br />
<br />
\definetextbackground[secondary][<br />
location=paragraph,<br />
background=color,backgroundcolor=middlegray,<br />
backgroundoffset=.5\bodyfontsize,<br />
before={\startnarrower\switchtobodyfont[small]},<br />
after={\stopnarrower},<br />
frame=off]<br />
<br />
\starttext<br />
<br />
\input knuth<br />
<br />
\startsecondary<br />
\input knuth<br />
\stopsecondary<br />
<br />
\input knuth<br />
<br />
\stoptext<br />
</context><br />
<br />
== Example: dashed underbar (by WS, 4/2011) ==<br />
<br />
<context><br />
\setuppapersize[A6][landscape]<br />
\setupbodyfont[10pt]<br />
<br />
\definetextbackground<br />
[dashed]<br />
[ location=text,<br />
framecolor=black,<br />
alternative=1,<br />
voffset=-\strutdp,<br />
background=,<br />
frame=off,<br />
dash=1]<br />
<br />
\starttext<br />
\startdashed\input ward \stopdashed<br />
\stoptext<br />
</context></div>LuP