You are on page 1of 279
Contents Preface 1 Getting Acquainted 1.1 How to Avoid Reading This Book 1.2 How to Read This Book 1.3 The Game of the Name 14 Turning Typing into Typography 1.5 Why Bs1RX? 1.6 ‘Turning Ideas into Input 17 Trying It Ont 2 Getting Started 2.1 Preparing an Input File 2.2 The Input 22.1 ences and Paragraphs Quotation Marks Dashes Space After a Period Special Symbols i Simple Text-Generating Commands Emphasizing Text Preventing Line Breaks Footnotes Formulas Ignorable Input 2.2.2 ‘The Document The Document Class The Title “Page” 28 Sectioning 1 Displayed Material Quotations, Lists xv 8 8 16 Poetry Displayed Formulas 2.2.5 Declarations 2.3 Running IATRX 2.4 Helpful Hints 2.5 Summary Carrying On 3.1 Changing the Type Style 3.2. Symbols from Other Languages B21 Accents 3.2.2 Symbols 3.3 Mathematical Formulas 3.3.1 Some Common Structures Subscripts and Fractions Roots Ellipsis ; 3.3.2 Mathematical Symbols Greek Letters Calligraphic Letters ‘A Menagerie of Mathematical Symbols The array Vertical Alignment More Complex Arva 3.34 Delimiters 3.3.5 Multiline Formulas 3.3.6 Putting One Thing Above Another Over- and Underlining Accents Stacking Symbols 3.3.7 Spacing in Math Mode 33.8 Changing Style in Math Mode Type Style Math Style When All Else Fails ing Commands and Environments Defining Commands Defining Environments 34.3 ‘Theorems and Such 3.5 Pigures and Other Floating Bodies 25 26 7 28 al 32 35 36 38 38 38 39 40 40 40 40 40 4 41 42 42 a4 45 5 46. 46 36 a7 3.5.1 Figures and Tables 3.5.2. Marginal Notes Lining t Up in Columns 3.6.1 The tabbing Enviro 3.6.2 The tabular Environ! Simulating Typed Text 4 Moving Information Around 4 42 43 5a 53 The ‘Table of Contents Cross-References Bibliography and Citation 4.3.1 Using BInTpX 4.3.2. Doing It Yourself . Splitting Your Input. Making an Index or Glossary 4.5.1 Compiling the Entries 4.5.2 Producing an Index or Glossary by Yourself Keyboard Input and Screen Output Sendinig Your Document 5 Other Decument Classes Books . Slides 52.3 Pr 5.24 Other ‘Text Letters 6 Designing It Yourself 6.1 63 64 Document and Page Styles 6.1.1 Document-Class Options 6.1.2 Page Styles 7 6.1.3 ‘The Title Page and Abstract 6.14 Customizing the Style Line and Page Breaking 6.2.1 Line Breaking 6.22 Page Breaking Numbering, Length, Spaces, and Boxes 64.1 Length 6.4.2 Spaces 64.3 Boxes LR Boxes 90 93, 93, 96 7 99) 99 101 103 104 é Parboxes Rule Boxes Raising and Lowering Boxes Saving Boxes 6.44 Formatting with Boxes 6.5 Centering and “Flushing” 6.6 List-Making Environments 6.6.1 The list Environment 6.6.2. The trivlist Environment 6.7 Fonts 6.7.1 Changing Type Size 6.7.2 Special Symbols Pictures and Colors 7.1 Pictures hes ZL1 ‘The picture Environment 7.12 Picture Objects Text Boxes Straight Lines Arrows Stacks . Circles Ovals and Rounded Corners Framing 73 Curves ZA Grids 7.5 Reusing Objects T.LG Repeated Patterns T.LT Some Hints on Drawing Pict 7.2 The graphics Package 7.4 Color Errors 8.1 Finding the Error . 82. INTpX’s Error Messages: 83° TEX’s Error Messages: 84. [TEX Warnings 8.5 TEX Warnings Using MakeIndes A.L How to Use Makelnder A.2 How to Generate Index Entries A21 When, Why, What, and How to Index 149. 150) 150) 150 A22 The Basics A23. The Fine Print A.3. Exror Messages ‘The Bibl Ba graphy Database 2 Format of the bib File B.1.1 ‘The Entry Format B.1.2. The Text of a Field Namies Titles B.L.3. Abbreviations B.1.4 Cross-References B.2_ The Entries B21 Entry Types B22 Fields Reference Manual C1 Commands and Environments CAL Command Names and Argume C12 Environments C.L8 Fragile Commands CLM Declarations oe C15 Invisible Commands and Environments C16. The \\ Command C2. The Structure of the Document CB. Sentences and Paragraphs CAL Making Sentences C32 Making Paragraphs C33. Footnotes C34 Accents and Special Symbols CA. Sectioning and Table of Contents CAA Sectioning Commands . C42 The Appendix C4. Table of Contents CAA Style Parameters C5 Classes, Packages, and Page Styles C5. Docw 5.2 Packages . C53. Page Styles . C54 The Title Page and Abstract C6 Displayed Paragraphs nt Class C.6.1 Quotations and Verse 6.2. List-Making Environments 155 156 156 157 187 158 158 159) 160) 160 162 165 166 166 167. 167 168 169 169) 170 170 170 171 172 173 174 174 175 175. 176 176 in 1s 179 181 183 Ist 184 k C.6.3 The List and trivlist Environments C64 Verbatim Mathematical Formulas G.7.1 Math Mode Environments G72 Common Strnetures 7.3. Mathematical Symbols C74 Arrays ©.7.5 Delimiters ©.7.6 Putting One Thing Above Another C27 Spacing C78 Changing Style C8 Definitions, Numbering, and Programming ©.8.1 Defining Commands C82. Defining Environments C83. Theoremslike Environments C84 Numbering C85. The ifthen Package C9 Figures and Other Floating Bodies C.9.1 Figures and Tables C.9.2 Marginal Notes C.10 Lining It Up in Cohumns ©.10.1 The tabbing Environment €.10.2 The array and tabular Environments C.L1 Moving Information Around CALI Files C.11.2 Cross-References C.11.3 Bibliography and Citation C.114 Splitting the Input C.11.5 Index and Glossary Producing an Index Compiling the Entries C.11.6 Terminal Input and Output €.12 Line and Page Breaking C121 Line Breaking C.12.2 Page Breaking C.13 Lengths, Spaces, and Boxes C131 Length C.13.2 Space C.13.3 Boxes, ©.14 Pichures and Color C4. The picture Environment Picture-Mode Commands Picture Objects 185 186 187 187 189 189 190 190 190) 191 191 192 192 192 193 194 195, 197 197 200 201 201 204 207 207 208 209 210 an 2 212 Picture Declarations C.14.2 The graphics Package C.14.3 The color Package ©.15 Font Selection C.15.1 Chan 15.2 Changing the €.15.3 Special Symbols, D What's New 227 E. Using Plain TeX Commands 231 Bibliography 235 Index 237 Preface ‘The first edition of this book appeared in 1985. It described IMTpX 2.09, the first widely used version of INTpX. Since then, IATEX has become extremely popular, with m world. Its functionality has grown through the efforts of many people, The time has come for a new version, IXTpX 2c, which is described in this edition. ITEX2e includes many of the ‘enhancements that were mace to LATEX 2.09, as well as some new ones. T implemented most of S1X 2.09 myself. LEX 22 was implemented by a group led by Frank Mittelbach, which included Johannes Braams, David Carlisle, Michael Downes, Alan Jeffrey, Chris Rowley, Sebastian Rabtz, and Rainer Schdpf. They were assisted by many testers of the new version, and by thousands of users around th the following organizations: the Ameriean Mathematical Society, the Open Uni- versity (UK), and the Zentrum fiir Datenverarbeitung der Universitat, Maina Lyle Ramshaw helped with the implementation of Bezier curves. My thanks to all of these people—especially Frank and Chris, with whom I have spent many enjoyable hours arguing about ISTBX. LXTEX has been made more useful by two programs: BusTpX, written by Oren Patashnik, and Makedndes, written by Pehong Chen and modified by Nelson Beebe. Many people helped me write this book—often without knowing it. Advice given to me over the years by Cynthia Hibbard and Mary-Claire van Leunen has found its way onto a number of these pages, Andrei Broder was my local informant for Romanian, Helen Goldstein assisted with research on matters ranging from. art to zoology. ‘This edition was improved by the corrections and suggestions of Mare Brown, Michel Goossens, and the implementers of ISTpX 2c. Stephen Harrison helped produce the final output. Errors and infelicities in the first printing were found by Rosemary Bailey, Malcolm Clark, and Ellen Gilkerson. ‘The following peo- ple found errors in, or suggested improvements to, the previous edition: Martin Abadi, Helmer Aslaksen, Barbara Beton, Rick Clark, John DeTreville, Math- ieu Federspiel, Michael Fischer, Stephen Gildea, Andy Hisgen, Joseph Hurler, Louis E. Janus, Dave Johnson, Charles Karney, Nori Kawasaki, Steve Kelem, Mark Kent, William LeKebvre, Jerry Leichter, Hank Lewis, Stephen Pe Hal Perkins, Flavio Rose, Scott Simpson, David Sullivan, Matthew Swift, Walter ‘Taylor, Joe Weening, Sam Whidden, Edgar Whipple, Chris Wilson, David Wise, and Rusty Wright. [also received helpful comments and complaints about pre- liminary versions of JSTEX and of the first edition of this book from Todd Allen, Robert Amsler, David Bacon, Stephen Barnard, Per Bothner, David Braunegg, Daniel Brotsky, Chuck Buckley, Pavel Curtis, Russell Greiner, Andrew Hanson, Michael Harrison, B. J. Herbison, Calvin W. Jackson, David Kosower, Ken- neth Laws, Tim Morgan, Mark Moriconi, Stuart Reges, A. Wayne Slawson, David Smith, Michael Spivak, Mark Stickel, Gary Swanson, Mike Urban, Mark Wadsworth, and Gio Wiederhold. Assistance in the development of IATEX 2.09 was provided by David Fuchs, Richard Furuta, Marshall Henrichs, Lynn Rug- eles, Richard Southall, Chris Torek, Howard Trickey, and SRI International. Since the introduction of version 2.09, my work on ISTpX has been supported by Digital Equipment Corporation. I want to thank Robert Taylor and all the other members of Digital's Systems Research Center for making it a fun place to work. Finally, T want to express my special thanks to two men who made this book possible, Donald Knuth created TpX, the program on which ISTRX is based. He also answered all my questions, even the stupid ones, and was always willing to explain TpX's mysteries. Peter Gordon persuaded me to write the first edition, despite my doubts that anyone would buy a book about a typesetting system, Over the years, he has provided advice, fine dining, and friendship. LL Palo Alto, California September 1994 CHAPTER 1 Getting Acquainted ear xP fi ex = Getting Acquainted ISTpX is a system for typesetting documents. Its first widely available version, mysteriously numbered 2.09, appeared in 1985, IXTpX is now extremely popular in the scientific and academic communities, and it is used extensively in industry. It has become a tingua franca of the s fie world; scientists send their papers J the world in the form of ISX input. Over the years, various nonstandard enhancements were made to TATEX 2.09 to overcome some of its limitations. [XIX input that made use of these en- hancements would not work properly at all sites. A new version of [TEX was needed to keep a Tower of Babel from rising. ‘The current version of IXTEX, with the somewhat less mysterious number 2c, was released in 1994, IXIpX 2e contains an improved method for handling different styles of type, commands for including graphics and producing colors, and many other new features. Almost all standard I8TpX 2.09 input files will work with INTEX 2¢. Howev« to take advantage of the new features, users must learn a few new FST} conver ISTpX 2.09 users should read Appendix D to find out what thas changed. ‘The rest of this book is about ISTHX, which, until a newer version appears, means TSTX 2. IXTpX is available for just about any computer made today, The versions that run on these diferent systems are essentially the same; an input file created according to the directions in this book should produce the same output with any of them, However, how you actually run IXTRX depends upon the computer electronically to colleagues arou system, Moreover, some new features may not be available on all systems when, TATEX 2c is first released. For each computer system, there is a short companion to this book, titled something like Local Guide to TRX for the McKiudge PC, containing information specific to that system. I will call it simply the Local Guide. It is distributed with the INTEX software. ‘There is another companion to this book, The [XTX Companion by Goossens, Mittelbach, and Samarin [3]. This companion is an in-depth guide to TEX and to its packages—standard enhancements that can be used at any site to provide The ISfpX Companion is the place to look if you can't find what you need im this hook. Tt describes more than a hundred packages. 1.1. How to Avoid Reading This Book Many people would rather learn about a program at their computer than by reading a book. There is a small sample IXIpX input file named smali2e.tex that shows how to prepare your own input files for typesetting simple documents. Before reading any further, you might want to examine smal12e. tex with a text editor and modify it to make an input file for a document of your own, then run E{TpX on this file and see what it produces. ‘The Local Guide will tell you how to find emal12e. tex and run IST on your computer; it may also contain information about text editors. Be careful not to destroy the original version of ‘smal12e.tex; you'll probably want to look at it again, The file smal12¢.tex is only forty lines long, and it shows how to produce only very simple documents. There is a longer file named sampleze. tex that contains more information, If smal12e.tex doesn’t tell you how to do some- thing, you can try looking at sample2e.tex. If you prefer to learn more about a program before you use it, read on. Almost everything in the sample input files is explained in the first two chapters of this book 1.2 How to Read This Book While samp1e2e. tex illustrates many of IXTpX’s features, it is still only about two hnndred fines long, and there is a lot that it doesn't explain. Eventually, you will want to typeset a document that requires more sophisticated formatting than you can obtain by imitating the two sample input files. You will then have to look in this book for the necessary information. You can read the section containing the information you need without having to read everything that precedes it, However, all the later chapters assume you have read Chapters 1 and 2. For example, suppose you want to set one paragraph of a document in small type. Looking up “typo sizo” in the index or browsing through the table of contents will lead you to Section 6.7.1, which talks about “declarations” aud, their “scope” —simple concepts that are explained in Chapter 2. It will take just a minute or vo to learn what to do if you've alread read Chapter 2; it could be quite frustrating if you haven't, So, it’s best to read the first. Ovo chapters now, before you need them. IsTEX’s input is a file containing the document's text together with com- mands that describe the document’s structure; its output is a file of typesetting instructions. Another program must be run to convert these instructions into printed output. With a high-resolution printer, ISTX can generate book-quality typesetting. This book tells you how to prepare a JAIpX input file. The current chapter discusses the philosophy underlying IATX; here is a brief sketch of what's in the remaining chapters and appendices: Chapter 2 explains what you should know to handle most simple documents and to read the rest of the hook, Section 2.5 contains a summary of everything in the chapter; it serves as a short reference manual. Chapter 3 describes logical structures for handling a variety of formatting problems. Section 3.4 explains how to define your own commands, whieh can save typing when you write the document and retyping when you change it. It’s a good idea to read the introduction up to the beginaing of Section 8.1—before reading any other part of the chapter Getting Acquainted Chapter 4 contains features especially useful for large documents, including Womatic cross-referencing and commands for splitting a large file into electronically. smaller pieces. Section 4.7 discusses sending your docun Chapter 5 is abont making books, slides, and letters (the kind you send by post). Chapter 6 describes the visual formatting of the text, It has information about changing the style of your document, explains how to correct bad line and page breaks, and tells how to do your own formatting of structures not explicitly handled by Chapter 7 discusses pictures—drawing them yourself and inserting ones pre- pared with other programis—and color. Chapter 8 explains how to deal with errors. This is where you should look when IATpX prints an error message that you don't understand Appendix A describes how to use the Makeinder program to make an index, Appendix B describes how to make a bibliographic database for use with BIBTEX, a separate program that provides an automatic bibliography fea- ture for ESTEX. Appendix C is a reference manual that compactly describes all ISTpX's fea- tures, including many advanced ones not described in the main text. Ifa command introduced in the earlier chapters seems to lack some necessary capabilities, check its description here to see if it has them. This appendix is a convenient place to refresh your memory of how something works, Appendix D describes the differences between the current version of Ey and the original version, L*T}3X 2.09, x Appendix B is for the reader who knows ‘IEX, the program on which ISTEX is built, and wants to use TX commands that are not described in this, book. When you face a formatting problem, the best place to look for a sohution is in the table of contents. Browsing through it will give you a good idea of what ISTEX has to offer. If the table of contents doesn’t work, look in the index; 1 have tried to make it friendly and informative, Each section of Chapters 3-7 is reasonably self-contained, assuming only that you have read Chapter 2, Where additional knowledge is required, explicit cross-references are given, Appendix C is also self-contained, but a command’s description may be hard to understand without first. reading the corresponding description in the earlier chapters. ‘The descriptions of most ISTgX commands include examples of their use, In this book, examples are formatted in two columns, as follows: 3 The Game of the Name ‘The left column shows the printed output; the right ‘The left columm shows the printed output} column contains the input that. produced it the right column contains the input that produced it. Note the special typewriter type style in the right column. It indicates what you type—either text that yon pnt in the input file or something like a file name that you type as part of a command to the computer. Since the sample output is printed in a narrower column, and with smaller type, than ISTEX normally uses, it won't look exactly like the output you'd get from that input. The convention of the output appearing to the left of the corresponding input is generally also used when co listed in tables, ands and their output are 1.3. The Game of the Name ‘The TeX in ISX refers to Donald Knuth’s TEX typesetting system. ‘The IATEX program is a special version of THX that understands IXTEX commands. Think of BTPX as a house built with the inmber and nails provided by TEX. You don"t need lumber and nails to live int a house, but they are handy for adding an extra room, Most ISTRX users never need to know any more about TEX than they can learn from this book. However, the lower-level TEX commands described in The ‘TpXbook [4] can be very useful when creating a new package for ET} Twill use the term “TEX” when describing standard ‘TpX features and “IXT;X” 1 describing features unique to FATEX, but. the distinction will he of interest to readers already familiar with TEX. You may ignore it and use the two names interchangeably. One of the hardest things about using ISTEX is deciding how to pronounce it. This is also one of the few things I'm not going to tell you abont INTpX, since pronunciation is best determined by usage, not fiat, TEX is usually pronounced teck, making lah-teck, lah-teck, and Tay-teck the logical choices; but language is not always logical, so day-tecks is also possible. ‘The written word carries more legal complications than the spoken, and the need to distinguish IpX and IXTfX from similarly spelled products restriets how you may write them. The best way to refer to these programs is by their logos, which can be generated with simple IXT;X commands, When this is impossible, as in an email message, you shold write them as TeX and LaTex, where the unusual capitalization identifies these computer programs, 1.4 Turning Typing into Typography Traditionally, an author provides a publisher with a typed manuscript. ‘The publisher’s typographic designer decides how the manuscript is to be formatted, specifying the length of the printed line, what style of type to use, how much Getting Acquainted space to leave above and below section headings, and many other things that, determine the printed document's appearance, The designer writes a series of instructions to the typesetter, who uses them to decide where on the page to put each of the author's words and symbols. In the old days, typesetters produced a matrix of metal type for each page; today they produce computer files. In either case, their output is used to control the machine that does the actual typesetting, DSTEX is your typographic designer, and ‘IGX is its typesetter. ‘The INTy commands that you type are translated into lower-level TEX typesetting: com- mands. Being a moder typesciter, TEX produces a computer file, called the device-independent or avi file. ‘The Local Guide explains how to use this file to generate a printed document with your computer. It also explains how to view your document on your computer, using a screen previewer. Unless your document is very short, you will want to see the typeset version as you're writing it. Use a previewer instead of laying waste to our planet's dwindling forests by printing lots of intermediate versions. In fact, unless you want to take a copy with you on a wilderness expedition, you may never have to print it at all. It is easier and faster to distribute your document electronically than by mailing paper copies. A human typographic designer knows what the manuscript is generally about and uses this knowledge in deciding how to format it. Consider the following typewritten manuscript ‘The German mathematician Kronecker, sitting quietly at his desk, wrote: God created the vhole numbers; all ‘the rest is man’s york. Seated in front of the terminal, with Basic hanging on ay every keystroke, I typed: for i= 1 to infinity Let number [i] = i A human designer knows that the first indented paragraph (God created ...) is a quotation and the second is a computer program, so the two should be formatted differently. He would probably set the quotation in ordinary roman type and the computer program in a typewriter type style. TATEX is only a computer program and can't understand English, so it can’t eure all this out by itself. It needs more help from you than a human designer would. The funtion of typographic design is to help the reader understand the au thor's ideas. For a docnment to be easy to read, its visual structure must reflect its logical structure, Quotations and computer programs, beitig logically distinct structural elements, should be distingnished visually from one another. The de- signer should therefore understand the document's logical structure. Since ISTEX can't understand your prose, you unust explicitly indicate the logieal structure by typing special commands. ‘The primary frmetion of almost all the JSTEX 1.5 Why PTX? commands that yon type should be to describe the logical structure of your doc- ument, As you are writing your document, you should be concerned with its logical structure, not its visual appearance. The I{TEX approach to typesetting can therefore be characterized as logical design. 1.5 Why BTpx? When IS1X was introduced in 1985, few anthors had the facilities for typesetting their own documents. ‘Today, desktop publishing is commonplace. You can buy a “wyshwyG” (what you see is what you get) program that lets you see exactly what your document will look like as you type it. WYSnVYG programs are very appealing. They make it easy to put text wherever you want in whatever size and style of type you want, Why use IXTgX, which requires you to tell it that a piece of text is a quotation or a computer program, when a WYSIWYG program allows you to format the text just the way you want it? Wystwv6 programs replace IXTpX’s logical design with visual design. Vie sual design is fine for short, simple documents like letters and memos. It is not good for more complex documents such as scientific papers. WstwyG has heen characterized as “what you see is all you've got”.! To illustrate the advan- tage of logical over visual design, I will consider a simple example from the file samplo2e. tox. Near the top of the second page of the document is the mathematical term (A,B). With a wysiwye program, this term is entered by typing (A,B). You could type it the same way in the ISTEX input, However, the term represents a mathematical structure—the inner product of A and B. An experienced EXTEX user will define a command to express this structure, ‘The file sample2e.tex defines the command \ip so that \ip{AHB} produces (A, B), The term (Pw) r the end of the document is also an inner product and is produced with the \ap command, Suppose you decide that there should be a little more space after the comma in an inner product. Just changing the definition of the \ip command will change (A,B) to (A, B) and (PW) to (P.w'). With a wvsnwye program, you would have to insert the space by hand in each formula—not a problem for a short document with two such terms, but a mathematical paper could contain dozens and a book could contain hundreds. You would probably produce inconsistent formatting by missing some formulas or forgetting to add the space when entering new ones. With IXTpX, you don't have to worry about formatting, while writing your document, Formatting de at any tine. The advantage of logical design becomes even more obvious if yon decide that you prefer the notation (4|B} for the inner product of A and B. ‘The jons can be made and changed "Brian Reid attributes this phrase to himself and/or Brian Kernighan.

You might also like