.ds tx TeX
GROFF_DIFF(7) manual page
Table of Contents
groff_diff - differences between GNU troff and classical
troff
This manual page describes the language differences
between groff, the GNU roff text processing system, and the classical roff
formatter of the freely available Unix~7 of the 1970s, documented in the
Troff User’s Manual by Ossanna and Kernighan. This inludes the roff language
as well as the intermediate output format (troff output).
The section SEE
ALSO gives pointers to both the classical roff and the modern groff documentation.
In this section, all additional features of groff compared
to the classical Unix~7 troff are described in detail.
The
names of number registers, fonts, strings/:macros/:diversions, special
characters (glyphs), and colors can be of any length. In escape sequences,
additionally to the classical ‘(xx’ construction for a two-character glyph
name, you can use ‘[xxx]’ for a name of arbitrary length.
- [rs][xxx]
- Print
the special character (glyph) called xxx.
- [rs][comp1 comp2 ...]
- Print composite
glyph consisting of multiple components. Example: ‘[rs][A~ho]’ is capital
letter A with ogonek which finally maps to glyph name ‘u0041_0328’. See the
groff info file for details how a glyph name for a composite glyph is constructed,
and groff_char(7)
for a list of glyph name components used in composite
glyph names.
- [rs]f[xxx]
- Set font xxx. Additionally, [rs]f[] is a new syntax
form equal to [rs]fP, i.e., to return to the previous font.
- [rs]*[xxx arg1
arg2 ...]
- Interpolate string xxx, taking arg1, arg2, ... as arguments.
- [rs]n[xxx]
- Interpolate number register xxx.
A scaled point
is equal to 1/sizescale points, where sizescale is specified in the DESC
file (1 by default). There is a new scale indicator~z that has the effect
of multiplying by sizescale. Requests and escape sequences in troff interpret
arguments that represent a point size as being in units of scaled points,
but they evaluate each such argument using a default scale indicator of~z.
Arguments treated in this way are the argument to the ps request, the third
argument to the cs request, the second and fourth arguments to the tkf
request, the argument to the [rs]H escape sequence, and those variants
of the [rs]s escape sequence that take a numeric expression as their argument.
For example, suppose sizescale is 1000; then a scaled point is equivalent
to a millipoint; the call .ps 10.25 is equivalent to .ps 10.25z and so sets the
point size to 10250 scaled points, which is equal to 10.25 points.
The number
register [rs]n[.s] returns the point size in points as decimal fraction.
There is also a new number register [rs]n[.ps] that returns the point size
in scaled points.
It would make no sense to use the z~scale indicator in
a numeric expression whose default scale indicator was neither u nor~z,
and so troff disallows this. Similarly it would make no sense to use a
scaling indicator other than z or~u in a numeric expression whose default
scale indicator was~z, and so troff disallows this as well.
There is also
new scale indicator~s which multiplies by the number of units in a scaled
point. So, for example, [rs]n[.ps]s is equal to 1m. Be sure not to confuse
the s and z~scale indicators.
Spaces are permitted
in a number expression within parentheses.
M indicates a scale of 100ths
of an em. f indicates a scale of 65536 units, providing fractions for color
definitions with the defcolor request. For example, 0.5f = 32768u.
- e1>?e2
- The maximum of e1 and e2.
- e1<?e2
- The minimum of e1 and e2.
- (c;e)
- Evaluate
e using c as the default scaling indicator. If c is missing, ignore scaling
indicators in the evaluation of~e.
- [rs]A’anything’
- This expands to 1 or~0, depending on whether anything is or is not acceptable
as the name of a string, macro, diversion, number register, environment,
font, or color. It returns~0 if anything is empty. This is useful if you
want to look up user input in some sort of associative table.
- [rs]B’anything’
- This expands to 1 or~0, depending on whether anything is or is not a valid
numeric expression. It returns~0 if anything is empty.
- [rs]C’xxx’
- Typeset
glyph named xxx. Normally it is more convenient to use [rs][xxx]R]. But [rs]C
has the advantage that it is compatible with recent versions of UNIX
and
is available in compatibility mode.
- [rs]E
- This is equivalent to an escape
character, but it is not interpreted in copy mode. For example, strings
to start and end superscripting could be defined like this
- .ds { [rs]v’-.3m’[rs]s’[rs]En[.s]*6u/10u’
- .ds } [rs]s0[rs]v’.3m’
- The use of
- [rs]E ensures that these definitions work
even if [rs]*{ gets interpreted in copy mode (for example, by being used
in a macro argument).
- [rs]Ff
- [rs]F(fm [rs]F[fam] Change font family.
This is the same as the fam request. [rs]F[] switches back to the previous
color (note that [rs]FP won’t work; it selects font family ‘P’ instead).
- [rs]mx
- [rs]m(xx [rs]m[xxx] Set drawing color. [rs]m[] switches back to the previous
color.
- [rs]Mx
- [rs]M(xx [rs]M[xxx] Set background color for filled objects
drawn with the [rs]D’...’ commands. [rs]M[] switches back to the previous color.
- [rs]N’n’
- Typeset the glyph with index~n in the current font. n~can be any
integer. Most devices only have glyphs with indices between 0 and 255.
If the current font does not contain a glyph with that code, special fonts
are not searched. The [rs]N escape sequence can be conveniently used in
conjunction with the char request, for example
- .char [rs][phone] [rs]f(ZD[rs]N’37’
-
- The index of each glyph is given in the fourth column in the font
- description
file after the charset command. It is possible to include unnamed glyphs
in the font description file by using a name of ---; the [rs]N escape sequence
is the only way to use these.
- [rs]On
- [rs]O[n] Suppress troff output. The
escapes [rs]O2, [rs]O3, [rs]O4, and [rs]O5 are intended for internal use
by grohtml.
- [rs]O0
- Disable any ditroff glyphs from being emitted to the
device driver, provided that the escape occurs at the outer level (see
[rs]O3 and [rs]O4).
- [rs]O1
- Enable output of glyphs, provided that the escape
occurs at the outer level.
- [rs]O0
- and [rs]O1 also reset the registers [rs]n[opminx],
[rs]n[opminy], [rs]n[opmaxx], and [rs]n[opmaxy] to~-1. These four registers
mark the top left and bottom right hand corners of a box which encompasses
all written glyphs.
- [rs]O2
- Provided that the escape occurs at the outer
level, enable output of glyphs and also write out to stderr the page number
and four registers encompassing the glyphs previously written since the
last call to [rs]O.
- [rs]O3
- Begin a nesting level. At start-up, troff is
at outer level. This is really an internal mechanism for grohtml while
producing images. They are generated by running the troff source through
troff to the postscript device and ghostscript to produce images in PNG
format. The [rs]O3 escape starts a new page if the device is not html (to
reduce the possibility of images crossing a page boundary).
- [rs]O4
- End
a nesting level.
- [rs]O5[Pfilename]
- This escape is grohtml specific. Provided
that this escape occurs at the outer nesting level, write filename to stderr.
The position of the image, P, must be specified and must be one of l,
r, c, or i (left, right, centered, inline). filename is associated with
the production of the next inline image.
- [rs]R’name [+-]n’
- This has the same
effect as
. -
- [rs]s(nn
- [rs]s[+-](nn Set the point size to nn points; nn must
be exactly two digits.
- [rs]s[[+-]n]
- [rs]s[+-][n] [rs]s’[+-]n’ [rs]s[+-]’n’ Set
the point size to n scaled points; n is a numeric expression with a default
scale indicator of~z.
- [rs]Vx
- [rs]V(xx [rs]V[xxx] Interpolate the contents
of the environment variable xxx, as returned by getenv(3)
. [rs]V is interpreted
in copy mode.
- [rs]Yx
- [rs]Y(xx [rs]Y[xxx] This is approximately equivalent
to [rs]X’[rs]*[xxx]’R]. However the contents of the string or macro xxx are
not interpreted; also it is permitted for xxx to have been defined as a
macro and thus contain newlines (it is not permitted for the argument to
[rs]X to contain newlines). The inclusion of newlines requires an extension
to the UNIX troff output format, and confuses drivers that do not know
about this extension.
- [rs]Z’anything’
- Print anything and then restore the
horizontal and vertical position; anything may not contain tabs or leaders.
- [rs]$0
- The name by which the current macro was invoked. The als request
can make a macro have more than one name.
- [rs]$*
- In a macro or string,
the concatenation of all the arguments separated by spaces.
- [rs]$@
- In a
macro or string, the concatenation of all the arguments with each surrounded
by double quotes, and separated by spaces.
- [rs]$^
- In a macro, the representation
of all parameters as if they were an argument to the ds request.
- [rs]$(nn
- [rs]$[nnn] In a macro or string, this gives the nn-th or nnn-th argument.
Macros and strings can have an unlimited number of arguments.
- [rs]?anything[rs]?
- When used in a diversion, this transparently embeds anything in the diversion.
anything is read in copy mode. When the diversion is reread, anything is
interpreted. anything may not contain newlines; use [rs]! if you want to
embed newlines in a diversion. The escape sequence [rs]? is also recognized
in copy mode and turned into a single internal code; it is this code that
terminates anything. Thus
- .nr x 1
- .nf .di d [rs]?[rs][rs]?[rs][rs][rs][rs]?[rs][rs][rs][rs][rs][rs][rs][rs]nx[rs][rs][rs][rs]?[rs][rs]?[rs]?
.di .nr x 2 .di e .d .di .nr x 3 .di f .e .di .nr x 4 .f
- prints~4.
-
- [rs]/
- This increases
the width of the preceding glyph so that the spacing between that glyph
and the following glyph is correct if the following glyph is a roman glyph.
Table of Contents