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

📄 ch19.htm

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


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

 -->






 











 

















<center><H1>TeX</H1></center>







<UL>



	<LI><A HREF="#Heading1">- 19 -</A>



	<UL>



		<LI><A HREF="#Heading2">TeX</A>



		<UL>



			<LI><A HREF="#Heading3">What Is TeX?</A>



			<LI><A HREF="#Heading4">Typesetting Versus Writing</A>



			<LI><A HREF="#Heading5">TeX</A>



			<UL>



				<LI><A HREF="#Heading6">Simple Text Formatting</A>



				<LI><A HREF="#Heading7">Fonts</A>



				<LI><A HREF="#Heading8">Controlling Spacing</A>



				<LI><A HREF="#Heading9">Page Layout</A>



				<LI><A HREF="#Heading10">Using Groups</A>



				<LI><A HREF="#Heading11">Mathematical Symbols</A>



				<LI><A HREF="#Heading12">Using Figures in Your Document</A>



				<LI><A HREF="#Heading13">Macros</A>



			</UL>



			<LI><A HREF="#Heading14">WARNING</A>



			<LI><A HREF="#Heading15">LaTeX: An Enhancement of TeX</A>



			<UL>



				<LI><A HREF="#Heading16">Defining a LaTeX Document</A>



				<LI><A HREF="#Heading17">Packages</A>



				<LI><A HREF="#Heading18">Using Special Characters</A>



				<LI><A HREF="#Heading19">Putting Structure into a LaTeX Document</A>



				<LI><A HREF="#Heading20">Adding Other Structural Elements</A>



				<LI><A HREF="#Heading21">Working with Figures and Tables</A>



			</UL>



			<LI><A HREF="#Heading22">VirTeX and IniTeX</A>



			<LI><A HREF="#Heading23">Summary</A>



		</UL>



	</UL>



</UL>







<P>



<HR SIZE="4">







<H2 ALIGN="CENTER"><A NAME="Heading1<FONT COLOR="#000077">- 19 -</FONT></H2>



<H2 ALIGN="CENTER"><A NAME="Heading2<FONT COLOR="#000077">TeX</FONT></H2>



<P><I>by Peter MacKinnon</I></P>



<P>IN THIS CHAPTER</P>







<UL>



	<LI>What Is TeX? 



	<P>



	<LI>Typesetting Versus Writing 



	<P>



	<LI>TeX 



	<P>



	<LI>LaTeX: An Enhancement of TeX 



	<P>



	<LI>VirTeX and IniTeX 



</UL>







<P><BR>



This chapter looks at the following topics:







<UL>



	<LI>What <TT>TeX</TT> is and why you would want to use it



	<P>



	<LI>The differences between typesetting and writing



	<P>



	<LI>The enhanced version of <TT>TeX</TT> called <TT>LaTeX</TT>



	<P>



	<LI><TT>What</TT> <TT>VirTeX</TT> and <TT>IniTeX </TT>are



</UL>







<H3 ALIGN="CENTER"><A NAME="Heading3<FONT COLOR="#000077">What Is TeX?</FONT></H3>



<P><TT>TeX</TT> (pronounced tech) is a text formatting system invented by Donald



Knuth. It lets you produce professionally typeset documents by embedding <TT>TeX</TT>



commands within a normal ASCII text file. This text file can then be converted to



what is known as a dvi (device-independent file), which can be either previewed on-screen



using an X Window program called <TT>xdvi</TT> or converted to a PostScript file



for printing.</P>



<P><TT>TeX</TT> is a powerful program in that it enables you to define specific typesetting



commands (such as font size, page size, or space between lines). It also works as



a programming language that enables you to create macros for defining more abstract



units of text such as documents, headings, and paragraphs. The benefit of these high-level



macros is that they enable you to concentrate on the authoring of a document, not



the typesetting. The key appeal of <TT>TeX</TT> for engineers and scientists is that



it supports the typesetting of complex mathematical formulas.



<H3 ALIGN="CENTER"><A NAME="Heading4<FONT COLOR="#000077">Typesetting Versus



Writing</FONT></H3>



<P>The usefulness of a document can be limited by its appearance. Consider two documents:



one that is well-organized with clearly defined units of text such as chapters, headings,



and paragraphs, and another that has no paragraph breaks and no space between lines.



