Category:N/t/roff: Difference between revisions

No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1:
{{language|N/t/roff}}
'''N/t/roff''' or '''/.ROFF/''' (regular expression) is a document formatting language used to instruct an automated typesetter/typewriter (i.e. printer) to set/print a document's text. Its name is an acronym of ''New Runoff'' and ''Typesetter Runoff'' respectively. For document preparation purposes (i.e. its designed use), the rules of how text is laid out is written in a ''/.ROFF/ source file''. /.ROFF/ is a predecessor of TeX, and so its ability is a subset of that of TeX and its core values is indeed very similar to that of TeX. To assist the writer in writing documents, macro packages, such as ''-me'', ''-ms'', ''-mm'', and ''-mom''; typefaces and their fonts, such as ''Avant Garde'', ''Helvetica'', and ''Times Roman''; and preprocessors like ''eqn'', ''pic'', and ''tbl'' are available at the writer's disposal. These macro packages and extensions are similar to what LaTeX provides to plain TeX.
 
/.ROFF/ '''are''' also compilers for the /.ROFF/ formatting language. The regular expression /.ROFF/ in this page metaphorically matches ''TROFF'' and ''NROFF'' (but it technically matches more than that). Thus, ''TROFF'' and ''NROFF'' are compilers.
The two compilers understand and parse the same language of /.ROFF/, but their outputs are '''not''' the same. Document output from the ''TROFF'' compiler is better-suited for typesetters: photo-typesetters, laser printers, etc.; whereas output from the ''NROFF'' compiler is better-suited for typewriter-like printers: line printers, daisy wheel printers, or glass teletypes. This holds, even if the both compilers get the exact same input verbatim; although all logical flow controls are executed in the same manner.
 
A typical ''/.ROFF/ source file'' for documents is a plaintext file with the extensions: <code>*.roff</code>, <code>*.me</code>, <code>*.ms</code>, <code>*.mm</code>, or <code>*.mom</code>. The extension depends on what macro package is used to set the pages of the document, although the /.ROFF/ compiler treats all of them the same way and associates no special meanings thither. Such a /.ROFF/ document contains the document's text itself (i.e. the writer's actual words) ''interspersed'' with some formatting requests that instruct the computer how to set the text on a page.
 
The complexity of those such requests, their subtleties, and how they intertwine is what makes up the basic /.ROFF/ formatting language. For more complex formatting work, the language offers logical constructs (if-else's), numerical registers (<code>.nr</code>), macro definitions with formal parameters (<code>.de</code>, akin to function definitions), and recursive macro calls. These features are what make the /.ROFF/ language Turing-complete as well, although tasks easy in most programming languages won't necessarily be easy in /.ROFF/. To quote Professor Brian W. Kernighan, a user of TROFF, in an email about this (November 23, 2017):
Line 31 ⟶ 32:
 
== Implementations ==
Given the availability, computational superiority, and free/open-source nature of GROFF, it is one of the best implementations, not only to typeset exceptionally beautiful documents, but also to implement algorithms and solve problems on Rosettacode. Heirloom Troff is also a good candidate as well and works pretty much the same as GROFF when <code>.cp 0</code> is set.
Anonymous user