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