groff
Format documents using troff typesetting system
TLDR
Format output for a PostScript printer, saving the output to a file
Render a man page using the ASCII output device, and display it using a pager
Render a man page into an HTML file
Typeset a roff file containing [t]ables and [p]ictures, using the [me] macro set, to PDF, saving the output
Run a groff command with preprocessor and macro options guessed by the grog utility
SYNOPSIS
groff [-abeghijklmnoqsStUvzCEGNRSXYZ] [-Aarg] [-darg] [-Darg] [-ffam] [-Fdir] [-Idir] [-Karg] [-Larg] [-Mdir] [-Parg] [-rarg] [-Targ] [-warg] [-Warg] [files…]
PARAMETERS
-Targ
output device, e.g., ascii, utf8, ps, pdf, html
-mandoc
use mandoc macro package for BSD man pages
-man
use man macro package for Unix man pages
-mdoc
use mdoc macro package
-me
use me macro package
-mm
use mm macro package
-mom
use mom macro package
-ms
use ms macro package
-Parg
pass arg to PostScript prologue
-rreg=val
set register reg to val
-Fdir
font directory
-Mdir
macro directory
-Idir
include directory for soelim
-wname
enable warning category name
-k
use pre-grohtml (deprecated)
-l
send output to spooler
-s
stop after troff
-z
suppress formatted output
-Z
enable device-independent output
DESCRIPTION
groff is the GNU implementation of the classic Unix roff typesetting system, serving as a modern replacement for troff and nroff. It formats input files written in the roff markup language, which uses macros, requests, and escape sequences to produce formatted output for various devices like terminals, PostScript, PDF, and HTML.
Primarily used for rendering Unix manual pages (man pages), groff also handles technical documentation, books, and reports. It supports preprocessors such as tbl for tables, eqn and pic for equations and diagrams, refer for bibliographies, and soelim for source file inclusion. The system is device-independent, allowing output tailored to specific formats via the -T option.
Invocation typically involves specifying a macro package (e.g., -man for man pages) and output device (e.g., -Tutf8 for terminals). Groff chains preprocessors automatically based on filename suffixes or explicit invocation. Its extensibility makes it powerful for precise typographic control, though the roff language has a steep learning curve.
Groff is integral to Unix-like systems, formatting most man pages via commands like man, which invokes groff -man -Tlocale file.1.
CAVEATS
Roff syntax is arcane and error-prone; steep learning curve. Not suited for general document authoring—prefer Markdown or LaTeX. Some options device-specific; test output. Preprocessors must match input suffixes.
PREPROCESSORS
Automatically invoked: tbl (.tbl), eqn/. pic (.pic), chem (.chem). Use explicitly with groff -e -t -p etc.
DEVICES
Common: ascii, latin1, utf8, ps, dvi, pdf, X75, html, X*-* for X11.
MACRO PACKAGES
-man (Unix), -mdoc (BSD), -ms (papers), -me (letters), -mm (memos), -mom (modern books).
HISTORY
Developed by James Clark starting 1990; first release 1.0 in 1991 as GNU troff. Merged with Berkeley tools; maintained by GNU since. Key enhancements: full Unicode, HTML/DVI/PDF output, better internationalization. Widely used for man pages since Linux adoption in 1990s.


