Difference between revisions of "Tabulate"
m (→Single row columns: Added ConTeXt output) |
m (→Basic commands: Slightly changed layout) |
||
Line 8: | Line 8: | ||
The sample describes the formatting characters: | The sample describes the formatting characters: | ||
− | <texcode> | + | {| |
+ | ! width="55%"| | ||
+ | ! width="10%"| | ||
+ | ! width="35%"| | ||
+ | |- | ||
+ | | <texcode> | ||
\starttabulate[|l|l|] | \starttabulate[|l|l|] | ||
\HL | \HL | ||
Line 22: | Line 27: | ||
\stoptabulate | \stoptabulate | ||
</texcode> | </texcode> | ||
− | + | | | |
− | + | |<context> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | <context> | ||
\starttabulate[|l|l|] | \starttabulate[|l|l|] | ||
\HL | \HL | ||
Line 43: | Line 42: | ||
\stoptabulate | \stoptabulate | ||
</context> | </context> | ||
+ | |} | ||
+ | |||
+ | * HL is horizontal line | ||
+ | * NC is new column (or new cell) | ||
+ | * NR is new row | ||
== Column Spans == | == Column Spans == |
Revision as of 08:44, 4 June 2009
< Tables Overview | Table >
Basic commands
Rather simple tabulating. You need the bars in the formatting field of \starttabulate! If you want vertical lines, you need another table mode (see Tables).
This is especially suited if you want to have paragraphs in one (or more) of the tabulate columns.
The sample describes the formatting characters:
\starttabulate[|l|l|] \HL \NC format \NC meaning \NC\NR \HL \NC c \NC centered \NC\NR \NC l \NC left aligned \NC\NR \NC r \NC right aligned \NC\NR \NC w(1cm) \NC one line, fixed width \NC\NR \NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR % You can leave out the \NC before \NR \HL \stoptabulate |
- HL is horizontal line
- NC is new column (or new cell)
- NR is new row
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 l
, r
or c
you could use \span\omit\span\omit\span\omit
for each cell.
You could prevent these values you could them in a macro and use it with
\use{2}
or \TWO
in the tabulate environment.
\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 |
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
\def\tabulateuse#1% {\dorecurse{\numexpr2*#1-1\relax}{\span\omit}\raggedright\ignorespaces} \appendtoks \let\use\tabulateuse \defineTABLEshorthands \to \everytabulate \starttext \starttabulate[|p(2cm)|p(3cm)|p(4cm)|] \NC \dorecurse{10}{text } \NC \dorecurse{4}{Lorem Ipsum } \NC \dorecurse{18}{text } \NC\NR \NC \TWO Short text spanning two tabulate paragraphs. \NC \dorecurse{17}{text } \NC\NR \stoptabulate \stoptext |