Open main menu

Changes

1,600 bytes added ,  12:50, 16 September 2008
column span for tabulate
< [[Tables Overview]] | [[Table]] >
 
== Basic commands ==
Rather simple tabulating. You ''need'' the bars in the formatting field of <cmd>starttabulate</cmd>! '''If you want vertical lines, you need another table mode''' (see [[Tables]]).
\stoptabulate
</context>
 
== Column Spans ==
 
Tabulate has no support for column spans but you could add this function yourself.
 
The code to do this depends on the tabulate setting and you have to know what
content what column setting you need.
 
=== Single row columns ===
 
To span columns in cells with <code>l</code>, <code>r</code> or <code>c</code>
you could use <code>\span\omit\span\omit\span\omit</code> for each cell.
 
You could prevent these values you could them in a macro and use it with
<code>\use{2}</code> or <code>\TWO</code> in the tabulate environment.
 
<texcode>
\def\tabulateuse#1%
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}}
 
\appendtoks
\let\use\tabulateuse
\defineTABLEshorthands
\to \everytabulate
 
\starttext
 
\starttabulate[|l|Br|l|l|]
\NC a \NC b \NC c \NC d \NR
\NC 1 \NC 2 \TWO \NC 4 \NR
\stoptabulate
 
\stoptext
</texcode>
 
=== Paragraph columns ===
 
For spanned columns in cells with paragraphs you need a different implementation.
 
To use this macro you have to take care about a few things:
 
* You have to set a width for each cell
* The format for the spanned column is fixed and you have to change it in the macro
 
<texcode>
\def\tabulateuse#1%
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}\raggedright\ignorespaces}
 
\appendtoks
\let\use\tabulateuse
\defineTABLEshorthands
\to \everytabulate
 
\starttext
 
\starttabulate[|p(4cm)|p(4cm)|p(6cm)|]
\NC \dorecurse{10}{text } \NC \dorecurse{8}{text } \NC
\dorecurse{18}{text } \NC\NR
\NC \TWO Short text spanning two tabulate paragraphs. \NC
\dorecurse{22}{text } \NC\NR
\stoptabulate
 
\stoptext
</texcode>
[[Category:Tables]]
gardener
110

edits