groff
Quick Reference
Command Name:
groff
Category:
text processing
Platform:
linux
Basic Usage:
Common Use Cases
- 1
Document formatting
Create formatted documents using the groff typesetting system
- 2
Report generation
Generate professional-quality reports and documents
- 3
Scripting
Use in shell scripts to generate formatted documents programmatically
- 4
Document processing
Manipulate and transform document data
Syntax
groff [OPTION]... [FILE]...
Options
| Option | Description |
|---|---|
| -a | Generate an ASCII approximation of the typeset output |
| -b | Print a backtrace with each warning or error message |
| -c | Disable color output |
| -e | Preprocess with eqn (for equations and mathematical notation) |
| -E | Inhibit all error messages of troff and its preprocessors |
| -g | Preprocess with grn (for gremlin illustrations) |
| -G | Process with grap preprocessor (for graphs) |
| -i | Read standard input after all specified files |
| -I DIR | Search directory DIR for included files |
| -j | Preprocess with chem (for chemical structure diagrams) |
| -J | Preprocess with refer (for bibliographic references) |
| -k | Produce output that maintains the original page layout |
| -l | Send the output to a printer |
| -m PACKAGE | Use macro package PACKAGE (e.g., -man, -ms, -mm, -mom) |
| -M DIR | Search directory DIR for macro files |
| -n NUM | Number first page NUM |
| -N | Disable groff extensions (for compatibility with classical troff) |
| -p | Preprocess with pic (for diagrams) |
| -P ARG | Pass ARG to the postprocessor |
| -r REG=VAL | Set register REG to VAL |
| -R | Preprocess with refer and process citations |
| -s | Preprocess with soelim (for including files) |
| -S | Safer mode (disable some potentially unsafe features) |
| -t | Preprocess with tbl (for tables) |
| -T FORMAT | Set output format to FORMAT (e.g., -Tpdf, -Thtml, -Tps, -Tascii) |
| -v | Print version information |
| -w | Enable warning messages |
| -W LEVEL | Set warning level to LEVEL |
| -z | Suppress formatted output (for checking errors) |
Examples
How to Use These Examples
The examples below show common ways to use the groff command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
groff -man manpage.1
Format a man page file (manpage.1) for terminal display. This processes the file with the "man" macro package, which is designed for creating Unix manual pages.
groff -man -Tpdf manpage.1 > manpage.pdf
Format a man page file and output as PDF. The -T option specifies the output format (in this case, PDF), allowing you to create professional-looking documentation.
groff -ms document.ms -T html > document.html
Format a document using the ms macros and output as HTML. The ms macro package is useful for general document formatting, and the HTML output can be viewed in any web browser.
groff -t -e -mandoc -Tascii manpage.1 | less
Format a man page with tbl and eqn preprocessors for ASCII output and view with less. The -t and -e options enable the tbl (table) and eqn (equation) preprocessors for handling tables and mathematical equations.
Advanced Examples:
groff -pet -ms complex.ms -Tps > complex.ps
Process a document with pic, eqn, and tbl preprocessors, using ms macros, and output as PostScript. This combines multiple preprocessors for handling diagrams (-p), equations (-e), and tables (-t) in a single document.
man ls | groff -man -Thtml > ls.html
Convert a man page directly from the man command to HTML format. This is useful for creating web-readable versions of man pages from the system's documentation.