Table tags enable you to display text in an arrangement of rows and columns. The system font used to create tables is the monospace font.
The table tag (:table.) signals the start of the table. It requires a corresponding :etable. at the end of the table.
The row tag (:row.) specifies the start of each row in the table. Each row must have at least one column-entry tag (:c.). This tag specifies the text for each column in the table.
The cols=' ' attribute of :table. specifies numeric values that represent the column widths, in character spaces, of each column in the table. The combined values cannot exceed 250 characters.
The number of columns in your table is determined by the number of column width values you have specified with the cols=' ' attribute. For example, if you enter the values shown in the following, your table will have three columns, each of which will be eleven characters spaces wide.
cols='11 11 11'
A Table with Three Columns: The following is a simple example of a table with two rows and three columns:
Input Example
:table cols='13 13 13'.:row. :c.Column 1 :c.Column 2 :c.Column 3 :row. :c.Row 1 Col 1 :c.Row 1 Col 2 :c.Row 1 Col 3 :row. :c.Row 2 Col 1 :c.Row 2 Col 2 :c.Row 2 Col 3 :etable.
Formatted Output
┌───────────┬───────────┬───────────┐ │Column 1 │Column 2 │Column 3 │ ├───────────┼───────────┼───────────┤ │Row 1 Col 1│Row 1 Col 2│Row 1 Col 3│ ├───────────┼───────────┼───────────┤ │Row 2 Col 1│Row 2 Col 2│Row 2 Col 3│ └───────────┴───────────┴───────────┘
If you have more :c. tags following a :row. tag than you have column-width values, the extra column entries are placed in a new row, and the compiler returns an error message.
If you have fewer :c. tags than column-width values, the compiler does not consider this an error. Space is still allocated for the specified columns; however, only the columns for which you have provided entries will be filled.
Table Rules and Frames: The rules= attribute of :table. specifies whether the table will have vertical rules, horizontal rules, a combination of both, or no rules at all to delineate the items in the table. The values that you can specify for rules= are:
rules=both
rules=none
rules=horiz
rules=vert
A Table with Horizontal Rules:
Input Example
:table rules=horiz cols='10 15 15'.:row. :c.SYMBOL :c.ELEMENT :c.CHARACTER :row. :c.&.bxas. :c.box ascender :c.&bxas. :row. :c.&.bxcr. :c.box cross :c.&bxcr. :row. :c.&.bxde. :c.box descender :c.&bxde. :etable.
Formatted Output
┌──────────────────────────────────────────────────────────┐ │ SYMBOL ELEMENT CHARACTER │ │──────────────────────────────────────────────────────────│ │ &bxas. box ascender ┴ │ │──────────────────────────────────────────────────────────│ │ &bxcr. box cross ┼ │ │──────────────────────────────────────────────────────────│ │ &bxde. box descender ┬ │ └──────────────────────────────────────────────────────────┘
If you do not specify the rules= attribute, your table will contain both vertical and horizontal rules (the default).
The frame= attribute of :table. specifies whether the table will have borders. The values that you can specify are:
frame=none
frame=rules
frame=box
If you specify frame=none, there will be no borders.
Specifying frame=rules results in a horizontal line at the top and bottom of the table.
If you specify frame=box, or do not specify the frame= attribute, the table is enclosed in a box.
A Table without a Frame: Here is the same table without a frame.
Input Example
:table rules=horiz frame=none cols='10 15 15'.:row. :c.SYMBOL :c.ELEMENT :c.CHARACTER :row. :c.&.bxas. :c.box ascender :c.&bxas. :row. :c.&.bxcr. :c.box cross :c.&bxcr. :row. :c.&.bxde. :c.box descender :c.&bxde. :etable.
Formatted Output
SYMBOL ELEMENT CHARACTER ────────── ────────── ────────── ────────── ────────── ──── & bxas . box ascender " ────────── ────────── ────────── ────────── ────────── ──── & bxcr . box cross ┼ ────────── ────────── ────────── ────────── ────────── ──── & bxde . box descender "
Special Considerations: None of the text-formatting tags (for example, list tags) can be used in a table. You can use character-graphic symbols and highlighted-phrase tags. However, boldface and italic highlighting can cause vertical misalignment of column text and rules. To use boldface highlighting in tables and avoid word alignment problems, place the highlighted-phrase tags (:hp2. and :ehp2.) as shown in the example. The table rules as well as the text will be displayed in boldface.
Input Example
:hp2. :table cols='11 11 11'. :row. :c.Row 1 Col 1 :c.Row 1 Col 2 :c.Row 1 Col 3 :row. :c.Row 2 Col 1 :c.Row 2 Col 2 :c.Row 2 Col 3 :etable. :ehp2.
Formatted Output
┌───────────┬───────────┬───────────┐
│Row 1 Col 1│Row 1 Col 2│Row 1 Col 3│
├───────────┼───────────┼───────────┤
│Row 2 Col 1│Row 2 Col 2│Row 2 Col 3│
└───────────┴───────────┴───────────┘
The above technique is practical only with :hp2. and does not work for :hp1. or for the highlighted-phrase tags that change the color of text.
Unformatted Text in a Table Column: The text in table columns is formatted only once-at compile time. If you do not want the compiler to format the text in a column, enclose it with :lines. and :elines., as shown in the following example.
Input Example
:table cols='10 10 15 10'. :row. :c.Spacecraft :c.Date :c.Astronauts :c.Mission :row. :c.Apollo 11 :c.7-16-1969 :c. :lines. Neil Armstrong Edwin Aldrin Michael Collins :elines. :c. First landing on the moon. :etable.
Formatted Output
┌──────────┬──────────┬───────────────┬──────────┐ │Spacecraft│Date │Astronauts │Mission │ ├──────────┼──────────┼───────────────┼──────────┤ │Apollo 11 │7-16-1969 │Neil Armstrong │First │ │ │ │Edwin Aldrin │landing on│ │ │ │Michael Collins│the moon. │ └──────────┴──────────┴───────────────┴──────────┘