This chapter discusses a variety of formatter requests that you can use to draw figures and achieve special effects like overstriking and vertically stacked text. It also dissects some of the most complex macros we’ve seen so far, so it should advance your knowledge of how to write macros as well as your knowledge of its explicit subject matter.
Preprocessors like tbl
and pic
draw boxes, lines, and simple figures using an underlying library of formatter escape sequences that you can also use directly. The eqn
preprocessor also uses many of these escape sequences, as well as others that are more appropriate for creating special effects with text characters.
The escape sequences are listed in Table 15-1. As you can see, there are quite a few! Fortunately, many of these need not be learned by the average user. The various preprocessors often allow a user to achieve the same effect more easily. Although tbl
or eqn
might seem difficult to learn, they are far simpler than the formatter commands they replace. For example, an eqn
construct like 10%
sup 5%
is easier to learn and type than an equivalent troff
construct like:
10s-3v'-3p'5v'3p's0
When it comes to drawing lines and figures, things get even more complex.
For this reason, many of the escape sequences we are about to discuss are not often used by the average person trying to achieve special effects. However, they are extremely useful to a developer of macros.
In this chapter, we’ll cover the sequences for local vertical and horizontal motions and line drawing, because these requests are most commonly used in macros. In addition, we will show several large macros that do line drawing in order to demonstrate both the use of escape sequences and techniques for writing complex macros.
Escape | Description |
---|---|
v' distance′ |
Move distance vertically down the page. Precede distance with a minus sign to move back up the page. |
h' distance′ |
Move distance horizontally to the right. Precede distance with a minus sign to move back to the left. |
u |
Move ½ em up (½ line in nroff ). |
d |
Move ½ em down (½ line in nroff ). |
|
Move 1 em up (1 line in nroff ). |
c |
Join next line to current output line, even across a break. |
P |
Cause a break, and adjust current partial output line. |
x' distance′ |
Add extra line space for oversize characters. |
(space) | Move right one space (distance determined by .ss ). |