{
    "mode": "man",
    "parameter": "groff_hdtbl",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/groff_hdtbl/7/json",
    "generated": "2026-10-07T03:23:47Z",
    "sections": {
        "Name": {
            "content": "groffhdtbl - Heidelberger table macros for GNU roff\n",
            "subsections": []
        },
        "Description": {
            "content": "The  hdtbl  macros consist of four base and three optional macros, controlled by about twenty\narguments.  The syntax is simple and similar to the HTML table model and nearly as  flexible:\nyou  can write sequences of tokens (macro calls with their arguments and content data), sepa‐\nrated by blanks and beginning with a macro call, into  the  same  line  to  get  compact  and\ncleanly  arrranged  input.   An advantage of hdtbl is that the tables are constructed without\ncalling a preprocessor; this means that groff(7)'s full macro capabilities are available.  On\nthe other hand, table processing with hdtbl is much slower than using the  tbl(1)  preproces‐\nsor.   A  further advantage is that the HTML-like syntax of hdtbl will be easily converted to\nHTML; this is not implemented yet.\n",
            "subsections": []
        },
        "Usage": {
            "content": "In this and the next section, we present examples to help users understand the basic workflow\nof hdtbl.  First of all, you must load the hdtbl.tmac file.  As with nearly all  other  groff\nmacro packages, there are two possibilities to do so: Either add the line\n\n.mso hdtbl.tmac\n\nto your roff file before using any macros of the hdtbl package, or add the option\n\n-m hdtbl\n\nto  the  command  line of groff (before the document file which contains hdtbl macros).  Then\nyou can include on or more tables in your document, where each one must be started and  ended\nwith the .TBL and .ETB macros, respectively.\n\nIn  this  man  page,  we  approximate  the result of each example as terminal output to be as\ngeneric as possible since hdtbl currently only supports the ps and pdf output drivers.\n\nThe simplest well-formed table consists of just single calls to the four base table macros in\nthe right order.  Here we construct a table with only one cell.\n\n.TBL\n.TR\n.TD\ncontents of the table cell\n.ETB\n\nA terminal representation is\n\n+------------------------------------------------------+\n| contents-of-the-table-cell                           |\n+------------------------------------------------------+\n\nEquivalent to the above is the following notation.\n\n.TBL .TR .TD \"contents of the table cell\" .ETB\n\nBy default, the formatted table is inserted into the surrounding text at the place of its de‐\nfinition.  If the vertical space isn't sufficient, it is placed at the top of the next  page.\nTables can also be stored for later insertion.\n\nUsing  ‘row-number*column-number’  as the data for the table cells, a table with two rows and\ntwo columns can be written as\n\n.TBL cols=2\n.  TR .TD 1*1 .TD 1*2\n.  TR .TD 2*1 .TD 2*2\n.ETB\n\nA terminal representation is\n\n+--------------------------+---------------------------+\n| 1*1                      | 1*2                       |\n+--------------------------+---------------------------+\n| 2*1                      | 2*2                       |\n+--------------------------+---------------------------+\n\nHere we see a difference from HTML tables: The number of columns must be explicitly specified\nusing the ‘cols=m’ argument (or indirectly via the ‘width’ argument, see below).\n\nThe contents of a table cell is arbitrary; for example, it can be another table, without  re‐\nstriction to the nesting depth.  A given table layout can be either constructed with suitably\nnested  tables  or with proper arguments to .TD and .TH, controlling column and row spanning.\nNote, however, that this table\n\n.TBL\n.  TR\n.    TD\n.      nop 1*1 1*2\n.  TR\n.    TD\n.      TBL cols=2 border=\n.        TR\n.          TD\n.            nop 2*1\n.          TD\n.            nop 2*2\n.      ETB\n.ETB\n\nand this table\n\n.TBL cols=2\n.  TR\n.    TD colspan=2\n.      nop 1*1 1*2\n.  TR\n.    TD\n.      nop 2*1\n.    TD\n.      nop 2*2\n.ETB\n\nare similar but not identical (the use of .nop is purely cosmetic to get proper indentation).\n\nThe first table looks like\n\n+------------------------------------------------------+\n| 1*1 1*2                                              |\n+------------------------------------------------------+\n|                                                      |\n| 2*1                         2*2                      |\n|                                                      |\n+------------------------------------------------------+\n\nand the second one like\n\n+------------------------------------------------------+\n| 1*1 1*2                                              |\n+---------------------------+--------------------------+\n| 2*1                       | 2*2                      |\n+---------------------------+--------------------------+\n\nHere is the latter table in a more compact form.\n\n.TBL cols=2 .TR \".TD colspan=2\" 1*1 1*2\n.            TR .TD 2*1 .TD 2*2 .ETB\n\nIf a macro has one or more arguments (see below), and it is not starting a  line,  everything\nbelonging to this macro including the macro itself must be enclosed in double quotes.\n",
            "subsections": []
        },
        "Macros and arguments": {
            "content": "The  order  of  macro  calls and other tokens follows the HTML model.  In the following list,\nvalid predecessors and successors of all hdtbl macros are given, together with  the  possible\narguments.\n\nMacro  arguments  are  separated by blanks.  The order of arguments is arbitrary; they are of\nthe form\n\nkey=value\n\nor\n\nkey='value1 [value2 [...]]'\n\nwith the only exception of the optional argument of the  macro  .ETB,  which  is  the  string\n‘hold’.  Another possible form is\n\n\"key=value1 [value2 [...]]\"\n\nHowever, this is limited to the case where the macro is the first one in the line and not al‐\nready enclosed in double quotes.\n\nArgument  values specified below as c are colors predefined by groff or colors defined by the\nuser with the .defcolor request.  Argument values d are decimal numbers with or without deci‐\nmal point.  Argument values m are natural numbers.  Argument values n  are  numerical  values\nwith  the  usual  groff scaling indicators.  Some of the arguments are specific to one or two\nmacros, but most of them can be specified with .TBL, .TR, .TD, and .TH.  These  common  argu‐\nments are explained in the next subsection.\n\nMost  of  the argument default values can be changed by the user by setting corresponding de‐\nfault registers or strings, as listed below.\n\n.TBL [args]\nBegin a new table.\n\npredecessor: .TD, .TH, .ETB, cell contents\nsuccessor: .CPTN, .TR\narguments:\nborder=[n]\nThickness of the surrounding box border.   ‘border=’  (no  value)  means\nneither  a surrounding box border nor any horizontal or vertical separa‐\ntor lines between the table rows and cells.  ‘border=0’  suppresses  the\nsurrounding  box  border, but still allows separator lines between cells\nand rows.\nDefault: ‘border=.1n’ (register ‘t*b’).\nbc=c   Border color.\nDefault: ‘bc=red4’ (string ‘t*bc’).\ncols=m Number of table columns.  This argument is necessary if  more  than  one\ncolumn is in the table and no ‘width’ arguments are present.\nDefault: ‘cols=1’ (register ‘t*cols’).\ncpd=n  Cell  padding,  i.e.,  the extra space between the cell space border and\nthe cell contents.\nDefault: ‘cpd=.5n’ (register ‘t*cpd’).\ncsp=n  Cell spacing, i.e., the extra space between the table border or vertical\nor horizontal lines between cells and the cellspace.\nDefault: ‘csp=.5n’ (register ‘t*csp’).\ntal=l|c|r\nHorizontal alignment of the table, if it is smaller than the line width.\n‘tal=l’: left alignment.  ‘tal=c’: centered alignment.   ‘tal=r’:  right\nalignment.\nDefault: ‘tal=l’ (register ‘t*tal’).\nwidth='w1 [w2 [...]]'\nWidths of table cells.  w1, w2, ... are either numbers of type n or nat‐\nural  numbers  with  the  pseudo-scaling indicator ‘%’, with the meaning\n“percent of the actual line length (or column length for  inner  tables,\nrespectively)”.   If there are less width values than table columns, the\nlast width value is used for the remaining cells.  The argument\n\nwidth='1.5i 10%'\n\nfor example indicates that the first column is 1.5 inches wide; the  re‐\nmaining columns take 1/10 of the column length each.\nDefault:  The table width equals the outer line length or column length;\nthe columns have equal widths.\nheight=n\nHeight of the table.  If the table with its contents is  lower  than  n,\nthe last row is stretched to this value.\n\n.CPTN [args]\nText of caption.\n\nThe (optionally numbered) table caption.  .CPTN is optional.\n\npredecessor: .TBL\nsuccessor: .TR\narguments:\nval=t|b\nVertical alignment of the table caption.  ‘val=t’: The caption is placed\nabove the table.  ‘val=b’: The caption is placed below the table.\nDefault: ‘val=t’ (string ‘t*cptn’).\n\n.TR [args]\nBegin a new table row.\n\npredecessor: .TBL, .CPTN, .TD, .TH, .ETB, cell contents\nsuccessor: .TD, .TH\narguments:\nheight=n\nThe  height  of  the  row.   If a cell in the row is higher than n, this\nvalue is ignored; otherwise the row height is stretched to n.\n\n.TD [args [cell contents]]\nBegin a table data cell.\n.TH [args [cell contents]]\nBegin a table header cell.\n\nArguments and cell contents can be mixed.  The macro .TH is not really  necessary  and\ndiffers  from  .TD  only  in three default settings, similar to the <TH> and <TD> HTML\ntags: The contents of .TH is horizontally and vertically centered and typeset in bold‐\nface.\n\npredecessor: .TR, .TD, .TH, .ETB, cell contents\nsuccessor: .TD, .TH, .TR, .ETB, cell contents\narguments:\ncolspan=m\nThe width of this cell is the sum of the widths of the m cells above and\nbelow this row.\nrowspan=m\nThe height of this cell is the sum of the heights of the  m  cells  left\nand right of this column.\n\nRemark:  Overlapping of column and row spanning, as in the following ta‐\nble fragment (the overlapping happens in the second cell in  the  second\nrow), is invalid and causes incorrect results.\n\n.TR .TD 1*1 \".TD 1*2 rowspan=2\" .TD 1*3\n.TR \".TD 2*1 colspan=2\"         .TD 2*3\n\nA working example for headers and cells with colspan is\n\n.TBL cols=3\n.  TR \".TH colspan=2\" header1+2 .TH header3\n.  TR .TD 1*1 .TD 1*2 .TD 1*3\n.  TR .TD 2*1 \".TD colspan=2\" 2*2+3\n.ETB\n\nThis looks like\n\n+------------------------------+---------------+\n|          header1+2           |    header3    |\n+--------------+---------------+---------------+\n| 1*1          | 1*2           | 1*3           |\n+--------------+---------------+---------------+\n| 2*1          | 2*2+3                         |\n+--------------+-------------------------------+\n\nA working example with rowspan is\n\n.TBL cols=3\n.  TR\n.  TD 1*1\n.  TD rowspan=2 1+2*2\n.  TD 1*3\n.\n.  TR\n.  TD 2*1\n.  TD 2*3\n.ETB\n\nwhich looks like\n\n+--------------+---------------+---------------+\n| 1*1          | 1+2*2         | 1*3           |\n+--------------+               +---------------+\n| 2*1          |               | 2*3           |\n+--------------+---------------+---------------+\n\n.ETB [hold]\nEnd of the table.\n\nThis macro finishes a table.  It causes one of the following actions.\n\n•  If the argument ‘hold’ is given, the table is held until it is freed by calling the\nmacro  .t*free,  which  in turn prints the table immediately, either at the current\nposition or at the top of the next page if its height is larger than the  remaining\nspace on the page.\n\n•  Otherwise,  if  the  table  is  higher  than the remaining space on the page, it is\nprinted at the top of the next page.\n\n•  If neither of the two above constraints hold, the table is printed  immediately  at\nthe place of its definition.\n\npredecessor: .TD, .TH, .ETB, cell contents\nsuccessor: .TBL, .TR, .TD, .TH, .ETB, cell contents\narguments:\nhold   Prevent  the  table  from being printed until it is freed by calling the\nmacro .t*free.  This argument is ignored for inner (nested) tables.\n\n.t*free [n]\nFree the next held table or n held tables.  Call this utility macro  to  print  tables\nwhich are held by using the ‘hold’ argument of the .ETB macro.\n",
            "subsections": [
                {
                    "name": "Arguments common to .TBL, .TR, .TD, and .TH",
                    "content": "The  arguments  described  in this section can be specified with the .TBL and .TR macros, but\nthey are eventually passed on to the table cells.  If omitted, the defaults take place, which\nthe user can change by setting the corresponding default registers or strings, as  documented\nbelow.   Setting  an  argument  with the .TBL macro has the same effect as setting it for all\nrows in the table.  Setting an argument with a .TR macro has the same effect  as  setting  it\nfor all the .TH or .TD macro in this row.\n\nbgc=[c]\nThe  background  color  of the table cells.  This includes the area specified with the\n‘csp’ argument.  The argument ‘bgc=’ (no value) suppresses a  background  color;  this\nmakes the background transparent.\nDefault: ‘bgc=bisque’ (string ‘t*bgc’).\nfgc=c  The foreground color of the cell contents.\nDefault: ‘fgc=red4’ (string ‘t*fgc’).\nff=name\nThe  font family for the table.  name is a groff font family identifier, such as A for\nAvant Garde or HN for Helvetica Narrow.\nDefault: The font family found before the table (string ‘t*ff’).\nfst=style\nThe font style for the table.  One of R, B, I, or BI for roman, bold, italic, or  bold\nitalic,  respectively.   As with roff's .ft request, the ‘fst’ argument can be used to\nspecify the font family and font style together, for  example  ‘fst=HNBI’  instead  of\n‘ff=HN’ and ‘fst=BI’.\nDefault: The font style in use right before the table (string ‘t*fst’).\nfsz='d1 [d2]'\nA  decimal  or fractional factor d1, by which the point size for the table is changed,\nand d2, by which the vertical line spacing is changed.  If d2 is omitted, value d1  is\ntaken for both.\nDefault: ‘fsz='1.0 1.0'’ (string ‘t*fsz’).\nhal=l|c|b|r\nHorizontal  alignment  of  the  cell  contents in the table.  ‘hal=l’: left alignment.\n‘hal=c’: centered alignment.  ‘hal=b’: both  (left  and  right)  alignment.   ‘hal=r’:\nright alignment.\nDefault: ‘hal=b’ (string ‘t*hal’).\nval=t|m|b\nVertical  alignment of the cell contents in the table for cells lower than the current\nrow.  ‘val=t’: alignment below the top of the cell.  ‘val=m’: alignment in the  middle\nof the cell.  ‘val=b’: alignment above the cell bottom.\nDefault: ‘val=t’ (string ‘t*val’).\nhl=[s|d]\nHorizontal  line  between  the rows.  If specified with .TD or .TH this is a separator\nline to the cell below.  ‘hl=’ (no value): no separator line.  ‘hl=s’: a single  sepa‐\nrator line between the rows.  ‘hl=d’: a double separator line.\n\nThe thickness of the separator lines is the half of the border thickness, but at least\n0.1 inches.  The distance between the double lines is equal to the line thickness.\n\nRemark:  Together  with ‘border=0’ for proper formatting the value of ‘csp’ must be at\nleast .05 inches for single separator lines and .15 inches for double separator lines.\nDefault: ‘hl=s’ (string ‘t*hl’).\nvl=[s|d]\nVertical separator line between the cells.  If specified with .TD or  .TH  this  is  a\nseparator  line to the cell on the right.  ‘vl=s’: a single separator line between the\ncells.  ‘vl=d’: a double separator line.  ‘vl=’ (no value): no vertical cell separator\nlines.  For more information see the documentation of the ‘hl’ argument above.\nDefault: ‘vl=s’ (string ‘t*vl’).\n\nhdtbl customization\nBefore creating the first table, you should configure default values to minimize  the  markup\nneeded in each table.  The following example sets up defaults suitable for typical papers:\n\n.ds t*bgc white\\\" background color\n.ds t*fgc black\\\" foreground color\n.ds t*bc black\\\"  border color\n.nr t*cpd 0.1n\\\"  cell padding\n\nThe  file /usr/share/doc/groff-base/examples/hdtbl/common.roff provides another example setup\nin the “minimal Page setup” section.\n\nA table which does not fit on a partially filled page is printed automatically on the top  of\nthe  next  page  if you append the little utility macro t*hm to the page header macro of your\ndocument's main macro package.  For example, say\n\n.am pg@top\n.  t*hm\n..\n\nif you use the ms macro package.\n\nThe macro t*EM checks for held or kept tables, and for missing ETB macros (table not closed).\nYou can call this macro by appending it the to end-of-input macro of the main, or  “full-ser‐\nvice”, macro package your document uses.  For example, try\n.am pg@end-text\n.  t*EM\n..\nif you use the ms package.\n"
                }
            ]
        },
        "Bugs and suggestions": {
            "content": "Please send your comments to the groff mailing list or directly to the author.\n",
            "subsections": []
        },
        "Authors": {
            "content": "The hdtbl macro package was written by Joachim Walsdorff.\n\nSee also\ngroff(1)\nprovides an overview of GNU roff and details how to invoke groff at the command line.\n\ngroff(7)\nsummarizes the roff language and GNU extensions to it.\n\ntbl(1) describes the traditional roff preprocessor for tables.\n\ngroff 1.23.0                                31 March 2024                             groffhdtbl(7)",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}