ch17_01.htm
来自「unix基础教程」· HTM 代码 · 共 278 行 · 第 1/2 页
HTM
278 行
<html><head><title>troff Preprocessors (UNIX in a Nutshell: System V Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Arnold Robbins" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="1-56592-427-4" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="UNIX in a Nutshell: System V Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Book Title" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch16_04.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch17_02.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h1 class="chapter">Chapter 17. troff Preprocessors</h1><div class="htmltoc"><h4 class="tochead">Contents:</h4><p><a href="ch17_01.htm#sect1">tbl</a><br /><a href="ch17_02.htm">eqn</a><br /><a href="ch17_03.htm">pic</a><br /><a href="ch17_04.htm">refer</a><br /></p></div><p><a name="unut-ch-17-ix-nroff-program-preprocessors-of" /><a name="unut-ch-17-ix-troff-program-preprocessors-of" /><a name="unut-ch-17-ix-text-formatting-nroff-troff-preprocessors" /><a name="unut-ch-17-ix-preprocessors-for-nroff-troff-system" />This chapter is divided into the following four sections, each covering adifferent preprocessor of the <tt class="literal">nroff</tt>/<tt class="literal">troff</tt> formatting system:</p><ul><li><p>The <tt class="literal">tbl</tt> preprocessor</p></li><li><p>The <tt class="literal">eqn</tt> preprocessor</p></li><li><p>The <tt class="literal">pic</tt> graphics language preprocessor</p></li><li><p>The <tt class="literal">refer</tt> preprocessor</p></li></ul><p>Each of these preprocessors translates codeinto <tt class="literal">nroff</tt>/<tt class="literal">troff</tt>requests and escape sequences.They process information only between delimiting macros: otherinput text is left alone.Usually, one or more of these preprocessors are invoked as part of a commandpipeline to format a file:</p><blockquote><pre class="code">$ <tt class="userinput"><b>pic</b></tt> <em class="replaceable"><tt>file</em> <tt class="userinput"><b>| tbl | eqn | troff</b></tt> <em class="replaceable">options</em> <tt class="userinput"><b>|</b></tt> <em class="replaceable">spooler</tt></em></pre></blockquote><p>On multiuser systems, it is typical to have a general-purpose shell scriptfor formatting. You would then select various command-line options tospecify which (if any) preprocessors to include in your particular format command. However, you can also invoke the preprocessors individually.This is useful for confirming that syntax is correct or fordetermining where it fails. For example, the command:</p><blockquote><pre class="code">$ <tt class="userinput"><b>tbl </b></tt><em class="replaceable"><tt>file</tt></em></pre></blockquote><p>takes input between each <tt class="literal">.TS</tt>/<tt class="literal">.TE</tt> macro pairand converts it to <tt class="literal">tbl</tt>code. All other input is passed through to the output unchanged.</p><p>In SVR4, these commands are part of the BSD compatibility package andare found in <tt class="literal">/usr/ucb</tt>.On Solaris, with the exception of <tt class="literal">pic</tt>,they are a standard part of the system and are foundin <tt class="literal">/usr/bin</tt>.The GNU version of <tt class="literal">troff</tt> (<tt class="literal">groff</tt>,see http://www.gnu.org)comes with versions of <tt class="literal">tbl</tt>, <tt class="literal">eqn</tt>,<tt class="literal">pic</tt>, and <tt class="literal">refer</tt>.</p><div class="sect1"><a name="unut-ch-17-sect-1" /><h2 class="sect1"><a name="sect1" />17.1. tbl</h2><p><a name="ch17.troff1" /><a name="ch17.troff2" /><a name="ch17.troff3" /><a name="unut-ch-17-ix-tbl-preprocessor" /><a name="unut-ch-17-ix-tables-formatting-in-nroff-troff" /><tt class="literal">tbl</tt> is a preprocessor for formatting tables in <tt class="literal">nroff</tt>/<tt class="literal">troff</tt>.When used in a command pipeline, <tt class="literal">tbl</tt> should precede <tt class="literal">eqn</tt>.This makes output processing more efficient.<tt class="literal">tbl</tt> has the following command-line syntax:</p><blockquote><pre class="code">tbl [<em class="replaceable"><tt>options</em>] [<em class="replaceable">files</tt></em>]</pre></blockquote><p>The canonical reference for <tt class="literal">tbl</tt> is<em class="citetitle">Tbl--A Program to Format Tables</em>,by L.L. Cherry and M.E. Lesk,in <em class="citetitle">UNIX Programmer's Manual, Tenth Edition</em>,Volume 2,AT&T Bell Laboratories, M.D. McIlroy and A.G. Hume editors,Holt Rinehart & Winston, 1990.This paper may be downloaded fromhttp://cm.bell-labs.com/cm/cs/doc/76/tbl.ps.gz.</p><a name="unut-ch-17-sect-1.1" /><div class="sect2"><h3 class="sect2">17.1.1. Options</h3><dl><dt><tt class="literal">-me</tt></dt><dd>Prepend the <em class="emphasis">me</em></tt> macros to the front of <tt><em class="replaceable">files</em></tt>.</p></dd><dt><tt class="literal">-mm</tt></dt><dd>Prepend the <em class="emphasis">mm</em></tt> macros to the front of <tt><em class="replaceable">files</em></tt>.</p></dd><dt><tt class="literal">-ms</tt></dt><dd>Prepend the <em class="emphasis">ms</em></tt> macros to the front of <tt><em class="replaceable">files</em></tt>.</p></dd><dt><tt class="literal">-TX</tt></dt><dd>Produce output using only full vertical line motions.This is useful when formatting with <tt class="literal">nroff</tt> or when printing to a device that does not support fractional line motion.(This option is not on Solaris <tt class="literal">tbl</tt>.)</p></dd></dl></div><a name="unut-ch-17-sect-1.2" /><div class="sect2"><h3 class="sect2">17.1.2. General Coding Scheme</h3><p>In a text file, coding for <tt class="literal">tbl</tt> might look like this:</p><blockquote><pre class="code"><tt class="userinput"><b>.TS H</b></tt><em class="replaceable"><tt>options</tt></em><tt class="userinput"><b>;</b></tt><em class="replaceable"><tt>format1</tt></em><em class="replaceable"><tt>format2</tt></em><tt class="userinput"><b>.</b></tt><em class="replaceable"><tt>Column Titles</tt></em><tt class="userinput"><b>.TH</b></tt><em class="replaceable"><tt>Item1 Item2 Item3</tt></em><em class="replaceable"><tt>Item1 Item2 Item3 ...</tt></em><tt class="userinput"><b>.TE</b></tt></pre></blockquote><p>Successful processing of a table by <tt class="literal">tbl</tt> depends largely onthe header lines, which consist of one line listing the options andone or more format lines. Each field of the table input must beseparated by a tab or the designated tab symbol, with each row typedentirely on a single line unless a field is enclosed by the text block symbols<tt class="literal">T{</tt> and <tt class="literal">T}</tt>.</p></div><a name="unut-ch-17-sect-1.3" /><div class="sect2"><h3 class="sect2">17.1.3. tbl Macros</h3><a name="IXT-17-123444" /><table border="1" cellpadding="3"><tr><td><tt class="literal">.TS</tt></td><td>Start table.</td></tr><tr><td><tt class="literal">.TE</tt></td><td>End table.</td></tr><tr><td><tt class="literal">.TS H</tt></td><td><p>Used when the table continues onto more than one page. Used with <tt class="literal">.TH</tt> todefine a header that prints on every page.</p></td></tr><tr><td><tt class="literal">.TH</tt></td><td>With <tt class="literal">.TS H</tt>, end the header portion of the table.</td></tr><tr><td><tt class="literal">.T&</tt></td><td>Continue table with new format line(s).</td></tr></table><p></div><a name="unut-ch-17-sect-1.4" /><div class="sect2"><h3 class="sect2">17.1.4. Options</h3><p>Options affect the entire table. Options can be separated by commasor spaces, but the line must end with a semicolon.</p><table border="1" cellpadding="3"><tr><td><tt class="literal">center</tt></td><td>Center with current margins.</td></tr><tr><td><tt class="literal">expand</tt></td><td>Flush with current right and left margins.</td></tr><tr><td>(leave <em class="emphasis">blank</em>)</td><td>Flush with current left margin (the default).</td></tr><tr><td><tt class="literal">box</tt></td><td>Enclose table in a box.</td></tr><tr><td><tt class="literal">doublebox</tt></td><td>Enclose table in two boxes.</td></tr><tr><td><tt class="literal">allbox</tt></td><td>Enclose each table entry in a box.</td></tr><tr><td><tt class="literal">tab(</tt><em class="replaceable"><tt>x</em><tt class="literal">)</tt></td><td>Define the tab symbol to be <em class="emphasis">x</tt></em> instead of a tab.</td></tr><tr><td><tt class="literal">linesize</tt> <em class="replaceable"><tt>n</tt></em></td><td><p>Set type size of lines or rules (e.g., from <tt class="literal">box</tt>)to <em class="emphasis">n</em> points.</p></td></tr><tr><td><tt class="literal">delim</tt> <em class="replaceable"><tt>xy</em></td><td><p>Recognize <em class="emphasis">x</em> and <em class="emphasis">y</tt></em>as the <tt class="literal">eqn</tt> delimiters.</p></td></tr></table><p></div><a name="unut-ch-17-sect-1.5" /><div class="sect2"><h3 class="sect2">17.1.5. Format</h3><p>The format line affects the layout of individual columns and rows ofthe table. Each line contains a key letter for each column of thetable. The column entries should be separated by spaces, and theformat section must end with a period. Each line of format correspondsto one line of the table, except for the last, which corresponds to allfollowing lines up to the next <tt class="literal">.T&</tt>, if any.</p>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?