# man > troff(1)

> **TLDR:** Typesetting processor for the groff (GNU Troff) document formatting system.
>
- Format output for a PostScript printer, saving the output to a file:
  `troff {{path/to/input.roff}} | grops > {{path/to/output.ps}}`
- Format output for a PostScript printer using the me macro package, saving the output to a file:
  `troff -{{me}} {{path/to/input.roff}} | grops > {{path/to/output.ps}}`
- Format output as ASCII text using the man macro package:
  `troff -T {{ascii}} -{{man}} {{path/to/input.roff}} | grotty`
- Format output as a pdf file, saving the output to a file:
  `troff -T {{pdf}} {{path/to/input.roff}} | gropdf > {{path/to/output.pdf}}`

*Source: tldr-pages*

---

[_troff_(1)](https://www.chedong.com/phpMan.php/man/troff/1/markdown)                               General Commands Manual                              [_troff_(1)](https://www.chedong.com/phpMan.php/man/troff/1/markdown)

## Name
       troff - GNU _roff_ typesetter and document formatter

## Synopsis
       **troff **[**-abcCEiRUz**] [**-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
       GNU  _troff_  transforms  ]8;;man:[groff(7)](https://www.chedong.com/phpMan.php/man/groff/7/markdown)\[_groff_(7)](https://www.chedong.com/phpMan.php/man/groff/7/markdown)]8;;\ language input into the device-independent output format de‐
       scribed in ]8;;man:[groff_out(5)](https://www.chedong.com/phpMan.php/man/groffout/5/markdown)\[_groff_out_(5)](https://www.chedong.com/phpMan.php/man/groffout/5/markdown)]8;;\; _troff_ is thus the heart of the GNU _roff_ document formatting  system.
       If  no  _file_  operands  are  given on the command line, or if _file_ is “**-**”, the standard input
       stream is read.

       GNU _troff_ is functionally compatible with the AT&T _troff_ typesetter and features numerous ex‐
       tensions.  Many people prefer to use the ]8;;man:[groff(1)](https://www.chedong.com/phpMan.php/man/groff/1/markdown)\[_groff_(1)](https://www.chedong.com/phpMan.php/man/groff/1/markdown)]8;;\ command, a front end which also  runs  pre‐
       processors and output drivers in the appropriate order and with appropriate options.

## Options
### -h   --help  -v  --version 
       exit afterward.

### -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 the formatted output.

              • A horizontal motion of any size is represented as one  space.   Adjacent  horizontal
                motions are not combined.  Inter-sentence space nodes (those arising from the second
                argument to the **.ss **request) are not represented.

              • Vertical motions are not represented.

              • Special characters are rendered in angle brackets; for example, the default soft hy‐
                phen character appears as “<hy>”.

              The above description should not be considered a specification; the details of **-a **out‐
              put are subject to change.

### -b     
              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 re‐
              quests that append to macros.

### -c     

### -C      -c

### -d _
### -d _
              Define _roff_ string _c_ or _string_ as _text._  _c_ must be one character; _string_ can be of ar‐
              bitrary length.  Such string assignments happen before any macro file is  loaded,  in‐
              cluding  the startup file.  Due to ]8;;man:[getopt_long(3)](https://www.chedong.com/phpMan.php/man/getoptlong/3/markdown)\[_getopt_long_(3)](https://www.chedong.com/phpMan.php/man/getoptlong/3/markdown)]8;;\ limitations, _c_ cannot be, and _string_
              cannot contain, an equals sign, even though that is a valid character in a _roff_  iden‐
              tifier.

### -E      -Ww
              sent to the standard error stream by documents or macro packages using **tm  **or  related
              requests.

### -f _

### -F _
              description files.  See the description of _GROFF_FONT_PATH_  in  section  “Environment”
              below for the default search locations and ordering.

### -i     

### -I _
              **soquiet **requests; and in “**\X'ps: import'**”, “**\X'ps: file'**”, and “**\X'pdf:  pdfpic'**”  de‐
              vice  control  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 _
              Process the file name_.tmac_ prior to any input files.  If not found, _tmac._name  is  at‐
              tempted.  _name_ (in both arrangements) is presumed to be a macro file; see the descrip‐
              tion  of  _GROFF_TMAC_PATH_  in section “Environment” below for the default search loca‐
              tions and ordering.

### -M _
              tion “Environment” below for the default search locations and ordering.

### -n _

### -o _
              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 _
### -r _
              Define  _roff_  register _c_ or _register_ as _numeric-expression._  _c_ must be a one-character
              name; _register_ can be of arbitrary length.  Such register  assignments  happen  before
              any  macro  file is loaded, including the startup file.  Due to ]8;;man:[getopt_long(3)](https://www.chedong.com/phpMan.php/man/getoptlong/3/markdown)\[_getopt_long_(3)](https://www.chedong.com/phpMan.php/man/getoptlong/3/markdown)]8;;\ limita‐
              tions, _c_ cannot be, and _register_ cannot contain, an equals sign, even though that is a
              valid character in a _roff_ identifier.

### -R     

### -T _

### -U     
              disabled  by  default because they allow an untrusted input document to write to arbi‐
              trary file names and run arbitrary commands.  This option also adds the current direc‐
              tory to the macro package search path; see the **-m **and **-M **options above.

### -w _
### -W _
              Enable (**-w**) or inhibit (**-W**) warnings in category _name._  See section “Warnings” below.

### -z     

## Warnings
       Warning diagnostics emitted by _troff_ are divided into named, numbered categories.   The  name
       associated  with  each  warning  category is used by the **-w **and **-W **options.  Each category is
       also assigned a power of two; the sum of enabled category codes is used by the  **warn  **request
       and  the  **.warn **register.  Warnings of each category are produced under the following circum‐
       stances.

                         ┌───────────────────────┬─────────────────────────────┐
                         │ Bit   Code   Category │ Bit    Code      Category   │
                         ├───────────────────────┼─────────────────────────────┤
                         │   0      _1_   **char     **│  10      _1024_   **reg         **│
                         │   1      _2_   **number   **│  11      _2048_   **tab         **│
                         │   2      _4_   **break    **│  12      _4096_   **right-brace **│
                         │   3      _8_   **delim    **│  13      _8192_   **missing     **│
                         │   4     _16_   **el       **│  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           **4   A filled output line could not be broken such that its  length  was  less
                           than the output line length **\n[.l]**.  This category is enabled by default.

       **char            **1   No  mounted font defines a glyph for the requested character.  This cate‐
                           gory 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 component in a color
                           definition was encountered, or an attempt was made to redefine a  default
                           color.

       **delim           **8   The closing delimiter in an escape sequence was missing or mismatched.

       **di            **256   A **di**, **da**, **box**, or **boxa **request was invoked without an argument when there
                           was no current diversion.

       **el             **16   The **el **request was encountered with no prior corresponding **ie **request.

       **escape      **32768   An unsupported escape sequence was encountered.

       **file      **1048576   An attempt was made to load a file that does not exist.  This category is
                           enabled by default.

       **font       **131072   A  non-existent font was selected, or the selection was ignored because a
                           font selection escape sequence was used after the output  line  continua‐
                           tion  escape  sequence on an input line.  This category is enabled by de‐
                           fault.

       **ig         **262144   An invalid escape sequence occurred in input ignored  using  the  **ig  **re‐
                           quest.  This warning category diagnoses a condition that is an error when
                           it occurs in non-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, at most one warning is given for each.

                           This warning is also emitted upon 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.

       **number          **2   An invalid numeric expression was encountered.  This category is  enabled
                           by default.

       **range          **64   A numeric expression was out of range for its context.

       **reg          **1024   An  undefined  register was used.  When an undefined register is derefer‐
                           enced, it is automatically defined with a value of 0.  So, unless  it  is
                           later deleted, at most one warning is given for each.

       **right-brace  **4096   A  right  brace escape sequence **\} **was encountered where a number was ex‐
                           pected.

       **scale          **32   A scaling unit inappropriate to its context was used in a numeric expres‐
                           sion.

       **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 com‐
                           patibility mode.

       **syntax        **128   A self-contradictory hyphenation mode was requested; an empty  or  incom‐
                           plete  numeric expression was encountered; an operand to a numeric opera‐
                           tor was missing; an attempt was made to define  a  recursive,  empty,  or
                           nonsensical  character class; or a _groff_ extension conditional expression
                           operator was used while in compatibility mode.

       **tab          **2048   A tab character was encountered where a number was expected, or  appeared
                           in an unquoted macro 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.

## 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  de‐
              vice  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.23.0/font_), and a compati‐
              bility 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  direc‐
              tory  (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.23.0/tmac_)
              after them.

       _GROFF_TYPESETTER_
              Set  the default output device.  If empty or not set, **ps **is used.  The **-T **option over‐
              rides _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 ]8;;man:[gmtime(3)](https://www.chedong.com/phpMan.php/man/gmtime/3/markdown)\[_gmtime_(3)](https://www.chedong.com/phpMan.php/man/gmtime/3/markdown)]8;;\ and ]8;;man:[asctime(3)](https://www.chedong.com/phpMan.php/man/asctime/3/markdown)\[_asctime_(3)](https://www.chedong.com/phpMan.php/man/asctime/3/markdown)]8;;\ 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
              ]8;;man:[tzset(3)](https://www.chedong.com/phpMan.php/man/tzset/3/markdown)\[_tzset_(3)](https://www.chedong.com/phpMan.php/man/tzset/3/markdown)]8;;\.  If _SOURCE_DATE_EPOCH_ is used, it is always converted to human-readable form
              using UTC.

## Files
       _/usr/share/groff/1.23.0/tmac/troffrc_
              is an initialization macro file loaded before any macro packages specified with **-m **op‐
              tions.

       _/usr/share/groff/1.23.0/tmac/troffrc-end_
              is an initialization macro file loaded after all macro packages specified with **-m  **op‐
              tions.

       _/usr/share/groff/1.23.0/tmac/_name_.tmac_
              are macro files distributed with _groff_.

       _/usr/share/groff/1.23.0/font/dev_name_/DESC_
              describes the output device _name_.

       _/usr/share/groff/1.23.0/font/dev_name_/_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 nec‐
       essary.

## 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 ]8;;mailto:<wl@gnu.org>\Werner Lemberg]8;;\, ]8;;mailto:<groff-bernd.warken-72@web.de>\Bernd Warken]8;;\, and ]8;;mailto:<g.branden.robinson@gmail.com>\G. Branden
       Robinson]8;;\.

