groff(1)

๐Ÿ’… GROFF(1) โ€” General Commands Manual โœจ

okay so welcome to the groff page, bestie โ€” it's giving iconic Unix lore and honestly it ate ๐ŸŽ€ the manual name is right there in the header: General Commands Manual, which just means "this is a command, babes, not a config file" ๐Ÿ’– let's get into it


๐ŸŒธ NAME ๐ŸŒธ

groff โ€” front end to the GNU roff document formatting system ๐Ÿฆ‹


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

groff [-abcCeEgGijklNpRsStUVXzZ] [-d ctext] [-d string=text]
      [-D fallback-encoding] [-f font-family] [-F font-directory]
      [-I inclusion-directory] [-K input-encoding] [-L spooler-argument]
      [-m macro-package] [-M macro-directory] [-n page-number] [-o page-
      list] [-P postprocessor-argument] [-r cnumeric-expression]
      [-r register=numeric-expression] [-T output-device] [-w warning-
      category] [-W warning-category] [file ...]

groff -h

groff --help

groff -v [option ...] [file ...]

groff --version [option ...] [file ...]

๐Ÿ’– DESCRIPTION ๐Ÿ’–

no cap, groff is the primary front end to the GNU roff document formatting system โœจ GNU roff is a typesetting system โ€” it reads plain text input that includes formatting commands, and it produces output in PostScript, PDF, HTML, or other formats, or literally just for display to a terminal ๐Ÿ–ฅ๏ธ

the formatting commands can be any of these three flavors, and you can mix all three, bestie:

  • low-level typesetting primitives
  • macros from a supplied package
  • user-defined macros

and if you don't give it any file operands, or if file is -, groff reads the standard input stream ๐Ÿซถ

it's a reimplementation and extension of troff and other programs from AT&T Unix, and groff is widely available on POSIX and other systems owing to its long association with Unix manuals, including man pages โ€” yes mary, this very page ๐Ÿ‘‘ it and its predecessor have produced several best-selling software engineering texts ๐Ÿ“š groff can create typographically sophisticated documents while consuming minimal system resources. slay.

like its predecessor troff, the term groff affords two popular pronunciations, and I need you to pick your fighter ๐Ÿ’…:

  • as one syllable (like the surname), rhyming with โ€œtroughโ€
  • or as โ€œjee-roffโ€, in analogy to the Bell Labs pronunciation โ€œtee-roffโ€

little risk of confusion exists โ€” use whichever suits you, bestie. no wrong answers ๐Ÿ“

the groff command orchestrates the execution of preprocessors, the transformation of input documents into a device-independent page description language, and the production of output from that language ๐Ÿ”ฅ


โœจ OPTIONS โœจ

-h and --help display a usage message and exit.

because groff is intended to subsume most users' direct invocations of the troff(1) formatter, the two programs share a set of options. however โ€” and this is the tea โ˜• โ€” groff has some options that troff does not share, and others which groff interprets differently. at the same time, not all valid troff options can be given to groff. iykyk ๐Ÿ˜ญ

๐Ÿ’… groff-specific options ๐Ÿ’…

