Grid table
Grid tables provide a complete table display. They allow any cell contents (text body elements) as well as the linking of rows and columns. However, it can be difficult to create grid tables, especially for simple data records.
A simpler (but limited) table representation can be found in section Simple table.
Properties
- Grid tables are described by a visual grid consisting of the characters "-", "=", "|" and "+". The hyphen ("-") is used for horizontal lines (line separators). The vertical bar ("|") is used for vertical lines (column separators). The plus sign ("+") is used for intersections of horizontal and vertical lines. The equal sign ("=") can be used to separate headers from the table body.
- As with other text body elements, blank lines are required before and after tables. To separate two consecutive tables, a paragraph with text or a paragraph with a vertical bar must be inserted. The latter is removed from the output.
- Left table borders should be aligned with the left edge of preceding text blocks. If tables are indented, they are considered as part of a block quote. The minimum indentation is one space.
Samples
The following sample illustrates:
- Merged columns and rows
- Different text body elements in cells
(In sample project: B_DocuElements\Tables\FB_Libdoc_GridTable)
(*
+------------------------+------------+----------+----------+
| Header row, column 1 | Header 2 | Header 3 | Header 4 |
| (header rows optional) | | | |
+========================+============+==========+==========+
| body row 1, column 1 | column 2 | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2 | Cells may span columns. |
+------------------------+------------+---------------------+
| body row 3 | Cells may | - Table cells |
+------------------------+ span rows. | - contain |
| body row 4 | | - body elements. |
+------------------------+------------+---------------------+
*)
Sample of an unwanted interaction between grid character and cell text
The following table contains a cell in row 2, which ranges from column 2 to column 4:
+--------------+----------+-----------+-----------+
| row 1, col 1 | column 2 | column 3 | column 4 |
+--------------+----------+-----------+-----------+
| row 2 | |
+--------------+----------+-----------+-----------+
| row 3 | | | |
+--------------+----------+-----------+-----------+
When a vertical bar is used in the text of this cell, unintended effects may occur if it is inadvertently aligned to a column boundary:
+--------------+----------+-----------+-----------+
| row 1, col 1 | column 2 | column 3 | column 4 |
+--------------+----------+-----------+-----------+
| row 2 | Use the command ``ls | more``. |
+--------------+----------+-----------+-----------+
| row 3 | | | |
+--------------+----------+-----------+-----------+
Several solutions are possible to break the continuity of the grid structure.
One way is to move the text by adding an additional space before the cell text. The space is removed in the output.
+--------------+----------+-----------+-----------+
| row 1, col 1 | column 2 | column 3 | column 4 |
+--------------+----------+-----------+-----------+
| row 2 | Use the command ``ls | more``. |
+--------------+----------+-----------+-----------+
| row 3 | | | |
+--------------+----------+-----------+-----------+
Another option is to add an additional row to row 2. The blank line is removed from the output.
+--------------+----------+-----------+-----------+
| row 1, col 1 | column 2 | column 3 | column 4 |
+--------------+----------+-----------+-----------+
| row 2 | Use the command ``ls | more``. |
| | |
+--------------+----------+-----------+-----------+
| row 3 | | | |
+--------------+----------+-----------+-----------+