rhl17.htm
来自「linux的初学电子书」· HTM 代码 · 共 921 行 · 第 1/2 页
HTM
921 行
<FONT COLOR="#000080">.in 0.75I</FONT></PRE>
<P>This is indented three-quarters of an inch.
<BR>
<P>To move the right margin to the left so that you can make a distinctive block of text within a normal chunk, you use the .ll (line length) command you saw earlier:
<BR>
<P>This is normal text, and goes on and on.Even more text that continues the tradition.
<BR>
<PRE>
<FONT COLOR="#000080">.in 1i
.ll -1i</FONT></PRE>
<P>This is now indented one inch to the left, and the right margin is indented one inch from the normal right margin. This makes the text stand out a little.
<BR>
<PRE>
<FONT COLOR="#000080">.in -1i
.ll +1i</FONT></PRE>
<P>And this is back to normal. The block will stand out nicely amongst all this normal text.
<BR>
<P>You will notice that we used relative movements of plus and minus a value in this example to make it easier. This way, we don't have to measure the page. You can revert to original values with the command .in and .ll with no arguments, as well.
<BR>
<P>An indent and line-length change is effective until the next command changes it. Sometimes you want to affect only a single line, though. If you want to indent only a single line, use the .ti (temporary indent) command:
<BR>
<P>This is really fine stuff. You can tell, 'cause I'm still awake.
<BR>
<PRE>
<FONT COLOR="#000080">.ti 3i</FONT></PRE>
<P>This line is temporarily indented by three inches, but the next line will be back to normal.
<BR>
<P>Tabs are used to set column output. Usually, tabs are used with groff only for unfilled text, which means material you would display in columns. Tab stops are set, by default, every half inch. To override these values, you use the .ta (tab) command. The
command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">.ta 1i 2i 3i 4i 5i 6i</FONT></PRE>
<P>sets the tabs at every inch instead. You can think of the setting of tabs within groff much as they are done on a typewriter, from left to right. Tabs are usually set for columns of numbers or tables, but the groff macro gtbl is much better at this.
(You get a look at gtbl in the next chapter.)
<BR>
<BR>
<A NAME="E69E238"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Other Character Controls</B></FONT></CENTER></H4>
<BR>
<P>The groff system has special instructions for controlling the size of individual letters, as well as formulas and special characters such as Greek letters. However, because it is unlikely that groff is used for this type of output these days, we'll
ignore the capabilities. If you want more information on how to provide these special features, check the groff man pages or consult a good troff book.
<BR>
<BR>
<A NAME="E68E121"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Macros</B></FONT></CENTER></H3>
<BR>
<P>A macro is a shorthand notation for a set of commands or strings. Many commands used to write man pages are macros. To give a practical example of a groff macro, suppose we want every paragraph to start with a blank line and a temporary indent of half
an inch. The groff commands to do this are
<BR>
<PRE>
<FONT COLOR="#000080">.sp
.ti +.5i</FONT></PRE>
<P>Instead of typing these two lines every paragraph, we can define a macro of one character (or more) that does it for us.
<BR>
<P>To define the macro, we use the .de (define) command followed by the name of the macro and the commands. It would look like this, placed somewhere at the top of the source code:
<BR>
<PRE>
<FONT COLOR="#000080">.de PP
.sp
.ti +.5I
..</FONT></PRE>
<P>The last line with two periods indicates the end of the definition. Now, whenever we use the command .PP it will be executed as the lines in the macro.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>Make sure that you don't define a macro with the name of a reserved groff command, or the macro will not be executed.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<BR>
<A NAME="E68E122"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Using mm</B></FONT></CENTER></H3>
<BR>
<P>The mm (memorandum macros) package is not really part of nroff or troff, although both can use it. The mm program reads a source file much as groff does and translates it to output. Many of the mm macros are used for man pages. Indeed, many users find
the nroff and troff commands too awkward or complicated, whereas mm is fully able to meet all their basic formatting needs.
<BR>
<P>To add mm commands, you use the period in the first column as with groff. The mm macros are usually quite simple, and easy to work with and use. We can look at the most important of them here.
<BR>
<P>Like groff, mm runs text together when reformatting, regardless of line breaks in the source file. To force a new paragraph, use the .P command. It forces a line break and adds a blank line to the output. Paragraphs are usually formatted so that they
are flush left.
<BR>
<P>Headings are created with the .H command. For example, the command
<BR>
<P>.H This is a Heading
<BR>
<P>will create a break, output the heading text in bold, and leave a bit of a space between the heading and the text that follows it.
<BR>
<P>There can be seven levels of headings; 1 is the highest and 7 is the lowest. To specify the heading level, add the number as the first argument after the .H command:
<BR>
<P>.H 2 This is a level 2 heading
<BR>
<P>The mm heading macro will number the headings automatically, although you can suppress the numbering with the .HU (heading unnumbered) command. To reset the numbering (at a section break, for example), use the .nr (number register) command followed by
the heading level and the number to use. For example, the command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">.nr H2 1</FONT></PRE>
<P>will restart the numbering of second-level headings at 1.
<BR>
<BR>
<A NAME="E69E239"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Lists</B></FONT></CENTER></H4>
<BR>
<P>Lists are easily created in mm with the .LI (list) command and the .LE (list end) command. This creates a bulleted list. For example, the command
<BR>
<PRE>
<FONT COLOR="#000080">.LI
thing 1
.LI
thing 2
.LE
thing 3</FONT></PRE>
<P>creates a bulleted list of the three bits of text. You can create a list with dashes instead of bullets using the .DL (dash list) command. The mark list command, .ML, creates a list with the character of your choice.
<BR>
<P>If you want a numbered list, use the .AL (automatic list) command. Lists with no arguments are created with Arabic numbers. To create an alphabetical list (A, B, C, and so on), use the macro command .AL A. Roman numerals (i, ii, iii, iv, v, and so on)
can be used with the .AL I command.
<BR>
<P>You can nest list types as necessary. For example, the command
<BR>
<PRE>
<FONT COLOR="#000080">.AL I
.LI
groff
.AL
.LI
macros
.LI
mm
.LE
.LI
gtbl
.LI
geqn
.LE</FONT></PRE>
<P>will create output that looks like this:
<BR>
<PRE>
<FONT COLOR="#000080">I. groff
1. macros
2. mm
II. gtbl
III. geqn</FONT></PRE>
<P>You have to be careful when terminating each list with an .LE command to ensure that you terminate the proper one. Experimentation and practice help you get the hang of this. You may have noticed that it takes a lot of commands to make a little list!
<BR>
<BR>
<A NAME="E69E240"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Font Changes</B></FONT></CENTER></H4>
<BR>
<P>Changing fonts with mm is quite simple. When working from a period command, the command .B (bold) creates bold text until an .R (restore) command, while .I (italic) does the same until an .R command. If you want to bold or italicize only one word, you
can do it after the period command, as this example shows:
<BR>
<P>This is normal text
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">.B</FONT></PRE>
<P>This is bold.
<BR>
<P>So is this.
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">.R</FONT></PRE>
<P>This is normal.
<BR>
<P>This is a single
<BR>
<PRE>
<FONT COLOR="#000080">.Bbold</FONT></PRE>
<P>word, though.
<BR>
<P>When you change only one word, you don't need a .R command.
<BR>
<P>Changes can be performed within text in the same manner as with groff:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">This is an \fIitalics set of words\fR until here.</FONT></PRE>
<BR>
<A NAME="E69E241"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Footnotes</B></FONT></CENTER></H4>
<BR>
<P>To create a footnote, use the .FS (footnote start) and .FE (footnote end) commands. Every footnote on a single page will be collected and printed at the bottom. Footnotes are automatically numbered unless you specify another character:
<BR>
<PRE>
<FONT COLOR="#000080">This is normal text.
.FS</FONT></PRE>
<P>This is a footnote with its proper number in front of it.
<BR>
<PRE>
<FONT COLOR="#000080">.FE
This is more normal text.
.FS *</FONT></PRE>
<P>But this is a footnote marked with an asterisk.
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">.FE</FONT></PRE>
<P>This is even more normal text. At the bottom of the page
<BR>
<P>will be a numbered footnote and an asterisked footnote.
<BR>
<P>You can use any valid character for the optional footnote mark, including special characters supported by groff.
<BR>
<BR>
<A NAME="E68E123"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Summary</B></FONT></CENTER></H3>
<BR>
<P>As you might expect, there is a lot to both groff and mm that we haven't looked at. Because groff is seldom used these days, we covered only the most important aspects. As I said earlier, if you want to learn more about groff or mm, find a good
reference book on the subject.
<P ALIGN=LEFT>
<A HREF="rhl16.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl16.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A>
<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="rhl18.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl18.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
</BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?