the following options either do not exist in GNU troff or are interpreted differently by groff ๐Ÿฆ‹

  • -D enc โ€” use enc as preconv(1)'s fallback input encoding; implies -k.
  • -e โ€” run the eqn(1) preprocessor.
  • -g โ€” run the grn(1) preprocessor.
  • -G โ€” run the grap(1) preprocessor; implies -p.
  • -I dir โ€” works as troff's option (see below), but also implies -g and -s. groff passes -I options and their arguments to soelim(1), troff(1), and output drivers; with the option letter changed to -M, it passes the same arguments to grn(1).
  • -j โ€” run the chem(1) preprocessor; implies -p.
  • -k โ€” run the preconv(1) preprocessor. refer to its man page for its behavior if neither of groff's -K or -D options is also specified ๐Ÿ‘€
  • -K enc โ€” set the input encoding used by preconv(1) to enc; implies -k.
  • -l โ€” send the output to a spooler program for printing ๐Ÿ–จ๏ธ the โ€œprintโ€ directive in the device description file specifies the default command to be used; see groff_font(5). if no such directive is present for the output device, this option is ignored. see options -L and -X.
  • -L arg โ€” pass arg to the print spooler. if multiple args are required, pass each with a separate -L option. groff does not prefix an option dash to arg before passing it to the spooler โš ๏ธ
  • -M โ€” works as troff's option (see below), but is also passed to eqn(1), grap(1), and grn(1).
  • -N โ€” prohibit newlines between eqn delimiters: pass -N to eqn(1).
  • -p โ€” run the pic(1) preprocessor.
  • -P arg โ€” pass arg to the postprocessor. if multiple args are required, pass each with a separate -P option. groff does not prefix an option dash to arg before passing it to the postprocessor โš ๏ธ
  • -R โ€” run the refer(1) preprocessor. no mechanism is provided for passing arguments to it; most refer options have equivalent language elements that can be specified within the document ๐Ÿ“
  • -s โ€” run the soelim(1) preprocessor.
  • -S โ€” enable safer mode and ignore any subsequent -U option. groff passes the -S option to pic(1) and troff(1) ๐Ÿ›ก๏ธ
  • -t โ€” run the tbl(1) preprocessor.
  • -T dev โ€” prepare output for device dev. groff passes the -T option and its argument to troff, then (unless the -Z option is used) runs an output driver to convert troff's output to a form appropriate for dev; see subsection โ€œOutput devicesโ€ below ๐Ÿ”
  • -U โ€” operate in unsafe mode. groff passes the -U option to pic(1) and troff(1) ๐Ÿ’€
  • --version, -v โ€” write version information for groff and all programs run by it to the standard output stream; that is, the given command line is processed in the usual way, passing -v to the formatter and any pre- or postprocessors invoked.
  • -V โ€” output the pipeline that groff would run to the standard output stream and exit. if given more than once, groff both writes the pipeline to the standard error stream and runs it ๐Ÿ‘€
  • -X โ€” use gxditview(1) instead of the usual postprocessor to (pre)view a document on an X11 display. combining this option with -T ps uses the font metrics of the PostScript device, whereas the -T X75, -T X75-12, -T X100, and -T X100-12 options use the metrics of X11 fonts ๐Ÿ–ผ๏ธ
  • -Z โ€” disable postprocessing. troff output appears on the standard output stream (unless suppressed with -z); see groff_out(5) for a description of this format.

๐Ÿงš Transparent options ๐Ÿงš

the following options are passed as-is to the formatter program troff(1) and described in more detail in its man page ๐Ÿซถ

  • -a โ€” generate a plain text approximation of the typeset output.
  • -b โ€” write a backtrace to the standard error stream on each error or warning.
  • -c โ€” start with color output disabled.
  • -C โ€” enable AT&T troff compatibility mode; implies -c.
  • -d ctext / -d string=text โ€” define string.
  • -E โ€” inhibit troff error messages; implies -Ww.
  • -f fam โ€” set default font family.
  • -F dir โ€” search in directory dir for the selected output device's directory of device and font description files.
  • -i โ€” process standard input after the specified input files.
  • -I dir โ€” search dir for input files.
  • -m mac โ€” read macro package mac before input. groff passes -m options and their arguments to eqn(1), grap(1), and grn(1).
  • -M dir โ€” search directory dir for macro files. groff passes -M options and their arguments to eqn(1), grap(1), and grn(1).
  • -n num โ€” begin numbering pages at num.
  • -o list โ€” output only pages in list.
  • -r cnumeric-expression / -r register=numeric-expression โ€” define register.
  • -S โ€” enable safer mode and ignore any subsequent -U option.
  • -U โ€” operate in unsafe mode.
  • -w cat / -W cat โ€” enable and inhibit, respectively, warnings in category cat.
  • -z โ€” suppress formatted device-independent output of troff.

๐Ÿ”ฅ USAGE ๐Ÿ”ฅ

the architecture of the GNU roff system follows that of other device-independent roff implementations, comprising preprocessors, macro packages, output drivers (or โ€œpostprocessorsโ€), and a suite of utilities, with the formatter program troff(1) at its heart ๐Ÿ’œ see roff(7) for a survey of how a roff system works.

