www.LinuxHowtos.org
%troff
Section: User Commands (1)Updated: 202-0-28
Index Return to Main Contents
Name
troff - GNU roff typesetter and document formatter.nr d-fallback 1
.nr d-fallback 1
Synopsis
[-abcCEiRSUz] [-d~ctext] [-d~string=text] [-f~fon-family] [-F~fon-directory] [-I~inclusio-directory] [-m~macr-package] [-M~macr-directory] [-n~pag-number] [-o~pag-list] [-r~cnumeri-expression] [-r~register=numeri-expression] [-T~outpu-device] [-w~warnin-category] [-W~warnin-category] [file~...] --help -v --versionDescription
GNU troff transforms language input into the devic-independent page description language detailed in troff is thus the heart of the GNU roff document formatting system. If no file operands are present, or if file is [lq]-[rq], troff reads the standard input stream. GNU troff is functionally compatible with the AT&T troff typesetter and features numerous extensions. Many people prefer to use the command, a front end which also runs preprocessors and output drivers in the appropriate order and with appropriate options.Options
-h and --help display a usage message, while -v and --version show version information; all exit afterward.- -a
-
Generate a plain text approximation of the typeset output.
The rea-only register
.A
is set to~1.
This option produces a sort of abstract preview of the formatted output.
-
- [bu]
- Page breaks are marked by a phrase in angle brackets; for example, [lq]<beginning of page>[rq].
- [bu]
- Lines are broken where they would be in formatted output.
- [bu]
- Vertical motion, apart from that implied by a break, is not represented.
- [bu]
- A horizontal motion of any size is represented as one space. Adjacent horizontal motions are not combined. Supplemental inte-sentence space (configured by the second argument to the .ss request) is not represented.
- [bu]
- A special character is rendered as its identifier between angle brackets; for example, a hyphen appears as [lq]<hy>[rq].
-
- The above description should not be considered a specification; the details of -a output are subject to change.
- -b
- Write a backtrace reporting the state of troff's input parser to the standard error stream with each diagnostic message. The line numbers given in the backtrace might not always be correct, because troff's idea of line numbers can be confused by requests that append to macros.
- -c
- Disable mult-color output and [lq]color[rq] request's ability to enable it.
- -C
- Enable AT&T troff compatibility mode; implies -c. See
- -d~ctext
- -d~string=text Define roff string~c or string as text. c~must be a on-character identifier; string can be of arbitrary length. Such assignments happen before any macro file is loaded, including the startup file. Due to limitations, c~cannot be, and string cannot contain, an equals sign, even though that is a valid character in a roff identifier.
- -E
- Inhibit troff error messages; implies -Ww. This option does not suppress messages sent to the standard error stream by documents or macro packages using tm or related requests.
- -f~fam
- Use fam as the default font family.
- -F~dir
- Search in directory dir for the selected output device's directory of device and font description files. See the description of GROFF_FONT_PATH in section [lq]Environment[rq] below for the default search locations and ordering.
- -i
- Read the standard input stream after all named input files have been processed.
- -I~dir
- Search the directory dir for files (those named on the command line; in psbb, so, and soquiet requests; and in [lq][rs]X[aq]ps: import[aq][rq], [lq][rs]X[aq]ps: file[aq][rq], and [lq][rs]X[aq]pdf: pdfpic[aq][rq] device extension escape sequences). -I may be specified more than once; each dir is searched in the given order. To search the current working directory before others, add [lq]-I .[rq] at the desired place; it is otherwise searched last. -I works similarly to, and is named for, the [lq]include[rq] option of Unix C compilers.
- -m~mac
- Search for the macro package mac.tmac and read it prior to any input. If not found, tmac.mac is attempted. See the description of GROFF_TMAC_PATH in section [lq]Environment[rq] below for the default search locations and ordering.
- -M~dir
- Search directory dir for macro files. See the description of GROFF_TMAC_PATH in section [lq]Environment[rq] below for the default search locations and ordering.
- -n~num
- Begin numbering pages at num. The default is~1.
- -o~list
- Output only pages in list, which is a comm-separated list of inclusive page ranges; n means page n, m-n means every page between~m and~n, -n means every page up to~n, and n- means every page from n~on. troff stops processing and exits after formatting the last page enumerated in list.
- -r~cnumeri-expression
- -r~register=numeri-expression Define roff register~c or register as numeri-expression. c~must be a on-character identifier; register can be of arbitrary length. Such assignments happen before any macro file is loaded, including the startup file. Due to limitations, c~cannot be, and register cannot contain, an equals sign, even though that is a valid character in a roff identifier.
- -R
- Prevent loading of troffrc and troffrc-end; this option can be useful for troubleshooting.
- -S
- Enable safer mode and ignore any subsequent -U option.
- -T~dev
- Prepare output for device dev. The default is ps; see
- -U
- Operate in unsafe mode, enabling the cf, open, opena, pi, pso, and sy requests, which are disabled by default because they allow an untrusted input document to run arbitrary commands, put arbitrary content into troff output, or write to arbitrary file names. (GNU troff does not, however, accept newlines (line feeds) in file names supplied as arguments to requests.) This option also adds the current directory to the macro package search path; see the -m and -M options above.
- -w~cat
- -W~cat Enable and inhibit, respectively, warnings in category cat. See section [lq]Warnings[rq] below.
- -z
- Suppress formatted output.
Warnings
GNU troff divides its warning diagnostics into named, numbered categories. The -w and -W options use the associated names. A power of two characterizes each category; the warn request and the .warn register respectively set and report the sum of enabled category codes. Warnings of each category are produced under the following circumstances.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break | 4 |
A filled output line could not be
broken such that its length was less than or equal to,
or
adjusted such that its length was exactly equal to,
the output line length
[lq][rs]n[.l][rq].
GNU
troff reports the amount of overset or underset in the scaling unit configured
by the
warnscale
request in
troff mode,
and in ens
([oq]n[cq];
character cells)
in
nroff mode.
This category is enabled by default.
|
| char | 1 |
No use-defined character of the requested name or index exists
and no mounted font defines a glyph for it,
or input could not be encoded for devic-independent output.
This category is enabled by default.
|
| color | 524288 |
An undefined color name was selected,
an attempt was made to define a color using an unrecognized color space,
an invalid channel value in a color definition was encountered,
or an attempt was made to redefine a default color.
|
| delim | 8 |
The selected delimiter character was ambiguous
because it is also meaningful when beginning a numeric expression,
or
the closing delimiter in an escape sequence was missing or mismatched.
A future
groff
release may reject ambiguous delimiters.
In compatibility mode,
ambiguous delimiters are accepted without warning.
|
| di | 256 |
A
di,
da,
box,
or
boxa
request was invoked without an argument when there was no current
diversion.
|
| escape | 32768 |
An unsupported escape sequence was encountered.
|
| file | 1048576 |
An attempt was made to read a file that does not exist.
or a stream remained open at formatter exit.
This category is enabled by default.
|
| font | 131072 |
A no-existent font was selected.
This category is enabled by default.
|
| ig | 262144 |
An invalid escape sequence occurred in input ignored using the
ig
request.
This warning category diagnoses a condition that is an error when it
occurs in no-ignored input.
|
| input | 16384 |
An invalid character occurred on the input stream.
|
| mac | 512 |
An undefined string,
macro,
or diversion was used.
When such an object is dereferenced,
an empty one of that name is automatically created.
So,
unless it is later deleted,
troff
issues at most one warning for each.
troff
also uses this category to warn of an attempt to move an unplanted trap
macro.
In such cases,
the unplanted macro is
not
dereferenced,
so it is not created if it does not exist.
|
| missing | 8192 |
A request was invoked with a mandatory argument absent.
|
| range | 64 |
A numeric expression was out of range for its context.
|
| reg | 1024 |
An undefined register was used.
When an undefined register is dereferenced,
the formatter automatically defines it with a value of~0.
So,
unless it is later deleted,
GNU
troff issues at most one warning for each.
|
| scale | 32 |
A scaling unit inappropriate to its context was used in a numeric
expression.
|
| space | 65536 |
A space was missing between a request or macro and its argument.
This warning is produced when an undefined name longer than two
characters is encountered and the first two characters of the name
constitute a defined name.
No request is invoked,
no macro called,
and an empty macro is not defined.
This category is enabled by default.
It never occurs in compatibility mode.
|
| syntax | 128 |
A sel-contradictory hyphenation mode or character flags were requested;
an empty or incomplete numeric expression was encountered;
an operand to a numeric operator was missing;
an attempt was made to format characters or spaces on an input line
after an output line continuation escape sequence;
a recognized but inapposite escape sequence
or unprintable character code
was used in a device extension command;
an attempt was made to define a recursive,
empty,
or nonsensical character class;
or a
groff
extension escape sequence
or conditional expression operator
was used while in compatibility mode.
|
| tab | 2048 |
A tab character appeared
in a parameterized escape sequence,
in an unquoted macro argument,
or where a request expected a numeric expression argument.
|
- all
- All warning categories except di, mac, and reg. This shorthand is intended to produce all warnings that are useful with macro packages and documents written for AT&T troff and its descendants, which have less fastidious diagnostics than GNU troff.
- w
- All warning categories. Authors of documents and macro packages targeting groff are encouraged to use this setting.
Exit status
troff exits with status~0 on successful operation, status~2 if the program cannot interpret its comman-line arguments, and status~1 if it encounters a fatal error during operation, or is directed to abort by the input.Environment
GROFF_FONT_PATH and GROFF_TMAC_PATH each accept a search path of directories; that is, a list of directory names separated by the system's path component separator character. On Unix systems, this character is a colon (:); on Windows systems, it is a semicolon (;).- GROFF_FONT_PATH
- A list of directories in which to seek the selected output device's directory of device and font description files. troff will scan directories given as arguments to any specified -F options before these, then in a sit-specific directory (/usr/:share/:groff/:site-font), a standard location (/usr/:share/:groff/:1.24.2/:font), and a compatibility directory (/usr/:lib/:font) after them.
- GROFF_TMAC_PATH
- A list of directories in which to search for macro files. troff will scan directories given as arguments to any specified -M options before these, then the current directory (only if in unsafe mode), the user's home directory, a sit-specific directory (/usr/:share/:groff/:site-tmac), and a standard location (/usr/:share/:groff/:1.24.2/:tmac) after them.
- GROFF_TYPESETTER
- Set the default output device. If empty or not set, ps is used. The -T option overrides GROFF_TYPESETTER.
- SOURCE_DATE_EPOCH
- A timestamp (expressed as seconds since the Unix epoch) to use as the output creation timestamp in place of the current time. The time is converted to huma-readable form using and when the formatter starts up and stored in registers usable by documents and macro packages.
- TZ
- The time zone to use when converting the current time to huma-readable form; see If SOURCE_DATE_EPOCH is used, it is always converted to huma-readable form using UTC.
Files
- /usr/:share/:groff/:1.24.2/:tmac/:troffrc
- is an initialization macro file loaded before any macro packages specified with -m options.
- /usr/:share/:groff/:1.24.2/:tmac/:troffrc-end
- is an initialization macro file loaded after all macro packages specified with -m options.
- /usr/:share/:groff/:1.24.2/:tmac/:name:.tmac
- are macro files distributed with groff.
- /usr/:share/:groff/:1.24.2/:font/:devname/:DESC
- describes the output device name.
- /usr/:share/:groff/:1.24.2/:font/:devname/F
- describes the font F of device name. troffrc and troffrc-end are sought neither in the current nor the home directory by default for security reasons, even if the -U option is specified. Use the -M comman-line option or the GROFF_TMAC_PATH environment variable to add these directories to the search path if necessary.
Authors
The GNU version of troff was originally written by James Clark; he also wrote the original version of this document, which was updated by Werner Lemberg Bernd Warken and G. Branden RobinsonSee also
Groff: The GNU Implementation of troff, by Trent A. Fisher and Werner Lemberg, is the primary groff manual. You can browse it interactively with [lq]info groff[rq].- offers an overview of the GNU roff system and describes its front end executable.
- details the groff language, including a short but complete reference of all predefined requests, registers, and escape sequences.
- explains the syntax of groff special character escape sequences, and lists all special characters predefined by the language.
- enumerates the differences between AT&T devic-independent troff and groff.
- covers the format of groff device and font description files.
- describes the format of troff's output.
- includes information about macro files that ship with groff.
-
supplies background on
roff
systems in general,
including pointers to further related documentation.