.TH GROFF_HDTBL 7 "7 February 2022" "groff 1.22.4" .SH NAME groff_hdtbl \- Heidelberger table macros for GNU roff . . .\" Save and disable compatibility mode (for, e.g., Solaris 10/11). .do nr groff_hdtbl_C \n[.C] .cp 0 . . .\" ==================================================================== .\" Legal Terms .\" ==================================================================== .\" .\" Copyright (C) 2005-2018 Free Software Foundation, Inc. .\" .\" This file is part of groff, the GNU roff type-setting system. .\" .\" Permission is granted to copy, distribute and/or modify this .\" document under the terms of the GNU Free Documentation License, .\" Version 1.3 or any later version published by the Free Software .\" Foundation; with no Invariant Sections, with no Front-Cover Texts, .\" and with no Back-Cover Texts. .\" .\" A copy of the Free Documentation License is included as a file .\" called FDL in the main directory of the groff source package. . . .ig Some simple formatting macros. Note that we use '.ig' here and not a comment to make 'mandb' 2.4.1 (and probably more recent versions also) happy; otherwise the '.char' lines and the stuff which follows is included in the 'whatis' database. .. . . .char \[lB] \F[\n[.fam]]\f[R][ .char \[rB] \F[\n[.fam]]\f[R]] . .char \[or] \F[\n[.fam]]\f[R]\||\| .char \[ell] \F[\n[.fam]]\f[R].\|.\|. . .char \[oq] \F[\n[.fam]]\f[R]\[oq] .char \[cq] \F[\n[.fam]]\f[R]\[cq] . . .ie F CR \{\ . . \" We have to solve the following problem. In this code . \" . \" foo . \" .CR bar . \" foo . \" . \" the space immediately after 'bar' should not be taken from the 'C' . \" family. At the same time, this . \" . \" foo . \" .CR bar\c . \" foo . \" . \" should work also. To fulfill both constraints we emit the . \" family changing commands both as escapes and macro calls. . . de make-C-macro . de C\\$1 . ds old-fam \\\\n[.fam] . fam C . \\$2 \&\\\\$*\F[]\F[\\\\*[old-fam]] . fam \\.. . . . . make-C-macro R nop . make-C-macro B B . make-C-macro I I . . de make-C-macro . de C\\$1 . ds old-fam \\\\n[.fam] . fam C . \\$1 \\\\$@ \F[]\F[\\\\*[old-fam]] . fam \\.. . . . . make-C-macro BI . make-C-macro IB . make-C-macro RI . make-C-macro IR . make-C-macro BR . make-C-macro RB .\} .el \{\ . ftr CR R . ftr CI I . ftr CB B . ftr CBI BI . . de CR . nop \&\\$* . . . als CB B . als CI I . . als CBI BI . als CIB IB . als CRI RI . als CIR IR . als CBR BR . als CRB RB .\} . . . .de XB . B "\\$1" . shift . CR "\\$1\c" . shift . while \\n[.$] \{\ . nop , . CR "\\$1\c" . shift . \} . br .. . . .de XAA . TQ . CRI \\$@ .. . . .de XDEF . br . B Default: . if !\\n[.$] \ . return . CRI "\\$1" "\\$2" .. . . .de XDEFR . br . B Default: . CR "\[oq]\\$1\[cq]" . nop (register . CR "\[oq]\\$2\[cq]\c" . nop ). .. . . .de XDEFS . br . B Default: . CR "\[oq]\\$1\[cq]" . nop (string . CR "\[oq]\\$2\[cq]\c" . nop ). .. . .\" ==================================================================== .SH DESCRIPTION .\" ==================================================================== . The .B hdtbl macros consist of four base and three optional macros, controlled by about twenty arguments. . The syntax is simple and similar to the .B 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 .B hdtbl is that the tables are constructed without calling a preprocessor; this means that .BR groff 's full macro capabilities are available. . On the other hand, table processing with .B hdtbl is much slower than using the .BR tbl (1) preprocessor. . A further advantage is that the HTML-like syntax of .B hdtbl will be easily converted to HTML; this is not implemented yet. . . .\" ==================================================================== .SH USAGE .\" ==================================================================== . In this and the next section, we present examples to help users understand the basic workflow of .BR hdtbl . . First of all, you must load the .I hdtbl.tmac file. . As with nearly all other groff macro packages, there are two possibilities to do so: . Either add the line . .PP .nf .nh .RS .CR .mso hdtbl.tmac .fi .hy .RE . .PP to your .I roff file before using any macros of the .B hdtbl package, or add the option . .PP .nf .nh .RS .CR \-m hdtbl .fi .hy .RE . .PP to the command line of groff (before the document file which contains .B hdtbl macros). . Then you can include on or more tables in your document, where each one must be started and ended with the .CR .TBL and .CR .ETB macros, respectively. . . .PP In this man page, we approximate the result of each example in the .I tty format to be as generic as possible since .B hdtbl currently only supports the PS and PDF output devices. . . .PP 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. . .PP .RS .nf .nh .CR .TBL .CR .TR .CR .TD .CI contents of the table cell .CR .ETB .fi .hy .RE . . .PP A .I tty representation is . .PP .nf .nh .ft CR .RS +------------------------------------------------------+ | contents-of-the-table-cell | +------------------------------------------------------+ .RE .ft .hy .fi . . .PP Equivalent to the above is the following notation. . .PP .RS .nh .nf .CRI ".TBL .TR .TD \[dq]" "contents of the table cell" "\[dq] .ETB" .fi .hy .RE . . .PP 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. . . .PP Using .CIR \[oq]row-number * column-number\[cq] as the data for the table cells, a table with two rows and two columns can be written as . . .PP .RS .nf .nh .CR ".TBL cols=2" .CR ". TR .TD 1*1 .TD 1*2" .CR ". TR .TD 2*1 .TD 2*2" .CR ".ETB" .fi .hy .RE . . .PP A .I tty representation is . . .PP .nf .nh .ft CR .RS +--------------------------+---------------------------+ | 1*1 | 1*2 | +--------------------------+---------------------------+ | 2*1 | 2*2 | +--------------------------+---------------------------+ .RE .ft .hy .fi . . .PP Here we see a difference from HTML tables: The number of columns must be explicitly specified using the .CRI \[oq]cols= m\[cq] argument (or indirectly via the .CR \[oq]width\[cq] argument, see below). . . .PP 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 .CR .TD and .CR .TH\c , controlling column and row spanning. . Note, however, that this table . .PP .RS .nf .nh .CR ".TBL" .CR ". TR" .CR ". TD" .CR ". nop 1*1 1*2" .CR ". TR" .CR ". TD" .CR ". TBL cols=2 border=" .CR ". TR" .CR ". TD" .CR ". nop 2*1" .CR ". TD" .CR ". nop 2*2" .CR ". ETB" .CR ".ETB" .fi .hy .RE . .PP and this table . .PP .RS .nf .nh .CR ".TBL cols=2" .CR ". TR" .CR ". TD colspan=2" .CR ". nop 1*1 1*2" .CR ". TR" .CR ". TD" .CR ". nop 2*1" .CR ". TD" .CR ". nop 2*2" .CR ".ETB" .fi .hy .RE . .PP are similar but not identical (the use of .CR .nop is purely cosmetic to get proper indentation). . . .PP The first table looks like . .PP .nf .nh .ft CR .RS +------------------------------------------------------+ | 1*1 1*2 | +------------------------------------------------------+ | | | 2*1 2*2 | | | +------------------------------------------------------+ .RE .ft .hy .fi . .PP and the second one like . .PP .nf .nh .ft CR .RS +------------------------------------------------------+ | 1*1 1*2 | +---------------------------+--------------------------+ | 2*1 | 2*2 | +---------------------------+--------------------------+ .RE .ft .hy .fi . .PP Here the latter table in a more compact form. . .PP .RS .nf .nh .CR ".TBL cols=2 .TR \[dq].TD colspan=2\[dq] 1*1 1*2" .CR ". TR .TD 2*1 .TD 2*2 .ETB" .fi .hy .RE . . .PP 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. . . .\" ==================================================================== .SH 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 .B hdtbl macros are given, together with the possible arguments. . .PP Macro arguments are separated by blanks. . The order of arguments is arbitrary; they are of the form . .PP .RS .CRI key= value .RE . .PP or . .PP .RS .CRI key=\[aq] "value1 \[lB]value2 \[lB]\[ell]\[rB]\[rB]" \[aq] .RE . .PP with the only exception of the optional argument of the macro .CR .ETB\c , which is the string .CR \[oq]hold\[cq]\c \&. . Another possible form is . .PP .RS .CRI \[dq]key= "value1 \[lB]value2 \[lB]\[ell]\[rB]\[rB]" \[dq] .RE . . .PP However, this is limited to the case where the macro is the first one in the line and not already enclosed in double quotes. . . .PP Argument values specified below as\~\c .CI c are colors predefined by .B groff or colors defined by the user with the .CR .defcolor request. . Argument values\~\c .CI d are decimal numbers with or without decimal point. . Argument values\~\c .CI m are natural numbers. . Argument values\~\c .CI n are numerical values with the usual .B groff scaling indicators. . Some of the arguments are specific to one or two macros, but most of them can be specified with .CR .TBL\c , .CR .TR\c , .CR .TD\c , and .CR .TH\ \&. . These common arguments are explained in the next subsection. . . .PP Most of the argument default values can be changed by the user by setting corresponding default registers or strings, as listed below. . .\"================================================================== . .TP .CBI ".TBL " \[lB]args\[rB] Begin a new table. . .IP .RS .XB predecessor: .TD .TH .ETB "cell contents" .XB successor: .CPTN .TR .XB arguments: . .RS .XAA border= \[lB]n\[rB] Thickness of the surrounding box border. . .CR \%\[oq]border=\[cq] (no value) means neither a surrounding box border nor any horizontal or vertical separator lines between the table rows and cells. . .CR \%\[oq]border=0\[cq] suppresses the surrounding box border, but still allows separator lines between cells and rows. . .XDEFR border=.1n t*b . .XAA bc= c Border color. . .XDEFS bc=red4 t*bc . .XAA cols= m Number of table columns. . This argument is necessary if more than one column is in the table and no .CR \[oq]width\[cq] arguments are present. . .XDEFR cols=1 t*cols . .XAA cpd= n Cell padding, i.e., the extra space between the cell space border and the cell contents. . .XDEFR cpd=.5n t*cpd . .XAA csp= n Cell spacing, i.e., the extra space between the table border or vertical or horizontal lines between cells and the cellspace. . .XDEFR csp=.5n t*csp . .XAA tal=l\[or]c\[or]r Horizontal alignment of the table, if it is smaller than the line width. . .CR \[oq]tal=l\[cq]\c : left alignment. . .CR \[oq]tal=c\[cq]\c : centered alignment. . .CR \[oq]tal=r\[cq]\c : right alignment. . .XDEFR tal=l t*tal . .XAA "width=\[aq]" "w1 \[lB]w2 \[lB]\[ell]\[rB]\[rB]" \[aq] Widths of table cells. . .CI w1\c .RI , "" .CI w2\c .RI , "" \[ell] are either numbers of type\~\c .CI n or natural numbers with the pseudo-scaling indicator .CR \[oq]%\[cq]\c , with the meaning \[lq]percent of the actual line length (or column length for inner tables, respectively)\[rq]. . If there are less width values than table columns, the last width value is used for the remaining cells. . The argument . .RS .IP .CR width=\[aq]1.5i 10%\[aq] .RE . .IP for example indicates that the first column is 1.5\~inches wide; the remaining columns take 1/10 of the column length each. . .XDEF The table width equals the outer line length or column length; the columns have equal widths. . .XAA height= n Height of the table. . If the table with its contents is lower than\~\c .CI n\c .RI , "" the last row is stretched to this value. .RE .RE . .\"================================================================== . .TP .CBI ".CPTN " \[lB]args\[rB] Text of caption. . .IP The (optionally numbered) table caption. . .CR .CPTN is optional. . .IP .RS .XB predecessor: .TBL .XB successor: .TR .XB arguments: . .RS .XAA val=t\[or]b Vertical alignment of the table caption. . .CR \[oq]val=t\[cq]\c : The caption is placed above the table. . .CR \[oq]val=b\[cq]\c : The caption is placed below the table. . .XDEFS val=t t*cptn .RE .RE . .\"================================================================== . .TP .CBI ".TR " \[lB]args\[rB] Begin a new table row. . .IP .RS .XB predecessor: .TBL .CPTN .TD .TH .ETB "cell contents" .XB successor: .TD .TH .XB arguments: . .RS .XAA height= n The height of the row. . If a cell in the row is higher than\~\c .CI n\c .RI , "" this value is ignored; otherwise the row height is stretched to\~\c .CI n\c .RI . "" .RE .RE . .\"================================================================== . .TP .CBI ".TD " "\[lB]args \[lB]cell contents\[rB]\[rB]" Begin a table data cell. .TQ .CBI ".TH " "\[lB]args \[lB]cell contents\[rB]\[rB]" Begin a table header cell. . .IP Arguments and cell contents can be mixed. . The macro .CR .TH is not really necessary and differs from .CR .TD only in three default settings, similar to the .CR