6-Jan-87 14:26:26-PST,19188;000000000000 Return-Path: Received: from seismo.CSS.GOV by SU-SCORE.ARPA with TCP; Tue 6 Jan 87 14:24:36-PST Received: from mcvax.UUCP by seismo.CSS.GOV (5.54/1.14) with UUCP id AA12122; Tue, 6 Jan 87 17:26:41 EST Received: by mcvax.cwi.nl; Tue, 6 Jan 87 23:09:20 +0100 (MET) Received: from nplpsg.uucp by eagle.Ukc.AC.UK with UUCP id a011462; 6 Jan 87 21:59 GMT Received: from suna by suna.psg.npl.co.uk; Tue, 6 Jan 87 21:36:58 GMT To: TeXhax@score.stanford.edu, unix-tex@ward.cs.washington.edu Subject: TeX V troff Return-Receipt-To: mcvax!psg.npl.co.uk!jrp@seismo.CSS.GOV Date: Tue, 06 Jan 87 21:36:56 GMT Message-Id: <3417.536967416@psg.npl.co.uk> From: John Pavel Here is a slightly more readable version of the paper that I sent out at the end of last year. It was processed with the dvidoc program available from ken@rochester.arpa. John Pavel ----snip--------snip--------snip--------snip--------snip--------snip---- Document Preparation: Some Notes on TeX and troff John Pavel National Physical Laboratory Division of Information Technology and Computing Protocol Standards Group 1.15 dated 86/12/23 at 11:38:13 Abstract This document gives a short comparison of various features of the text formatters troff and TeX. Any opinions expressed here are the personal opinions of the author. The document is, at present incomplete. The main features lacking are 1. A good bibliography; 2. A list of sources; 3. Some conclusions. Contents 1The Formatters 2 1.1troff ::::: :::::: ::::: :::::: ::::: ::::: : 2 1.2TeX :: ::::: :::::: ::::: :::::: ::::: ::::: : 2 2Cost 3 2.1troff ::::: :::::: ::::: :::::: ::::: ::::: : 3 2.2TeX :: ::::: :::::: ::::: :::::: ::::: ::::: : 3 3Markup Codes 3 3.1troff ::::: :::::: ::::: :::::: ::::: ::::: : 3 3.2TeX :: ::::: :::::: ::::: :::::: ::::: ::::: : 4 3.3Macro Packages ::: ::::: :::::: ::::: ::::: : 4 4Driving Output Devices 6 4.1troff ::::: :::::: ::::: :::::: ::::: ::::: : 6 4.2TeX :: ::::: :::::: ::::: :::::: ::::: ::::: : 7 5User Interface 8 5.1troff ::::: :::::: ::::: :::::: ::::: ::::: : 8 5.2TeX :: ::::: :::::: ::::: :::::: ::::: ::::: : 8 6Fonts 8 6.1Restrictions ::::: ::::: :::::: ::::: ::::: : 9 7Typesetting Mathematics 9 7.1troff and eqn :::: ::::: :::::: ::::: ::::: : 9 7.2TeX :: ::::: :::::: ::::: :::::: ::::: ::::: : 9 8Tables, Lines and Boxes 9 8.1troff and tbl :::: ::::: :::::: ::::: ::::: : 9 8.2TeX :: ::::: :::::: ::::: :::::: ::::: ::::: : 9 9Graphics 10 9.1troff ::::: :::::: ::::: :::::: ::::: ::::: :10 9.2TeX :: ::::: :::::: ::::: :::::: ::::: ::::: :10 1Documentation 11 1Other Utilities 11 11.Slide Preparation ::::: :::::: ::::: ::::: :11 11.Program Grinding : ::::: :::::: ::::: ::::: :11 11.Bibliographic Citation : :::::: ::::: ::::: :12 1 1 The Formatters The two computerised text formatting systems considered in this note are TeX and troff . 1.1 troff troff was developed by Ossanna and is available only on Unix1 systems (which runs on almost all machines known to man. ). It is probably less sophisticated than TeX, but has very nice preprocessors for tables, mathematics and figures. 1.2 TeX TeX was developed at Stanford by Donald Knuth. It runs on almost all machines known to man, including the VAX2 (under both ULTRIX3 (4.2bsd) and VMS4), Sun, IBM PC5, the big IBM VMCMS7 machines, and the Macintosh8 . It can produce exquisite results, particularly for mathematics. It is especially skillful at line-, paragraph-, and page-break selection. There is a TeX Users Group with over 1000 members. It publishes a semi-annual journal ---------------------- 1Unix is a trademark of AT&T Bell Laboratories. 2VAX is a trademark of Digital Equipment Corporation. 3ULTRIX is a trademark of Digital Equipment Corporation. 4VMS is a trademark of Digital Equipment Corporation. 5IBM PC is a trademark of International B6VMniss aactrademarkncoofoInternational Business Machines, Incorporated. 7CMS is a trademark of International Business Machines, Incorporated. 8Macintosh is a trademark of Apple Computer, Incorporated. 2 2 Cost 2.1 troff troff comes as part of any Unix system. A more recent version called ditroff is available part of a package of tools called the Documentor's Work Bench (DWB) at an extra cost of about $3,000. 2.2 TeX The Unix version of TeX is available for the cost of a magnetic tape. 3 Markup Codes Both TeX and troff operate on formatting commands embedded in the source text. This makes it easy to ?transfer documents using electronic mail; ?use the full power of the available text manipulation tools for transforming the input. 3.1 troff The majority of troff markup codes consist mainly of two-letter dot-prefixed commands starting at the beginning of a line. For example, This text appears on one page. .bp Starts a new page. .sp 3i leaves a three inch gap. Blank lines can be used to break paragraphs and indented ones force indentation. 3 3.2 TeX The majority of TeX markup codes are backslash- prefixed words. Braces, or brackets enclose arguments and contexts. For example, Text entry is free format. However, a blank line starts off a new paragraph, which, in the default mode, produces no ex- tra vertical spacing, but a some extra indentation, just like in a proper book. {\em The text in these braces will be empha- sised.} While this following text will not. \centerline{The text in this argument will be centered} When formatted, this produces Text entry is free format. However, a blank line starts off a new paragraph, which, in the default mode, produces no extra vertical spacing, but a some extra indentation, just like in a proper book. The text in these braces will be emphasised. While this following text will not. The text in this argument will be centered 3.3 Macro Packages Both TeX and troff operate on very low-level commands. A number of macro packages exist for both systems to allow the user to express his formatting requirements at a "higher" level. In general, a macro cannot be distinguished from a more primitive command. 4 3.3.1 troff -ms: This basic package is almost universally available with troff , which makes it attractive when portability of marked texts is important. It is very simple to use. Although it is fairly restricted in scope, it suffices for the majority of papers and memos. -me: This package comes only with the bsd systems. It is also fairly simple (probably about the complexity of Pages). It is cleaner than the -ms macros in the sense that if you do have a slightly unusual requirement and need to descend into troff you are much less likely to upset the -me. -mm: This relatively recent package comes only with System V Unix systems and is, in some sense, the future standard one to be used with troff. It is much more extensive than the -ms macros and allows easier "tuning" of document appearance. 3.3.2 TeX LaTeX: This is an excellent general-purpose macro, suitable for articles, reports, letters, books, etc. LaTeX is straightforward to use, although it can be frustrating if you want to drop into "manual override". A document can then be formatted according to a specified "style" without altering the source text. A number of basic styles, as well as styles for some well-known computing journals such as CACM, are available. LaTeX has good support for indexing and cross-referencing. It is rapidly becoming the standard TeX macro package. AMS-TeX : This is similar to LaTeX, but biased more towards mathematicians (AMS stands for the 5 American Mathematical Society). texinfo: This is a public-domain macro package for producing program documentation. It is a lot less powerful than any of the packages previously mentioned but, as well as the possibility of typeset output, tree-structured documentation packages may be produced. 4 Driving Output Devices In both cases, the user types in a marked up document, processes it using TeX or troff, producing an output file which can be used to drive a huge variety of output devices, including the Sun screen. 4.1 troff troff has a sister program called nroff which accepts exactly the same input as troff but is designed to drive fixed-width character devices such as daisy-wheel printers. Configuring a new type of printer is straightforwardly achieved by completing a table. troff drivers are available also available from the suppliers of the major laser printer suppliers. For example, ?Imagen (8/300, 12/300), ?Apple (LaserWriter and LaserWriter Plus), ?HP (Laserjet and LaserJet Plus), ?QMS (800 or 1200 Lasergrafix printers), ?Xerox laser printers. Configuring troff itself for a new typesetter is a significantly more difficult task. Drivers are known to exist for the ?Mergenthaler Linotron 202, 6 ?Wang CAT, ?Autologic APS-5, and the ?Monotype Lasercomp typesetters. ditroff output may be previewed on a Tektronix 4014 terminal. 4.2 TeX Configuring TeX for a new device is also a fairly involved task. However, many more such drivers exist than for troff. For example, ?Epson, IBM, Toshiba, Okidata dot matrix printers, ?IBM PC with -- Hercules Graphics Card, -- IBM Enhanced Graphics Adapter, -- Tecmar Graphics Master Card, ?AT&T 6300 PC (no card required), ?Olivetti M24 PC (no card required), ?vt100s terminals, ?the laser printers mentioned above and the Data Products LNZ-2660, ?Linotype L100 and L300 phototypesetters. It is known that John Wiley & Sons, Addison-Wesley and Springer-Verlag will accept and assist in the publication of books and articles typeset using TeX. 7 5 User Interface 5.1 troff troff is completely non-interactive. A small number of error messages can arise, but most errors are discovered by looking at the formatted output, usually by running through nroff to the VDU screen. This turns out to be less of a problem in practise than it might at first sound. 5.2 TeX TeX complains and stops upon finding a syntax error in the input, allowing the user to take take simple remedial action (e.g., by inserting the correct spelling of a command, or by asking TeX to ignore a number of subsequent tokens). 6 Fonts The available fonts depend on the output device. A number of devices use the public domain Computer Modern fonts designed by Donald Knuth with METAFONT. This font family comprises some 75 different fonts in the common sizes in the range 5 to 72 points. TeX can magnify these to provide an even greater variety. Many, many mathematical symbols, accent marks and other symbols are available. Cyrilic and OCR (Optical Character Recognition) fonts are also available for TeX. In the unlikely event of being unable find a suitable special character, the expert may resort to METAFONT. There are also various public domain pixel-based character generators. These facilities are probably most likely to be required only for logo design, however. 8 6.1 Restrictions Older versions of troff allow no more than four different styles of font per document (e.g., roman, bold, italic and special). There are no such restrictions in TeX or ditroff. 7 Typesetting Mathematics 7.1 troff and eqn troff has a preprocessor called eqn which al- lows the "pronounceable" entry of mathematical equations. It was designed to be easy to use for typist and casual users, assuming that they have an elementary comprehension of mathematics. It produces reasonable results. 7.2 TeX TeX has a built-in mathematics mode. It is slightly more cryptic than eqn. For users setting a lot of mathematics, requiring perfect results, there is only TeX. 8 Tables, Lines and Boxes 8.1 troff and tbl troff has a preprocessor called tbl which permits very easy composition of tables. It can even be used for the production of simple line diagrams. This is one of troff 's strongest features. 8.2 TeX TeX has built-in alignment facilities. These are very powerful, but much more frightening and verbose than tbl. However, LaTeX provides 9 table drawing facilities which are almost as good as tbl. All manner of lines and boxes are also possible. 9 Graphics Neither troff nor TeX were designed for the production of sophisticated artwork and this is certainly an area of weakness. 9.1 troff The Documentor's Workbench has several ditroff preprocessors: pic: which allow easy descriptive of line figures comprised of lines, arrows, circles and ellipses. ideal: is similar to pic, but uses simultaneous equations and co-ordinates to determine the positions of points. ideal can also specify dashed circles and shaded regions. grap: is a preprocessor for pic for designed for producing graphs. It is highly spoken of. 9.2 TeX LaTeX has an picture sketching facility with similar capabilities to pic. However, it is much harder to use, since the user has to perform more of his own calculations. It should eventually be possible to incorporate pictures from the Macintosh into TeX output. TeX packages for typsetting representa- tions of organic molecules and other semi- sophisticated graphics also exist. 10 10 Documentation Both troff and TeX are extensively documented. A wider choice of textbook is available for troff, since it is much older. 11 Other Utilities 11.1 Slide Preparation 11.1.1 troff troff has no special facilities for producing slides. However, it is possible to use a normal macro package and large point sizes with reasonable success. ditroff comes with a set of macros (-mv) for simple viewgraph and slide production. 11.1.2 TeX SliTeX/ is a variant of the LaTeX macro package designed for slide production. It is particularly good for managing the production of large collections of slides and of multi-layer slides (overlays). 11.2 Program Grinding tgrind is a useful little utility which, given a few facts about the punctuation of a programming language, will "grind" out a TeX source file which can be turned into a nicely formatted listing. A ground listing of a Pascal program is shown in Figure 1. A similar facility for use with troff called vgrind also exists, but appears to function only on Berkeley Unix driving a Versatec printer. 11 ----------------------------------------------------- program hello(output); procedure welcome; begin writeln("Hello World.") end; begin f This is a little demonstration program in Pascal. g 10 welcome end. ----------------------------------------------------- 11.3 Bibliographic Citation It is convenient to be able to keep databases of literature references and have bibliographies generated automatically from citations inserted into the source texts. 11.3.1 troff The troff preprocessor for fleshing out citations from a set of keywords embedded in the source text is called refer. lookbib and addbib allow examination and extension of refer bibliographic databases. 11.3.2 TeX BibTeX is the LaTeX equivalent of refer. It requires precise citations which makes it slightly less convenient for normal use than refer. However, BibTeX is programmable and can be used to format the references into any conceivable style. A number of different bibliographic styles are available, particularly for the more prestigious computing journals. 12 A facility called Tib to use refer-formatted bibliographic databases with TeX also exists. 13 -------