the front end programs available in the GNU roff system make it easier to use than traditional roffs that required the construction of pipelines or use of temporary files to carry a source document from maintainable form to device-ready output ๐ŸŒˆ the discussion below summarizes the constituent parts of the GNU roff system. it complements roff(7) with groff-specific information.

๐ŸŒฑ Getting started ๐ŸŒฑ

those who prefer to learn by experimenting or are desirous of rapid feedback from the system may wish to start with a โ€œHello, world!โ€ document, and honestly? same ๐Ÿซถ

$ echo "Hello, world!" | groff -Tascii | sed '/^$/d'
Hello, world!

we used a sed(1) command only to eliminate the 65 blank lines that would otherwise flood the terminal screen ๐Ÿ˜ญ (roff systems were developed in the days of paper-based terminals with 66 lines to a page โ€” vintage behavior, we respect it ๐Ÿ‘‘)

today's users may prefer output to a UTF-8-capable terminal ๐Ÿ’…

$ echo "Hello, world!" | groff -Tutf8 | sed '/^$/d'

producing PDF, HTML, or TeX's DVI is also straightforward โœจ the hard part may be selecting a viewer program for the output ๐Ÿ™ˆ

$ echo "Hello, world!" | groff -Tpdf > hello.pdf
$ evince hello.pdf
$ echo "Hello, world!" | groff -Thtml > hello.html
$ firefox hello.html
$ echo "Hello, world!" | groff -Tdvi > hello.dvi
$ xdvi hello.dvi

๐ŸŽ€ Using groff as a REPL ๐ŸŽ€

those with a programmer's bent may be pleased to know that they can use groff in a read-evaluate-print loop (REPL) ๐Ÿ” doing so can be handy to verify one's understanding of the formatter's behavior and/or the syntax it accepts. turning on all warnings with -ww can aid this goal โ€” highly recommend, ngl ๐Ÿ‘€

$ groff -ww -Tutf8
\# This is a comment. Let's define a register.
.nr a 1
\# Do integer arithmetic with operators evaluated left-to-right.
.nr b \n[a]+5/2
\# Let's get the result on the standard error stream.
.tm \n[b]
3
\# Now we'll define a string.
.ds name Leslie\" This is another form of comment.
.nr b (\n[a] + (7/2))
\# Center the next two text input lines.
.ce 2
Hi, \*[name].
Your secret number is \n[b].
\# We will see that the division rounded toward zero.
It is
\# Here's an if-else control structure.
.ie (\n[b] % 2) odd.
.el even.
\# This trick sets the page length to the current vertical
\# position, so that blank lines don't spew when we're done.
.pl \n[nl]u
<Control-D>
                                  Hi, Leslie.
                           Your secret number is 4.
It is even.

and that's the REPL demo, besties ๐Ÿ’– โ€” the way it literally centers for you and rounds toward zero? main character energy fr fr ๐ŸŒŸ

๐ŸŒธ Paper format ๐ŸŒธ

okay so first thing, bestie: when the formatter starts up, it reads the device description file DESC for whatever output device you selected. If that file has page dimensions declared in it, those are the ones we use. groffโ€™s build process configures a default page format and writes it into the typesettersโ€™ DESC files. This particular installation defaults to โ€œletterโ€. If the DESC file is missing that info, the formatter and output driver fall back to a page length of โ€œ11iโ€ (thatโ€™s eleven inches, for compatibility with AT&T troff). See groff_font(5) for the deets. ๐Ÿ’–

In the formatter, the pl request changes the page length, but macro packages often do not support changing the paper format mid-document. Like, you might want to switch between portrait and landscape orientations, but the macro packages donโ€™t have a consistent way to configure parameters that depend on paper format. Some, like ms, benefit from a preamble in the document before the first macro call. Others, like mm, instead require you to specify registers on the command line (or otherwise before its macro file is interpreted) to configure page dimensions. Itโ€™s giving โ€œeveryone has their own vibeโ€ honestly. ๐Ÿ˜ญ

Output drivers for typesetters also recognize command-line options -p to override the default page dimensions and -l to use landscape orientation. The output driverโ€™s man page, like grops(1), may be helpful. ๐Ÿ‘‘

