⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unx21.htm

📁 Linux Unix揭密.高质量电子书籍.对学习Linux有大帮助,欢迎下载学习.
💻 HTM
📖 第 1 页 / 共 5 页
字号:

<TD>

<P>\r</P>

<TD>

<P>Reverse 1-em vertical motion</P>

<TR>

<TD>

<P>\s</P>

<TD>

<P>Requests a change in point size; can be specified as an absolute value or with &#177;</P>

<TR>

<TD>

<P>\S'n'</P>

<TD>

<P>Slants output n degrees to the right</P>

<TR>

<TD>

<P>\t</P>

<TD>

<P>Horizontal tab</P>

<TR>

<TD>

<P>\u</P>

<TD>

<P>Moves up half a line space</P>

<TR>

<TD>

<P>\v'n'</P>

<TD>

<P>Moves vertically down; to move up the page, specify negative number</P>

<TR>

<TD>

<P>\w</P>

<TD>

<P>Interpolates width of specified string</P>

<TR>

<TD>

<P>\x</P>

<TD>

<P>Extra line-space function</P>

<TR>

<TD>

<P>\zc</P>

<TD>

<P>Prints c with zero width (without spacing)</P>

<TR>

<TD>

<P>\{</P>

<TD>

<P>Begins conditional input</P>

<TR>

<TD>

<P>\}</P>

<TD>

<P>Ends conditional input</P>

<TR>

<TD>

<P>\[newline]</P>

<TD>

<P>Concealed (ignored) newline</P>

<TR>

<TD>

<P>\X</P>

<TD>

<P>X, any character not listed above</P></TABLE>

<P>Listing 21.12 shows troff input with in-line font and size changes, and Figure 21.18 shows the output.

<BR></P>

<P>

<BR><B><A HREF="21unx18.gif">Figure 21.18. </B><B><I>troff</I></B><B> output with in-line font </B><B>changes.</A></B>

<BR></P>

<UL>

<LH><B>Listing 21.12. </B><B>troff</B><B> source with in-line font changes.</B></LH></UL>

<PRE>\fB\s+4We, the people\s-4\fP 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.</PRE>

<P>Two other in-line escapes are \&amp; and \p. The \&amp; escape is a zero-length control character and can be used to enable the printing of a control character (.) at the start of a line. The \p escape generates a break, but also requests that the line 

be spread to the current input line length.

<BR></P>

<P>Similarly, if a word requires extra vertical space, the in-line escape \x is used to request the additional vertical space. The amount of space needed must be enclosed in single quotes.

<BR></P>

<P>The next in-line escape deals with unfilled text only. If a line of unfilled text is terminated with a \c, the next text present will be treated as a continuation of that line. This allows the document writer to include a sequence of requests in the 
middle of a line, even if those requests do not have associated in-line escapes. The .cs request is an example of a case where \c may be used.

<BR></P>

