UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: 12.2 Command-line InvocationChapter 12
Nroff and Troff
Next: 12.4 Default Operation of Requests
 

12.3 Using the Requests: An Overview

Formatting is specified by embedding brief codes into the text source file. These codes act as directives to nroff and troff when they are invoked. For example, to center a line of text, type the following code in a file:

 .ce
This text should be centered.

When formatted, the output appears centered:

 .ce
This text should be centered.

There are two types of formatting codes:

Requests, also known as primitives, allow direct control of almost any feature of page layout and formatting. Macros combine requests to create a total effect. In a sense, requests are like atoms, and macros are like molecules.

See Sections 13, 14, and 15 for more information on macros.

12.3.1 Common Requests

The most commonly used requests are:

 .ad   .ds   .ll   .nr   .sp
 .br   .fi   .na   .po   .ta
 .bp   .ft   .ne   .ps   .ti
 .ce   .in   .nf   .so   .vs
 .de   .ls

For example, a simple macro could be written as follows:

.ta 1.2i
.	\" Ps macro - show literal text display
.de Ps	\" Define a macro named "Ps"
.sp .5	\" Space down half a line
.in 1i	\" Indent one inch
.ta 10n +10n	\" Set new tabstops
.ps 8	\" Use 8-point type
.vs 10	\" Use 10-point vertical spacing
.ft CW	\" Use constant width font
.br		\" Break line (.ne begins count on next line)
.ne 3	\" Keep 3 lines together
.nf	\" No-fill mode (output lines as is)
..	\" End macro definition

12.3.2 Specifying Measurements

With some requests, the numeric argument can be followed by a scale indicator that specifies a unit of measurement. The valid indicators and their meanings are listed below. Note that all measurements are internally converted to basic units (this conversion is shown in the last column). A basic unit is the smallest possible size on the printer device. The device resolution (e.g., 300 dots per inch), determines the size of a basic unit. In the following table, T specifies the current point size and R specifies the device resolution.

ScaleMeaningEquivalentNumber of
IndicatorUnitBasic Units
cCentimeter2.54 inchesR / 2.54
iInch6 picas or 72 pointsR
mEmT pointsR × T / 72
nEn0.5 emR × T / 144
pPoint1/72 inchR / 72
PPica1/6 inchR / 6
uBasic unit1
vVertical line space(Current value in basic units)
NoneDefault

You can specify a scale indicator for any of the requests below, except for .ps, which always uses points. If no unit is given, the default unit is used. (The second column lists the scale indicators as described in the previous table.) For horizontally oriented requests, the default unit is ems. For vertically oriented requests, the default is usually vertical lines.

RequestDefaultRequestDefault
ScaleScale
.chv.plv
.dtv.pov
.ieu.psp
.ifu.rtv
.inm.spv
.llm.svv
.ltm.tam
.mcm.tim
.nev.vsp
.nru.whv

12.3.3 Requests That Cause a Line Break

Most requests can be interspersed with text without causing a line break in the output. The following requests cause a break:

.bp   .ce   .fi   .in   .sp
.br   .cf   .fl   .nf   .ti

If you need to prevent these requests from causing a break, begin them with the "no break" character (normally ') instead of a dot (.). For example, .sp takes effect right away, but 'sp waits until the output line is completely filled. Only then does it add a line space.


Previous: 12.2 Command-line InvocationUNIX in a Nutshell: System V EditionNext: 12.4 Default Operation of Requests
12.2 Command-line InvocationBook Index12.4 Default Operation of Requests

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System