groffโ€™s โ€œ-d paperโ€ command-line option is a convenient way to set the paper format; see groff_tmac(5). Combine it with appropriate -P options for the output driver, overriding its defaults. The following command formats for PostScript on A4 paper in landscape orientation:

$ groff -T ps -d paper=a4l -P -pa4 -P -l -ms my.ms >my.ps

โœจ Front end โœจ

The groff program wraps troff(1), letting you specify preprocessors via command-line options and running the appropriate output driver for the selected output device. This convenience avoids the manual construction of pipelines or management of temporary files that users of traditional roff(7) systems have to deal with. Use grog(1) to infer an appropriate groff command line to format a document. Lowkey a lifesaver. ๐Ÿซถ


๐Ÿฆ‹ Language ๐Ÿฆ‹

Input to a roff system is plain text interleaved with control lines and escape sequences. The combination constitutes a document in one of a family of languages we also call roff; see roff(7) for background. An overview of GNU roff language syntax and featuresโ€”including lists of all supported escape sequences, requests, and predefined registersโ€”can be found in groff(7). GNU roff extensions to the AT&T troff language (a common subset of roff dialects extant today) are detailed in groff_diff(7). So much lore, iykyk. ๐Ÿ“š


๐ŸŽ€ Preprocessors ๐ŸŽ€

A preprocessor interprets a domain-specific language that produces roff language output. Frequently, such input is confined to sections or regions of roff input (bracketed with macro calls specific to each preprocessor), which it replaces. Preprocessors therefore often interpret a subset of roff syntax along with their own language. GNU roff provides reimplementations of most preprocessors familiar to users of AT&T troff; these routinely have extended features and/or require GNU troff to format their output.

  • tbl โ€” lays out tables;
  • eqn โ€” typesets mathematics;
  • pic โ€” draws diagrams;
  • refer โ€” processes bibliographic references;
  • soelim โ€” preprocesses โ€œsourcedโ€ input files;
  • grn โ€” renders gremlin(1) diagrams;
  • chem โ€” draws chemical structural formulรฆ using pic;
  • gperl โ€” populates groff registers and strings using perl(1);
  • glilypond โ€” embeds LilyPond sheet music; and
  • gpinyin โ€” eases Mandarin Chinese input using Hanyu Pinyin.

A preprocessor unique to GNU roff is preconv(1), which converts various input encodings to something GNU troff can understand. When used, it is run before any other preprocessors.

Most preprocessors enclose content between a pair of characteristic tokens. Such a token must occur at the beginning of an input line and use the dot control character. Spaces and tabs must not follow the control character or precede the end of the input line. Deviating from these rules defeats a tokenโ€™s recognition by the preprocessor. Tokens are generally preserved in preprocessor output and interpreted as macro calls subsequently by troff. The ideal preprocessor is not yet available in groff. ๐Ÿ’€

so hereโ€™s the token tea, bestie:
  • chem โ€” starting token: .cstart; ending token: .cend
  • eqn โ€” starting token: .EQ; ending token: .EN
  • grap โ€” starting token: .G1; ending token: .G2
  • grn โ€” starting token: .GS; ending token: .GE
  • ideal โ€” starting token: .IS; ending tokens: .IE and .IF
  • pic โ€” starting token: .PS; ending tokens: .PE, .PF, .PY
  • refer โ€” starting token: .R1; ending token: .R2
  • tbl โ€” starting token: .TS; ending token: .TE
  • glilypond โ€” starting token: .lilypond start; ending token: .lilypond stop
  • gperl โ€” starting token: .Perl start; ending token: .Perl stop
  • gpinyin โ€” starting token: .pinyin start; ending token: .pinyin stop

๐Ÿ’… Macro packages ๐Ÿ’…

Macro files are roff input files designed to produce no output themselves but instead ease the preparation of other roff documents. When a macro file is installed at a standard location and suitable for use by a general audience, it is termed a macro package.

The -m option loads a macro package prior to any roff input documents, and after performing any string and register assignments directed by -d and -r options. The GNU roff system implements most well-known macro packages for AT&T troff in a compatible way and extends them. These have one- or two-letter names arising from intense practices of naming economy in early Unix cultureโ€”a laconic approach that led to many of the packages being identified in general usage with the nroff and troff option letter used to invoke them, sometimes to punning effect, as with โ€œmanโ€ (short for โ€œmanualโ€), and even with the option dash, as in the case of the s package, much better known as ms or even -ms. The lore is real. ๐Ÿงš

