demo: place bookmarks before writing section headings
[neatroff_make.git] / tmac / tmac.tbl
blob6bbf1cc3a5794ec752b3164e54657f34f189480b
1 .\" A macro package for simple tables
2 .\"
3 .\" This package creates simple tables, without using the tbl
4 .\" preprocessor.  The main macros are as follows:
5 .\"
6 .\" .tblbeg colwid1 colwid2 ...
7 .\"   This macro begins a table.  Its arguments are the widths of the
8 .\"   columns.  At most four columns are supported.  The width of the
9 .\"   last column can be 0 to expand it to the end of the line.
10 .\"
11 .\" .tblbox all row col
12 .\"   Specifies whether to draw box around the table (when all is 1),
13 .\"   between the rows (when row is 1), or between its columns (when
14 .\"   col is 1).
15 .\"
16 .\" .tblrow "column #1" "column #2" ...
17 .\"   Starts a new row.  Parameters provide a compact way of
18 .\"   specifying  the contents of a table row (instead of calling
19 .\"   .tblcol for every column).
20 .\"
21 .\" .tblcol col
22 .\"   Begins column number col for the current row.
23 .\"
24 .\" .tblmac mac1 mac2 ...
25 .\"   Before writing the contents of each column, the corresponding
26 .\"   macro in the list of the arguments of this macro is invoked (e.g.,
27 .\"   mac2 is called when starting column #2).
28 .\"
29 .\" .tblrst
30 .\"   This macro is called just before switching to new rows and columns
31 .\"   and drawing the table.  It should reset the indentation (and other
32 .\"   variables such as fonts, if necessary).
33 .\"
34 .\" .tblend
35 .\"   Ends a table.
36 .\"
37 .nr tblgap 1n
38 .nr tblboxall 0
39 .nr tblboxrow 0
40 .nr tblboxcol 0
41 .nr tblbrdrsz 30        \" border point size
42 .nr tblvertsz 16        \" vertical line point size
43 .nr tblhorisz 16        \" horizontal line point size
44 .de tblrst
45 .       in 0
47 .de tblbeg
48 .       tblrst
49 .       nr tblwid1 0\\$1
50 .       if "\\$1"0" .nr tblwid1 \\n(.l
51 .       nr tblwid2 0\\$2
52 .       if "\\$2"0" .nr tblwid2 \\n(.l-\\n[tblwid1]
53 .       nr tblwid3 0\\$3
54 .       if "\\$3"0" .nr tblwid3 \\n(.l-\\n[tblwid1]-\\n[tblwid2]
55 .       nr tblwid4 0\\$4
56 .       if "\\$4"0" .nr tblwid4 \\n(.l-\\n[tblwid1]-\\n[tblwid2]-\\n[tblwid3]
57 .       nr tblwid \\n[tblwid1]+\\n[tblwid2]+\\n[tblwid3]+\\n[tblwid4]
58 .       nr tblrow.one 1
60 .de tblmac
61 .       ds tblrst1 "\\$1
62 .       ds tblrst2 "\\$2
63 .       ds tblrst3 "\\$3
64 .       ds tblrst4 "\\$4
66 .de tblbox
67 .       nr tblboxall 0\\$1
68 .       nr tblboxrow 0\\$2
69 .       nr tblboxcol 0\\$3
71 .de tblcolbeg
72 .       nr tblcol.ok 1
73 .       sp |\\n[tblrow.top]u
74 .       tblrst
75 .       \\*[tblrst\\$1]
76 .       if \\$1=1 .in +0u
77 .       if \\$1=2 .in +\\n[tblwid1]u
78 .       if \\$1=3 .in +\\n[tblwid1]u+\\n[tblwid2]u
79 .       if \\$1=4 .in +\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u
80 .       ll \\n(.iu+\\n[tblwid\\$1]u
81 .       in +\\n[tblgap]u
82 .       ll -\\n[tblgap]u
84 .de tblcolend
85 .       br
86 .       nr tblcol.ok 0
87 .       if \\n(.d>\\n[tblrow.bot] .nr tblrow.bot \\n(.d
89 .de tblrowbeg
90 .       tblrst
91 .       if (\\n[tblboxall]+\\n[tblboxrow])&(\\n[tblrow.one]) \s[\\n[tblbrdrsz]]\D'l \\n[tblwid]u 0'\s[]
92 .       br
93 .       nr tblrow.ok 1
94 .       nr tblrow.one 0
95 .       mk tblrow.top
96 .       mk tblrow.bot
98 .de tblrowend
99 .       if \\n[tblcol.ok] .tblcolend \\$1
100 .       nr tblrow.ok 0
101 .       tblrst
102 .       sp |\\n[tblrow.bot]u
103 .       nr tblht \\n[tblrow.bot]u-\\n[tblrow.top]u+.5v
104 .       sp -.5v
105 .       if \\n[tblboxall]:\\n[tblboxcol] \{\
106 .               ps \\n[tblbrdrsz]
107 \h'|0'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
108 \h'|\\n[tblwid]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'
109 .               ps
110 .               sp -1
111 .       \}
112 .       if \\n[tblboxcol] \{\
113 .               ps \\n[tblvertsz]
114 \h'|\\n[tblwid1]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
115 \h'|\\n[tblwid1]u+\\n[tblwid2]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
116 \h'|\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'
117 .               ps
118 .               sp -1
119 .       \}
120 .       if \\n[tblboxrow]:(\\n[tblboxall]&\\$1) \{\
121 .               ie \\$1 .ps \\n[tblbrdrsz]
122 .               el .ps \\n[tblhorisz]
123 \h'|0'\D'l \\n[tblwid]u 0'
124 .               ps
125 .               sp -1
126 .       \}
127 .       sp
129 .de tblcol
130 .       br
131 .       if \\n[tblcol.ok] .tblcolend \\$1
132 .       tblcolbeg \\$1
133 .       if \\n(.$>=2 \\$2
135 .de tblrow
136 .       if \\n[tblrow.ok] .tblrowend 0
137 .       tblrowbeg
138 .       if \\n(.$>=1 .tblcol 1
139 .       if \\n(.$>=1 \\$1
140 .       if \\n(.$>=2 .tblcol 2
141 .       if \\n(.$>=2 \\$2
142 .       if \\n(.$>=3 .tblcol 3
143 .       if \\n(.$>=3 \\$3
144 .       if \\n(.$>=4 .tblcol 4
145 .       if \\n(.$>=4 \\$4
147 .de tblend
148 .       br
149 .       if \\n[tblcol.ok] .tblcolend
150 .       if \\n[tblrow.ok] .tblrowend 1
151 .       tblrst