troff
Troff is a command line tool and text formatting language developed in the 1970s primarily for creating typeset documents. It was initially designed for the Unix operating system but has been ported to various platforms over the years. Troff stands for "typesetter roff," with "roff" being short for "run-off," meaning the production of formatted output.
Troff operates by processing input text files that contain a combination of plain text and formatting commands. These commands provide instructions for various formatting tasks such as changing font styles, adjusting line spacing, managing page breaks, and incorporating tables and diagrams.
The formatting commands in troff are represented by escape sequences and are prefixed with a period (.). For example, .B is used for bold text, .I for italic, and .HP for paragraph indentation. This allows users to control the appearance and structure of their documents with fine-grained precision.
In addition to text formatting, troff also provides support for typesetting mathematical formulas, including equations, fractions, subscripts, and superscripts. This makes it suitable for technical and scientific documentation.
Troff output can be sent directly to a printer, displayed on a terminal screen, or saved to a file for later processing. It supports various output devices and formats, including PostScript, PDF, and plain text.
To help streamline the document creation process, troff includes a set of pre-defined macro packages, such as the "ms" and "mm" macros, which provide higher-level commands for common formatting tasks. These macros can be customized or extended to suit specific requirements.
Over the years, troff has inspired a number of derivative systems, such as the GNU tr2tex and groff tools, which offer enhanced functionality and improved compatibility with modern systems. However, troff remains popular and widely used for its simplicity, efficiency, and stability.
While troff has a steeper learning curve compared to more modern document processors, it offers a high level of control and customization, making it a favored choice for experienced users and those seeking precise document formatting.
Troff has played a significant role in the history of computer typography, paving the way for subsequent text processing systems and contributing to the development of electronic publishing.
List of commands for troff:
-
troff:tldr:2fa85 troff: Format output as [a]SCII text using the [man] macro package.$ troff -T ${ascii} -${man} ${path-to-input-roff} | grottytry on your machineexplain this command
-
troff:tldr:38c22 troff: Format output as a [pdf] file, saving the output to a file.$ troff -T ${pdf} ${path-to-input-roff} | gropdf > ${path-to-output-pdf}try on your machineexplain this command
-
troff:tldr:7cd4c troff: Format output for a PostScript printer, saving the output to a file.$ troff ${path-to-input-roff} | grops > ${path-to-output-ps}try on your machineexplain this command
-
troff:tldr:bcf9c troff: Format output for a PostScript printer using the [me] macro package, saving the output to a file.$ troff -${me} ${path-to-input-roff} | grops > ${path-to-output-ps}try on your machineexplain this command