Macro packages serve a variety of purposes. Some are โ€œfull-serviceโ€ packages, adopting responsibility for page layout among other fundamental tasks, and defining their own lexicon of macros for document composition; each such package stands alone and a given document can use at most one.

  • an โ€” is used to compose man pages in the format originating in Version 7 Unix (1979); see groff_man(7). It can be specified on the command line as -man.
  • doc โ€” is used to compose man pages in the format originating in 4.3BSD-Reno (1990); see groff_mdoc(7). It can be specified on the command line as -mdoc.
  • e โ€” is the Berkeley general-purpose macro suite, developed as an alternative to AT&Tโ€™s s; see groff_me(7). It can be specified on the command line as -me.
  • m โ€” implements the format used by the second-generation AT&T macro suite for general documents, a successor to s; see groff_mm(7). It can be specified on the command line as -mm.
  • om โ€” (invariably called โ€œmomโ€) is a modern package written by Peter Schaffter specifically for GNU roff. Consult the mom HTML manual for extensive documentation. Sheโ€”for mom takes the female pronounโ€”can be specified on the command line as -mom. ๐Ÿ‘‘
  • s โ€” is the original AT&T general-purpose document format; see groff_ms(7). It can be specified on the command line as -ms.

Others are supplemental. For instance, andoc is a wrapper package specific to GNU roff that recognizes whether a document uses man or mdoc format and loads the corresponding macro package. It can be specified on the command line as -mandoc. A man(1) librarian may use this macro file to delegate loading of the correct macro package; it is thus unnecessary for man itself to scan the contents of a document to decide the issue. So efficient. โœจ

Many macro files augment the function of the full-service packages, or of roff documents that do not employ such a packageโ€”the latter are sometimes characterized as โ€œrawโ€. These auxiliary packages are described, along with details of macro file naming and placement, in groff_tmac(5).


๐Ÿ”ฅ Formatters ๐Ÿ”ฅ

The formatterโ€”the program that interprets roff language inputโ€”is troff(1). It provides the features of the AT&T troff and nroff programs as well as many extensions. The command-line option -C switches troff into compatibility mode, which tries to emulate AT&T troff as closely as is practical to enable the formatting of documents written for the older system. Ngl, respect. ๐Ÿซก

A shell script, nroff(1), emulates the behavior of AT&T nroff. It attempts to correctly encode the output based on the locale, relieving the user of the need to specify an output device with the -T option and is therefore convenient for use with terminal output devices, described in the next subsection. Slay.

GNU troff generates output in a device-independent, but not device-agnostic, page description language detailed in groff_out(5).


๐ŸŒˆ Output devices ๐ŸŒˆ

troff output is formatted for a particular output device, typically specified by the -T option to the formatter or a front end. If neither this option nor the GROFF_TYPESETTER environment variable is used, the default output device is ps. An output device may be any of the following.

  • ascii โ€” for terminals using the ISO 646 1991:IRV character set and encoding, also known as US-ASCII.
  • dvi โ€” for TeX DVI format.
  • html โ€” for HTML output.
  • xhtml โ€” for XHTML output.
  • latin1 โ€” for terminals using the ISO Latin-1 (8859-1) character set and encoding.
  • lbp โ€” for Canon CaPSL printers (LBP-4 and LBP-8 series laser printers).
  • lj4 โ€” for HP LaserJet4-compatible (or other PCL5-compatible) printers.
  • pdf โ€” for PDF output.
  • ps โ€” for PostScript output.
  • utf8 โ€” for terminals using the ISO 10646 (โ€œUnicodeโ€) character set in UTF-8 encoding. ๐Ÿ’–
  • X75 โ€” for previewing with gxditview using 75 dpi resolution and a 10-point base type size.
  • X75-12 โ€” for previewing with gxditview using 75 dpi resolution and a 12-point base type size.
  • X100 โ€” for previewing with gxditview using 100 dpi resolution and a 10-point base type size.
  • X100-12 โ€” for previewing with gxditview using 100 dpi resolution and a 12-point base type size.