**See 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 “info groff”.

       ]8;;man:[groff(1)](https://www.chedong.com/phpMan.php/man/groff/1/markdown)\[_groff_(1)](https://www.chedong.com/phpMan.php/man/groff/1/markdown)]8;;\
              offers an overview of the GNU _roff_ system and describes its front end executable.

       ]8;;man:[groff(7)](https://www.chedong.com/phpMan.php/man/groff/7/markdown)\[_groff_(7)](https://www.chedong.com/phpMan.php/man/groff/7/markdown)]8;;\
              details the _groff_ language, including a short but complete reference of all predefined
              requests, registers, and escape sequences.

       ]8;;man:[groff_char(7)](https://www.chedong.com/phpMan.php/man/groffchar/7/markdown)\[_groff_char_(7)](https://www.chedong.com/phpMan.php/man/groffchar/7/markdown)]8;;\
              explains the syntax of _groff_ special character escape sequences, and lists all special
              characters predefined by the language.

       ]8;;man:[groff_diff(7)](https://www.chedong.com/phpMan.php/man/groffdiff/7/markdown)\[_groff_diff_(7)](https://www.chedong.com/phpMan.php/man/groffdiff/7/markdown)]8;;\
              enumerates the differences between AT&T device-independent _troff_ and _groff_.

       ]8;;man:[groff_font(5)](https://www.chedong.com/phpMan.php/man/grofffont/5/markdown)\[_groff_font_(5)](https://www.chedong.com/phpMan.php/man/grofffont/5/markdown)]8;;\
              covers the format of _groff_ device and font description files.

       ]8;;man:[groff_out(5)](https://www.chedong.com/phpMan.php/man/groffout/5/markdown)\[_groff_out_(5)](https://www.chedong.com/phpMan.php/man/groffout/5/markdown)]8;;\
              describes the format of _troff_'s output.

       ]8;;man:[groff_tmac(5)](https://www.chedong.com/phpMan.php/man/grofftmac/5/markdown)\[_groff_tmac_(5)](https://www.chedong.com/phpMan.php/man/grofftmac/5/markdown)]8;;\
              includes information about macro files that ship with _groff_.

       ]8;;man:[roff(7)](https://www.chedong.com/phpMan.php/man/roff/7/markdown)\[_roff_(7)](https://www.chedong.com/phpMan.php/man/roff/7/markdown)]8;;\
              supplies background on _roff_ systems in general, including pointers to further  related
              documentation.

groff 1.23.0                                31 March 2024                                   [_troff_(1)](https://www.chedong.com/phpMan.php/man/troff/1/markdown)