The first document is much more appealing to the reader, whereas the second document



is downright painful to read. So, despite the best efforts of an author to create



a magnum opus, or even a recipe for strawberry jam, the meaning behind the words



may get lost in a typographical abyss.</P>



<P>In book publishing, authors aren't usually responsible for anything beyond the



genius of their words. They usually leave the design and crafting of the book to



a book designer. This person then hands the design template to page layout technicians.



<TT>TeX</TT> performs this book design and typesetting role for you, enabling you,



the author, to be your own publisher. It gives you control over the publication of



your own material while still permitting you to concentrate on what you're supposed



to be writing about!



<H3 ALIGN="CENTER"><A NAME="Heading5<FONT COLOR="#000077">TeX</FONT></H3>



<P>A <TT>TeX</TT> file can be created with any Linux text editor such as <TT>vi</TT>



or <TT>Emacs</TT>. You can enter text into a file called <TT>arkana.tex</TT> like



this:</P>



<PRE><FONT COLOR="#0066FF">Do you suppose that Alfred Hitchcock would have had as successful a directing



career if he did not have the considerable talents of actors Cary Grant and 



James Stewart in his most popular films? That's a tough one to answer... \bye



</FONT></PRE>



<P>After you have saved your file, use the <TT>TeX</TT> program to convert it to



a dvi file using the following command:</P>



<PRE><FONT COLOR="#0066FF">$ tex arkana



</FONT></PRE>



<P>The resulting <TT>arkana.dvi</TT> file that is created contains your text. This



file can be used by different output devices (hence the name) for viewing or printing.



For example, if you want to print your dvi file to a PostScript printer, convert



it to a <TT>ps</TT> format, and print it using the <TT>dvi2ps</TT> utility:</P>



<PRE><FONT COLOR="#0066FF">$ dvi2ps arkana.dvi | lp



</FONT></PRE>



<P>This assumes that the default printer is PostScript-capable. If you want to just



preview how the text looks, use the <TT>X</TT> application <TT>xdvi</TT>:</P>



<PRE><FONT COLOR="#0066FF">$ xdvi arkana.dvi &amp;



</FONT></PRE>



<P>The <TT>tex</TT> command also produces a log file entitled <TT>arkana.log</TT>,



containing any error and warning messages, and other information such as the number



of pages of output. The beauty of all this indirect representation of <TT>TeX</TT>



output is that the <TT>TeX</TT> source file and its resulting dvi are very portable,



particularly from Linux to its ancestor UNIX.



<H4 ALIGN="CENTER"><A NAME="Heading6<FONT COLOR="#000077">Simple Text Formatting</FONT></H4>



<P>Most of the work in creating a <TT>TeX</TT> document is putting in the words that



discuss whatever you're writing about. As shown earlier, it is fairly simple to create



an unadorned <TT>TeX</TT> file: The only special command you used was <TT>\bye</TT>.



This command tells the <TT>TeX</TT> program that it has reached the end of the document.



The <TT>\bye</TT> command uses one of several characters that <TT>TeX</TT> treats



with special interest, specifically the backslash or escape character. Here is the



set of special characters that <TT>TeX</TT> recognizes: <TT>\</TT>, <TT>{</TT>, <TT>}</TT>,



<TT>~</TT>, <TT>#</TT>, <TT>$</TT>, <TT>%</TT>, <TT>^</TT>, <TT>&amp;</TT>, and the



space character. The meaning behind these characters will be discussed as you progress.</P>



<P>One of the main conveniences of <TT>TeX</TT> is the intelligent way it deals with



text. Words are any sequence of characters separated by whitespace characters. The



number of whitespace characters between words is immaterial because <TT>TeX</TT>



treats them as one character. Sentences are recognized by the last word preceding



a <TT>.</TT>, <TT>?</TT>, <TT>!</TT>, or <TT>:</TT>. Paragraphs are distinguished



by a blank line following a sentence. Much like the spaces between words, <TT>TeX</TT>



treats excess blank lines as redundant and ignores them. Thus, the text</P>



<PRE><FONT COLOR="#0066FF">How do you compare



these two terrific leading men? James Stewart had that good-natured, 



All-American       charm      mixed



with a surprising element of vulnerability, uncommon



among     other major Hollywood actors.



Cary Grant, on the other