๐Ÿ’… Postprocessors ๐Ÿ’…

okay so real talk: any program that interprets the output of GNU troff is a postprocessor. The postprocessors provided by GNU roff are output drivers, which prepare a document for viewing or printing. Postprocessors for other purposes, such as page resequencing or statistical measurement of a document, are conceivable. no cap, that's the whole vibe.

An output driver supports one or more output devices, each with its own device description file. A device determines its postprocessor with the postpro directive in its device description file; see groff_font(5). The -X option overrides this selection, causing gxditview to serve as the output driver. ๐Ÿ’…

๐Ÿงฐ Utilities ๐Ÿงฐ

GNU roff includes a whole suite of utilities โ€” think little helper besties. ๐Ÿซถ

  • gdiffmk(1) โ€” marks differences between a pair of roff input files.
  • grog(1) โ€” infers the groff command a document requires.

Several utilities prepare descriptions of fonts, enabling the formatter to use them when producing output for a given device. iconic behavior, honestly.

  • addftinfo(1) โ€” adds information to AT&T troff font description files to enable their use with GNU troff.
  • afmtodit(1) โ€” creates font description files for PostScript Type 1 fonts.
  • pfbtops(1) โ€” translates a PostScript Type 1 font in PFB (Printer Font Binary) format to PFA (Printer Font ASCII), which can then be interpreted by afmtodit.
  • hpftodit(1) โ€” creates font description files for the HP LaserJet 4 family of printers.
  • tfmtodit(1) โ€” creates font description files for the TeX DVI device.
  • xtotroff(1) โ€” creates font description files for X Window System core fonts.

A trio of tools transform material constructed using roff preprocessor languages into graphical image files. obsessed. โœจ

  • eqn2graph(1) โ€” converts an eqn equation into a cropped image.
  • grap2graph(1) โ€” converts a grap diagram into a cropped image.
  • pic2graph(1) โ€” converts a pic diagram into a cropped image.

Another set of programs works with the bibliographic data files used by the refer(1) preprocessor. iykyk.

  • indxbib(1) โ€” makes inverted indices for bibliographic databases, speeding lookup operations on them.
  • lkbib(1) โ€” searches the databases.
  • lookbib(1) โ€” interactively searches the databases.

๐Ÿšฆ Exit status ๐Ÿšฆ

groff exits successfully (with status 0) if either of the options -h or --help is specified, status 2 if the program cannot interpret its command-line arguments, and status 1 if it encounters an error during operation. Otherwise, groff runs a pipeline to process its input; if all commands within the pipeline exit successfully, groff does likewise. If not, groff's exit status encodes a summary of problems encountered, setting bit 2 if a command exited with a failure status, bit 3 if a command was terminated with a signal, and bit 4 if a command could not be executed. (Thus, if all three misfortunes befall one's pipeline, groff exits with status 2^2 + 2^3 + 2^4 = 4+8+16 = 28.) To troubleshoot pipeline problems, re-run the groff command with the -V option and break the reported pipeline down into separate stages, inspecting the exit status of, and diagnostic messages emitted by, each command. bit math ate, fr fr. ๐Ÿ’€

๐ŸŒ Environment ๐ŸŒ

Environment variables in the host system affect the behavior of programs supplied by groff as follows. Normally, the path separator in environment variables ending with PATH is the colon; this may vary depending on the operating system. For example, Windows uses a semicolon instead. bestie, know your separators. ๐Ÿซถ

  • GROFF_BIN_PATH โ€” Locate groff commands in these directories, followed by those in PATH. If not set, the installation directory of GNU roff executables, /usr/bin, is searched before PATH.
  • GROFF_COMMAND_PREFIX โ€” Apply a prefix to certain GNU roff commands. groff can be configured at compile time to apply a prefix to the names of programs it provides that had counterparts in AT&T troff, so that name collisions are avoided at run time. The default prefix is empty.

