Changes

Jump to navigation Jump to search
432 bytes added ,  15:11, 19 January 2006
fixed column keys table, enhanced layout, added Category:Tables
<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
<table width="100%" cols="2"><tr valign="top"><td>
<context>
\switchtobodyfont[ss, 8pt]\starttable[|l|lp(.5\textwidth)|]
\HL
\NC \bf Key \VL \bf Meaning \SR
\NC \type{c} \VL centered column\AR
\NC \type{r} \VL right-aligned column\AR
\NC \type{p(width)} \VL Set each cell as a paragraph\AR
\NC \type{w} \VL Set minimum column width\AR
\NC \type{k} \VL Insert a kern both left and right of the column\AR
\NC \type{o} \VL Set the tabskip to the right of this column only\LR
\HL
\stoptable
</context>
</td><td>
===Examples===
; <code>|l|</code> : a left aligned column, as wide as necessary
; <code>|lw(2cm)|</code> : a left aligned column of at least 2 cm width
; <code>|p(2cm)|</code> : a centered(!) paragraph of 2 cm width
; <code>|lp(.5\textwidth)|</code> : a left aligned paragraph of specified width
; <code>...</code> : Please add more
; <code>...</code> :
 
{{todo|add more examples of column definitions}}
</tr></table>
==Column Spans==
It's possible to create columnspans (i.e. cells that span more than one column) with the command <cmd>use[<i>N</i>]</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''.
 
{{todo|example for column spans}}
==Table as Floating Object==
A very nice application in table are background colors for rows/cells (a feature that doesn't work in [[tabulate]]):
 
<table cols="2"><tr valign="top"><td>
<texcode>
\setupcolors[state=start]
\placetable[here][tab:sample]{sample table}
\starttable[|l|l|]
\HL
\BL[2]\SR
\NC Command \NC Meaning \NC\SR
\HL
\NC \tex{NC} \NC next column \NC\FR\NC \tex{HL} \NC horizontal line \NC\MR\NC \tex{VL} \NC vertical line \NC\MR\NC \tex{NR} \NC next row \NC\LR
\HL
\CL[green]\SR
\NC \tex{AR} \NC automatic row \NC\SR
\HL
\stoptable
</texcode>
The commands work something like this: first, you say what background colour you want for the next rowand then you typeset the row. Observe: the line with the colour-command and the row it is supposedto colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the backgroundwon't cover the whole cell. * <cmd>BL</cmdtd> makes a gray background: the optional argument tells BL how many cells it should color* <cmd>CL</cmdtd> makes a colored line
<context>
\setupcolors[state=start]
\placetable[here][tab:sample]{sample table}
\starttable[|l|l|]
\HL
\BL[1]\SR
\NC Command \NC Meaning \NC\SR
\HL
\NC \tex{NC} \NC next column \NC\FR\NC \tex{HL} \NC horizontal line \NC\MR\NC \tex{VL} \NC vertical line \NC\MR\NC \tex{NR} \NC next row \NC\LR
\HL
\CL[green]\SR
\NC \tex{AR} \NC automatic row \NC\SR
\HL
\stoptable
</context>
</td>
</tr></table>
The commands work something like this: first, you say what background colour you want for the next row
and then you typeset the row. Observe: the line with the colour-command and the row it is supposed
to colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the background
won't cover the whole cell.
 
* <cmd>BL</cmd> makes a gray background: the optional argument tells BL how many cells it should color
* <cmd>CL</cmd> makes a colored line
==Fit Table Width==
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.
 
<texcode>
\SetTableToWidth{\textwidth}
\HL
\stoptable
</texcode>
<!-- It makes no sense to typeset this here. -->
\stoptext</texcode>[[Category:Tables]]

Navigation menu