On Unix-like operating systems, the troff command performs typesetting functions and formats documents. It is the major component of the document processing system developed by AT&T for Unix.

This page covers the GNU/Linux version of troff.

Description

troff formats text for printers and character terminals, and is one of the most important pieces of software in Unix history.

  • Description
  • Syntax
  • Warnings
  • Environment
  • Files
  • Examples
  • Related commands
  • Linux commands help

Like roff, nroff and groff, troff is descended from a text formatting program called RUNOFF written by Jerome Saltzer for MIT’s CTSS operating system in the mid-1960s. The name RUNOFF comes from the phrase “to run off a document,” meaning to finalize a document, or prepare it for publication or presentation.

Later iterations of RUNOFF were called rf and then roff, and a version of roff was eventually written for Unix on a PDP-7. Eventually, it evolved in to nroff (“newer roff”) and then troff (“typesetter roff”). The legendary Brian Kernighan eventually rewrote troff, giving it a more flexible syntax and designing it to be device-independent.

Although other typesetting software packages such as LaTeX have gained prominent usage throughout the years, troff is still used extensively in Unix, and is the default type formatter for man.

This documentation is for GNU version of the troff command, which is part of the groff package and commonly used on Linux.

Syntax

troff [-abcivzCERU] [-d cs] [-f fam] [-F dir] [-I dir] [-m name] [-M dir] [-n num] [-o list] [-r cn] [-T name] [-w name] [-W name] [file …]

Options

Warnings

The warnings that can be given by troff are divided into the following categories. The name associated with each warning is used by the -w and -W options; the number is used by the warn request, and by the .warn register; it is always a power of 2 to allow bitwise composition (any two codes can be combined additively to create a unique number).

  • directories given with the -M command line option,then in directories given in the GROFF_TMAC_PATH environment variable,then in the current directory (only if in “unsafe” mode),the home directory,/usr/lib/groff/site-tmac,/usr/share/groff/site-tmac,and finally in /usr/share/groff/1.22.2/tmac.

Warnings, listed by bit:

Descriptions:

There are also names that can refer to groups of warnings:

Environment

troff makes use of the following environment variables:

Files

Note that troffrc and troffrc-end are neither searched in the current nor in the home directory by default for security reasons (even if the -U option is given). Use the -M command line option or the GROFF_TMAC_PATH environment variable to add these directories to the search path if necessary.

Examples

troff myfile

Process file myfile.

checknr — Check nroff and troff files for errors.col — Filter reverse linefeeds.dpost — Translate files created by troff into PostScript under Solaris.eqn — Language processor for describing equations.lp — Print a file on the System V operating system.man — Display the manual page of a given command.nroff — Format documents for terminal display or line-printer.tbl — Preprocessor which formats tables for nroff or troff.