Troff and Friends
Total Page:16
File Type:pdf, Size:1020Kb
this talk • history and background • theory • practical usage ... of nroff, troff, and friends (tbl, eqn, refer, pic) troff and friends please interrupt me at any time in case of questions markus schnalke <[email protected]> please tell me what I should demonstrate goal: motivate to learn and use these programs my troff history historical background ______________________________________________________ years ago __________________________________first contact through man pages see my talk on ‘‘old software treasuries’’ ___________________________________________________ a simple document, just to try it___ quick summary: ___________________________________________________a year ago used pic for my diploma thesis___ • terminal = keyboard + line printer ___________________________________________________two months ago started to learn troff better ___ • no screen orientation thus: It’s all pretty new to me too :-) • size limits on software history of typesetting history of troff • completely by hand early 60s at MIT: •‘‘hot metal’’ typesetting (Linotype) • RUNOFF for CTSS • completely by computers (line printers and photo- • ‘‘right-justifying type-out program’’ typesetters) • ported to many systems (also MULTICS) goal: text automatically right-adjusted and hyphenated around 1970 at Bell Labs: • roff by McIlroy (Unix version of RUNOFF) • used daily history of troff (2) glossary nroff (‘‘new roff’’) • word processing • by Joe Ossanna • text formating • strength: macro programmable • document preparation • still only for daisy wheel/golf ball printers • typesetting troff (‘‘typesetting roff’’?) and: nroff, ditroff, troff, otroff • superset of nroff groff is the GNU implementation of troff and friends • written when Bell Labs got a phototypesetter • supports different fonts, font sizes, more characters, ... • basically the same program as nroff with different out- put TeX Differences: __________________________________________________ metaphor basic entity troff__________________________________________________ hand composer line TeX__________________________________________________ raster image paragraph nroff Heirloom troff does also include paragraph-at-once adjustment, hanging characters, and micro typography but no question, TeX is great software! nroff nroff (2) Input consists of: overview • command lines (match to /ˆ[.’]/) words lines nroff • input lines (everything else) on lines on pages • plus escape sequences (introduced with backslash) nroff does: Unrecognized commands are simply ignored • filling (→ hyphenation) • adjusting (→ adding inter-word spaces) All commands and names are one or two characters number registers • own namespace • set with: .nr XY 42 • substitute value: \n(XY • increment, decrement in defineable steps possible <nroff demo> • defineable format: .af XY 0001 (1, 0001, i, I, a, A) • remove register: .rr XY strings macros • namespace together with macros and diversions • share namespace with strings and diversions • set with: .ds AB "foo • define: • substitute value: \*(AB .de AB • append: .as AB "bar . \" number of arguments: \n(.$ . \" first argument: \$1 • rename: .rn AB CD .. • remove: .rm AB .am • may contain escape sequences • append with: • rename and remove like with strings (diversions collect text for later insertion – not covered here) • add backslashes to delay interpretation • may be nested if two kinds: • .if with only one branch • .ie and .el with two branches true is: • ! false <nroff demo> • ’foo’foo’ • non-negative number (-1 is false!) • valid numeric comparison • e/o and t/n in the matching cases multiline branches with \{ and \} troff a nroff for phototypesetters supports: • high resolution and small movements • different fonts troff • different font sizes • special characters <troff demo> macro packages macro packages ms • principally not different from normal input • the standard macros • get prepended to the normal input • developed for Bell Labs internal documents • searched for at a central location • superseded by mm • usage: troff -ms input.ms • easy to learn (is the same as: troff s input.ms) • used for these slides • multiple macro packages for one document possible, but beware conflicts • well known macro packages are: ms, mm, me, man man slides • the man page macros • came from Sape Mullender over Uriel to me • that’s what you use when you write man pages • http://repo.cat-v.org/troff-slider/sample_slides.ms • stripped down to this specific task • I took .SS and .IT and added .PA, that’s all • could be improved ... and I plan to do that to learn more about troff ;-) • these slides are created with those macros, of course <macros demo> preprocessors preprocessors tbl • add ‘‘features’’ to troff by Mike Lesk • work only on text between start and end markers example code: • copy everything else through .TS • they are a very nice concept to extend software! center box; lfB | cfB | cfB l | c | c. write your own preprocessor (in the language of your tab separated fields choice) if you want to add some functionality = several lines of data _ last format applies _ to all further lines .TE eqn refer • by Kernighan and Cherry • by Mike Lesk • the first preprocessor • for literature references (like bibtex for LaTeX) • would hardly exist without yacc • but does a ‘‘fuzzy’’ search • write formulas as spoken in English • macro package needs to support refer • Greek letters and math symbols available example: • inline formulas possible with delim $$ .[ words unique to the referenced document example: .] x sub {1,2}˜=˜{ -b ˜+-˜ sqrt { b sup 2˜-˜4 a c } } over { 2 a } sample database entry: − ± √2 − = __b_____b_____4_ac__ %T Title x 1, 2 2a %A Author %D Date of publication %I Issuer pic • by Kernighan • draw diagrams by ‘‘explaining’’ them • impressed me much example: .PS further stuff ED: box "ed" arrow right box "ex" arrow box "vi" arrow up right from ED.ne box "grep" arrow down right from ED.se box "sed" .PE postprocessors doctype dpost • frequent question: which preprocessors are needed? • for troff • doctype gives the answer • converts device independent output to PostScript • introduced in ‘‘The Unix Programming Environment’’ • a script, mainly in awk col • easy to extend to personal needs • for nroff • removes backward movements (primary for multi column text) literature • ‘‘Text Processing and Typesetting with Unix’’ by Bar- this talk was prepared using tools of the Heirloom project: ron and Rees explains everything pretty good (focus on http://heirloom.sf.net nroff) the slides macros were taken from • ‘‘Heirloom Documentation Tools Nroff/Troff User's http://repo.cat-v.org/troff-slider/ Manual’’ by Ossanna, Kernighan, and Ritter is more a ed technical reference all editing was done with , of course :-) • Various documents collected on http://troff.org the slides and examples are available on my website http://marmaro.de/docs and on http://ulm.ccc.de/ChaosSeminar/ 2009-11-09.