henesyinit from p9fd787fda5 years agoHistory
3348 lines · 108.3 KB · HTML
RawDownload
<html>        <title>-</title><body BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#330088" ALINK="#FF0044"><H1>Troff User's Manual</H1><DL><DD><I>Joseph F. Ossanna<br>Brian W. Kernighan<br><br>&#32;<br>bwk@research.bell-labs.com<br></I></DL><H4>Introduction</H4><P><I>Troff</I> and <I>nroff</I> are text processors that format text for typesetter- andtypewriter-like terminals, respectively.They accept lines of text interspersed with lines offormat control information andformat the text into a printable, paginated documenthaving a user-designed style.<I>Troff</I> and <I>nroff</I> offerunusual freedom in document styling:arbitrary style headers and footers;arbitrary style footnotes;multiple automatic sequence numbering for paragraphs, sections, etc;multiple column output;dynamic font and point-size control;arbitrary horizontal and vertical local motions at any point;anda family of automatic overstriking, bracket construction, andline-drawing functions.  </P><P><I>Troff</I>produces its output in a device-independent form,although parameterized for a specific device;<I>troff</I> output must be processed by a driver for thatdevice to produce printed output.</P><P><I>Troff</I> and <I>nroff</I> are highly compatible with each other and it is almost alwayspossible to prepare input acceptable to both.Conditional input is provided to enablethe user to embed input expressly destined for either program.<I>Nroff</I> can prepare output directly for a variety of terminal types andis capable of utilizing the full resolution of each terminal.<I>Nroff</I> is the same program as <I>troff</I>; in fact, on Plan 9 <I>nroff</I> is a shell script that calls <I>troff</I> with theargument.</P><H4>Background to the Plan 9 Edition</H4><P>The primary change to <I>troff</I> and <I>nroff</I> for Plan 9 issupport of the Unicode Standard, which was added during1992 and 1993.  There are two results.  First, there is muchless need for the myriad of two-character names that are somuch a part of <I>troff</I> lore; in Plan 9, for example, one naturally uses theUnicode character &#189; instead of <I>troff</I>'sSecond, the output device, though calledis almost always a form of PostScript printer;the panoply of special drivers for different typesettershas largely disappeared.Unfortunately, not all PostScript printers can copewith Unicode characters, so there remains a need forprograms that synthesize PostScript characters from bitmaps;this is especially true for Asian languages.</P><H4>Background to the Second Edition</H4><P><I>Troff</I>was originally written by the late Joe Ossannain about 1973, in assembly language for thePDP-11,to drive the Graphic Systems CAT typesetter.It was rewritten in C around 1975,and underwent slow but steady evolution untilOssanna's death late in 1977.</P><P>In 1979, Brian Kernighanmodified<I>troff</I>so that it would produce output for a variety of typesetters,while retaining its input specifications.Over the decade from 1979 to 1989,the internalshave been modestly revised,though much of the code remains as it was when Ossanna wrote it.</P><P><I>Troff</I>reads parameter fileseach time it is invoked, toset values for machine resolution,legal type sizes and fonts, and character names,character widthsand the like.<I>Troff</I>output isASCIIcharactersin a simple languagethat describes where each character is to be placedand in what size and font.A post-processor must be written for each deviceto convert this typesetter-independent languageinto specific instructions for that device.</P><P>The output language contains information that was not readilyidentifiable in the older output.In the newer language, the beginning of each page, line, and wordis marked,so post-processors can do device-specific optimizationssuch as sorting the data vertically or printing it boustrophedonically,independent of<I>troff</I>.</P><P>Capabilities for graphics have been added:<I>troff</I>recognizes commands for drawing diagonal lines,circles, ellipses, circular arcs,and quadratic B-splines.There are also ways to pass arbitrary information to the output,unprocessed by<I>troff</I>.</P><P>A number of limitations have been eased or eliminated.A document may have an arbitrary number of fonts on any page(if the output device permits it, of course).Fonts may be accessed merely by naming them;``mounting'' is no longer necessary.There are no limits on the number of characters.Character height and slant may be setindependently of width.</P><P>The remainder of this document contains a description ofusage and command-line options;a summary of requests, escape sequences, and pre-defined number registers;a reference manual;tutorial examples;and a list of commonly-available characters.</P><H4>Acknowledgements</H4><P>Joe Ossanna's<I>troff</I>remains a remarkable accomplishment.For more than twenty years, it has proven a robust tool,taking unbelievable abuse from a variety of preprocessorsand being forced into uses that were never conceived ofin the original design,all with considerable grace under fire.</P><P>Recent versions of <I>troff</I> have profited fromsignificant code improvements byJaap Akkerhuis, Dennis Ritchie, Ken Thompson, and Molly Wagner.UTF facilities owe much to Jaap Akkerhuis.Andrew Hume, Doug McIlroy, Peter Nelson and Ravi Sethi made valuable suggestions on the manual.I fear that the remaining bugs are my fault.<br>&#32;<br><HR><br>&#32;<br></P><br>&#32;<br><B>Usage</B><P><I>Troff</I> or <I>nroff</I> is invoked as<DL><DT><DD><TT><PRE>troff  <I>options  files</I>nroff  <I>options  files</I></PRE></TT></DL>where <I>options</I> represents any of a number of option argumentsand <I>files</I> represents the list of files containing the documentto be formatted.An argument consisting of a single minusrepresents standard input.If no filenames are given input is taken from the standard input.The options, which may appear in any order so long as they appearbefore the files, are:<br><img src="-.16251.gif"><br></P><P>Each option is a separate argument;for example,<DL><DT><DD><TT><PRE>troff -Tutf -ms -mpictures -o4,6,8-10 <I>file1 file2</I></PRE></TT></DL>requests formatting of pages 4, 6, and 8 through 10 of a document contained in the filesnamed <I>file1</I> and <I>file2</I>,specifies the output in UTF,and invokes the macro packagesand</P><P>Various pre- and post-processors are available for use with <I>nroff</I> and <I>troff</I>.These include the equation preprocessor<I>eqn</I>(for <I>troff</I> only),the table-construction preprocessor<I>tbl</I>,and<I>pic</I>and<I>grap</I>for various forms of graphics.<br>&#32;<br><HR><br>&#32;<br></P><br>&#32;<br><B>Request Summary</B><P>In the following table,the notation &#177;<I>N</I> in the<B><I>column means that the forms </I></B><I>N</I><B><I>, </I></B><I>+N</I><B><I>, or </I></B><I>-N</I><B><I> are permitted,to set the parameter to </I></B><I>N</I><B><I>, increment it by </I></B><I>N</I><B><I>, or decrement it by </I></B><I>N</I><B><I>,respectively.Plain </I></B><I>N</I><B><I> means that the value is used to set the parameter.</I></B><B><I>separated by </I></B>are for<I>troff</I>and<I>nroff</I>respectively.In the <B><I>column,<br><img src="-.16252.gif"><br><br>&#32;<br><br><img src="-.16253.gif"><br><br><DL><DT><DD><TT><PRE></I></B><TT>ab</TT><B><I>	20</I></B><TT>ad</TT><B><I>	4</I></B><TT>af</TT><B><I>	8</I></B><TT>am</TT><B><I>	7</I></B><TT>as</TT><B><I>	7</I></B><TT>bd</TT><B><I>	2</I></B><TT>bp</TT><B><I>	3</I></B><TT>br</TT><B><I>	4</I></B><TT>c2</TT><B><I>	10</I></B><TT>cc</TT><B><I>	10</I></B><TT>ce</TT><B><I>	4</I></B><TT>cf</TT><B><I>	19</I></B><TT>ch</TT><B><I>	7</I></B><TT>cs</TT><B><I>	2</I></B><TT>cu</TT><B><I>	10</I></B><TT>da</TT><B><I>	7</I></B><TT>de</TT><B><I>	7</I></B><TT>di</TT><B><I>	7</I></B><TT>ds</TT><B><I>	7</I></B><TT>dt</TT><B><I>	7</I></B><TT>ec</TT><B><I>	10</I></B><TT>el</TT><B><I>	16</I></B><TT>em</TT><B><I>	7</I></B><TT>eo</TT><B><I>	10</I></B><TT>ev</TT><B><I>	17</I></B><TT>ex</TT><B><I>	18</I></B><TT>fc</TT><B><I>	9</I></B><TT>fi</TT><B><I>	4</I></B><TT>fl</TT><B><I>	20</I></B><TT>fp</TT><B><I>	2</I></B><TT>ft</TT><B><I>	2</I></B><TT>hc</TT><B><I>	13</I></B><TT>hw</TT><B><I>	13</I></B><TT>hy</TT><B><I>	13</I></B><TT>ie</TT><B><I>	16</I></B><TT>if</TT><B><I>	16</I></B><TT>ig</TT><B><I>	20</I></B><TT>in</TT><B><I>	6</I></B><TT>it</TT><B><I>	7</I></B><TT>lc</TT><B><I>	9</I></B><TT>lg</TT><B><I>	10</I></B><TT>lf</TT><B><I>	20</I></B><TT>ll</TT><B><I>	6</I></B><TT>ls</TT><B><I>	5</I></B><TT>lt</TT><B><I>	14</I></B><TT>mc</TT><B><I>	20</I></B><TT>mk</TT><B><I>	3</I></B><TT>na</TT><B><I>	4</I></B><TT>ne</TT><B><I>	3</I></B><TT>nf</TT><B><I>	4</I></B><TT>nh</TT><B><I>	13</I></B><TT>nm</TT><B><I>	15</I></B><TT>nn</TT><B><I>	15</I></B><TT>nr</TT><B><I>	8</I></B><TT>ns</TT><B><I>	5</I></B><TT>nx</TT><B><I>	19</I></B><TT>os</TT><B><I>	5</I></B><TT>pc</TT><B><I>	14</I></B><TT>pi</TT><B><I>	19</I></B><TT>pl</TT><B><I>	3</I></B><TT>pm</TT><B><I>	20</I></B><TT>pn</TT><B><I>	3</I></B><TT>po</TT><B><I>	3</I></B><TT>ps</TT><B><I>	2</I></B><TT>rd</TT><B><I>	18</I></B><TT>rm</TT><B><I>	7</I></B><TT>rn</TT><B><I>	7</I></B><TT>rr</TT><B><I>	8</I></B><TT>rs</TT><B><I>	5</I></B><TT>rt</TT><B><I>	3</I></B><TT>so</TT><B><I>	19</I></B><TT>sp</TT><B><I>	5</I></B><TT>ss</TT><B><I>	2</I></B><TT>sv</TT><B><I>	5</I></B><TT>sy</TT><B><I>	19</I></B><TT>ta</TT><B><I>	9</I></B><TT>tc</TT><B><I>	9</I></B><TT>ti</TT><B><I>	6</I></B><TT>tl</TT><B><I>	14</I></B><TT>tm</TT><B><I>	20</I></B><TT>tr</TT><B><I>	10</I></B><TT>uf</TT><B><I>	10</I></B><TT>ul</TT><B><I>	10</I></B><TT>vs</TT><B><I>	5</I></B><TT>wh</TT><B><I>	7<br>&#32;<br></PRE></TT></DL></P></I></B><br>&#32;<br><B>Alphabetical Request and Section Number Cross Reference</B><br>&#32;<br><br>&#32;<br><DL><DT><DD><TT><PRE><br>&#32;<br><br>&#32;<br><HR><br>&#32;<br></PRE></TT></DL><br>&#32;<br><B>Escape Sequences for Characters, Indicators, and Functions</B><br>&#32;<br><br><img src="-.16254.gif"><br><br>&#32;<br>The escape sequencesandare interpreted in copy mode (&#167;7.2). <br>&#32;<br><HR><br>&#32;<br><br>&#32;<br><B>Predefined Number Registers</B><br>&#32;<br><br><img src="-.16255.gif"><br>  <br>&#32;<br><B>Predefined Read-Only Number Registers</B><br>&#32;<br><br><img src="-.16256.gif"><br><br>&#32;<br><HR><br>&#32;<br><br>&#32;<br><B>Reference Manual</B><H4>1 General Explanation</H4><br>&#32;<br><B><I>0.0s.  Form of input.</I></B> Input consists of <I>text lines</I>, which are destined to be printed,interspersed with <I>control lines</I>,which set parameters or otherwise control subsequent processing.Control lines begin with a <I>control character</I>&#173;normally <TT>.</TT> (period) or <TT>'</TT> (single quote)&#173;followed by a one or two character name that specifiesa basic <I>request</I> or the substitution ofa user-defined <I>macro</I> in place of the control line.The control character <TT>'</TT> suppresses the <I>break</I> function&#173;the forced output of a partially filled line&#173;caused by certain requests.The control character may be separated from the request/macro name bywhite space (spaces and/or tabs) for aesthetic reasons.Names should be followed by eitherspace or newline.Control lines with unrecognized names are ignored.<P>Various special functions may be introduced anywhere in the input bymeans of an <I>escape</I> character, normally <TT>\</TT>.For example, the functioncauses the interpolation of the contents of the<I>number register R</I>in place of the function;here <I>R</I> is either a single character nameas in <TT>\n</TT><I>x</I>,or a two-character name introduced bya left-parenthesis, as in <TT>\n(</TT><I>xx</I>.</P><br>&#32;<br><B><I>0.0s.  Formatter and device resolution.</I></B> <I>Troff</I> internally stores and processes dimensions in units that correspond tothe particular device for which output is being prepared;values from 300 to 1200/inch are typical.See &#167;23.<I>Nroff</I> internally uses 240 units/inch,corresponding to the least common multiple of thehorizontal and vertical resolutions of varioustypewriter-like output devices.<I>Troff</I> rounds horizontal/vertical numerical parameter input to the actualhorizontal/vertical resolution of the output device indicated by the <TT>-T</TT> option(default<I>Nroff</I> similarly rounds numerical input to the actual resolutionof its output device(default Model 37 Teletype).<br>&#32;<br><B><I>0.0s.  Numerical parameter input.</I></B> Both <I>nroff</I> and <I>troff</I>accept numerical input with the appended scaleindicatorsshown in the following table,where<I>S</I> is the current type size in points and<I>V</I> is the current vertical line spacing inbasic units.<br><img src="-.16257.gif"><br>In <I>nroff</I>, both the em and the en are taken to be equal to thenominal character width,which is output-device dependent;common values are 1/10 and 1/12 inch.Actual character widths in <I>nroff</I> need not be all the same and constructed characterssuch as -&#62; (->) are often extra wide.The default scaling isfor the horizontally-oriented requestsand functionsand horizontal coordinates offor the vertically-oriented requests and functionsand vertical coordinates offor therequest;andfor the requestsand<I>All</I> other requests ignore any scale indicators.When a number register containing an already appropriately scaled numberis interpolated to provide numerical input,the unit scale indicator<TT>u</TT> may need to be appended to preventan additional inappropriate default scaling.The number, <I>N</I>, may be specified in decimal-fraction formbut the parameter finally stored is rounded to an integer number of basic units.Internal computations are performed in integer arithmetic.<P>The <I>absolute position</I> indicator <TT>|</TT> may be prefixedto a number <I>N</I>to generate the distance to the vertical or horizontal place <I>N</I>.For vertically-oriented requests and functions, <TT>|</TT><I>N</I>becomes the distance in basic units from the current vertical place on the page or in a <I>diversion</I> (&#167;7.4)to the vertical place <I>N</I>.For <I>all</I> other requests and functions,<TT>|</TT><I>N</I>becomes the distance fromthe current horizontal place on the <I>input</I> line to the horizontal place <I>N</I>.For example,<DL><DT><DD><TT><PRE>.sp |3.2c</PRE></TT></DL>will space in the required direction to 3.2 centimeters from the top of the page.</P><br>&#32;<br><B><I>0.0s.  Numerical expressions.</I></B> Wherever numerical input is expected,an expression involving parentheses,the arithmetic operators <TT>+</TT>, <TT>-</TT>, <TT>/</TT>, <TT>*</TT>, <TT>%</TT> (mod),and the logical operators<TT>&#60;</TT>,<TT>&#62;</TT>,<TT>&#60;=</TT>,<TT>&#62;=</TT>,<TT>=</TT> (or <TT>==</TT>),<TT>&amp;</TT> (and),<TT>:</TT> (or)may be used.Except where controlled by parentheses, evaluation of expressions is left-to-right;there is no operator precedence.In the case of certain requests, an initial <TT>+</TT> or <TT>-</TT> is strippedand interpreted as an increment or decrement indicator respectively.In the presence of default scaling, the desired scale indicator must beattached to <I>every</I> number in an expressionfor which the desired and default scaling differ.For example,

Lines 1–500 of 3348.