troff(1)

๐ŸŒˆ troff(1) ๐ŸŒˆ

General Commands Manual โ€” yes bestie, you found the right page ๐Ÿ’…


๐Ÿ’– NAME ๐Ÿ’–

troff โ€” GNU roff typesetter and document formatter โœจ

โœจ SYNOPSIS โœจ

troff [-abcCEiRSUz] [-d ctext] [-d string=text] [-f font-family]
      [-F font-directory] [-I inclusion-directory] [-m macro-package]
      [-M macro-directory] [-n page-number] [-o page-list] [-r cnumeric-
      expression] [-r register=numeric-expression] [-T output-device]
      [-w warning-category] [-W warning-category] [file ...]

troff --help

troff -v

troff --version

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Okay so GNU troff transforms groff(7) language input into the device-independent page description language detailed in groff_out(5). That means troff is literally the heart of the GNU roff document formatting system ๐Ÿซถ๐Ÿ”ฅ. If there are no file operands, or if file is โ€œ-โ€, 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 groff(1) command, a front end which also runs preprocessors and output drivers in the appropriate order and with appropriate options ๐Ÿ‘‘.


๐Ÿ’… OPTIONS ๐Ÿ’…

  • -h, --help โ€” display a usage message; exits afterward.
  • -v, --version โ€” show version information; exits afterward.
  • -a โ€” generate a plain text approximation of the typeset output. The read-only register .A is set to 1. This option produces a sort of abstract preview of the formatted output ๐Ÿ‘€โœจ.
    • Page breaks are marked by a phrase in angle brackets; for example, โ€œ<beginning of page>โ€.
    • Lines are broken where they would be in formatted output.
    • Vertical motion, apart from that implied by a break, is not represented.
    • A horizontal motion of any size is represented as one space. Adjacent horizontal motions are not combined. Supplemental inter-sentence space (configured by the second argument to the .ss request) is not represented.
    • A special character is rendered as its identifier between angle brackets; for example, a hyphen appears as โ€œ<hy>โ€.
The above description should not be considered a specification; the details of -a output are subject to change. No cap, thatโ€™s literally what the page says ๐Ÿ˜ญ.
  • -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 multi-color output and the color request's ability to enable it.
  • -C โ€” enable AT&T troff compatibility mode; implies -c. See groff_diff(7).
  • -d ctext, -d string=text โ€” define roff string c or string as text. c must be a one-character identifier; string can be of arbitrary length. Such assignments happen before any macro file is loaded, including the startup file. Due to getopt_long(3) 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 โ€œEnvironmentโ€ 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 โ€œ\X'ps: import'โ€, โ€œ\X'ps: file'โ€, and โ€œ\X'pdf: pdfpic'โ€ 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 โ€œ-I .โ€ at the desired place; it is otherwise searched last. -I works similarly to, and is named for, the โ€œincludeโ€ 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 โ€œEnvironmentโ€ 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 โ€œEnvironmentโ€ 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 comma-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 cnumeric-expression, -r register=numeric-expression โ€” define roff register c or register as numeric-expression. c must be a one-character identifier; register can be of arbitrary length. Such assignments happen before any macro file is loaded, including the startup file. Due to getopt_long(3) 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 groff(1).
  • -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.
โš ๏ธ This is the unsafe-mode option, bestie. It is lowkey dangerous for exactly the reasons listed: arbitrary commands, arbitrary content in output, arbitrary file names. Stay safe out there ๐Ÿ’€๐Ÿ’–.
  • -w cat โ€” enable warnings in category cat. See section โ€œWarningsโ€ below.
  • -W cat โ€” inhibit warnings in category cat. See section โ€œWarningsโ€ below.
  • -z โ€” suppress formatted output.

โš ๏ธ Warnings โš ๏ธ

