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.Ais set to1. 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
.ssrequest) is not represented. - A special character is rendered as its identifier between angle brackets; for example, a hyphen appears as โ
<hy>โ.
- Page breaks are marked by a phrase in angle brackets; for example, โ
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 oftroff's input parser to the standard error stream with each diagnostic message. The line numbers given in the backtrace might not always be correct, becausetroff's idea of line numbers can be confused by requests that append to macros ๐ซ .-cโ disable multi-color output and thecolorrequest's ability to enable it.-Cโ enable AT&Ttroffcompatibility mode; implies-c. Seegroff_diff(7).-d ctext,-d string=textโ define roff stringcorstringastext.cmust be a one-character identifier;stringcan be of arbitrary length. Such assignments happen before any macro file is loaded, including the startup file. Due togetopt_long(3)limitations,ccannot be, andstringcannot contain, an equals sign, even though that is a valid character in a roff identifier ๐.-Eโ inhibittrofferror messages; implies-Ww. This option does not suppress messages sent to the standard error stream by documents or macro packages usingtmor related requests.-f famโ usefamas the default font family ๐.-F dirโ search in directorydirfor the selected output device's directory of device and font description files. See the description ofGROFF_FONT_PATHin 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 directorydirfor files (those named on the command line; inpsbb,so, andsoquietrequests; and in โ\X'ps: import'โ, โ\X'ps: file'โ, and โ\X'pdf: pdfpic'โ device extension escape sequences).-Imay be specified more than once; eachdiris searched in the given order. To search the current working directory before others, add โ-I .โ at the desired place; it is otherwise searched last.-Iworks similarly to, and is named for, the โincludeโ option of Unix C compilers ๐.-m macโ search for the macro packagemac.tmacand read it prior to any input. If not found,tmac.macis attempted. See the description ofGROFF_TMAC_PATHin section โEnvironmentโ below for the default search locations and ordering.-M dirโ search directorydirfor macro files. See the description ofGROFF_TMAC_PATHin section โEnvironmentโ below for the default search locations and ordering.-n numโ begin numbering pages atnum. The default is1.-o listโ output only pages inlist, which is a comma-separated list of inclusive page ranges;nmeans pagen,m-nmeans every page betweenmandn,-nmeans every page up ton, andn-means every page fromnon.troffstops processing and exits after formatting the last page enumerated inlist๐.-r cnumeric-expression,-r register=numeric-expressionโ define roff registercorregisterasnumeric-expression.cmust be a one-character identifier;registercan be of arbitrary length. Such assignments happen before any macro file is loaded, including the startup file. Due togetopt_long(3)limitations,ccannot be, andregistercannot contain, an equals sign, even though that is a valid character in a roff identifier.-Rโ prevent loading oftroffrcandtroffrc-end; this option can be useful for troubleshooting ๐ง.-Sโ enable safer mode and ignore any subsequent-Uoption.-T devโ prepare output for devicedev. The default isps; seegroff(1).-Uโ operate in unsafe mode, enabling thecf,open,opena,pi,pso, andsyrequests, which are disabled by default because they allow an untrusted input document to run arbitrary commands, put arbitrary content intotroffoutput, or write to arbitrary file names. (GNUtroffdoes 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-mand-Moptions 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 categorycat. See section โWarningsโ below.-W catโ inhibit warnings in categorycat. 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(code4) โ 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]. GNUtroffreports the amount of overset or underset in the scaling unit configured by thewarnscalerequest in troff mode, and in ens (โnโ; character cells) in nroff mode. This category is enabled by default.char(code1) โ 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(code524288) โ 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(code8) โ 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(code256) โ adi,da,box, orboxarequest was invoked without an argument when there was no current diversion.escape(code32768) โ an unsupported escape sequence was encountered.file(code1048576) โ 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(code131072) โ a non-existent font was selected. This category is enabled by default.ig(code262144) โ an invalid escape sequence occurred in input ignored using theigrequest. This warning category diagnoses a condition that is an error when it occurs in non-ignored input.input(code16384) โ an invalid character occurred on the input stream.mac(code512) โ 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,troffissues at most one warning for each.troffalso 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(code8192) โ a request was invoked with a mandatory argument absent.range(code64) โ a numeric expression was out of range for its context.reg(code1024) โ an undefined register was used. When an undefined register is dereferenced, the formatter automatically defines it with a value of0. So, unless it is later deleted, GNUtroffissues at most one warning for each.scale(code32) โ a scaling unit inappropriate to its context was used in a numeric expression.space(code65536) โ 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(code128) โ 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(code2048) โ 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 exceptdi,mac, andreg. This shorthand is intended to produce all warnings that are useful with macro packages and documents written for AT&Ttroffand its descendants, which have less fastidious diagnostics than GNUtroff.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.troffwill scan directories given as arguments to any specified-Foptions 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.troffwill scan directories given as arguments to any specified-Moptions 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,psis used. The-Toption overridesGROFF_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 usinggmtime(3)andasctime(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; seetzset(3). IfSOURCE_DATE_EPOCHis 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-moptions./usr/share/groff/1.24.2/tmac/troffrc-endโ is an initialization macro file loaded after all macro packages specified with-moptions./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 devicename./usr/share/groff/1.24.2/font/devname/Fโ describes the fontFof devicename.
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 withinfo 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
- alpine 3.24: groff-doc 1.24.2-r0 ยท GPL-3.0-or-later
- Copyright 1989-2024 Free Software Foundation, Inc
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms