summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/make-tex-work/html/ch01.html
blob: 0a685eef90530ffbf2944d039560862d5b360785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
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&#160;1.&#160;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&#160;I.&#160;An Introduction to TeX" />
    <link rel="previous" href="pt01.html"
    title="Part&#160;I.&#160;An Introduction to TeX" />
    <link rel="next" href="ch02.html"
    title="Chapter&#160;2.&#160;Editing" />
  </head>

  <body>
    <div class="navheader">
      <table border="0" cellpadding="0" cellspacing="0"
      width="100%" summary="Navigation table">
        <tr>
          <td align="left">&#160;<a title="Making TeX Work"
          href="index.html"><img src="figures/nav-home.png"
          alt="Home" border="0" /></a>&#160;<a
          title="Part&#160;I.&#160;An Introduction to TeX"
          href="pt01.html"><img src="figures/nav-prev.png"
          alt="Prev" border="0" /></a>&#160;<a
          title="Part&#160;I.&#160;An Introduction to TeX"
          href="pt01.html"><img src="figures/nav-up.png" alt="Up"
          border="0" /></a>&#160;<a
          title="Chapter&#160;2.&#160;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&#160;1.&#160;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
        &#8220;beautiful,&#8221; 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
        &#8220;TeX,&#8221; 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 &#8220;g,&#8221; 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&#160;<a href="ch01.html#fig.charbox"
          title="Figure&#160;1.1.&#160;The Letters g and h inside their boxes.">
          Figure&#160;1.1</a> shows the character boxes formed by
          the Computer Modern<a id="id2857800" class="indexterm"
          name="id2857800"></a> Roman letters &#8220;g&#8221; and
          &#8220;h.&#8221; 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 &#8220;g&#8221;).</p>

          <div class="figure">
            <a id="fig.charbox" name="fig.charbox"></a>

            <p class="title"><b>Figure&#160;1.1.&#160;The Letters
            &#8220;g&#8221; and &#8220;h&#8221; 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 &#8220;glues&#8221;<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&#160;1.1.&#160;An Example of a TeX Document">
          Example&#160;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
          &#8220;word&#8221; that you put in your document. These
          extra words are instructions for TeX, and they do not
          usually appear in your typeset document. Example&#160;<a
          href="ch01.html#ex.csexample"
          title="Example&#160;1.1.&#160;An Example of a TeX Document">
          Example&#160;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&#160;1.1.&#160;An Example
            of a TeX Document</b></p>
