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

📄 ch19.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 4 页
字号:


		<TD ALIGN="LEFT">Delta</TD>



	</TR>



</TABLE>



</P>



</CENTER>



<P><TT><BR>



TeX</TT> 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.



<CENTER>



<H4><A NAME="Heading12<FONT COLOR="#000077">Using Figures in Your Document</FONT></H4>



</CENTER>



<P>Figures that are drawn outside of <TT>TeX</TT> can be inserted into their own



space. This space &quot;floats.&quot; In other words, <TT>TeX</TT> 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.</P>



<P>To insert a figure that must appear at the top of a page, use the following command:</P>



<PRE><FONT COLOR="#0066FF">\topinsert figure \endinsert



</FONT></PRE>



<P>Here, figure can be an external reference or an internal definition. <TT>TeX</TT>



tries to place the figure at the top of the next page with sufficient space.</P>



<P>You can also tell <TT>TeX</TT> that you want a figure to appear on its own page



by using this command:</P>



<PRE><FONT COLOR="#0066FF">\pageinsert figure \endinsert



</FONT></PRE>



<CENTER>



<H4><A NAME="Heading13<FONT COLOR="#000077">Macros</FONT></H4>



</CENTER>



<P>Macros have made <TT>TeX</TT> 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.</P>



<P>A macro is defined once, using the following format:</P>



<PRE><FONT COLOR="#0066FF">\def macroname {new text}



</FONT></PRE>



<P>In this case, macroname is a name or <TT>TeX</TT> 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</P>



<PRE><FONT COLOR="#0066FF">\def\brg{burger}







Ham\brg, cheese\brg, lim\brg.



</FONT></PRE>



<P>is output as follows:</P>



<PRE><FONT COLOR="#0066FF">Hamburger, cheeseburger, limburger.



</FONT></PRE>



<P>Macros can refer to other macros, as in</P>



<PRE><FONT COLOR="#0066FF">\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:</P>



<PRE><FONT COLOR="#0066FF">a wonderful thing is a tigger cause a tigger is a wonderful thing



</FONT></PRE>







<DL>



	<DT><FONT COLOR="#0066FF"></FONT></DT>



</DL>











<DL>



	<DD>



<HR>



<A NAME="Heading14<FONT COLOR="#000077"><B>WARNING:</B> </FONT>You must be



	careful of recursive macro definitions: macros that refer to their own names within



	their definition. Such macro definitions cause <TT>TeX</TT> to continuously (and



	vainly) evaluate the macro, leading to an infinite loop. The following is an example



	of this:



</DL>











<DL>



	<DD><FONT COLOR="#0066FF">\def\itself{\itself}<BR>



	\itself</FONT> 



<HR>







</DL>







<PRE></PRE>



<P><TT>TeX</TT> 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:</P>



<PRE><FONT COLOR="#0066FF">\def macroname (list of formal parameters) {new text}



</FONT></PRE>



<P>Here, the list of parameters is specified as <TT>#1</TT>, <TT>#1#2</TT>, <TT>#1#2#3</TT>,



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</P>



<PRE><FONT COLOR="#0066FF">\def\parm#1{This is the #1 time I'll say this.}



\parm{first}



\parm{second}



\parm{last}



</FONT></PRE>



<P>produces the following:</P>



<PRE><FONT COLOR="#0066FF">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</P>



<PRE><FONT COLOR="#0066FF">\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:</P>



<PRE><FONT COLOR="#0066FF">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</P>



<PRE><FONT COLOR="#0066FF">\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.</P>



<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.</P>



<P>Macro definitions can be nested within each other, as in the following:</P>



<PRE><FONT COLOR="#0066FF">\def\hey{Hey\def\hey{hey}}



</FONT></PRE>



<PRE><FONT COLOR="#0066FF">\hey, \hey, \hey.



</FONT></PRE>



<P>This has the following output:</P>



<PRE><FONT COLOR="#0066FF">Hey, hey, hey.



</FONT></PRE>



<P>As with many topics within this book, we have examined only some of the highlights



of <TT>TeX</TT>. There is much more to learn but, having covered the basics regarding



macros, you can now look at the most popular extension of <TT>TeX</TT>, which uses



macros to enhance the creation of documents. This extension is <TT>LaTeX</TT>.



<CENTER>



<H3><A NAME="Heading15<FONT COLOR="#000077">LaTeX: An Enhancement of TeX</FONT></H3>



