The tabulate environment allows you to create simple tables, suited for tables with large blocks of text. This type of table does not produce vertical lines between cells—hence the name tabulate, hinting at the type of table created with tabs.
Rather than try to explain the many details of this layout, let me first show the code example.
% start envrionment and setup columns \starttabulate[|p(6cm) j3|p(6cm)|] % create a cell \NC American Community Survey % %create a cell \NC Current Population Survey % % end the row \NC\NR % create a horizontal line % \HL % % create a cell \NC All dollar values for income are adjusted to latest calendar year of estimates using the Consumer Price Index for the date collected versus the average for the year. % create a cell \NC None % % end the row \NC\NR % % end tabulate \stoptabulate
Begin the table with the starttabulate command. Set up the column information in the first option. The information for formatting each column gets put between the “|” character. A one column table needs 2 “|” characters, a two column table needs 3 “|” characters, and so on.
The first colum of my table has two commands. The first, p(6cm), tells ConTeXt to create a 6 cm paragraph for the column. If the column contains cells with brief text that aren’t really paragraphs, use the l, r, or c property. The l command aligns the text left; the r aligns the text right; and the c command centers the text. For example, for a two-column table, my setups might look like this:
% make two columns, both aligned left \starttabulate[|l|l|]
In addtion, one can use the w property for a one line column. Like the p option, the [:pr; w] option takes a dimmension in parenthesis.
Each column must contain one of the above properties, so that ConTeXt knows how to format it.
The setups for each column can have additional commands. The j3 option in my table creates space after the column. A number lower than 3 creates less space, while a number greater than 3 creates more. The opposite property, i creates space before the column, and functions just like its counterpart j. The property k seems to create space on either side of the column.
Here is a summary of the options for the column setups.
option | result |
l | align left |
r | align right |
c | align center |
p(dimen) | create a paragraph with width dimen |
w(dimen) | create a column with width dimen |
f #1 | font |
B | bold |
I | italic |
S | slanted |
T | Type |
R | roman |
m | math |
M | display math |
h | hook (inner level of par lines) |
b | before (may be command) |
a | after (may be command) |
i<number> | skip left of column |
j<number> | skip right of column |
k<number> | skip around column |
Within the body of the table itself, issue comand in order to create cells, rows, and horiziontal lines. The NC command creates a new cell. The NR command creates a new row. The HL creates a horizontal line.
You must end every rown (including the last) with the NR command.
The standard table commands give us pretty good flexibility in creating complicated tables.
Here is a basic table.
\placetable[here][tab:insurance]{Percentage of People without health insurance in US} \starttable[|l w(30mm)|l|l|] \HL \VL State \VL 3-year average \VL 2-year average \VL\SR \HL[4] \VL Alabama \VL 13.3 \VL 13.5 \VL\FR \HL \VL Alaska \VL 17.8 \VL 18.8 \VL\MR \HL \VL Arizona \VL 17.3 \VL 16.9 \VL\LR \HL \stoptable
Rather than using the NC command to creat a new cell, this table uses VL, which creates a vertical line between each cell.
Notice how the HL command has the option 4. This option increases the line width by a factor of 4. You can use any integer you want—the larger the number, the thicker the width. You can use the same option after a VL command.
The endings for each row are different than the NL commands fromt the tabulate table. Each ending performs a different function.
* The SR command puts extra space between it and the next row. (Frankly, I don’t find this to be the case with my table, but this is what it is supposed to do.)
* The FR command establishes the correct distance for the first row.
* The MR establishes the correct distance for the middle row.
* The LR command establishes the correct distance for the last row.
You can use the AR or automatic row command in place of the SR, FR, and LR commands. The AR command seems to do a good job adjusting the height.
In order to merge cells horizontally, use the NC instead of the VL command, and omit any text for the cell to be merged. In other words, simpley create an empty cell with no border.
\starttable[|l w(30mm)|l|l|] \HL \VL State \VL 3-year average \VL 2-year average \VL\SR \HL[4] \VL Alabama \NC \VL 13.5 \VL\FR ...
Here are some more examples of tables.
This table is an example of merging cells horizontally and vertically. It also shows how to cutomize a header, center cell text, and create blank cells.
This table is likewise a good example of merging cells horizontally and vertically.
The TABLE is the most powerful and flexible tables module in ConTeXt. Its sytax is closest to css stylesheets.
You can find a PDF file with many examples at url=http://www.pragma-ade.com/general/manuals/enattab.pdf
The following is a simple table.
\bTABLE \bTR \bTD State \eTD \bTD3-year average \eTD \bTD2-year average \eTD \eTR \bTR \bTD Alabama \eTD \bTD 13.3 \eTD \bTD 13.5 \eTD \eTR ... \eTABLE
Each command in the TABLE environment is paired: bTABLE is matched with eTable, bTR is matched with eTR, and so on. The lower-case “b” stands for beginn, while the lower-case “e” stands for end.
The commands otherwise look very much like XHTML format, with TR standing for table row, and TD for table cell.
Customizing cells and rows in TABLE is more straightforward than with other table modules. Use the setupTABLE command. The first few commands of this option describe the rows, columns, or cells that need to be customized. The last option describes the actual customization.
You can use as many setupTABLE commands as you have customizations.
Each cell in the TABLE environment is assigned both a row and column number.
each cell as a row and column number
If the table has merged cells, the numbering does not change. The invisible cells are given their number, and the non-invisible cells keep theirs.
each cell as a row and column number
Here is a table of possible properties you can use to customize each cell.
option | result | note |
width=<dimen> | set height | |
height=<dimen> | set height | |
background=color | sets color | used in conjuction with color=<color>;use the word "color," not the name of the color |
color=<color> | sets color | used in conjuction with backgroundcolor=color |
frame=<off>|<on> | turns frame (borders) off or on | |
framecolor=<color> | set color of border | |
rulethickness=<dimen> | set thickness of rule for entire frame around cell |
To change something for individual cells using cell addressing (that is, identifying the cells by their rows and numbers), use the [:setupTABLE] command, followed by the number of the column, followed by the number followed by the number of the row, and finally followed by the desired customization. The following table makes the first cell (1, 1) and the middle cell (2, 2) red.
%needed to get color \setupcolors[state=start] % % set up first column, first row \setupTABLE[1][1][background=color, backgroundcolor=red] % % setup second column, second row \setupTABLE[2][2][background=color, backgroundcolor=red]
copyright 2005 Paul Henry Tremblay
License: GPL
home | contents | previous | next
last updated: 2005-04-11