6.  Local Motions: Drawing lines and characters

      Remember `Area = [pi]r2' and the big `P' in the Paternoster. How are they done? troff provides a host of commands for placing characters of any size at any place. You can use them to draw special characters or to tune your output for a particular appearance. Most of these commands are straightforward, but messy to read and tough to type correctly.

      If you won't use eqn, subscripts and superscripts are most easily done with the half-line local motions \uand \dTo go back up the page half a point-size, insert a \uat the desired place; to go down, insert a \d(\uand \dshould always be used in pairs, as explained below.) Thus Area = \(*pr\u2\d
produces
Area = [pi]r2
To make the `2' smaller, bracket it with
\s-2...\s0Since
\uand
\drefer to the current point size,
be sure to put them either both inside or both outside
the size changes,
or you will get an unbalanced vertical motion.

      Sometimes the space given by \uand \disn't the right amount. The \vcommand can be used to request an arbitrary amount of vertical motion. The in-line command \v'(amount)'
causes motion up or down the page by the amount specified in
`(amount)'.
For example, to move the `P' down, we used
^in +0.6i (move paragraph in)
^ll -0.3i (shorten lines)
^ti -0.3i (move P back)
\v'2'\s36P\s0\v'-2'ater noster qui est
in caelis ...
A minus sign causes upward motion, while
no sign or a plus sign means down the page.
Thus
\v'-2'causes an upward vertical motion
of two line spaces.

      There are many other ways to specify the amount of motion _ \v'0.1i'
\v'3p'
\v'-0.5m'
and so on are all legal.
Notice that the scale specifier
ior
por
mgoes inside the quotes.
Any character can be used in place of the quotes;
this is also true of all other
troff
commands described in this section.

      Since troff does not take within-the-line vertical motions into account when figuring out where it is on the page, output lines can have unexpected positions if the left and right ends aren't at the same vertical position. Thus \vlike \uand \dshould always balance upward vertical motion in a line with the same amount in the downward direction.

      Arbitrary horizontal motions are also available _ \his quite analogous to \vexcept that the default scale factor is ems instead of line spaces. As an example, \h'-0.1i'
causes a backwards motion of a tenth of an inch.
As a practical matter, consider printing the mathematical symbol
`>>'.
The default spacing is too wide, so
eqn
replaces this by
>\h'-0.3m'>
to produce >>.

      Frequently \his used with the `width function' \wto generate motions equal to the width of some character string. The construction \w'thing'
is a number equal to the width of `thing' in machine units
(1/432 inch).
All
troff
computations are ultimately done in these units.
To move horizontally the width of an `x',
we can say
\h'\w'x'u'
As we mentioned above,
the default scale factor for
all horizontal dimensions is
mems, so here we must have the
ufor machine units,
or the motion produced will be far too large.
troff
is quite happy with the nested quotes, by the way,
so long as you don't leave any out.

      As a live example of this kind of construction, all of the command names in the text, like .spwere done by overstriking with a slight offset. The commands for .spare ^sp\h'-\w'.sp'u'\h'1u'.sp
That is, put out `.sp', move left by the width of `.sp',
move right 1 unit, and print
`.sp' again.
(Of course there is a way to avoid typing that much input
for each command name, which we will discuss in Section 11.)

      There are also several special-purpose troff commands for local motion. We have already seen \0which is an unpaddable white space of the same width as a digit. `Unpaddable' means that it will never be widened or split across a line by line justification and filling. There is also \which is an unpaddable character the width of a space, \|which is half that width, \^which is one quarter of the width of a space, and \&which has zero width. (This last one is useful, for example, in entering a text line which would otherwise begin with a `.'.)

      The command \oused like \o'set of characters'
causes (up to 9)
characters to be overstruck,
centered on the widest.
This is nice for accents, as in
syst\o"e\(ga"me t\o"e\(aa"l\o"e\(aa"phonique
which makes
syste`me te'le'phonique
The accents are
\(gaand
\(aaor
\`and
\'remember that each is just one character to
troff.

      You can make your own overstrikes with another special convention, \zthe zero-motion command. \zxsuppresses the normal horizontal motion after printing the single character xso another character can be laid on top of it. Although sizes can be changed within \oit centers the characters on the widest, and there can be no horizontal or vertical motions, so \zmay be the only way to get what you want:
oooo
is produced by
^sp 2
\s8\z\(sq\s14\z\(sq\s22\z\(sq\s36\(sq
The
.spis needed to leave room for the result.

      As another example, an extra-heavy semicolon that looks like ,. instead of ; or ;
can be constructed with a big comma and a big period above it:
\s+6\z,\v'-0.25m'.\v'0.25m'\s0
`0.25m' is an empirical constant.

      A more ornate overstrike is given by the bracketing function \bwhich piles up characters vertically, centered on the current baseline. Thus we can get big brackets, constructing them with piled-up smaller pieces:
b b x b b

by typing in only this:
^sp
\b'\(lt\(lk\(lb' \b'\(lc\(lf' x \b'\(rc\(rf' \b'\(rt\(rk\(rb'

      troff also provides a convenient facility for drawing horizontal and vertical lines of arbitrary length with arbitrary characters. \l'1i'draws a line one inch long, like this: __________. The length can be followed by the character to use if the _ isn't appropriate; \l'0.5i.'draws a half-inch line of dots: ...... The construction \Lis entirely analogous, except that it draws a vertical line instead of horizontal.