Why groff?

UNIX systems in general and Linux systems in particular offer users a large and growing number of choices for committing text to print. These include everything from commercial and open-source WYSIWYG word processors, to other typesetting engines such as TEX/LATEX and lout. The main reason for preferring typesetters to word processors is the advantage of logical markup compared to visual formatting. This is in some ways a matter of personal preference, and in others a matter of conceptual savy. The main reason for preferring groff to its brethren is that it has a simpler, smaller command set than the other packages and is included with even minimal installs.

The article assumes the reader may already be familiar with the fundamental advantages of logical formatting. This difference is in many ways analogous to the difference between using a spreadsheet and a database. In a spreadsheet, the data is inseparable from its visual layout. A database, on the other hand, maintains data separately from its visual appearance, so that layout may be flexibly specified in any number of ways with other tools and report generators as the occasion demands. It is typical for a spreadsheet to be easier to set up in the initial stages of development and useful for prototyping. But for projects requiring longevity, flexibility and portability, it is generally considered preferable to keep the underlying data unbundled from its visual layout.

This is the philosophy behind the structured markup conventions demonstrated in the growing movement toward XML, which treats documents as consisting of logical blocks of information in order to make that information more accessible. These logical blocks may then be defined to have specific and consistent formatting and appearance attributes, to convey the visual cues appropriate for their logical structure, as well as to be appropriate for the target media used for publication.

Some other reasons for using groff may include:

Through the use of groff macros, it is possible to develop a set of logical markup tags and style sheets that provide a consistent “look and feel” for document collections—for yourself, your workgroup and even across departments. This system allows global revision of the “look and feel” of archived documents at any time, requiring no modification to the documents themselves. And, users won't need to spend their time forever “tweaking” the layout of their documents, as is so tempting in WYSIWYG environments.

groff makes an excellent choice as a formatting/typesetting engine for your own applications. By building your programs to generate simple plain-text output with embedded groff macros, you can provide access to typeset-quality printed output. Programs designed in this way are relatively easy to implement (as compared to, say, generating PostScript directly), are portable and device-independent. Your end users may change the definition of the underlying groff macros to suit their own preferences without needing to access or modify your program source code.

groff is one of those tools that just fits nicely into “the UNIX way”, a tool that performs its designated task with aplomb, power and flexibility, and in fluid concert with other tools in the system. The groff package includes a set of preprocessors that format tabular data, equations and line drawings, while groff itself performs the typesetting. This makes groff easily adaptable through the use of pipes and filters to other custom applications, such as form letters and report templates.