https://wiki.contextgarden.net/api.php?action=feedcontributions&user=132.166.21.4&feedformat=atomWiki - User contributions [en]2024-03-28T19:30:23ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Registers&diff=8913Registers2008-09-15T09:26:33Z<p>132.166.21.4: /* Tricks */</p>
<hr />
<div>< [[Structurals]] | [[References]] > (It's also in the manual at "Registers")<br />
<br />
=Basics=<br />
<br />
Putting a word into the index as simple as <cmd>index</cmd><tt>{word}</tt>. (Always type <cmd>index</cmd> ''before'' the word you refer to!)<br />
<br />
To sort e.g. <cmd>ConTeXt</cmd> under "C", you write <cmd>index</cmd><tt>[CONTEXT]{\ConTeXt}</tt>.<br />
<br />
If you need multiple levels (up to three), use "+" or "&" separators like in <cmd>index</cmd><tt>{beans+baked}</tt>.<br />
<br />
You get a cross reference in your index with <cmd>seeindex</cmd> like in <cmd>seeindex</cmd><tt>[CONTEXT]{\ConTeXt}{\TeX}</tt> (ConTeXt: see TeX).<br />
<br />
To typeset the index, use <cmd>placeindex</cmd> (without title) or <cmd>completeindex</cmd> (with titling).<br />
<br />
==Example==<br />
<texcode><br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats.<br />
There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</texcode><br />
<context><br />
\tfx<br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats. There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</context><br />
<br />
=Styling the Index=<br />
<br />
<cmd>setupregister</cmd><tt>[index]</tt> is your friend. <cmd>placeindex</cmd> and <cmd>completeindex</cmd> take the same options.<br />
<br />
You can also style single entries with the :: syntax like this (from the manual):<br />
<br />
<texcode><br />
\setupregister[index][form][pagestyle=bold,textstyle=slanted]<br />
\setupregister[index][tb][textstyle=bold]<br />
\setupregister[index][nb][pagestyle=bold]<br />
\setupregister[index][hm][pagestyle=slanted]<br />
<br />
\index{tb::foot+squarefoot} % text in "tb" style<br />
\index[nb::]{squareroot} % number in "nb" style<br />
\index[hm::root]{$\sqrt{2}$} % number in "hm" style, sorted at "root"<br />
</texcode><br />
<br />
=More Registers=<br />
<br />
<cmd>index</cmd> is only one special case of <cmd>register</cmd>. You can define as much different registers as you like:<br />
<br />
<cmd>defineregister</cmd><tt>[singular name][plural name]</tt>, e.g. <br />
<texcode><br />
\defineregister[mouse][mice]<br />
\setupregister[mouse][style=\ss]<br />
<br />
\mouse{rat}<br />
<br />
\placemouse<br />
</texcode><br />
<br />
(Don't know if the plural form is used anywhere...)<br />
<br />
=Tricks=<br />
<br />
* <cmd>startregister</cmd><tt>[index][mymouse]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse]</tt>: to mark several pages for the same entry; becomes e.g. "mouse 12--16". Note that if you have two or more of these ranges, you need them to have different <tt>[key]</tt> values to stop the system treating them as part of a great big range. So, use <cmd>startregister</cmd><tt>[index][mymouse1]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse1]</tt> and then <cmd>startregister</cmd><tt>[index][mymouse2]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse2]</tt> to get two independent ranges in the list. <cmd>startregister</cmd> takes four arguments, of which two are mandatory: <cmd>startregister</cmd><tt>[NAME_OF_REGISTER]{ENTRY_NAME}</tt>. The other arguments are <tt>[KEY_FOR_RANGE]</tt> and <tt>[KEY_FOR_SORTING]</tt>. To give an example: <cmd>startregister</cmd><tt>[index][levi][Levi-Strauss]{Lévi|-|Strauss}</tt>. This will start a range with the key <tt>levi</tt> which will put the entry "Lévi-Strauss" in the register "index" (the "normal" register) and sort it under "Levi-Strauss." To mark the end of the range, you write <cmd>stopregister</cmd><tt>[index][levi]</tt>.<br />
* Automatically collapse page ranges: <cmd>placeindex[compress=yes]</cmd><br />
* <cmd>writetoregister</cmd> (sometimes needed to avoid macro expansion issues)<br />
* A register per chapter: <cmd>placeregister</cmd><tt>[index][criterium=chapter]</tt><br />
* Place a word in text ''and'' index: <tt>\def\Tindex#1{\index{#1}#1}</tt> -- Please someone enhance this to get space correction, [] sorting etc.!<br />
* The name that you will get in the head of \completeregister can be set with: \setupheadtext[register=My new index]<br />
<br />
=Coupled Registers=<br />
<br />
This is a special feature for documents that are only used on screen: Make a word clickable to jump to the index, the first or last occurrence.<br />
<br />
Enable it with <cmd>setupregister</cmd><tt>[index][coupling=yes]</tt>.<br />
Substitute <cmd>index</cmd> with <cmd>coupledindex</cmd> and enjoy!<br />
<br />
=Impact on vertical spacing=<br />
<br />
In some situations, placing an <cmd>index</cmd> (or related command) might affect vertical spacing and the page-breaking mechanism. In those situations it is advisable to wrap the command in a <cmd>doflushatpar</cmd> as shown below (needs a ConTeXt version dated after 14th Dec 2005):<br />
<br />
<texcode><br />
\starttext<br />
\section{Tufte}<br />
\dorecurse{4}{\input tufte \par}<br />
\section{Knuth}<br />
\doflushatpar{\index{Knuth}}<br />
\input knuth \par<br />
\stoptext<br />
</texcode><br />
<br />
This will stop bad-page breaking between the section title and the following para, for example.<br />
<br />
==Technical note==<br />
<br />
The above command is defined as follows:<br />
<br />
<texcode><br />
\long\def\doflushatpar#1%<br />
% {\dogotopar{\dontleavehmode#1}} % this one can introduce empty lines<br />
{\dogotopar{#1\ifvmode\nobreak\fi}} % while this one can mess up vertical space<br />
</texcode><br />
<br />
Note the two possible definitions, and the pitfalls with each one. If you are still having trouble with specific <cmd>index</cmd> commands, try using the alternative definition. When they are used in the right context, these three possible ways of placing an index term (the plain <cmd>index</cmd>, or it wrapped in one of the two possible <cmd>doflushatpar</cmd>s, should solve any problem.</div>132.166.21.4https://wiki.contextgarden.net/index.php?title=Registers&diff=8912Registers2008-09-15T09:25:22Z<p>132.166.21.4: /* Tricks */</p>
<hr />
<div>< [[Structurals]] | [[References]] > (It's also in the manual at "Registers")<br />
<br />
=Basics=<br />
<br />
Putting a word into the index as simple as <cmd>index</cmd><tt>{word}</tt>. (Always type <cmd>index</cmd> ''before'' the word you refer to!)<br />
<br />
To sort e.g. <cmd>ConTeXt</cmd> under "C", you write <cmd>index</cmd><tt>[CONTEXT]{\ConTeXt}</tt>.<br />
<br />
If you need multiple levels (up to three), use "+" or "&" separators like in <cmd>index</cmd><tt>{beans+baked}</tt>.<br />
<br />
You get a cross reference in your index with <cmd>seeindex</cmd> like in <cmd>seeindex</cmd><tt>[CONTEXT]{\ConTeXt}{\TeX}</tt> (ConTeXt: see TeX).<br />
<br />
To typeset the index, use <cmd>placeindex</cmd> (without title) or <cmd>completeindex</cmd> (with titling).<br />
<br />
==Example==<br />
<texcode><br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats.<br />
There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</texcode><br />
<context><br />
\tfx<br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats. There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</context><br />
<br />
=Styling the Index=<br />
<br />
<cmd>setupregister</cmd><tt>[index]</tt> is your friend. <cmd>placeindex</cmd> and <cmd>completeindex</cmd> take the same options.<br />
<br />
You can also style single entries with the :: syntax like this (from the manual):<br />
<br />
<texcode><br />
\setupregister[index][form][pagestyle=bold,textstyle=slanted]<br />
\setupregister[index][tb][textstyle=bold]<br />
\setupregister[index][nb][pagestyle=bold]<br />
\setupregister[index][hm][pagestyle=slanted]<br />
<br />
\index{tb::foot+squarefoot} % text in "tb" style<br />
\index[nb::]{squareroot} % number in "nb" style<br />
\index[hm::root]{$\sqrt{2}$} % number in "hm" style, sorted at "root"<br />
</texcode><br />
<br />
=More Registers=<br />
<br />
<cmd>index</cmd> is only one special case of <cmd>register</cmd>. You can define as much different registers as you like:<br />
<br />
<cmd>defineregister</cmd><tt>[singular name][plural name]</tt>, e.g. <br />
<texcode><br />
\defineregister[mouse][mice]<br />
\setupregister[mouse][style=\ss]<br />
<br />
\mouse{rat}<br />
<br />
\placemouse<br />
</texcode><br />
<br />
(Don't know if the plural form is used anywhere...)<br />
<br />
=Tricks=<br />
<br />
* <cmd>startregister</cmd><tt>[index][mymouse]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse]</tt>: to mark several pages for the same entry; becomes e.g. "mouse 12--16". Note that if you have two or more of these ranges, you need them to have different <tt>[key]</tt> values to stop the system treating them as part of a great big range. So, use <cmd>startregister</cmd><tt>[index][mymouse1]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse1]</tt> and then <cmd>startregister</cmd><tt>[index][mymouse2]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse2]</tt> to get two independent ranges in the list. <cmd>startregister</cmd> takes four arguments, of which two are mandatory: <cmd>startregister</cmd><tt>[NAME_OF_REGISTER]{ENTRY_NAME}</tt>. The other arguments are <tt>[KEY_FOR_RANGE]</tt> and <tt>[KEY_FOR_SORTING]</tt>. To give an example: <cmd>startregister</cmd><tt>[index][levi][Levi-Strauss]{Lévi|-|Strauss}</tt>. This will start a range with the key <tt>levi</tt> which will put the entry "Lévi-Strauss" in the register "index" (the "normal" register) and sort it under "Levi-Strauss." To mark the end of the range, you write <cmd>stopregister</cmd><tt>[index][levi]</tt>.<br />
* Automatically collapse page ranges: <cmd>placeindex[compress=yes]</cmd><br />
* <cmd>writetoregister</cmd> (sometimes needed to avoid macro expansion issues)<br />
* A register per chapter: <cmd>placeregister</cmd><tt>[index][criterium=chapter]</tt><br />
* Place a word in text ''and'' index: <tt>\def\Tindex#1{\index{#1}#1}</tt> -- Please someone enhance this to get space correction, [] sorting etc.!<br />
* Cross reference: <cmd>seeindex{senatus populusque romanus}{SPQR}</cmd><br />
* The name that you will get in the head of \completeregister can be set with: \setupheadtext[register=My new index]<br />
<br />
=Coupled Registers=<br />
<br />
This is a special feature for documents that are only used on screen: Make a word clickable to jump to the index, the first or last occurrence.<br />
<br />
Enable it with <cmd>setupregister</cmd><tt>[index][coupling=yes]</tt>.<br />
Substitute <cmd>index</cmd> with <cmd>coupledindex</cmd> and enjoy!<br />
<br />
=Impact on vertical spacing=<br />
<br />
In some situations, placing an <cmd>index</cmd> (or related command) might affect vertical spacing and the page-breaking mechanism. In those situations it is advisable to wrap the command in a <cmd>doflushatpar</cmd> as shown below (needs a ConTeXt version dated after 14th Dec 2005):<br />
<br />
<texcode><br />
\starttext<br />
\section{Tufte}<br />
\dorecurse{4}{\input tufte \par}<br />
\section{Knuth}<br />
\doflushatpar{\index{Knuth}}<br />
\input knuth \par<br />
\stoptext<br />
</texcode><br />
<br />
This will stop bad-page breaking between the section title and the following para, for example.<br />
<br />
==Technical note==<br />
<br />
The above command is defined as follows:<br />
<br />
<texcode><br />
\long\def\doflushatpar#1%<br />
% {\dogotopar{\dontleavehmode#1}} % this one can introduce empty lines<br />
{\dogotopar{#1\ifvmode\nobreak\fi}} % while this one can mess up vertical space<br />
</texcode><br />
<br />
Note the two possible definitions, and the pitfalls with each one. If you are still having trouble with specific <cmd>index</cmd> commands, try using the alternative definition. When they are used in the right context, these three possible ways of placing an index term (the plain <cmd>index</cmd>, or it wrapped in one of the two possible <cmd>doflushatpar</cmd>s, should solve any problem.</div>132.166.21.4https://wiki.contextgarden.net/index.php?title=Registers&diff=8911Registers2008-09-15T09:24:41Z<p>132.166.21.4: /* Tricks */</p>
<hr />
<div>< [[Structurals]] | [[References]] > (It's also in the manual at "Registers")<br />
<br />
=Basics=<br />
<br />
Putting a word into the index as simple as <cmd>index</cmd><tt>{word}</tt>. (Always type <cmd>index</cmd> ''before'' the word you refer to!)<br />
<br />
To sort e.g. <cmd>ConTeXt</cmd> under "C", you write <cmd>index</cmd><tt>[CONTEXT]{\ConTeXt}</tt>.<br />
<br />
If you need multiple levels (up to three), use "+" or "&" separators like in <cmd>index</cmd><tt>{beans+baked}</tt>.<br />
<br />
You get a cross reference in your index with <cmd>seeindex</cmd> like in <cmd>seeindex</cmd><tt>[CONTEXT]{\ConTeXt}{\TeX}</tt> (ConTeXt: see TeX).<br />
<br />
To typeset the index, use <cmd>placeindex</cmd> (without title) or <cmd>completeindex</cmd> (with titling).<br />
<br />
==Example==<br />
<texcode><br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats.<br />
There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</texcode><br />
<context><br />
\tfx<br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats. There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</context><br />
<br />
=Styling the Index=<br />
<br />
<cmd>setupregister</cmd><tt>[index]</tt> is your friend. <cmd>placeindex</cmd> and <cmd>completeindex</cmd> take the same options.<br />
<br />
You can also style single entries with the :: syntax like this (from the manual):<br />
<br />
<texcode><br />
\setupregister[index][form][pagestyle=bold,textstyle=slanted]<br />
\setupregister[index][tb][textstyle=bold]<br />
\setupregister[index][nb][pagestyle=bold]<br />
\setupregister[index][hm][pagestyle=slanted]<br />
<br />
\index{tb::foot+squarefoot} % text in "tb" style<br />
\index[nb::]{squareroot} % number in "nb" style<br />
\index[hm::root]{$\sqrt{2}$} % number in "hm" style, sorted at "root"<br />
</texcode><br />
<br />
=More Registers=<br />
<br />
<cmd>index</cmd> is only one special case of <cmd>register</cmd>. You can define as much different registers as you like:<br />
<br />
<cmd>defineregister</cmd><tt>[singular name][plural name]</tt>, e.g. <br />
<texcode><br />
\defineregister[mouse][mice]<br />
\setupregister[mouse][style=\ss]<br />
<br />
\mouse{rat}<br />
<br />
\placemouse<br />
</texcode><br />
<br />
(Don't know if the plural form is used anywhere...)<br />
<br />
=Tricks=<br />
<br />
* <cmd>startregister</cmd><tt>[index][mymouse]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse]</tt>: to mark several pages for the same entry; becomes e.g. "mouse 12--16". Note that if you have two or more of these ranges, you need them to have different <tt>[key]</tt> values to stop the system treating them as part of a great big range. So, use <cmd>startregister</cmd><tt>[index][mymouse1]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse1]</tt> and then <cmd>startregister</cmd><tt>[index][mymouse2]{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse2]</tt> to get two independent ranges in the list. <cmd>startregister</cmd> takes four arguments, of which two are mandatory: <cmd>startregister</cmd><tt>[NAME_OF_REGISTER]{ENTRY_NAME}</tt>. The other arguments are <tt>[KEY_FOR_RANGE]</tt> and <tt>[KEY_FOR_SORTING]</tt>. To give an example: <cmd>startregister</cmd><tt>[index][levi][Levi-Strauss]{Lévi|-|Strauss}</tt>. This will start a range with the key <tt>levi</tt> which will put the entry "Lévi-Strauss" in the register "index" (the "normal" register) and sort it under "Levi-Strauss." To mark the end of the range, you write <cmd>stopregister</cmd><tt>[index][levi]</tt>.<br />
* Automatically collapse page ranges: <cmd>placeindex[compress=yes]</cmd><br />
* <cmd>writetoregister</cmd> (sometimes needed to avoid macro expansion issues)<br />
* A register per chapter: <cmd>placeregister</cmd><tt>[index][criterium=chapter]</tt><br />
* Place a word in text ''and'' index: <tt>\def\Tindex#1{\index{#1}#1}</tt> -- Please someone enhance this to get space correction, [] sorting etc.!<br />
* Cross reference: <cmd>seeindex{senatus populusque romanus }{SPQR}</cmd><br />
* The name that you will get in the head of \completeregister can be set with: \setupheadtext[register=My new index]<br />
<br />
=Coupled Registers=<br />
<br />
This is a special feature for documents that are only used on screen: Make a word clickable to jump to the index, the first or last occurrence.<br />
<br />
Enable it with <cmd>setupregister</cmd><tt>[index][coupling=yes]</tt>.<br />
Substitute <cmd>index</cmd> with <cmd>coupledindex</cmd> and enjoy!<br />
<br />
=Impact on vertical spacing=<br />
<br />
In some situations, placing an <cmd>index</cmd> (or related command) might affect vertical spacing and the page-breaking mechanism. In those situations it is advisable to wrap the command in a <cmd>doflushatpar</cmd> as shown below (needs a ConTeXt version dated after 14th Dec 2005):<br />
<br />
<texcode><br />
\starttext<br />
\section{Tufte}<br />
\dorecurse{4}{\input tufte \par}<br />
\section{Knuth}<br />
\doflushatpar{\index{Knuth}}<br />
\input knuth \par<br />
\stoptext<br />
</texcode><br />
<br />
This will stop bad-page breaking between the section title and the following para, for example.<br />
<br />
==Technical note==<br />
<br />
The above command is defined as follows:<br />
<br />
<texcode><br />
\long\def\doflushatpar#1%<br />
% {\dogotopar{\dontleavehmode#1}} % this one can introduce empty lines<br />
{\dogotopar{#1\ifvmode\nobreak\fi}} % while this one can mess up vertical space<br />
</texcode><br />
<br />
Note the two possible definitions, and the pitfalls with each one. If you are still having trouble with specific <cmd>index</cmd> commands, try using the alternative definition. When they are used in the right context, these three possible ways of placing an index term (the plain <cmd>index</cmd>, or it wrapped in one of the two possible <cmd>doflushatpar</cmd>s, should solve any problem.</div>132.166.21.4https://wiki.contextgarden.net/index.php?title=Table&diff=8910Table2008-09-15T07:38:54Z<p>132.166.21.4: </p>
<hr />
<div>< [[Tables Overview]] | [[Tabulate]] | [[Tables]] ><br />
<br />
This is ConTeXts oldest table module. It uses the same formatting as [[Tabulate]] (see [[Tables Overview]]).<br />
<br />
This mode is based on Michael Wichura's TaBlE package for PlainTeX. The official manual for it is commercial (about 40 USD), see [http://www.pctex.com/books.html PCTeX] -- but note that the TaBlE manual only talks about the original syntax, which does not use <cmd>NC</cmd>, <cmd>HL</cmd> cum suis.<br />
<br />
The only ConTeXt docs are in [[manual:ms-cb-en.pdf|ConTeXt - an excursion]]. There is also two introductory articles in tugboat [http://tug.org/TUGboat/Articles/tb28-3/tb90mahajan.pdf ConTeXt basics for users: Table macros] [http://www.tug.org/TUGboat/Articles/tb29-1/tb91mahajan.pdf Table macros II] by Aditya Mahajan (2007 and 2008).<br />
<br />
<br />
== Basic Commands ==<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
* You get vertical lines (rules), if you use <cmd>VL</cmd> instead of <cmd>NC</cmd>.<br />
* Better use <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd>, <cmd>LR</cmd> instead of <cmd>NR</cmd>.<br />
* You can also use <cmd>AR</cmd> instead of <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd> and <cmd>LR</cmd> (AR for automatic row).<br />
* You can leave out the <cmd>NC</cmd> before the "row" command, but not if you use <cmd>AR</cmd> in a last or single row (see example).<br />
* You can influence the table with <cmd>setuptables</cmd>.<br />
* There are also <cmd>BL</cmd> and <cmd>CL</cmd> for colored backgrounds, see below.<br />
<br />
==Column Definition==<br />
<br />
The table is defined by the template enclosed in square brackets after <cmd>starttable</cmd>. The template has the form<br />
<tt>|keys for the first column|keys for the second column|...|keys for the last column|</tt>. Please note that the each column is surrounded by <tt>|</tt> signs. These are necessary. The formatting keys for each column can be a choice of<br />
<br />
<table width="100%" cols="2"><tr valign="top"><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|lp(.5\textwidth)|]<br />
\HL<br />
\NC \bf Key \VL \bf Meaning \SR<br />
\HL<br />
\NC \NC Primitive Keys \SR<br />
\HL<br />
\NC \type{a{tokens}}\VL Adds \type{tokens} {\em after} the column content\AR<br />
\NC \type{b{tokens}}\VL Adds \type{tokens} '''before''' the column content\AR<br />
\NC {\tt \backslash\{ } \VL Enclose the column in braces (grouping)\AR<br />
\NC \type{*{n}{keys}}\VL Equivalent to repeating the formatting keys \type{keys} \type{n} times\NC\LR<br />
\HL<br />
\NC \NC Positioning Keys\SR<br />
\HL<br />
\NC \type{\LeftGlue} \VL Specifies the left glue to be used before the column\AR<br />
\NC \type{\RightGlue} \VL Specifies the right glue to be used after the column\AR<br />
\NC \type{l} \VL left-aligned column\AR<br />
\NC \type{c} \VL centered column\AR<br />
\NC \type{r} \VL right-aligned column\AR<br />
\NC \type{p(width)} \VL Set each cell as a paragraph\AR<br />
\NC \type{w} \VL Set minimum column width\AR<br />
\NC \type{k} \VL Insert a kern both left and right of the column\AR<br />
\NC \type{i} \VL Add a kern to the left of the column\AR<br />
\NC \type{j} \VL Add a kern to the right of the column\LR<br />
\HL<br />
\NC \NC Numeric and Math Item Keys \SR<br />
\HL<br />
\NC \type{n} \VL Numeric item not in math mode\AR<br />
\NC \type{N} \VL Numeric item in math mode\AR<br />
\NC \type{m} \VL Each cell is in (inline) math mode. Equivalent to \type{b$ a$}\AR<br />
\NC \type{M} \VL Each cell is in display math mode. Equivalent to \type{\{b{$\displaystyle}a$}} \AR<br />
\NC \type{\m} \VL Equivalent to \type{l b{{}}m}\AR<br />
\NC \type{\M} \VL Equivalent to \type{l b{{}}M}\LR<br />
\HL<br />
\NC \NC Style Keys \SR<br />
\HL<br />
\NC \type{f\command} \VL Set font according to following \tex{command}\AR<br />
\NC \type{B} \VL Bold. Equivalent to \type{f\bf}\AR<br />
\NC \type{I} \VL Italic. Equivalent to \type{f\it}\AR<br />
\NC \type{S} \VL Slanted. Equivalent to \type{f\sl}\AR<br />
\NC \type{R} \VL Roman. Equivalent to \type{f\rm}\AR<br />
\NC \type{T} \VL Teletype. Equivalent to \type{f\tt}\AR<br />
\NC \type{C} \VL Color. Use it in combination with \backslash\{ (e.g. \backslash\{C\{red\} )\LR<br />
\HL<br />
\NC \NC Tabskip Keys \SR<br />
\HL<br />
\NC \type{s} \VL Set the tabskip to the right of this column and of all following columns up to the next \type{s} or \type{o} key\AR<br />
\NC \type{o} \VL Set the tabskip to the right of this column only\LR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><td><br />
===Examples===<br />
; <code>|l|</code> : a left aligned column, as wide as necessary<br />
; <code>|lw(2cm)|</code> : a left aligned column of at least 2 cm width<br />
; <code>|p(2cm)|</code> : a centered(!) paragraph of 2 cm width<br />
; <code>|lp(.5\textwidth)|</code> : a left aligned paragraph of specified width<br />
; <code>|rp(.5\textwidth)|</code> : a right aligned paragraph of specified width<br />
; <code>|cp(.5\textwidth)|</code> : a center aligned paragraph of specified width<br />
; <code>|xp(.5\textwidth)|</code> : a justified paragraph of specified width<br />
; <code>...</code> : Please add more<br />
; <code>...</code> : <br />
<br />
{{Todo|add more examples of column definitions}}<br />
</td></tr></table><br />
<br />
==Column Spans==<br />
<br />
It's possible to create columnspans (i.e. cells that span more than one column) with the command <cmd>use{<i>N</i>}</cmd> where ''N'' is the number of columns spanned by the cell. It's often necessary to use <cmd>ReFormat[<i>new keys</i>]{}</cmd> to reformat this specific cell according to the ''new keys''.<br />
<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR % slightly shorted<br />
\HL<br />
\NC left column text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left column text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR<br />
\HL<br />
\NC left column text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left column text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
<br />
(<cmd>ReFormat</cmd> can be abbreviated <cmd>REF</cmd> for brevity.)<br />
== Row Spans==<br />
<br />
It's also possible to create rowspans (i.e. cells that span more than one row) with the command <cmd>Raise(<i>dimen</i>){<i>content</i>}</cmd> or <cmd>Lower(<i>dimen</i>){</i>content</i>}</cmd> that raise or lower ''content'' by ''dimen''.<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
(<cmd>Lower(.5\lineheight){a}</cmd> can be abbreviated <cmd>LOW{a}</cmd> for brevity.)<br />
<br />
An alternative means of spanning rows by a tall object makes use of a bit of TeX magic:<br />
<cmd>smash{tall objext}</cmd>:<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
==Table as Floating Object==<br />
<br />
<texcode><br />
\placetable[here][tab:sample]{sample table}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
* See [[Floating Objects]] in general.<br />
* If you need information about <cmd>placetable</cmd> look after <cmd>placefloat</cmd> in the manual or texshow!<br />
* If you'd like to leave out the table's caption (here: "sample table"), you can't simply leave the braces empty but must write <tt>none</tt>!<br />
<br />
==Background Colors==<br />
<br />
A very nice application in table are background colors for rows/cells (a feature that doesn't work in [[Tabulate]]):<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><br />
</tr></table><br />
The commands work something like this: first, you say what background colour you want for the next row<br />
and then you typeset the row. Observe: the line with the colour-command and the row it is supposed<br />
to colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the background<br />
won't cover the whole cell.<br />
<br />
* <cmd>BL</cmd> makes a gray background: the optional argument tells BL how many cells it should color<br />
* <cmd>CL</cmd> makes a colored line<br />
<br />
==Fit Table Width==<br />
<br />
Hans posted a solution to the list for fitting a wide table (with paragraphs and vertical lines) to the page width. The key to his solution is the <code>.45\textwidth</code> settings when setting each cell as a paragraph.<br />
<br />
<texcode><br />
\SetTableToWidth{\textwidth}<br />
<br />
\starttable[|p(.45\textwidth)|p(.45\textwidth)|]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<!-- It makes no sense to typeset this here. --><br />
<br />
== Booktabs ==<br />
<br />
Latex has an excellent package called booktabs for typesetting tables. The main features of that package is that you can have top, mid, and bottom rules of different thickness. It is possible to achieve similar effects using tables. For example, to match the default settings of booktabs (Well almost, this gives a top and bottom rules of 0.09em while booktabs sets it to 0.08em).<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
[[Category:Tables]]</div>132.166.21.4https://wiki.contextgarden.net/index.php?title=Table&diff=8907Table2008-09-12T09:22:58Z<p>132.166.21.4: /* Column Spans */</p>
<hr />
<div>< [[Tables Overview]] | [[Tabulate]] | [[Tables]] ><br />
<br />
This is ConTeXts oldest table module. It uses the same formatting as [[Tabulate]] (see [[Tables Overview]]).<br />
<br />
This mode is based on Michael Wichura's TaBlE package for PlainTeX. The official manual for it is commercial (about 40 USD), see [http://www.pctex.com/books.html PCTeX] -- but note that the TaBlE manual only talks about the original syntax, which does not use <cmd>NC</cmd>, <cmd>HL</cmd> cum suis.<br />
<br />
The only ConTeXt docs are in [[manual:ms-cb-en.pdf|ConTeXt - an excursion]]. There is also two introductory articles in tugboat [http://tug.org/TUGboat/Articles/tb28-3/tb90mahajan.pdf ConTeXt basics for users: Table macros] [http://www.tug.org/TUGboat/Articles/tb29-1/tb91mahajan.pdf Table macros II] by Aditya Mahajan (2007 and 2008).<br />
<br />
<br />
== Basic Commands ==<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
* You get vertical lines (rules), if you use <cmd>VL</cmd> instead of <cmd>NC</cmd>.<br />
* Better use <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd>, <cmd>LR</cmd> instead of <cmd>NR</cmd>.<br />
* You can also use <cmd>AR</cmd> instead of <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd> and <cmd>LR</cmd> (AR for automatic row).<br />
* You can leave out the <cmd>NC</cmd> before the "row" command, but not if you use <cmd>AR</cmd> in a last or single row (see example).<br />
* You can influence the table with <cmd>setuptables</cmd>.<br />
* There are also <cmd>BL</cmd> and <cmd>CL</cmd> for colored backgrounds, see below.<br />
<br />
==Column Definition==<br />
<br />
The table is defined by the template enclosed in square brackets after <cmd>starttable</cmd>. The template has the form<br />
<tt>|keys for the first column|keys for the second column|...|keys for the last column|</tt>. Please note that the each column is surrounded by <tt>|</tt> signs. These are necessary. The formatting keys for each column can be a choice of<br />
<br />
<table width="100%" cols="2"><tr valign="top"><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|lp(.5\textwidth)|]<br />
\HL<br />
\NC \bf Key \VL \bf Meaning \SR<br />
\HL<br />
\NC \NC Primitive Keys \SR<br />
\HL<br />
\NC \type{a{tokens}}\VL Adds \type{tokens} {\em after} the column content\AR<br />
\NC \type{b{tokens}}\VL Adds \type{tokens} '''before''' the column content\AR<br />
\NC {\tt \backslash\{ } \VL Enclose the column in braces (grouping)\AR<br />
\NC \type{*{n}{keys}}\VL Equivalent to repeating the formatting keys \type{keys} \type{n} times\NC\LR<br />
\HL<br />
\NC \NC Positioning Keys\SR<br />
\HL<br />
\NC \type{\LeftGlue} \VL Specifies the left glue to be used before the column\AR<br />
\NC \type{\RightGlue} \VL Specifies the right glue to be used after the column\AR<br />
\NC \type{l} \VL left-aligned column\AR<br />
\NC \type{c} \VL centered column\AR<br />
\NC \type{r} \VL right-aligned column\AR<br />
\NC \type{p(width)} \VL Set each cell as a paragraph\AR<br />
\NC \type{w} \VL Set minimum column width\AR<br />
\NC \type{k} \VL Insert a kern both left and right of the column\AR<br />
\NC \type{i} \VL Add a kern to the left of the column\AR<br />
\NC \type{j} \VL Add a kern to the right of the column\LR<br />
\HL<br />
\NC \NC Numeric and Math Item Keys \SR<br />
\HL<br />
\NC \type{n} \VL Numeric item not in math mode\AR<br />
\NC \type{N} \VL Numeric item in math mode\AR<br />
\NC \type{m} \VL Each cell is in (inline) math mode. Equivalent to \type{b$ a$}\AR<br />
\NC \type{M} \VL Each cell is in display math mode. Equivalent to \type{\{b{$\displaystyle}a$}} \AR<br />
\NC \type{\m} \VL Equivalent to \type{l b{{}}m}\AR<br />
\NC \type{\M} \VL Equivalent to \type{l b{{}}M}\LR<br />
\HL<br />
\NC \NC Style Keys \SR<br />
\HL<br />
\NC \type{f\command} \VL Set font according to following \tex{command}\AR<br />
\NC \type{B} \VL Bold. Equivalent to \type{f\bf}\AR<br />
\NC \type{I} \VL Italic. Equivalent to \type{f\it}\AR<br />
\NC \type{S} \VL Slanted. Equivalent to \type{f\sl}\AR<br />
\NC \type{R} \VL Roman. Equivalent to \type{f\rm}\AR<br />
\NC \type{T} \VL Teletype. Equivalent to \type{f\tt}\AR<br />
\NC \type{C} \VL Color. Use it in combination with \backslash\{ (e.g. \backslash\{C\{red\} )\LR<br />
\HL<br />
\NC \NC Tabskip Keys \SR<br />
\HL<br />
\NC \type{s} \VL Set the tabskip to the right of this column and of all following columns up to the next \type{s} or \type{o} key\AR<br />
\NC \type{o} \VL Set the tabskip to the right of this column only\LR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><td><br />
===Examples===<br />
; <code>|l|</code> : a left aligned column, as wide as necessary<br />
; <code>|lw(2cm)|</code> : a left aligned column of at least 2 cm width<br />
; <code>|p(2cm)|</code> : a centered(!) paragraph of 2 cm width<br />
; <code>|lp(.5\textwidth)|</code> : a left aligned paragraph of specified width<br />
; <code>|rp(.5\textwidth)|</code> : a right aligned paragraph of specified width<br />
; <code>|cp(.5\textwidth)|</code> : a center aligned paragraph of specified width<br />
; <code>|xp(.5\textwidth)|</code> : a justified paragraph of specified width<br />
; <code>...</code> : Please add more<br />
; <code>...</code> : <br />
<br />
{{Todo|add more examples of column definitions}}<br />
</td></tr></table><br />
<br />
==Column Spans==<br />
<br />
It's possible to create columnspans (i.e. cells that span more than one column) with the command <cmd>use{<i>N</i>}</cmd> where ''N'' is the number of columns spanned by the cell. It's often necessary to use <cmd>ReFormat[<i>new keys</i>]{}</cmd> to reformat this specific cell according to the ''new keys''.<br />
<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR % slightly shorted<br />
\HL<br />
\NC left column text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left column text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR<br />
\HL<br />
\NC left column text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left column text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
Note that one can create rowspans (i.e. cells that span more than one row) using a bit of TeX magic:<br />
<cmd>smash{\vcenter{\hbox{A tall object}}}</cmd>...<br />
<br />
==Table as Floating Object==<br />
<br />
<texcode><br />
\placetable[here][tab:sample]{sample table}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
* See [[Floating Objects]] in general.<br />
* If you need information about <cmd>placetable</cmd> look after <cmd>placefloat</cmd> in the manual or texshow!<br />
* If you'd like to leave out the table's caption (here: "sample table"), you can't simply leave the braces empty but must write <tt>none</tt>!<br />
<br />
==Background Colors==<br />
<br />
A very nice application in table are background colors for rows/cells (a feature that doesn't work in [[Tabulate]]):<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><br />
</tr></table><br />
The commands work something like this: first, you say what background colour you want for the next row<br />
and then you typeset the row. Observe: the line with the colour-command and the row it is supposed<br />
to colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the background<br />
won't cover the whole cell.<br />
<br />
* <cmd>BL</cmd> makes a gray background: the optional argument tells BL how many cells it should color<br />
* <cmd>CL</cmd> makes a colored line<br />
<br />
==Fit Table Width==<br />
<br />
Hans posted a solution to the list for fitting a wide table (with paragraphs and vertical lines) to the page width. The key to his solution is the <code>.45\textwidth</code> settings when setting each cell as a paragraph.<br />
<br />
<texcode><br />
\SetTableToWidth{\textwidth}<br />
<br />
\starttable[|p(.45\textwidth)|p(.45\textwidth)|]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<!-- It makes no sense to typeset this here. --><br />
<br />
== Booktabs ==<br />
<br />
Latex has an excellent package called booktabs for typesetting tables. The main features of that package is that you can have top, mid, and bottom rules of different thickness. It is possible to achieve similar effects using tables. For example, to match the default settings of booktabs (Well almost, this gives a top and bottom rules of 0.09em while booktabs sets it to 0.08em).<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
[[Category:Tables]]</div>132.166.21.4