📄 unx21.htm
字号:
<UL>
<LH><B>Listing 21.10. </B><B>troff</B><B> source showing multiple point sizes.</B></LH></UL>
<PRE>.ce
.ft B
.ps 24
.ss 28
.vs 28
Preamble
.sp
.ft I
We, the people
.ps 12
.ss 14
.vs 14
of the United States, in order
to form a more perfect Union, establish justice, insure
domestic tranquility, provide for the common defense, promote
the general welfare,
and secure the blessing of liberty to ourselves and our
posterity do ordain and establish this Constitution for the
United States of America.
.sp
.ce
.ft B
Article I
.sp
.ft R
Section 1 Legislative powers; in whom vested:
.sp
All legislative powers herein granted shall be vested in a
Congress of the United States, which shall consist of a Senate
and a House of Representatives.</PRE>
<P>The last text request is .cs, which sets a constant character width for a given font in troff. This takes three arguments. The first is a font, the second is the width of the space, and the last is the character point size. If the third argument is
absent, the default is the current character width. If the second argument is also absent, that turns off the constant width.
<BR></P>
<P>Listing 21.11 shows this for the default Times Roman font in the preamble, and turns it off for the remainder of the Constitution. Figure 21.17 shows the output.
<BR></P>
<P>
<BR><B><A HREF="21unx17.gif">Figure 21.17. </B><B><I>troff</I></B><B> output using .</B><B><I>cs</I></B><B>.</A></B>
<BR></P>
<UL>
<LH><B>Listing 21.11. </B><B>troff</B><B> source illustrating the .cs request.</B></LH></UL>
<PRE>.ce
.ft B
.ps 24
.ss 28
.vs 28
Preamble
.sp
.ft I
We, the people
.ps 12
.ss 14
.vs 14
.ft R
.cs R 15
of the United States, in order
to form a more perfect Union, establish justice, insure
domestic tranquility, provide for the common defense, promote
the general welfare,
and secure the blessing of liberty to ourselves and our
posterity do ordain and establish this Constitution for the
United States of America.
.sp
.cs R
.ce
.ft B
Article I
.sp
.ft R
Section 1 Legislative powers; in whom vested:
.sp
All legislative powers herein granted shall be vested in a
Congress of the United States, which shall consist of a Senate
and a House of Representatives.</PRE>
<P>Fonts can also be specified by position—font 1, font 2, font 3, and so on. In the olden days of troff, before device-independent troff (ditroff), only four positions were available. Quite naturally, 1 was the body type (Times Roman), 2 was the
italic version of 1, and 3 was the bold version of 1. You got one elective—position 4—but it was almost always used for the Special font (the one with Greek letters and mathematical symbols). As a consequence, specifying fonts by position is not
done frequently.
<BR></P>
<P>The following examples all change the word "very" to italics (in nroff, the words are underlined):
<BR></P>
<PRE>This is \f2very\fP easy.
This is
.fp 2
very
.fp 1
easy.</PRE>
<P>Notice that in the first line, \fP is used to turn off italics. The P stands for Previous and resets the font to what it was before the italic font was requested (in this case, Times Roman). The second example resets the font to Times Roman by
specifying its font
<BR>position.
<BR></P>
<P>You can count on finding your default body type in position 1, italics in 2, and bold in 3. Beyond that, you have no idea. It depends on your system installation, and they're all different.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B> Don't specify font changes by position for any position other than 1, 2, or 3. If someone at another branch of your company prints your file, you don't know what font 4 might be, and you can't control
the results.
<BR></NOTE>
<HR ALIGN=CENTER>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="more.gif" WIDTH = 35 HEIGHT = 35><B>What Does </B><B>\f4</B><B> Look Like?</B>
<BR>
<BR>If you want to know what font is loaded in what position on your printers, create a test file that looks something like this:
<BR>
<BR>When I ask for \ef4, I get \f4This Font\fP.
<BR>When I ask for \ef5, I get \f5This Font\fP.
<BR>When I ask for \ef6, I get \f6This Font\fP.
<BR>.
<BR>.
<BR>.
<BR>
<BR>Print the file, and you'll have a wall decoration that's attractive and useful.
<BR></NOTE>
<HR ALIGN=CENTER>
<H3 ALIGN="CENTER">
<CENTER><A ID="I11" NAME="I11">
<FONT SIZE=4><B>In-Line Escape Sequences</B>
<BR></FONT></A></CENTER></H3>
<P>The basics of document building are now passed. All the requests I have examined have been of the form .xx and stand alone on each line. Although any document can be produced using these requests, an in-line request may be easier to use in many cases.
These can generate special characters, change fonts, change point sizes, and produce local motions.
<BR></P>
<P>Escape sequences (backslash-character or backslash-open-parenthesis-character-character) can be used to change fonts and point size and for many other tasks. Table 21.3 lists troff escape sequences.
<BR></P>
<UL>
<LH><B>Table 21.3. </B><B>troff</B><B> escape sequences.</B>
<BR></LH></UL>
<TABLE BORDER>
<TR>
<TD>
<PRE><I>Sequence</I>
<BR></PRE>
<TD>
<PRE><I>Description</I>
<BR></PRE>
<TR>
<TD>
<P>\</P>
<TD>
<P>Prevents the next character from being processed by troff</P>
<TR>
<TD>
<P>\e</P>
<TD>
<P>Prints the escape character; default is the backslash (\)</P>
<TR>
<TD>
<P>\'</P>
<TD>
<P>Prints acute accent</P>
<TR>
<TD>
<P>\'</P>
<TD>
<P>Prints grave accent</P>
<TR>
<TD>
<P>\-</P>
<TD>
<P>Prints a minus sign in the current font</P>
<TR>
<TD>
<P>\[space]</P>
<TD>
<P>Creates an unpaddable 1-en space</P>
<TR>
<TD>
<P>\0</P>
<TD>
<P>Prints a space the width of a digit</P>
<TR>
<TD>
<P>\|</P>
<TD>
<P>Prints a 1/6-em width space</P>
<TR>
<TD>
<P>\^</P>
<TD>
<P>Prints a 1/12-em width space</P>
<TR>
<TD>
<P>\&</P>
<TD>
<P>Nonprinting zero-width character</P>
<TR>
<TD>
<P>\!</P>
<TD>
<P>Transparent line indicator</P>
<TR>
<TD>
<P>\"</P>
<TD>
<P>Begins a comment</P>
<TR>
<TD>
<P>\\$n</P>
<TD>
<P>Interpolates argument</P>
<TR>
<TD>
<P>\%</P>
<TD>
<P>Before word, prevents hyphenation; in middle of word, indicates where word can be hyphenated</P>
<TR>
<TD>
<P>\(xx</P>
<TD>
<P>Specifies character named xx</P>
<TR>
<TD>
<P>\\*x , \*(xx</P>
<TD>
<P>Specifies string named x or xx</P>
<TR>
<TD>
<P>\a</P>
<TD>
<P>Specifies leader character used in macros</P>
<TR>
<TD>
<P>\b'abc...'</P>
<TD>
<P>Bracket-building function</P>
<TR>
<TD>
<P>\c</P>
<TD>
<P>Interrupts text processing</P>
<TR>
<TD>
<P>\d</P>
<TD>
<P>Moves down half a line space</P>
<TR>
<TD>
<P>\D</P>
<TD>
<P>Draws line, circle, ellipse, arc, or spline</P>
<TR>
<TD>
<P>\fx, \f(xx, \fn</P>
<TD>
<P>Requests a font change; font with 1-character name is specified as \fH; font with 2-character name is specified as \f(HB.</P>
<TR>
<TD>
<P>\h'n'</P>
<TD>
<P>Moves horizontally to the right; to move left, specify negative number</P>
<TR>
<TD>
<P>\H'n'</P>
<TD>
<P>Sets character height to n points</P>
<TR>
<TD>
<P>\jx</P>
<TD>
<P>Marks horizontal place on output line in register x</P>
<TR>
<TD>
<P>\kx</P>
<TD>
<P>Marks horizontal place on input line in register x</P>
<TR>
<TD>
<P>\l</P>
<TD>
<P>Draws horizontal line</P>
<TR>
<TD>
<P>\L</P>
<TD>
<P>Draws vertical line</P>
<TR>
<TD>
<P>\nx, \n(xx</P>
<TD>
<P>Interpolates number register x or xx</P>
<TR>
<TD>
<P>\o</P>
<TD>
<P>Overstrikes specified characters</P>
<TR>
<TD>
<P>\p</P>
<TD>
<P>Breaks output line</P>
<TR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -