home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: 12.2 Command-line Invocation Chapter 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 , which provide the most elementary instructions, and

  • Macros , which are predefined combinations of requests.

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.

Scale Meaning Equivalent Number of
Indicator Unit Basic Units
c Centimeter 2.54 inches R / 2.54
i Inch 6 picas or 72 points R
m Em T points R × T / 72
n En 0.5 em R × T / 144
p Point 1/72 inch R / 72
P Pica 1/6 inch R / 6
u Basic unit 1
v Vertical line space (Current value in basic units)
None Default

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.

Request Default Request Default
Scale Scale
.ch v .pl v
.dt v .po v
.ie u .ps p
.if u .rt v
.in m .sp v
.ll m .sv v
.lt m .ta m
.mc m .ti m
.ne v .vs p
.nr u .wh v

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 Invocation UNIX in a Nutshell: System V Edition Next: 12.4 Default Operation of Requests
12.2 Command-line Invocation Book Index 12.4 Default Operation of Requests

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