</CENTER>



<P><TT>LaTeX</TT> is a collection of macros that build on the capabilities of <TT>TeX</TT>



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.



<TT>LaTeX</TT> macros shift the emphasis away from the details of things such as



&quot;set text to 8-point slanted&quot; to concepts that writers identify more readily



with, such as the emphasis of a word or phrase. Thus, <TT>LaTeX</TT> macros have



names that are more representative of the way writers think when they are writing.</P>



<P>Because <TT>LaTeX</TT> is an extension of <TT>TeX</TT>, you'll find it easy to



become quickly productive in <TT>LaTeX</TT>, assuming that you have some experience



in <TT>TeX</TT>. White space and spacing between paragraphs are handled in the same



manner as in <TT>TeX</TT>. The special characters in <TT>TeX</TT> are the same in



<TT>LaTeX</TT>, and comments are denoted using the <TT>%</TT> character.</P>



<P>The key differences between <TT>TeX</TT> and <TT>LaTeX</TT> become apparent as



you learn more about the macros that define the layout of your document in a convenient



fashion.



<CENTER>



<H4><A NAME="Heading16<FONT COLOR="#000077">Defining a LaTeX Document</FONT></H4>



</CENTER>



<P>Every <TT>LaTeX</TT> document begins with the <TT>\documentclass</TT> 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. </P>



<CENTER>



<P><FONT SIZE="4"><B>Table 19.2. Document classes. </B></FONT>



<TABLE BORDER="0">



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><I>Document Class</I></TD>



		<TD ALIGN="LEFT"><I>Description</I></TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>article</TT></TD>



		<TD ALIGN="LEFT">Used for short reports, reference cards, presentations, scientific</TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"></TD>



		<TD ALIGN="LEFT">journals, and so on.</TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>book</TT></TD>



		<TD ALIGN="LEFT">Used for complete books.</TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>report</TT></TD>



		<TD ALIGN="LEFT">Used for reports having several chapters, theses, and so on.</TD>



	</TR>



</TABLE>



</P>



</CENTER>



<P><BR>



To create a very basic <TT>LaTeX</TT> document, simply place some words between the



two commands <TT>\begin{document}</TT> and <TT>\end{document}</TT>. The text that



precedes the <TT>\begin{document}</TT> 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:</P>



<PRE><FONT COLOR="#0066FF">\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 <TT>gloves.tex</TT>),



use the following command:</P>



<PRE><FONT COLOR="#0066FF">% latex gloves



</FONT></PRE>



<P>This produces a dvi file and a log file in the same manner used by <TT>TeX</TT>.



The dvi file can either be converted to PostScript, or viewed directly using <TT>xdvi</TT>.</P>



<P>You can specify options with the type of document in the <TT>\documentclass</TT>



command using the following format:</P>



<PRE><FONT COLOR="#0066FF">\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. </P>



<CENTER>



<P><FONT SIZE="4"><B>Table 19.3. \documentclass options. </B></FONT>



<TABLE BORDER="0">



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><I>Option</I></TD>



		<TD ALIGN="LEFT"><I>Description</I></TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>10pt</TT>, <TT>11pt</TT>, <TT>12pt</TT></TD>



		<TD ALIGN="LEFT">The default font for the document, which is <TT>10pt</TT> if not otherwise stated.</TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>fleqn</TT></TD>



		<TD ALIGN="LEFT">Displays formulas as left-justified instead of centered.</TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>leqno</TT></TD>



		<TD ALIGN="LEFT">Numbers formulas on the left side.</TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>letterpaper</TT>, <TT>a4 paper</TT></TD>



		<TD ALIGN="LEFT">The paper size, which is <TT>letterpaper</TT> by default.</TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>openright</TT>, <TT>openany</TT></TD>



		<TD ALIGN="LEFT">Starts the first page of a chapter on the right side, or on the next available page.</TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>titlepage</TT>, <TT>notitlepage</TT></TD>



		<TD ALIGN="LEFT">Does or does not start a new page after the title.</TD>



	</TR>



	<TR ALIGN="LEFT" rowspan="1">



		<TD ALIGN="LEFT"><TT>twocolumn</TT></TD>



		<TD ALIGN="LEFT">Splits each page into two columns (useful for newsletters).</TD>



	</TR>



⌨️ 快捷键说明

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