323 325




Linux Unleashed, Third Edition:groff





-->















Previous
Table of Contents
Next




Fonts
Changing fonts requires the command .ft (font type). In the early days of troff, only four fonts were supported: Roman, Roman bold, Roman italic, and a set of special characters. Other fonts had to be specially loaded in the phototypesetter. For this reason, groff defaults to Roman.
To switch to Roman bold, use the command .ft B, while .ft I switches, not surprisingly, to Roman italic. To return to the normal Roman font, the command .ft R is used, although on most systems, .ft by itself will suffice:


This is in normal Roman font.
.ft B
This is bold.
.ft I
This is italic.
.ft
This is back to normal Roman font.


You can switch fonts with a line-embedded command, too, using \f followed by either I or B, switching back to the normal font with R:


This is normal, \fBbold\fR and \fIitalics\fR.


Since underline wasn’t supported on most system printers, underlined text was converted to italic. The underline command .ux would italicize the next x lines of text.
Because we now have many more fonts to work with than Roman, we must be able to change fonts within groff. The command to change fonts is .fp (font physically mounted), which also requires a number to indicate the position the font was mounted in the phototypesetter (old stuff, isn’t it?). For example, if Helvetica was mounted in font position three and we referred to it by the font letter H, the command


.fp 3 H


would instruct the phototypesetter to switch to Helvetica in font position three. groff still retains these old-style commands.
Indenting and Line Length
The line length is set to default to 6.5 inches within groff. To override this value, the .ll (line length) command is used with an argument indicating the units. For example, the command


.ll 7i


switches groff to use a seven-inch line length. The maximum length accepted is usually about 7.5 inches, so to use wider paper than that you have to move the left margin over to compensate with the .po (page offset) command. The value .po 0 sets the left margin as far over as possible.
To indent text, you use the .in (indent) command. It takes a number and an indicator of the units as arguments, as the following example shows:


This is normal stuff.
.in 0.75I
This is indented three-quarters of an inch.


To move the right margin to the left so that you can make a distinctive block of text within a normal chunk, use the .ll (line length) command shown earlier:


This is normal text, and goes on and on.
Even more text that continues the transition.
.in 1i
.ll -1i
This is now indented one inch to the left, and the
right margin is indented one inch from the normal right
margin. This makes the text stand out a little.
.in -1i
.ll +1i
And this is back to normal. The block will stand out nicely
amongst all this normal text.


Notice that in this example relative movements of plus and minus a value are used to make it easier. This way, we don’t have to measure the page. To revert to original values, use the commands .in and .ll with no arguments, as well.
An indent and line-length change is effective until the next command changes it. Sometimes you want to affect only a single line, though. If you want to indent only a single line, use the .ti (temporary indent) command:


This is really fine stuff. You can tell, ’cause I’m
still awake.
.ti 3i
This line is temporarily indented by three inches, but the
next line will be back to normal.


Tabs are used to set column output. Usually, tabs are used with groff only for unfilled text, which is material that displays in columns. Tab stops are set, by default, every half inch. To override these values, use the .ta (tab) command. The command


.ta 1i 2i 3i 4i 5i 6i


sets the tabs at every inch instead. You can think of the setting of tabs within groff much as they are done on a typewriter, from left to right. Tabs are usually set for columns of numbers or tables, but the groff macro gtbl is much better at this. (You get a look at gtbl in the next chapter.)
Other Character Controls
The groff system has special instructions for controlling the size of individual letters, as well as formulas and special characters such as Greek letters. However, because it is unlikely groff is used for this type of output these days, we’ll ignore those capabilities. If you want more information on how to provide these special features, check the groff man pages or consult a good troff book.
Macros
A macro is a shorthand notation for a set of commands or strings. Many commands used to write man pages are macros. To give a practical example of a groff macro, suppose we want every paragraph to start with a blank line and a temporary indent of half an inch. The groff commands to do this are


.sp
.ti +.5i


Instead of typing these two lines every paragraph, we can define a macro of one character (or more) that does it for us.

To define the macro, we use the .de (define) command followed by the name of the macro and the commands. It looks like this, placed somewhere at the top of the source code:


.de PP
.sp
.ti +.5I
..


The last line with two periods indicates the end of the definition. Now, whenever we use the command .PP, it will be executed as the lines in the macro.

Note:  Make sure that you don’t define a macro with the name of a reserved groff command, or the macro will not be executed.






Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
323 325
324 325
21 (323)
323 326
322 325
bizuteria;slubna,kategoria,323
AMP E 323

więcej podobnych podstron