Linux "groff" Command Line Options and Examples
front-end for the groff document formatting system

This document describes the groff program, the main front-end for the groff document formatting system. The groff program and macro suite is the implementation of a roff(7) system within the free software collection GNU ⟨http://www.gnu.


Usage:

groff [-abcegijklpstzCEGNRSUVXZ] [-d cs] [-D arg] [-f fam] [-F dir] [-I dir] [-K arg] [-L arg] [-m name] [-M dir] [-n num] [-o list]
[-P arg] [-r cn] [-T dev] [-w name] [-W name] [file ...]
groff -h | --help
groff -v | --version [option ...]






Command Line Options:

-D
arg Set default input encoding used by preconv to arg. Implies -k.
groff -D ...
-e
Preprocess with eqn.
groff -e ...
-g
Preprocess with grn.
groff -g ...
-G
Preprocess with grap. Implies -p.
groff -G ...
--help
Print a help message.
groff --help ...
-j
Preprocess with chem. Implies -p.
groff -j ...
-K
arg Set input encoding used by preconv to arg. Implies -k.
groff -K ...
-N
Don't allow newlines within eqn delimiters. This is the same as the -N option in eqn.
groff -N ...
-p
Preprocess with pic.
groff -p ...
-P
Pass -option or -option arg to the postprocessor. The option must be specified with the necessary preceding minus sign(s) ‘-’or ‘--’ because groff does not prepend any dashes before passing it to the postprocessor. For example, to pass a title to thegxditview postprocessor, the shell commandgroff -X -P -title -P 'groff it' foois equivalent togroff -X -Z foo | gxditview -title 'groff it' -
groff -P ...
-s
Preprocess with soelim.
groff -s ...
-t
Preprocess with tbl.
groff -t ...
-U
Unsafe mode. Reverts to the (old) unsafe behaviour; see option -S.
groff -U ...
--version
Output version information of groff and of all programs that are run by it; that is, the given command line is parsed in theusual way, passing -v to all subprograms.
groff --version ...
-z
Suppress output generated by troff. Only error messages are printed.
groff -z ...
-a
ASCII approximation of output.
groff -a ...
-b
Backtrace on error or warning.
groff -b ...
-c
Disable color output. Please consult the grotty(1) man page for more details.
groff -c ...
-C
Enable compatibility mode.
groff -C ...
-E
Disable troff error messages.
groff -E ...
-f
fam Set default font family.
groff -f ...
-F
dir Set path for font DESC files.
groff -F ...
-i
Process standard input after the specified input files.
groff -i ...
-m
Include macro file name.tmac (or tmac.name); see also groff_tmac(5).
groff -m ...
-M
dir Path for macro files.
groff -M ...
-n
num Number the first page num.
groff -n ...
-o
Output only pages in list.
groff -o ...
-r
Set number register.
groff -r ...
-w
Enable warning name. See troff(1) for names.
groff -w ...
-W
disable warning name. See troff(1) for names.USING GROFFThe groff system implements the infrastructure of classical roff; see roff(7) for a survey on how a roff system works in general.Due to the front-end programs available within the groff system, using groff is much easier than classical roff. This section givesan overview of the parts that constitute the groff system. It complements roff(7) with groff-specific features. This section can beregarded as a guide to the documentation around the groff system.Paper SizeThe virtual paper size used by troff to format the input is controlled globally with the requests .po, .pl, and .ll. Seegroff_tmac(5) for the ‘papersize’ macro package which provides a convenient interface.The physical paper size, giving the actual dimensions of the paper sheets, is controlled by output devices like grops with the com‐mand line options -p and -l. See groff_font(5) and the man pages of the output devices for more details. groff uses the commandline option -P to pass options to output devices; for example, the following selects A4 paper in landscape orientation for the PSdevice:groff -Tps -P-pa4 -P-l ...Front-endsThe groff program is a wrapper around the troff(1) program. It allows to specify the preprocessors by command line options and auto‐matically runs the postprocessor that is appropriate for the selected device. Doing so, the sometimes tedious piping mechanism ofclassical roff(7) can be avoided.The grog(1) program can be used for guessing the correct groff command line to format a file.The groffer(1) program is an allround-viewer for groff files and man pages.PreprocessorsThe groff preprocessors are reimplementations of the classical preprocessors with moderate extensions. The standard preprocessorsdistributed with the groff package areeqn(1) for mathematical formulae,grn(1) for including gremlin(1) pictures,pic(1) for drawing diagrams,chem(1)for chemical structure diagrams,refer(1)for bibliographic references,soelim(1)for including macro files from standard locations,andtbl(1) for tables.A new preprocessor not available in classical troff is preconv(1) which converts various input encodings to something groff canunderstand. It is always run first before any other preprocessor.Besides these, there are some internal preprocessors that are automatically run with some devices. These aren't visible to the user.Macro PackagesMacro packages can be included by option -m. The groff system implements and extends all classical macro packages in a compatibleway and adds some packages of its own. Actually, the following macro packages come with groff:man The traditional man page format; see groff_man(7). It can be specified on the command line as -man or -m man.mandoc The general package for man pages; it automatically recognizes whether the documents uses the man or the mdoc format andbranches to the corresponding macro package. It can be specified on the command line as -mandoc or -m mandoc.mdoc The BSD-style man page format; see groff_mdoc(7). It can be specified on the command line as -mdoc or -m mdoc.me The classical me document format; see groff_me(7). It can be specified on the command line as -me or -m me.mm The classical mm document format; see groff_mm(7). It can be specified on the command line as -mm or -m mm.ms The classical ms document format; see groff_ms(7). It can be specified on the command line as -ms or -m ms.www HTML-like macros for inclusion in arbitrary groff documents; see groff_www(7).Details on the naming of macro files and their placement can be found in groff_tmac(5); this man page also documents some other,minor auxiliary macro packages not mentioned here.Programming LanguageGeneral concepts common to all roff programming languages are described in roff(7).The groff extensions to the classical troff language are documented in groff_diff(7).The groff language as a whole is described in the (still incomplete) groff info file; a short (but complete) reference can be foundin groff(7).FormattersThe central roff formatter within the groff system is troff(1). It provides the features of both the classical troff and nroff, aswell as the groff extensions. The command line option -C switches troff into compatibility mode which tries to emulate classicalroff as much as possible.There is a shell script nroff(1) that emulates the behavior of classical nroff. It tries to automatically select the proper outputencoding, according to the current locale.The formatter program generates intermediate output; see groff_out(7).DevicesIn roff, the output targets are called devices. A device can be a piece of hardware, e.g., a printer, or a software file format. Adevice is specified by the option -T. The groff devices are as follows.ascii Text output using the ascii(7) character set.cp1047 Text output using the EBCDIC code page IBM cp1047 (e.g., OS/390 Unix).dvi TeX DVI format.html HTML output.latin1 Text output using the ISO Latin-1 (ISO 8859-1) character set; see iso_8859_1(7).lbp Output for Canon CAPSL printers (LBP-4 and LBP-8 series laser printers).lj4 HP LaserJet4-compatible (or other PCL5-compatible) printers.ps PostScript output; suitable for printers and previewers like gv(1).pdf PDF files; suitable for viewing with tools such as evince(1) and okular(1).utf8 Text output using the Unicode (ISO 10646) character set with UTF-8 encoding; see unicode(7).xhtml XHTML output.X75 75dpi X Window System output suitable for the previewers xditview(1x) and gxditview(1). A variant for a 12pt document basefont is X75-12.X100 100dpi X Window System output suitable for the previewers xditview(1x) and gxditview(1). A variant for a 12pt document basefont is X100-12.The postprocessor to be used for a device is specified by the postpro command in the device description file; see groff_font(5).This can be overridden with the -X option.The default device is ps.Postprocessorsgroff provides 3 hardware postprocessors:grolbp(1)for some Canon printers,grolj4(1)for printers compatible to the HP LaserJet 4 and PCL5,grotty(1)for text output using various encodings, e.g., on text-oriented terminals or line-printers.Today, most printing or drawing hardware is handled by the operating system, by device drivers, or by software interfaces, usuallyaccepting PostScript. Consequently, there isn't an urgent need for more hardware device postprocessors.The groff software devices for conversion into other document file formats aregrodvi(1)for the DVI format,grohtml(1)for HTML and XHTML formats,grops(1)for PostScript.gropdf(1)for PDF.Combined with the many existing free conversion tools this should be sufficient to convert a troff document into virtually any exist‐ing data format.UtilitiesThe following utility programs around groff are available.addftinfo(1)Add information to troff font description files for use with groff.afmtodit(1)Create font description files for PostScript device.eqn2graph(1)Convert an eqn image into a cropped image.gdiffmk(1)Mark differences between groff, nroff, or troff files.grap2graph(1)Convert a grap diagram into a cropped bitmap image.groffer(1)General viewer program for groff files and man pages.gxditview(1)The groff X viewer, the GNU version of xditview.hpftodit(1)Create font description files for lj4 device.indxbib(1)Make inverted index for bibliographic databases.lkbib(1)Search bibliographic databases.lookbib(1)Interactively search bibliographic databases.pdfroff(1)Create PDF documents using groff.pfbtops(1)Translate a PostScript font in .pfb format to ASCII.pic2graph(1)Convert a pic diagram into a cropped image.tfmtodit(1)Create font description files for TeX DVI device.xditview(1x)roff viewer distributed with X window.xtotroff(1)Convert X font metrics into GNU troff font metrics.ENVIRONMENTNormally, the path separator in the following environment variables is the colon; this may vary depending on the operating system.For example, DOS and Windows use a semicolon instead.GROFF_BIN_PATHThis search path, followed by $PATH, is used for commands that are executed by groff. If it is not set then the directorywhere the groff binaries were installed is prepended to PATH.GROFF_COMMAND_PREFIXWhen there is a need to run different roff implementations at the same time groff provides the facility to prepend a prefix tomost of its programs that could provoke name clashings at run time (default is to have none). Historically, this prefix wasthe character g, but it can be anything. For example, gtroff stood for groff's troff, gtbl for the groff version of tbl. Bysetting GROFF_COMMAND_PREFIX to different values, the different roff installations can be addressed. More exactly, if it isset to prefix xxx then groff as a wrapper program internally calls xxxtroff instead of troff. This also applies to the pre‐processors eqn, grn, pic, refer, tbl, soelim, and to the utilities indxbib and lookbib. This feature does not apply to anyprograms different from the ones above (most notably groff itself) since they are unique to the groff package.GROFF_ENCODINGThe value of this environment value is passed to the preconv preprocessor to select the encoding of input files. Setting thisoption implies groff's command line option -k (this is, groff actually always calls preconv). If set without a value, groffcalls preconv without arguments. An explicit -K command line option overrides the value of GROFF_ENCODING. See preconv(1)for details.GROFF_FONT_PATHA list of directories in which to search for the devname directory in addition to the default ones. See troff(1) andgroff_font(5) for more details.GROFF_TMAC_PATHA list of directories in which to search for macro files in addition to the default directories. See troff(1) andgroff_tmac(5) for more details.GROFF_TMPDIRThe directory in which temporary files are created. If this is not set but the environment variable TMPDIR instead, temporaryfiles are created in the directory $TMPDIR. On MS-DOS and Windows 32 platforms, the environment variables TMP and TEMP (inthat order) are searched also, after GROFF_TMPDIR and TMPDIR. Otherwise, temporary files are created in /tmp. The refer(1),groffer(1), grohtml(1), and grops(1) commands use temporary files.GROFF_TYPESETTERPreset the default device. If this is not set the ps device is used as default. This device name is overwritten by theoption -T.EXAMPLESThe following example illustrates the power of the groff program as a wrapper around troff.To process a roff file using the preprocessors tbl and pic and the me macro set, classical troff had to be called bypic foo.me | tbl | troff -me -Tlatin1 | grottyUsing groff, this pipe can be shortened to the equivalent commandgroff -p -t -me -T latin1 foo.meAn even easier way to call this is to use grog(1) to guess the preprocessor and macro options and execute the generated command (byusing backquotes to specify shell command substitution)`grog -Tlatin1 foo.me`The simplest way is to view the contents in an automated way by callinggroffer foo.meBUGSOn EBCDIC hosts (e.g., OS/390 Unix), output devices ascii and latin1 aren't available. Similarly, output for EBCDIC code page cp1047is not available on ASCII based operating systems.Report bugs to the groff mailing list ⟨bug-groff@gnu.org⟩. Include a complete, self-contained example that allows the bug to bereproduced, and say which version of groff you are using.POSITIONS FROM INSTALLATIONThere are some directories in which groff installs all of its data files. Due to different installation habits on different operat‐ing systems, their locations are not absolutely fixed, but their function is clearly defined and coincides on all systems.Collection of Installation DirectoriesThis section describes the position of all files of the groff package after the installation — got from Makefile.comm at the top ofthe groff source package./usr/dict/papers/Indindex directory and index name/usr/lib/fontlegacy font directory/usr/bindirectory for binary programs/usr/lib/groff/site-tmacsystem tmac directory/usr/share/doc/groff-basedocumentation directory/usr/share/doc/groff-base/examplesdirectory for examples/usr/share/doc/groff-base/htmldocumentation directory for html files/usr/share/doc/groff-base/pdfdocumentation directory for pdf files/usr/share/groff/1.22.3data subdirectory/usr/share/groff/1.22.3/eignfile for common words/usr/share/groff/1.22.3/fontdirectory for fonts/usr/share/groff/1.22.3/oldfontdirectory for old fonts/usr/share/groff/1.22.3/tmactmac directory/usr/share/groff/1.22.3/tmac/mmmm tmac directory/usr/share/groff/site-fontlocal font directory/usr/share/groff/site-tmaclocal tmac directorygroff Macro DirectoryThis contains all information related to macro packages. Note that more than a single directory is searched for those files as docu‐mented in groff_tmac(5). For the groff installation corresponding to this document, it is located at /usr/share/groff/1.22.3/tmac.The following files contained in the groff macro directory have a special meaning:troffrcInitialization file for troff. This is interpreted by troff before reading the macro sets and any input.troffrc-endFinal startup file for troff. It is parsed after all macro sets have been read.name.tmactmac.nameMacro file for macro package name.groff Font DirectoryThis contains all information related to output devices. Note that more than a single directory is searched for those files; seetroff(1). For the groff installation corresponding to this document, it is located at /usr/share/groff/1.22.3/font. The followingfiles contained in the groff font directory have a special meaning:devname/DESCDevice description file for device name, see groff_font(5).devname/FFont file for font F of device name.AVAILABILITYInformation on how to get groff and related information is available at the groff GNU website ⟨http://www.gnu.org/software/groff⟩.Three groff mailing lists are available:for reporting bugs ⟨bug-groff@gnu.org⟩.for general discussion of groff, ⟨groff@gnu.org⟩.the groff commit list ⟨groff-commit@ffii.org⟩, a read-only list showing logs of commitments to the groff repository.Details on repository access and much more can be found in the file README at the top directory of the groff source package.There is a free implementation of the grap preprocessor, written by Ted Faber ⟨faber@lunabase.org⟩. The actual version can be foundat the grap website ⟨http://www.lunabase.org/~faber/Vault/software/grap/⟩. This is the only grap version supported by groff.
groff -W ...