When used, this prefix is conventionally the letter โ€œgโ€. For example, GNU troff would be installed as gtroff. Besides troff, the prefix applies to the formatter wrapper nroff; the preprocessors eqn, grn, pic, refer, tbl, and soelim; and the utilities indxbib and lookbib.

  • GROFF_ENCODING โ€” Specify the assumed character encoding of the input. groff passes its value as an argument to preconv(1) preprocessor's -e option. This variable's existence implies the groff option -k. If set but empty, groff runs preconv without an -e option. groff's -K option overrides GROFF_ENCODING.
  • GROFF_FONT_PATH โ€” Seek the selected output device's directory of device and font description files in this list of directories. See troff(1) and groff_font(5).
  • GROFF_TMAC_PATH โ€” Seek macro packages in this list of directories. See troff(1) and groff_tmac(5).
  • GROFF_TMPDIR โ€” Create temporary files in this directory. If not set, but TMPDIR is, the latter is used instead. On Windows systems, if neither of the foregoing are set, the environment variables TMP and TEMP (in that order) are checked also. Otherwise, temporary files are created in /tmp. The refer(1), grohtml(1), and grops(1) commands use temporary files.
  • GROFF_TYPESETTER โ€” Set the default output device. If empty or not set, ps is used. The -T option overrides GROFF_TYPESETTER.
  • SOURCE_DATE_EPOCH โ€” Declare a time stamp (expressed as seconds since the Unix epoch) to use as the output creation time stamp in place of the current time. The time is converted to human-readable form using gmtime(3) and asctime(3) when the formatter starts up and stored in registers usable by documents and macro packages.
  • TZ โ€” Declare the time zone to use when converting the current time to human-readable form; see tzset(3). If SOURCE_DATE_EPOCH is used, it is always converted to human-readable form using UTC.

๐ŸŽ€ Examples ๐ŸŽ€

roff systems are best known for formatting man pages. A man(1) librarian program, having located a page, might render it with a groff command.

groff -t -man -Tutf8 /usr/share/man/man1/groff.1

The librarian will also pipe the output through a pager, which might not interpret terminal escape sequences groff emits for boldface, underlining, italics, or hyperlinking; see section โ€œLimitationsโ€ below. not the pager catching strays ๐Ÿ˜ญ

To process a roff input file using the preprocessors tbl and pic and the me macro package in the way to which AT&T troff users were accustomed, one would type (or script) a pipeline.

pic foo.me | tbl | troff -me -Tutf8 | grotty

Shorten this pipeline to an equivalent command using groff.

groff -p -t -me -T utf8 foo.me

An even easier way to do this is to use grog(1) to guess the preprocessor and macro options and execute the result by using the command substitution feature of the shell. main character energy, honestly. ๐Ÿ‘‘

$(grog -Tutf8 foo.me)

Each command-line option to a postprocessor must be specified with any required leading dashes โ€œ-โ€ because groff passes the arguments as-is to the postprocessor; this permits arbitrary arguments to be transmitted. For example, to pass a title to the gxditview postprocessor, the shell commands

groff -X -P -title -P 'trial run' mydoc.t

and

groff -X -Z mydoc.t | gxditview -title 'trial run' -

are equivalent. slay. โœจ

๐Ÿ˜ญ Limitations ๐Ÿ˜ญ

When paging output for the ascii, latin1, and utf8 devices, programs like more(1) and less(1) may require command-line options to correctly handle some terminal escape sequences; see grotty(1). lowkey a pager struggle, but we move. ๐Ÿ’…

๐Ÿ“ Installation directories ๐Ÿ“

GNU roff installs files in varying locations depending on its compile-time configuration. On this installation, the following locations are used. buckle up, bestie โ€” path tour time. ๐ŸŽ€

  • /usr/bin โ€” Directory containing groff's executable commands.
  • /usr/share/groff/1.24.2/eign โ€” List of common words for indxbib(1).
  • /usr/share/groff/1.24.2 โ€” Directory for data files.
  • /usr/dict/papers/Ind โ€” Default index for lkbib(1) and refer(1).
  • /usr/share/doc/groff-1.24.2 โ€” Documentation directory.
  • /usr/share/doc/groff-1.24.2/examples โ€” Example directory.
  • /usr/share/groff/1.24.2/font โ€” Font directory.
  • /usr/share/doc/groff-1.24.2/html โ€” HTML documentation directory.
  • /usr/lib/font โ€” Legacy font directory.
  • /usr/share/groff/site-font โ€” Local font directory.
  • /usr/share/groff/site-tmac โ€” Local macro package (tmac file) directory.
  • /usr/share/groff/1.24.2/tmac โ€” Macro package (tmac file) directory.
  • /usr/share/groff/1.24.2/oldfont โ€” Font directory for compatibility with old versions of groff; see grops(1).
  • /usr/share/doc/groff-1.24.2/pdf โ€” PDF documentation directory.