hand, was versatile     enough to play the villain as well as the suave hero in many films.



</FONT></PRE>



<P>is formatted by <TT>TeX</TT> as follows:</P>



<PRE><FONT COLOR="#0066FF">How do you compare these two terrific leading men? James Stewart had that good-natured, All-American charm mixed with a surprising element of vulnerability, uncommon among other major Hollywood actors.



Cary Grant, on the other hand, was versatile enough to play the villain as well as the suave hero in many films.



</FONT></PRE>



<P>You can also insert comments into your <TT>TeX</TT> file using the <TT>%</TT>



character. Text following a <TT>%</TT> character is treated as a comment and not



made part of the <TT>TeX</TT> output. The text</P>



<PRE><FONT COLOR="#0066FF">From her% Nothing to do with Hitchcock



% ...nothing at all



e to there



</FONT></PRE>



<P>is formatted as</P>



<PRE><FONT COLOR="#0066FF">From here to there



</FONT></PRE>



<P><TT>TeX</TT> has several commands for manipulating paragraphs. The <TT>\par</TT>



command starts a new paragraph, which has the same effect as inserting a blank line.</P>



<PRE><FONT COLOR="#0066FF">From here \par to there



</FONT></PRE>



<P>The preceding line is formatted as follows:</P>



<PRE><FONT COLOR="#0066FF">From here







to there



</FONT></PRE>



<P>The <TT>\noindent</TT> command tells <TT>TeX</TT> not to indent the paragraph:</P>



<PRE><FONT COLOR="#0066FF">I grew up on Newcastle Street.



\noindent That was close to Hazlehurst.



</FONT></PRE>



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



<PRE><FONT COLOR="#0066FF">        I grew up on Newcastle Street.



That was close to Hazlehurst.



</FONT></PRE>



<P>You can also use the escape character before a space in order to force the insertion



of an extra space:</P>



<PRE><FONT COLOR="#0066FF">I think that I need an extra\ \ \ space or two.



I'm sure        of it.



</FONT></PRE>



<P>This becomes</P>



<PRE><FONT COLOR="#0066FF">I think that I need an extra   space or two.



I'm sure of it.



</FONT></PRE>



<H4 ALIGN="CENTER"><A NAME="Heading7<FONT COLOR="#000077">Fonts</FONT></H4>



<P>Fonts are representations of characters that share similar size and style. The



default font that <TT>TeX</TT> uses is Roman. You can override this by using the



internal names that <TT>TeX</TT> associates with fonts that are externally loaded.



You can also add new font definitions. The definitions that <TT>TeX</TT> knows about



by default are <TT>\rm</TT> (Roman), <TT>\tt</TT> (typewriter), <TT>\bf</TT> (bold),



<TT>\sl</TT> (slanted), and <TT>\it</TT> (italic). <TT>TeX</TT> continues using whatever



font was last specified (including the default) until it is instructed to do otherwise.



Therefore, the text</P>



<PRE><FONT COLOR="#0066FF">This is roman, but I think I will switch to \tt typewriter for a while; then again, maybe \it italic would be nice. Now back to \rm roman.



</FONT></PRE>



<P>appears as follows:</P>



<P>This is roman, but I think I will switch to <TT>typewriter for a while; then again,



maybe</TT> italic would be nice. Now back to roman.</P>



<P>You can add a font and change its size using a command like this:</P>



<PRE><FONT COLOR="#0066FF">\font \fontname=auxiliary font



</FONT></PRE>



<P>To use a 12-point roman font, redefine the <TT>\rm</TT> definition to use the



<TT>cmr12</TT> auxiliary font, like this:</P>



<PRE><FONT COLOR="#0066FF">\font\rm=cmr12







We are changing from this font \rm to that font.



</FONT></PRE>



<P>This formats as follows:</P>



<P><TT>We are changing from this font</TT> to that font.</P>



<P>Fonts have up to 256 different symbols including the standard numeric, uppercase,



and lower- case character symbols that you use most frequently. Symbols that are



not represented on a standard keyboard can be accessed using the <TT>\char</TT> command.



This command uses the integer that follows it as a character code index into a font's



character table. For example, the text</P>



<PRE><FONT COLOR="#0066FF">TeX would interpret \char 37 as a comment symbol



but it would not



⌨️ 快捷键说明

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