<pre class="screen">
\def\ora{O'Reilly \&amp; 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&#160;1.1.&#160;An Example of a TeX Document">
                Example&#160;1.1</a>, the macro control sequence
                \ora is defined as a shortcut for typing
                &#8220;O'Reilly &amp; Associates.&#8221; 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&#160;1.1.&#160;An Example of a TeX Document">
                Example&#160;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&#160;<a href="ch05.html"
                title="Chapter&#160;5.&#160;Fonts">Chapter&#160;5</a>,
                <span class="emphasis"><em><a href="ch05.html"
                title="Chapter&#160;5.&#160;Fonts">Chapter&#160;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 &#8220;count&#8221;
                values because they are simple counting numbers
                like 1, 2, 17, or -5), dimensions (also called
                &#8220;lengths&#8221;; 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&#160;<a href="ch01.html#ex.csexample"
                title="Example&#160;1.1.&#160;An Example of a TeX Document">
                Example&#160;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 &#8220;primitive&#8221;
                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&#160;1.1.&#160;An Example of a TeX Document">
                Example&#160;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&#160;<a
          href="ch04.html"
          title="Chapter&#160;4.&#160;Macro Packages">Chapter&#160;4</a>,
          <span class="emphasis"><em><a href="ch04.html"
          title="Chapter&#160;4.&#160;Macro Packages">Chapter&#160;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&#160;<a href="ch01.html#tab.activechars"
          title="Table&#160;1.1.&#160;Special Characters in Plain TeX ">
          Table&#160;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&#160;<a href="ch05.html"
          title="Chapter&#160;5.&#160;Fonts">Chapter&#160;5</a>,
          <span class="emphasis"><em><a href="ch05.html"
          title="Chapter&#160;5.&#160;Fonts">Chapter&#160;5</a></em></span>.</p>

          <div class="table">
            <a id="tab.activechars" name="tab.activechars"></a>

            <p class="title"><b>Table&#160;1.1.&#160;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">&amp;</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 (&#8212;)
                  (font-specific)</td>
                </tr>

                <tr>
                  <td align="center">&lt;</td>

                  <td>Produces an upside down exclamation mark (¡)
                  (font-specific)</td>
                </tr>

                <tr>
                  <td align="center">&gt;</td>

                  <td>Produces an upside down question mark (¿)
                  (font-specific)</td>
                </tr>

                <tr>
                  <td align="center">"</td>

                  <td>Incorrect for quoted text; use &#8220; and
                  &#8221; 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&#160;1.2.&#160;How to Typeset Special Characters">
          Table&#160;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 &#8220;out of
          the box.&#8221; Chapter&#160;<a href="ch07.html"
          title="Chapter&#160;7.&#160;International Considerations">
          Chapter&#160;7</a>, <span class="emphasis"><em><a
          href="ch07.html"
          title="Chapter&#160;7.&#160;International Considerations">
          Chapter&#160;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&#160;1.2.&#160;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">&amp;</td>

                  <td>\&amp;</td>
                </tr>

                <tr>
                  <td align="center">&#8220;</td>

                  <td>``</td>
                </tr>

                <tr>
                  <td align="center">&#8221;</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">&lt;</td>

                  <td>$&lt;$</td>
                </tr>

                <tr>
                  <td align="center">&gt;</td>

                  <td>$&gt;$</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&#160;1.2.&#160;How to Typeset Special Characters">
            Table&#160;1.2</a> will not always produce exactly what
            you want. The entry for &#8220;~&#8221; really produces
            a tilde accent, not a tilde character and the entries
            for &#8220;{&#8221; through &#8220;\&#8221; 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> &#8220;{&#8221; and &#8220;}&#8221;
          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">
&#8220;This                      is some ex
      ample text.&#8221;
</pre>

          <p>and this line:</p>
<pre class="screen">
&#8220;This is some example text.&#8221;
</pre>

          <p>both produce:</p>

          <div class="literallayout">
            <p>
            &#8220;This&#160;is&#160;some&#160;example&#160;text.&#8221;</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>&#160;[<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, &#8220;Although they [WYSIWYG
        environments] are often easy to use, fun, and entertaining,
        it is often difficult to do a really good job with
        them.&#8221; 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 &#8220;other&#8221; 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 &#8220;dot&#8221;
          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&#160;<a href="ch10.html"
          title="Chapter&#160;10.&#160;Online Documentation">Chapter&#160;10</a>,
          <span class="emphasis"><em><a href="ch10.html"
          title="Chapter&#160;10.&#160;Online Documentation">Chapter&#160;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&#160;1.2.&#160;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>&#160;[<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&#160;<a href="ch01.html#fig.wholesimple"
          title="Figure&#160;1.3.&#160;A high-level view of TeX">Figure&#160;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&#160;1.3.&#160;A high-level
            view of TeX</b></p>

            <div class="mediaobject">
              <img src="figures/tex.01.03.png" />
            </div>
          </div>

          <p>Figure&#160;<a href="ch01.html#fig.wholething"
          title="Figure&#160;1.4.&#160;High-level view of TeX including more detail">
          Figure&#160;1.4</a> expands on Figure&#160;<a
          href="ch01.html#fig.wholesimple"
          title="Figure&#160;1.3.&#160;A high-level view of TeX">Figure&#160;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&#160;1.4.&#160;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 &#8220;<a
            href="ch01.html#sec.texforbeginners"
            title="What Is TeX?">the section called &#8220;What Is
            TeX?&#8221;</a>&#8221; 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&#160;<a href="ch02.html"
            title="Chapter&#160;2.&#160;Editing">Chapter&#160;2</a>,
            <span class="emphasis"><em><a href="ch02.html"
            title="Chapter&#160;2.&#160;Editing">Chapter&#160;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&#160;<a href="ch03.html"
            title="Chapter&#160;3.&#160;Running TeX">Chapter&#160;3</a>,
            <span class="emphasis"><em><a href="ch03.html"
            title="Chapter&#160;3.&#160;Running TeX">Chapter&#160;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&#160;<a href="ch03.html"
            title="Chapter&#160;3.&#160;Running TeX">Chapter&#160;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
            &#8220;<a href="ch01.html#subsubsec.printpreview"
            title="Using macros">the section called &#8220;Using
            macros&#8221;</a>.&#8221;)</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&#160;<a href="ch04.html"
            title="Chapter&#160;4.&#160;Macro Packages">Chapter&#160;4</a>,
            <span class="emphasis"><em><a href="ch04.html"
            title="Chapter&#160;4.&#160;Macro Packages">Chapter&#160;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&#160;<a href="ch11.html"
            title="Chapter&#160;11.&#160;Introducing MetaFont">Chapter&#160;11</a>,
            <span class="emphasis"><em><a href="ch11.html"
            title="Chapter&#160;11.&#160;Introducing MetaFont">Chapter&#160;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&#160;<a href="ch05.html"
            title="Chapter&#160;5.&#160;Fonts">Chapter&#160;5</a>,
            <span class="emphasis"><em><a href="ch05.html"
            title="Chapter&#160;5.&#160;Fonts">Chapter&#160;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 &#8220;<a
            href="ch01.html#subsubsec.runningtex"
            title="TeXing a Simple Document">the section called
            &#8220;TeXing a Simple Document&#8221;</a>,&#8221;
            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&#160;<a
            href="ch05.html"
            title="Chapter&#160;5.&#160;Fonts">Chapter&#160;5</a>.</p>

            <p>Chapter&#160;<a href="ch08.html"
            title="Chapter&#160;8.&#160;Printing">Chapter&#160;8</a>,
            <span class="emphasis"><em><a href="ch08.html"
            title="Chapter&#160;8.&#160;Printing">Chapter&#160;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&#160;<a
            href="ch09.html"
            title="Chapter&#160;9.&#160;Previewing">Chapter&#160;9</a>,
            <span class="emphasis"><em><a href="ch09.html"
            title="Chapter&#160;9.&#160;Previewing">Chapter&#160;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&#160;<a href="ch01.html#fig.texcmplx"
          title="Figure&#160;1.5.&#160;TeXing a More Complex Document">
          Figure&#160;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&#160;1.5.&#160;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&#160;<a
          href="ch01.html#ex.knuthbbl"
          title="Example&#160;1.2.&#160;A typical bibliography database entry">
          Example&#160;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>&#160;[<a
          href="bi01.html#kn:texbook">kn:texbook</a>]. The key for
          this entry is &#8220;kn:texbook.&#8221;</p>

          <div class="example">
            <a id="ex.knuthbbl" name="ex.knuthbbl"></a>

            <p class="title"><b>Example&#160;1.2.&#160;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 &#8220;plain&#8221;
          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&#160;<a
          href="ch04.html"
          title="Chapter&#160;4.&#160;Macro Packages">Chapter&#160;4</a>,
          <span class="emphasis"><em><a href="ch04.html"
          title="Chapter&#160;4.&#160;Macro Packages">Chapter&#160;4</a></em></span>,
          and graphics in Chapter&#160;<a href="ch06.html"
          title="Chapter&#160;6.&#160;Pictures and Figures">Chapter&#160;6</a>,
          <span class="emphasis"><em><a href="ch06.html"
          title="Chapter&#160;6.&#160;Pictures and Figures">Chapter&#160;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 &#8220;TeX is designed to typeset
          beautiful pages&#8221; 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 &amp; 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 &#8220;escape&#8221;
          category followed by any sequence of characters defined
          to be in the &#8220;letter&#8221; category or a single
          character in the &#8220;other&#8221; 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&#160;<a href="ch04.html"
          title="Chapter&#160;4.&#160;Macro Packages">Chapter&#160;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&#8212;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&#160;I.&#160;An Introduction to TeX"
          href="pt01.html"><img src="figures/nav-prev.png"
          alt="Prev" border="0" /></a>&#160;</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">&#160;<a
          title="Chapter&#160;2.&#160;Editing"
          href="ch02.html"><img src="figures/nav-next.png"
          alt="Next" border="0" /></a></td>
        </tr>

        <tr>
          <td width="40%" align="left">Part&#160;I.&#160;An
          Introduction to TeX&#160;</td>

          <td width="20%" align="center"><a
          title="Part&#160;I.&#160;An Introduction to TeX"
          href="pt01.html"><img src="figures/nav-up.png" alt="Up"
          border="0" /></a></td>

          <td width="40%" align="right">
          &#160;Chapter&#160;2.&#160;Editing</td>
        </tr>
      </table>
    </div>
  </body>
</html>