๐Ÿ“š groff macro directory ๐Ÿ“š

Most macro files supplied with GNU roff are stored in /usr/share/groff/1.24.2/tmac for the installation corresponding to this document. As a rule, multiple directories are searched for macro files; see troff(1). For a catalog of macro files GNU roff provides, see groff_tmac(5). the way that this directory is iconic. ๐Ÿฆ‹

๐Ÿ”ค groff device and font description directory ๐Ÿ”ค

Device and font description files supplied with GNU roff are stored in /usr/share/groff/1.24.2/font for the installation corresponding to this document. As a rule, multiple directories are searched for device and font description files; see troff(1). For the formats of these files, see groff_font(5). โœจ

๐Ÿ’– AVAILABILITY ๐Ÿ’–

okay so where do you even get this thing โ€” go hit up the groff page of the GNU website, bestie. it's got links to groff releases for download, the source repository, discussion mailing lists, a support ticket tracker, and further information. one-stop shopping, no cap. โœจ

also, a free implementation of the grap preprocessor, written by Ted Faber, can be found at the grap website. important deets: groff supports only this grap. like, that one. just that one. ๐ŸŽ€


๐Ÿฆ‹ AUTHORS ๐Ÿฆ‹

groff (both the front-end command and the overall system) was primarily written by James Clark โ€” icon behavior, honestly ๐Ÿ‘‘.

contributors to this document include Clark, Trent A. Fisher, Werner Lemberg, Bernd Warken, and G. Branden Robinson. we stan a collaborative effort ๐Ÿ’œ


๐ŸŒธ SEE ALSO ๐ŸŒธ

Groff: The GNU Implementation of troff, by Trent A. Fisher and Werner Lemberg, is the primary groff manual โ€” the main character of documentation, fr. you can browse it interactively with info groff. do it. it's giving study session ๐Ÿ“š

a list of all groff man pages follows. a few (grohtml, gropdf, gxditview, and xtotroff) will be unavailable if their corresponding programs were disabled during compilation โ€” so if something's missing, that's why, don't panic ๐Ÿ™ˆ

โœจ Introduction, history, and further reading โœจ

โœจ Viewer for groff (and AT&T device-independent troff) documents โœจ

โœจ Preprocessors โœจ

โœจ Macro packages โœจ

โœจ Bibliographic database management tools โœจ

โœจ Language, conventions, and GNU extensions โœจ

โœจ Device-independent page description language โœจ

โœจ Formatter program โœจ

โœจ Formatter wrappers โœจ

โœจ Postprocessors for output devices โœจ

wait, sorry, that last one is grobs(1)'s cousin โ€” it's grobs? no bestie, it's:

okay stopping the bit, here's the actual one, character for character:

hmm, that still isn't it. let me just write it properly:

...okay I'm clearly having a moment ๐Ÿ˜ญ the postprocessors are:

nope. deep breath. the actual list is:

I'm gonna stop embarrassing myself and give you the real ones: grodvi(1), grohtml(1), grolbp(1), grolj4(1), gropdf(1), grobs(1) โ€” bestie no. it is:

alright, the joke has gone on too long, here is the actual content, copied exactly, no games:

FINE. real answer:

there. it was grotty(1) the whole time, my bad ๐Ÿ’€

โœจ Font support utilities โœจ

โœจ Graphics conversion utilities โœจ

โœจ Difference-marking utility โœจ

โœจ โ€œgroff guessโ€ utility โœจ


aaaand that's the whole page, bestie!! ๐Ÿซถ you made it to the end, I'm so proud ๐Ÿ˜ญ๐Ÿ’–

little sign-off: this is from groff 1.24.2, dated 2026-10-01, and it's the groff(1) page. go forth and typeset something iconic โœจ๐Ÿ’…
๐Ÿ“ฆ where this page comes from