Next: , Previous: , Up: gtroff Reference   [Contents][Index]


5.9 Manipulating Spacing

Request: .sp [distance]

Space downwards distance. With no argument it advances 1 line. A negative argument causes gtroff to move up the page the specified distance. If the argument is preceded by a ‘|’ then gtroff moves that distance from the top of the page. This request causes a line break, and that adds the current line spacing to the space you have just specified. The default scaling indicator is ‘v’.

For convenience you may wish to use the following macros to set the height of the next line at a given distance from the top or the bottom of the page:

.de y-from-top-down
.  sp |\\$1-\\n[.v]u
..
.
.de y-from-bot-up
.  sp |\\n[.p]u-\\$1-\\n[.v]u
..

A call to ‘.y-from-bot-up 10c’ means that the bottom of the next line will be at 10cm from the paper edge at the bottom.

If a vertical trap is sprung during execution of sp, the amount of vertical space after the trap is discarded. For example, this

.de xxx
..
.
.wh 0 xxx
.
.pl 5v
foo
.sp 2
bar
.sp 50
baz

results in

foo


bar

baz

The amount of discarded space is available in the number register .trunc.

To protect sp against vertical traps, use the vpt request:

.vpt 0
.sp -3
.vpt 1
Request: .ls [nnn]
Register: \n[.L]

Output nnn-1 blank lines after each line of text. With no argument, gtroff uses the previous value before the last ls call.

.ls 2    \" This causes double-spaced output
.ls 3    \" This causes triple-spaced output
.ls      \" Again double-spaced

The line spacing is associated with the current environment (see Environments).

The read-only number register .L contains the current line spacing setting.

See Changing Type Sizes, for the requests vs and pvs as alternatives to ls.

Escape: \x'spacing'
Register: \n[.a]

Sometimes, extra vertical spacing is only needed occasionally, e.g. to allow space for a tall construct (like an equation). The \x escape does this. The escape is given a numerical argument, usually enclosed in quotes (like ‘\x'3p'’); the default scaling indicator is ‘v’. If this number is positive extra vertical space is inserted below the current line. A negative number adds space above. If this escape is used multiple times on the same line, the maximum of the values is used.

See Escapes, for details on parameter delimiting characters.

The .a read-only number register contains the most recent (nonnegative) extra vertical line space.

Using \x can be necessary in combination with the \b escape, as the following example shows.

This is a test with the \[rs]b escape.
.br
This is a test with the \[rs]b escape.
.br
This is a test with \b'xyz'\x'-1m'\x'1m'.
.br
This is a test with the \[rs]b escape.
.br
This is a test with the \[rs]b escape.

produces

This is a test with the \b escape.
This is a test with the \b escape.
                    x
This is a test with y.
                    z
This is a test with the \b escape.
This is a test with the \b escape.
Request: .ns
Request: .rs
Register: \n[.ns]

Enable no-space mode. In this mode, spacing (either via sp or via blank lines) is disabled. The bp request to advance to the next page is also disabled, except if it is accompanied by a page number (see Page Control, for more information). This mode ends when actual text is output or the rs request is encountered, which ends no-space mode. The read-only number register .ns is set to 1 as long as no-space mode is active.

This request is useful for macros that conditionally insert vertical space before the text starts (for example, a paragraph macro could insert some space except when it is the first paragraph after a section header).


Next: , Previous: , Up: gtroff Reference   [Contents][Index]