345-348.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 144 行

HTML
144
字号
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:TeX and LaTeX</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=19//-->

<!--PAGES=345-348//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="../ch18/341-344.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="348-351.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 19<BR>TeX and LaTeX

</FONT></H2>

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

<DL>

<DT><B>In This Chapter</B>

<DT>&#149;&nbsp;&nbsp; Typesetting versus writing 

<DT>&#149;&nbsp;&nbsp; TeX

<DT>&#149;&nbsp;&nbsp; LaTeX: An enhancement of TeX

<DT>&#149;&nbsp;&nbsp; VirTeX and IniTeX

</DL>

<P><TT>TeX</TT> (pronounced <I>tech</I>) 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 <I>dvi</I> (device-independent file), which can be either previewed onscreen using an X Window program called <TT>xdvi</TT> or converted to a PostScript file for printing.</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 writing 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><A NAME="Heading2"></A><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 <I>magnum opus,</I> 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&#146;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 allowing you to concentrate on what you&#146;re supposed to be writing about!</P>

<H3><A NAME="Heading3"></A><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<B>:</B></P>

<!-- CODE SNIP //-->

<PRE>

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&#146;s a tough one to answer&#133;

\bye

</PRE>

<!-- END CODE SNIP //-->

<P>After you save your file, use the <TT>TeX</TT> program to convert it to a dvi file using this command:</P>

<!-- CODE SNIP //-->

<PRE>

&#36; tex arkana

</PRE>

<!-- END CODE SNIP //-->

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

<!-- CODE SNIP //-->

<PRE>

&#36; dvi2ps arkana.ps | lp

</PRE>

<!-- END CODE SNIP //-->

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

<!-- CODE SNIP //-->

<PRE>

&#36; xdvi arkana.dvi &#38;

</PRE>

<!-- END CODE SNIP //-->

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

<H4 ALIGN="LEFT"><A NAME="Heading4"></A><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&#146;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 <I>escape</I> character. Here is the set of special characters that <TT>TeX</TT> recognizes: <TT>\</TT>, <TT>&#123;</TT>, <TT>&#125;</TT>, <TT>~</TT>, <TT>#</TT>, <TT>&#36;</TT>, <TT>%</TT>, <TT>^</TT>, <TT>&#38;</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>

<!-- CODE //-->

<PRE>

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.

</PRE>

<!-- END CODE //-->

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

<!-- CODE SNIP //-->

<PRE>

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 Hitchcock films.

</PRE>

<!-- END CODE SNIP //-->

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

<!-- CODE SNIP //-->

<PRE>

From her% Nothing to do with Hitchcock

% &#133;nothing at all

e to there

</PRE>

<!-- END CODE SNIP //-->

<P>is formatted as

</P>

<!-- CODE SNIP //-->

<PRE>

From here to there

</PRE>

<!-- END CODE SNIP //-->

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="../ch18/341-344.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="348-351.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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