📄 0233-0236.html
字号:
<HTML>
<HEAD>
<TITLE>Sams Teach Yourself Linux in 24 Hours:Preparing Documents:EarthWeb Inc.-</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311623 //-->
<!-- TITLE=Sams Teach Yourself Linux in 24 Hours//-->
<!-- AUTHOR=Bill Ball//-->
<!-- PUBLISHER=Macmillan Computer Publishing//-->
<!-- IMPRINT=Sams//-->
<!-- CHAPTER=15 //-->
<!-- PAGES=0229-0242 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0229-0232.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0237-0240.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-233"><P>Page 233</P></A>
<P>use man macros to format manual pages. For example, if you create a manual page for
a new game called nw, the manual page, called nw.6, may look like the following:
</P>
<!-- CODE //-->
<PRE>
# cat nw.6
.TH Nano-Warrior 6 Games 1/1/98 Linux
.SH NAME
nw - play Nano-Warrior
.SH SYNOPSIS
nw
.B -d
.PP
-d = play deathmatch mode
.SH DESCRIPTION
.PP
The nw command is used to play a game of Nano-Warrior on your Linux
console. Play continues until you are wiped out by hordes of alien
invaders swarming down the screen.
.PP
Don't give up the fight!
.SH FILES
/usr/games/nw
.PP
$HOME/.nw_scores
.SH BUGS
Probably too many.
</PRE>
<!-- END CODE //-->
<P>You can process this manual page and send it to your display with the following:
</P>
<!-- CODE //-->
<PRE>
# groff -Tascii -man nw.6
Nano-Warrior(6) Linux Nano-Warrior(6)
NAME
nw - play Nano-Warrior
SYNOPSIS
nw -d
-d = play deathmatch mode
DESCRIPTION
The nw command is used to play a game of Nano-Warrior on
your Linux console. Play continues until you are wiped out
by hordes of alien invaders swarming down the screen.
Don't give up the fight!
FILES
/usr/games/nw
$HOME/.nw_scores
BUGS
Probably too many.
</PRE>
<!-- END CODE //-->
<A NAME="PAGENUM-234"><P>Page 234</P></A>
<P>Notice that the man page macros have boldfaced the sections and formatted the
following text automatically. A list of these and other manual page macros are found in the
man.7 manual page under the /usr/man/man7 directory. You can read this manual page with
the following:
</P>
<!-- CODE SNIP //-->
<PRE>
# man 7 man
</PRE>
<!-- END CODE SNIP //-->
<P>The groff formatting program also comes with other sets of typesetting macros, such as
the me, mm, or ms manuscript macros used to format text files. You'll generally need to
specify the macro set on the groff command line if you use these commands:
</P>
<!-- CODE SNIP //-->
<PRE>
# groff -Tascii -mm myfile.txt
</PRE>
<!-- END CODE SNIP //-->
<P>Documentation for several of these macros are in various
groff-related manual pages. One of the best documented sets included with your Linux distribution is the mm
manuscript macros in the groff_mm manual page. Table 15.1 lists some common macros
you can use to produce formatted documents.
</P>
<P>Table 15.1. Common groff_mm macros.
</P>
<TABLE>
<TR><TD>
Action
</TD><TD>
Macro Name
</TD></TR><TR><TD>
Center justify
</TD><TD>
.ds C
</TD></TR><TR><TD>
End text box
</TD><TD>
.b2
</TD></TR><TR><TD>
Justification off
</TD><TD>
.sa 0
</TD></TR><TR><TD>
Justification on
</TD><TD>
.sa 1
</TD></TR><TR><TD>
Line fill off
</TD><TD>
.ds N
</TD></TR><TR><TD>
Line fill on
</TD><TD>
.ds F
</TD></TR><TR><TD>
New paragraph with x indent
</TD><TD>
.p x
</TD></TR><TR><TD>
No indents
</TD><TD>
.ds L
</TD></TR><TR><TD>
Right justify
</TD><TD>
.ds R
</TD></TR><TR><TD>
Start bold text
</TD><TD>
.b
</TD></TR><TR><TD>
Start text box
</TD><TD>
.b1
</TD></TR><TR><TD>
Use columns
</TD><TD>
.mc
</TD></TR><TR><TD>
Use one column
</TD><TD>
.1c
</TD></TR><TR><TD>
Use two columns
</TD><TD>
.2c
</TD></TR></TABLE>
<P>Some of the more common commands that don't require a macro set are listed in
Table 15.2. Experiment with them to see their effect on your documents before printing.
</P>
<A NAME="PAGENUM-235"><P>Page 235</P></A>
<P>Table 15.2. Common groff typesetting commands.
</P>
<TABLE>
<TR><TD>
Action
</TD><TD>
Command Name
</TD></TR><TR><TD>
Begin new page
</TD><TD>
.bp
</TD></TR><TR><TD>
Begin new paragraph
</TD><TD>
.pp
</TD></TR><TR><TD>
Center next x lines
</TD><TD>
.ce x
</TD></TR><TR><TD>
Center text x
</TD><TD>
.ce x
</TD></TR><TR><TD>
Insert (space) x inches down
</TD><TD>
.sp xi
</TD></TR><TR><TD>
Insert x inches down
</TD><TD>
.sv xi
</TD></TR><TR><TD>
Set font bold
</TD><TD>
.ft B
</TD></TR><TR><TD>
Set font roman
</TD><TD>
.ft R
</TD></TR><TR><TD>
Set line spacing to x
</TD><TD>
.ls x
</TD></TR><TR><TD>
Temporary indent x inches
</TD><TD>
.ti xi
</TD></TR><TR><TD>
Turn off line fill
</TD><TD>
.nf
</TD></TR><TR><TD>
Turn on centering
</TD><TD>
.ce
</TD></TR><TR><TD>
Turn on indenting x inches
</TD><TD>
.in xi
</TD></TR><TR><TD>
Turn on line fill
</TD><TD>
.fi
</TD></TR><TR><TD>
Underline next x lines
</TD><TD>
.ul x
</TD></TR></TABLE>
<P>When you're ready to produce a formatted document, use the
groff command's -T command-line option to produce a document in several different formats. The
groff formatter produces PostScript, TeX dvi (discussed next), text, HP printer-control
language, or PCL, formats. Look at the following example:
</P>
<!-- CODE SNIP //-->
<PRE>
# groff -Tascii -mm myfile.txt >myfile.txt
# groff -Tps -mm myfile.txt >myfile.ps
# groff -Tdvi -mm myfile.txt >myfile.dvi
</PRE>
<!-- END CODE SNIP //-->
<P>You can preview these documents before printing by using several different programs,
such as ghostview for PostScript, or xdvi, for dvi files.
</P>
<H4><A NAME="ch15_ 7">
Formatting Text with TeX
</A></H4>
<P>The TeX typesetting system, originally by Donald E. Knuth, is a collection of programs
and other utilities used to produce professionally formatted documents. It is a much
more sophisticated system than the groff distribution, and includes more than 65 programs,
along with related support files, such as libraries, macros, fonts, and documentation.
</P>
<P>If you install TeX on your system, you'll need at least 30 megabytes for the
main distribution, 10 megabytes for a series of related macros called LaTeX, and eight
megabytes</P>
<A NAME="PAGENUM-236"><P>Page 236</P></A>
<P>for 50 different fonts. Obviously, describing the entire system and how to use each
different program in the TeX system is beyond this hour. But this section shows you how to
get started with a sample document.
</P>
<P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
CAUTION
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
Previewing TeX dvi documents requires a preprocessing step that can
take several minutes before the pages are even displayed. Files must first
be processed by the MakeTeXPK program, and related processes can eat up
your system resources. A much better approach is to convert the file to
PostScript with the dvips command, found under the
/usr/bin directory, with: dvips -f < texdoc.dvi
>tex.ps, and to then use the ghostview program with
ghostview tex.ps to read the file.
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
</P>
<P>You'll find documentation for TeX in a variety of places. You can read the manual
pages for related files, check the /usr/info directory for TeX info files, and browse to the
/usr/lib/texmf/texmf/doc directory. There are 10 different directories of documentation files, but the
easiest way to read about your TeX distribution is to use the lynx Web browser with the following:
</P>
<!-- CODE SNIP //-->
<PRE>
# lynx /usr/lib/texmf/texmf/doc/index.html
</PRE>
<!-- END CODE SNIP //-->
<P>The TeX distribution files are displayed in an organized list, and you can browse
through the list to download sample files and guides directly to your home directory.
Beginning users should definitely read the TeX Frequently Asked Questions document.
</P>
<P>Like the groff program, TeX uses formatting commands inserted in your text files
to manipulate how your file looks when printed. You'll create your file, insert
appropriate commands or macros to format text, and then process your document through TeX
to create an output file, usually in dvi format, that you can preview or print.
</P>
<P>To see a sample of TeX using the LaTeX macros, try processing an example file in the
TeX directories:
</P>
<!-- CODE SNIP //-->
<PRE>
# latex /usr/lib/texmf/texmf/doc/generic/pstricks/samples.tex
</PRE>
<!-- END CODE SNIP //-->
<P>This creates a file called samples.dvi. You should convert the file to PostScript first,
then preview the document with the ghostscript program:
</P>
<!-- CODE SNIP //-->
<PRE>
# dvips -f <samples.dvi >samples.ps
# ghostview samples.ps
</PRE>
<!-- END CODE SNIP //-->
<P>You'll see that you can use TeX to produce complex diagrams and text. But you'll have
to make the effort to learn TeX first!
</P>
<P><CENTER>
<a href="0229-0232.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0237-0240.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -