<<

Stanford University Libraries Dept. o. Special Collections _ Col) DOg^ Title — box _^_ fT^x n** O.A v tiro

Gourmet Guide to Technical Text by Computer

WITH NUMEROUS EXPLICIT ILLUSTRATIONS

MICHAEL SPIVAK, Ph.D. THE JOY OF Tj^C by

Michael Spivak c

c

c

c Copyright. (C) I'JSO by tlic American Society

M;U!irm..tU\.l This is version —3 of the _A_4__r-T£X manual. _X_^ls_f-T[s( is meant to be used by some one who knows nothing about computers, except how to use a text editor, but this version is net meant for such technical typists. It is a very incomplete preliminary version, for l£X hackers, from whom suggestions for improvements arc being solicited. Please excuse the appearance of this version—it's not a very good advertise- ment for TVJ-, which is supposed to produce beautiful books! There arc lots of reasons and excuses for this (mainly lack or time), but things will look better later on; at the moment only the bare-bones output routine from Appendix B of the T]^< manual has been used, so there aren't even running heads to tell you what Chapter and section you are in. Some of the nifty macros mentioned here don't actually exist yet, but they should be operating soon (at certain points it will be clear that some are still oug;/y). Also, some of the and symbols mentioned here aren't available yet, so some things were actually written in by hand. In particular, the symbols for "sidetrips" and "cautions" that are mentioned in the Introduction haven't been designed (on ) yet, so SIDETRIP and CAUTION appear instead; also the sidclrip:; haven't been set in smaller type, although they eventually will be. The ellipses . . . appear at several places. Sometimes this material hasn't been written because some design considerations still have to be made; sometimes I .was just too lazy. Anyone familiar with the T£X manual will know what to do about th.se points. Chapter 4 is quite incomplete—we just wanted to assure people thai if will be real easy to set matrices (none of this \vcenter{\halign{ stuff!. Eventually, we will be able to set partitioned matrices of all sorts and many kinds of commutative diagrams. There will also be a way of setting simple tables, the kinds that might actually appear in a math paper. A macro package to handle ___■ 1 1 the various sorts of tables, like ibl in troff, is clearly possible—it's just a question of getting some one to do it (it's not clear whether such a macro package should be part of this manual). Finally, only a few Exercises have been included. Basically, there just wasn't time to make the others. But we'd also be interested in suggestions for Exercises (interesting or tricky typesetting problems which you've come across). All suggestions and corrections, major and minor (misprints, complaints about the exposition, bugs, suggestions for nicer syntax in the macros, new macros that arc needed, etc.) will be gratefully received (but probably not acknowledged). They can he sent to the author by ordinary mail, the only kind he reads, c/o Publish or Perish, Inc., 2000 Center Street, Suite 1404, Berkeley, CA 94704. Or they can be sent via computer to palais mit-mc.

Q Introduction. WHAT 1&X CAN DO (and _.mnot do)

The title of this book is a little deceptive. It might give you wrong ideas about the pronunciation or T£.X, which actually stands for TAU EP3ILON CHI; according to its creator, Donald E. Knuth, insiders pronounce T^X so that it rhymes with blecchhh. Ts_ is thus an upper-case, or capital letter, form of rex, the beginning of the Creek word that means art, and that is also the root of English words like technology. This name emphasizes two basic features of '_£X:' il is a romputcr system for typesetting technical text, especially text containing n lot uf mathematics; and il is a system for producing beautiful text, comparable to the w-.. k of the finest printers. One other feature of the system needs to be emphasized: TfJ< allows you to do all of this easily . In fact, this is a manual for someone who knows nothing about computers (written by someone who knows nothing about computers). Actually, that last statement isn't quite true: the one thing we assume is that ycu ah .;..dy know how to use a computer terminal to create a file (in prac- tice, this knowing how to use an "editor", so lha* you can easily correct or change a" file). Nothing about typesetting itself is assumed, although a few printers' terms will be introduced along the way. You can remain blissfully ig- norant of the complicated rules that typesetters have developed for the proper setting of mathematics formulas —TfcX knows them all. Nor is any knowledge cf mathematics required. But you will still need to have a general idea of what printed mathematics ought to look like. Mathematicians and experienced tech- nical typists -who already know this—will find that 7&X allows them to specify mathematics formulas with less effort than before, yet with greater control over the finished product. Novice technical typists have a dual task: learning what mathematicians want, and learning how to get Tp/C to produce it. This manual will tell you all about the second, and give you as much help as possible with the first. In order to get some idea just how TjJ< works, we will examine a recent paper from a w.ll-known journal that was typeset by IfcX.

0-1

.nc.'n:, (.

. « BULLETIN (New Series) OF THE ASININE MATHEMATICAL SOCIETY Volume 23, Number 6, November 2001 co 2001 Asinine Mathematical Society 0002-990 1/01/0000-0503/502.00

WHAT EVERY YOUNG MATHEMATICIAN SHOULD KNOW K. ELVIN ( ABSTRACT. We evaluate an interesting definite integral. The purpose of this paper is to call attention to a result of which many math ematicians seem to be ignorant. THEOREM. The value off^^e -^dx is < c~x dx = >/*. /oo-oo PROOF: We have {I>'^-{IX'-'^lXy-^) /"°° f°° _ 2 _ 2 = / cx c v dxdy by Fubini J—oo J—oo *-&+*) dydx /oo-oo J/ oo 2 — * _ 2 r' r r = / / c rdrdO using polar coordinates

r rlit\ _r - =°o" -f[_]" = 7T . Remark.t. A mathematician is one to whom that is as obvious as that twicetwi two makes four is to you.

INSTITUTE FOll HAUGHTY ATTITUDES ( flcrrivrd by the editors April 2001 Hc-.r_irch supported in pari by ihr* National Foundation Mathematical Mubjrct cttts#ifirut ion(IU.)0). Primary '20A 00 Keywords:

(

/-oo

I, Snobbishnrss

Obvious. The author first wrote this paper by hand, and then, being a lazy fellow himself, gave it to a to c technical typist produce a computer file. Parts of this file are shown below, in a style of type which will always be used to indicate input typed on a terminal, as opposed to the output I^X will produce, or the contents of this manual itself; don't worry if your keyboard lacks some of these symbols— T£X has a way of getting around this.

C Xbeginpaper Xtitle What Every Young Mathematician Should Know\endtitle Xauthor K. Elvin Xendauthor

Xbegintext The purpose of this paper is to call attention to a result of wiiich many mathematicians seem to be ignorant. Xtheorem Theorem\\The value of $\int4.<-\infty>T\infty -.T-C-xT2>\, dxs is ?s\inti-C-\infLy>T\infty eT<-xT2>\, dx= c XsqrtXpi . ss\endtheorem Xproof ProofXX We have $$\al ign XleftC \intJ.{-\infty>T\infty eT<-xT2}\ , dx \right)T2 __=\left( \ir.t4-<-\infty>T\infty eT{-xT2>\, dx \right) c MeftC \int-K-\infty>?\infty eT-C-yT2>\, dy \right) \\ _.=\intJ.-C-\infty>T\infty \intJ-C-\infty>T\infty eT-OxT2>eT-C-yT2>\ , dx\, dy

Even a cursory examination of this file gives some idea how T^X is used. C For example, all of the English words that appear in the article are embedded somewhere in the file, while specifications for formulas are set off either by $ signs (when the formula is set within text), or by $$ signs (when it is displayed). In addition to the English words and the letters in formulas, there are lots of cryptic combinations,' called control sequences , which begin with \. Some con- trol sequences, like Xtitle, Xtheorem and \al ign, tell TgX how to process the input which follows. Other control sequences are the names of special symbols; for example, Xpi stands for tt, and \int stands for the "integral sign" /in /^° . Once this file was produced, a few simple instructions told T^X to set the paper in a style suitable for preprints, on a printer that quickly and cheaply produces output suitable for proofreading, though a little blurry: C

5

C c

What Every Young Mathematician Should Know K. ELVIN

Institute for Haughty Attitudes April 1, 2001

The purpose of this paper is to call attention to a result of which many mathematicians seem to be ignorant. e~'i THEOREM. The value of f^a) dx is

c~ lS dx = \fz. /oo-oo

PROOF: We have (/->SX/_>S(E -^) ,oo = / / c xc y dxdy by Fubini J— cc J—00 /«oo / e-^A-v^dydx /oo-oo J—oo 2 c r rdrdO using polar coordinates '0 /"oo c~r\dr dO Jo/

—y- dO

Remark. A mathematician is one to whom that is as obvious as that twice two makes four is to you.

Hesearrh supported in pari t>y the National Snubliisliiir,*... FoiimlaLiuu.

c

,00 i

Once satisfied with the reactions to his preprint, the author submitted the paper to the journal (all he had to do was send them the original computer file). The journal gave T&X a few other simple instructions that -caused it to typeset the paper in the journal's style, this time on a high-resolution printing device that produces camera copy suitable for printing.* Had the journal rejected the paper, the authorcould have sent it (that is, the computer file) to another journal, which could typeset it in their style, using another brief set of instructions. C As you can sec, T^X appears to be awfully knowledgeable! To understand how it attained to such worldly sophistication, three levels of T&X ought lo be distinguished.

(1) Stripped-down T^X, without any frills, is a system for manipulating letters and other symbols, combining them to form horizontal lines (automatically adjusting C the spacing so that lines of text al) come out the same length), combining the lines lo form or displayed formulas (automatically adjusting them to the right heights), forming the paragraphs into pages, etc. There are control sequences like \hskip .sin, which is a "horizontal" blank space half an inch wide, and \vskip 3in, which isa "vertical" blank space 3 inches high extending c across the , and so forth. There arc also a lot of control sequences for setting mathematics formulas, since that is one of TsC's basic aims. For example, \sqrt instructs T£X to properly place the "square-root" sign y/~ around the symbols which follow (automatically adjusting the height and width of the y/~~ sign). You can tell TfcX the information about many "fonts", each of which specifies the exact chape of a large number of letters and symbols of a certain size and \rv style, together with certain other infoimation that typesetters traditionally like to worry about (like the fact that the T' and "i" in "find" are joined together into the "" fi). Once you have specified some fonts, you can create a paper by choosing a , inserting a certain \vskip from the top of the page, then a certain \hskip to indent the , then some text, etc., etc. (Actu'_rily, T£X makes things a little easier than that! can V TfiX be told at the outset that all paragraphs will begin with an Xhskip .sin, and a special control sequence indicates when a new paragraph is beginning.)

(2) Like any reasonable system, T£X allows you to define new control sequences in terms of old ones. For example, the control sequence \align, which tells Tsi C how to align the equal signs in a long displayed equation, was defined in terms of 6 or 7 other control sequences; use of the single control sequence \al ign obviously

♦Nowadays virtually all prim inn is done by phot.o-o.Tset. Until the advent of computer-run photo-typesetting processes, camera copy was produced by setting metal type, printing one copy, and then destroying the type! c

7

c

c f

saves a lot of time. Since Xalign will be needed so often, it would be silly to ask each user to redefine it. So I^X also comes in a deluxe model, equipped with a whole bunch of new control sequences, defined once and for all. C (3) Setting mathematics papers involves a lot of other formatting besides the proper display of formulas. For example, the words "Theorem" and "Proof are often set in a different type-style, they might be indented or they might be set flush, there might be an extra line of space between the statement of the theorem and the previous paragraph, etc., etc. What a drag it would be to specify c all these requirements every time a theorem has to be stated! The solution to this problem calls for the construction of control sequences like Xtheorem that contain all this information. But most 1&X users won't want to worry about things like this—there's too much to learn and it's too hard to do correctly! In fact, most users T^X won't even want to worry about what type style and type ( size they should use, especially since these things will depend on which journal the paper eventually appears in. This problem is handled by having a "journal independent" format, which was used, for example, in the file on page 3. The control sequences Xbeginpaper, \title and Xtheorem appearing in this file do not have unique definitions. Instead, different definitions for these control sequences appear in separate files that specify a preprint style or a specific journal style. The appropriate file is added to the beginning of the main file when we teli T^X to print the paper.

This third level clearly represents a much more specialized system, which we will distinguished by the name J.J\VJ-Toi; it is a particularly easy system to use because it concentrates on the limited job of producing papers for jour- nal;., or in a preprint style. The sporty level-one T^X is a vehicle for the high- performance enthusiast; _yUl_f-'_EX serves those for whom reliability and.ease of operation arc the primary considerations. _4.Jt.f-TEX users will hardly ever need the lower-level sequences, control like Xhskips and \vskips; in fact, these i control sequences should be avoided, because they may interfere with _-__4l,_f- TeX's automatic journal-formatting processes (appropriate warnings will be issued whenever the workings of such control sequences arc divulged). Despite its specialized nature, JJiVJ-TQi will do almost anything that a mathematician will ever need. Moreover, __Ul_r-T£j( comes equipped with one other feature thai greatly increases its versatility: there is an easy way of making changes in the preprint format, so as to produce a format of one's own. Thus, a single file can be used by JJkf-Tty for printing in any journal style, as well as in the author's own personal format.

(

(

C

8 _

This is basically a manual for using the specialized system _4._/.b_?-TfcX, al- though we will often refer to it familiarly as T£X, and adopt the more formal c name only when we want to mention a feature of the system which, is peculiar to _X_4l.lf-I}.;X. The main body of the text concentrates on the most important construction,, in typesetting, while side-trips into more esoteric matter arc set in separate paragraphs that begin with the road-sign 0 Studying .bis manual will probably be much more pleasant if these sidctrips arc skipped the first time through—so they have been printed in small type to c discourage you from reading them. On the other hand, whenever you sec the sign

C you should Stop, Look and Listen! Approach with caution, or you may be mowed down by an unexpected train of thought. In Chapter 1 we will !": :rn how to produce a file for TeX containing ordinary text, and we .Hi also heve the opportunity to run TEX, to see what the output looks like. Chapter 2 concentrates on mathematics formulas. Chapter 3 is also c concerned with running TEX, but in greater detail than in Chapter 1. Finally, Chapter A tackles more difficult typesetting problems, like matrices. These four Chapters contain almost everything you need to know (and quite a few things you may want to skip). The last Chapter is a little different: it tells you how to go about making

r modifications in the standard preprint style, so as to get a style of jour own design. You can even use this for .citing most parts of a book, but you will probably need a more comprehensive format, designed by a TEXpcrt, to take care of things like beginnngs of chapters. Now that we've finally gotten to books, it is appropriate to mention a few of limitations (these apply both to and to _/__-.-._.-T£X). C TEX's TeX (1) TEX cannot be called upon to prepare an index, or a table of contents. (2) TeX does not have a facility for automatically keeping track of the numbering of theorems and equations. (3) TEX will not split long footnotes into parts and distribute them over the succeeding pages.

9 There is no inherent limitation to TfiX that prevents it from incorporating these subsidiary features; they justdidn't seem worth bothering about in the first version. Most of them aren't very important for setting mathematics papers, but c they do become important for setting books, and help is on the way. There will soon be programs for setting the table of contents (which actually isn't very hard by hand), and for preparing an index (which is hard). The indexing program will still depend on the author's selecting the entries that should appear—deciding what should go in an index is too important to be left to a dumb machine—but T£X will do all the cross-indexing, alphabetizing, etc. An automatic numbering c system for theorems and formulas would be extremely useful (especially when the author decides to insert a new equation, which requires changing the num- bering of all subsequent equations, and also all references in tlie text to these equations!). Probably some one, out of sheer frustration, will produce such a program soon—one problem real is that different authors have different ideas v.. about how numbering should be done. THERE ARE, IN ADDITION, LOTS OF OTHER THINGS THAT T&X won't do. For example, there is no easy way to have TeX automatically set the first line of each paragraph in upper-case letters, or to have it set the print automatically in a specified special shape, as some poetry by Dylan Thomas appears, oh!

Etc., etc., etc. Aren't you glad that mathematicians don't care about such things!

(

C

c

10 c Chapter 1. Learning TftX's Lingo.

This Chapter explains the fundamental steps in preparing a TeX file contain- ing ordinary English text. Lots of exercises have been interspersed throughout C the text, to clarify certain points, or just to provide practice. In most cases, the answers can simply be written on paper and checked with Appendix A, but there arc also a few more extensive Exercises that call for the creation of computer files. These files will be used as the input for TeX, so that you will get a chance to sec some TeX output. c Before we begin, it's a good idea to take a look at the keyboard of your terminal, because we want to note which symbols are sure to be available (most terminals also have their own choice of additional special keys). The following symbols should all appear; any exceptions will be discussed below. First we have the upper- and lower-case letters, and the numerals: c ABCDEFGHI JKL.MNOPQRSTUVW XYZ abedefghi jklmnopqrstuvwxyz 0123456789

You're probably already aware of the fact that the numeral i has to be distin- c guished from the irwer-case letter 1, and that the numeral 0 has to be distin- guished from the upper-case letter 0. On some terminals zero appears with a slash through it, as 0, while on other terminals the letter 0 appears this way; you should have no trouble determining which is which, since the zero will be close to the other numerals. (Printing devices also have differing conventions about slashing the letter 0 and the numeral zero, which might conflict with the c conventions on your terminal. Sigh.) Next we have the symbols

f i ' [apostrophe or single right quote ) - (single left quote ) C () C ] /(slash) -() * (asterisk) which are used for , for writing numbers like 1,370.0003, for hyphen- ation and/or word-building, and for parenthetical remarks [possibly in brackets k"

11

C instead of parentheses]; on most fonfs the asterisk prints high* to serve as an indicator for footnotes. On your keyboard and screen, the quote marks * and * might appear as "genuine" quotes, deprived you ' and '. Don't feel if have less { aesthetically pleasing symbols—TeX will set them the right way. All terminals also have a double quote mark " (or "), but it hasn't been listed in this group because TEX has its own method for producing double quote marks. We should also mention that in addition to the hyphen - many terminals have a long horizontal line that appears on the screen as _ ( or underline). We will never use this symbol (not even to produce a sentence like this one). c Next come the few standard keyboard characters that will be used in math- ematics formulas:

-t- < > I

X The symbol I may appear broken, as ] , but TEX will always set it solid. T&X has control sequences to name all other mathematical symbols, including letters from foreign alphabets. Of course, English letters and numerals are also used in mathematics formulas, and most of the punctuation symbols arc used as well. For example, / is used in fractions like a/6, and the hyphen will be used for the minus sign in formulas, like x — y. However, Tj^X will use different spacing rules in mathematics, and the minus sign prints differently than a hyphen. Moreover, letter., arc normally italicized** in formulas. The fourth group of symbols that normally appear on every keyboard includes the following:

\ (bactelash ) < > $ & # % " (or ") O

Each of these symbols has a special usage in _A_s/V_._--'_eX; for example, as we mentioned on page 0-3, all control sequences begin with \, while $ signs or $$ signs arc used to set off mathematics formulas. This raises an interesting question: What if one is so crass as lo write a paper mentioning money (actual dollars and cents)—how can the dollar sign $ be intruded into the text? The answer is to use the control sequence Xs, which is the name of the $ symbol; as we shall learn in §3, all the special symbols can be named in one way or another. There is one further symbol that most users tend to overlook: pressing the

"Like this. **It is surprising how Tew mathematiciansare conscious of this fact!

12

.

C space bar produces a s3'inbol that appears blank on the screen. We will use the symbol C v whenever it is necessary to emphasize that the blank space has been entered We should also explicitly mention the (carriage-return) key, which moves the cursor down to the beginning of the next line. Prcs..i:ig (carriage-return) twice in succession produces a blank line on the screen. C Exceptions. If you have a peculiar terminal, one or two of these keys might not appear. Actually, as far as the internal workings of the machine is concerned, there is usually some combination of keys that will produce each symbol—but it might be something weird, like simultaneously pressing the control key and c the. space bar. (To find out things like this you will probably have to contact the people who sold you the terminal and scream.) J.J{J-I}^\ also provides you with control sequences for all these special symbols, in case you happen lo be the victim of such a clumsy arrangement. For example, typing \lq has the name effect, as far as X-.U-TeX is concerned, as typing the left quote X A complete list of these control sequences for missing keys is given in Appendix X (you'll c probably never need to look at it).

More Serious Problems. The general operating system on which you arc working has probably already assigned special meanings to certain symbols, and this is particularly likely with the symbols that Tj.]a treats specially. The wizards for :c your system will tell you what to do about this.

c

c

C

13 §1. Ordinary text. To set ordinary text you basically just type in what you want to come out, let and TEX worry about all the details. For example, suppose that you enter the ( following in your file:

This is the first paragraph of a 2,000 page document that has beon set by The System. The lines are automatically justified, i.e., they are c all set to the same length. To do this. The System inserts extra space between words, and/or hyphenates ones that are too long. ( But it can't correct errors.) C

Now let's get down to the nitty-gritty: how did The System know that it was supposed to begin a new paragraph here? Come, come, you really should be able to figure that out for yourself!

Using this input file, TeX will produce the following output: This i;; the first paragraph of a 2,000 page document that has been set by The System. The lines are automatically justified, i.e., they an; all sel to the same length. To do this, The System inserts extra space between words, and/or hyphenates ones thai are 100 long. ( But it can't correct errors.) Now let's get down to the nitty-gritty: how did The System know that it was supposed to begin a new paragraph here? Come, come, you really should he able to figure that out for yourself! Notice that the input lines can be of any convenient size; TeX automatically arranges them in paragraphs, with all lines made equally long. Similarly, extra spaces between words have no particular significance for TEX, which treats them as single spaces. The (carriage-return) at the end of a line also tells TeX to insert a space, and TEX then ignores any extra spaces that occur at the beginning of the next line. Although typists arc usually taught to leave two spaces after the punctuation marks :, ? and !, such niceties arc irrelevant to TEX, which uses its own judgement for the spacing after punctuation. But if you leave no space at all, then TeX also leaves no space, so that you can get expressions like "2,000"

( 14

(

C and "i.e.," in the output. On the other hand, the space between ( and But was a mistake, that caused an unwanted space in the output. TeX essentially set "(" c as a one-letter word; it might even have ended up setting "(" at the end of one line and the word "But" at the beginning of the next line! By now you've probably solved the paragraphing mystery. TeX ends a paragraph when it encounters a completely blank line (and it Btarts a new paragraph as soon as it sees the next letter). More precisely, TeX ends a paragraph C when it encounters two (carriage-return)s in succession; this produces a blank line on the screen. Of course, a blank line on the screen might really be the line

UULI consisting of three blank spaces (plus a (carriage-return))—in fact, it is easy to c end up with such lines when you use a text editor to delete all the visible portions of a line. Fortunately, this is no problem: TeX ignores the three blank spaces, since they come right after the (carriage-return) at the end of the previous line, so it still sees two (carriage-relurn)s in succession, and ends the paragraph. You can also leave as many blank lines in a row as you like, because TeX will ignore c "paragraphs" that are only zero lines long. Blank lines are not the only way to indicate the end of a paragraph. TeX will also end a paragraph when if encounters the control sequence Xpar, which has exactly the same significance in its mind as two (carriagc-return)s in succession. Suppose, for example, that we append our file as follows: c. out for yourself! Xpar Now we are in the third paragraph. For \sl.oo you can have a copy of this document.

Our output will then be appended as follows: ic

you really should be able to figure that out for yourself! Now we are in the third paragraph. For $1.00 you can have a copy of this document. ,c In this final paragraph we introduced the control sequence \$ in order to contrast it* with the control sequence Xpar. TeX recognizes two different kinds of

♦Recall that \$ is the name of the symbol S. If we had carelessly typed $ rather than \s, then TeX would have thought that a mathematicalformula was beginning, and it would have searched vainly for another $ sign to tell it where the formula ended! X

C

x

15 control sequences. The first kind, like \s, consists or \ followed by a single non- letter . The second kind, like Xpar, consists of \ followed by a string of letters, without any other symbols mixed in. No other possibilities arc allowed. So, for r example, neither \sa nor \par3 can be a control sequence. Control sequences of the first kind arc especially convenient to use, because there can never be any ambiguity about where they end. It is perfectly safe to type \si . 00, because there cannot be a control sequence \sl or \si . 0 etc. It is also OK to type \s|_li.oo (if you prefer keeping your control sequences segregated), c but the output will still be "$1.00": TeX always ignores any additional spaces after control sequences. So what do you do if you specifically want the output "$ 1.00", with a space between "$" and "1"? One possibility is to type \s\Ul . oo r using the control sequence \u (that is, X followed by a blank space). Here \l_j is the name for a blank space of output text; it is a control sequence of the first kind, just like \s. Exercise. What would you type to obtain the output "$ 1.00", with two spaces between "$" and "1"?

SIDETRIP. The control sequence \u specifics the amount of space that goes between words in ordinary text; it is actually a variable amount of space, since TeX has to stretch or shrink spaces when it adjusts the lengths of lines. On the other hand, the control sequence \. specifics a blank .pace which is exactly the width of any numeral 0, 1, . . . , 9 (each numeral is surrounded by a certain amount of non-variable space so that they all have the same total width). This can sometimes be useful for setting displays like $ 1.36 512.98 $ .17 which we'll learn about later. Control sequences of the second kind, like Xpar, require a little more finesse. Notice that in the input line

out for yourself ! Xpar Now the space after Xpar was necessary; without it, TfjX would have thought that we were trying to use a control sequence named XparNow. Of course, you can always (

C

16 » leave more than one space after Xpar—extra spaces will simply be ignored. A control sequence of the second kind is also ended automatically by any non- c Ititer . If we had appended our file to read out for yourself!\par\si .oo is the price of this document.\pari buck will get you a copy. c the output would have been appended to read

you really should be able to figure that out for yourself! $1.00 is the price of this document. c: 1 buck will get you a copy. Exercise Now that we've settled the matter of control sequences, we can turn our attention once again to literary matters. First cf all, single quote marks are produced in the obvious way: the input ' produces ' and the input * produces X To produce double-quote marks, you simply type two single-quote marks of the appropriate kind immediately in succession. The input

so that's how the letter *A' is produced!

C produces "Oh, so that's how the letter 'A' is produced!" are also important literary devices—as in sentences like this one. A is not the same as a hyphen or a minus sign. In fact, carefully printed mathematics books have , minus signs, and two kinds of dashes, an -dash - and an -dash — (traditionally the width of a capital N and M, respectively). En-dashes arc used for number ranges, like "pager J. 3 -3d", and also in contexts like "Fig. A-12" or "equation (3-4)". Em-dashes are used for punctuation in sentences—they are C the kinds of dashes to which the author of this manual has apparently become addicted. These different symbols can be produced as follows:

for a hyphen, type a hyphen (-); for an en-dash, type two hyphens ( —); for an em-dash, type three hyphens ( ).

17

C

c

Oh, * Notice that there arc usually no spaces on cither side of hyphens or dashes; don't put any into the input file unless you really want them to appear! As we have already indicated, a hyphen will automatically be turned into a minus sign when it is used between the $ signs which indicate mathematics formulas (in which case you won't have to worry about spaces, bcause TeX's own mathematics spacing conventions will take over). We mustn't omit mention of another literary device, the "ellipses" or three dots (. . .) which indicates an omission. If you simply type thrc-. periods in a row, the output is "...", with the dots too close together. So X/I_.f-'_EX gives you the (. control sequence \dots to help you. The input

Hmm \dots how do you space the dots?

produces "Hmm . . . how do you space the dots?" Thecontrol sequence \dots not only gives the right spacing between the periods, it also takes care of the spacing on cither side of them. It doesn't matter whether or not you leave spaces between Hmm and \dots; any spaces you leave are disregarded by \dots. (Of course, the spaces after \dots are certainly irrelevant, since they follow a control sequence). Exercise . . .

The most important literary devices are undoubtedly boldface print and italic print; and there's also slanted print (whiclfis a rather recent innovation). You can change to these fonts by using the control sequences \bf, \it and \sl; the control sequence \rm returns you to ordinary (roman) type. Thus, the input Don't .onfuse \it emphasising \rm something with boldly \bf asserting \rm it. produces the output Don't confuse emphasizing something with boldly asserting it. If the format you are using doesn't have slanted text, _..Xr_.f- TEX will substitute italic text instead. And if X/M-TeX happens to be setting text in a different type-size (as in a footnote), it will automatically choose the proper size type for the italic, bold, or slanted font. Despite these amenities, you might resent having to include al! the extra \rm instructions. They're certainly a nuisance to type, and an omission can be disastrous—you might end up with pages and pages of italicized words instead of just one! Fortunately, there's a way of switching fonts that's much better for most purposes. Use the input

Don't confuse {Ait emphasizing} something with boldly {\bf asserting} it.

18 The braces < and > are always used to "group" things in TeX input. They are used extensively for setting mathematics, but they also serve very nicely here X? to let TeX know that <\it emphasi7.e> and -C\bf asserting} arc separate groups within the ordinary . Grouping is also useful in many other situations. For example, we indicated before that \s\Lii.oo % produces the output "$ 1.00". Another possibility is to type <\s>ui . oo with the braces isolating the control sequence \s. In this sit>- .lion, the blank space is taken seriously, because the rule for ignoring blank spaces after control sequences is applied only .} C within the group -C. . that contains this control se- quence. (So if you type <\$U>Ul . 00, the first blank space will be ignored, but the second one won't be.) Exercise. What output would be produced by the input ■C\s}_JUl .00? Another way to get the output "$ 1.00" is to type c \sOui ■ oo using an empty group; the <} combination is a group of no characters, so it produces no output, but it still isolates \$ and ends TEX's mission to search out and destroy extra blank spaces. The empty group <} may seem like a cheap trick, but it has loto of neat uses, and is sometimes almost indispensible. x. Exercise. What can you type if you want the output to contain two hyphens in a row? (You can't type — , but there arc many possible solutions.) Finally, what about the most primitive method of emphasizing text, by means of underlined words? Basically, you shouldn't use it—that's why was invented! Underlining is really meant for mathematics formulas, where c letters or short expressions might be underlined, as in the formula x + A(z). As we shall see later, it is also possible lo underline individual words, but TeX will not lake a whole bunch of text, underline each word, and then arrange them in paragraphs. (Moreover, the letters g, j, p, q and y cause problems.) If you really want underlined text, you should use a "underlined font", in which each letter already has an underline as part C of it. Well, this has turned out to be a pretty long section, partly because literary folk have invented so many devices, and partly because TeX has so many devices to deal with them. Why not take a rest and come back some other time to work the following Exercise? It calls for the creation of a computer file, which we will use in the next section to get some output. C TeX

C

v

19 J §2. A first run. Although we've only covered the rudiments of TEXspcak, it's time to take a little break, lie back, and let the computer do some work. You produced a file at the end of the last section; we'll ask .>._>.-. if-T^X to process it and see what happens. This section is necessarilly a little imprecise because the details involved in running A/t_lf-TEX depend on the particular operating system you are using. To be specific, we'll describe a run in the TOPS 20 system, and indicate the places where changes might have to be made for other systems—you've probably been provided with a supplementary page explaining justwhich changes are necessary. First of all, the file which you constructed is not yet in a suitable state to be submitted to Xy.l>_f-TEX- To prepare it properly, first add the lines Xinput amstex C Xinput preprint Xbeginpaper Xbegintext

(in this order) at the beginning. The line Xinput amstex tells TeX to read in the file that contains all or _/DH>_f-TjEX's special features, and the line Xinput preprint tells TEX to read in the file that describes the standard "preprint" format. Between Xbeginpaper and Xbegintext we can put things like the title, author, etc. Jus;, for the fun of it, let's insert

Xtitle Our Very First Attempt to Make The System Turn Out a PaperXendtitle between Xbeginpaper and Xbegintext. The control sequence \endtitle serves the function of telling _*-TeX where this (absurdly long) title eilds, without having to put it in braces; as you can see from the file on page 0-3, similar constructions are used in several other situations. At the very end of your file you must add the line Xendpaper (carriage-return)

It is absolutely essential that you have the (carriage-return) at the end of the last line (so that the cursor moves down to the next line). If you forget it, then TEX will never actually finish reading the last line of your file, and you'll be stuck in TEX for all eternity! Finally, your file has to have a name—we'll assume that it is named paper . (if your operating system doesn't allow such names, one or two details will change .

<

_-__.

110 later on). Now that the file paper.tex has been created, you can leave the editor. Once again you are in communication with the operating system, which has given you a prompt sign—to be specific, we'll assume that it's the symbol O. Now we're ready to go! First you have to ask the operating system to run TeX. To do this, you type tex (or perhaps run tex, or something of that sort). [Actually, you might encounter a problem before you even begin: TeX sometimes places such heavy demands on the computer's capabilities that your system might ( require TeX jobs lo be done in batch mode. For the moment, however, let's assume that you can sit at the terminal and have T)^_ talk to you.] After it has been invoked by the proper incantation, including the (carriage-return) at the end of the line, TeX will prompt you with an asterisk (*). Type c Xinput paper

This tell. TEX to read in your file. Notice that we type Xinput paper to process the file named p3per.tex (with other operating systems this arrangement may be different). As soon as you press (carriage-return), TeX will start to read your file, and when it sees the first line, Xinput amstex, it will dutifully in i read the appropriate file of AJU'S-Tj^'s special features. TeX will print a not very scrutiblc message to indicate that it has read the file, and then on the next line it will ask you a question:

C *\input paper amstex Do you want output? (y or n follow answer by return)

What's the meaning of this—what's the of running TEX if you don't-get output? Well, you might have made a serious error, like omitting a } somewhere, or spelling a control sequence incorrectly, so that TeX doesn't recognize it. In such a case, TEX will become confused, issue an "error message", and wait for further instructions. So it's often a good idea lo first let TeX coldly appraise your file without asking for output. Chapter 3 discusses error messages in greater detail- -for the present we will simply assume that the file paper, tex contains no errors (check it carefully against the answer in Appendix A, and for heaven's sake, don't forget the \cndtitle at the end of the title!). Let's cross our fingers and ask for output: on the same line as the question, type y followed by (carriage-return). TEX will return to your file, read in the "preprint" file as instructed, print another message lo assure you that it has done C so, and then continue to talk to you. Soon (if your system isn't too overloaded)

111

X

«

Qtex your screen will look like this: Otex *\input paper r . . . amstex Do you want output? (y or n, follow answer by return) y . . . preprint ... Overfull box Overfull box [i] c Execution completed.

The [1] tells you that _4._4._f- TeX has processed enough of your file to make one page, which has been numbered "1"; no other numbers appeared, since the c output for the whole file will fit on one page. Once TfiX finished processing this page it gave you an Execution completed message, and returned you to the operating system, with its prompt ©. Assuming that paper.tex was error-free, no other messages should have appeared on the screen. But what about those Overf ul 1 box messages? These are "information messages", rather than "error ( messages", telling you that something is too big to be set properly. You haven't actually made an error—you've simply asked TeX to typeset something that won't fit where it's supposed to go. For example, \title . . . \endtitle specifics a one-line title (we'll learn later how to produce multi-line titles); the first Overfull box message arose because our title is too long to fit on one line. You'll have to take a look at the output in order to see vhat TeX did with the title, and to" discover why in the world one of the other lines was too long, thus generating the second Overfull box message. Now how do you actually get the output? When TeX flashed its Execution completed message, it had just constructed, and placed in your directory, a new file called paper, dvi. is "device-independent" This a file that can be used, ( with suitable supplementary programs, to run a Versatec, Varian, Alphatype, or any of several similar printers. If your operating system is particularly gracious, it may have automatically sent paper, dvi off to be printed; a message will probably appear on your screen telling you when your job is completed. But in most cases you will have to tell the system to print your paper. For example, on the TOPS 20 system, to run your file on a Versatec you type V vspool paper

—the system automatically interprets this as paper .dvi. Once you hit (carriage- return), the system will convert each page of the dvi-file into a file that runs the (

112

C

( t Versatec, and print out the numbers of the pages as they are completed

© vspool paper [1]

Now it's just a matter of waitingfor the printer to be free, so thatyour paper will actually be printed. There's probably some way for you to find out how many c pages are before you in the qucu^for the printer, and the system may flash you a message when your page is actually printed. We'll want to examine the printed paper carefully, so you should go pick it up as soon as possible. Before you do, however, remember that there's a new file paper . dvi in your directory—it has now served its purpose, and you probably want to delete il. But don't delete c paper . tex—we'll want to make some changes in it. [If your system doesn't allow you to call upon TeX from the terminal, you should submit a job control file to batch mode in the usual manner. Note that the y should be part of this file. Pick up the paper the next day, or whenever possible.] Once we have the printed output in hand, we can immediately sec the reason c for the first Overfull box message—the title extends beyond the margins. If the title had extended right off the paper the output would probably be pretty garbled, since most printing devices wrap the extra pieces around to the other (some printing devices just give up, and leave the line blank). Even though this overfull box isn't an "error", it certainly wants some fixing. One possibility c is to display the title on several lines, as explained in §5; for example, we might decide to break it as follows:

Our Very First Attempt to Make The System Turn Out A Paper C Clearly TeX can't be expected to do this formatting automatically—it requires an aesthetic decision (including capitalizing the word "A"). Our problem can also be solved immediately in another way—by choosing a more sensible title! So let's go back to the file paper.tex and change the title to "Our First Attempt". c The second overfull box is less conspicuous—il is the line ending with the word "Asterisk*" extending just a little beyond the margin. TeX didn't try to hyphenate "Asterisk*", even though it did hyphenate the word "asterisk" in the previous paragraph, because it never fools around with a "word" that contains upper-case letters or non-letters, like asterisks. Consequently, il was stuck with a line that it couldn't shrink down to the proper length, because the inter-word C

C

c

Q

113 spaces would have become too small; moreover, it couldn't move the final word to the next line because then the inter-word spaces would have become too large. What rotten luck! (Requiring innumerable hours for the author of this manual to fabricate.) Note also that better line breaks might have been possible if the word "*********" had been hyphenated on the previous line. TEX will sometimes miss such opportunities because it doesn't search through the dictionary to find all legitimate hyphenations— this consumes too much time and memory but C relies instead on some special rules which almost always work. In rare cases, like the present one, minor repairs will be necessary. Again, one possibility is to do some rewriting; in fact, careful authors will often resort to rewriting to make something appear better in print. It is also possible to give TeX a little help with its hyphenation. For example, in paper.tex you can replace and Asterisk* by ********** *****X-***** and As\-terisk* The control sequence \- indicates a "discretionary hyphen", a place where a word may be hyphenated if necessary. After inserting the discretionary hyphens into paper.tex, try printing it once again. This will provide a good review of all the steps that are involved in running J.JH>'J-T&. You will want to examine the output carefully to see how it was affected by the changes. Afterwards you can read the following consoling remarks.

In practice, missed hyphenations are quite rare, so you will seldom have to use TEX in this "in tractive" manner. Moreover, when proofreading the output from TeX, the amount of work needed to discover any hyphenation errors* is negligible compared to the amount ofwork proofreading already involves. Finally, _-.Jl.f- TEX keeps its own dictionary of troublesome words that commonly occur in mathematical works, but which aren't covered by its hyphenationrules; from tfme to time this dictionary will be expanded as the experience of its users dictates. It has perhaps not escaped your notice that the fancy word "interactive" was just a euphemism for "trial and error" . In the forsccablc future, however, TeX will have an additional feature making this word far more meaningful. As you type the input, TeX will display the output on the screen as it xvill actually appear on the printed page! So errors and overfull boxes will become known the moment they arise, and they can be corrected before anything ever gets printed. With

*On very rare occasions you may even find a word which T^X hyphenated incorrectly. You can easily (ix this hy typing the word with discretionary hyphensin the right places, since TeX won't add any hyphens to a word with discretionaryhyphens. You can evenput a discretionary itynhen at the end of the word if want to he sure that it, isn't hyphenated at all.

114

(

\

you this Utopian prospect before us, let us return to some of the humdrum details of typesetting.

115 41 §3. Special symbols and diacritical marks. Recall that the symbols r \<> $ * % & have special uses in X^-TeX, so some finagling is required to make them appear in the output. We know that \$ stands for the dollar sign $. Most of the other special symbols are produced similarly: r

Die input produces the output \< { \> } \$ $ ,4 C

% ,0

The undirected double quote mark " hasn't been added to this list for the simple reason that it really isn't a symbol at all—on most fonts it just doesn't appear, since printed books use directional quotes-"and ". (The undirected quote " docs appear on the font used for setting the input portions of this manual, but that's another story!) If X/M-TEX ever gets it into its head to add " as a special symbol, it can be named by some control sequence like Xquote (the obvious candidate.\" already has a special meaning, which we'll learn about soon). The backslash \ is another symbol that doesn't appear on any literary font. But \ is a fairly common mathematical symbol; in fact, it is used in a couple of different ways. Appendix S lists the special control sequences for this symbol. This leaves only the "tilde" or "squiggle" ~ to be accounted for. There is a large squiggle ~ that is used mainly in mathematical formulas, like A ~J3—it too has a special control sequence to name it, listed in Appendix S. The more common literary use for the tilde is as an accent or diacritical mark over letters in certain foreign words, like "canon". In fact, a whole slew of special symbols and diacritical marks is needed for foreign languages which still basically use the roman alphabet. If you are an English literary chauvinist, you might be tempted to skip the rest . of this section—after all, you can always type the usual sloppy approximation to non-English words and names, watch your foreign colleagues fume, and trust the journal editors to worry about details. But remember that accents are also used for mathematical symbols, like x, so you can't ignore it completely! (Accents in mathematics formulas arc treated in more detail in Chaptcr2§ll.) (

V.

(

,#

116 c

»- » The following control sequences will get you special symbols needed in foreign languages: C input output C (German letter ss) _c (Latin and Scandinavian ligature ac) JE (Latin and Scandinavian ligature AE) oe (French ligature oc) c

For example, if you want to specify "jC^op's CEuvres" you can type C \AE sop's \OE uvres

Notice that the spaces after the control sequences are necessary. Another way to separate them would be to type c "C\AE>sop's <\OE>uvres This looks a little nicer in the file, but it's harder to type. The following accents arc presently available (notice that spaces are not necessary after the control sequences of the first kind): c input output Vo - 6 (accent grave) \"o 6 (accent aigu, acute accent) \A o 6 (accent circonflcxe, circumflex or "hat" accent) \v o 6 (Slavic accent, inverted circumflex) \u o 6 (breve, short vowel) c \=o 6 (macron or bar, long vowel) \"o 6 (umlaut or double dot) \H o 6 (long Hungarian umlaut) \s o 6 (tilde or squiggle) \t oo 6b (tics two letters together) \Scan a a (Scandinavian a with circle) \Pol 1 1 (Polish crossed 1) \Ced c c (cedilla accent) The last three examples arc shown with letters other than "o" because they are somewhat special. The Scandinavian accent is shown over an "a" since "6" isn't C

117

C

( « a Scandinavian letter. Similarly, the Polish accent is specifically designedfor the letter "1", and cedilla accents arc usually associated with the letter "c". These control sequences can also be applied to capital letters. For example, r \"0 produces "6", \Pol L produces "L" and \Ced C produces "C". The input \Scand A produces "A", with the circle touching the "A"; this is the preferred symbol, traditional in Scandinavian books. If you want "A", use \hScand A to set the circle higher. There is only one little detail that won't take care of automatically. T&X C When the letters "i" and "j" arc accented, it is customary to use the undotted symbols "1" and "j". You can get these by typing \i and \j, respectively. For example, to obtain "minus" you would type m\=\i n\u us. Sach type style hag its own accents, and yon can even miv th*"-

■C\it \'E> \'E Et \bf \'E t \bf\'\rm E E

CAUTION. Accents apply to only one letter, except for \t, which applies to a pair of letters (with no space between them). If you try to type \'{ab> you'll get an error message. In fact, you'll get an error message even if you try to type \'! Usually, TfJX will simply ignore superfluous pairs of braces. But extra brace:-, can cause problems in certain special situations, like this one: After an ac- cent, T|?X immediately looks for either a letter (or pair of letters) or a font change instrucUion, like \it, followed by a letter. So you also can't type \bf\'<\rm E> or <\bf\->\rm E. Another thing you can't type is something like \A\=x or \A<\=x>; in other words, you can't get an accent over an accent, as in the symbol i. (But you can do this in math formulas—sec Chapter2§ll.) Exercise . .

C

C

118 §4. Footnotes and further flourishes

C We're tantalizingly close to a complete command of jt^t_'-T£X's ordinary text-setting capabilities. The most important remaining topic is one that you're probably already wondering about—footnote construction. It turns out that it's quite easy to get a footnote, but it's a little tricky to get two of them! The first footnote on page 1-2 was produced by the input

C prints high \footnote *\\Like this . \endf ootnote to serve

(It might be nicer to enter this in the file as

prints high \f ootnote *\\Like this, \endf ootnote Q to serve . . .

for the sake of clarity.) The control sequence \f ootnote processes two elements, the footnote indicator (*) and the footnote text (Like this); it automatically places the indicator both at the end of the previous word ("high"), and at the ( beginning of the footnote text v/hen it is printed at the bottom of the page. Since the indicator goes between \footnote and \\, while the footnote text goes between \\ and \endf ootnote, the control sequence \footnote always knows exactly which part of the input text is the indicator, and which is the footnote text—that i> why it was unnecessary to type "i- l£X uses constructions of this sort for most control sequences that process a lot c of input. It doesn't matter whether or not you leave space(s) before typing\f ootnote. The control sequence \footnote automaticallyplaces the indicator right next t_-jLLLe_jDr_^oJ_J_^^ __£Jcr_li_Ao£jiQ±_a_.

/ SIDETRIP. But there is one little detail that you will have to attend to yourself. Normally, fottnotc indicators go after punctuation. If, for some reason, you want to put the indicator right before some punctuation*, say a comma, you can't type punctuation c \footnote*\\Like this. \endfootnote, say a comma, . . . because you'll get a space before the comma! In this situation you'll have to use [he control sequence \unskip to get rid of the space that would normally be

C "Like this.

C

C

■*,

119 skipped:

punctuation \footnote*\\Like this . \endf ootnote\unskip say a comma, . . .

For the second footnote on page 1-2 the author of this manual originally typed (

italicized\footnote*\\lt is surprising ... \endf ootnote in

since he didn't know that it would come out on the same page. This gave two footnotes with the same indicator "*". Even worse, there was another horizontal line before the second footnote! So the input was changed to C

italicized\sfootnote**\\lt is surprising. .. \endsf ootnote in

using the control sequence \sfootnote, which is meant for all successive foot- notes on the same page. T£X simply won't do such things for you automatically; this is another situation where }>ou will have to use T£X interactively, making a minor change after examining the first output. It shouldn't arise very frequently, because extensive footnoting is regarded as very bad style in mathematical works. CAUTION. Long footnotes are likewise considered to be bad style, and they are also dangerous, sin-.e Tj}_ won't split up a footnote for you. If you ask for a footnote that is too long to fit on the current page, TjtX will cut the current page short and transfer the line containing the footnote indicator to the top of the next page, which will also bear the footnote itself. Extra space will be inserted between lines of the current page in order to make it come out to the right size. When you see how bad this looks, you will have to go back and split the footnote in two.

Exercise. What do you do with the second half of the footnote? In other words, how do you get it to appear at thebottom of the next page, without any indicator? Should you intend to ignore our sage advice against extensive footnoting, you will probably want to use numbers as footnote indicators. They should be £&ta_L&^^ so you will need to look at Chapter 2§2. (If you elect to print all the footnotes together at the end of a section, \f ootnote shouldn't be used at all; just add the instructions for the superscript numbers in the right places in the text, and type all the footnotes at the end.) (

X

c

,*■

120 _ SIDETRIP. In addition to the asterisk * you can use any of the favorite literary symbols §, f, $ and as footnote indicators. Each of these symbols is named by a special control sequence, listed in Appendix S. Notice, however, that on most fonts the asterisk already appears in the position of a superscript, while these other symbols don't. If you want them as superscripts, see Chapter 2§2. The remainder of this section is a potpourri of minor points, listed roughly in order of increasing arcanencss. It's really one long sidctrip, and you might just skim through it, to get some idea what's there. But if you are determined to master all this material, the final Exercise will provide the ultimate test. It calls for the construction of a file that uses every little point that has been raised in this Chapter.

C We've already pointed out that basic spacing controls like \hskips and \vskips should hardly ever be used with J.X!__f-TEX, since all the formatting is done for you. But occasionally you might want a little more control over AM>!f- T^X's spacing, and then you may have to resort to them. We'll take up horizontal spacing and vertical spacing separately. 1. Horizontal spacing (\hskip): If you type \hskip iin in the middle of a paragraph, the output will have one inch of blank space at that point. Units other than inches can be used, but we will not discuss them until Chapter 2, which is concerned with setting formulas. Mathematics formulas are almost the only places where you will ever want to request specific horizontal spacing, and even then you will probably use one of the special control sequences that T£X c has provided. for this task. So \hskips will be very rare in your files. CAUTION.Don't type Xhskip -Clin}! Thebraces arc not merely unnecessary— they'll actually confuse T£X completely. When T£X sees \hskip it immediately looks for a number, and then for a unit like in. This is another of those spefcial c situations, like accents, where extraneous braces will cause trouble. CAUTION. If you ask for an Xhskip lin, but there's not quite an inch of space left on the line, you will get an Overfull box,. SIDETRIP. There is one Xhskip that is useful when mathematical formulas appear next to each other in a "literary" , so we will introduce it now, c even though we won't learn how to type math formulas until the next Chapter. A sentence like For all x, x2+ 1 > 0. is a little confusing when read quickly, because the symbols x and x 1 -\- 1, which c belong to different clauses, tend to merge into one long math symbol. Some

121

C

c

\< ■F authors will carefully avoid such constructions, writing for example,

For all we have x 2 x, -f- 1 >0. r But many authors don't (and such devices do tend to make the text wordy). The control sequence Xxskip gives a small Xhskip that can help make things clearer. If you type

For all $xs,Xxskip $ ( you'll get For all x, x 2 -f 1 >0. It doesn't matter whether or not you have space(s) before Xxskip—JLJk>'S-Tsi will automatically adjust for this. c SIDETRIP. There are other situations where \xski ps can be used to give a little extra professional gloss to the finished product. For example, in this manual an Xxskip i. left before and after parenthesized sentences. (Like this one.) Thus, the author typed

sentences . Xxskip (Like this one.)\xskip Thus

2. Vertical spacing (\vskip): A \vskip will be useful if you want to leave some extra space between paragraphs. For example, you might want to leave 1.5 inches of space for a hand-drawn diagram. To do this, type

. . . end of one paragraph, \par\vskip i.sin Start of next paragraph . . .

CAUTION. Don't type \vskip {1.5 in}; IgX expects to see a number right after Xvskip. CAUTION. Notice that the Xvskip goes after the Xpar! T^X won't allow you to put a \vskip before the Xpar, or anywhere else within a paragraph. Until it sees a Xpar, l£X is constructing horizontal lines of text, and a request for a vertical space within one of these horizontal lines will be very unnerving. CAUTION, \vskips can cause the same problems as \footnotes. If you ask for a \vskip i.sin when the current page has less than 1.5 inches left, TfjX v/ill cut short the current page, just as it would for an overly long footnote. You can then try to shorten the space or put it somewhere else; as a last resort, try deleting some of the deathless prose in the preceeding paragraph. (

122

C

( SIDETRIP. There's another way to get blank space in the output without having to worry about this problem. The input C ar\topinsert<\vskip I.sin}

will end the paragraph, and at. the same time reserve 1.5 inches of space cither at the top pa.cc of the current fif there is room., or at the top of the next oafc. Even if the output isn't quite what you wanted, it'll vC X be ry easy to fix. If the blank space comes out on the next page, then there just wasn't room for it on the current page, so it's probably just where you want it. On the other hand, if the blank space ends up at the lop of the current page, then you at least know that there is enough room for it en the current page, and now you can change

X \par\topinsert-C\vskip i.sin}

to XparXvfikip i.sin. Now thai, we've covered spacing fairly thoroughly, we'll mention two other devices that you will find useful. C 3. Sometimes you might have to start a new line of input textright in the middle of a long word. You certainly don't want to hyphenate it, because TrrX will assume that your hyphen is part of the normal spelling of the word. In this situation, use the control sequence jy., which .tells TirX not to count the succeeding (carriage- return) as a space: \r I can't even <\it find} the word antidisestabl\ ! ishmentarianism in the dictionary!

Here's another neat application:

In sentences with dashes \! like this one there shouldn't be spaces before or after the dashes.

4- Wjjen^^^TrX sees the symbol %, it effectively c ignores it and everything £fe__J__-_L_____e_4___j^^ This allows you to insert remarks that you don't want to appear in the output:

by Schwartz's Lemma. %Is this how you spell Schwartz? c

v

123 CAUTION. What actually happens is that JUVS-TpX interprets % as a (carriage- C£tuxn). This can produce problems if you have a whole line of comment, as in the following:

. . . This is some text. JJ This is a very long % comment, that spills over onto another line. This is more text . . .

This input textwill cause JJUf-TpX to sec two(carriage-return)s in a row fnamel C the two % signs); so TpX will start a new paragraph! (And if you do something like this while setting an equation, things will get very confusing, since you're not supposed to start new paragraphs in such situations.) To be on the safe side, always precede comments_h_y_-somg t.pxt: C This % This is a very, very long is % comment that has had to be split up some %onto three different lines text.

% Now come some more subtle points. 5. The input

This is <\it italics}: this is roman.

produces "This is italics : this is roman." with the slanted "s" toppling over onto the unslanted ":" which comes immediately after it. The control sequence \/ will add just the right amount of extra space:

This is -CXit italicsX/}: this is roman.

CAUTION. Be sure to put the \/ right after the s, without any intervening space! You will want to use \/ whenever a slanted letter is followed immediately by a tall unslanted character, like ; ? ! ) j and also " (as the author ruefully found out 7 lines ago!). You will also want to use \/ when a slanted letter is followed immediately by a roman letter (this might happen, for example, if you only italicize the prefix of a word). .

124

{

( C. Sometimes you will need quotes within quotes, as in "They call this 'typesetting'" he sneered.

It won't do to type

\typesetting'<" '} he sneered because not enough space will be left after the single quote—you'll get '" which looks almost like three equally-spaced single quotes. On the other hand, "U" will leave too much space—and T^X might even start a new line at such a space! The control sequence Xaspace will solve this problem. Type

"typesetting' \qspace"he sneered.

You will also get the correct spacing in any of the legitimate combinations

spac t> t

s v t space" * ' " It doesn't matter how many spaces you leave ridit before Xqspace— AAVS-T\i?. will automatically adjust for this. % At this point we begin to pass from the sublime to the % ridiculous. 7. When T^X adds extra spacing to adjust the length of a line, it tends to put more space at the ends of sentences than between words, because this looks better. But periods also occur after , as in "D. E. Knuth". So T|?X doesn't put extra .pacing, after/ periods which follow upper case letters. Pretty clever, huh? Well, it doesn't take too long to think of situations where this isn't clever enough, (a) TftX can't be expected to know that the periods at the end of

i.e. cf. etc. Proc. Amcr. Math. Soc.

indicate abbreviations, rather than ends of sentences. The easiest solution to this c problem is to use the control sequence \q mentioned in §1. If you type i.e.Xu cf.\U etc.Xu Proc . \UAmer .UMath . \uSoc . \u

tkc_Ll_-X-VdlUnseri_ordina inter-word spaces, rather than the somewhat larger spaces that occur after a period. C

C

125 L

(b) We hate to mention it, but sometimes periods after upper case letters are ends of sentences: Whose out there writ- ing all this crazy stuff? It is I. Supported in part by the NSF.

Try some empty groups:

. . . It is 10. . . .by the NSF-Q .

SIDETRIP. We've already mentioned that you will need to use the control se- quence \unskip after \footnote. . . \endf ootnote when a footnote in- C dicator is placed right before some punctuation. A less critical problem arises if you want to put a footnote indicator on the last word of a sentence.* Since the period no longer occurs at the end of a word, T£X won't know that the sentence ends there! So it will leave only the usual interword spacing, instead of the somewhat larger space that normally goes after a period. If you really want to worry about this, you can use Xxskip (page ??): type

of a sentence. \f oobnote*\\Af ter the period . \endfootnote\xskip Since the period . . .

8. Following normal printing conventions, T£X allows sentences with a dash— like this one—to break just after a dash. But it usually won't break a sentence —as this one is broken—by starting a line with a dash. Breaks before dashes are regarded as very bad style, but conceivably you might have to resort to one in order to avoid even worse breaks somewhere else. If you want to allow a dash to occur at the beginning of a line, just type an empty group right before it

O

TfX has nothing against breaks before an empty group, if that's the way the paragraph crumbles.

*After the period.

C

126 r

» 9. We've purposely delayed explaining a point that may have been bothering you for quite some time. If you want an unindented paragraph, type Xnoindent C input £i&ht before the which bepjnsjt. For example, the unindented paragraph (b) in topic 7 was produced by typing

after a period, \par\noindent (b) c Notice that we still have to finish the previous paragraph with a Xpar or a blank line. You really shouldn't ever need to use Xnoindent, because JUkS-Tffi. docs all the formatting for you. CAUTION To start this topic we really typed something like f of the game.\par\vskip . iin\noindent9. We've

to get the extra space before the unindented paragraph. But this device should be used very, sparingly! Remember that you don't want to add instructions that will defeat X/IW-'iLX's journal formatting feature! If you arc setting a paper in the c preprint style, but you want all paragraphs to be set unindented and prececded by a certain amount of space, you shouldn't add a lot of \par\vskip .iin Xnoindents. The proper course of action is to use ordinary \pars or blank lines, but to make a change in the preprint format itself, as explained in Chapter 5! Then your input text can also be used by any journal to set the paper in its style. %0h well, we might as well reveal other control sequences % that shouldn't be needed. 10. You can get a centered line of text by typing

\par\ctrline-C. . . }

*-. Bc_surc_> put Xpar before Xctrline (a Xvskip can go before or after the Xctrl me).

11. Suppose that you've just finished a section, and you want the next section to begin at the top of the next page. Type C \par\vf illXeject

right before the input for the next section. The \jpar ends the last paragraph of the present section, the Xvf ill fills the remainder of the page~ with vertical C and thcAej^ct^a^uMLy^njlUh^jiage.

127

<

Sfiace, . Occasionally you might want to use \eject without the \par\vfill preceding it. For example, suppose that page 3 happened to get two footnotes on it. When you change the second \footnote to \sf ootnote, some vertical space will be deleted, since there is some extra vertical spacebefore a \f ootnote, but not before a \sf ootnote. This means that all the succcding pages may be changed slightly, which could be quite a problem if the spacing on these pages is a delicate issue. To avoid this, just type \eject after the last word that appears on page 3. Since you didn't end the paragraph with a Xpar, TeX will stretch the last line to the right margin. And since you didn't use \vf ill to fill up the remainder of the page with empty space, the extra space created by changing \footnote to Xsfootnote will be distributed between the lines, in nearly imperceptible increments.

128 ♦i §3. Final formatting. £ In §2 we spiffed up our file with control sequences like Xbeginpaper and Xendpaper. This section covers some of the other control sequences which are used in the "journal-independent" files that .-UU-T^X can set in various for- mats. Because so many aspects of a paper (like the bibliography, for example), arc journal-dependent, .AXII^-TeX has quite a few of these formatting control se- c quences, probably more than one would want to contend with at this delicate stage of our acquaintance. So in this section we will cover only the most important ones; the others are listed in Appendix F, and can be learned later. Mathematicians setting their own papers will probably prefer to leave the details of things like the bibliography to some one else, while technical typsists will eventually want to learn all the formatting control sequences. C The following control sequences arc used for processing material which is not 'art of the text pron.r, like the title and the author's name: ~~7

Xbeginpaper c Xtitle . . . \endtitle Xauthor . . . Xendauthor Xaddress . ... Xendaddress } (optional) Xacknow . . . Xendacknow C \d-te . . . \enddate

Xabstract . . . Xendabstract (optional) c Xbegintext

Xendpaper

f They should be used in the order listed, with Xbeginpaper coming right after Xinput amstex and \input preprint and with Xendpaper coming at the very end. No particular order is required within the group of control sequences that appear in braces {}. We've already mentioned that Xtitle . . . Xendtitle gives a one-line title- C £o_-_o__yl_--Jin-L^lcJt only necessary to separate the individual lines b

X

129 s nieanß of \\: Xtitle Our Very First Attempt to Make\\ The System Turn Out\\A PaperXendtitle The Xauthor of a paper can be two people, like "Flot Sam and Jet Sam", with a corresponding double Xaddress, like "Asea and Ashore", and even a double Xacknow, like "The first author was supported by W.A.T.E.R. and the second author acted under the direction of W.1.N.D." This is the way that the preprint format expects multiple-author papers to be handled. But many journals have special formats for multiple authors. Simply list the authors, their addresses, and their acknowledgements as Xauthor first author \\ second author XX . . . \endauthor and so forth. The control sequence Xabstract . . . \endabstract is used for text that might be set in a separate style, to serve as an abstract for the paper. If the journal normally prefaces abstracts with the word "Abstract.", "Summary.", etc., this will be printed automatically, so it shouldn't be typed. If the journal doesn't print abstracts, the text will simply be ignored. After Xbegintext comes the actual text, whose formatting also requires special control sequences. The most important of these is Xtheorem . . . \\ . . . \endtheorem which processes a statement and a label attached to it. For example, with the preprint format, the input

Xtheorem Theorem (Folk-theoref .)\\ One plus one is two, and neither four nor three . Xendtheorem gets printed as TmiOßliM (FOLK-THEORCM). One plus one is two, and neither four nor three. Notice that the period after the label gets printed automatically (some formats might print a colon, or nothing at all). Of course, Xtheorem can also be used for a Lemma, Corollary, etc. The proof of a theorem (or lemma, corallary, etc.) should be processed by the control sequence Xproof . . . \\ . . . Xendproof For example, with the preprint format, the input Xproof Proof \\See the Collected Poems of A. E. Haussman . Xendproof gets printed as

130 c *i <

PROOF: See the Collected Poems of A. E. Haussman. The colon, whatever, gets printed ic or automatically. Althoug!_hAl . Ax\ . . Xendproof looks completely analogous to Xtheorem . . . .XX Xendtheorem, there's actually a big difference in the way that _/L.__'-T£X treats them. The statement of .1 theorem is usually set in a special way (c.g.,in italic type), so -Olif-TcX needs the Xendtheorem to tell it where this special processing ends. Ifyou leave Xendtheorem out, IgX will * c search all the way to the end ofyour file in an attempt to find it. (Of course, your file might well have an Xendtheorem at the end of the next theorem—this will probably cause complete chaos!) So don't forget to put the Xendtheorem at the end of the theorem. On the other hand, proofs are usually set as ordinary text, except that extra space may be left at the end. If you forget the Xendproof at c the end ofa proof (which is easy when the proof is long), it won't be a catastrophe; at worst, the extra space at the end won't be supplied. This covers the main control sequences needed for formatting the text of a paper, but there are a couple of others that you might find useful at this stage. Frequently, a statement mentions several properties or conditions that are displayed, as in c THEOREM. Suppose that all the standard laws ofreasoning hold. Suppose, moreover, that we know that (i) All men are mortal. (ii) Socrates is a man. Then we can conclude that Socrates is mortal. c This shouldn't be set with Xpars, because the indentations have to vary so that the right parentheses will line up; moreover, different formats specify different indentations, as well as different type faces for the labels "(i)" and "(ii)". Instead type Xtheorem Theorem\\Suppose that all the standard lav/s V of reasoning hold. Suppose, moreover, that we know that Xconditions (i) __ All men are mortal,\\ (ii) __ Socrates is a man . \endconditions Then we can conclude that Socrates is mortal . Xendtheorem Notice that \\ separates the individual lines of the Xconditions, while the special symbol Sc separates each condition from its label; in the next Chapter we will discover many similar uses for &., to line things up correctly. At the end of a proof, right before Xendproof, you can type the control sequence Xqed and ~4._4U-TeX will automatically supply the end-of-proof shib- boleth specified by each format; this might be "Q.E.D.", a black box |, or perhaps nothing at all. C.

131 Chapter 2. T£X's Brand of Mathematics

The real fun r.iul challenge of technical typesettingcomes from the horrendous formulas with

Tlii.s simple example illustrates several important points. (0 Letters are . :tomai icaHy italicized in I'-.rmulas, but numerals and punctua- tion symbols (like parentheses) are set in roman typ ; .. Notice, by the way, that even a single symbol can be a "formula": if you type $x$ in the input, you will get .." in Uie output. (1>) ,The hyphen becomes a minus sign and (he slash become;; a slanted fraction C J nc n lirI ir xy^'bo! U\ stands for ihc "absolute value of 1". but it's not necessary - - (hi to' k.-ic-A what . means; the only important thing is that TtX will typeset | even if your kin- board has j instead of I .) (3) Most important of all, T^X completely ignores all spaces within $ signs. When setting a formula, T|y< relics on its own spacing rules, which probably (X involve more details than you would want to keep track of. For example, in the formula y = 3(x — i.5)/(--2|i| -j- I) the — sign is a "binary relation", wiiich functions as a verb, and the -j- sign and the first — sign are "binary operators", wiiich function like conjunctions, while the second — sign functions like an ad- jective. Standard printing conventions use spacing which reflects these different roles: thus, there is a little more space around.the — sign than there is around the -f sign or the first — sign, while there is no space at all after the second sign. —

2-1

C

c

t * CAUTION. Although spaces and single (carriage-rcturn)s don't count in math mode, you can't have a blank line, or a Xpar in math mode—the whole concept of paragraphing doesn't make sense within a formula. CAUTION. If yon leave out the $ sign which ends a formula, and nonchalantly continue with input text, I^X will naturally assume that you want to process everything up until the next $ sign as one gigantic formula

y 3(x— -)- = 1,5)/(—2\x\ l)toappearinlheoutpu.tbytyping. . (

Most likely you'll get an Overfull box. Of course, before Ts. ever finds the next sign, it might encounter something which isn't allowed in math mode, like a Xpar, for example. In this case you'll end up with an error mc.sage. But in any case, you will probably get IftX (and yourself) thoroughly confused—a lot of your input will come out as garbage, if it comes out at all. ( In parsing, you might notice that the spacing in the above output is different from that used for ordinary italic text. Compare

typing on line A (the product oft, y, p, j, n and g) with typing (the italicized word).

Although TcX ignores spaces within $ signs, they should not be regarded as useless, since they can make the input text a lot easier to read—for example, individual parts of long complicated formulas can be separated by several spaces. Initially, force of habit may lead you to use spaces even m short formulas, like $y = 3(x - i.5)/(-2|x| - so as to approximate the spacing that will eventually appear in print. However, you'll soon come to realize that the spaces do nothing but slow down the typing, and you'll probably graduate to something like $y__3 (x-1) / (-2 I x I +1) $, reserv- ing spares for more complicated situations. In this manual we'll use spacing in a haphazard way, just to emphasize that it's an unnecessary good. Exercise. What's wrong with typing the following?

If the formulas y=x-l$ is true

Exercise. Explain how to type the following sentence. Deleting an element from an n-tuplc leaves an (n — l)-tuplc. c

22

(

$

1)$ Don't be taken in by T^X's finesse in setting mathematics formulas. Even though TjjX is usually smart enough to choose correct spacing, if docan't really "understand" formulas (any more than a human typesetter docs). Technical typists should regard this as good news, for it means that they don't have to understand the formula either! For example, it's not important to know why the parentheses arc there—so long as they get typed in. Mathematicians actually use parentheses in many different ways, but again it is not necessary to understand these different uses. If you type $y-f ( x)s you will get the formula y = f(x), X in which the parentheses have a special mathematical use. Similarly, if you type $y=f [ x] $ and $z=f (x ,y) $ you will get the formulas y -- /[_.) and z = /(.?, y). The brackets and comma in t.heso formula illustrate once again that punctua- tion marks in formulas arc set in roman type. Notice also that a comma in a formula is followed by a smaller space than a comma in ordinary text (T£X docs £ this because commas in formulas usually separate parts of a single mathematical entity). For this reason, actual punctuation commas should always be left out side the $ signs. For example, always type

For all $a$ and $b$ we have $abs.

rather than

For all $a$ and $b$ wo have $ab.s

SIDETRIP. Colons and semi-colons are also foliov/fd by a smaller space in for- mulas. No space at all b left after periods in formulas, so that you can get decimal c numbers, like 3.11159. Malhcmaticiansarc usually pretty careful about putting the necessary paren- theses in their manuscript. But they sometimes get lazy, and stop counting parentheses in a formula like the following: c J +2(3 + 4(5 + 6(7 + __))) Even if the parentheses don't match up, a catastrophe won't ensue—T]^X isn't very discriminating on this score, and will be quite happy to typeset the formula

I 2(3 4(5 -|- 6(7 x)) C + + + even though it is mathematically unacceptable. This is fortunate, because Tiy< mustn't object to a formula like [x,x + I], which doesn't look like it should be mathematically acceptable, but which actually is, because the parenthesis and bracket have special meanings. C 2-3

C

X

t » Braces, as well as parentheses and brackets, are often used with special meanings, as in the formula * + W + (*) + [*] + {x} To set this formula you have to remember that printed braces must be specified by the conftrol sequences \< and \>, since actual braces serve the special function of grouping things. Thus, you should type C x +|x|+ (x)+[ x]+\-Cx\> Brackets and braces may also be used just like parentheses, in order to make the pairings clearer, as in the formula

l + 2{3+4[5 + 6(7 + x)]} ( Such constructions are becoming a little old-fashioned, since [ ] and { } frequently have special meanings, but they occur often enough in many branches of math- ematics.

Exercise. What output would be produced by the following input?

$l+2<3+4 [5+6 (7+x*) ] >$

In connection with this exercise, notice that the input

$l+2<3+4[5+6 (7+x) ] \>s with one and < no matching >, will cause T)rX to throw a fit. Printed parentheses brackets and braces (specified by \< and \>) don't have to be balanced in for- mulas. But actual braces in the input arc instructions to Tr^X—they must' bt balanced. , When IcX s setting formulas within text, it may have to break them between lines. Broken formulas arc always a headache, so T^X avoids breaks when it can, and tries to choose reasonable breaks when necessary. Preference is given to breaks after binary relations, and second preference to breaks after binary operators. For example, if the formula specified by

$f (x,y) =(x+y) (x-y)s must be broken, the break will occur after the = sign if possible, or after the sign or sign, a + - as last resort. A break definitely won't occur after a comma 2-4 (

(

( f (which is another reason why punctuation commas should be left ouside the $ signs). Anything in braces is treated as an unbreakable unit, so you can avoid a c break after the + or — by typing $f Cx,y)=<(x+y)(x-y)>s

Remember, however, that by doing this you may be forcing I~EX to give you an Overfull box message. Actually, it really isn't necessary to bother worrying c about such things until you encounter one of those rare instances where a bad break occurs. (And then the best solution may involve a little rewriting.) SIDETRIP. If you type $(x+y)\*(x-y)s,Ts{ will treat the \* somewhat like a discretionary hypyhen \-, except that \* means multiplication: a line break will be allowed at that place, if necessary, but I^X will insert a X, rather than hyphen. C a One of the simplest things to do with a long formula in to display it, instead of trying to set it within the text. Even short formulas may be displayed, to give them prominence. The art of displaying formulas is actually an important aspect of mathematical style, so TljX will never make a decision to display a formula on its own—you have to tell Ts( to do this by enclosing the input in $$ signs c instead of $ signs. For example, the input . . . If $f(x)=x+ls, then we will have $$f ( [x+l 3 / [x+2] )=\< [x+i] / [x+2] \>+l =(x+i)/(x+3) .ss Consequently c produces the output . . . If f(x) —x+ 1, then we will have f{\x + Ij/[x + 2]) = {\x + ]]/[x + 2]}' + 1 = (x + l)/(x + 3). r Consequently, . . . Notice that everything between the $$ signs got set as a one- line formula— multi-line formulas don't get explained until §8. Notice also that although the comma was typed outside the $ signs, the period was typed inside the $$ signs- otherwise the period would have appeared at the beginning of the next line, right C before "Consequently" ! CAUTION. We broke the first line of this input in a weird place as a reminder that in math mode I^X ignores all spaces, including the ones created by 'carriage- return^. But remember that you mustn't have a blank line in math mode—this includes formulas between $$ signs as well as ones between $ signs. (.

C

25 '. ' SIDETRIP. If a proof ends with a display and you use the control sequence Xqed (page??), it should also occur inside the $$ signs. SIDETRIP. You can put math formulas with the text of a \f ootnote, by using r $ signs, but for technical reasons you can't put $$ . . .$$ within a\footnote. (In order to process a \f ootnote, IftX goes into an altered state of consciousness from which it is not prepared to take off into the astral plane demanded by $$ signs.) If you really must have a displayed formula in a \f ootnote, see §11. Conversely, as good taste alone would dictate, you can't have a \footnote inside a formula, whether displayed or not. So far we've only dealt with formulas involving letters, numerals and punctua- tion, togetherwith the symbols =, +, — , <, >, |. But mathematiciansroutinely employ dozens of other symbols, like 00, <, V, £, etc. Each of these symbols has a control sequence to name it. For example, the symbol G, which indicates C membership in a set, is named by \in. So you can get the formula x G A by typing x\in A (notice that the space after \in is needed!). Similarly, the symbol 00, which stands for "infinity" (more or less), is named by Xinfty (the shorter name \inf happens to be used for something else, which we'll learn about in §8). The names for all special symbols are listed in Appendix S—they can be learned as needed. CAUTION. All of these special symbols should be used only in math mode (between $ signs or $$ signs)—T^X will complain if your input file has \in or Xinfty outside of n.ath mode. Also, some keyboards have special keys like 00, but you should not use them, even in math mode—there's no reason to expect them to give you the right thing. You really shouldn't even use the keys labelled =, +, <, > and | outside of math mode, since the spacing won't be right. As a matter of fact, outside of math mode the key labelled I won't even give you | (try it and sec!). Mathematicians have supplemented their arsenal of specially concocted sym- bols with a horde of letters stolen from other alphabets; control sequences for these special symbols arc also listed in Appendix S. For example, $\alphas, $\betas and $\gammas produce the Greek letters a, (3 and 7, while $\Gammas produces T, which is an upper case gamma. Notice that $\epsilonsproduces the Greek letter c, which is quite different from the membership symbol £. Just to make matters a little worse, c has the variant form _? , which is produced by $\varepsilons. Three other Greek letters also have variant forms: while the input $(\phi , Xtheta, \)s yields the formula (<£, _>,u>), the input $$(\varphi, Xvartheta, \varcmega)ss yields the displayed formula (

(

26 v - . CAUTION. TJjX has no regard for the glories of the Greek tcnguc—as far as it is concerned, Greek letters are just additional weird symbols, and they are c allowed only in math mode. In a pinch you can get the output rex by typing $\tau\epsilon\chis, but if you're actually setting Greek text, you will be using a different version of TftX, designed for a keyboard with Greek letters on it, and you shouldn't even be reading this manual, which is undoubtedly all English to you. X SIDETRIP. Although 6 is rapidly gaining acceptance as the standard symbol for membership in a set, some mathematicians prefer c or £ . If this is required, don't type $.\\epsilon As, because you'll get xtA, with the wrong spacing. Instead use Xepsilonin or \varepsilonin. SIDETRIP. Upper case Greek letters actually come in two styles, ( rAeAEiiEY**n

and r AOAniiErvvn c (all the other upper case letters arc 'dentical with upper case roman or italic letters, at least so far as mathematical typesetting is concerned). The choice of style is made by the journal format; the preprint format uses the "italic" style, unless it is changed as explained in Chapter 5. In addition to Greek letters, X/iW-T^X will also set upper-case script letters "A,lt>, -6 and the lonely lower-case produced by $\Ascrs, $\B>_crs, C .. ..., \Zscrs and $\lscrs. Like Greek Setters, these control sequences can be used only in math mode. X/il.xTi^< lias several other special fonts, like gothic (German), that are used in math formulas; Appendix S also lists these fonts, together with the control sequences that identify them. To indicate a letter in one of these fonts you ( simply type the identifying control sequence right before the letter (but you've got to be in math mode). For example, $\goth g$ produces a , while $\goth G$ and $\goth produce v£ and G> (which only people like Q^tiht, and Gtk'tUtr r.an distinguish). You can get Xgoth to apply to a group of letters by enclosing it in braces, and you can even have the symbols +, -, =, <, >, | and ( / in the group : Xgoth aa+ \goth-Cb+|c |-d>+e £<_ + b +|<-| — 4 +c Notice that Xgoth doesn't work in the same way as the control sequences \rm, \bf, \it and \sl, which arc meant for ordinary text, and aren't even C

27

C

S$ - - allowed in math mode. The control sequence Xgoth applies only to the next letter, or group—succeding symbols are set as usual. Notice also that the hyphen comes out as a minus sign, which is what you'll usually want. A special control frequence is available if for some reason you need the hyphen from the gothic font. Bold face letters in math mode are treated as a special font, even though they may be the same as the bold face letters used in ordinary text. To get boldface letters in math mode, use the control sequence \bold: . $\bold xy+zs xy + « Notice that \bold works like Xgoth, and not like \bf. There is one Cher feature of technical typesetting that ought to be mentioned in this section. Sometimes formulas can be made to look a little prettier by using slightly bigger parentheses ( and ) (named by Xbiglp and Xbigrp, respectively). For example, \big parentheses arc used in the formula (x-/(y))(x + /(y)) And \bii£ parentheses should also be used in formulas like 0(l/n) Here O is an upper-case "oh", not a zero (helpful hint: a formula should usually have O instead of 0 when it comes right before a left parenthesis). Exercise. What input produces the above formulas? Unfo/tunatcly, there are few hard and fast rules for choosing \biglps and \bi crrps, and mathematicians will seldom indicate them explicitly in their manuscripts (though they may appreciate them in the output). In fact, even journals may be negligent about using larger size parentheses (maybe X/M-Ti^. will change that). J-Jh'S-Tty actually has three sizes of large parentheses that you can specify: ( Xbiglp and \bigrp) i Xbigglp and Xbiggrp j

( \kiggglp and Xbiggrp j

Moreover, there are corresponding brackets (Xbiglbracket, Xbigrbracket, etc.), braces (\biglbrace, Xbigrbrace, etc.), vertical lines (\biglv, \bigrv, etc.) and double vertical lines (\biglvv, \bigrw, etc.). But you will almost never need to use any of them. As we shall see in §C, you can usually ask T£X to select the right size for you.

(

(

(

28 1) §2. The 2nd level of complexity. Technical typesetting wouldn't be such a big deal if spacing were the only concern. But mathematics formulas also convey a lot of information through the positioning of text—as superscripts and subscripts, for example. Since you can't use positioning on the terminal -the input just goes in line by line—all this information has to be conveyed in some other way. Superscripts and subscripts are indicated by the control sequences \sp and \sb: The input produces the output $x\sp2s x 2 $x\sp a$ xa $x\sp\alphas x° C $:< \sb2s x 2 $2\sp x$ 2* If your keyboard has T and J- you can use them instead of \sp and \sb: $xT2$ x 2 $xX2$ r x-2 Actually, T is one of the standard keys that will be. on nearly every keyboard. This key wasn't mentioned in Chapter J because it often appears disguised, as (arrow-head or "carat"); it can often be found on the top half of the 6 key. Whether it appears as Tor ", it will work just the same. The key X is not standard, and will be missing from many keyboards,* but to save space in this manual we V will usually use T and X instead of Xsp and \sb. CAUTION. Use the T and X keys only if they actually produce symbols on the screen. Some terminals have keys labelled T and J which do not enter text, but merely move the cursor up and down. The instructions T and X apply only to the next single character, so there is no ambiguity in the following: 2 $xT2yT2$ x 2y $x\sp2y\sp2s x 2y2 $x T 2y T2s x2lj2 r $xX2yX2$ x 2y2 $X2FX3S 2. F:i 2 $<>T2FX3S F3

*lr.von don'l have a hoy labelled X can goI. Hie elTerl or X by using "control A", provided c thai there's a oonvonienl for you to..outer "control A" inlo your lilo.

C

you wn.y

29 t

Notice that you can have a superscript or subscript following nothing, as in the last two examples. If you want a whole expression superscripted or subscripted, just enclose it in braces: $z=xT {2y>s z = x 2« $xX=v/$ Xy+Z = W $2T<32>s 232 $xXs $xT{\-C3y\»s x{3i/>

1 Exercise. Explain how to get a footnote with a numerical indicator, or a footnote^ 2 ) with a more complicated arrangement.

( When a sub or superscript applies to a whole expression, mathematicians will u__ parentheses (or brackets or braces) to indicate this: (* + I)3

$[xT2]T3$ $\T<3y>s {x 2y»

Actually, mathematicians and experienced technical typists may be somewhat supri.sed that these simple inputs worked—how did TjjX know, for example, that 3 was supposed to 'c an exponent to the whole expression (x +1) or (x2 )? The r answer is very simple: _£X didn't know—it justfollowed instructions very literally and set the 3 as an exponent to the right parenthesis! On the other hand, here's what happens when you enclose things in braces: (z + 1) ! (same as before) $<(xT2)>T3$ (x 2)3 l*¥ $< \ >T{3y>s $<«(xT2)>T3)>T4$

( Although this might seem better from a logical point of view, expressions like (x-)' 1 arc standard fare in most printed mathematics.

'Like lliis one. 2. Like (.his one!

(

(

$(x+i)T3s $(xT2)T3S

${(x+l)}T3s

${[xT2]}T3s

210 . > Exercise, ir you did decide to use these higher superscripts, how might the last example be improved? X You will need braces stacked in the other direction for sub or superscripts that arc themselves sub or superscripts: $2T{2Tx}s 22 * 2T{(2Tx)>s 2V"> 1 $2T{2T{2Tx}}s 2 2' 2T<(a+b)T2>s 2( + fc)2 $xXs Xyj xX{yT2>s v Notice that superscripts arc sat in smaller type, while superscripts to superscripts are set in yet smaller type (in most formats); T^- doesn't decrease the type size any further after this, because such tiny symbol;; would be too hard to read. By the way, if you set a big tower of superscripts, like 22 within text, T_jJ( will automatically leave enough space around the line containing""'' it. Exercise. V/hat output would be produced by the following inputs? $<2T2>Txs $-CxXy}X2s

As this exercise is meant to show, there is a big difference between xT and Tz; while the first produces !,: c x""', the second simply produces x , which could just as well be specified by xT-Cyz>. Tvj>. will not accept the ambiguous input xtyTs (some computer typesetting systems treat this as xT{yTz}, while others treat it as X<92>+\pis

xX{yTaXb>Ts X~r,. fib You can also get staggered sub IC and superscripts, by the artful use or braces, even resorting at times to the empty group <>: $Xbs or $ATaOXbs A\ $T2s or $xXi<>T2s Xi 2 J $RXi-C>Tj<>X{kl>s n t u

211

Q The non-staggered form is generally considered more elegant, and formulas like A"b often appear in printed works only because they are easier to set on a linotype staggering machine. But in some cases the serves mathematical purposes. Many c mathematicians prefer i; 2 when the 2 docs not function as an "index", but in- dicates the square of x,-. And the example J.,J- ./ is not a weird product of the author's imagination; rather, it is a weird product of "tensor analysis", a branch of mathematics waggishly defined as the study of sub and superscripts, where exact positioning is important. There are two sub and superscripts which require a little separate discus- X sion. The control sequence Xprime stands for the character /, which is used for superscripts: $yXlT\ + yT<\pritne\primo\primtjXX2s %jx + y'2" And the control sequence Xast stands for a centered asterisk (Xast is allowed ( only in math mode, and the symbol it produces is quite different* from the symbol * that you obtain when you press the key labelled *). It is frequently used for both superscripts and subscripts: fX\ast(\mu)s f{x) f)Mf-i) SIDETRIP. We said that Tj^K sets sub and superscripts in a smaller size. Actually, that's not quite true! Tj^C will automatically select a smaller size for italic, Greek and script letters, and almost all special math symbols that you normally en- , including the Hebrew letter 1. (\aleph). But the smaller size won't be selected for the other special fonts, like Xgoth and \bold. To get the right size, you have to use the control sequence Xsizes, which specifically instructs T£X to use the size for superscripts (you can even use \sizes when you're not in a superscript): $2T-C\sizes<\goth g + \bold X» 2j+ x (\sizes-Cx>+ y)T2$ (_" + y]1 Notice that braces surround the whole, \sizes construction in the first example. If the braces weren't there, T£X would think that you wanted 2T\sises followed by Xgoth g + \bold X, which doesn't mean anything at all, since \sizes isn't a symbol. The control sequence \sizes will also be necessary for a whole bunch of rarely used symbols, but there's really no need to worry about which symbols these arc. They will be used as sub and superscripts so rarely that you can just make changes if they ever appear the wrong size in the first output. On very rare occassions, you might need the control sequence \sizess, which specifies the size used for supcrscripts-to-superscripts (actually, for most special fonts this is the same as the size used for superscripts).

( 2-12

(

$fT\ast(x)\hat 4

« expression Al3 SIDETRIP. In an like x?)2 the sub and superscripts will line up precisely, because all numerals in a font have exactly the same width. But other symbols won't line up so well, as in the extreme example

$RT-Ciii}X{mmm}s Dili mram

If this becomes bothersome, you can specify the sub and superscripts a pair at a time: §3. Defining new control sequences. Although we've only begun to delve into the complexity of mathematical formulas, T^X's capacity for creating new control sequences can already be ( k aprcciated. If you're typing a manuscript in which the symbol R^ i appears fifty times, it's going to become quite a bore to type RXi-C>T{jk>OXl at each occurrence. For such situations you can create your own control sequences to serve as abbreviations, by typing*

( \def me new control sequence -.input that this control sequence stands for}

Suppose, for example, that you want to use Xsymbol as an abbreviation for the k input that produces the symbol Rp i. You can type

Xdef ina\symbolOXl> and thenceforth T]^. will know that \cymbol stands for RXi {>TXl:

SgT-CmXsymbol glss 9ilßi Jkigjk

TpX does have, one idiosyncracy about control sequences: it distinguishes between upper and lower case for the firtit letter of a control sequence, but not for any others. Thus, \Cymbol would be a different control sequence, requiring a separate definition, 'but if you typed XsYmbol you'd get exactly the same result as if you typed \symbol. Of course, a name like Xsymbol or \Symbol isn't a very good choice when several different symbols need abbreviations. For the control sequence that abbreviates the input for RXi you might choose instead the name \R (mathematicians would probably pick something like \curv sinceRXt is a form of the curvature tensor). The particular choice of names is a purely personal decision, but you'll probably want ones that are both brief and easy to remember. The names of most. AjVo^-Tj^. control sequences were chosen more for their mnemonic value than for their brevity. If your manuscript has only an occasional Greek letter, you'll probably find it convenient to type Xchi for x n "d \xi for £ (assuming that you customarily call these letters by their proper names, rather than "cross" and "mainspring", or something like that). But when Greek (.

*Ho;hlois familiar with T^X (l lie basic svslem, as opposed in (he specialized . -1. H-J-Tj-J. ver- sion), know thai TjrX usually uses a slighh dilTerenl way of crealing new control .sequences. This will also work in .(. H.l-Tj^.. but il. won'l give you certain safely features that we'll mention later. 2-14 (

(

way * a letters arc liberally sprinkled throughout a manuscript it can become wearisome to type long names like \alpha and Xepsilon, so you'll probably prefer your c own special symbols. For example, you might want \ag, \bg and \cg for a, /? and -,; and for F, the upper case form of 7, you might want \Cg (but not \cG! that's exactly the same as \cg). Just type — Xdef ineXcg-CXgamma} Xdef ine\Cg-C\Gamma} and T£X will know that henceforth Xcg stands for Xgamma, which yields in !(. 7 math mode, while \Cg stands for \Garnma, which in math mode yields T (or F, depending on the format). Exercise. Why would il be a bad idea to define \ag as follows? Xdef ine\ag<3\alphas} c If you're going to use certain control sequences ("like Xccr and XcC. over msUmiJiSMELJLhcy car] be put iiLa_Far4y^tjU_ig. When you create a file for a_ii_aayM_rip_^ contents of the definition file into the beginningof paper . tsx. In addition to the control sequences which will be part of your persona! working vocabulary, you'll usually want some new ones for each particular manuscript. It'll probably create less confusion if you first examine the manuscript to determine which new control sequences will be. needed, and then list all of them at, or near, the beginning of the file —that way you'll know where to look if you forget any. By the way, control sequences don't have to be used only for input that will occur in math mode. For example, if the name "E. Cartan" occurs frequently, C it might be convenient to define Xdef ine\Cartan-C\'E. Cartan} And, of course, a special control sequence was used to produce the logo "TVX" in this manual. c When you arc defining control sequences, a few precautions should be ob- served: CAUTION. As you can see from the above examples, the definition of a control .£-^Li.ilu_ce.j^ But don't make crazy definitions that define a control sequence in terms of itself, like C Xdefine\regress-Cinfmite Xregress} This would cause Tj^Xto replace an occurrence of the control sequence Xregressby infinite \regress; then it would replace \regress again, to get infinite infinite Xregress; then it would replace Xregress again ... . Eventually tiring of this nonsense, il would issue a pathetic complaint. c

C

(.

215 » » CAUTION, In Chapter 1 we introduced the control sequence \f ootnote, which can be use. Tor example, as follows:

\footnote*\\ Footnote text, \endfootnote i

Now if you think that \f ootnote is too long a name, you might define

Xdef in e\i-n{\footnote} ( and from then on you could get a footnote by typing

\fn*\\ Footnote text, \endfootnote

But don't try to monkey with the control sequences XX and \endf ootnote! For example, if you define C

Xdef ine\ef n\\endfootnote} and then type \fn*\\ Footnote text .\efn it just won't work—you'll get an error message. The control sequence \f ootnote always expects to see the exact sequence of symbols \\ and \endf ootnotefur- ther on (in this particular context, \\ and \endf ootnotearen't really function- ing as control sequences, but arc part of the "syntax" for \f ootnote). Later in tins chapter v/e'ii encounter numerous control sequences of this sort, which are used in conjunction with subsidiary control sequences. The same restriction always applies: don't tryr to do anything about the subsidiary ones. SIDETRIP. A TLXperl could tell you how to change the \endf ootnote, -but \f ootnotcs are such rare beasts that it's probably not worth the trouble. In all this discussion we've omitted one important point: just where do you do your Xdef ines? Well, you can do them just about anywhere. You can type \define\. . . { . . . }in the middle of a paragraph, right between two words. Or between the last word of a paragraph and the control sequence Xpar, or a blank line. Or right after a Xpar. Or right before an equation, or even in the middle of an equation! When Tj^X sees a \define it simply takes note of the definition, and presses onwards. There arc only two things that you have to be awareof. First of all, a control sequence should always be defined before it is used- -if T^X encounters a control sequence which has not yet been defined, it will issue an error message and stop. 2-16 .

{ * " (This also applies, of course, to a misspelled control sequence, so be extra careful when you type control sequences.) Secondly, a control c sequence that occurs between signs or SS si m..r n.. fm-. gotten once the processed— ... formula lias been a Xdef me might be put between $ signs if it is just being used to help set a particularly complicated formula & \defme braces <. . .} is also fcrgotten once this rroup h..s Wn processed. Of course, you'd probably never think of saying \dofine braces, butyou within might end up doing this inadvertently ifyou use one ofthe control c sequences that docs a lot of fancy things for you. For example, if you have a Xdef inside me a \footnote, this control sequences actually ends up putting your Xdef me inside braces, where it will promptly be forgotten. So don't bury Xdefinestoo deeply. There's one other thing that might be worrying you. What if you define a control !c sequence that's already been defined? If you do this, TeX will give precedence to the new definition, but only for the part of the input that comes after this new definition. So if you've been using the definition \define\R_rUi-OT-CjkKHl}

c and the symbol RX, disappears entirely after page 3, while the symbol RJkl begins to occur will, distressing regularity, you can now type Xdef ine\rUßXi-QTj-C}X{kl}}

exercising care with your right braces, and henceforth the input \R will produce c the new symbol R^m- You can even make definitions that overide X^-T^'s definitions of its own control sequences. For example, suppose that want to have formulae like x _ A rather than x£A. You probably won't want to have to keep typing \epsi lanin (page*?). Instead you can redefine \in " C Xdef ineXin-CXepsilonin}

Wli£lLXC__Lm_Llj^^ will take precedence, since it will occur after definition, "JAIXXXX* which is made when Tj;X reads the line \input amstex in your file. So you can now get x c A by typing x\in A. r Of course, arc some V there dangers. For example, you might decide to define Xdef ine\A{AXi -QT-CJ k}{}Xl} unaware of the fact that \A already has a meaning (given in Chapter i§3, which you've skipped). With this new definition, everything will work just fine,' unless '(.

217

X

c

$ « p you happen to across the symbol x in the manuscript. When you consult Chapter I§3, you'll find that this should be typed as \A x. But if you were to type

$\A x$ in this situation, you'd end up with i- A ij ix\\

So let's hope that you remember that you've already defined \A (that, at any rate, is a lot easier than trying to remember all of Xy.l.'-TirX's control sequences, especially the rarely used ones). Assuming that you do recognize the problem, what can you do about it? Well, you could go back to your definition of \A and change \A to something else. Of course, you'd have to make the same change at all the places where you've already used XA. This really isn't much of a problem with a text editor, but there's a. trickier way out that is much easier. First decide on some alternative name for Xyll-f-TjjX's control sequence \A. A safe choice would be \ncwA, since none or _.._/..) if-TjjjX's control sequences begin with \new. (A briefer safe choice would be XzA, since the Greek letter \zeta is the only JLJW-'[)&. control sequence beginning with \z.) Then put the definition Xdef ine\newA-C\A} right before your definition, so that your file has

Xdef ine\newA-C\A} \dofine\A

The first line gives \newA the meaning of JL.A\>'S-TrsCs control sequence \A. Then the next line gives \A your meaning. So everything's hunky-dory: you can now get AX) by typing XA and you can get x by typing XnewA x. TLX has many control sequences which arc not mentioned anywhere in this manual, but which are used in the definitions of control sequences that do get mentioned. If one of these unmentioned control sequences ever got redefined, the result would be complete chaos, because some of the control sequences which you use would now have a completely different meaning! So .AJWi'S-T]^. won't let you redefine them— if you do try to redefine them, _4._-.b_f- I]^. will give you an error message.* There isn't much you can do at that point, except go back and replace the offending symbol by something else, everywhere that it occurs. At the end of this section there is a (long!) list of all these forbidden control sequences, just

*This safely feature won't he present if you make .your delinitions in the basic T^X manner.

i

218 «w want to in case you save yourself the trouble of finding out too late that fome control sequence can't be redefined. There's no need to look al it very carefully. Most of the control sequences on this list have names thai you'd probably never think of using anyway; you might ju.t check through it and make a small list of names that you might conccivablyhave used. Dy the way, all the examples in this section showed control sequences of the second kind (\ followed by letter..). Almost all the control r.cquenccs of the first kind already have a special meaning, so you shouldn't redefine them (.UW- T£j>( won't give you an error message about these, since you've just been given a warning). The control sequences \O. \l \9 don't have special meanings. however, and they arc good on-the-spot control sequences to use for oppressions that need abbreviation in just one or two formulas. CAUTION. A final admonition. If yen try to do something fancy with your control sequence, you'll probably botch it. For example, the author of this manual originally thnoughl that it would be neat for _-Ut,_"-T£.X to define

Xdef ine\f;troke

so that you could get / by typing £fXstrokeS, instead of $fT\primes. But this doesn't work, because (he input $f\ctroke\strokcs would be translated into the input $fT\p.-imeT\prime3, which isn't allowed. As a general rule, use control _'.-qu ences for specific complex symbols, rather than for "operations". SIDETP.iP. Exercise. The following definition cleverly avoids the problem:

XdefineXstroke-COTXprime}

But it still doesn't work. Why not? SIDETRIP. Exercise. Yon intend to tel! people that there are lots cf things they should not do, so you'd like to have a control sequence Knot that gives the word "not" in boldface. Explain what's wrong with the definition Xdef ine\not<\bf not} ?.ni\ give a good definition. SIDETRIP. You probably shouldn't read this. ("A little learning is a dan- gerous thing ... ") In the Introduction we said that the underscore key _ will never be used. This could be passed of] as a white lie, ifwc hadn't been so damned emphatic about it! Actually, .AXillf-T^X treats an underscore exactly like a letter. So you can use in the names of control sequences of the first kind like \symbol_one \sy;tjmol_two

219 As a matter of fact.XAMgC _ uses in the names of many of its own control r #» sequences, ones which never appear in this manual, but are used in the defin tion of control sequences hat do appear. All of these special control se St ,CUCr AMT& ( - WHatCVCr y U d lf y" Use m the name of7 a"controlf l0 »nde«o* r^nir 7 sequence, don't put it al° the°'beginning!

.. 1--X- f

(

c

t

t

220 _»"" "

§4. Control sequences with ngruments. Although we've said a lot about control sequences, so far we've only produced rather simple-minded ones. In practice, you'll probably require control sequences that arc more flexible. For example, if the symbol RJ\ occurs frequently in a manuscript, it's a good bet that the same symbol will also occur with I replaced by other letters, like _V\ Jk /_,j R t j, RX\„ "V You don't need to make special control sequences Tor each such symbol. Instead you can define a control sequence C \R "with one argument" this means that $\R 1$ will produce, ff and $\R —jk ,■">*, \alphas will produce R, .„ etc. To do this you tvnc \define\R#l

This tells TtfX that \R 1 should be translated as RXi-Q T{jkK}Xl, while the C input XRXalpha should be translated as RXiOl"CjkH}X\alpha; whatever ______umc»t". appears after \R gets substituted for #1 in the definition. If, your argument involves more than one symbol or control sequence., it i______Ui_L_l____Mc_^^ aruuni-iit. Compare the following: C \R I+i RXi + 1 \R -o+i} RXr+i

Exercise. What cutpu. would be produced by $\R-ClT\ast}sand$\R lT\asts? c What would happen if you typed $\R lX\asts? Exercise. If your manuscript has oodles of boldface letters in math formulas, it's going to b" very unpleasant tocontinually type Xbold x, \bold y, etc. Explain how to define a control sequence \1 so that \lx gives a boldface x, \iy gives a boldface y, etc. Why is \l a better choice than something like \b? ° ' C Exercise. Also explain how to define a control sequence \2 so that \2x gives a boldface in the proper size for a superscript. CAUTION. The same control sequence can't be used both as an ordinary control Lemtcjtcc and as a control sequence with one argument. For example, if you first define c \define\R

221

C

\ (

CAUTION. When you make a definition like

Xdefine \R ■CRXiO'KjkHHl} any spaces after Xdef me and \Rarc irrelevant (they're ignored, since they follow control sequences). But you have to be very careful when you define a control sequence with one argument, like

\define\R #l-CRXi<}T-Cjk}<}X#l} (. Do not leave a space, or a .carriage-return),between $1 and -Ci! —this could lead to incredible confusion. SIDETRIP. Namely, if you were to define

Xdefine \R #1 -CRXi<}T

-.v .iii a space after #1, then TjJ. would think that you actually expected a space ■'■a follow the argument. So, for example, if you gave Tjy. the input

$\R I+l= 3$ it would conclude that the argument has to be 1-+-!=, and ycu would end up with iWi=3, rather than RXi +1 = 3

In order to introduce control sequences with arguments, we used the rather unrealistic premise that only the last letter in the symbol R.X'i happens to vary. In practice, a manuscript with the symbol fiX i will probably have lots of other substitution:,for the indices, like TVJ'/, RXn, etc. So you will really vvantja^controj sequence with four arguments. To produce this you define

\define\R#l#2#3#4

This new control sequence works as follows:

$\R ij'kls RXI $\R iXalpha lks RXk i'l $\R j{iT\prime}l{kT\prime}s Rjr? h'

Control sequences with several arguments require even more precautions than control sequences with one argument. 2-22 .

(

C * r CAUTION. In the above definition, the symbols *i g4 that follow \R must c__JDC_ijLXM£yX-_^t__order, and you" can only''go up to jta, (O n the other hand the dcr of appearance within the definition itself doesn't matter. For example,' if°-you prefer naming all subscripts before all superscripts you can define \define\R#l#2#3#4

be very careful: Do not leave a space, or a .cariia<_c-rcturn. between any of these _sy_ia_LQjs! ! ~ CAUTION. Not only C that, you must also fetLjam__.K>r.. to leave a ..pare »r a _ca£n_L£e-return) between the arguments when you use the control The $\R sccmcnceif input iXalpha lks was OK, because the space followed a control sequence, which ignores TfiX (except to note whore the control sequence end;;) but you mustn't type something like \R i jUkl. If you do, Tj*C will think that the space i_L;tl.ie_jJjJi_L___4luJiic___i! r $\R ij kls _VU _-/

Despite these cautionary remarks, you don't have to worry about extra spaces when you use the special JAU-l).^ control sequencesthat we'll be learning about. They've all been carefully jimmied so that the basic rule still holds: in math mode spaces don't count.

SIDETRIP. Perhaps you'd like to know how to make your own control sequences foolproof. Here's one way. Choose some symbol that you don't expect ever to appear in an argument—a good choice would be since any asterisks in piath formulas will be specified by Xast. Then define

\define\R #I*£2*#3*#4*{ }

With this definition you would type

$\R i*j*k*l*s to get RXi C is This a little more cumbersome in such a simple case, but it has two big ad vantages. (1) Although you must still be careful not to have any spaces in the sequence

#I*#2*#3*#4*{

*,

223 * * when you define \R, you can afford to be very cavalier about spaces when you use \R. The input $\R i *j*k* I*s won't confuse T& at all, because it knows that the first argument doesn't end until it sees the first it will conclude that the first argument is iLU—and the extra spaces won't count when the definition of \R gets expanded out. (2) For the same reason, you can dispense with extra braces: if Tj_s. sees the input ( $\R i* jT\prime *k*lX2* it knows that the first argument is i, the second is UjTXprimcLl, the third is k, and the fourth is IX2.

(

224

i

*; §5. Our problems mount.

In a formula with superscripts and subscripts, the symbols still go in "from left to right". But many formulas involve more critical dislocations, with one subformula placed on top of the other. T£X has several control sequences to specify such formulas. The most important of these control sequences produces fractions. For ex- ample, the displayed fraction C n + 1 n + 3 was produced by typing $$n+l\frac n+3ss. Notice that it was unnecessary to enclose n+l and n+3 in braces. The control sequences\f rac applies to everything in the formula, and you have to use braces to restrict its ran^c: C x y2 $$x+yT2\frac + k+lss ~k + f $$x-fCyT2\frac k}+ Iss .+£+_ ( y2 $$x+

$$x=

$$x=(yT2\frac k+l)ss c CAUTION. Notice the braces in the example rac 2}+

C

$${n\f

225 often in a manuscript that you decide to define a control sequence \f to name it. If you make the definition

\define\f

71 71 and you want to specify the expression , you'll have to type --w + —_b

c If you leave out the braces, Tg< will translate \f-»\f into n\frac2+n\frac2 and issue an error message. SIDETRIP. There's a clever, and useful, way out of this predicament: define

\def\f{{n\frac 2}} C

Notice the extra pair of braces! Thic definition makes \f mean Cn\frac 2}, so it's perfectly all right to type \f "+" \f . You can use \f rac within text, as well as in displayed equations. For ex- ample, $l\frac2s produces thefraction -J,-. But fractions like $x-t-y\frac z$ are usually not set within text, since you get ~^, with letters that arc rather small and hard to read. If you want, you can get to appear in the text in the same size that it would appear if displayed: to do this, just type rac a}s. Notice that extra space is automatically placed around the line containing this fraction. There's another operation \atop, which is like \frac, except that it just puts one thing on top of the other, without the fraction line:

n $$n\atcp kss k

Although this particular output isn't too common by itself, it often occurs in combination with other symbols, as in n] fn\

The second of thesesymbols is the standard notation for a "binomial coefficient", which tells how many ways there are to choose k things out of n things. In the next section we'll learn how to put the proper size brackets and parentheses .

t

C

$$-C\f}-<\f}ss

$\sized

226 around n\atop k, but binomial coefficients are so common that there is also a special control sequence \choose to produce them: C $$n\choose kss ("j As far as grouping is concerned, \atop and \choose work just like \frac: n $$n+l\atop kT2ss X A;~t"2

$$n+-Ci\choose k}T2ss n+ ( j

Similarly, $n\choose k$ produces ("), while $\sized-Cn\choose k}s produces the symbol I jin the text. C: When yon have \fracs within other \f racs (or \atops or Nchoorses), the type size gets smaller, just as with sub and superscripts:

$$n\frac-C2+.n\frcc2}}ss ___— 2+f 9 +n $$«n\frac2}+ n}\frac 2}ss —A*

«

$,n\choose{k\frac 2}ss C. |"j As you can see, this doesn't always look so good. The last formula would look better as $$n\choose k/2ss ( n \k/2j) <. or $$n\choose{l\frac2}ss (iO And flic third might look better as c (I) 2 which you can get by typing $$\sized{n\choose k}\frac 2ss

227

X

r-U^.^.e-s, —_ SIDETRIP. Besides \sized, we've already mentioned \sizes and \sizess. In addition, there's \sizet to specify the size used in text. For example,

the inane example $\sized{\sizess{n}\choose-(\sizes{n}T\sizet<2}}}s ?! produces the inane example I \ )?! which does at least illustrate all uses. All of these control sequences will be useful on occasion. SIDETRIP. SIDETRIP. For fractions within fractions, you might want to make use of \thickf rac, which produces a fraction with a thick line:

n J $$\sized

But use this sparingly; it seldom appears in modern mathematical printing. SIDETRIP. SIDETRIP. When you use \frac, \atop, etc., the numerator and denominator are centered over each other. To move cither one to the left or right, use\lft< } or \rt< }. For example .. .

(

C

228 §G. Variable size symbols You've probably already noticed that \frac is a pretty clever little control c sequence, for it chooser a fraction line whose length depends on tfie numerator and denominator. !)$. has many other control sequences that select symbols whose size depends on the context. For example, you can \underline or \overl me a formula: $$\underline 4ss 4 (S $$\underline{\underline-_4+x}}ss A-\-x n+m}ss x-+m 3 $$\overline{\ove>rline-_xT3}+xT

$$\sqrt

$$\sqrt

1 + + + + + yjl+'y/i+i c

C

c

$$\xT{\underline

229 The four smallest square-root signs arc made up of distinct characters, together with ovcrlines of the appropriate length, but the three largest signs are all essen- tially the same, except Tor a vertical segment I that gets repeated as often as necessary to reach the desired size. SIDETRIP. Cube roots and similar things are left to the fine points in §11. Large parentheses are constructed in a manner similar to large square-root signs: once T£K gets beyond \biggg parentheses, it combines standard tops and bottoms with a repcatablepcatable extension: ((( I*-\biggglp \bigggrp -» I There is one important difference between parentheses and square roots, however: TrX( will not choose the appropriate size parentheses unless you formally request them. To get a formula enclosed in parentheses of the right size, type

\left( formula \right )

Similarly, you can get variable size brackets by typing

\left [ formula \right] For example:

$$1-Aleft( l\'fracl -xT2\right) T3ss l+ ( —-— j 2 $$x=\left[yT2\atop k+l\right]ss x= V A; + 1

CAUTION. Notice that the \frac in the first example did not apply to the 1+ or to the T3, and that the T3 applied to the entire formula enclosed by \left( and \right). In other words, \left( and \right) grouped tilings , just like the braces < and }. In the second example, \left[ and \right] also acted like braces—compare Exercise 5-1. Actually, it's the \left and \right alone that perform the grouping func- tion. You can put any "delimiter" you want after \left and \right—they

*

230 don't have to be the left and right members of a matching pair. For example, you can type

$$x+y\in\left(-Ca\frac b},_c\frac d}\right]ss x -|- y£ ( __, 5-1 or even (yukk)

$$x+y\in\left]{a\frac b>.

SIDETRIP. If you type \left] a, b\right [ you will get ]a,b[ with ordinary size ] ami [. But you will also be. assured of getting the right spacing in contexts where TfcX might be Tooled by tin: fact that a right bracket is actually functioning C as a le.'l delimiter. For example, XxXin] a , b [$' happens to come out an x _■]_, £>[, but _Tx\in\lof t] a, b\righb [$ comes out correctly spaced, as x £ ]a,b[. SIDETRIP. The control sequences \(, \), \[ and \] don't have any special meanings in _/Lu.?-TeX. You mi^ht find it convenient to define \( to mean \left. (, etc. c Variable si'/.c braces are also available—remember to type \< and \}:

$$li-\left\Cl\fracl-xT2\right\}T3ss l+ ( 1 I,l— xl J

C And you can get. a variable size vertical line | with double vertical line j| with \ | left floor bracket [ with \1 floor right floor bracket J with \rfloor left ceiling bracket [ with \lceil right ceiling bracket ] with \rceil

(When the control sequences on the right are used without \left and \right they produce the smallest size symbols.) For example, $$\left\| x\frac a\right\| __ ___M =< \|x\|\frac|a|}ss a \a\ Notice that the braces were necessary after the equal sign, though not before.

C

X

231 In addition, you can get a variable size left angle bracket ( with \lr.ngle right angle bracket ) with \rangle

But this symbol is not constructed with rcpcatable extensions and is available in only four sizes:

<><>(>() (' If your formula happens to be enormous, T|_X will simply settle for its largest pair. By the way, 1^ allows you to type \left< as well as \lef t\langle, even though < isn't the same as ( . SIDETRIP. On the previous page we used \left and \right together with I" I/2 1 \atop to get the symbol ... Another possibility is to type

$$yT2\comb[] k+lss

Tl.is is not only shorter, it often results in a little better spacing between the top and the bottom. You can n place [ and ] by any two delimiters you want. For example, \choo_e is precisely the same as \comb(). r In addition to constructions like (s, -j], where the delimiters are of different types, there are also situations where one of the dclim'tcrs is blank— just not there—as in X x |X|Ixl =/ >° \-x,' x< 0 A period gives a blank delimiter, so this formula could be typed as . . \right.ss where". . ." specifics the text

x, x> 0 —x, x < 0 We'll learn how to produce this in Chapter A (don't try to do it with \atop you'll never get. things lined up right). — You will also want to use a blank delimiter along with one other delimiter, the last that we will mention. This is a variable size /, specified by cither \lef t/ 2-32 C

c

c

$$!x|=\left\{. or Xright/. For example,

$$\left.ct-l\frac u\right/xT2ss _-_-_-__. /x2

$$xT2\left/c+l\frac d\right.ss x 7 /-"iii

Notice that it is important for the \lef t/ or \right/ to encl«4_ the large part of the formula, since the size of the delimiters is based on what goes between \left and Xright. You should probably alio be aware of the fact that / is just like ( and ) —it comes in only four sizes. SIDETRIP. A third use for blank delimiters is for formulas thai have three delimiters in them, like i-rH To handle this particular example, it's important to tackle the big part first

$$\lcft\{a-<-b\frac2\right|ss and $$\left.\left.\-Ca+b\fr-ac2\right|a

produce c {_±i and {-¥ a

( (Actually, the spacing in this example inn t quite what a connoisseur would expect. We'll take this point up again in §11.) SiDETRIP. Sometimes blank delimiters show up in print for non-mathemafical reasons (a parenthetical statement might end with a displayed equation, like C -0 If you're a mathematician you should avoid this construction. If you're a technical typist, try pretending that you don't know how to set it!

C

X

233 * §7. Large operators. There is another family of variable size symbols, called large operators , which work a little differently than delimiters. The two most important of these r arc the signs and / which mathematicians use to indicate "summation" and "integration"—all you have to rcmc abcr is that \sum stands for Yl> an^ \int for /. These control sequences are listed in Appendix S, together with a few others, like U and F] and / and ©. The symbols £ and Yl are j»st upper case Greek sigma and pi, respectively, but they are set in a different type size, and possibly in a different type style. As you can already see from the previous paragraph, \sum produces a larger symbol in displays than in text. For example,

stands for $\sum $ stands for

$$\sum xXnss xn

Usually ]T. occurs with "limits", i.e., with formulas that appear above and below if, as in

TO

Xn u=^l

Now comes the. good news—to specify these limits, you simply type them in like sub and superscripts:

m

Xn n— 1

If you specify the limits for a formula set within text, like xXns, the limits will automatically be set as sub and superscripts, so that they won't take up too much space: X^Li x„. The same thing happens if \sum appears in a sub or superscript:

HI B\right) T<\sum TmX{n=i}xXn}ss W~~

(

(

$$\sumX-Cn=l}tmxXnss

$\sumX{n=l}Tm

$$\left(A\frac

234 SIDETRIP. The input $$2T-C\sumTmX-Cn=l}xXn}ss will give

2^n=,I »

In this particular case, a smaller £ would look better, so you could use \Sigma instead of \sum. Integrations arc slightly different from summations, in that the limits get set to the right even in displayed formulas X the symbol $\intX{-\infty}T-t>\infty}s the symbol /+*

/+oo-oo c. Notice, that the —oo is not directly below the +00 in cither style; the precise positioning is determined by the font that the / sign comes from. Actually, some journalformats set limits above and below / signs in displays, and some set limits to the right of £ signs in displays—X.ilff-Tj^. will make these decisions for you automatically. The preprint format u..cs the first set of conventions, unless you change it, as explained in Chapter 5. Although TgX fakes care of all these features automatically, there are still tome details that you ought to know about. SIDETRIP. / signs often occur in pairs, as //. Cut you can't simply type $$\int\intss, because you'i! get too much space between the symbols. So use \twoint: \int\int / /

\twoint / / There's also \threeint and Vfourint, as well as

\mul tint / "" " /

These symbols often occur with a single lower limit. When the format calls for limits above and below / signs, this lower limit is centered under the symbol. For example, $$\twointXMss will give // 11, M - depending on the format.

235 * SIDETRIP. If you specify $\sized-C\sum4.{n-_i>tw xXn}s within text, you TO will get 22 xn, and if you specify $\sized-_\int T<+\infty}X<-\inf ty}}s n=l

+00 you will get for with J^ J J lots of extra space around the line. But you

m 00 can't get £ xn or in text without consulting a IgCpert. n=J ___/ SIDETRIP. Sometimes several rows of limits must be stacked under a large operator, as in the displayed formula ( w E p^x) o

You can get this with \atop, but you have to be a little careful. If you type £$\sumX-CO

o

$$\suini<\sizes

If i were in x

2-36 (

(.

( §8. Spacing and roman letters. Although Te-X can usually figure out the correct spacing in formulas, it some- times needs a little coaching. That's why the previous section didn't display any formulas like b f(x)dz a even though there were several displayed formulas involving the sum sign £\ The fe problem here is the space between /(_.) and dx—careM typesettersalways supply it, but Tp}{ would get too confused trying to do that automatically. Although this space is important, it's quite a bit less than the space you would get with \l_J. So at this point it would be nice to know a little about the way that T&X measures things. "Points" and "picas" are printers' C traditional basic units, so T&X understands points and picas. T£X also understands inches and certain metric units. Each unit of measure is given a two-letter abbreviation: pt point Pc (one pica equals 12 points) c in inch, (one inch equals 72.27 points) cm centimeter (one inch equals 2.5400 centimeters) Typical "dimensions" are 3 in ipt C + 29 pc -0.01 in Oem Notice that a space, between the number and the unit is optional. Also optional is the space between the number and a + or — sign (latter on we'll sec some reasons why you might want negative dimensions!); moreover, a + sign is redundant, but allowed. There's one other thing that it is very important to notice: to get a dimension of one point you must specify lpt, not simply pt; and if for some reason you have to specify something whose dimension is zero, you must specify Opt or Oem or Osomcthing--0 alone is not a dimension. c You don't have to remember all these units, of course. You will probably vanI to use inches or centimeters if you ever use \vskip to leave space for a iiclurc, as explained on p. ?? But for most typesetting purposes, the unit you really need is one that we haven't mentioned yet, the

em c

C

237 J» An cm is a unit that depends on the particular font being used—in 10-point type an em is usually lOpts, in 8-point type it is usually Bpts, etc.* The advantage of using ems should be obvious: any spacing you specify will automatically be / adjusted to correspond to the type size eventually u_-«d for setting the paper. Notice again, that you ?ra/_i type iem, not just em, to specify a dimension. Printers have a special name for a horizontal space whose dimension is i em—it is called a "quad" (originally a "quad" was a square piece of blank type). Quads have become standard spaces for typesetting mathematics, so TfrX uses \quad to stand for this amount of space. Thus, \quad means essentially** the ( same thing as Xhskip lem. 'IfcX also has the control sequence Xqquad, which is equivalent to \quad\quad. The space Xqquad is usually just the right amount for a display containing a main formula _with a side condition, like Fn = F„__i Fn 2, n 1. + > C This may b„ specified by the input

$$FXn- FX {n- I}+ F Xl . (in winch all typed spaces arc ignored). A XquaJ is a rather big chunk ofspace, more than the space between words in a sentence, so T^X has much finer units for use within an equation. For example, printers usually surround = signs with a "thick space", which is of a quad.' T£X uses \; to stand for a thick space, but you will almost never need r to use X; explicit!)', because I):;X puts the thick space in automatically. TrX uses \, to stand for the printer's "", which is 1 of a quad. This is the space you will want for formulas involving integrals:

$$XintXaTb f(x)\,dxss f[x) dx a And in general, you will want a thin space before dx or dy or ./whatever in calculus formulas like the following:

dx\,dy=r\,dr\,d\theta dxdy ~ rdrdO

♦The name em mines Tor the Tart thai an cm-dash is usually lem wide (;ilihouj-|, a rout designer is free lo i- 1loose (he sizes Ibv the. em, the ein-ilash, ami an upper case "M" at will). "-"There is a distinction between \quad and Xhskip 1 em. because em always refers to the particular foul beiim used in the main bod.v or the lext. while \quad in math mode refers to (he Tout set at (he hei.m lime; for example, (he size or \quad in a superscript dependson the particular font being used for (he superscript.

(

.>

238

i, f But don't use \, for "derivatives", involving one ..something over another, like dy dy/dx or — . There arc a few other occasions when you will need to play with TeX's spacing, but they arc so special that they have been included with the fine points in §11. Spaces arc not the only things that you will want to insert into formulas. Sometimes you will want ordinary type, as in the formula C y = f[x + constant) You can't type y=f(x+constant), because you'll get y — f{x +constant) c And if you try to type. y_=f (x*-C\rm constant}) you won't get. anything at all—the instruction Xrm just isn't allowed in math mode. But you can obtain roman letters, or anything else that you would get outside of math mode, by using Use control sequence \nomath:

( y=f (x+\nom3th-Cconstant}) Notice that the proper spacing occurs automatically around the + sign— -T^X treat,I "constant" just like an ordinary math symbol x. 11-.re is a somewhat more complicated example. To gel the display:

V ? n — 7 „_i + F„__2 for every n > 1 you can type

$$FXn-FXl . $$

C Notice the space between <\it every"} and }; it was needed to get the space between every and n > 1 in the output. A safer possibility would be to type \nomath

C

*v_

;

$n>is}

239 * Roman letters have another, very special function in mathematics. Common mathematical operators like "sin", "cos" and "log" are always set in roman type (these symbols arc abbreviations for "sine", "cosine" and "logarithm", respec- tively). It would be a nuisance to type \nomath

$$\maxX{l

sin x $$\limX{x\goestoO}<\sin x\frac x}=lss lim = 1 _■—0 x $$2T<\,\maxX

C

c

x„

240 1 +

The last example should serve as a reminder that krgc operators have their limits set as subscripts and superscripts in exponents. Il also shows you that the type size gets smaller, as it should, in exponents. None of these features would be supplied by \nomath

\opname and \Opname

For example, \opname{hog} will produce an operator hog which is treated just like log:

$$\opname

And \Opname

c

(The list will include such things as \Sin, to be used in the construction \SinT<-l}x to get Sin _I x.) c

241

C

$s-2T<\,\MaxX

(3-1) x = y while others put them on the right:

x = y (3-1)

To produce the above equations with a tag, just type $$x=y\tag(3— I)ss AAVS-I\J}\ will automatically choose the appropriate placement for the tag. The preprint format normally places tags on the left, but you can opt for tags on the right when you make changes in the format, as explained in Chapter 5. Notice that tags are processed as ordinary text, rather than as formulas in math mode, so that — gives you an en-dash, rather than two minus signs. If you need a tag processed as math text, just use $ signs. For example, \tag $AT\primeswill give the tag A' and \tag AsXls will give the tag Aj. In addition to deciding which side the tag goes on, \tag also makes a lot of other, more subtle judgements, which arc part of the classical typesetting tradition. For example, the equation itself is centered, unless this would place it too close to the tag, in which case \tag tries to compress the equation somewhat, and possibly move it over to (.he side. Finally, if this ploy fails, \tag puts the tag on a separate line. Left-hand tags go on the line before the formula: (3-1) a very long formula . while right-hand tags go on the line after the formula:

. . . a very long formula (3-1)

242

V 1 *- Of course, you don't have to remember any of this—-_-L4l_r-T£X docs it all for you. C Another common combination is a display containing several equations, in which certain symbols arc aligned. For example, in the display x—y = z x2 -=y 2 3 X x3 = y

the = signs arc aligned, and the three equations arc centered as a unit. To produce this display, type

$$\align x & = y = z\\ C xT2 &. = yT2 \\ xT3 & - yT3 \cndalignss The si;rns serve the special function of telling T].X which symbols arc to be aligned; they should immediately precede these symbols. Notice that \\ separates C the various lines, while \endalign indicates the end of the whole alignment (and takes the place of the \\ after the last line). Of course, it's not necessary to type the input exactly as shown, with the &. signs lined up. All those blank spaces, including the ones created by single (carriage.-rcturn)s, don't count in math mode; they just make the input look something like the intended output (so they can be helpful at first, though you'll soon tire of typing them). SIDETRIP. You can insert extra space, of a certain dimension between lines of an \align by putting \xspace (dimen) \\ r v between them, where (dimen) is the dimension, like 6pt or lem. Don't use \quad here, since it is not a dimension, but a horizontal space having the dimension lem.

One of the surprising things you can do with \align is to allow some of the formulas involved to be blankl For example, you can get the display C 2 (a + b){a +b) = a2 + 2, a6+ 6 , (a + b){a - 6) = (a + 6) - (a + 6)6 1 = a2+ ab —ab— b 2-62 C = a .

C

V

_.

243 . > which contains one short equation and one long broken equation, with the input $$\align (a+b) (a+b) __ =aT2+2ab+bT2, \\ (a+b) (a-b) & =(a+b) a-(a+b) b\\ &. =aT2+ab-ab-bT2\\ ii =aT2-bT2.\endalignss By the way, this example illustrates an important rule about breaking equations in displays: although equations within text arc broken after equal signs and other binary relations, long displayed equations should always be broken before binary c relations. You can also use \align to obtain the broken equation Z = {X + Y)[A -| B+ C +D+£ +F + G + # + /f +L + Af + /V) t n T C This equation illustrates another important rule for breaks within displays: al- though equations within text are broken after binary operations, this equations is- broken before, a binary opcralio.i, namely the + sign which has been singled out by a double arrow f|. The single arrow., f have been used to indicate the paren- theses that surround the subformula in which this + sign resides. The placement of the + sign illustrates another important rule for breaks within displays: the + sign lies somewhat to the right of the corresponding left parenthesis, usually at least I wo quads to the right. So to get this broken equation, type $$\align Z-(Xh-Y) & (A-> B+C-»D+E+F\\ 1 Xqquad -t-G-<-H-<-K+L-»-M+N) \endal ignss SIDETRIP..Remember that you can get extra space between the lines by using \xspaco . . . \\. Sometimes you might want some extra space for the sake of clarity —a couple of points will usually do. And the following example shows a case where you will want negative space. If you type $$\align Z=\sumXi (XXi+YXi) _. (AXi+BXi+CXi+DXi+EXi+FXi\\ &. Xqquad -t-GXi +HXi+KXii-L.Xi-. MXi+NXi)\endal ignss you'll get Z = J2(X + Y^A +B'+C>+D' + Ei + ft i ' ' + d + Hi + Xi + Li + Mi + Ni) which seems to have a lot of extra space between the lines, because the first line has the . under the £ sign. So you should put something like Xxspace -Bpt \\ between the two lines (.

244

C

( +

SIDETRIP. You might have a little trouble with a formula like Z = {X+Y)(£+C+D+ E+F + g+h +k.+ l~\-m-\-n\ where there is a big right parenthesis on the second line to match the big left '■'3 parenthesis en the first line. For the first line you could use the construction \left(-CA\frac B>+ C -.D+E+FXright. But a similar construction won't work on the second line—a Xright) will still j>ive you an ordinary size ). The simplest way out is to use Xbigglp and Xbiggrp, which wil! probably be the right size. SIDETRIP. SIDETRIP. In a complicated case you can use the control sequence .Xphantom-C. . .}, which produces an invisible symbol of the same height as the'formula that appears in the braces {. . .}. For example, the second line of ih_ above equation could be specified by

..Xqquad \left. \phantom{A\frac B} + G-t-H-»-K-i-L+M-i-N\ri£ht)

In the previous paragraphs we relied on two generally accepted rules for breaking displayed equations: (1) Break a disnlayed equation before binary relations and operations. (2) When an equation is broken before a binary operation, the next line should start at least two quads to the right of the beginning of the smallest subformula containing it. More elaborate sets ofrules can be compiled, but they vary from printer to printer, and in any case are never really adequate. T£JX doesn't even attempt to break long displayed formulas, because this is an art—the author of a mathematical manuscript should really determine all breaks, since they depend on subtle factors of mathematica! exposition. (Since it's often difficult for the author to foresee the need for breaks, the judgement of the experienced technical typi;:l can also be invaluable.) c There's just one other printing convention for broken equations that you should know about. The following display shows a special form often used for an equation requiring two lines: A+B+C+D+E+F+G+H + l + J + X + L + M + N C =P+Q+R+S+T+U+V 2-45

_- (

+ The first line begins near the left margin, and the second line ends near the right margin, the exact distance being determined by the formal. This form is generally preferred for a broken equation with a long left-hand side. The above display was specified by r

$$\twol me A+B+C+D+E+F-I-G+H+l-t-J+K-i-L+M+rAX =P+Q+R-tS+T+U+V\endtwol mess

( SIDETRIP. If you want extra space of a certain dimension between the two lines use '

$$\tv;oline5 Pace . . . \\(dimcn)\\ . . . \endtv/ol inespacess where (dimen) is the dimension, like 2pt or iein. (And once again, don't use . Xquad, which is not a dimension, but a horizontal space having a dimension of lem.)

f

X

c

246 f V §10. More about equations in display.

In the previous section we saw that Xalign can be used to produce broken equations as well as aligned ones. Actually, \al ign is even more versatile than this, because the the result of an \al ign is a unit; it may be regarded as a single formula, or as one gigantic mathematical symbol. So, for example, you can get the display c ra = b la2 = 62 simply by typing

$$\leit\

/ , \ c = d c (with the two pieces centered vertically with respect to each other) by typing

$3\left\-C\al ign . . . Xendal ign\right . \qquad\lcft\-_\align. . . Xendal ignXright . $$ c Incidentally, this is a good example of a situation where a couple of on-the- spot control frequences can keep you from going bananas. It would probably be a good idea to handle the input somewhat as follows:

/- $$\def\l<\align. . . Xendalign} Xdef\2<\al ign . . . .Xendalign} \left\-C Xl Xright. \qquad\lef t\< \2 Xright. ss

c CAUTION. The neat feature of Xalign as a unit docs have a disadvantage, similar to the problem with \f ootnote and Xvskip. If you ask for an Xalign that is too long to be squeezed onto the current page, T]rX will cut short the current page (inserting additional line spaces to bring it to the proper length), and the \al ign will appear at the lop of the next page. Some rewriting may be necessary; a long \al ign might have to be split in two. C

247

i _ > Since an Xalign is a new formula, you can \tag it, just like any other formula. The input

$$\align a__=b\\ c__=d\\ e&rrf\\g____h\endal ign \tag(l)ss will produce the display a = b c _= d .-/ m g = h (or the same display with the tag on the left). Notice that the tag is centered with respect to the aligned set of equations. This is fine when you want to put a tag on a whole set of aligned equations, but there arc two situations where something else is called for. First of all, you might have a display like

(1) o=6 = c a2=62 (2) a3 =63

involving several aligned equations, some with individual tags. For this you will need \aligntag. To get the above display, type

$$\alitintag a & =b=c \tag (I)\\ aT2__ =bT2\\ aT3__ =cT3 \tag (2) \endal igntagss

The second situation involves a long broken equation, like m+ a = b

— d Although it's a type of \al ign, any tag it bears is customarily not centered, but is placed cither at the beginning of the first line:

(1) a= 6 = c = d

(

(

248 . or at the end of the last line: a = b = c -__d (1)

To tell \aligntag that you arc putting a tag on a long equation, use \ltag instead of \tag on the first line of the equation, and put \endltag on the last € line. For example, to get a display which will appear either as (1) a=6 = c (2) d = c

= 0 or as

a _= 6 = c (1) <_ c C = = / (2) you should type c $$\al igntag a &. =b=c \tag (I)\\ d & =c \ltag(2)\\ ii =f\\ ii =g \endltag\endaligntagss

CAUTION. An \al igntag isn't as versatile as an \al ign; you can't slick an \al igntag inside other constructions, because an \al igntag is already as wide as the whole page (although it may have a lot of blank space on one side or the other).

L. SIDETRIP. Just as with an \align, you can insert extra space of a certain dimension between lines of an \al igntag by putting \xspace (dimen) \\ between them.

C

4.

249 '} SIDETRIP. You can also insert an extra line of text . . . between lines of an Xalign bag by putting \xline . . .\\ between them. The extra line will start at the left margin of the page. For example, you can produce the display (1) a = 6 c = d and hence, since a2 =62 by (1) (2) a2c = b2d. by typing

$$\al igntag a __ = b\tag (I)\\ C c ii = d\\ \xline and hence, since $aT2=bT2s by (I)\\ aT2c = bT2 d . \tag (2)\endal igntagss

Even if none of your equations have tags, you should still use \al igntag if you need a construction like this. (If you use \xl me . . .\\ in an \al ign, the text will start at the left-hand side of the \al ign, instead of at the left-hand side of th_ page.)

SIDETRIP. There's actually one other situation where you don't want things centered after an Xalign. If a proof ends with an Xaligned set of equations, and you use the control sequence Xqed (page??), you shouldn't type it after the Xendal ign, but instead make it part of the last line of the \al ign. There's still one more possibility that we have to talk about. Sometimes you will need a display consisting of a bunch of equations which arc individually centered, instead of being aligned: a=6+ c d = c /+<.=/- One possibility is to type

$$a=b+css \closeup $$d=ess \closeup $$f+g=hss

The control sequence \closeup deletes the extra space which would normally appear after one displayed equation and before the next one. Another possibility

C

250 . is to use the control sequence \bunch, which is just like \align, except that you don't need any & signs, since nothing's being aligned:

$$\bunch a=b+c\\ d=e\\ f-»-g=h\endbunchss

A \bunch is a unit, just like an \al ign, so it can also be given a \tag. But if you c want a bunch of centered equations with individual tags, you'll need \bunchtag, which is just like \al igntag, except that once again no signs arc needed. By artfully combining these control sequences you will be able to specify all the impressive displays in the following exercise.

C

c

c

ic

_.

251 4 §11. Fine points of mathematical typing. This section contains, not to put too fine a point on it, lots of little things that didn't seem to fit nicely anywhere in the previous sections. Since there arc a good many topics to be covered, sometime., in irritating detail, it's probably best to glance idly through this section, just to sec what maneuvers are available, and then refer back to it as needed.

1- Dots We've already introduced the control sequence \dots to produce the f proper spacing between the three dots in sentences like "Hmm ... I wonder why?" Three dots arc al:.o used in mathematics formulas, but the best mathematical typesetting traditions recognize numerous subtle distinctions. For example, in the formulas (xj,...,Xn ) Xj-j \-Xn 2^+-+*» r low dots arc used in the first, while centered dots are used in the second and centered dots witout extra spaces between them arc used in the third. J.Jih'J-Tj^i has icveia! different control sequenceswhich will enable you to produce formulas that even a master printer would be proud of. al) Use \cdots (three centered dots) between binary relations and operators

$xssbl= \cdots=xXn=os "x,= " ■ " = xn = 0 :.Xl-.\cdots->-xXns x\ + \- xn AXl\cap\cdots\cap AXns A\C\--- C\An $$2T-C\,xXi-.\cdots-+-xXnXss 2;r '+' +I" Notice that a space before \cdots is irrelevant (since we're in math mode); notice also that the spaces between the dots arc automatically deleted in superscripts. The dots which appear in \cdots arc the same as the multi- plication dot, specified by \cdot, that is used in formulas like x y; this dot depend? on the particular font being used, and is often larger than a period. a2) Use \cdotss (three centered dots followed by a thin space) when the three dots are followed by punctuation. For example, the input

the infinite sum $yXI-i-yXI-. \cdotsss

produces the output

the infinite sum y\ + y2 + " "

C.

C

"

252 A3) Also use \cdotss when the dots separate integral signs: X i i \intXoTl\cdotss\intXoTl o 0 Although __t^H._.-I)jX gives you \ldots for three low dots, most of the time you'll want to use one of two related control sequences: bl) Use \ldotss (three low dots followed by a thin space) before commas: C $CxXi,\ldotss,xXn)s (xi,...,x v ) The dots of \ldotss are ordinary periods—only the spacing is adjusted. You have to be in math mode to use \i dotes, but it is still useful for producing the "literary" throe dots when they are followed by a comma. For example, the input

the components $xXls, $\ldotsss, $xXns of $(xXl,\ldotss, xXn)s produces the output c the components xj( , X„of (X],...,!,,)

Notice that the first two commas, typedoutside of math mode, are followed by larger spaces (and, if necessary, T^X could break a line a.rtcr one of them). b2) In "muhiplicalivc" contexts, like X|X2 . . .x„, where the three dots don't have any other symbols around them , use \idotsm (three low dots prccecded and followed by thin spaces):

xXlxX2\ldotsm xXns x\X2 ...xn Cl-x) (l-xT2)\ldotsm(l-xTk)s (1 — x)(l - x 2 . ,. (1 - xk). 2 Exception: For the formula x'x . . . x", type $xTlxT2\ldotss xTns be- 2 n cause x'x . . .x already has "hole" at the after x 2. Here is an example that uses three kinds of three dots: To get the formula l i /(*j, , x,,) dx\ . . . dxn o t) you would type $$\intXOTl\cdotss\intXOTi f CxXl,\ldotss,xXn)\,dxXl\ldotsm dxXnss

X

(

)

253 b3) Finally, when an expression involving three low dots comes at the end of a sentence, you'll want to use \ldotss\, (that's three low dots followed by two thin spaces): the sequence 0, 1,0, 1 , $\ldotss\, $. the sequence 0,1,0,1,. 2. Vertical Lines. The symbols I*l 11*11 (*) [x] {x} [x] [xj all occur in mathematics. Oddly enough, it is the simplest ones, |xj and ||x||, which can cause problems. For example, compare the following $[-x]_-[+x]s [—*] = [+*] $\<"X\}=\

$$\left|-

C

c

c

254 .. Sometimes | is used in quite a different way, to indicate the relation of divisibility: a \ b ("a divides 6"). If you type $a|bs you'll get the unpleasantly c squashed formula a\b, so you should use the special control sequence \relv for a vertical line used as a relation:

$a\relv b$ a\b

A third use for | is in formula 1, like {x | x s}, which :C > is read "the set of all x such that x > 5". The control sequence \rolv gives the right spacing for the | in this construction, but you will also need special spacing for the braces, which is supplied by \leftset and \rightr. et: $$\leftset x\relv x>_s\rightsetss {x|x > 5 } C Some mathematicians prefer the formula {x : x > s}. The control sequence \relcolon will give the right spacing for the colon. SIDETRIP. Formulas like

r {*\tXi <2} and {,| p + ,<2}

were treated on page ??, except that we didn't worry about the spacing. The control sequences \leftset and \rightset actually give variable size braces, jc so they are the things to use here instead of \left\{ and \right\}. To get the proper spacing around the vertical line, use the control sequences \leftrelv and \rightrelv instead of \lef 1 1 and \righb I :

$3\leftset x\leftrelv_x\frac x+l}<2\rightset\right . ss $$\left . \leftset p\frac q \rightrelv p+q<2\rightsetss V. 3. Accents in math mode. Mathematicians often accent letters to give them special meanings:

x x x x x x It-

Other literary accents hardly ever appear, but there are some additional accents that arc used in math mode. For example,

$\b x$ x c

255 This small arrow accent is indicated by \b because x is often used instead of a boldface x. In math mode you can accent an already accented letter, to get a double accent:

X

In fact, you can accent any formula at all. But this usually isn't very useful, since the accent just gets centered over the formula: (

$\b-Cx+y}s x + y Of course, in this case you would probably use \arrow:

$\arro-.v-Cx+y}s x + y Notice that the. a.rrow head is somewhat larger on \arrovv —in general, \b looks better over single letters. To indicate that a small arrow is supposed to apply to a whole formula, you may want to set it as follows: $(x+y) \supbs [* + vf The control sequence \supb gives the accent ' set as a superscript. There's also a \suparrow, with the large arrow-head, just in case you want it. The other accents need special discussion also. (i) You may wish to use \cverline rather than \= even for single letters:

$\= x$ X $\overline x

You will probably want to \overline a whole formula, but the accent " can also be superscripted, like \b: $\overl ine{x+y}s x + y $(x+y)\supequals (x + y)~ (The control sequence giving as a superscript is called \supequal , since "\sup=" isn't the name of a control sequence.)

.

(

$\A<\=x}s

x$

"

256 f (ii) There arc four kinds of dot accents in math mode: $\dot x$ x $\twodot x$ x $\threedot x$ x $\fourdot x$ x These dots may not be the same size as the ones in V'x, so don't use \" in math c mode. For formulas, there are \supdot, \suptwodot, etc. $(x+y) \suptv.'odots (x + y)' (iii) The squiggle \c doesn't look so hot if it's applied to an upper-case letter (this doesn't happen in c literary contexts), so you should use \bigs instead: $\s M$ M $\bigs U$ M preferred There is a \sups for use with formulas: C $(x-t-y)\supss (*+_/)" But mathematicians usually prefer to have long squiggles set over long formulas: $\longc-Cf (x)}s fix) $\longgs

C

257 (v) The accents \v and \u arc seldom used. There are also \supv and \supu. 4. Ovcrscripts and underscripts. In addition to accents, other symbols are sometimes set over or under a letter, instead of as a superscript or subscript.

y=x2 x 3 A) =Bi A M + x J J x a/3

_s-._/1-.-.-TeX allows you to produce these formulas by typing ( $$y=\twodots xOT2+\oset \sizess{(b)}\to x<}T3ss $$\uset \sizess

$$\obrace

$$\uset\sizet<>o}\to

$$\uset k\u\opname-(times}\to

2-58 . Chapter 3. T^'s Erroneous Zones.

In Chapter 1 we learned how to run Xs4l>_. -TeX, but a few details still need to be explained. For example, you might want to sec how a paper will look in some journal's format. To do this, you simply replace the line \input preprint in your file by a similar line that tells l£X to read the description of the jour nal's format. For example, to get the format of the Bulletin of the American c Mathematical Society , put in the line

\input bams Appendix J gives the names of the appropriate files for all journals whose format has been incorporated into i^W-T]^ at the present time. X Even if you use the preprint format, you may want to make various changes, as will be explained in Chapter 5. All of these changes can be placed in a file changes . tex, and then you simply add the line

\input changes

€ right after the line \input preprint

There are also a few options that can be exercised when you print a paper. Your system probably has a way of modifying the verser command so that you print pages, say pages /" only certain 3-8. This can be useful if you make changes in a portion of a large paper, and only want to see how the new part looks. One problem with this procedure is that you may have to guess at the appropriate pages. Another possibility is to go right into your file and insert the lines \outputoff at the beginning of the file \outputon at the beginning of the section you want »■%_. \outputoff at the end of the section you want

Then when you tex your file, the dvi file will contain the part you want. (The dvi file won't construct pieces of a page, so if the section you want begins some- where in the middle of page 2, you'll get the top part of page 2 also; and if it C

31 ends somewhere on page 4, you'll get the remainder of page A.) Actually, you really don't have to put \outputoff at the beginning of the file: When _4._4k.f- TeX asks you C Do you want output? (y or n, follow answer by return)

typing y is the same as putting \outputon at the beginning of the file, and typing n is the same as putting \outputof f there. ( Congratulations, you now know everything there is to know about running _4._41.-. -T£X! There's just one problem—it probably won't work. When you try to run -sOli:. -TeX you'll undoubtedly get some error message, which will cause leX to stop. (Remember that even an innocent misspelling can be a serious error, if it involves a control sequence, and of course by now we know enough to make a lot more hideous errors.) ( We've been mentioning "error messages" all along, but we've put off serious, consideration of errors until now, because it's undoubtedly the most unpleasant aspect of using TeX (or any other computer system). TeX does it's damndest to diagnose your errors for you, but it can't really know what's in your mind—all it can do is tell you what seems to be wrong with what's in your file. As we shall see, sometimes TeX won't detect an error at all (but you'll see it in the output), and sometimes TeX gives a completely faulty diagnosis of your error, because your concept and TEX's concept of what you arc doing are totally disparate. There's only one thing you can be sure of: if TeX says there's an error, then there is an error (but it might be a real bitch to find). Experience is the best teacher in matters of this sort, and you'll probably get a valuable education as soon as you start using JLJi$-Ts<. seriously. The aim of this Chapter is to familiarize you with the most common sorts of errors, and give you some hints on how to detect them, so that you don't go out intoJ,he real world totally unprepared.

The remainder of this Chapter hasn't been written yet. All we have is the list of error messages:

(

(

32 „>

THE ERrOrS OF IfeX

jAmbiguous; you need another "_ and You seem to be using or \atop m \frac more than once in the same group. iAll mixed up, can't continue. Something has gone wrong with your use of a construction involving the symbol &, like \align or Xconditions or \array (Chapter 4). iArguroent of (control sequence, can *t begin with You're using a c control sequence with one or more arguments, and for some reason you began one of the arguments with } (maybe it was supposed to be < ). !Blank space should follow file name. You've probably goofed right at the start. Maybe you did something like putting \input preprint right after \input amstex (on the same line, instead of on separate lines). Start over. ( ! Display math should end with $$. While processing a displayed equation, TeX got to a single $ sign (one which wasn't buried in some other construction like \nomath-ffor $x>os}). Maybe you just typed $ instead of $$ by mistake. If not, you'reprobably in deep trouble. LDouble subscript . c You applied X twice to the same thing. S_JDgu.b.ljg_Sujge rscri pt — - --—i - . You applied T twice— to the same thing. J Extra (something,). There arc several messages telling you that your input text contains something extra. For example, if your input contains $x}+ys, TeX will say that you have an extra }. If you get the message Extra al ignment tab, you have probably forgotten the \\ thaat separates the lines in an \align or Xconditions or something like that. Or in an \array (Chapter 4) you may have fewer \c, \1 and \rs than the number of columns you're trying to set. C j. First use of font must define it. You probably typed \: somewhere by mistake (this is a control sequence, never mentioned in this manual, which is used at the most fundamental level of leX design). If you type \: and you don't get this message, then something else weird will happen—you'll probably find that the output has suddenly changed to some C

C

: '■ ■■ ■ ;■» " in*,..

33 <- *1 completely difTerent font; strange symbols may appear in profusion. Beware! Don't ever type \:

L-Aha.Ugr_-_iJL__m^^ r You've used \al ign or \array (Chapter 4) orsomething similar, but not between $$ signs. ! Illegal font code You've probably typed \; by mistake (see ! First use of f ont ... above). 1 Illegal parameter number in definition of .controlscq. c You did something like Xdefine\R#i{x+#2}. ! Illegal unit of measure (pt inserted You have a dimension like 3qt which TeX doesn't understand (maybe you typed it incorrectly, or just forgot the unit). If you press (carriage-return), TeX will interpret it as 3pt (and make the qt part of your input text!). Input page ended while scanning def of (controlse* You' probably forgot a } somewhere in the definition of the control sequence. J LnPMJ_-J_a^ This message has been preceeded by a Runaway argument? message, showing the beginning of some argument to a control sequence that apparently never ended. Maybe you started with a < but never put in the }. Or perhaps you followed the suggestion on page ?? and defined \def ine\R#l*#2*<. . .}, and then forgot about the *s when you used \R. I_ lfealA must follow an expl i c it c haractLer . You used the control sequence \/ (page'??), but not rigH after a letter (maybe you left a space before it). L Lookup failed on fi 1 c (filename). You told TeX to \input a file, but it couldn't find it. Maybe you spelled it wrong. Maybe you've forgotten what you called your file? J Missing (something) inserted . This message is a little misleading: TeX hasn't inserted anything directly into your file, but jnlo a copy of your file that it has made for processingj>ujj^oses. If you press (carriage-return), TeX will pretend that the (somcthing)is there . This message can arise in lots of ways, and it can name a variety of things that TEX sometimes thinks arc missing (TeX may be wrong—it's just guessing). You might be told that a missing < has been inserted if you forgot to put braces in a construction that needs them, like \topinsert (page??) or \ctrline (page??). If TeX says that a $ is missing it may be because you have a \par or blank line in the middle of a formula—whenever TeX gets to a Xpar inside a math formula, it assumes that you meant to end the formula before the Xpar.

V

34 r- *

[Only one allowed per tab. You've probably* forgotten to put an & between the \c or \1 or \r for one ( of an Xarrayand the one for the next column. (This message is a little mysterious _s4._>lk-f- in TeX, since \array doesn't even use #, but don't worry about it.) j__gnl_L_^ijigXe._ch___rac^ be accented in horizontal mode . You tried to do something like \'{ab}, and you weren't in math mode (where it is allowed). C 1 -_aj_aroeters must be numbered consecutively When you define a control sequence with arguments, you must list #1, #2, ... in that order (page ??). Runaway argument? See ! Input page ended while ... above. ! TEK. capacity exceeded, sorry ... You've asked T£X to do something it's not big enough to handle—there will be a second part of the message giving some ide| what. If it says memsize ? you've = asked it to store too-many things in its memory. Maybe you made too many definitions (you're only allowed to make ???). Maybe you just made one of those ( crazy definitions we warned you about (page ??). If it says savesize =_?, you've probably put a < somewhere and never closed it up with a }. Or you may have tried to make a gigantic \array (Chapter 4) that's bigger than a page. If it says anything else, you'd better call in the experts. !_-_lJie.rg_.'s no \halign or \val ign_g£ihjg_on .' Your input contains an ( &.which doesn't seem to be part of an \al ign or Xarray or something like that. You might have simply typed &. instead of \& to get a & in the output. Or you might not have matching -Cs and }s somewhere in your \al ign or whatever. j This can't happen . Something really unexpected has caused TeX to come to a screeching halt. Call in the marines! j Too many }' s Just what it says. |_ Undefined control sequence . c You're using a control sequence that TeX hasn't (yet) heard about. Maybe you forgot to define the control sequence before you used it. Maybe you just spelled it wrong. MJnknown delimiter. You've used \left or Xright followed by something not mentioned in Chapter 2§6.

C,

35 *. "■""■. ! Use of (controlseq) doesn 't match its definition, You've probably made a definition like Xdefine\R#l* #2*{. . .} and then typed \R x*y*. Your definition tells TeX that there should be a space after the first but your use of the the control sequence doesn't conform to this. ! Warning: Long input line has been broken. Yourinput contains a very long sequence of characters between (carriage-rcturn)s. TgX arbitrarily broke it after 150 characters. Whoa ! have ti ( You probably forgot to put \input amstex at the beginning of your file. ! You can only define a control sequence . You typed Xdefinition and then the next thing wasn't a control sequence (maybe you just left out the \). ! You can't do that in (mode. . This is the biggy, which we've already discussed. ! You can't redefine this control sequencej.rj^____^„S__. You've tried to define one of the control sequences which X/V-J-TeX won't let you redefine, because it is used in the definition of yet other control sequences. The shorter message !__J__yL_-_-3_a___-_-jr^ indi- cates that you have discovered one of the control sequences which even TeX won't let you redefine, because it is used at crucial points of TeX processing.

t

*,

you

36 ,>

Chapter 4. Hardcore Typesetting: Sophisticated Positions * We can now typeset incredibly complicated formulas, and all sorts of displays involving aligned formulas. But we still can't get a "matrix" , the parenthesized C array that appears in the equation ( x 1 .1 X A= \ x+ y 11 .11 , \x + y + z in .my or a construction like for x > 0 {x— 1 for x < 0 .

( Of course, we know how to get the parentheses and the left brace (and the right nothing). But we've never tried to set the arrays inside them. Now we're ready to do it, using the control sequence \array. Notice that the various columns of the array

X 1 .1 C x+ y 11 .11 x + y+z 111 .111 are set in different ways: the elements of the first column are centered within the column (this is the usual way of setting formulas in an array), while the numbers . in the second column are set flush right, and the decimal numbers in the third column are set flush left. The choice for each column is the first thing we have to decide upon whenever we use Xarray. We also have to decide how much space we want between the columns. For example, the above array has a quad of space after the first two columns (a standard choice). Now we can get this array as follows: c $$\array \c\quad & \r\quad &\l\\ x &. 1 ii .I\\ x+y k 11 ii .11\\ x+y+z&lll-k.lll \endarrayss 10

41

iC

v (

■V

This is nearly self-explanatory. The first line (everything up to the first \\) specifies the arrangement of the columns and the spacing: \c\quad indicates a column with centered elements followed by a quad of space; \r\quad indicates a column with elements set flush right, followed by a quad of space; \1 indicates a column with elements set flush left. The &. signs separate the specifications for each column, and the \\ ends the specifications. < After the specifications we simply list all the elements, row by row, separating individual elements in a row by __, and separating the variousrows by \\. Finally, we end the \array with \endarray (which takes the place of the \\ at the end of the last row). ( Of course, you don't have to type the \array like this, with each row on a separate line. You can use any arrangement you find convenient, since spaces and (single) (carriage-return)s don't count in math mode. CAUTION. You must specify \c or \r or \1 for each column. If you have the column of double-digit numbers 21 22 23 24 25 then \c, \r and \1 will all give the same arrangement, since all numerals have the same width. Nevertheless, you have to pick one! CAUTION. The control sequences \c, \r and \1 are subsidiary to \array, and like \endarray, they can't be replaced. In other words, even if you m^ke the definition \def ine\center<\c}, you can't use \center instead of \c in Xarray. SIDETRIP. On the other hand, if you've already defined \c or \r or \l, you don't have to go back and change it to something else. -X_-.1_.-TEXwill temporarily ignore your definition while it is setting the \array. Using the above \array input we can now get the first formula in this chapter by typing $$A =\left( \array \endarray\right) \, , ss The thin space between the matrix and the comma had to be inserted by hand, but the = sign and the comma automatically come out at just the right height.

42 .1. Exercise 1. How would you get the second formula (be careful about the period!). CAUTION. As you should realize when working this Exercise, you will need c \nomath if you want non-mathematical things to appear in an \array. You probably set one of the elements as \nomath-Cfor $x>os}, with a pair of $ signs buried inside the \nomath. But be sure not to type the first element as X, $x+ls: .W-TeX is already processing things in math mode in an \array, and a naked $ sign will lead to complete havoc. C To vary the space between columns of an \array, just change \quad to some other amount of horizontal space, like \qquad or \quad\qquad or \, or more generally \hskip (dimen), where (dimen) is some dimension, like 6pt or .6em. If you don't specify any space after a column, it will be set right next to the succeeding column. On the other hand, the usual space \r between rows is . 3em. To get extra space of a certain dimension between two rows, simply put \xspace (dimen) \\ between them, where (dimen) is the dimension. (Don't use \quad here, since it's not a dimension, but a horizontal space having the dimension lem.) C This is the whole secret of setting \arrays—all the rest is commentary. you 1. If have a complicated formula as one of the entries, it will come out as if it were being set in text: $$\array \c \quad ii \c\\ N a k \sumXiTN xXn\\ a £_ xn b it c\endarrayss b c

But you can always use \sized to get it set as a display

$$\array\c\quad__\c\\ N v. a_Asized-C\sumXlTNxXn}\\ l_,xn b__c\endarrayss ° l 6 c 2. the If entries of an \array involve any sort of stacking, then within each row the entries will be vertically centered with respect to each other: X $$\array\c\quad__\c\\ % _j_ x+y__\sized{A\frac b}\\ _ S \sized

X

x

43 c . SIDETRIP. The \array $$\array\c\quad__\c\\ x+yi\sized

(

44

c

c * > > 4. As far as T}2_ is concerned, an \array is just another (gigantic) mathematical symbol. So, for example, you can get the aligned equation fa 6WO l\__fa-Q + b-l al + 6 0\ \c d)'\l o)~\c-0 + d-l c-l + d-o) -C 3 by typing $$\align \left(\array\c\quad\c\\a__b\\c

45 A t CAUTION. Notice that the inner \arrays in the above example were put in braces. If the braces were omitted, TeX would become confused, because it would think that the first Xarray goes with the first Xendarray, rather than the last one. (Typing

■CXleft (Xarray . . . \endarray\right)} would work also.) In practice, of course, you'll probably type something like

$$\define\l<\ left (\array\c\quad__\c\\ l_-o\\o..l\endarray\right) } \define\2< . . . } \define\3< . . . } \define\4< . . . } Xarray\c\qquad__\c\\ ■C\i}_-<\2}\\ <\3}&<\4}\endarrayss

Notice that we still put \1 in braces (otherwise T^C would get confused as soon as it substituted \left (Xarray . . . \endarray\right) for \l). SIDETRIP. In the above example we could have defined

\def ine\l<<\lef t(\array . . . \endarray}} with an extra pair ofbraces, and then we wouldn't need braces around \1 (compare page ??). 6. When you're typing a matrix, you have to concentrate so hard on the \array part that it's easy to forget the \left( and \right). So there's the handy control sequence \matrix . . . \endmatrix, which is just like \array, ex- cept that the parentheses get put in automatically. There's also \bmatrix if you want a matrix surrounded by brackets °* , and \vmatrix if you want it surrounded by vertical lines r' . 7. You might very well get tired of typing the specifications for arrays over and over again. If you make definitions like

\def ine\twof ormat-(\c\quad_k\c\\} \def ine\threeformat{\c\quad__\c\quad__\c\\}

46 »» < ... * you'll be able to type

$$\array\threeformat o 6 a__b__c\\ c d&e&f\endarray def

(Notice that the \\ was put into the definitions of \twoformat and \threef ormatso that it didn't have to be -3'pcd in the \array.) You can even C make definitions like \def ine\twoarrayC\array\c\quad_.\c\\} Xdef ine\threearrawy-C\array\c\quad

C $$\twoarray a&b\\ a b c&d\endarrayss c d

Notice th.at you still type \endarray, not \endtwoarrayI 8. The "generic" matrix (an 012 021 022

\O-mi O-rn.2 really involves an array with four rows and columns, in which some of the entries are \ldots (. . .) and some are \vdots (:) and one entry is empty. Such a matrix looks better when the space between columns is less than a quad. You might use \U, or better yet, the "thick space" \; that we mentioned on page ?? $$\matrix\c\\;&\c\;__\c\;_fe\c\\ aX's instead of o's, etc. What will \generic<(a+b)} give? How about \generic-(a+b}? c

47

X

c