s-gnu-diff.sh: easy compare codebase(s)
[s-roff.git] / contrib / hdtbl / groff_hdtbl.7.in
blobfef1b2c0892c6da1ac7b5344775545ca6207a7b4
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
29 .ig
30   Some simple formatting macros.  Note that we use `.ig' here and not a
31   comment to make `mandb' 2.4.1 (and probably more recent versions also)
32   happy; otherwise the `.char' lines and the stuff which follows is included
33   in the `whatis' database.
37 .char \[lB] \F[\n[.fam]]\f[R][
38 .char \[rB] \F[\n[.fam]]\f[R]]
40 .char \[or] \F[\n[.fam]]\f[R]\||\|
41 .char \[ell] \F[\n[.fam]]\f[R].\|.\|.
43 .char \[oq] \F[\n[.fam]]\f[R]\[oq]
44 .char \[cq] \F[\n[.fam]]\f[R]\[cq]
47 .ie F CR \{\
49 .  \" We have to solve the following problem.  In this code
50 .  \"
51 .  \"   foo
52 .  \"   .CR bar
53 .  \"   foo
54 .  \"
55 .  \" the space immediately after `bar' should not be taken from the `C'
56 .  \" family.  At the same time, this
57 .  \"
58 .  \"   foo
59 .  \"   .CR bar\c
60 .  \"   foo
61 .  \"
62 .  \" should work also.  To fulfill both constraints we emit the
63 .  \" family changing commands both as escapes and macro calls.
65 .  de make-C-macro
66 .    de C\\$1
67 .      ds old-fam \\\\n[.fam]
68 .      fam C
69 .      \\$2 \&\\\\$*\F[]\F[\\\\*[old-fam]]
70 .      fam
71 \\..
72 .  .
74 .  make-C-macro R nop
75 .  make-C-macro B B
76 .  make-C-macro I I
78 .  de make-C-macro
79 .    de C\\$1
80 .      ds old-fam \\\\n[.fam]
81 .      fam C
82 .      \\$1 \\\\$@ \F[]\F[\\\\*[old-fam]]
83 .      fam
84 \\..
85 .  .
87 .  make-C-macro BI
88 .  make-C-macro IB
89 .  make-C-macro RI
90 .  make-C-macro IR
91 .  make-C-macro BR
92 .  make-C-macro RB
93 .\}
94 .el \{\
95 .  ftr CR R
96 .  ftr CI I
97 .  ftr CB B
98 .  ftr CBI BI
100 .  de CR
101 .    nop \&\\$*
102 .  .
103 .  als CB B
104 .  als CI I
106 .  als CBI BI
107 .  als CIB IB
108 .  als CRI RI
109 .  als CIR IR
110 .  als CBR BR
111 .  als CRB RB
115 .de TQ
116 .  br
117 .  ns
118 .  TP
122 .de XB
123 .  B "\\$1"
124 .  shift
125 .  CR "\\$1\c"
126 .  shift
127 .  while \\n[.$] \{\
128 .    nop ,
129 .    CR "\\$1\c"
130 .    shift
131 .  \}
132 .  br
136 .de XAA
137 .  TQ
138 .  CRI \\$@
142 .de XDEF
143 .  br
144 .  B Default:
145 .  if !\\n[.$] \
146 .    return
147 .  CRI "\\$1" "\\$2"
151 .de XDEFR
152 .  br
153 .  B Default:
154 .  CR "\[oq]\\$1\[cq]"
155 .  nop (register
156 .  CR "\[oq]\\$2\[cq]\c"
157 .  nop ).
161 .de XDEFS
162 .  br
163 .  B Default:
164 .  CR "\[oq]\\$1\[cq]"
165 .  nop (string
166 .  CR "\[oq]\\$2\[cq]\c"
167 .  nop ).
172 .SH DESCRIPTION
175 .B hdtbl
176 macros consist of four base and three optional macros, controlled by about
177 twenty arguments.
179 The syntax is simple and similar to the
180 .B HTML
181 table model and nearly as flexible: You can write sequences of tokens (macro
182 calls with their arguments and content data), separated by blanks and
183 beginning with a macro call, into the same line to get compact and cleanly
184 arrranged input.
186 An advantage of
187 .B hdtbl
188 is that the tables are constructed without calling a preprocessor; this
189 means that
190 .BR @L_ROFF@ 's
191 full macro capabilities are available.
193 On the other hand, table processing with
194 .B hdtbl
195 is much slower than using the
196 .BR tbl (@MAN1EXT)
197 preprocessor.
199 A further advantage is that the HTML-like syntax of
200 .B hdtbl
201 will be easily converted to HTML; this is not implemented yet.
204 .SH USAGE
206 The simplest well-formed table consists of just single calls to the four
207 base table macros in the right order.
209 Here we construct a table with only one cell.
214 .CR .TBL
215 .CR .TR
216 .CR .TD
217 .CI contents of the table cell
218 .CR .ETB
223 Equivalent to the above is the following notation.
227 .CRI ".TBL .TR .TD " "contents of the table cell" " .ETB"
231 By default, the formatted table is inserted into the surrounding text at the
232 place of its definition.
234 If the vertical space isn't sufficient, it is placed at the top of the next
235 page.
237 Tables can also be stored for later insertion.
240 Using
241 .CIR \[oq]row-number * column-number\[cq]
242 as the data for the table cells, a table with two rows and two columns can
243 be written as
248 .CR ".TBL cols=2"
249 .CR ".  TR .TD 1*1 .TD 1*2"
250 .CR ".  TR .TD 2*1 .TD 2*2"
251 .CR ".ETB"
256 Here we see a difference to HTML tables: The number of columns must be
257 explicitly specified using the
258 .CRI \[oq]cols= m\[cq]
259 argument (or indirectly via the
260 .CR \[oq]width\[cq]
261 argument, see below).
264 The contents of a table cell is arbitrary; for example, it can be another
265 table, without restriction to the nesting depth.
267 A given table layout can be either constructed with suitably nested tables
268 or with proper arguments to
269 .CR .TD
271 .CR .TH\c
272 , controlling column and row spanning.
274 Note, however, that this table
279 .CR ".TBL"
280 .CR ".  TR"
281 .CR ".    TD"
282 .CR ".      nop 1*1 1*2"
283 .CR ".  TR"
284 .CR ".    TD"
285 .CR ".      TBL cols=2 border="
286 .CR ".        TR"
287 .CR ".          TD"
288 .CR ".            nop 2*1"
289 .CR ".          TD"
290 .CR ".            nop 2*2"
291 .CR ".      ETB"
292 .CR ".ETB"
297 and this table
302 .CR ".TBL cols=2"
303 .CR ".  TR"
304 .CR ".    TD colspan=2"
305 .CR ".      nop 1*1 1*2"
306 .CR ".  TR"
307 .CR ".    TD"
308 .CR ".      nop 2*1"
309 .CR ".    TD"
310 .CR ".      nop 2*2"
311 .CR ".ETB"
316 are similar but not identical.
319 Here the latter table in a more compact form.
324 .CR ".TBL cols=2 .TR \[dq].TD colspan=2\[dq] 1*1 1*2"
325 .CR ".            TR .TD 2*1 .TD 2*2 .ETB"
330 If a macro has one or more arguments, and it is not starting a line, it must
331 be enclosed in double quotes.
334 .SH MACROS AND ARGUMENTS
336 The order of macro calls and other tokens follows the HTML model.
338 In the following list, valid predecessors and successors of all
339 .B hdtbl
340 macros are given, together with the possible arguments.
343 Macro arguments are separated by blanks.
345 The order of arguments is arbitrary; they are of the form
349 .CRI key= value
357 .CRI key=\[aq] "value1 \[lB]value2 \[lB]\[ell]\[rB]\[rB]" \[aq]
361 with the only exception of the optional argument of the macro
362 .CR .ETB\c
363 , which is the string
364 .CR \[oq]hold\[cq]\c
367 Another possible form is
371 .CRI \[dq]key= "value1 \[lB]value2 \[lB]\[ell]\[rB]\[rB]" \[dq]
375 However, this is limited to the case where the macro is the first one in the
376 line and not already enclosed in double quotes.
379 Argument values specified below as\~\c
380 .CI c
381 are colors predefined by
382 .B @L_ROFF@
383 or colors defined by the user with the
384 .CR .defcolor
385 request.
387 Argument values\~\c
388 .CI d
389 are decimal numbers with or without decimal point.
391 Argument values\~\c
392 .CI m
393 are natural numbers.
395 Argument values\~\c
396 .CI n
397 are numerical values with the usual
398 .B @L_ROFF@
399 scaling indicators.
401 Some of the arguments are specific to one or two macros, but most of them
402 can be specified with
403 .CR .TBL\c
405 .CR .TR\c
407 .CR .TD\c
408 , and
409 .CR .TH\
412 These common arguments are explained in the next subsection.
415 Most of the argument default values can be changed by the user by setting
416 corresponding default registers or strings, as listed below.
418 .\"------------------------------------------------------------------
421 .CBI ".TBL " \[lB]args\[rB]
422 Begin a new table.
426 .XB predecessor: .TD .TH .ETB "cell contents"
427 .XB successor: .CPTN .TR
428 .XB arguments:
431 .XAA border= \[lB]n\[rB]
432 Thickness of the surrounding box border.
434 .CR \%\[oq]border=\[cq]
435 (no value) means neither a surrounding box border nor any horizontal or
436 vertical separator lines between the table rows and cells.
438 .CR \%\[oq]border=0\[cq]
439 suppresses the surrounding box border, but still allows separator lines
440 between cells and rows.
442 .XDEFR border=.1n t*b
444 .XAA bc= c
445 Border color.
447 .XDEFS bc=red4 t*bc
449 .XAA cols= m
450 Number of table columns.
452 This argument is necessary if more than one column is in the table and no
453 .CR \[oq]width\[cq]
454 arguments are present.
456 .XDEFR cols=1 t*cols
458 .XAA cpd= n
459 Cell padding, i.e., the extra space between the cell space border and
460 the cell contents.
462 .XDEFR cpd=.5n t*cpd
464 .XAA csp= n
465 Cell spacing, i.e., the extra space between the table border or
466 vertical or horizontal lines between cells and the cellspace.
468 .XDEFR csp=.5n t*csp
470 .XAA tal=l\[or]c\[or]r
471 Horizontal alignment of the table, if it is smaller than the line width.
473 .CR \[oq]tal=l\[cq]\c
474 : left alignment.
476 .CR \[oq]tal=c\[cq]\c
477 : centered alignment.
479 .CR \[oq]tal=r\[cq]\c
480 : right alignment.
482 .XDEFR tal=l t*tal
484 .XAA "width=\[aq]" "w1 \[lB]w2 \[lB]\[ell]\[rB]\[rB]" \[aq]
485 Widths of table cells.
487 .CI w1\c
489 .CI w2\c
490 , \[ell] are either numbers of type\~\c
491 .CI n
492 or natural numbers with the pseudo-scaling indicator
493 .CR \[oq]%\[cq]\c
494 , with the meaning \[lq]percent of the actual line length (or column length
495 for inner tables, respectively)\[rq].
497 If there are less width values than table columns, the last width value is
498 used for the remaining cells.
500 The argument
504 .CR width=\[aq]1.5i 10%\[aq]
508 for example indicates that the first column is 1.5\|inches wide; the
509 remaining columns take 1/10 of the column length each.
511 .XDEF
512 The table width equals the outer line length or column length; the columns
513 have equal widths.
515 .XAA height= n
516 Height of the table.
518 If the table with its contents is lower than\~\c
519 .CI n\c
520 , the last row is stretched to this value.
524 .\"------------------------------------------------------------------
527 .CBI ".CPTN " \[lB]args\[rB]
528 Text of caption.
531 The (optionally numbered) table caption.
533 .CR .CPTN
534 is optional.
538 .XB predecessor: .TBL
539 .XB successor: .TR
540 .XB arguments:
543 .XAA val=t\[or]b
544 Vertical alignment of the table caption.
546 .CR \[oq]val=t\[cq]\c
547 : The caption is placed above the table.
549 .CR \[oq]val=b\[cq]\c
550 : The caption is placed below the table.
552 .XDEFS val=t t*cptn
556 .\"------------------------------------------------------------------
559 .CBI ".TR " \[lB]args\[rB]
560 Begin a new table row.
564 .XB predecessor: .TBL .CPTN .TD .TH .ETB "cell contents"
565 .XB successor: .TD .TH
566 .XB arguments:
569 .XAA height= n
570 The height of the row.
572 If a cell in the row is higher than\~\c
573 .CI n
574 this value is ignored; otherwise the row height is stretched to\~\c
575 .CI n\c
580 .\"------------------------------------------------------------------
583 .CBI ".TD " "\[lB]args \[lB]cell contents\[rB]\[rB]"
584 Begin a table data cell.
586 .CBI ".TH " "\[lB]args \[lB]cell contents\[rB]\[rB]"
587 Begin a table header cell.
590 Arguments and cell contents can be mixed.
592 The macro
593 .CR .TH
594 is not really necessary and differs from
595 .CR .TD
596 only in three default settings, similar to the
597 .CR <TH>
599 .CR <TD>
600 HTML tags: The contents of
601 .CR .TH
602 is horizontally and vertically centered and typeset in boldface.
606 .XB predecessor: .TR .TD .TH .ETB "cell contents"
607 .XB successor: .TD .TH .TR .ETB "cell contents"
608 .XB arguments:
611 .XAA colspan= m
612 The width of this cell is the sum of the widths of the\~\c
613 .CI m
614 cells above and below this row.
616 .XAA rowspan= m
617 The height of this cell is the sum of the heights of the
618 .CI m
619 cells left and right of this column.
622 .B Remark:
623 Overlapping of column and row spanning, as in the following table fragment
624 (the overlapping happens in the second cell in the second row), is invalid
625 and causes incorrect results.
630 .CR ".TR .TD 1*1 \[dq].TD 1*2 rowspan=2\[dq] .TD 1*3"
631 .CR ".TR \[dq].TD 2*1 colspan=2\[dq]         .TD 2*3"
637 .\"------------------------------------------------------------------
640 .CB ".ETB \[lB]hold\[rB]"
641 End of the table.
644 This macro finishes a table.
646 It causes one of the following actions.
649 .IP \[bu] 3
650 If the argument
651 .CR \[oq]hold\[cq]
652 is given, the table is held until it is freed by calling the macro
653 .CR .t*free\c
654 , which in turn prints the table immediately, either at the current position
655 or at the top of the next page if its height is larger than the remaining
656 space on the page.
658 .IP \[bu] 3
659 Otherwise, if the table is higher than the remaining space on the page,
660 it is printed at the top of the next page.
662 .IP \[bu] 3
663 If none of the two above constraints hold, the table is printed immediately
664 at the place of its definition.
669 .XB predecessor: .TD .TH .ETB "cell contents"
670 .XB successor: .TBL .TR .TD .TH .ETB "cell contents"
671 .XB arguments:
674 .XAA hold
675 Prevent the table from being printed until it is freed by calling the
676 macro
677 .CR .t*free\c
680 This argument is ignored for inner (nested) tables.
684 .\"------------------------------------------------------------------
687 .CBI ".t*free " \[lB]n\[rB]
688 Free the next held table or
689 .CI n\c
690 \~held tables.
692 Call this utility macro to print tables which are held by using the
693 .CR \[oq]hold\[cq]
694 argument of the
695 .CR .ETB
696 macro.
699 .SS Arguments common to \f[CB].TBL\f[], \f[CB].TR\f[], \f[CB].TD\f[], and \f[CB].TH\f[]
701 The arguments described in this section can be specified with the
702 .CR .TBL
704 .CR .TR
705 macros, but they are eventually passed on to the table cells.
707 If omitted, the defaults take place, which the user can change by setting
708 the corresponding default registers or strings, as documented below.
710 Setting an argument with the
711 .CR .TBL
712 macro has the same effect as setting it for all rows in the table.
714 Setting an argument with a
715 .CR .TR
716 macro has the same effect as setting it for all the
717 .CR .TH
719 .CR .TD
720 macro in this row.
723 .XAA bgc= \[lB]c\[rB]
724 The background color of the table cells.
726 This includes the area specified with the
727 .CR \[oq]csp\[cq]
728 argument.
730 The argument
731 .CR \[oq]bgc=\[cq]
732 (no value) suppresses a background color; this makes the background
733 transparent.
735 .XDEFS bgc=bisque t*bgc
737 .XAA fgc= c
738 The foreground color of the cell contents.
740 .XDEFS fgc=red4 t*fgc
742 .XAA ff= name
743 The font family for the table.
745 .CI name
746 is one of the @L_ROFF@ font families, for example
747 .CR A
748 for the AvantGarde fonts or
749 .CR HN
750 for Helvetica-Narrow.
752 .XDEF
753 The font family found before the table (string
754 .CR \[oq]t*ff\[cq]\c
757 .XAA fst= style
758 The font style for the table.
760 One of
761 .CR R\c
763 .CR I\c
765 .CR B\c
766 , or
767 .CR BI
768 for roman,
769 .BR bold ,
770 .IR italic ,
771 or \f[BI]bold italic\f[], respectively.
773 As with
774 .BR roff 's
775 .CR .ft
776 request the
777 .CR \[oq]fst\[cq]
778 argument can be used to specify the font family and font style together, for
779 example
780 .CR \[oq]fst=HNBI\[cq]
781 instead of
782 .CR \[oq]ff=HN\[cq]
784 .CR \[oq]fst=BI\[cq]\c
787 .XDEF
788 The font style in use right before the table (string
789 .CR \[oq]t*fst\[cq]\c
792 .XAA "fsz=\[aq]" "d1 \[lB]d2\[rB]" \[aq]
793 A decimal or fractional factor
794 .CI d1\c
795 , by which the point size for the table is changed, and
796 .CI d2\c
797 , by which the vertical line spacing is changed.
800 .CI d2
801 is omitted, value
802 .CI d1
803 is taken for both.
805 .XDEFS "fsz=\[aq]1.0 1.0\[aq]" t*fsz
807 .XAA hal=l\[or]c\[or]b\[or]r
808 Horizontal alignment of the cell contents in the table.
810 .CR \[oq]hal=l\[cq]\c
811 : left alignment.
813 .CR \[oq]hal=c\[cq]\c
814 : centered alignment.
816 .CR \[oq]hal=b\[cq]\c
817 : both (left and right) alignment.
819 .CR \[oq]hal=r\[cq]\c
820 : right alignment.
822 .XDEFS hal=b t*hal
824 .XAA val=t\[or]m\[or]b
825 Vertical alignment of the cell contents in the table for cells lower
826 than the current row.
828 .CR \[oq]val=t\[cq]\c
829 : alignment below the top of the cell.
831 .CR \[oq]val=m\[cq]\c
832 : alignment in the middle of the cell.
834 .CR \[oq]val=b\[cq]\c
835 : alignment above the cell bottom.
837 .XDEFS val=t t*val
839 .XAA hl=\[lB]s\[or]d\[rB]
840 Horizontal line between the rows.
842 If specified with
843 .CR .TD
845 .CR .TH
846 this is a separator line to the cell below.
848 .CR \[oq]hl=\[cq]
849 (no value): no separator line.
851 .CR \[oq]hl=s\[cq]\c
852 : a single separator line between the rows.
854 .CR \[oq]hl=d\[cq]\c
855 : a double separator line.
858 The thickness of the separator lines is the half of the border thickness,
859 but at least 0.1\|inches.
861 The distance between the double lines is equal to the line thickness.
864 .B Remark:
865 Together with
866 .CR \[oq]border=0\[cq]
867 for proper formatting the value of
868 .CR \[oq]csp\[cq]
869 must be at least .05\|inches for single separator lines and .15\|inches for
870 double separator lines.
872 .XDEFS hl=s t*hl
874 .XAA vl=\[lB]s\[or]d\[rB]
875 Vertical separator line between the cells.
877 If specified with
878 .CR .TD
880 .CR .TH
881 this is a separator line to the cell on the right.
883 .CR \[oq]vl=s\[cq]\c
884 : a single separator line between the cells.
886 .CR \[oq]vl=d\[cq]\c
887 : a double separator line.
889 .CR \[oq]vl=\[cq]
890 (no value): no vertical cell separator lines.
892 For more information see the documentation of the
893 .CR \[oq]hl\[cq]
894 argument above.
896 .XDEFS vl=s t*vl
899 .SH HDTBL CUSTOMIZATION
901 A table which does not fit on a partially filled page is printed
902 automatically on the top of the next page if you append the little
903 utility macro
904 .CR t*hm
905 to the page header macro of your document's main macro package.
906 For example, say
911 .CR ".am pg@top"
912 .CR ".  t*hm"
913 .CR ".."
918 if you use the
919 .B ms
920 macro package.
923 .B hdtbl
924 has built-in page header and page footer macros,
925 .B HM
927 .BR BM .
928 If they interfere with your own header and footer macros, simply
930 .CR ".rm\ HM"
932 .CR ".rm\ BM"
933 to remove them.
936 .SH AUTHOR
938 .MT Joachim.Walsdorff@urz.uni-heidelberg.de
939 Joachim Walsdorff
943 .SH BUGS AND SUGGESTIONS
945 Please send your commments to the
946 .MT @BUGMAIL@
947 mailing list
949 or directly to the author.
951 .\" s-tr-mode