NAME
groff_hdtbl - Heidelberger table macros for GNU roffDESCRIPTION
The hdtbl macros consist of four base and three optional macros, controlled by about twenty arguments. The syntax is simple and similar to the HTML table model and nearly as flexible: You can write sequences of tokens (macro calls with their arguments and content data), separated by blanks and beginning with a macro call, into the same line to get compact and cleanly arrranged input. An advantage of hdtbl is that the tables are constructed without calling a preprocessor; this means that groff's full macro capabilities are available. On the other hand, table processing with hdtbl is much slower than using the tbl(1) preprocessor. A further advantage is that the HTML-like syntax of hdtbl will be easily converted to HTML; this is not implemented yet.USAGE
In this and the next section, we present examples to help users understand the basic workflow of hdtbl. First of all, you must load the hdtbl.tmac file. As with nearly all other groff macro packages, there are two possibilities to do so: Either add the linecontents of the table cell
+------------------------------------------------------+ | contents-of-the-table-cell | +------------------------------------------------------+
Equivalent to the above is the following notation.
.TBL.TR.TD"contentsofthetablecell".ETB
+--------------------------+---------------------------+ | 1*1 | 1*2 | +--------------------------+---------------------------+ | 2*1 | 2*2 | +--------------------------+---------------------------+
Here we see a difference from HTML tables: The number of columns must be explicitly specified using the ‘cols=m’ argument (or indirectly via the argument, see below). The contents of a table cell is arbitrary; for example, it can be another table, without restriction to the nesting depth. A given table layout can be either constructed with suitably nested tables or with proper arguments to and , controlling column and row spanning. Note, however, that this table
+------------------------------------------------------+ | 1*1 1*2 | +------------------------------------------------------+ | | | 2*1 2*2 | | | +------------------------------------------------------+
and the second one like
+------------------------------------------------------+ | 1*1 1*2 | +---------------------------+--------------------------+ | 2*1 | 2*2 | +---------------------------+--------------------------+
Here the latter table in a more compact form.
MACROS AND ARGUMENTS
The order of macro calls and other tokens follows the HTML model. In the following list, valid predecessors and successors of all hdtbl macros are given, together with the possible arguments. Macro arguments are separated by blanks. The order of arguments is arbitrary; they are of the formkey=value
or
key='value1[value2[]]'
with the only exception of the optional argument of the macro , which is the
string . Another possible form is
"key=value1[value2[]]"
However, this is limited to the case where the macro is the first one in the
line and not already enclosed in double quotes.
Argument values specified below as c are colors predefined by
groff or colors defined by the user with the request. Argument
values d are decimal numbers with or without decimal point.
Argument values m are natural numbers. Argument
values n are numerical values with the usual groff
scaling indicators. Some of the arguments are specific to one or two macros,
but most of them can be specified with , , , and These common arguments are
explained in the next subsection.
Most of the argument default values can be changed by the user by setting
corresponding default registers or strings, as listed below.
- .TBL[args]
- Begin a new table.
predecessor:
successor:
arguments:
$@ Thickness of the surrounding box border.
(no value) means neither a surrounding box border nor any horizontal or
vertical separator lines between the table rows and cells. suppresses the
surrounding box border, but still allows separator lines between cells and
rows.
Default: $@ Border color.
Default: $@ Number of table columns. This argument is necessary if more
than one column is in the table and no arguments are present.
Default: $@ Cell padding, i.e., the extra space between the cell space
border and the cell contents.
Default: $@ Cell spacing, i.e., the extra space between the table border
or vertical or horizontal lines between cells and the cellspace.
Default: $@ Horizontal alignment of the table, if it is smaller than the
line width. : left alignment. : centered alignment. : right alignment.
Default: $@ Widths of table cells. w1, w2,
are either numbers of type n or natural numbers with the
pseudo-scaling indicator , with the meaning “percent of the actual line
length (or column length for inner tables, respectively)”. If there are
less width values than table columns, the last width value is used for the
remaining cells. The argument
- for example indicates that the first column is
1.5 inches wide; the remaining columns take 1/10 of the column
length each.
- .CPTN[args]
- Text of caption.
- The (optionally numbered) table caption. is optional.
predecessor:
successor:
arguments:
$@ Vertical alignment of the table caption. :
The caption is placed above the table. : The caption is placed below the
table.
Default:
- .TR[args]
- Begin a new table row.
predecessor:
successor:
arguments:
$@ The height of the row. If a cell in the row
is higher than n, this value is ignored; otherwise the
row height is stretched to n.
- .TD[args[cellcontents]]
- Begin a table data cell. .TH[args[cellcontents]] Begin a table header cell.
- Arguments and cell contents can be mixed. The macro is not really necessary and differs from only in three default settings, similar to the and HTML tags: The contents of is horizontally and vertically centered and typeset in boldface.
predecessor:
successor:
arguments:
$@ The width of this cell is the sum of the
widths of the m cells above and below this row. $@ The height of
this cell is the sum of the heights of the m cells left and right of
this column.
A working example for headers and cells with colspan is
This looks like
which looks like
- Remark: Overlapping of column and row spanning, as in the following table fragment (the overlapping happens in the second cell in the second row), is invalid and causes incorrect results.
+------------------------------+---------------+ | header1+2 | header3 | +--------------+---------------+---------------+ | 1*1 | 1*2 | 1*3 | +--------------+---------------+---------------+ | 2*1 | 2*2+3 | +--------------+-------------------------------+
A working example with rowspan is
+--------------+---------------+---------------+ | 1*1 | 1+2*2 | 1*3 | +--------------+ +---------------+ | 2*1 | | 2*3 | +--------------+---------------+---------------+
- .ETB [hold]
- End of the table.
- This macro finishes a table. It causes one of the following actions.
- •
- If the argument is given, the table is held until it is freed by calling the macro , which in turn prints the table immediately, either at the current position or at the top of the next page if its height is larger than the remaining space on the page.
- •
- Otherwise, if the table is higher than the remaining space on the page, it is printed at the top of the next page.
- •
- If neither of the two above constraints hold, the table is printed immediately at the place of its definition.
predecessor:
successor:
arguments:
$@ Prevent the table from being printed until
it is freed by calling the macro . This argument is ignored for inner (nested)
tables.
- .t*free[n]
- Free the next held table or n held tables. Call this utility macro to print tables which are held by using the argument of the macro.
Arguments common to .TBL, .TR, .TD, and .TH
The arguments described in this section can be specified with the and macros, but they are eventually passed on to the table cells. If omitted, the defaults take place, which the user can change by setting the corresponding default registers or strings, as documented below. Setting an argument with the macro has the same effect as setting it for all rows in the table. Setting an argument with a macro has the same effect as setting it for all the or macro in this row.- $@ The background color of the table cells. This includes
the area specified with the argument. The argument (no value) suppresses a
background color; this makes the background transparent.
- The thickness of the separator lines is the half of the border thickness, but at least 0.1 inches. The distance between the double lines is equal to the line thickness.
-
Remark: Together with for proper formatting the
value of must be at least .05 inches for single separator lines and
.15 inches for double separator lines.
HDTBL CUSTOMIZATION
Before creating the first table, you should configure default values to minimize the markup needed in each table. The following example sets up defaults suitable for typical papers:BUGS AND SUGGESTIONS
Please send your commments to the groff mailing list or directly to the author.AUTHORS
The hdtbl macro package was written by Joachim WalsdorffSEE ALSO
- groff(1)
- provides an overview of GNU roff and details how to invoke groff at the command line.
- groff(7)
- summarizes the roff language and GNU extensions to it.
- tbl(1)
- describes the traditional roff preprocessor for tables.
7 March 2023 | groff 1.22.4 |