LinuxCommandLibrary

nroff

Format text for terminal display or printing

SYNOPSIS

nroff [options] [file ...]

PARAMETERS

-Tname
    Specifies the output device or terminal type (e.g., lp, 300, latin1, utf8). This option largely dictates how the output is rendered.

-olist
    Prints only the specified pages from the document. list can be a comma-separated range (e.g., 1,3-5,7).

-sn
    Stops processing and prompts for continuation every n pages, useful for printing on physical printers.

-raN
    Sets the numeric register a to the value N. Registers are internal variables used for formatting control.

-uN
    Sets the emboldening factor to N, controlling the number of times characters are overstruck to simulate bold text.

-i
    Reads standard input after processing all specified input files, allowing for piped input.

-z
    Suppresses all output, primarily useful for checking syntax errors in the input files without displaying the formatted result.

-h
    Uses tab characters instead of multiple spaces in the output where possible, which can save bandwidth and improve rendering on some terminals.

-e
    Produces equally-spaced words in the output, striving for a more justified appearance.

-mname
    Prepends the macro file `/usr/lib/tmac/tmac.name` (or similar path) to the input files, loading specific macro packages like man, ms, or mm.

DESCRIPTION

nroff (New ROFF) is a venerable and powerful text formatting program, historically a cornerstone of the Unix operating system for producing readable documents on character-oriented display devices such as terminals and line printers. It processes input files containing plain text interspersed with special formatting requests and macro calls. These instructions control various aspects of document layout, including font styles (though often rendered as overstriking or bold on terminals), spacing, pagination, and structural elements. Unlike its sibling, troff, which targets high-resolution typesetters, nroff is optimized for plain text output, making it the primary engine behind the display of manual pages (man pages) on virtually all Unix-like systems. It supports various macro packages like -man, -ms, and -mm to simplify complex document creation.

CAVEATS

In modern Linux distributions, the functionality of nroff is largely provided by the groff (GNU roff) project. When you invoke nroff, it typically executes groff with options configured for terminal output. Consequently, direct usage of nroff is less common for new document creation, but it remains critical for viewing existing formatted documents like manual pages. Its capabilities are limited to character-based rendering, meaning it cannot produce complex graphics, true scalable fonts, or advanced typographical effects common in graphical word processors.

<B>MACRO PACKAGES</B>

nroff's power lies in its extensive support for macro packages (e.g., man, ms, mm). These packages are collections of predefined formatting requests that abstract away low-level commands, allowing users to focus on document structure and content rather than intricate typesetting details. For instance, the man macros are specifically designed for formatting manual pages.

<B>UNIX PHILOSOPHY AND PIPELINING</B>

True to the Unix philosophy, nroff is often used as part of a toolchain. It can process output from specialized preprocessors like tbl (for tables), eqn (for equations), and pic (for diagrams), and its output can then be further refined by post-processors like col for optimal terminal display. This modular approach allows for flexible and powerful document processing.

HISTORY

nroff emerged from Bell Labs in the early 1970s as a descendant of the original roff (Run Off) text formatting system. It was specifically developed to produce formatted output on line printers and character-oriented terminals, making it a pivotal tool for generating documentation, particularly the manual pages, for the nascent Unix operating system. Its development ran parallel to troff, which was designed for high-resolution phototypesetters. Although the original nroff implementation has been largely superseded by the open-source groff (GNU roff) project, groff meticulously maintains backward compatibility, ensuring that historical documents and the fundamental mechanism for displaying man pages continue to function seamlessly across Unix-like systems today.

SEE ALSO

troff(1), groff(1), man(1), col(1), tbl(1), eqn(1), pic(1), refer(1)

Copied to clipboard