diff options
author | Karl Berry <karl@freefriends.org> | 2005-12-29 00:35:06 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2005-12-29 00:35:06 +0000 |
commit | 86f6ad0f8431ad33548e4b843418630365dcd7cb (patch) | |
tree | 59533054992d6c5e40a4cdbb4004b083bdfa4b1d /Master/texmf-doc/doc/english/make-tex-work/html/ch01.html | |
parent | 41ceff5a615ab4e3d46b1c94bd26d9dcf9d6c1f8 (diff) |
doc/english/m
git-svn-id: svn://tug.org/texlive/trunk@22 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-doc/doc/english/make-tex-work/html/ch01.html')
-rw-r--r-- | Master/texmf-doc/doc/english/make-tex-work/html/ch01.html | 2103 |
1 files changed, 2103 insertions, 0 deletions
diff --git a/Master/texmf-doc/doc/english/make-tex-work/html/ch01.html b/Master/texmf-doc/doc/english/make-tex-work/html/ch01.html new file mode 100644 index 00000000000..0a685eef905 --- /dev/null +++ b/Master/texmf-doc/doc/english/make-tex-work/html/ch01.html @@ -0,0 +1,2103 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta name="generator" + content="HTML Tidy for Linux/x86 (vers 1st March 2002), see www.w3.org" /> + <meta http-equiv="Content-Type" + content="text/html; charset=ISO-8859-1" /> + + <title>Chapter 1. The Big Picture</title> + <link rel="stylesheet" href="mtw.css" type="text/css" /> + <meta name="generator" + content="DocBook XSL Stylesheets V1.53.0" /> + <link rel="home" href="index.html" title="Making TeX Work" /> + <link rel="up" href="pt01.html" + title="Part I. An Introduction to TeX" /> + <link rel="previous" href="pt01.html" + title="Part I. An Introduction to TeX" /> + <link rel="next" href="ch02.html" + title="Chapter 2. Editing" /> + </head> + + <body> + <div class="navheader"> + <table border="0" cellpadding="0" cellspacing="0" + width="100%" summary="Navigation table"> + <tr> + <td align="left"> <a title="Making TeX Work" + href="index.html"><img src="figures/nav-home.png" + alt="Home" border="0" /></a> <a + title="Part I. An Introduction to TeX" + href="pt01.html"><img src="figures/nav-prev.png" + alt="Prev" border="0" /></a> <a + title="Part I. An Introduction to TeX" + href="pt01.html"><img src="figures/nav-up.png" alt="Up" + border="0" /></a> <a + title="Chapter 2. Editing" + href="ch02.html"><img src="figures/nav-next.png" + alt="Next" border="0" /></a></td> + + <td align="right"><i>Making TeX Work</i> Version 1.0.1 + <span class="alpha-version">(<a + href="co01.html"><em>Alpha</em></a>)</span></td> + </tr> + </table> + </div> + + <div class="chapter"> + <div class="titlepage"> + <div> + <h2 class="title"><a id="chap.tex" + name="chap.tex"></a>Chapter 1. The Big + Picture</h2> + </div> + + <div> + <p class="releaseinfo">$Revision: 1.1 $</p> + </div> + + <div> + <p class="pubdate">$Date: 2002/08/23 14:31:13 $</p> + </div> + <hr class="component-separator" /> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h2 class="title" style="clear: both"><a + id="sec.texforbeginners" + name="sec.texforbeginners"></a>What Is TeX?</h2> + </div> + </div> + + <p>TeX<a id="id2856076" class="indexterm" + name="id2856076"></a><a id="id2855998" class="indexterm" + name="id2855998"></a> is a <span + class="emphasis"><em>typesetting system</em></span>. It is + a collection of programs, files, and procedures for + producing professional quality documents with minimum + effort.</p> + + <p>TeX's job is to translate the text you type into a + beautiful<a id="id2856025" class="indexterm" + name="id2856025"></a> typeset page. The key word here is + “beautiful,” and it is a very lofty + goal.<sup>[<a id="id2856038" name="id2856038" + href="#ftn.id2856038">1</a>]</sup> What I mean by beautiful + is that TeX, when presented with several paragraphs of + plain text and left to its own devices, produces a + remarkably aesthetic page. Despite the fact that TeX may + have to contend with multiple fonts<a id="id2856069" + class="indexterm" name="id2856069"></a> and mathematics<a + id="id2857340" class="indexterm" name="id2857340"></a>, it + still manages to typeset pages in which each of the + following aesthetic principles hold <span + class="emphasis"><em>simultaneously:</em></span></p> + + <div class="itemizedlist"> + <ul type="disc"> + <li> + <p>The right margin is justified<a id="id2857364" + class="indexterm" name="id2857364"></a>.</p> + </li> + + <li> + <p>Proper justification is achieved without + letterspacing<a id="id2857382" class="indexterm" + name="id2857382"></a>.</p> + </li> + + <li> + <p>Interword spacing is neither too tight nor too + loose.<a id="id2857400" class="indexterm" + name="id2857400"></a></p> + </li> + + <li> + <p>The page is evenly gray.</p> + </li> + + <li> + <p>The baselines<a id="id2857426" class="indexterm" + name="id2857426"></a><a id="id2857433" + class="indexterm" name="id2857433"></a> of multiple + fonts are properly aligned.</p> + </li> + + <li> + <p>Hyphenation<a id="id2857454" class="indexterm" + name="id2857454"></a> is automatic, if required, and + usually correct.</p> + </li> + + <li> + <p>Ladders<a id="id2857471" class="indexterm" + name="id2857471"></a> are avoided.</p> + </li> + </ul> + </div> + + <p>TeX processes documents a paragraph at a time, rather + than a line at a time like most other programs. Internally, + TeX computes a value called <span + class="emphasis"><em>badness<a id="id2857492" + class="indexterm" name="id2857492"></a></em></span> for + each line of the paragraph<a id="id2857501" + class="indexterm" name="id2857501"></a>. Anything that + detracts from the appearance of a line (tight or loose + spacing, a hyphen, etc.) increases the badness associated + with that line. Every paragraph that TeX produces is + optimal in terms of the total amount of badness present. + Because TeX searches for an optimal solution, changing the + last word of a paragraph can affect the spacing of the + first line of the paragraph. After you've gained a little + bit of experience with TeX, you'll be able to override any + one, or all, of the rules it uses to compute badness, but + in most situations you won't want to. I will describe more + of TeX's approach to text formatting and how it differs + from that of word processors, desktop publishers, and other + markup languages in the following sections.</p> + + <p>TeX is not a simple program, but a set of programs, + tools, fonts, and other types of files. Two programs form + the core of the TeX typesetting system. One of them is TeX + itself, the program that reads your input files and + transforms them into typeset form. The other program is + MetaFont, a tool for creating fonts. Producing TeX + documents involves a series of steps, including editing the + document, running TeX itself, and processing TeX's output + in various ways.</p> + + <p>Over the years, TeX has been made available on almost + every computer platform<a id="id2857542" class="indexterm" + name="id2857542"></a>, so it is probably available for the + computer system that you use. Compiling TeX on different + systems has been possible, in large part, because TeX is a + text formatter and not a word processor. Unlike a word + processor, TeX never deals directly with displaying text on + the screen or interacting with input from the keyboard + (except in a very basic way). These features of an + application are typically the most difficult to port from + one system to another.</p> + + <p>Beyond the technical details that make translation from + one system to another possible, Donald Knuth<a + id="id2857571" class="indexterm" name="id2857571"></a> + added an important stipulation to the free distribution of + TeX: in order for any program to be called + “TeX,” it must pass a rigorous test suite<a + id="id2857586" class="indexterm" name="id2857586"></a>. + This means that the TeX you use behaves exactly like the + TeX I use.<sup>[<a id="id2857595" name="id2857595" + href="#ftn.id2857595">2</a>]</sup> This feature has + contributed greatly to TeX's success. It means that a large + community of TeX users can transparently share<a + id="id2857615" class="indexterm" name="id2857615"></a> + documents.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h2 class="title" style="clear: both"><a id="id2857628" + name="id2857628"></a>TeX for Beginners</h2> + </div> + </div> + + <p>If you are already familiar with TeX, you may find some + of the material in this section repetitive. If so, just + skim it quickly. This section will help you understand how + TeX interprets the things you type into your input file. + When you understand the concepts discussed here, you'll be + ready to write really, really simple documents in TeX.</p> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="sec.tex.controlsequences" + name="sec.tex.controlsequences"></a>Boxes and + Glue</h3> + </div> + </div> + <a id="boxes.start" class="indexterm" + name="boxes.start"></a> + + <p>Despite the apparent complexity of TeX's job, it uses + a very simple metaphor: all typographic elements are + boxes<a id="id2857670" class="indexterm" + name="id2857670"></a>. The simplest boxes, individual + characters<a id="id2857681" class="indexterm" + name="id2857681"></a><a id="id2857691" class="indexterm" + name="id2857691"></a> have a set shape defined by the + font they come from. There are three parameters that + define a box: width<a id="id2857704" class="indexterm" + name="id2857704"></a><a id="id2857714" class="indexterm" + name="id2857714"></a>, height<a id="id2857725" + class="indexterm" name="id2857725"></a><a id="id2857735" + class="indexterm" name="id2857735"></a>, and depth<a + id="id2857744" class="indexterm" name="id2857744"></a><a + id="id2857754" class="indexterm" name="id2857754"></a>. + The distinction between height and depth is a bit subtle. + When a row of characters is typeset, every character + rests on an imaginary line called the <span + class="emphasis"><em>baseline</em></span>. Some + characters, like the lowercase “g,” descend + below the baseline<a id="id2857774" class="indexterm" + name="id2857774"></a>. The distance from the baseline to + the top of a box is its height; the distance from the + baseline to the bottom is its depth.</p> + + <p>Figure <a href="ch01.html#fig.charbox" + title="Figure 1.1. The Letters g and h inside their boxes."> + Figure 1.1</a> shows the character boxes formed by + the Computer Modern<a id="id2857800" class="indexterm" + name="id2857800"></a> Roman letters “g” and + “h.” The <span + class="emphasis"><em>x-y</em></span> distance of each box + is its height and the <span + class="emphasis"><em>y-z</em></span> distance is its + depth. The <span class="emphasis"><em>reference + point</em></span><a id="id2857830" class="indexterm" + name="id2857830"></a> of the box, marked with an <span + class="emphasis"><em>r</em></span>, is on the leftmost + edge of the box where the height and depth meet. + Characters that have no <span + class="emphasis"><em>descenders<a id="id2857848" + class="indexterm" name="id2857848"></a></em></span> (no + elements that go below the baseline), have a depth of + zero. TeX uses the character box metrics, but font + designers are free to allow glyphs to extend outside the + box (for example, at the top of the “g”).</p> + + <div class="figure"> + <a id="fig.charbox" name="fig.charbox"></a> + + <p class="title"><b>Figure 1.1. The Letters + “g” and “h” inside their + boxes.</b></p> + + <div class="mediaobject"> + <img src="figures/g-h.png" + alt="The Letters 'g' and 'h' inside their boxes" /> + </div> + </div> + + <p>The following paragraph demonstrates how TeX uses the + metrics from the physical dimensions of each character to + build word, line, and paragraph boxes.</p> + + <p class="box">TeX “glues”<a id="id2857937" + class="indexterm" name="id2857937"></a> character boxes + together to form words. When boxes are joined, they are + always joined so their reference points are horizontally + aligned as shown in <a href="ch01.html#ex.csexample" + title="Example 1.1. An Example of a TeX Document"> + Example 1.1</a>.<sup>[<a id="id2857956" + name="id2857956" href="#ftn.id2857956">3</a>]</sup> + Character-boxes (like <span class="box">t</span><span + class="box">h</span><span class="box">i</span><span + class="box">s</span>) are joined to form words, + word-boxes<a id="id2857992" class="indexterm" + name="id2857992"></a> (like <span + class="box">this</span>) are joined to form lines, and + line-boxes<a id="id2858011" class="indexterm" + name="id2858011"></a> form paragraphs. TeX accomplishes + the task of forming a justified paragraph by allowing the + glue between words to stretch<a id="id2858026" + class="indexterm" name="id2858026"></a> and shrink<a + id="id2858037" class="indexterm" name="id2858037"></a> a + little bit and by occasionally breaking the glue between + characters to insert a hyphen. Although the rules are + slightly different, TeX builds a page out of vertical + boxes (paragraphs, figures, etc.) in an analogous + manner.</p> + + <p>This is a very generalized overview. In reality, a lot + of subtlety is required to capture all of the nuances of + typographical appearance.</p> + <a id="id2858059" class="indexterm" name="id2858059"></a> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="id2858068" + name="id2858068"></a>Control Sequences</h3> + </div> + </div> + + <p>A <span class="emphasis"><em>control sequence<a + id="id2858081" class="indexterm" + name="id2858081"></a></em></span> is a special + “word” that you put in your document. These + extra words are instructions for TeX, and they do not + usually appear in your typeset document. Example <a + href="ch01.html#ex.csexample" + title="Example 1.1. An Example of a TeX Document"> + Example 1.1</a> shows a contrived example of a TeX + document that uses several control sequences.</p> + + <div class="example"> + <a id="ex.csexample" name="ex.csexample"></a> + + <p class="title"><b>Example 1.1. An Example + of a TeX Document</b></p> +<pre class="screen"> +\def\ora{O'Reilly \& Associates} +\font\orafont=grlg10 +\parskip=\baselineskip +\parindent=0pt +\pageno=5 +This book is published by \ora in +the \textit{Nutshell} series. +\bye +</pre> + </div> + + <p>In most macro packages, a control sequence is a + backslash followed by a sequence of letters.<sup>[<a + id="id2858135" name="id2858135" + href="#ftn.id2858135">4</a>]</sup> TeX is case-sensitive, + so the control sequence \large is different from \Large + (these control sequences switch to large and very large + fonts in the LaTeX macro package). Control sequences end + with the first non-letter, even if it isn't a space. For + example, \parskip0pt is the control sequence \parskip + followed by <tt>0pt</tt>. This control sequence tells TeX + to insert zero points of extra space between + paragraphs.</p> + + <p>Unless instructed otherwise (with control sequences), + TeX builds rectangular paragraphs out of lines of words. + Changing fonts, building tables, and typesetting + mathematical equations<a id="id2858193" class="indexterm" + name="id2858193"></a> are examples of situations in your + document where TeX needs extra information.</p> + + <p>The number of control sequences used in a TeX document + may seem overwhelming at first. Luckily, every control + sequence falls into one of several categories:</p> + + <div class="variablelist"> + <dl> + <dt><span class="term">Macro control + sequences</span></dt> + + <dd> + <p>Macro control sequences<a id="id2858228" + class="indexterm" name="id2858228"></a> associate a + name with an arbitrary string of text (including + other control sequences). They are interpreted by + replacing the control sequence with the text of its + definition.<sup>[<a id="id2858243" name="id2858243" + href="#ftn.id2858243">5</a>]</sup></p> + + <p>Macro control sequences are the root of TeX's + tremendous flexibility. By defining control + sequences with meaningful names, like \chapter and + \footnote, TeX can present a reasonably simple + interface to the user. By redefining those control + sequences, the typeset output can be modified + without requiring you to retype large quantities of + text.</p> + + <p>In <a href="ch01.html#ex.csexample" + title="Example 1.1. An Example of a TeX Document"> + Example 1.1</a>, the macro control sequence + \ora is defined as a shortcut for typing + “O'Reilly & Associates.” This is a + simple example of how a macro control sequence can + be used.</p> + </dd> + + <dt><span class="term">Font control sequences<a + id="id2858301" class="indexterm" + name="id2858301"></a></span></dt> + + <dd> + <p>In <a href="ch01.html#ex.csexample" + title="Example 1.1. An Example of a TeX Document"> + Example 1.1</a>, the line \font\orafont=grlg10 + creates a font control sequence called \orafont. + When \orafont is used, TeX will begin typesetting + in the font <tt>grlg10</tt>. The name of the font, + <tt>grlg10</tt> in this case, refers to an external + file that contains font metric information. Fonts + are discussed in Chapter <a href="ch05.html" + title="Chapter 5. Fonts">Chapter 5</a>, + <span class="emphasis"><em><a href="ch05.html" + title="Chapter 5. Fonts">Chapter 5</a></em></span>.</p> + </dd> + + <dt><span class="term">Registers</span></dt> + + <dd> + <p>Registers<a id="id2858391" class="indexterm" + name="id2858391"></a> are like variables in a + programming language. They hold a single value of a + particular type. Many types of values can be + stored: numbers (also called “count” + values because they are simple counting numbers + like 1, 2, 17, or -5), dimensions (also called + “lengths”; they are distances like + 3.5pt or 2in), boxes, glue, and token lists (an + internal representation of your document used by + TeX).<sup>[<a id="id2858415" name="id2858415" + href="#ftn.id2858415">6</a>]</sup></p> + + <p>If you are unfamiliar with computer programming, + think of these registers as place holders. When TeX + needs to save a piece of information, like how much + space should be inserted between paragraphs, it + stores the information in a register. When the + information is needed again, in this case when TeX + has finished typesetting one paragraph and is about + to start another, it can retrieve that information + from the register. Registers are usually given + names that at least hint at how they are used. This + helps people read and modify the rules that TeX + uses to typeset documents.</p> + + <p>In Example <a href="ch01.html#ex.csexample" + title="Example 1.1. An Example of a TeX Document"> + Example 1.1</a>, \parskip, \baselineskip, and + \parindent are dimension registers. The \pageno + control sequence is a count register.</p> + + <p>There are only 256 registers of each type. The + type of information (number, dimension, or token + list) that a register can contain is defined when + the control sequence is created. Once a variable + like \parindent is created to hold a dimension, it + can never hold a number or a token list.<sup>[<a + id="id2858485" name="id2858485" + href="#ftn.id2858485">7</a>]</sup></p> + + <p>Registers may seem unnecessary now that you know + about macro control sequences, which can store + arbitrary information. However, registers differ + from macro control sequences not only in the types + of values they can hold, but also in the types of + operations that can be performed on them. There is + a TeX command called \advance, for example, that + can increment the value stored in a register by an + arbitrary amount. You can't \advance a macro + control sequence.</p> + </dd> + + <dt><span class="term">Built-in commands</span></dt> + + <dd> + <p>A number of control<a id="id2858535" + class="indexterm" name="id2858535"></a> sequences + are built into TeX. These “primitive” + operations form the basis for all higher-level + functionality. There are a wide variety of control + sequences of this type. Everything that can be done + in TeX can be reduced to a sequence of primitive + operations.</p> + + <p>There is no way to know, simply by inspection, + if a control sequence is one of the built-in + sequences or not. Luckily, it doesn't matter very + often; it really only matters when you are writing + complex macros.</p> + + <p>The \font control sequence in <a + href="ch01.html#ex.csexample" + title="Example 1.1. An Example of a TeX Document"> + Example 1.1</a> is a built-in control + sequence. So is \advance, mentioned above.</p> + </dd> + </dl> + </div> + + <p>The number and kind of control sequences available + depends upon the macro package that you are using. (Macro + packages are discussed fully in Chapter <a + href="ch04.html" + title="Chapter 4. Macro Packages">Chapter 4</a>, + <span class="emphasis"><em><a href="ch04.html" + title="Chapter 4. Macro Packages">Chapter 4</a></em></span>.) + For the rest of this chapter, the default settings of + Plain TeX<a id="id2858616" class="indexterm" + name="id2858616"></a> are assumed.<sup>[<a id="id2858627" + name="id2858627" href="#ftn.id2858627">8</a>]</sup> There + are other macro packages, like LaTeX, Lollipop, and + TeXinfo, which have different default values.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="sec.textformVSwordproc" + name="sec.textformVSwordproc"></a>Special + Characters</h3> + </div> + </div> + <a id="id2858665" class="indexterm" name="id2858665"></a> + + <p>In addition to control sequences, TeX reserves several + characters <a id="id2858675" class="indexterm" + name="id2858675"></a> for special purposes. Most of them + do not occur very frequently in ordinary text, but you + must be aware of them because there will be very + surprising consequences if you use them incorrectly.</p> + + <p>Table <a href="ch01.html#tab.activechars" + title="Table 1.1. Special Characters in Plain TeX "> + Table 1.1</a> shows all of the special characters in + Plain TeX.<sup>[<a id="id2858704" name="id2858704" + href="#ftn.id2858704">9</a>]</sup> Most of these + characters are special in other macro packages as well. + Font-specific characters are not reserved by TeX, but + they don't produce the results you would expect when + typeset in Computer Modern because of the way TeX expects + fonts to be laid out. Fonts are discussed in detail in + Chapter <a href="ch05.html" + title="Chapter 5. Fonts">Chapter 5</a>, + <span class="emphasis"><em><a href="ch05.html" + title="Chapter 5. Fonts">Chapter 5</a></em></span>.</p> + + <div class="table"> + <a id="tab.activechars" name="tab.activechars"></a> + + <p class="title"><b>Table 1.1. Special + Characters in Plain TeX <a id="id2858750" + class="indexterm" name="id2858750"></a></b></p> + + <table + summary="Special Characters in Plain TeX charactersspecialtypesetting" + border="1"> + <colgroup> + <col align="center" /> + <col /> + </colgroup> + + <thead> + <tr> + <th align="center">Character</th> + + <th>Meaning</th> + </tr> + </thead> + + <tbody> + <tr> + <td align="center">#</td> + + <td>Used for parameter definition in macros and + tables</td> + </tr> + + <tr> + <td align="center">$</td> + + <td>Toggles in and out of math mode</td> + </tr> + + <tr> + <td align="center">%</td> + + <td>A comment (TeX ignores everything to the end + of the line)</td> + </tr> + + <tr> + <td align="center">&</td> + + <td>The column separator in tables</td> + </tr> + + <tr> + <td align="center">~</td> + + <td>The active space (an unbreakable space)</td> + </tr> + + <tr> + <td align="center">_</td> + + <td>Marks a subscript (valid only in math + mode)</td> + </tr> + + <tr> + <td align="center">^</td> + + <td>Marks a superscript (valid only in math + mode)</td> + </tr> + + <tr> + <td align="center">\</td> + + <td>Begins a control sequence</td> + </tr> + + <tr> + <td align="center">{</td> + + <td>Begins a group</td> + </tr> + + <tr> + <td align="center">}</td> + + <td>Ends a group</td> + </tr> + + <tr> + <td align="center">|</td> + + <td>Produces an em-dash (—) + (font-specific)</td> + </tr> + + <tr> + <td align="center"><</td> + + <td>Produces an upside down exclamation mark (¡) + (font-specific)</td> + </tr> + + <tr> + <td align="center">></td> + + <td>Produces an upside down question mark (¿) + (font-specific)</td> + </tr> + + <tr> + <td align="center">"</td> + + <td>Incorrect for quoted text; use “ and + ” instead (font-specific)</td> + </tr> + </tbody> + </table> + </div> + + <p>It is best to avoid these characters until you are + familiar with TeX. If you need to typeset<a + id="id2859024" class="indexterm" name="id2859024"></a> + one of these characters, <a href="ch01.html#tab.acttype" + title="Table 1.2. How to Typeset Special Characters"> + Table 1.2</a> shows what to put in your document. + You should also avoid characters outside the standard + printable ASCII character set<a id="id2859048" + class="indexterm" name="id2859048"></a> (characters with + ASCII values below 32 and above 126). TeX can be + configured to accept characters outside the printable + ASCII range, to support non-English languages, for + example, but it is not configured to do so “out of + the box.” Chapter <a href="ch07.html" + title="Chapter 7. International Considerations"> + Chapter 7</a>, <span class="emphasis"><em><a + href="ch07.html" + title="Chapter 7. International Considerations"> + Chapter 7</a></em></span>, discusses the issues of + typesetting in different languages.</p> + + <div class="table"> + <a id="tab.acttype" name="tab.acttype"></a> + + <p class="title"><b>Table 1.2. How to Typeset + Special Characters<a id="id2859097" class="indexterm" + name="id2859097"></a></b></p> + + <table + summary="How to Typeset Special Charactersspecial characterstypesetting" + border="1"> + <colgroup> + <col align="center" /> + <col /> + </colgroup> + + <thead> + <tr> + <th align="center">To Get</th> + + <th>Put This in Your Document</th> + </tr> + </thead> + + <tbody> + <tr> + <td align="center">#</td> + + <td>\#</td> + </tr> + + <tr> + <td align="center">$</td> + + <td>\$</td> + </tr> + + <tr> + <td align="center">%</td> + + <td>\%</td> + </tr> + + <tr> + <td align="center">&</td> + + <td>\&</td> + </tr> + + <tr> + <td align="center">“</td> + + <td>``</td> + </tr> + + <tr> + <td align="center">”</td> + + <td>''</td> + </tr> + + <tr> + <td align="center">~</td> + + <td>\~</td> + </tr> + + <tr> + <td align="center">{</td> + + <td>$\{$</td> + </tr> + + <tr> + <td align="center">}</td> + + <td>$\}$</td> + </tr> + + <tr> + <td align="center"><</td> + + <td>$<$</td> + </tr> + + <tr> + <td align="center">></td> + + <td>$>$</td> + </tr> + + <tr> + <td align="center">|</td> + + <td>$|$</td> + </tr> + + <tr> + <td align="center">_</td> + + <td>$\underbar{\hbox{\ }}$</td> + </tr> + + <tr> + <td align="center">^</td> + + <td>$\hat{\hbox{ }}$</td> + </tr> + + <tr> + <td align="center">\</td> + + <td>$\backslash$</td> + </tr> + </tbody> + </table> + </div> + + <div class="sidebar"> + <p>Some of the suggestions in <a + href="ch01.html#tab.acttype" + title="Table 1.2. How to Typeset Special Characters"> + Table 1.2</a> will not always produce exactly what + you want. The entry for “~” really produces + a tilde accent, not a tilde character and the entries + for “{” through “\” all get the + actual characters from TeX's math fonts. The Computer + Modern text fonts don't include these characters so it + is necessary to get them from the math fonts. However, + if you are using PostScript or other kinds of fonts, + you may very well have curly braces, angle brackets, + underscores, etc. in the font. You can access these + characters directly with the \char primitive. I + strongly recommend that you always define macros for + this purpose, so that you can easily switch to some + other method if you change fonts. Introducing \char + primitives makes your document less portable. To use + the \char primitive, simply put the decimal ASCII value + of the character that you want to print. For example, + this book is typeset with PostScript fonts that include + a backslash character at position 92, so I defined \bs + to print a backslash like this:</p> +<pre class="screen"> +\def\bs{\char92\relax} +</pre> + + <p>Using \relax after the decimal value assures that + TeX won't get confused if I put a backslash in front of + other digits like this \bs300dpi.</p> + </div> + + <p>The braces<a id="id2859474" class="indexterm" + name="id2859474"></a> “{” and “}” + are a very special case. TeX uses curly braces to delimit + arguments and make changes (like switching fonts) that + are local to a small section of the document. These are + called <span class="emphasis"><em>grouping characters<a + id="id2859497" class="indexterm" + name="id2859497"></a></em></span><a id="id2859504" + class="indexterm" name="id2859504"></a> in TeX jargon. + For example, to typeset a single word in boldface, you + put {\bf word} into your input file. The \bf control + sequence switches to boldface type, and the curly braces + localize the effect to the single word <span + class="bold">word</span>. As a result, it is very + important that you avoid braces (except when you use them + as delimiters) and that you carefully match all opening + and closing braces. One of the most common errors in TeX + is to forget a closing brace.</p> + + <p>One last special character is the blank space<a + id="id2859543" class="indexterm" name="id2859543"></a>. + For the most part, TeX doesn't care how you space your + lines of text. Any space that occurs is simply a word + break to TeX, and inserting multiple spaces doesn't + influence how TeX typesets the line. TeX also considers + the end of a line an implicit space. If you are trying to + control the layout of your input text and want to break a + line without introducing a space, place a comment + character (% in most macro packages)<a id="id2859552" + class="indexterm" name="id2859552"></a> at the very end + of the line. If the last character of a line is the + comment character, TeX ignores the line break and all the + leading spaces on the following line. This allows you to + use indentation<a id="id2859574" class="indexterm" + name="id2859574"></a> to make your input file more + readable. \goodbreak</p> + + <p>For example, the following lines in your input + file:</p> +<pre class="screen"> +“This is some ex + ample text.” +</pre> + + <p>and this line:</p> +<pre class="screen"> +“This is some example text.” +</pre> + + <p>both produce:</p> + + <div class="literallayout"> + <p> + “This is some example text.”</p> + </div> + + <p>in your typeset document.</p> + </div> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h2 class="title" style="clear: both"><a id="id2859644" + name="id2859644"></a>Text Formatting Versus Word + Processing</h2> + </div> + </div> + + <p>For many people, writing documents with a computer + implies using a word processor like WordPerfect<a + id="id2859660" class="indexterm" name="id2859660"></a> or + Microsoft Word<a id="id2859674" class="indexterm" + name="id2859674"></a>.<a id="id2859683" class="indexterm" + name="id2859683"></a><a id="id2859696" class="indexterm" + name="id2859696"></a> The word processing program controls + every aspect of what you do: it's where you type your text, + where you see what it will look like, where you print, and + where you do everything else. Some of these environments, + the so-called WYSIWYG<a id="id2859715" class="indexterm" + name="id2859715"></a> (what-you-see-is-what-you-get) + programs, attempt to show you what the printed document + will actually look like <span + class="emphasis"><em>while</em></span> you edit it.<sup>[<a + id="id2859730" name="id2859730" + href="#ftn.id2859730">10</a>]</sup></p> + + <p>If WYSIWYG environments are what you're used to, or what + you expect, TeX's approach may seem very strange at first + because TeX is a <span class="emphasis"><em>text + formatter</em></span>,<a id="id2859754" class="indexterm" + name="id2859754"></a><a id="id2859767" class="indexterm" + name="id2859767"></a> not a word processor. Instead of + trying to show you what your document will look like while + you type, TeX expects you to do all the typing somewhere + else, and then pass it a source file containing all of your + text plus control sequences that tell TeX how you'd like it + printed.</p> + + <p>In <span class="emphasis"><em>The Psychology of Everyday + Things</em></span> [<a + href="bi01.html#dn:psyeveryday">dn:psyeveryday</a>], Donald + Norman<a id="id2859798" class="indexterm" + name="id2859798"></a> describes these two modes of + interaction as first person and third person. First person + interaction provides the user with the ability to directly + manipulate the elements of a task, whether it's flying an + airplane or resizing text. Third person interaction, on the + other hand, occurs where the user is expected to type + commands to the computer in an appropriate command + language; the shell prompt is a good example of third + person interaction.</p> + + <p>Is first person interaction really better? Well, it + depends. Norman writes, “Although they [WYSIWYG + environments] are often easy to use, fun, and entertaining, + it is often difficult to do a really good job with + them.” The problem which arises is that the user is + required to do the task, and he or she may not be very good + at it. Third person systems are better when the computer + program can be trusted to do a better job of the task than + the user.</p> + + <p>Is TeX really better than a word processor? Well, it + depends on the task and the person doing it. TeX probably + isn't better for designing one page flyers with lots of + fonts and graphics (although I've done it). But for longer + documents, TeX offers all of these advantages:</p> + + <div class="itemizedlist"> + <ul type="disc"> + <li> + <p>TeX has a precise understanding of the rules of + typesetting,<a id="id2859861" class="indexterm" + name="id2859861"></a> so you don't have to.</p> + </li> + + <li> + <p>Predefined styles allow experts to extend (or + bend) the rules of typesetting without burdening the + user.</p> + </li> + + <li> + <p>Journals and magazines can achieve consistency of + appearance much more reliably because the consistency + is in the style files.</p> + </li> + + <li> + <p>TeX runs on cheap systems (old PCs with monochrome + monitors and no graphics capability, for + example).</p> + </li> + + <li> + <p>Although complex and difficult to learn, TeX + offers incredibly flexible table construction + tools.</p> + </li> + + <li> + <p>Few, if any, word processors can provide running + headers and footers as flexibly as TeX. Imagine the + task of writing a dictionary: the left and right hand + side headers change on each page, each time a new + entry is added.</p> + </li> + + <li> + <p>TeX offers flexible bibliography layouts.</p> + </li> + + <li> + <p>TeX is extensible.<a id="id2859945" + class="indexterm" name="id2859945"></a> Its behavior + can be modified by defining new commands and + environments without changing the actual program.</p> + </li> + </ul> + </div> + + <p>There are some other good reasons to separate document + creation from text formatting:</p> + + <div class="itemizedlist"> + <ul type="disc"> + <li> + <p>Documents are portable.<a id="id2859978" + class="indexterm" name="id2859978"></a> Because the + source files are just plain text without any + nonprintable characters, they can easily be copied + from one system to another.</p> + </li> + + <li> + <p>TeX is portable. TeX runs everywhere. You can + process your documents with TeX on unix workstations; + personal computers running MS-DOS, OS/2, and Windows; + IBM mainframes running VM/CMS; workstations running + VAX/VMS; Macintoshes; Amigas; Ataris; and just about + every other computer with a reasonable amount of + memory. And the typeset output will be the same! This + adds another dimension of portability to your + documents.</p> + </li> + + <li> + <p>TeX is free. You can afford to have it on every + system you use. Several sources of TeX software are + listed in the preface of this book.</p> + </li> + + <li> + <p>TeX allows you to separate markup and output. + Logical divisions in the text (chapters, sections, + itemized lists, etc.) are identified by control + sequences. An entirely different page layout can + result from simply changing the definition of a few + control sequences.</p> + + <p>This means that the look of your documents can be + changed (to fit the style guidelines of a particular + journal or publisher, for example) without changing + the text of your documents at all.</p> + </li> + + <li> + <p>Plain text files are easier to manipulate with + other tools than specially encoded word processor + files are. This means that you can use standard + utilities on your documents: revision control, grep, + shell scripts, etc. This is a less common practice in + non-unix environments, but it is still + convenient.</p> + </li> + + <li> + <p>You can continue to use your favorite editing + tools. The extent to which you find this advantageous + is dependent, naturally, on the extent to which you + have a favorite editing program. Nevertheless, this + can be a considerable advantage. For example, users + familiar with <b>emacs</b><a id="id2860077" + class="indexterm" name="id2860077"></a> can continue + to rely on all of the features they are used to, + including interactive spellchecking, access to online + services like Webster's dictionary, customized editor + macros, and convenient services like reading + mail.</p> + </li> + + <li> + <p>You get better looking output. TeX gives you far + more precise control over the placement of elements + on the page than most word processing programs. And + TeX is very intelligent about typesetting (paragraph + breaking, kerning<a id="id2860098" class="indexterm" + name="id2860098"></a>, ligatures<a id="id2860112" + class="indexterm" name="id2860112"></a>, etc.).</p> + </li> + </ul> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="sec.howtexworks" + name="sec.howtexworks"></a>What About Desktop + Publishing?</h3> + </div> + </div> + + <p>Desktop publishing systems<a id="id2860137" + class="indexterm" name="id2860137"></a><a id="id2860150" + class="indexterm" name="id2860150"></a> like Ventura + Publisher<a id="id2860171" class="indexterm" + name="id2860171"></a> and Aldus PageMaker<a + id="id2860185" class="indexterm" name="id2860185"></a> + are noted for their ability to incorporate multiple fonts + and graphics into a document. As word processors become + more sophisticated, the line between word processing and + desktop publishing is becoming blurry.</p> + + <p>This book shows you many ways that TeX can provide + access to the same sophisticated features. TeX can + incorporate pictures and figures in a number of ways + (just take a look at the way I've wrapped text around + this kiwi),<sup>[<a id="id2860201" name="id2860201" + href="#ftn.id2860201">11</a>]</sup> and TeX can use + almost any font that another program can use---it can + certainly use <span class="emphasis"><em>all</em></span> + of the popular types of fonts. Like typical word + processors, desktop publishing programs force you to use + a single application to create your entire document, and + they lack the flexibility required to combine just the + pieces that you want. All of the advantages of text + formatting over word processing also apply to desktop + publishing programs. I'll grant, however, that WYSIWYG + environments are easier for first-time users. But that + doesn't make them better, it just makes them more + popular.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="id2860232" + name="id2860232"></a>What About troff?</h3> + </div> + </div> + + <p><b>troff</b><a id="id2860245" class="indexterm" + name="id2860245"></a> <a id="id2860259" class="indexterm" + name="id2860259"></a> is the “other” text + formatting system. If you've ever tried to read a unix + reference page without formatting it first, you've seen + <b>troff</b>. For a long time it was distributed as part + of all unix systems. Now it is more likely an extra-cost + option. The Free Software Foundation's <a id="id2860290" + class="indexterm" name="id2860290"></a><b>groff</b><a + id="id2860303" class="indexterm" name="id2860303"></a> + processor is a free, <b>troff</b>-compatible system.</p> + + <p>On the surface, it is easier to compare TeX and troff + than to compare TeX to the other document preparation + systems described in this chapter. In reality, the + differences are subtle: TeX and troff have the same + general paradigm; they are equally powerful to a large + extent, and both have advantages and disadvantages.</p> + + <p><b>troff</b> is similar to TeX in many ways. Like TeX, + troff processes a plain text file and produces a typeset + document. TeX and troff differ in the way that formatting + information is inserted into the text. TeX uses control + sequences<a id="id2860356" class="indexterm" + name="id2860356"></a>, where troff uses a mixture of + control sequences<sup>[<a id="id2860372" name="id2860372" + href="#ftn.id2860372">12</a>]</sup> and “dot” + commands (lines of text that begin with a period and + contain typesetting commands).</p> + + <p>Although I am inclined to say that troff documents are + far more cryptic than TeX documents, I am certain that + there are plenty of troff users who would disagree + (strongly).</p> + + <p>Objectively, TeX handles mathematical typesetting<a + id="id2860407" class="indexterm" name="id2860407"></a> + far better than troff and probably has better support for + multilingual documents<a id="id2860424" class="indexterm" + name="id2860424"></a><a id="id2860434" class="indexterm" + name="id2860434"></a>. The <b>nroff</b><a id="id2860451" + class="indexterm" name="id2860451"></a> processor, which + produces plain text output from a troff document, at one + time provided a strong argument in favor of troff for + typesetting documents required in both typeset and plain + text formats. However, the TeXinfo<a id="id2860469" + class="indexterm" name="id2860469"></a> macro package for + TeX has largely defeated that argument. In troff's + defense, TeXinfo is very, very different from other TeX + macro packages, so it really is necessary to plan ahead + and learn a very different set of macros to typeset both + plain text and typeset documents with TeXinfo. + Chapter <a href="ch10.html" + title="Chapter 10. Online Documentation">Chapter 10</a>, + <span class="emphasis"><em><a href="ch10.html" + title="Chapter 10. Online Documentation">Chapter 10</a></em></span>, + discusses this issue further.</p> + + <p>In my experience, there is more free support for TeX + than troff. TeX is supported by a large community of + users actively producing new, useful document-preparation + formats, styles, and tools. In addition, TeX is more + widely available than troff: a TeX port exists for almost + every practical computer system, whereas troff is still + mostly confined to unix systems (although the Free + Software Foundation's <b>groff</b> package has been + ported to similar systems like MS-DOS, Windows NT, and + OS/2).</p> + + <p>The following fragments show a side-by-side comparison + of TeX commands, on the left, and troff commands, on the + right:</p> +<pre class="screen"> +\begin{figure} .(z + \begin{center} .hl + \hrule Text to be floated. + \vspace{8pt} .sp + Text to be floated. .ce + \hrule .hl + \caption{Example figure...} Figure \*[fig]: Example figure... + \vspace{8pt} .)z + \end{center} +\end{figure} +</pre> + + <p>Both examples produce a floating figure that looks + like this:</p> + + <div class="figure"> + <a id="id2860574" name="id2860574"></a> + + <p class="title"><b>Figure 1.2. Example + figure produced by both TeX and troff</b></p> + + <div class="informaltable"> + <table width="100%" border="1"> + <colgroup> + <col /> + </colgroup> + + <tbody> + <tr> + <td>Text to be floated.</td> + </tr> + </tbody> + </table> + </div> + </div> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="id2860619" + name="id2860619"></a>What About SGML?</h3> + </div> + </div> + + <p>The Standard Generalized Markup Language (SGML)<a + id="id2860629" class="indexterm" name="id2860629"></a> is + a document description language. SGML aims to separate + the content of a document from its presentation. In other + words, SGML identifies the features of a document + (chapter headings, paragraphs, etc.) without specifying + how they are to be presented.</p> + + <p>This means that all SGML documents must interact with + a document formatter of some sort. Many people are + finding that TeX is a natural choice when selecting a + document formatter for their SGML environment. In fact, + LaTeX<a id="id2860647" class="indexterm" + name="id2860647"></a> already provides many SGML-like + commands because it was designed to separate markup from + presentation. One of the specific goals of an effort + (currently underway) to develop a new version of LaTeX is + to make SGML and LaTeX work together easily, cleanly, and + efficiently. For more information about the goals of this + project and information about what you can do to help, + please read <span class="emphasis"><em>The LaTeX3 + Project</em></span> [<a + href="bi01.html#l3:project">l3:project</a>].</p> + </div> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h2 class="title" style="clear: both"><a id="id2860690" + name="id2860690"></a>How TeX Works</h2> + </div> + </div> + + <p>A functioning TeX system<a id="id2860698" + class="indexterm" name="id2860698"></a> in which you are + producing documents of medium size and complexity is really + a collection of tools and files that are related to each + other in well defined (if somewhat subtle) ways.</p> + + <p>One of the fundamental goals of this book is to shed + light on these relationships and allow you to put together + a TeX system that quickly and easily does the jobs you need + to accomplish.</p> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="subsubsec.runningtex" + name="subsubsec.runningtex"></a>TeXing a Simple + Document</h3> + </div> + </div> + + <p>This section briefly describes what you need to know + about how TeX processes a simple document (that is, one + that does not contain complex document elements like a + table of contents, indexes, bibliographies, etc.). + Figure <a href="ch01.html#fig.wholesimple" + title="Figure 1.3. A high-level view of TeX">Figure 1.3</a> + shows how the standard TeX tools fit together at the most + basic level.</p> + + <div class="figure"> + <a id="fig.wholesimple" name="fig.wholesimple"></a> + + <p class="title"><b>Figure 1.3. A high-level + view of TeX</b></p> + + <div class="mediaobject"> + <img src="figures/tex.01.03.png" /> + </div> + </div> + + <p>Figure <a href="ch01.html#fig.wholething" + title="Figure 1.4. High-level view of TeX including more detail"> + Figure 1.4</a> expands on Figure <a + href="ch01.html#fig.wholesimple" + title="Figure 1.3. A high-level view of TeX">Figure 1.3</a>, + showing additional tools and files that you'll often need + to use.</p> + + <div class="figure"> + <a id="fig.wholething" name="fig.wholething"></a> + + <p class="title"><b>Figure 1.4. High-level + view of TeX including more detail</b></p> + + <div class="mediaobject"> + <img src="figures/tex.01.04.png" /> + </div> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h4 class="title"><a id="id2860862" + name="id2860862"></a>Editing your document</h4> + </div> + </div> + + <p>The most tangible and important part of your TeX + system is your document<a id="id2860872" + class="indexterm" name="id2860872"></a>. This is the + file (or files) in which you write down what you want + to typeset with TeX. In addition to the actual text, + you include control sequences to describe how you want + the final text to appear (size, font, justification, + etc.). The section “<a + href="ch01.html#sec.texforbeginners" + title="What Is TeX?">the section called “What Is + TeX?”</a>” earlier in this chapter tells + you briefly what goes into your document file.</p> + + <p>The most common way to create a document is with an + editor<a id="id2860909" class="indexterm" + name="id2860909"></a><a id="id2860916" + class="indexterm" name="id2860916"></a><a + id="id2860926" class="indexterm" name="id2860926"></a>, + which can provide you with a number of features to make + typing TeX documents easier. For example, an editor can + help you insert common control sequences<a + id="id2860940" class="indexterm" name="id2860940"></a> + automatically, run TeX automatically (from within the + editor), and keep you from making common mistakes (like + typing a left brace, but not the matching right one). + These features and how they work in editors including + GNU Emacs, aucTeX, and Multi-Edit are described in + Chapter <a href="ch02.html" + title="Chapter 2. Editing">Chapter 2</a>, + <span class="emphasis"><em><a href="ch02.html" + title="Chapter 2. Editing">Chapter 2</a></em></span>.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h4 class="title"><a id="id2860982" + name="id2860982"></a>Running TeX</h4> + </div> + </div> + + <p>Once you have prepared your document file, it is + time to run<a id="id2860991" class="indexterm" + name="id2860991"></a><a id="id2861001" + class="indexterm" name="id2861001"></a> the TeX program + itself. This may not be as easy as it sounds. You need + to determine the name of the TeX program at your site, + to make sure all of the files TeX needs are available + to it; you also need to specify the correct + command-line options. Chapter <a href="ch03.html" + title="Chapter 3. Running TeX">Chapter 3</a>, + <span class="emphasis"><em><a href="ch03.html" + title="Chapter 3. Running TeX">Chapter 3</a></em></span>, + describes everything you need to know.</p> + + <p>TeX may find errors in your document (places where + TeX doesn't understand the instructions you used; not + spelling or grammatical errors, unfortunately ;-). + Chapter <a href="ch03.html" + title="Chapter 3. Running TeX">Chapter 3</a> + also describes the most common errors you're likely to + make and gives advice for interpreting error + messages.</p> + + <p>If TeX is successful in formatting your document + (i.e., your document doesn't contain any errors), it + produces a <tt>DVI</tt> (DeVice Independent)<a + id="id2861075" class="indexterm" name="id2861075"></a> + file. The <tt>DVI</tt> file is a device-independent + representation of the typeset output of your document. + <tt>DVI</tt> files are transitory. Although there are a + few programs that can manipulate them (to rearrange the + order of the pages in the output, for example), most of + the time you will immediately transform them into + something else---either printed output or previewed + output on the screen. (See the following section + “<a href="ch01.html#subsubsec.printpreview" + title="Using macros">the section called “Using + macros”</a>.”)</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h4 class="title"><a id="subsubsec.printpreview" + name="subsubsec.printpreview"></a>Using macros</h4> + </div> + </div> + + <p>The control sequences<a id="id2861139" + class="indexterm" name="id2861139"></a> that you insert + in your document are defined by a macro package<a + id="id2861152" class="indexterm" + name="id2861152"></a>.<sup>[<a id="id2861160" + name="id2861160" href="#ftn.id2861160">13</a>]</sup> + Macro packages are collections of TeX commands (macros) + that extend TeX. Macro packages are frequently stored + in format files, specially compiled versions of the + macro package. The iniTeX<a id="id2861169" + class="indexterm" name="id2861169"></a> program + interprets all of the control sequences in a macro + package to create a format file that TeX reads when it + runs.</p> + + <p>Many macro packages are particularly effective in + implementing particular document styles or supporting + particular types of writing. Two of the most common are + Plain TeX<a id="id2861194" class="indexterm" + name="id2861194"></a> and LaTeX<a id="id2861205" + class="indexterm" name="id2861205"></a>. + Chapter <a href="ch04.html" + title="Chapter 4. Macro Packages">Chapter 4</a>, + <span class="emphasis"><em><a href="ch04.html" + title="Chapter 4. Macro Packages">Chapter 4</a></em></span>, + describes Plain TeX, LaTeX, and a number of other macro + packages that extend the power and ease of TeX.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h4 class="title"><a id="id2861241" + name="id2861241"></a>Using fonts</h4> + </div> + </div> + + <p>One of TeX's strengths is its support for a myriad + of predefined fonts<a id="id2861249" class="indexterm" + name="id2861249"></a> and its ability to let you create + fonts of your own. In addition to your document and the + format file, when TeX runs it needs font information as + well. This is provided in the form of a set of + <tt>TFM</tt> (TeX Font Metric)<a id="id2861277" + class="indexterm" name="id2861277"></a> files that tell + TeX the size and shape (roughly speaking, at least) of + each character, as well as some other information about + how characters are related to each other.</p> + + <p>Historically, the MetaFont<a id="id2861292" + class="indexterm" name="id2861292"></a> program was the + way a TeX user created fonts. Like TeX itself, MetaFont + is about ten years old. Ten years ago, it was a unique + program that was indispensible for creating the type of + output TeX produces. Today there are many competing + font technologies, all of them more common than + MetaFont, and MetaFont's role is diminishing. Many + people use TeX today without ever using MetaFont at + all. Nevertheless, MetaFont still has some importance, + and we describe how to run and use it in + Chapter <a href="ch11.html" + title="Chapter 11. Introducing MetaFont">Chapter 11</a>, + <span class="emphasis"><em><a href="ch11.html" + title="Chapter 11. Introducing MetaFont">Chapter 11</a></em></span>. + Because the standard fonts that come with TeX are still + the fonts produced by MetaFont, it will also be + mentioned elsewhere in this book.</p> + + <p>If you are writing complex documents, you may need + to learn a lot about fonts and how to define and use + them. Chapter <a href="ch05.html" + title="Chapter 5. Fonts">Chapter 5</a>, + <span class="emphasis"><em><a href="ch05.html" + title="Chapter 5. Fonts">Chapter 5</a></em></span>, + tells you everything you need to know, including + information about the New Font Selection Scheme, a new + way of describing and selecting fonts in TeX.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h4 class="title"><a id="id2861369" + name="id2861369"></a>Previewing or printing TeX + documents</h4> + </div> + </div> + + <p>After you have produced a <tt>DVI</tt> file, as + described in the section “<a + href="ch01.html#subsubsec.runningtex" + title="TeXing a Simple Document">the section called + “TeXing a Simple Document”</a>,” + later in this chapter, you run another program + (generically called a DVI driver)<a id="id2861405" + class="indexterm" name="id2861405"></a> to translate + the <tt>DVI</tt> file so you can either preview or + print your document. Driver programs need your + <tt>DVI</tt> file and some collection of fonts (usually + <tt>PK</tt> (packed)<a id="id2861442" class="indexterm" + name="id2861442"></a><a id="id2861461" + class="indexterm" name="id2861461"></a><a + id="id2861469" class="indexterm" name="id2861469"></a> + font files).<sup>[<a id="id2861489" name="id2861489" + href="#ftn.id2861489">14</a>]</sup> Many different + kinds of fonts are described in Chapter <a + href="ch05.html" + title="Chapter 5. Fonts">Chapter 5</a>.</p> + + <p>Chapter <a href="ch08.html" + title="Chapter 8. Printing">Chapter 8</a>, + <span class="emphasis"><em><a href="ch08.html" + title="Chapter 8. Printing">Chapter 8</a></em></span>, + tells you how to print<a id="id2861540" + class="indexterm" name="id2861540"></a><a + id="id2861546" class="indexterm" name="id2861546"></a> + your documents and deal with the problems you may + encounter using bitmapped or scalable fonts, printing + pictures and figures, and other printing issues.</p> + + <p>Often you will want to look at your document before + you actually print it. Because TeX is not a WYSIWYG + system,<sup>[<a id="id2861567" name="id2861567" + href="#ftn.id2861567">15</a>]</sup> you cannot do this + until you have processed the <tt>DVI</tt> file. There + are a number of good previewing products<a + id="id2861597" class="indexterm" + name="id2861597"></a><a id="id2861603" + class="indexterm" name="id2861603"></a>, including + xdvi<a id="id2861617" class="indexterm" + name="id2861617"></a>, <b>dvimswin</b><a id="id2861634" + class="indexterm" name="id2861634"></a>, and + <b>dviscr</b><a id="id2861648" class="indexterm" + name="id2861648"></a>, that let you look at your + processed document on the screen before you decide + whether to print it. See Chapter <a + href="ch09.html" + title="Chapter 9. Previewing">Chapter 9</a>, + <span class="emphasis"><em><a href="ch09.html" + title="Chapter 9. Previewing">Chapter 9</a></em></span>, + for complete information.</p> + </div> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="id2861683" + name="id2861683"></a>TeXing More Complex + Documents</h3> + </div> + </div> + + <p>This section briefly describes how TeX processes a + more complex document (that is, one that includes + elements like a table of contents, indexes, + bibliographies, etc.).</p> + + <p>Many TeX formats implement sophisticated + cross-referencing schemes. Cross references<a + id="id2861700" class="indexterm" name="id2861700"></a> + may sound rather esoteric, but they occur frequently. + Tables of contents, figure and table numbers, indexes, + and bibliographic references are all flavors of cross + referencing.</p> + + <p>Cross references make your document more complex + because they require more information than is immediately + available when TeX initially processes your document. For + example, if you refer to a figure which occurs later in + the document, TeX has no way of knowing what figure + number to insert into the text at the point of the + reference. These are called <span + class="emphasis"><em>forward references</em></span><a + id="id2861726" class="indexterm" + name="id2861726"></a>.</p> + + <p>TeX macro packages that support cross referencing + overcome the difficulty of forward references by + requiring you to process your document more than once. + Each time your document is processed, the necessary + reference information is stored into a separate file. If + that file exists when you process your document, the + information saved <span class="emphasis"><em>last + time</em></span> is loaded so that it is available <span + class="emphasis"><em>this time</em></span>. The practical + implication of this functionality is that documents with + cross references frequently have to be processed twice. + Occasionally, you may have to process a document three + times. This occurs when the inserted reference causes TeX + to format a paragraph differently, which in turn causes + TeX to change a page break.<sup>[<a id="id2861760" + name="id2861760" href="#ftn.id2861760">16</a>]</sup> + Because most changes are incremental while revising a + document, this is normally only an issue the first time + you process a document.</p> + + <p>The following sections describe the LaTeX methods for + constructing a table of contents, figure references, an + index, and a bibliography. LaTeX is used in this example + because it is a very common macro package and is typical + of the way macro packages provide these features. Similar + mechanisms exist in most formats, except Plain TeX.</p> + + <p>Figure <a href="ch01.html#fig.texcmplx" + title="Figure 1.5. TeXing a More Complex Document"> + Figure 1.5</a> shows the relationships between many + of the components described in the following sections. + LaTeX creates several sorts of auxiliary files depending + on the kind of cross references required by your document + and the style files you use. These auxiliary files may be + modified (and others may be created) by other sorts of + post-processing programs (like <b>MakeIndex</b><a + id="id2861811" class="indexterm" name="id2861811"></a> + for constructing indexes or BibTeX<a id="id2861819" + class="indexterm" name="id2861819"></a> for constructing + bibliographies). LaTeX uses these auxiliary files, if + they exist, to update your document when it is processed + again.</p> + + <div class="figure"> + <a id="fig.texcmplx" name="fig.texcmplx"></a> + + <p class="title"><b>Figure 1.5. TeXing a More + Complex Document</b></p> + + <div class="mediaobject"> + <img src="figures/tex.01.05.png" /> + </div> + </div> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="id2861875" + name="id2861875"></a>Building a Table of + Contents</h3> + </div> + </div> + + <p>A table of contents<a id="id2861885" class="indexterm" + name="id2861885"></a> is the simplest form of cross + reference. In LaTeX, you request a table of contents by + inserting the \tableofcontents command wherever you want + it to appear in your document. If you request the table + of contents at the end of your document rather than the + beginning, your document can be printed with only one + pass through TeX.</p> + + <p>LaTeX uses a file with the same name as your document + and the extension <tt>.toc</tt> to hold the table of + contents entries. You can control the level of detail in + your table of contents by setting the \secnumdepth + counter. A value of zero includes only chapters; one + includes chapters and sections; two includes chapters, + sections, and subsections, and so on.</p> + + <p>The LaTeX commands \listoftables and \listoffigures + perform the same functions as \tableofcontents for lists + of tables and figures. They use external files with the + extensions <tt>.lot</tt><a id="id2861950" + class="indexterm" name="id2861950"></a> and + <tt>.lof</tt><a id="id2861966" class="indexterm" + name="id2861966"></a>, respectively. As with the table of + contents, your document can be correctly formatted in one + pass if the \listoftables and \listoffigures commands are + placed at the end of the document.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="id2861991" + name="id2861991"></a>Figure References</h3> + </div> + </div> + + <p>Figure references<a id="id2862000" class="indexterm" + name="id2862000"></a> are a special case of LaTeX's cross + referencing mechanism. The LaTeX command + \label{<i><tt>string</tt></i>} creates a referent. You + refer to the label with the command + \ref{<i><tt>string</tt></i>}. In normal body text, the + label refers to the current section or subsection. In a + figure or table environment, the label refers to that + figure or table.</p> + + <p>If your document contains no forward references<a + id="id2862038" class="indexterm" name="id2862038"></a> + (if all \label commands occur before the \ref's that + refer to them) then it can be formatted in one pass. + Otherwise, TeX will have to be run two or three times to + make all of the references correct.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="id2862061" + name="id2862061"></a>Indexes and Glossaries</h3> + </div> + </div> + + <p>Indexes<a id="id2862070" class="indexterm" + name="id2862070"></a> and glossaries<a id="id2862079" + class="indexterm" name="id2862079"></a> differ from the + preceding forms of reference in that they must be + processed by a separate program. In general, this is true + regardless of the macro package or format you use. An + external program is required because indexes and + glossaries must be alphabetized, and in indexes, + consecutive page numbers have to be converted into + ranges, and so on.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="id2862096" + name="id2862096"></a>Bibliographies</h3> + </div> + </div> + + <p>LaTeX works in conjunction with another program, + called BibTeX<a id="id2862105" class="indexterm" + name="id2862105"></a>, to provide a flexible, convenient + way to construct bibliographies<a id="id2862119" + class="indexterm" name="id2862119"></a>. The \cite + commands allows you to refer to other documents in much + the same way that the \ref command allows you to refer to + other portions of the same document.</p> + + <p>You make a citation by placing the command + \cite{<i><tt>string</tt></i>} where you wish the citation + to occur. The <span + class="emphasis"><em>string</em></span> is a key that + refers to the document in your bibliography database that + you wish to cite. Example <a + href="ch01.html#ex.knuthbbl" + title="Example 1.2. A typical bibliography database entry"> + Example 1.2</a> is a typical entry in a bibliography + database. It describes Knuth's<a id="id2862157" + class="indexterm" name="id2862157"></a> classic book + <span class="emphasis"><em>The + TeXbook</em></span> [<a + href="bi01.html#kn:texbook">kn:texbook</a>]. The key for + this entry is “kn:texbook.”</p> + + <div class="example"> + <a id="ex.knuthbbl" name="ex.knuthbbl"></a> + + <p class="title"><b>Example 1.2. A typical + bibliography database entry</b></p> +<pre class="screen"> +@Book{kn:texbook, + author = "Donald E. Knuth", + title = "The {TeX}book", + publisher = "Addison-Wesley", + year = 1989, + edition = "Fifteenth", + isbn = "0-201-13447-0" + note = "Paperback ISBN: 0-201-13448-9" +} +</pre> + </div> + + <p>Each entry in the database consists of a type (book, + article, magazine, etc.), a key, and a number of fields. + The number and names of the fields depend on the type of + entry. The database is simply a plain ASCII file + containing any number of entries. You can have multiple + databases.</p> + + <p>These are the commands you use, in addition to \cite, + to include a bibliography in your document:</p> +<pre class="screen"> +\bibliographystyle{plain} +\bibliography{textools,refbooks} +</pre> + + <p>The \bibliographystyle command tells BibTeX how to + format the bibliography, and the \bibliography command + identifies which bibliographic databases contain the + citations that you have made. The “plain” + style of bibliography is selected, and the + <tt>textools</tt> and <tt>refbooks</tt> files contain the + bibliographic information for the documents cited. + Document styles can be used to alter the format of + citations in your text. The default extension for + bibliographic styles is <tt>.bst</tt><a id="id2862291" + class="indexterm" name="id2862291"></a>. The default + extension for database files is <tt>.bib</tt><a + id="id2862308" class="indexterm" + name="id2862308"></a>.</p> + + <p>LaTeX places citations and bibliography information + into the <tt>.aux</tt> file<a id="id2862331" + class="indexterm" name="id2862331"></a>. BibTeX reads the + <tt>.aux</tt><a id="id2862348" class="indexterm" + name="id2862348"></a> file and constructs a bibliography, + which it places into a file with the extension + <tt>.bbl</tt><a id="id2862366" class="indexterm" + name="id2862366"></a>, using the entries you cited and + the bibliography style you selected.</p> + </div> + + <div class="section"> + <div class="titlepage"> + <div> + <h3 class="title"><a id="id2862381" + name="id2862381"></a>Special Things</h3> + </div> + </div> + + <p>Sometimes, producing a complex document requires the + ability to interface with objects outside of TeX + (pictures or figures created by high-end graphics + packages, special features of a particular printer, + etc.). To support this kind of communication, TeX + provides a control sequence called \special. The + arguments passed to the \special command are written + directly to the <tt>DVI</tt> file for the DVI driver. It + is the responsibility of the DVI driver to handle them. + DVI drivers typically ignore \special commands that they + do not recognize.</p> + + <p>You will find \special commands of various kinds + described throughout this book, particularly when + discussing color typesetting in Chapter <a + href="ch04.html" + title="Chapter 4. Macro Packages">Chapter 4</a>, + <span class="emphasis"><em><a href="ch04.html" + title="Chapter 4. Macro Packages">Chapter 4</a></em></span>, + and graphics in Chapter <a href="ch06.html" + title="Chapter 6. Pictures and Figures">Chapter 6</a>, + <span class="emphasis"><em><a href="ch06.html" + title="Chapter 6. Pictures and Figures">Chapter 6</a></em></span>.</p> + </div> + </div> + + <div class="footnotes"> + <br /> + <hr width="100" align="left" /> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2856038" name="ftn.id2856038" + href="#id2856038">1</a>]</sup> Before I proceed, the + notion of beautiful in this context needs some + explanation. Several people have pointed out that the + logo type used by many TeX-related programs (including + TeX itself) is intrinsically ugly. These same folks argue + that a sentence like “TeX is designed to typeset + beautiful pages” is self-contradictory because it + begins with such an ugly construction. Obviously, TeX + can't <span class="emphasis"><em>prevent</em></span> you + from typesetting ugly things. But TeX can typeset + beautiful things too. We at O'Reilly & Associates + think that this book, typeset completely in TeX, is an + excellent example.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2857595" name="ftn.id2857595" + href="#id2857595">2</a>]</sup> This is not a whole-truth. + Implementors of TeX may make some system-dependent + alterations as long as the resulting program still passes + the test suite; so our TeXs may not behave <span + class="emphasis"><em>exactly</em></span> the same way. + They will, however, produce identical documents given + identical input (unless the input relies on + system-dependent features not available in both TeXs, + naturally. ;-)</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2857956" name="ftn.id2857956" + href="#id2857956">3</a>]</sup> This is subtly different + from saying that they are joined at the baseline. There + are TeX commands which can change the position of the + reference point in a box, whereas the baseline is an + imaginary line that depends solely on the shape of the + character.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2858135" name="ftn.id2858135" + href="#id2858135">4</a>]</sup> Technically, it's any + character defined to be in the “escape” + category followed by any sequence of characters defined + to be in the “letter” category or a single + character in the “other” category.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2858243" name="ftn.id2858243" + href="#id2858243">5</a>]</sup> Actually, macro expansion + differs from pure textual replacement in a number of + technical ways, but they aren't important here.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2858415" name="ftn.id2858415" + href="#id2858415">6</a>]</sup> Technically, several other + kinds of values are stored this way as well, but they are + less common and won't be discussed in this book at + all.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2858485" name="ftn.id2858485" + href="#id2858485">7</a>]</sup> Most control sequences can + be redefined to hold different kinds of values, but they + can never hold different kinds of values at the same + time. A dimension register can be redefined to hold + tokens, for example, but then it can't hold dimensions + anymore (unless it is redefined again).</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2858627" name="ftn.id2858627" + href="#id2858627">8</a>]</sup> Plain TeX is the name of a + particular macro package. I selected it for the purpose + of example in this chapter because it is always installed + with TeX. Most of what follows in this chapter is true in + other macro packages as well, but some of the details are + different. See Chapter <a href="ch04.html" + title="Chapter 4. Macro Packages">Chapter 4</a> + for more information.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2858704" name="ftn.id2858704" + href="#id2858704">9</a>]</sup> All of these special + characters are configurable, but most macro packages use + the Plain TeX defaults.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2859730" name="ftn.id2859730" + href="#id2859730">10</a>]</sup> TeX pundits, and other + folks who have been frustrated by the limitations of + these environments, frequently refer to this as + WYSIAYG—what you see is <span + class="emphasis"><em>all</em></span> you get.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2860201" name="ftn.id2860201" + href="#id2860201">11</a>]</sup> TeX doesn't do this sort + of thing automatically, but it isn't hard to do. Why the + kiwi? It was on my business card at the time.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2860372" name="ftn.id2860372" + href="#id2860372">12</a>]</sup> Although it has a very + different notion of what constitutes a control + sequence.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2861160" name="ftn.id2861160" + href="#id2861160">13</a>]</sup> Well, actually, they're + TeX primitives, are defined by a macro package, defined + in a file loaded by a macro package, or defined in your + document.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2861489" name="ftn.id2861489" + href="#id2861489">14</a>]</sup> Some drivers may also + benefit from loading the <tt>TFM</tt> files used to + create your document.</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2861567" name="ftn.id2861567" + href="#id2861567">15</a>]</sup> Textures for the Mac and + <b>Scientific Word</b> offer WYSIWYG-like environments, + but that's not the point ;-)</p> + </div> + + <div class="footnote"> + <p><sup>[<a id="ftn.id2861760" name="ftn.id2861760" + href="#id2861760">16</a>]</sup> With extreme cleverness + or extreme bad luck you can create a document which will + <span class="emphasis"><em>never</em></span> format + correctly.</p> + </div> + </div> + </div> + + <div class="navfooter"> + <table width="100%" summary="Navigation table"> + <tr> + <td width="40%" align="left"><a + title="Part I. An Introduction to TeX" + href="pt01.html"><img src="figures/nav-prev.png" + alt="Prev" border="0" /></a> </td> + + <td width="20%" align="center"><a title="Making TeX Work" + href="index.html"><img src="figures/nav-home.png" + alt="Home" border="0" /></a></td> + + <td width="40%" align="right"> <a + title="Chapter 2. Editing" + href="ch02.html"><img src="figures/nav-next.png" + alt="Next" border="0" /></a></td> + </tr> + + <tr> + <td width="40%" align="left">Part I. An + Introduction to TeX </td> + + <td width="20%" align="center"><a + title="Part I. An Introduction to TeX" + href="pt01.html"><img src="figures/nav-up.png" alt="Up" + border="0" /></a></td> + + <td width="40%" align="right"> +  Chapter 2. Editing</td> + </tr> + </table> + </div> + </body> +</html> + |