<P>Fonts may be changed in-line by using the \f escape. Single character font identifiers can be designated with \fB, but two-character identifiers need a ( to group the letters. An example would be \f(HI for a change to Helvetica-Italic. Point sizes can 
similarly be changed with \s. Here, two-digit fonts are acceptable. Relative changes can be made, too. Figure 21.18 shows a case where the words &quot;We the people&quot; are bold and four points larger than surrounding text.

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I12" NAME="I12">

<FONT SIZE=4><B>Special Characters</B>

<BR></FONT></A></CENTER></H3>

<P>Although special characters are system-dependent, there are several special characters that you can expect to have in your system. Table 21.4 lists these.

<BR></P>

<P>ASCII is limited to a small number of printable characters; fortunately, troff provides access to many more characters and symbols needed for mathematics and other applications. A few are escape sequences, but most are two-character escapes. Several 
two-character printing symbols are available, some on the default font, and some on a special font. These include Greek characters, mathematical characters, and editing symbols. An example of this is the mathematical expressions in Listing 21.13 and Figure 

21.19.

<BR></P>

<P>

<BR><B><A HREF="21unx19.gif">Figure 21.19. </B><B><I>troff</I></B><B> output of special </B><B>characters.</A></B>

<BR></P>

<UL>

<LH><B>Listing 21.13. In-line character requests for </B><B>troff</B><B>.</B></LH></UL>

<PRE>2\(*pr

\(issin\(*td\(*t\(eqcos\(*t

\(*S(\(*a\(mu\(*b)\(-&gt;\(if</PRE>

<P>Other characters that can come in handy are bullets, \(bu, the copyright symbol, \(co, and daggers, \(dg. Four characters have their own commands. To print a backslash, use \\. A minus sign is \-, an open quote is \', and a close quote is \'.

<BR></P>

<P>Table 21.4 list the special characters typically available for the standard fonts.

<BR></P>

<UL>

<LH><B>Table 21.4. Special characters.</B>

<BR></LH></UL>

<TABLE BORDER>

<TR>

<TD>

<PRE><I>In-line Request</I>

<BR></PRE>

<TD>

<PRE><I>Character Produced</I>

<BR></PRE>

<TR>

<TD>

<P>\\</P>

<TD>

<P>backslash</P>

<TR>

<TD>

<P>\'</P>

<TD>

<P>close quote</P>

<TR>

<TD>

<P>\'</P>

<TD>

<P>open quote</P>

<TR>

<TD>

<P>-</P>

<TD>

<P>hyphen</P>

<TR>

<TD>

<P>\-</P>

<TD>

<P>current font minus sign</P>

<TR>

<TD>

<P>\(bu</P>

<TD>

<P>bullet</P>

<TR>

<TD>

<P>\(co</P>

<TD>

<P>copyright</P>

<TR>

<TD>

<P>\(ct</P>

<TD>

<P>cent sign</P>

<TR>

<TD>

<P>\(de</P>

<TD>

<P>degree</P>

<TR>

<TD>

<P>\(dg</P>

<TD>

<P>dagger</P>

<TR>

<TD>

<P>\(em</P>

<TD>

<P>3/4 em dash</P>

<TR>

<TD>

<P>\(ff</P>

<TD>

<P>ff ligature</P>

<TR>

<TD>

<P>\(fi</P>

<TD>

<P>fi ligature</P>

<TR>

<TD>

<P>\(Fi</P>

<TD>

<P>ffi ligature</P>

<TR>

<TD>

<P>\(fl</P>

<TD>

<P>fl ligature</P>

<TR>

<TD>

<P>\(Fl</P>

<TD>

<P>ffl ligature</P>

<TR>

<TD>

<P>\(fm</P>

<TD>

<P>foot mark</P>

<TR>

<TD>

<P>\(hy</P>

<TD>

<P>hyphen</P>

<TR>

<TD>

<P>\(rg</P>

<TD>

<P>registered trademark</P>

<TR>

<TD>

<P>\(ru</P>

<TD>

<P>rule</P>

<TR>

<TD>

<P>\(sq</P>

<TD>

<P>square</P>

<TR>

<TD>

<P>\(14</P>

<TD>

<P>1/4</P>

<TR>

<TD>

<P>\(12</P>

<TD>

<P>1/2</P>

<TR>

<TD>

<P>\(34</P>

<TD>

<P>3/4</P></TABLE>

<H3 ALIGN="CENTER">

<CENTER><A ID="I13" NAME="I13">

<FONT SIZE=4><B>Strings and Macros</B>

<BR></FONT></A></CENTER></H3>

<P>troff and nroff provide the ability to specify strings that can be used repeatedly. The strings can be given one- or two-character identifiers, and those identifiers can be referenced later. Strings can be defined with the .ds request. The next argument 

must be the identifier, and the string that follows is assigned to the identifier. The .as request appends additional text to the string. Accessing the string is accomplished with the in-line escape \*. Our Constitution provides an example in Listing 21.14 

and Figure 21.20.

<BR></P>

<P>

<BR><B><A HREF="21unx20.gif">Figure 21.20. </B><B><I>troff</I></B><B> output with a defined </B><B>string.</A></B>

<BR></P>

<UL>

<LH><B>Listing 21.14. </B><B>troff</B><B> source defining a string.</B></LH></UL>

<PRE>.ce

.ds us United States

Preamble

.sp

We, the people

of the \*(us, 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

\*(us of America.

.sp

.ce

Article I

.sp

Section 1  Legislative powers; in whom vested:

.sp

All legislative powers herein granted shall be vested in a

Congress of the \*(us, which shall consist of a Senate and a

House of Representatives.</PRE>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP:</B> Using a defined string for repeated text ensures a consistent look to the document.

<BR></NOTE>

<HR ALIGN=CENTER>

<P>Macros provide a technique for the document writer to group repeated requests into a single troff request. If the document writer notices that groups of requests are being repeated, those are ideal candidates for making a macro. Examples include 
quotations, paragraphs, and section headers. Chapter 26 goes into greater detail on macro writing; however, I will show you the basics here.

<BR></P>

<P>Macros are defined with the .de request. A one- or two-character label should follow the request. By convention, macro names are often uppercase, although this is not a requirement. The troff requests then follow the .de until the .. request is present. 

These requests are then executed whenever the macro is called. You call the macro by starting the line with a . followed by the macro name, without a space.

<BR></P>

<P>Macros can be designed to take arguments. Up to nine arguments can be passed to a macro and are accessed as \$N, where N is the argument position from 1 to 9. These can be treated as ordinary variables and can be used anywhere in the macro. When a macro 

is defined, the contents of the commands are interpreted. This means that the presence of strings, variables, and comments are translated when the macro is read. To insure that the argument is not interpreted until the macro is used, the argument should be 

listed in the definition as \\$N. The \\ will be interpreted as \. This \\ can be used whenever the writer wants the escape to be interpreted when the macro is invoked.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -