ebook img

An introduction to TeX and friends PDF

80 Pages·1992·0.426 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview An introduction to TeX and friends

An introduction to T X and friends E Gavin Maltby November 1992 Contents 1 Getting acquainted with TEX 1 1.1 The spirit of TEX . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1.1 TEX is a typesetter, not a word-processor . . . . . . . . 2 1.1.2 Typical TEX interfaces . . . . . . . . . . . . . . . . . . 4 2 Getting started with LATEX 7 2.1 Why start with LATEX? . . . . . . . . . . . . . . . . . . . . . . 7 2.2 LATEX formats, and we compose . . . . . . . . . . . . . . . . . 9 2.3 Document styles . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.4 Preparing a non-mathematical document . . . . . . . . . . . . 10 2.4.1 Sentences and paragraphs . . . . . . . . . . . . . . . . 11 2.4.2 Punctuation . . . . . . . . . . . . . . . . . . . . . . . . 13 2.4.3 Ties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.4.4 Specially reserved symbols . . . . . . . . . . . . . . . . 17 2.4.5 So what are control symbols and words? . . . . . . . . 18 2.4.6 Commands to change appearance . . . . . . . . . . . . 21 2.4.7 Accents . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.4.8 Over-ruling some of TEX’s choices . . . . . . . . . . . . 24 2.4.9 Commenting your document . . . . . . . . . . . . . . . 25 2.4.10 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.4.11 Topmatter . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.4.12 Sectioning commands . . . . . . . . . . . . . . . . . . . 26 2.4.13 LATEX environments . . . . . . . . . . . . . . . . . . . . 28 2.4.14 em environment . . . . . . . . . . . . . . . . . . . . . . 28 2.4.15 quote and quotation environments . . . . . . . . . . . 29 2.4.16 verse environment . . . . . . . . . . . . . . . . . . . . 31 2.4.17 center environment . . . . . . . . . . . . . . . . . . . 31 i 2.4.18 flushright and flushleft environments . . . . . . . 32 2.4.19 verbatim environment . . . . . . . . . . . . . . . . . . 33 2.4.20 itemize, enumerate, description environments . . . 35 2.4.21 tabbing environment . . . . . . . . . . . . . . . . . . . 37 2.4.22 tabular environment . . . . . . . . . . . . . . . . . . . 39 2.4.23 figure and table environments . . . . . . . . . . . . . 41 2.4.24 The letter document style . . . . . . . . . . . . . . . 43 2.4.25 Common pitfalls; Error messages . . . . . . . . . . . . 43 2.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3 Mathematical typesetting with LATEX 49 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 3.2 Displaying a formula . . . . . . . . . . . . . . . . . . . . . . . 53 3.3 Using mathematical symbols . . . . . . . . . . . . . . . . . . . 55 3.3.1 Symbols available from the keyboard . . . . . . . . . . 55 3.3.2 Greek letters . . . . . . . . . . . . . . . . . . . . . . . 56 3.3.3 Calligraphic uppercase letters . . . . . . . . . . . . . . 56 3.3.4 Binary operators . . . . . . . . . . . . . . . . . . . . . 57 3.3.5 Binary relations . . . . . . . . . . . . . . . . . . . . . . 58 3.3.6 Miscellaneous symbols . . . . . . . . . . . . . . . . . . 58 3.3.7 Arrow symbols . . . . . . . . . . . . . . . . . . . . . . 59 3.3.8 Expression delimiters . . . . . . . . . . . . . . . . . . . 59 Z X 3.3.9 Operators like and . . . . . . . . . . . . . . . . . 60 3.3.10 Accents . . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.4 Some common mathematical structures . . . . . . . . . . . . . 61 3.4.1 Subscripts and superscripts . . . . . . . . . . . . . . . 61 3.4.2 Primes . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 3.4.3 Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . 64 3.4.4 Roots . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 3.4.5 Ellipsis . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 3.4.6 Text within an expression . . . . . . . . . . . . . . . . 66 3.4.7 Log-like functions . . . . . . . . . . . . . . . . . . . . . 66 3.4.8 Over- and Underlining and bracing . . . . . . . . . . . 67 3.4.9 Stacking symbols . . . . . . . . . . . . . . . . . . . . . 68 3.4.10 Operators; Sums, Integrals, etc. . . . . . . . . . . . . . 68 3.4.11 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 ii 3.4.12 Changes to spacing . . . . . . . . . . . . . . . . . . . . 70 3.5 Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 3.6 Theorems, Propositions, Lemmas, ... . . . . . . . . . . . . . . 72 3.7 Where to from here? . . . . . . . . . . . . . . . . . . . . . . . 73 3.8 AMS-LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 iii List of Tables 2.1 Commands for selecting type styles . . . . . . . . . . . . . . . 21 2.2 LATEX size-changing commands. . . . . . . . . . . . . . . . . . 22 2.3 Control sequences for accents . . . . . . . . . . . . . . . . . . 23 2.4 LATEX sectioning commands . . . . . . . . . . . . . . . . . . . 26 3.1 Lowercase Greek letters . . . . . . . . . . . . . . . . . . . . . 56 3.2 Uppercase Greek letters . . . . . . . . . . . . . . . . . . . . . 56 3.3 Binary Operation Symbols . . . . . . . . . . . . . . . . . . . . 57 3.4 Binary relations . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.5 Miscellaneous symbols . . . . . . . . . . . . . . . . . . . . . . 59 3.6 Arrow symbols . . . . . . . . . . . . . . . . . . . . . . . . . . 59 3.7 Delimiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 3.8 Variable-sized symbols . . . . . . . . . . . . . . . . . . . . . . 61 3.9 Math accents . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.10 Log-like functions . . . . . . . . . . . . . . . . . . . . . . . . . 67 iv Chapter 1 Getting acquainted with T X E TEX is well known to be the typesetting package, and a vast cult of TEX lovers has evolved. But to the beginning TEX user, or to someone wondering if they should bother changing to TEX, it is often not clear what all the fuss is about. After all, are not both WordPerfect and Ventura Publisher capable of high quality output? Newcomers have often already seen what TEX is capable of (many books, journals, letters are now prepared with TEX) and so expect to find a tremendously powerful and friendly package. In fact they do, but that fact is well hidden in one’s initial TEX experiences. In this chapter we describe a little of what makes TEX great, and why other packages cannot even begin to compete. Be warned that a little patience is required—TEX’s virtues are rather subtle to begin with. But when the penny drops, you will wonder how you ever put up with anything different. 1.1 The spirit of T X E In order to really appreciate TEX one needs to get a feel for what I call the “spirit” of TEX. When TEX appears to be making me work overtime to achieve something that I think ought to be perfectly straightforward, consul- tation with the TEX spirit shows me the error of my ways. 1 1.1.1 T X is a typesetter, not a word-processor E TEX was designed with no limiting application in mind. It was intended to be able to prepare practically any document—from a single page all-text letter to a full blown book with huge numbers of formulae, tables, figures etc. The size and the complexity of a TEXable document is limited only by hardware considerations. Furthermore, TEX seeks to achieve all this whilst setting typesetting standards of the highest order for itself. The expertise of generations of professional printers has been captured in TEX, and it has been taught all the tricks of the trade. Historically, printers prepared a document by placing metal characters in a large tray and arranging and binding them to form a page. This was very precisely done, but the ultimate precision was limited because of the mechan- ical nature of things and by time considerations. TEX prepares a page in an analogous manner (putting your characters and formulae into “boxes” which are then “glued” together to form the page), but has the advantage of enor- mous precision because placement calculations are performed by computer. Indeed, TEX’s internal unit (the “scaled point”) is about one-hundredth of the wavelength of natural light! “But conventional word processors run on computers , too”, you object. Yes, but their fundamental limitation is that they try to “keep up” with you and “typeset” your document as you type. This means that it can only make decisions at a local level (eg, it decides where to break a line just as you type the end of the line). TEX’s secret is that it waits until you have typed the whole document before it typesets a single thing! This means that TEX can make decisions of a global nature in order to optimise the aesthetic appeal of your document. It has been taught what looks good and what looks bad (having been given a measure of the “badness” of various possibilities) and makes choices for your document that are designed to make it “minimally bad”. ButTEX’svirtuesrunmuchdeeperthanthat,whichisjustaswellbecause it is possible to get satisfactory, though imperfect, results from some word processors. OneofTEX’sstrongestpoints isits abilitytotypesetcomplicated formulae with ease. Not only does TEX make hundreds of special symbols easily accessible, it will lay them out for you in your formulae. It has been taught all the spacing, size, font, ...conventions that printers have decided look best in typeset formulae. Although, of course, it doesn’t understand 2 anymathematicsitknowsthegrammarofmathematics—itrecognisesbinary relations, binary operators, unary operators, etc. and has been taught how thesepartsshouldbeset. Itisconsequentlyratherdifficulttogetanequation to look bad in TEX. Another advantage of compiling a document after it is typed is that cross- referencing can be done. You can label and refer back to chapters, sections, tables etc. by name rather than absolute number, and TEX will number and cross-reference these for you. Similarly, it will compile a table of contents, glossary, index and bibliography for you. Essential to the spirit of TEX is that it formats the document whilst you just take care of the content, making for increased productivity. The cross- referencing just mentioned is just part of this. Many more labour-saving mechanisms are provided for through style files. These are generic descrip- tions of classes of documents, teaching TEX just how each class likes to be formatted. This is taught in terms of font preferences, default page sizes, placement of title, author, date, etc. For instance, a paper style file could teach TEX that when typesetting a theorem it should embolden the part that states the theorem number and typeset the text of the theorem statement in slanted Roman typeface (as in many journals). The typist simply provides and indication that a theorem is being stated, and then types the text of the theoremwithout botheringtochooseanyfontsordoanyformatting—allthat is done by the style file. Style files exist for all manner of document—letters, articles, papers, books, proceedings, review articles, and so on. In addition to style files, there are macro packages. A macro is just a definition of a new TEX command in terms of existing ones. Don’t think small when you think of macros! When typing a document that has a lot of repetition in it, say the same expression is used again and again in different different equations, you can define a macro in your document to abbrevi- ate that expression. But macros can teach TEX how to typeset all sorts of complicated structures, not just parts of an equation. Many macro packages (files that are just collections of definitions) have been written to teach TEX all sorts of applications. There are specialist maths packages (AMS-TEX, AMS-LATEX), general purpose packages (LATEX), packages for setting tree diagrams, Feynmann diagrams, languages like Chinese, Arabic and Ancient Greek, orchestralscores, andmany, manymore. Allthesearefreelyavailable, a spin-off of the giant TEX cult. Another facet of the design of TEX allows it to use practically any output 3 device. In fact, TEX doesn’t talk to any printers, screens, phototypesetters at all! Instead, when a document is compiled a device independent (.dvi) is produced—TEX does not compile with any particular output device in mind. Printer drivers are then invoked on this .dvi file and, in consultation with the font data for that printer, produce output suitable for the particular device. You can choose an HP Laserjet driver, or an Apple LaserWriter driver, or a dot matrix driver etc. All use the same .dvi file as input (and remember the material in there is set to enormous accuracy) and attempt to image that file on the particular device as faithfully as possible. If you are using a top of the line laser printer or phototypesetter, then TEX’s massive internal precision will not be wasted. Alternatively, a dot matrix printer will give a coarse approximation of the ideal image that is suitable only for proof- reading. In addition to portability, these .dvi files help ensure that there are very few printing surprises when you move from one device to another: how many times has your favourite word-processor made you reformat a document when you wish to change printers? There are many other motivations one could cite for the superiority of TEX. Butitistimethatwestartedtogetourhandsdirty. Onelastcomment: TEX was not designed to supplant secretaries and professional printers—it was designed to aid them in their work and, in the words of the TEX designer Donald Knuth, allow them to “go forward and create masterpieces of the publishingart”.Italsoallowsthosewhogeneratethematerialtobetypeset— mathematicians, physicists, computer scientists, etc—to prepare their own documents in a language that is intimately linked to the language we use for writing such material. The novice reader will still have no idea of what a TEX source file looks like. Indeed, why do we keep referring to it as a source file? The fact of the matter is that TEX is essentially a programming language. Just as in any compiled language (e.g., Pascal, C) one prepares a source file and submits it to the compiler which attempts to produce an object file (.dvi file in the TEX case). To learn TEX is to learn the command syntax of the commands that can be used in the source file. 1.1.2 Typical T X interfaces E TEX was designed to run on a multitude of computers. It is therefore the case that the documentation for TEX and its “friends” LATEX, AMS-TEX, etc. is 4 not computer specific. Only command syntax is described—i.e., the content of your source file—but few details of how to get from there to a printout are given. Those details are left to site-specific documents. The average user loses little in using TEX on, say, a PC rather than on a bigger machine. Indeed, compilation times on the new PCs begin to rival those on a Sun Sparc Station 2 (no slouch). Running on top of DOS can cause memory problems when very large documents are being prepared. That aside, the quality of the document is not affected because of the careful design of TEX—whether you work on a a machine with massive floating point precision or a modest XT the .dvi files produced on compilation will be identical; and when those files are submitted to printer equivalent printer drivers (say for an HP LaserJet III attached to a Sun in one case and a PC in the other) the output will be identical because the font information they draw on is identical. By the nature of TEX most time is spent editing the source document (before submitting it for compilation). No special interface is necessary here, you just use your favourite text editor (perhaps customising it to enhance TEXnical typing. Thus TEX user interfaces are usually small and simple, often even missing. One frequently uses TEX at command line level, just running the editor, compiler etc. as you need them. Sometimes a TEXshell program is present, which runs these for you when you choose various menu options. Whatever the interface, there are just a few basic steps to preparing a document: 1. Chooseadocumentstyletobaseyourdocumenton(e.g.,letter,article). 2. Glance through the material you have to type, and decide what defi- nitions might be made to save you a lot of time. Also, decide on the overall structure of the prospective document (e.g., will the largest sec- tional unit be a chapter or a part?). If you are going to compose as you type, then pause a moment to think ahead and plan the structure of your document. The importance of this step cannot be overstressed, for it makes clear in your mind what you want from TEX. 3. Prepare your input file, specifying only the content and the logical structure (parts, sections, theorems,...) thereof and forgetting about formatting details. 5

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.