Sync-to-go: contrib/hdtbl..
[s-roff.git] / contrib / hdtbl / hdtbl.7.in
blob11ecafdce01b4e0a1e5701d1e1db97cc62c9f59d
1 .ig
2 @ hdtbl.7.in
4 Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
6 Copyright (C) 2005, 2006, 2008, 2009
7   Free Software Foundation, Inc.
9 Written by Joachim Walsdorff <Joachim.Walsdorff@urz.uni-heidelberg.de>
11 Permission is granted to copy, distribute and/or modify this document
12 under the terms of the GNU Free Documentation License, Version 1.1 or
13 any later version published by the Free Software Foundation; with the
14 Invariant Sections being this .ig-section and AUTHORS, with no
15 Front-Cover Texts, and with no Back-Cover Texts.
17 You should have received a copy of the Free Documentation License
18 as part of the file COPYING; also located in the main directory of the
19 source package of this program.
22 .TH @U_ROFF@_HDTBL @MAN7EXT@ "@MDATE@" "@T_ROFF@ v@VERSION@"
25 .SH NAME
26 @L_ROFF@_hdtbl \- @L_ROFF@ `hdtbl' macros for generation of tables
28 .do nr __compat \n[.C]
29 .cp 0
31 .ig
32   Some simple formatting macros.  Note that we use `.ig' here and not a
33   comment to make `mandb' 2.4.1 (and probably more recent versions also)
34   happy; otherwise the `.char' lines and the stuff which follows is included
35   in the `whatis' database.
39 .char \[lB] \F[\n[.fam]]\f[R][
40 .char \[rB] \F[\n[.fam]]\f[R]]
42 .char \[or] \F[\n[.fam]]\f[R]\||\|
43 .char \[ell] \F[\n[.fam]]\f[R].\|.\|.
45 .char \[oq] \F[\n[.fam]]\f[R]\[oq]
46 .char \[cq] \F[\n[.fam]]\f[R]\[cq]
49 .ie F CR \{\
51 .  \" We have to solve the following problem.  In this code
52 .  \"
53 .  \"   foo
54 .  \"   .CR bar
55 .  \"   foo
56 .  \"
57 .  \" the space immediately after `bar' should not be taken from the `C'
58 .  \" family.  At the same time, this
59 .  \"
60 .  \"   foo
61 .  \"   .CR bar\c
62 .  \"   foo
63 .  \"
64 .  \" should work also.  To fulfill both constraints we emit the
65 .  \" family changing commands both as escapes and macro calls.
67 .  de make-C-macro
68 .    de C\\$1
69 .      ds old-fam \\\\n[.fam]
70 .      fam C
71 .      \\$2 \&\\\\$*\F[]\F[\\\\*[old-fam]]
72 .      fam
73 \\..
74 .  .
76 .  make-C-macro R nop
77 .  make-C-macro B B
78 .  make-C-macro I I
80 .  de make-C-macro
81 .    de C\\$1
82 .      ds old-fam \\\\n[.fam]
83 .      fam C
84 .      \\$1 \\\\$@ \F[]\F[\\\\*[old-fam]]
85 .      fam
86 \\..
87 .  .
89 .  make-C-macro BI
90 .  make-C-macro IB
91 .  make-C-macro RI
92 .  make-C-macro IR
93 .  make-C-macro BR
94 .  make-C-macro RB
95 .\}
96 .el \{\
97 .  ftr CR R
98 .  ftr CI I
99 .  ftr CB B
100 .  ftr CBI BI
102 .  de CR
103 .    nop \&\\$*
104 .  .
105 .  als CB B
106 .  als CI I
108 .  als CBI BI
109 .  als CIB IB
110 .  als CRI RI
111 .  als CIR IR
112 .  als CBR BR
113 .  als CRB RB
117 .de TQ
118 .  br
119 .  ns
120 .  TP
124 .de XB
125 .  B "\\$1"
126 .  shift
127 .  CR "\\$1\c"
128 .  shift
129 .  while \\n[.$] \{\
130 .    nop ,
131 .    CR "\\$1\c"
132 .    shift
133 .  \}
134 .  br
138 .de XAA
139 .  TQ
140 .  CRI \\$@
144 .de XDEF
145 .  br
146 .  B Default:
147 .  if !\\n[.$] \
148 .    return
149 .  CRI "\\$1" "\\$2"
153 .de XDEFR
154 .  br
155 .  B Default:
156 .  CR "\[oq]\\$1\[cq]"
157 .  nop (register
158 .  CR "\[oq]\\$2\[cq]\c"
159 .  nop ).
163 .de XDEFS
164 .  br
165 .  B Default:
166 .  CR "\[oq]\\$1\[cq]"
167 .  nop (string
168 .  CR "\[oq]\\$2\[cq]\c"
169 .  nop ).
174 .SH DESCRIPTION
177 .B hdtbl
178 macros consist of four base and three optional macros, controlled by about
179 twenty arguments.
181 The syntax is simple and similar to the
182 .B HTML
183 table model and nearly as flexible: You can write sequences of tokens (macro
184 calls with their arguments and content data), separated by blanks and
185 beginning with a macro call, into the same line to get compact and cleanly
186 arrranged input.
188 An advantage of
189 .B hdtbl
190 is that the tables are constructed without calling a preprocessor; this
191 means that
192 .BR @L_ROFF@ 's
193 full macro capabilities are available.
195 On the other hand, table processing with
196 .B hdtbl
197 is much slower than using the
198 .BR tbl (@MAN1EXT)
199 preprocessor.
201 A further advantage is that the HTML-like syntax of
202 .B hdtbl
203 will be easily converted to HTML; this is not implemented yet.
206 .SH USAGE
208 The simplest well-formed table consists of just single calls to the four
209 base table macros in the right order.
211 Here we construct a table with only one cell.
216 .CR .TBL
217 .CR .TR
218 .CR .TD
219 .CI contents of the table cell
220 .CR .ETB
225 Equivalent to the above is the following notation.
229 .CRI ".TBL .TR .TD " "contents of the table cell" " .ETB"
233 By default, the formatted table is inserted into the surrounding text at the
234 place of its definition.
236 If the vertical space isn't sufficient, it is placed at the top of the next
237 page.
239 Tables can also be stored for later insertion.
242 Using
243 .CIR \[oq]row-number * column-number\[cq]
244 as the data for the table cells, a table with two rows and two columns can
245 be written as
250 .CR ".TBL cols=2"
251 .CR ".  TR .TD 1*1 .TD 1*2"
252 .CR ".  TR .TD 2*1 .TD 2*2"
253 .CR ".ETB"
258 Here we see a difference to HTML tables: The number of columns must be
259 explicitly specified using the
260 .CRI \[oq]cols= m\[cq]
261 argument (or indirectly via the
262 .CR \[oq]width\[cq]
263 argument, see below).
266 The contents of a table cell is arbitrary; for example, it can be another
267 table, without restriction to the nesting depth.
269 A given table layout can be either constructed with suitably nested tables
270 or with proper arguments to
271 .CR .TD
273 .CR .TH\c
274 , controlling column and row spanning.
276 Note, however, that this table
281 .CR ".TBL"
282 .CR ".  TR"
283 .CR ".    TD"
284 .CR ".      nop 1*1 1*2"
285 .CR ".  TR"
286 .CR ".    TD"
287 .CR ".      TBL cols=2 border="
288 .CR ".        TR"
289 .CR ".          TD"
290 .CR ".            nop 2*1"
291 .CR ".          TD"
292 .CR ".            nop 2*2"
293 .CR ".      ETB"
294 .CR ".ETB"
299 and this table
304 .CR ".TBL cols=2"
305 .CR ".  TR"
306 .CR ".    TD colspan=2"
307 .CR ".      nop 1*1 1*2"
308 .CR ".  TR"
309 .CR ".    TD"
310 .CR ".      nop 2*1"
311 .CR ".    TD"
312 .CR ".      nop 2*2"
313 .CR ".ETB"
318 are similar but not identical.
321 Here the latter table in a more compact form.
326 .CR ".TBL cols=2 .TR \[dq].TD colspan=2\[dq] 1*1 1*2"
327 .CR ".            TR .TD 2*1 .TD 2*2 .ETB"
332 If a macro has one or more arguments, and it is not starting a line, it must
333 be enclosed in double quotes.
336 .SH MACROS AND ARGUMENTS
338 The order of macro calls and other tokens follows the HTML model.
340 In the following list, valid predecessors and successors of all
341 .B hdtbl
342 macros are given, together with the possible arguments.
345 Macro arguments are separated by blanks.
347 The order of arguments is arbitrary; they are of the form
351 .CRI key= value
359 .CRI key=\[aq] "value1 \[lB]value2 \[lB]\[ell]\[rB]\[rB]" \[aq]
363 with the only exception of the optional argument of the macro
364 .CR .ETB\c
365 , which is the string
366 .CR \[oq]hold\[cq]\c
369 Another possible form is
373 .CRI \[dq]key= "value1 \[lB]value2 \[lB]\[ell]\[rB]\[rB]" \[dq]
377 However, this is limited to the case where the macro is the first one in the
378 line and not already enclosed in double quotes.
381 Argument values specified below as\~\c
382 .CI c
383 are colors predefined by
384 .B @L_ROFF@
385 or colors defined by the user with the
386 .CR .defcolor
387 request.
389 Argument values\~\c
390 .CI d
391 are decimal numbers with or without decimal point.
393 Argument values\~\c
394 .CI m
395 are natural numbers.
397 Argument values\~\c
398 .CI n
399 are numerical values with the usual
400 .B @L_ROFF@
401 scaling indicators.
403 Some of the arguments are specific to one or two macros, but most of them
404 can be specified with
405 .CR .TBL\c
407 .CR .TR\c
409 .CR .TD\c
410 , and
411 .CR .TH\
414 These common arguments are explained in the next subsection.
417 Most of the argument default values can be changed by the user by setting
418 corresponding default registers or strings, as listed below.
420 .\"------------------------------------------------------------------
423 .CBI ".TBL " \[lB]args\[rB]
424 Begin a new table.
428 .XB predecessor: .TD .TH .ETB "cell contents"
429 .XB successor: .CPTN .TR
430 .XB arguments:
433 .XAA border= \[lB]n\[rB]
434 Thickness of the surrounding box border.
436 .CR \%\[oq]border=\[cq]
437 (no value) means neither a surrounding box border nor any horizontal or
438 vertical separator lines between the table rows and cells.
440 .CR \%\[oq]border=0\[cq]
441 suppresses the surrounding box border, but still allows separator lines
442 between cells and rows.
444 .XDEFR border=.1n t*b
446 .XAA bc= c
447 Border color.
449 .XDEFS bc=red4 t*bc
451 .XAA cols= m
452 Number of table columns.
454 This argument is necessary if more than one column is in the table and no
455 .CR \[oq]width\[cq]
456 arguments are present.
458 .XDEFR cols=1 t*cols
460 .XAA cpd= n
461 Cell padding, i.e., the extra space between the cell space border and
462 the cell contents.
464 .XDEFR cpd=.5n t*cpd
466 .XAA csp= n
467 Cell spacing, i.e., the extra space between the table border or
468 vertical or horizontal lines between cells and the cellspace.
470 .XDEFR csp=.5n t*csp
472 .XAA tal=l\[or]c\[or]r
473 Horizontal alignment of the table, if it is smaller than the line width.
475 .CR \[oq]tal=l\[cq]\c
476 : left alignment.
478 .CR \[oq]tal=c\[cq]\c
479 : centered alignment.
481 .CR \[oq]tal=r\[cq]\c
482 : right alignment.
484 .XDEFR tal=l t*tal
486 .XAA "width=\[aq]" "w1 \[lB]w2 \[lB]\[ell]\[rB]\[rB]" \[aq]
487 Widths of table cells.
489 .CI w1\c
491 .CI w2\c
492 , \[ell] are either numbers of type\~\c
493 .CI n
494 or natural numbers with the pseudo-scaling indicator
495 .CR \[oq]%\[cq]\c
496 , with the meaning \[lq]percent of the actual line length (or column length
497 for inner tables, respectively)\[rq].
499 If there are less width values than table columns, the last width value is
500 used for the remaining cells.
502 The argument
506 .CR width=\[aq]1.5i 10%\[aq]
510 for example indicates that the first column is 1.5\|inches wide; the
511 remaining columns take 1/10 of the column length each.
513 .XDEF
514 The table width equals the outer line length or column length; the columns
515 have equal widths.
517 .XAA height= n
518 Height of the table.
520 If the table with its contents is lower than\~\c
521 .CI n\c
522 , the last row is stretched to this value.
526 .\"------------------------------------------------------------------
529 .CBI ".CPTN " \[lB]args\[rB]
530 Text of caption.
533 The (optionally numbered) table caption.
535 .CR .CPTN
536 is optional.
540 .XB predecessor: .TBL
541 .XB successor: .TR
542 .XB arguments:
545 .XAA val=t\[or]b
546 Vertical alignment of the table caption.
548 .CR \[oq]val=t\[cq]\c
549 : The caption is placed above the table.
551 .CR \[oq]val=b\[cq]\c
552 : The caption is placed below the table.
554 .XDEFS val=t t*cptn
558 .\"------------------------------------------------------------------
561 .CBI ".TR " \[lB]args\[rB]
562 Begin a new table row.
566 .XB predecessor: .TBL .CPTN .TD .TH .ETB "cell contents"
567 .XB successor: .TD .TH
568 .XB arguments:
571 .XAA height= n
572 The height of the row.
574 If a cell in the row is higher than\~\c
575 .CI n
576 this value is ignored; otherwise the row height is stretched to\~\c
577 .CI n\c
582 .\"------------------------------------------------------------------
585 .CBI ".TD " "\[lB]args \[lB]cell contents\[rB]\[rB]"
586 Begin a table data cell.
588 .CBI ".TH " "\[lB]args \[lB]cell contents\[rB]\[rB]"
589 Begin a table header cell.
592 Arguments and cell contents can be mixed.
594 The macro
595 .CR .TH
596 is not really necessary and differs from
597 .CR .TD
598 only in three default settings, similar to the
599 .CR <TH>
601 .CR <TD>
602 HTML tags: The contents of
603 .CR .TH
604 is horizontally and vertically centered and typeset in boldface.
608 .XB predecessor: .TR .TD .TH .ETB "cell contents"
609 .XB successor: .TD .TH .TR .ETB "cell contents"
610 .XB arguments:
613 .XAA colspan= m
614 The width of this cell is the sum of the widths of the\~\c
615 .CI m
616 cells above and below this row.
618 .XAA rowspan= m
619 The height of this cell is the sum of the heights of the
620 .CI m
621 cells left and right of this column.
624 .B Remark:
625 Overlapping of column and row spanning, as in the following table fragment
626 (the overlapping happens in the second cell in the second row), is invalid
627 and causes incorrect results.
632 .CR ".TR .TD 1*1 \[dq].TD 1*2 rowspan=2\[dq] .TD 1*3"
633 .CR ".TR \[dq].TD 2*1 colspan=2\[dq]         .TD 2*3"
639 .\"------------------------------------------------------------------
642 .CB ".ETB \[lB]hold\[rB]"
643 End of the table.
646 This macro finishes a table.
648 It causes one of the following actions.
651 .IP \[bu] 3
652 If the argument
653 .CR \[oq]hold\[cq]
654 is given, the table is held until it is freed by calling the macro
655 .CR .t*free\c
656 , which in turn prints the table immediately, either at the current position
657 or at the top of the next page if its height is larger than the remaining
658 space on the page.
660 .IP \[bu] 3
661 Otherwise, if the table is higher than the remaining space on the page,
662 it is printed at the top of the next page.
664 .IP \[bu] 3
665 If none of the two above constraints hold, the table is printed immediately
666 at the place of its definition.
671 .XB predecessor: .TD .TH .ETB "cell contents"
672 .XB successor: .TBL .TR .TD .TH .ETB "cell contents"
673 .XB arguments:
676 .XAA hold
677 Prevent the table from being printed until it is freed by calling the
678 macro
679 .CR .t*free\c
682 This argument is ignored for inner (nested) tables.
686 .\"------------------------------------------------------------------
689 .CBI ".t*free " \[lB]n\[rB]
690 Free the next held table or
691 .CI n\c
692 \~held tables.
694 Call this utility macro to print tables which are held by using the
695 .CR \[oq]hold\[cq]
696 argument of the
697 .CR .ETB
698 macro.
701 .SS Arguments common to \f[CB].TBL\f[], \f[CB].TR\f[], \f[CB].TD\f[], and \f[CB].TH\f[]
703 The arguments described in this section can be specified with the
704 .CR .TBL
706 .CR .TR
707 macros, but they are eventually passed on to the table cells.
709 If omitted, the defaults take place, which the user can change by setting
710 the corresponding default registers or strings, as documented below.
712 Setting an argument with the
713 .CR .TBL
714 macro has the same effect as setting it for all rows in the table.
716 Setting an argument with a
717 .CR .TR
718 macro has the same effect as setting it for all the
719 .CR .TH
721 .CR .TD
722 macro in this row.
725 .XAA bgc= \[lB]c\[rB]
726 The background color of the table cells.
728 This includes the area specified with the
729 .CR \[oq]csp\[cq]
730 argument.
732 The argument
733 .CR \[oq]bgc=\[cq]
734 (no value) suppresses a background color; this makes the background
735 transparent.
737 .XDEFS bgc=bisque t*bgc
739 .XAA fgc= c
740 The foreground color of the cell contents.
742 .XDEFS fgc=red4 t*fgc
744 .XAA ff= name
745 The font family for the table.
747 .CI name
748 is one of the @L_ROFF@ font families, for example
749 .CR A
750 for the AvantGarde fonts or
751 .CR HN
752 for Helvetica-Narrow.
754 .XDEF
755 The font family found before the table (string
756 .CR \[oq]t*ff\[cq]\c
759 .XAA fst= style
760 The font style for the table.
762 One of
763 .CR R\c
765 .CR I\c
767 .CR B\c
768 , or
769 .CR BI
770 for roman,
771 .BR bold ,
772 .IR italic ,
773 or \f[BI]bold italic\f[], respectively.
775 As with
776 .BR roff 's
777 .CR .ft
778 request the
779 .CR \[oq]fst\[cq]
780 argument can be used to specify the font family and font style together, for
781 example
782 .CR \[oq]fst=HNBI\[cq]
783 instead of
784 .CR \[oq]ff=HN\[cq]
786 .CR \[oq]fst=BI\[cq]\c
789 .XDEF
790 The font style in use right before the table (string
791 .CR \[oq]t*fst\[cq]\c
794 .XAA "fsz=\[aq]" "d1 \[lB]d2\[rB]" \[aq]
795 A decimal or fractional factor
796 .CI d1\c
797 , by which the point size for the table is changed, and
798 .CI d2\c
799 , by which the vertical line spacing is changed.
802 .CI d2
803 is omitted, value
804 .CI d1
805 is taken for both.
807 .XDEFS "fsz=\[aq]1.0 1.0\[aq]" t*fsz
809 .XAA hal=l\[or]c\[or]b\[or]r
810 Horizontal alignment of the cell contents in the table.
812 .CR \[oq]hal=l\[cq]\c
813 : left alignment.
815 .CR \[oq]hal=c\[cq]\c
816 : centered alignment.
818 .CR \[oq]hal=b\[cq]\c
819 : both (left and right) alignment.
821 .CR \[oq]hal=r\[cq]\c
822 : right alignment.
824 .XDEFS hal=b t*hal
826 .XAA val=t\[or]m\[or]b
827 Vertical alignment of the cell contents in the table for cells lower
828 than the current row.
830 .CR \[oq]val=t\[cq]\c
831 : alignment below the top of the cell.
833 .CR \[oq]val=m\[cq]\c
834 : alignment in the middle of the cell.
836 .CR \[oq]val=b\[cq]\c
837 : alignment above the cell bottom.
839 .XDEFS val=t t*val
841 .XAA hl=\[lB]s\[or]d\[rB]
842 Horizontal line between the rows.
844 If specified with
845 .CR .TD
847 .CR .TH
848 this is a separator line to the cell below.
850 .CR \[oq]hl=\[cq]
851 (no value): no separator line.
853 .CR \[oq]hl=s\[cq]\c
854 : a single separator line between the rows.
856 .CR \[oq]hl=d\[cq]\c
857 : a double separator line.
860 The thickness of the separator lines is the half of the border thickness,
861 but at least 0.1\|inches.
863 The distance between the double lines is equal to the line thickness.
866 .B Remark:
867 Together with
868 .CR \[oq]border=0\[cq]
869 for proper formatting the value of
870 .CR \[oq]csp\[cq]
871 must be at least .05\|inches for single separator lines and .15\|inches for
872 double separator lines.
874 .XDEFS hl=s t*hl
876 .XAA vl=\[lB]s\[or]d\[rB]
877 Vertical separator line between the cells.
879 If specified with
880 .CR .TD
882 .CR .TH
883 this is a separator line to the cell on the right.
885 .CR \[oq]vl=s\[cq]\c
886 : a single separator line between the cells.
888 .CR \[oq]vl=d\[cq]\c
889 : a double separator line.
891 .CR \[oq]vl=\[cq]
892 (no value): no vertical cell separator lines.
894 For more information see the documentation of the
895 .CR \[oq]hl\[cq]
896 argument above.
898 .XDEFS vl=s t*vl
901 .SH HDTBL CUSTOMIZATION
903 A table which does not fit on a partially filled page is printed
904 automatically on the top of the next page if you append the little
905 utility macro
906 .CR t*hm
907 to the page header macro of your document's main macro package.
908 For example, say
913 .CR ".am pg@top"
914 .CR ".  t*hm"
915 .CR ".."
920 if you use the
921 .B ms
922 macro package.
924 The macro
925 .CR t*EM
926 checks for held or kept tables,
927 and for missing
928 .CR ETB
929 macros (table not closed).
932 .SH AUTHOR
934 .MT Joachim.Walsdorff@urz.uni-heidelberg.de
935 Joachim Walsdorff
939 .SH BUGS AND SUGGESTIONS
941 Please send your commments to the
942 .MT @BUGMAIL@
943 mailing list
945 or directly to the author.
947 .cp \n[__compat]
948 .rr __compat
950 .\" s-tr-mode