rhl19.htm
来自「linux的初学电子书」· HTM 代码 · 共 2,061 行 · 第 1/4 页
HTM
2,061 行
D
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
\diamond
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Diamond</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
D
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
\Delta
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Delta</FONT>
</TABLE><P>TeX uses particular fonts for the formulas it produces. These can be overridden in the usual fashion, but the changes are applicable only to letters and digits.
<BR>
<BR>
<A NAME="E69E264"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Using Figures in Your Document</B></FONT></CENTER></H4>
<BR>
<P>Figures that are drawn outside of TeX can be inserted into their own space. This space "floats." In other words, TeX knows that it must keep track of the figure space as the text around it is added or deleted. This flexibility means that you,
the writer, need not worry about exactly where in the document your figures will appear.
<BR>
<P>To insert a figure that must appear at the top of a page, use the following command:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">\topinsert figure \endinsert</FONT></PRE>
<P>Here, figure can be an external reference or an internal definition. TeX tries to place the figure at the top of the next page with sufficient space.
<BR>
<P>You can also tell TeX that you want a figure to appear on its own page by using this command:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">\pageinsert figure \endinsert</FONT></PRE>
<BR>
<A NAME="E69E265"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Macros</B></FONT></CENTER></H4>
<BR>
<P>Macros have made TeX a highly extendible system. They essentially enable you to create new commands by associating existing commands and text sequences to a macro name. After they are defined, these macros can be used in other parts of your document to
replace repetitive pieces of text, or to encapsulate abstract operations.
<BR>
<P>A macro is defined once, using the following format:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">\def macroname {new text}</FONT></PRE>
<P>In this case, macroname is a name or TeX command preceded by a backslash character. Any reference to this macro name is replaced by the new text throughout the document. For example, the macro definition
<BR>
<PRE>
<FONT COLOR="#000080">\def\brg{burger}
Ham\brg, cheese\brg, lim\brg.</FONT></PRE>
<P>is output as follows:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">Hamburger, cheeseburger, limburger.</FONT></PRE>
<P>Macros can refer to other macros, as in
<BR>
<PRE>
<FONT COLOR="#000080">\def\tig{a tigger }
\def\wond{a wonderful thing }
\def\pooh{\wond is \tig cause \tig is \wond}
\pooh\par</FONT></PRE>
<P>which produces the following:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">a wonderful thing is a tigger cause a tigger is a wonderful thing</FONT></PRE>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>You must be careful of recursive macro definitions—macros that refer to their own names within their definition. Such macro definitions cause TeX to continuously (and vainly) evaluate the macro, leading to an infinite loop. The following is an
example of this:
<BR>\def\itself{\itself}
<BR>\itself</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>TeX macros have the added feature of being able to accept parameters when expanded, if a list of formal parameters has been specified in the macro definition. To create a macro using parameters, you would use this format:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">\def macroname (list of formal parameters) {new text}</FONT></PRE>
<P>Here, the list of parameters is specified as #1, #1#2, #1#2#3, and so on. This is a powerful aspect of macros because it can change the output of an expanded macro based on the parameter in use. For example, the code
<BR>
<PRE>
<FONT COLOR="#000080">\def\parm#1{This is the #1 time I'll say this.}
\parm{first}
\parm{second}
\parm{last}</FONT></PRE>
<P>produces the following:
<BR>
<PRE>
<FONT COLOR="#000080">This is the first time I'll say this.
This is the second time I'll say this.
This is the last time I'll say this.</FONT></PRE>
<P>Each parameter that is used must be passed separately by enclosing it in braces, as in
<BR>
<PRE>
<FONT COLOR="#000080">\def\family#1#2{My #1 is #2.}
\family{wife}{Cindy}
\family{sister}{Sheila}
\family{father}{Myles}</FONT></PRE>
<P>which makes the following output:
<BR>
<PRE>
<FONT COLOR="#000080">My wife is Cindy.
My sister is Sheila.
My father is Myles.</FONT></PRE>
<P>You must specify an appropriate match of parameters in your macro definition. The macro definition
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">\def\mistake#1{This is wrong because of #2.}</FONT></PRE>
<P>is incorrect because it refers to a second parameter that is not specified in the formal parameter list.
<BR>
<P>Macros can be redefined in your document, but you should be aware that only the most recent definition will be applied. Also, macros defined within groups are only valid within the scope of the group.
<BR>
<P>Macro definitions can be nested within each other, as in the following:
<BR>
<PRE>
<FONT COLOR="#000080">\def\hey{Hey\def\hey{hey}}
\hey, \hey, \hey.</FONT></PRE>
<P>This has the following output:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">Hey, hey, hey.</FONT></PRE>
<P>As with many topics within this book, we have examined only some of the highlights of TeX. There is much more to learn but, having covered the basics regarding macros, you can now look at the most popular extension of TeX, which uses macros to enhance
the creation of documents. This extension is LaTeX.
<BR>
<BR>
<A NAME="E68E130"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>LaTeX</B><B> An Enhancement of </B><B>TeX</B></FONT></CENTER></H3>
<BR>
<P>LaTeX is a collection of macros that build on the capabilities of TeX and provide a higher level of abstraction for the creation of documents. It is essentially a style library that encourages uniform formatting and typesetting across documents. LaTeX
macros shift the emphasis away from the details of things such as "set text to 8-point slanted" to concepts that writers identify more readily with, such as the emphasis of a word or phrase. Thus, LaTeX macros have names that are more
representative of the way writers think when they are writing.
<BR>
<P>Because LaTeX is an extension of TeX, you'll find it easy to become quickly productive in LaTeX, assuming that you have some experience in TeX. White space and spacing between paragraphs are handled in the same manner as in TeX. The special characters
in TeX are the same in LaTeX, and comments are denoted using the % character.
<BR>
<P>The key differences between TeX and LaTeX become apparent as you learn more about the macros that define the layout of your document in a convenient fashion.
<BR>
<BR>
<A NAME="E69E266"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Defining a </B><B>LaTeX</B><B> Document</B></FONT></CENTER></H4>
<BR>
<P>Every LaTeX document begins with the \documentclass command. The parameter passed to this command specifies what kind of document you want to write. The basic document classes are described in Table 19.2.
<BR>
<BR>
<P ALIGN=CENTER>
<CENTER>
<FONT COLOR="#000080"><B>Table 19.2. Document classes.</B></FONT></CENTER>
<BR>
<TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Document Class</I>
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Description</I></FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
article
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Used for short reports, reference cards, presentations, scientific journals, and so on.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
book
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Used for complete books.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
report
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Used for reports having several chapters, theses, and so on.</FONT>
</TABLE><P>To create a very basic LaTeX document, simply place some words between the two commands \begin{document} and \end{document}. The text that precedes the \begin{document} command is called the preamble, and the text that comes after is known as
the body. So, you can create a very simple document such as the following:
<BR>
<PRE>
<FONT COLOR="#000080">\documentclass{article}
\begin{document}
What a small document this is.
\end{document}</FONT></PRE>
<P>To process this document (which you will edit in a file called gloves.tex), use the following command:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">% latex gloves</FONT></PRE>
<P>This produces a DVI file and a log file in the same manner used by TeX. The DVI file can either be converted to PostScript, or viewed directly using xdvi.
<BR>
<P>You can specify options with the type of document in the \documentclass command using the following format:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">\documentclass[option]{document class}</FONT></PRE>
<P>These options relate to the physical structure of the document. Some of the more common ones are listed in Table 19.3.
<BR>
<BR>
<P ALIGN=CENTER>
<CENTER>
<FONT COLOR="#000080"><B>Table 19.3. </B><B>\documentclass</B><B> options.</B></FONT></CENTER>
<BR>
<TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Option</I>
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Description</I></FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
10pt, 11pt, 12pt
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
The default font for the document, which is 10pt if not otherwise stated.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
fleqn
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Displays formulas as left-justified instead of centered.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
leqno
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Numbers formulas on the left side.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
letterpaper, a4 paper
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
The paper size, which is letterpaper by default.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
openright, openany
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Starts the first page of a chapter on the right side, or on the next available page.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
titlepage, notitlepage
</FONT>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?