tmac.tbl: start a new row automatically only if tblrowaut is set
[neatroff_make.git] / tmac / tmac.tbl
blob6b0ed9bc770c32f3172df7bdd096d6604fcd105b
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 .\"   The compact way of specifying the contents of a table row (instead
18 .\"   of calling .tblcol for every column).
19 .\"
20 .\" .tblcol col
21 .\"   Begins column number col for the current row.  With an argument of
22 .\"   1, a new row is inserted.
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 tblrowaut 1
42 .de tblrst
43 .       in 0
45 .de tblbeg
46 .       tblrst
47 .       nr tblwid1 0\\$1
48 .       if "\\$1"0" .nr tblwid1 \\n(.l
49 .       nr tblwid2 0\\$2
50 .       if "\\$2"0" .nr tblwid2 \\n(.l-\\n[tblwid1]
51 .       nr tblwid3 0\\$3
52 .       if "\\$3"0" .nr tblwid3 \\n(.l-\\n[tblwid1]-\\n[tblwid2]
53 .       nr tblwid4 0\\$4
54 .       if "\\$4"0" .nr tblwid4 \\n(.l-\\n[tblwid1]-\\n[tblwid2]-\\n[tblwid3]
55 .       nr tblwid \\n[tblwid1]+\\n[tblwid2]+\\n[tblwid3]+\\n[tblwid4]
56 .       nr tblrow.one 1
58 .de tblmac
59 .       ds tblrst1 "\\$1
60 .       ds tblrst2 "\\$2
61 .       ds tblrst3 "\\$3
62 .       ds tblrst4 "\\$4
64 .de tblbox
65 .       nr tblboxall 0\\$1
66 .       nr tblboxrow 0\\$2
67 .       nr tblboxcol 0\\$3
69 .de tblcolbeg
70 .       nr tblcol.ok 1
71 .       sp |\\n[tblrow.top]u
72 .       tblrst
73 .       \\*[tblrst\\$1]
74 .       if \\$1=1 .in +0u
75 .       if \\$1=2 .in +\\n[tblwid1]u
76 .       if \\$1=3 .in +\\n[tblwid1]u+\\n[tblwid2]u
77 .       if \\$1=4 .in +\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u
78 .       ll \\n(.iu+\\n[tblwid\\$1]u
79 .       in +\\n[tblgap]u
80 .       ll -\\n[tblgap]u
82 .de tblcolend
83 .       nr tblcol.ok 0
84 .       if \\n(.d>\\n[tblrow.bot] .nr tblrow.bot \\n(.d
86 .de tblrowbeg
87 .       tblrst
88 .       if (\\n[tblboxall]+\\n[tblboxrow])&(\\n[tblrow.one]) \D'l \\n[tblwid]u 0'
89 .       br
90 .       nr tblrow.ok 1
91 .       nr tblrow.one 0
92 .       mk tblrow.top
93 .       mk tblrow.bot
95 .de tblrowend
96 .       if \\n[tblcol.ok] .tblcolend \\$1
97 .       nr tblrow.ok 0
98 .       tblrst
99 .       sp |\\n[tblrow.bot]u
100 .       nr tblht \\n[tblrow.bot]u-\\n[tblrow.top]u+.5v
101 .       sp -.5v
102 .       if \\n[tblboxall]:\\n[tblboxcol] \{\
103 \h'|0'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
104 \h'|\\n[tblwid]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'
105 .               sp -1
106 .       \}
107 .       if \\n[tblboxcol] \{\
108 \h'|\\n[tblwid1]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
109 \h'|\\n[tblwid1]u+\\n[tblwid2]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
110 \h'|\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'
111 .               sp -1
112 .       \}
113 .       if \\n[tblboxrow]:(\\n[tblboxall]&\\$1) \{\
114 \h'|0'\D'l \\n[tblwid]u 0'
115 .               sp -1
116 .       \}
117 .       sp
119 .de tblcol
120 .       br
121 .       if \\n[tblcol.ok] .tblcolend \\$1
122 .       if \\$1=1&\\n[tblrowaut] .if \\n[tblrow.ok] .tblrowend 0
123 .       if \\$1=1&\\n[tblrowaut] .tblrowbeg
124 .       tblcolbeg \\$1
126 .de tblrow
127 .       if \\n(.$>=1 .tblcol 1
128 .       if \\n(.$>=1 \\$1
129 .       if \\n(.$>=2 .tblcol 2
130 .       if \\n(.$>=2 \\$2
131 .       if \\n(.$>=3 .tblcol 3
132 .       if \\n(.$>=3 \\$3
133 .       if \\n(.$>=4 .tblcol 4
134 .       if \\n(.$>=4 \\$4
136 .de tblend
137 .       br
138 .       if \\n[tblcol.ok] .tblcolend
139 .       if \\n[tblrow.ok] .tblrowend 1
140 .       tblrst