groff_hdtbl(7)
πΈ Name πΈ
okay so bestie, this is the groff_hdtbl(7) page from the Miscellaneous Information Manual, and it is literally all about groff_hdtbl β Heidelberger table macros for GNU roff. π
β¨ Description β¨
The hdtbl macros are a whole little squad: four base macros and three optional macros, controlled by about twenty arguments. The syntax is simple and similar to the HTML table model, and it is 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 arranged input. π«Ά
An advantage of hdtbl is that the tables are constructed without calling a preprocessor; this means that groff(7)'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. (iykyk π)
π«Ά 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 line
.mso hdtbl.tmac
to your roff file before using any macros of the hdtbl package, or add the option
-m hdtbl
to the command line of groff (before the document file which contains hdtbl macros). Then you can include one or more tables in your document, where each one must be started and ended with the .TBL and .ETB macros, respectively. π
In this man page, we approximate the result of each example as terminal output to be as generic as possible since hdtbl currently only supports the ps and pdf output drivers.
The simplest well-formed table consists of just single calls to the four base table macros in the right order. Here we construct a table with only one cell.
.TBL
.TR
.TD
contents of the table cell
.ETB
A terminal representation is
+------------------------------------------------------+
| contents-of-the-table-cell |
+------------------------------------------------------+
Equivalent to the above is the following notation.
.TBL .TR .TD "contents of the table cell" .ETB
By default, the formatted table is inserted into the surrounding text at the place of its definition. If the vertical space isn't sufficient, it is placed at the top of the next page. Tables can also be stored for later insertion. π
Using βrow-number*column-numberβ as the data for the table cells, a table with two rows and two columns can be written as
.TBL cols=2
. TR .TD 1*1 .TD 1*2
. TR .TD 2*1 .TD 2*2
.ETB
A terminal representation is
+--------------------------+---------------------------+
| 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 width 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 .TD and .TH, controlling column and row spanning. Note, however, that this table
.TBL
. TR
. TD
. nop 1*1 1*2
. TR
. TD
. TBL cols=2 border=
. TR
. TD
. nop 2*1
. TD
. nop 2*2
. ETB
.ETB
and this table
.TBL cols=2
. TR
. TD colspan=2
. nop 1*1 1*2
. TR
. TD
. nop 2*1
. TD
. nop 2*2
.ETB
are similar but not identical (the use of .nop is purely cosmetic to get proper indentation). π
The first table looks like
+------------------------------------------------------+
| 1*1 1*2 |
+------------------------------------------------------+
| |
| 2*1 2*2 |
| |
+------------------------------------------------------+
and the second one like
+------------------------------------------------------+
| 1*1 1*2 |
+---------------------------+--------------------------+
| 2*1 | 2*2 |
+---------------------------+--------------------------+
Here is the latter table in a more compact form.
.TBL cols=2 .TR ".TD colspan=2" 1*1 1*2
. TR .TD 2*1 .TD 2*2 .ETB
β οΈ important vibe check: If a macro has one or more arguments (see below), and it is not starting a line, everything belonging to this macro including the macro itself must be enclosed in double quotes. no cap.
π 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 form
key=value
or
key='value1 [value2 [...]]'
with the only exception of the optional argument of the macro .ETB, which is the string βholdβ. 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 .defcolor 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 .TBL, .TR, .TD, and .TH. 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:
.TD,.TH,.ETB, cell contents - successor:
.CPTN,.TR - arguments:
border=[n]β Thickness of the surrounding box border.border=(no value) means neither a surrounding box border nor any horizontal or vertical separator lines between the table rows and cells.border=0suppresses the surrounding box border, but still allows separator lines between cells and rows. Default:border=.1n(registert*b).bc=cβ Border color. Default:bc=red4(stringt*bc).cols=mβ Number of table columns. This argument is necessary if more than one column is in the table and nowidtharguments are present. Default:cols=1(registert*cols).cpd=nβ Cell padding, i.e., the extra space between the cell space border and the cell contents. Default:cpd=.5n(registert*cpd).csp=nβ Cell spacing, i.e., the extra space between the table border or vertical or horizontal lines between cells and the cellspace. Default:csp=.5n(registert*csp).tal=l|c|rβ Horizontal alignment of the table, if it is smaller than the line width.tal=l: left alignment.tal=c: centered alignment.tal=r: right alignment. Default:tal=l(registert*tal).width='w1 [w2 [...]]'β 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 argumentwidth='1.5i 10%'for example indicates that the first column is 1.5 inches wide; the remaining columns take 1/10 of the column length each. Default: The table width equals the outer line length or column length; the columns have equal widths.height=nβ Height of the table. If the table with its contents is lower than n, the last row is stretched to this value.
.CPTN [args]
Text of caption.
The (optionally numbered) table caption. .CPTN is optional.
- predecessor:
.TBL - successor:
.TR - arguments:
val=t|bβ Vertical alignment of the table caption.val=t: The caption is placed above the table.val=b: The caption is placed below the table. Default:val=t(stringt*cptn).
.TR [args]
Begin a new table row.
- predecessor:
.TBL,.CPTN,.TD,.TH,.ETB, cell contents - successor:
.TD,.TH - arguments:
height=nβ 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 [cell contents]] β begin a table data cell π.TH[args [cell contents]] β begin a table header cell β¨
okay so bestie, arguments and cell contents can totally be mixed together, no cap β you don't have to pick one. and real talk: the .TH macro isn't actually necessary, it differs from .TD in exactly three default settings, kinda like the <TH> and <TD> HTML tags do: the contents of .TH get horizontally and vertically centered, and typeset in boldface. that's the whole tea. three little settings, that's it. π
predecessor: .TR, .TD, .TH, .ETB, cell contents successor: .TD, .TH, .TR, .ETB, cell contents
arguments:
colspan=mβ this cell's width is the sum of the widths of the m cells above and below this row π«Άrowspan=mβ this cell's height is the sum of the heights of the m cells left and right of this column πΈ
β οΈ remark, and i mean it: overlapping column and row spanning β like in the table fragment below, where the overlap happens in the second cell of the second row β is invalid and causes incorrect results. don't do it. it's giving chaos. π
.TR .TD 1*1 ".TD 1*2 rowspan=2" .TD 1*3
.TR ".TD 2*1 colspan=2" .TD 2*3
a working example for headers and cells with colspan is
.TBL cols=3
. TR ".TH colspan=2" header1+2 .TH header3
. TR .TD 1*1 .TD 1*2 .TD 1*3
. TR .TD 2*1 ".TD colspan=2" 2*2+3
.ETB
and this looks like
+------------------------------+---------------+
| header1+2 | header3 |
+--------------+---------------+---------------+
| 1*1 | 1*2 | 1*3 |
+--------------+---------------+---------------+
| 2*1 | 2*2+3 |
+--------------+-------------------------------+
a working example with rowspan is
.TBL cols=3
. TR
. TD 1*1
. TD rowspan=2 1+2*2
. TD 1*3
.
. TR
. TD 2*1
. TD 2*3
.ETB
which looks like
+--------------+---------------+---------------+
| 1*1 | 1+2*2 | 1*3 |
+--------------+ +---------------+
| 2*1 | | 2*3 |
+--------------+---------------+---------------+
.ETB[hold] β end of the table π¦
this macro finishes a table, and it causes one of the following actions:
- if the argument
holdis given, the table is held until it's freed by calling the macro.t*free, 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's printed at the top of the next page
- if neither of the two constraints above hold, the table is printed immediately at the place of its definition β¨
predecessor: .TD, .TH, .ETB, cell contents successor: .TBL, .TR, .TD, .TH, .ETB, cell contents
arguments:
holdβ prevent the table from being printed until it's freed by calling the macro.t*free. ngl 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 that are being held via theholdargument of the.ETBmacro.
π Arguments common to .TBL, .TR, .TD, and .TH π
so the arguments in this section can be specified with the .TBL and .TR macros, but they eventually get passed on down to the table cells. if you omit them, the defaults kick in β and the user can change those defaults by setting the corresponding default registers or strings, as documented below. setting an argument with the .TBL macro does the same thing as setting it for all rows in the table. setting an argument with a .TR macro does the same thing as setting it for all the .TH or .TD macros in that row. slay, inheritance. π
bgc=[c]β the background color of the table cells. this includes the area specified with thecspargument. the argumentbgc=(no value) suppresses a background color, which makes the background transparent. β¨ default:bgc=bisque(stringt*bgc).fgc=cβ the foreground color of the cell contents. π¨ default:fgc=red4(stringt*fgc).ff=nameβ the font family for the table. name is a groff font family identifier, such asAfor Avant Garde orHNfor Helvetica Narrow. default: the font family found before the table (stringt*ff).fst=styleβ the font style for the table. one ofR,B,I, orBIfor roman, bold, italic, or bold italic, respectively. as with roff's.ftrequest, thefstargument can specify the font family and font style together, for examplefst=HNBIinstead offf=HNandfst=BI. π default: the font style in use right before the table (stringt*fst).fsz='d1 [d2]'β a decimal or fractional factor d1, by which the point size for the table is changed, and d2, by which the vertical line spacing is changed. if d2 is omitted, the value d1 is taken for both. π default:fsz='1.0 1.0'(stringt*fsz).hal=l|c|b|rβ horizontal alignment of the cell contents in the table.hal=l: left alignment.hal=c: centered alignment.hal=b: both (left and right) alignment.hal=r: right alignment. default:hal=b(stringt*hal).val=t|m|bβ vertical alignment of the cell contents in the table, for cells lower than the current row.val=t: alignment below the top of the cell.val=m: alignment in the middle of the cell.val=b: alignment above the cell bottom. default:val=t(stringt*val).hl=[s|d]β horizontal line between the rows. if specified with.TDor.TH, this is a separator line to the cell below.hl=(no value): no separator line.hl=s: a single separator line between the rows.hl=d: a double separator line. π
the thickness of the separator lines is 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 withborder=0, for proper formatting the value ofcspmust be at least .05 inches for single separator lines and .15 inches for double separator lines. don't skip this, it's important fr fr.
default: hl=s (string t*hl).
vl=[s|d]β vertical separator line between the cells. if specified with.TDor.TH, this is a separator line to the cell on the right.vl=s: a single separator line between the cells.vl=d: a double separator line.vl=(no value): no vertical cell separator lines. for more info, see the documentation of thehlargument above. π default:vl=s(stringt*vl).
π hdtbl customization π
before you create the very 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:
.ds t*bgc white\" background color
.ds t*fgc black\" foreground color
.ds t*bc black\" border color
.nr t*cpd 0.1n\" cell padding
the file /usr/share/doc/groff-1.24.2/examples/hdtbl/common.roff provides another example setup in the "minimal Page setup" section. π¦
a table that doesn't fit on a partially filled page gets printed automatically at the top of the next page if you append the little utility macro t*hm to the page header macro of your document's main macro package. for example, say
.am pg@top
. t*hm
..
if you use the ms macro package. π
the macro t*EM checks for held or kept tables, and for missing ETB macros (i.e. table not closed π). you can call this macro by appending it to the end-of-input macro of the main, or "full-service", macro package your document uses. for example, try
.am pg@end-text
. t*EM
..
if you use the ms package.
π Bugs and suggestions π
please send your comments to the groff mailing list or directly to the author. be nice about it, they're doing their best π«Ά
π Authors π
the hdtbl macro package was written by Joachim Walsdorff. legend behavior, honestly. π
π¦ See also π¦
groff(1)β provides an overview of GNU roff and details how to invokegroffat the command line.groff(7)β summarizes the roff language and GNU extensions to it.tbl(1)β describes the traditional roff preprocessor for tables.
okay that's the whole page bestie, you're officially an hdtbl girly now π
β¨ this one shipped as groff 1.24.2, dated 2026-10-01, and it lives in section 7 as groff_hdtbl β go forth and make tables that serve. ππΈπ«Ά
π¦ where this page comes from
- alpine 3.24: groff-doc 1.24.2-r0 Β· GPL-3.0-or-later
- Copyright 2005-2020 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms