BSD 3 development
[unix-history] / usr / doc / trofftut / tt06
CommitLineData
8340f87c
BJ
1.NH
2Local Motions: Drawing lines and characters
3.PP
4Remember `Area = \(*pr\u2\d' and the big `P'
5in the Paternoster.
6How are they done?
7.UL troff
8provides a host of commands for placing characters of any size
9at any place.
10You can use them to draw special characters
11or to tune your output for a particular appearance.
12Most of these commands are straightforward, but messy to read
13and tough to type correctly.
14.PP
15If you won't use
16.UL eqn ,
17subscripts and superscripts are most easily done with
18the half-line local motions
19.BD \eu
20and
21.BD \ed .
22To go back up the page half a point-size, insert a
23.BD \eu
24at the desired place;
25to go down, insert a
26.BD \ed .
27.BD \eu \& (
28and
29.BD \ed
30should always
31be used in pairs, as explained below.)
32Thus
33.P1
34Area = \e(*pr\eu2\ed
35.P2
36produces
37.P1
38Area = \(*pr\u2\d
39.P2
40To make the `2' smaller, bracket it with
41.BD \es\-2...\es0 .
42Since
43.BD \eu
44and
45.BD \ed
46refer to the current point size,
47be sure to put them either both inside or both outside
48the size changes,
49or you will get an unbalanced vertical motion.
50.PP
51Sometimes the space given by
52.BD \eu
53and
54.BD \ed
55isn't the right amount.
56The
57.BD \ev
58command can be used to request an arbitrary amount of vertical motion.
59The in-line command
60.P1
61\ev'(amount)'
62.P2
63causes motion up or down the page by the amount specified in
64`(amount)'.
65For example, to move the `P' down, we used
66.P1 2
67.ta 1i
68^in +0.6i (move paragraph in)
69^ll \-0.3i (shorten lines)
70^ti \-0.3i (move P back)
71\ev'2'\es36P\es0\ev'\-2'ater noster qui est
72in caelis ...
73.P2
74A minus sign causes upward motion, while
75no sign or a plus sign means down the page.
76Thus
77.BD \ev\(fm\-2\(fm
78causes an upward vertical motion
79of two line spaces.
80.PP
81There are many other ways to specify the amount of motion _
82.P1
83\ev'0.1i'
84\ev'3p'
85\ev'\-0.5m'
86.P2
87and so on are all legal.
88Notice that the scale specifier
89.BD i
90or
91.BD p
92or
93.BD m
94goes inside the quotes.
95Any character can be used in place of the quotes;
96this is also true of all other
97.UL troff
98commands described in this section.
99.PP
100Since
101.UL troff
102does not take within-the-line vertical motions into account
103when figuring out where it is on the page,
104output lines can have unexpected positions
105if the left and right ends aren't at the same
106vertical position.
107Thus
108.BD \ev ,
109like
110.BD \eu
111and
112.BD \ed ,
113should always balance upward vertical motion in a line with
114the same amount in the downward direction.
115.PP
116Arbitrary horizontal motions are also available _
117.BD \eh
118is quite analogous to
119.BD \ev ,
120except that the default scale factor is ems instead of line spaces.
121As an example,
122.P1
123\eh'\-0.1i'
124.P2
125causes a backwards motion of a tenth of an inch.
126As a practical matter, consider printing the mathematical symbol
127`>>'.
128The default spacing is too wide, so
129.UL eqn
130replaces this by
131.P1
132>\eh'\-0.3m'>
133.P2
134to produce >\h'-.3m'>.
135.PP
136Frequently
137.BD \eh
138is used with the `width function'
139.BD \ew
140to generate motions equal to the width
141of some character string.
142The construction
143.P1
144\ew'thing'
145.P2
146is a number equal to the width of `thing' in machine units
147(1/432 inch).
148All
149.UL troff
150computations are ultimately done in these units.
151To move horizontally the width of an `x',
152we can say
153.P1
154\eh'\ew'x'u'
155.P2
156As we mentioned above,
157the default scale factor for
158all horizontal dimensions is
159.BD m ,
160ems, so here we must have the
161.BD u
162for machine units,
163or the motion produced will be far too large.
164.UL troff
165is quite happy with the nested quotes, by the way,
166so long as you don't leave any out.
167.PP
168As a live example of this kind of construction,
169all of the command names in the text, like
170.BD .sp ,
171were done by overstriking with a slight offset.
172The commands for
173.BD .sp
174are
175.P1
176^sp\eh'\-\ew'.sp'u'\eh'1u'.sp
177.P2
178That is, put out `.sp', move left by the width of `.sp',
179move right 1 unit, and print
180`.sp' again.
181(Of course there is a way to avoid typing that much input
182for each command name, which we will discuss in Section 11.)
183.WS
184.PP
185There are also several special-purpose
186.UL troff
187commands for local motion.
188We have already seen
189.BD \e0 ,
190which is an unpaddable white space
191of the same width as a digit.
192`Unpaddable' means that it will never be widened
193or split across a line by line justification and filling.
194There is also
195.BD \e (blank),
196.tr ^^
197which is an unpaddable character the width of a space,
198.BD \e| ,
199which is half that width,
200.BD \e^ ,
201which is one quarter of the width of a space,
202and
203.BD \e& ,
204which has zero width.
205.tr ^.
206(This last one is useful, for example, in entering
207a text line which would otherwise begin with a `.'.)
208.PP
209The command
210.BD \eo ,
211used like
212.P1
213\eo'set of characters'
214.P2
215causes (up to 9)
216characters to be overstruck,
217centered on the widest.
218This is nice for accents, as in
219.P1 2
220syst\eo"e\e(ga"me t\eo"e\e(aa"l\eo"e\e(aa"phonique
221.P2
222which makes
223.P1
224syst\o"e\(ga"me t\o"e\(aa"l\o"e\(aa"phonique
225.P2
226The accents are
227.BD \e(ga
228and
229.BD \e(aa ,
230or
231.BD \e\`
232and
233.BD \e\' ;
234remember that each is just one character to
235.UL troff .
236.PP
237You can make your own overstrikes with another special convention,
238.BD \ez ,
239the zero-motion command.
240.BD \ezx
241suppresses the normal horizontal motion
242after printing the single character
243.BD x ,
244so another character can be laid on top of it.
245Although sizes can be changed within
246.BD \eo ,
247it centers the characters on the widest,
248and
249there can be no horizontal or vertical motions,
250so
251.BD \ez
252may be the only way to get what you want:
253.P1
254.sp 2
255\s8\z\(sq\s14\z\(sq\s22\z\(sq\s36\(sq
256.P2
257is produced by
258.P1
259^sp 2
260\es8\ez\e(sq\es14\ez\e(sq\es22\ez\e(sq\es36\e(sq
261.P2
262The
263.BD .sp
264is needed to leave room for the result.
265.PP
266As another example, an extra-heavy semicolon
267that looks like
268.P1
269\s+6\z,\v'-0.25m'.\v'0.25m'\s0 instead of ; or \s+6;\s0
270.P2
271can be constructed with a big comma and a big period above it:
272.P1
273\es+6\ez,\ev'\(mi0.25m'.\ev'0.25m'\es0
274.P2
275`0.25m' is an empirical constant.
276.PP
277A more ornate overstrike is given by the bracketing function
278.BD \eb ,
279which piles up characters vertically,
280centered on the current baseline.
281Thus we can get big brackets,
282constructing them with piled-up smaller pieces:
283.P1
284.sp
285.ne 3
286\b'\(lt\(lk\(lb' \b'\(lc\(lf' x \b'\(rc\(rf' \b'\(rt\(rk\(rb'
287.sp
288.P2
289by typing in only this:
290.P1 0
291\&^sp
292\eb\(fm\e(lt\e(lk\e(lb\(fm \eb\(fm\e(lc\e(lf\(fm x \eb\(fm\e(rc\e(rf\(fm \eb\(fm\e(rt\e(rk\e(rb\(fm
293.P2
294.PP
295.UL troff
296also provides a convenient facility for drawing horizontal and vertical
297lines of arbitrary length with arbitrary characters.
298.BD \el\(fm1i\(fm
299draws a line one inch long, like this:
300\l'1i'\|.
301The length can be followed by
302the character to use if the \(ru isn't appropriate;
303.BD \el\(fm0.5i.\(fm
304draws a half-inch line of dots: \l'.5i.'.
305The construction
306.BD \eL
307is entirely analogous,
308except that it draws a vertical line instead of horizontal.