okay bestie, GNU troff does NOT just dump all its warnings into one big blobโ€”it divides them into named, numbered categories, and it's actually kinda iconic. The -w and -W options use these names. Each category is a power of two, and the warn request and the .warn register respectively set and report the sum of enabled category codes. Here's when each category fires:

                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚ Bit   Code   Category โ”‚ Bit    Code     Category โ”‚
                โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
                โ”‚   0      1   char     โ”‚  10      1024   reg      โ”‚
                โ”‚   1      2   unused   โ”‚  11      2048   tab      โ”‚
                โ”‚   2      4   break    โ”‚  12      4096   unused   โ”‚
                โ”‚   3      8   delim    โ”‚  13      8192   missing  โ”‚
                โ”‚   4     16   unused   โ”‚  14     16384   input    โ”‚
                โ”‚   5     32   scale    โ”‚  15     32768   escape   โ”‚
                โ”‚   6     64   range    โ”‚  16     65536   space    โ”‚
                โ”‚   7    128   syntax   โ”‚  17    131072   font     โ”‚
                โ”‚   8    256   di       โ”‚  18    262144   ig       โ”‚
                โ”‚   9    512   mac      โ”‚  19    524288   color    โ”‚
                โ”‚                       โ”‚  20   1048576   file     โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  • break (code 4) โ€” a filled output line couldn't be broken so its length was less than or equal to, or adjusted so its length was exactly equal to, the output line length \n[.l]. GNU troff reports the amount of overset or underset in the scaling unit configured by the warnscale request in troff mode, and in ens (โ€˜nโ€™; character cells) in nroff mode. This category is enabled by default.
  • char (code 1) โ€” no user-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 device-independent output. This category is enabled by default.
  • color (code 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 (code 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 (code 256) โ€” a di, da, box, or boxa request was invoked without an argument when there was no current diversion.
  • escape (code 32768) โ€” an unsupported escape sequence was encountered.
  • file (code 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 (code 131072) โ€” a non-existent font was selected. This category is enabled by default.
  • ig (code 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 non-ignored input.
  • input (code 16384) โ€” an invalid character occurred on the input stream.
  • mac (code 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 (code 8192) โ€” a request was invoked with a mandatory argument absent.
  • range (code 64) โ€” a numeric expression was out of range for its context.
  • reg (code 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 (code 32) โ€” a scaling unit inappropriate to its context was used in a numeric expression.
  • space (code 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 (code 128) โ€” a self-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 (code 2048) โ€” a tab character appeared in a parameterized escape sequence, in an unquoted macro argument, or where a request expected a numeric expression argument.

Two warning names group other warning categories for convenience.

  • 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 command-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 site-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 site-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 human-readable form using gmtime(3) and asctime(3) 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 human-readable form; see tzset(3). If SOURCE_DATE_EPOCH is used, it is always converted to human-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 command-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 Robinson.

โœจ SEE ALSO โœจ

Okay bestie, before you go, here's the whole friend group ๐Ÿ’– โ€” like, the other pages you're gonna want in your tabs while you're deep in troff brainrot:

  • Groff: The GNU Implementation of troff, by Trent A. Fisher and Werner Lemberg โ€” this is the primary groff manual, the main character of the whole documentation situation ๐Ÿ‘‘. You can browse it interactively with info groff, no cap.
  • groff(1) โ€” gives you the big-picture overview of the GNU roff system and describes its front end executable. Start here if you're like "wait, what even is all this" ๐ŸŒ€
  • groff(7) โ€” the groff language deep-dive, including a short but complete reference of all predefined requests, registers, and escape sequences. It's giving cheat-sheet excellence ๐Ÿ”ฅ
  • groff_char(7) โ€” explains the syntax of groff special character escape sequences, and lists all special characters predefined by the language. The emoji-adjacent lore ๐ŸŒธ
  • groff_diff(7) โ€” enumerates the differences between AT&T device-independent troff and groff. For when you need to know what's OG vs. what's GNU ๐Ÿ’…
  • groff_font(5) โ€” covers the format of groff device and font description files. Fonts, but make it file-format spec ๐ŸŽ€
  • groff_out(5) โ€” describes the format of troff's output. Yes, the actual bytes it spits out, we love a transparent pipeline โญ
  • groff_tmac(5) โ€” all the info about macro files that ship with groff. Your macro besties ๐Ÿซถ
  • roff(7) โ€” supplies background on roff systems in general, including pointers to further related documentation. The lore episode ๐ŸŒˆ

And that's the whole page, bestie โ€” you ate that ๐Ÿ’…โœจ This tour was brought to you by groff 1.24.2, dated 2026-10-01, and it's the troff(1) manual page specifically, so go forth and typeset iconically ๐Ÿฆ‹๐Ÿ’œ

๐Ÿ“ฆ where this page comes from