TUGboat, Volume 10 (1989), No. 1 3 1

Typesetting Concrete testfont routine [5, Appendix HI; these tests put Donald E. Knuth the characters through their basic paces by type- Stanford University setting formulas such as /A+ ,B1+ + ... + Z1, a2tb2+c2t..+z2, az+br+c2+...+p,and

During 1987 and 1988 I prepared a textbook entitled 3 + 5 + + + . . + 2. I noticed among other things [I],written with co-authors that the Fraktur characters had all been placed too Ron Graham and Oren Patashnik. I tried my best high above the baseline, and that more blank to make the book mathematically interesting, but was needed at the left and right of the characters in I also knew that it would be typographically in- subscript/superscript sizes. After fixing such prob- teresting-because it would be the first major use lems I also needed to set the italic corrections so of a new by , commissioned that subscripts and superscripts would have proper by the American Mathematical Society. This type- offsets; and I needed to define suitable kerns with face, called AMS Euler, had been carefully digitized a \skewchar so that accents would appear visually and put into form by Stanford's digital centered. AMS Euler contains more than 400 char- students [a]; but it had not yet been acters, and Hermann had made them beautiful; my "tuned up" for real applications. My new book job was to find the right adjustments to the spacing served as an ideal test case, because (1) it involved so that they would fit properly into mathematics. a great variety of mathematical formulas; (2) I was The next step was to design a set of l)$ highly motivated to make the book readable and macros so that AMS Euler could be used con- attractive; (3) my experiences with tuning up Com- veniently in math mode. This meant adding new puter Modern gave me insights into how to set the "families" to the conventions I had defined in pre- mysterious parameters used by TEX in math vious formats. Plain 'I?@typesets mathematics mode; and (4) the book was in fact being dedicated with four basic font families (namely, \f am0 for to Leonhard Euler, the great mathematician after text, \fml for math italic, \fm2 for symbols, whom the typeface was named. and \fm3 for large delimiters), plus a few oth- The underlying philosophy of Zapf's Euler de- ers that are used less frequently (\fam4 for text sign was to capture the flavor of mathematics as italic, \f an5 for slanted text, \fam6 for boldface it might be written by a mathematician with ex- roman, and \fam7 for typewriter style). I added cellent handwriting. For example, one of the ear- \fm8 for AMS Euler Script and \fa9 for AMS marks of AMS Euler is its zero, 'O', which is Euler Fraktur; the AMS Euler Greek and Roman slightly pointed at the top because a handwrit- went into the old position of math italic, \fami. ten zero rarely closes together smoothly when the Hermann had designed new parentheses and brack- curve returns to its starting . A handwrit- ets, which were bundled together with the Fraktur ten rather than mechanical style is appropriate for ; therefore my file changed plain W's mathematics because people generally create math conventions by defining, e.g., \mathcode' (="4928 with pen, pencil, or chalk. The Euler letters are and \delcodec (="928300. Similarly, Euler has upright, not italic, so that there is a general con- the symbol '6' as an alternative to 'I1,packaged sistency with mathematical symbols like plus signs with the Script alphabet; to make TEX recognize and parentheses, and so that built-up formulas fit this substitution I said \mathchardef \leq="3814 together comfortably. AMS Euler includes seven al- \let\le=\leq. phabets: Uppercase Roman (ABC through XYZ), With such additions to the plain TEX macros I lowercase Roman (abc through xyz), uppercase could type formulas like $\tan(x+y)$ as usual and Greek (ABr through WO),lowercase Greek (aby get not 'tanjzfy)' but 'tan(x+y)'. There was, how- through x+w), uppercase kaktur (UBC through ever, one significant difference between typing the X!J3), lowercase Fraktur (abc through ~q),and up- manuscripts for Concrete Mathematics and for The percase Script (ABCthrough X2Z). It also includes Art of Computer Programming, caused by the fact two sets of digits (0123456789 and 0123456789)~as that the Euler numerals 0123456789 are distinctly well as special characters like p, H,and some punc- different from the numerals 0123456789 in ordinary tuation marks. Details about its design are dis- text. In previous work, I used to "optimize" my cussed in another article [7]. typing by saying, e.g., To refine the digitized characters for mathemat- ical use, I began by correcting the way they ap- $x$ is either 1 or $-I$, peared in their "boxes," from W'Sviewpoint. For this purpose I used the \math tests of the standard TUGboat, Volume 10 (1989), No. 1 thereby omitting $'s around a mathematical con- the respective letter pairs Aa, Bb, Cc, Dd, and Ee stant unless I needed them to get a minus sign in- from the style of standard Ro- stead of a . After all, I reasoned, those extra man to an Egyptian style. I had made these cover $IS just make TEX work harder and the result looks designs just for fun, at the suggestion of Marshall the same; so why should I be logical? But in Con- Hendricks, but I had never had time to experiment crete Mathematics I needed to type with a complete text face in that style. Now I had a good reason to indulge that whim, and after a $x$ is either $I$ or $-I$, pleasant afternoon of experiments I found a combi- nation of parameters that looked reasonably attrac- to keep x from being 'either 1 or -1'. The early tive, at least when I examined samples produced by drafts of my manuscript had been prepared in the our laser printer. (I magnified the fonts and viewed old way; therefore I needed to spend several hours them from a distance, to overcome the effects of laboriously hunting down and correcting all in- 300dpi resolution.) Then I made more elaborate stances where the new convention was necessary. samples of text and printed them on Stanford's APS This experience proved to be worthwhile, because phototypesetter, to see if the new fonts would really it taught me that there is a useful and meaningful pass muster. Some characters needed to be adjusted distinction between text numerals and mathemati- (e.g., the 'w' was too dark), but I was happy with cal numerals. Text numerals are used in contexts the result and so was Roy. like '1776' and 'Chapter 5' and '41 ways', where I decided to call the resulting font Concrete the numbers are essentially part of the English Roman, because of its general solid appearance and language; mathematical numerals, by contrast, are because it was first used in the book Concrete Math- used in contexts like 'the of ematics. (In case you haven't guessed, the text 12 and 18 is 6', where the numbers are part of the you are now reading is set in .) mathematics. (Authors of technical texts in lan- There also zs Concrete Italzc, a companzon face guages like Japanese, where Arabic numerals are that zs used for emphaszs zn the book. EVEN used in formulas but not in ordinary text, have al- STRONGER EMPHASIS IS OCCASIONALLY ACHIEVED ways been well aware of this distinction; now I had BY USING A CONCRETEROMAN CAPS AND SMALL a chance to learn it too.) CAPS FONT. Anybody who has the METAFONT As I was tooling up to begin using AMS Eu- sources for Computer Modern can make the Con- ler, my publishers were simultaneously showing the crete fonts rather easily by preparing parameter files preliminary manuscript of Concrete Mathematics to such as ccrl0 .mf,analogous to cmrl0 .mf; you just a book designer, Roy Howard Brown. I had sent need to change certain parameter values as shown Roy a copy of the first Euler report [8] so that he in the accompanying table. could see examples of the typeface we planned to Here are samples of Concrete Roman in the 9 pt, use for mathematics. Our original intention, based 8pt, 7pt, 6pt, and spt sizes: on Zapf's original plans when he began the design in 1980, was to use Computer Modern Roman for Mathematics books and journals do not look as the text and AMS Euler for the mathematics. But beautiful as they used to. It is not that their math- Roy noticed that AMS Euler was somewhat darker ematical content is unsatisfactory, rather that the old and well-developed traditions of in color than a traditional mathematical italic, so have become too expensive. Fortunately, it now ap- he decided that the text face should be correspond- pears that mathematics itself can be used to solve ingly heavier. He sent me several samples of type- this problem. faces with more suitable weights, so that I could A first step in the solution is to devise a method for prepare a special font compatible with AMS Euler. unambiguously specifying mathematical manuscripts in (One of my basic premises when I had developed the such a way that they can easily be manipulated by ma- Computer Modern meta-font was that it should be chines. Such languages, when properly designed, can readily adaptable to new situations like this.) When be learned quickly by authors and their typists, yet manuscripts in this form will lead directly to high qual- I saw Roy's samples, I decided to pursue something ity plates for the printer with little or no human inter- that I'd wanted an excuse to do for several years, vention. namely to find settings for the parameters of Com- A second step in the solution makes use of classical puter Modern that would produce an "Egyptian" mathematics to design the shapes of the letters and sym- bols themselves. It is possible to give a rigorous definition (square-) style. of the exact shape of the letter "a", for example, in such a The cover designs for Computers & Typeset- way that infinitely many styles (bold, extended, sans-serif, italic, etc.) are obtained from a single definit~onby chang- ting, Volumes A-El show a gradual transition of ing only a few parameters. When the same is done for the TUGboat, Volume 10 (1989), No. 1 33

other letters and symbols, we obtain a mathematical def- brary, so these new may help solve some of inition of type fonts, a definition that can be used on all the legibility problems we all know too well. But a machines both now and in the future. The main signifi- cance of this approach is that new symbols can readily be typeface that is too bold can also make a book tire- added in such a way that they are automatically consistent some to read. To avoid this problem, Roy decided with the old ones. to use a \baselineskip of 13 pt with lOpt type. Of course ~t is necessary that the mathematically-defined let- ters be beautiful according to traditional notions of =sthetics This gives an additional advantage for mathematical Given a sequence of points in the plane, what is the most pleas- ing curve that connects them? This question leads to interesting work, because it prevents formulas like a;' mathematics, and one solution based on a novel family of spline in the body of the text from interfering with each curves has produced excellent [SIC] fonts of type in the author's preliminary experiments other; the normal 12 pt baselineskip used in most We may conclude that a mathematical approach to the design of alphabets does not elmunate the artists who have been domg the mathematics books can get uncomfortably tight. Of job for so many years, on the contrary ~t gives them an exc~ting course, the increased space between lines also in- new medium to work with [2] creases the number of pages by about 8%; this seems Heavier weight makes the type more resilient a reasonable price to pay for increased readability. to xeroxing and easier to read in a poorly lighted li-

Table of parameter values for Concrete fonts, using the conventions found on pages 12-31 of [6]: name cmr10 ccr10 ccr9 ccr5 ccslc9 cctilO ccmilO cccsclO lower font- ident CMR CCR CCR CCR CCR CCR CCR CCSLC CCTI CCMI CCCSC serif-fit 0 1 1 1 1 1 1 0 1 1 1 cap-serif-fit 5 3 2.8 2.6 2.4 2.2 2 2 3 3 3 x-height 155 165 148.5 132 115.5 99 82.5 155 165 165 155 bar-height 87 92 78.3 69.6 60.9 52.2 43.5 85 92 92 87 tiny 8 11 10 9 8 7 6 9 11 11 11 fine 7 6 6 6 6 6 5 6 6 6 6 thin-join 7 17 17 15 13 12 11 13 17 17 17 hair 9 21 20 19 17 15 14 16 21 21 21 stem 25 25 24 22 20 18 16 22 24 25 25 curve 30 27 26 24 21.5 19 17 23 26 27 27 ess 27 25 24 22 20 17 12 25 24 25 25 flare 33 29 26 24 23 20 18 28 28 29 29 cap-hair 11 21 20 19 17 15 14 16 21 21 21 cap-stem 32 27 26 24 21.5 19 17 23 26 27 27 cap-curve 37 28 27 25 22.5 20 18 24 27 28 28 cap-ess 35 27 24 22 21.5 19 14 23 26 27 27 20 5 5 4 4 3 3 5 5 5 5 jut 28 30 27 24 21 19 17 15 30 30 30 cap-jut 37 32 29 26 23 20 18 16 32 32 32 vazr 8 21 20 19 17 15 14 15 21 21 21 notch-cut 10 516 314 213 7/12 112 5/12 314 516 516 516 bar, etc.* 11 21 20 19 17 15 14 15 21 21 21 cap-notch- cut 10 1 .9 .8 .7 .6 .5 .9 1 1 1 serif-drop 4 5 3.6 3.2 2.8 2.4 2 3.6 5 5 5 0 8 4 4 3 3 3 3 4 4 4 4 upex- o 8 3 3 3 3 3 2 3 3 3 3 other values from cm10 cmr9 cmr8 cmr7 cmr 6 cmr5 *The measurements for bar apply also to slab, cap-bar, and cap-band. All of the Concrete fonts have dish = 0,fudge = .95,superness = 8/11, superpull = 1/15, and beak-darkness = 11/30. Parameters not mentioned here are inherited from the corresponding cm fonts, except that cccsclO has lower.fudge = .93; cctilO has the u value 20 not 18.4,and the crisp value 11 not 8;ccmilO has the crisp value 0 not 8. 34 TUGboat, Volume 10 (1989), No. 1

Is the extra weight of Concrete Roman really and JpM' cos x2 dx. The new integral signs went into necessary for compatibility with AMS Euler? Here a new font called euexl0, which became \f am10 in is a small sample that uses ordinary cmrlO as the math mode; I told T'to get integral signs from text font, so that readers can judge this question for the new font by simply saying themselves: The set S is, by definition, all points that can be written as tkalak(i- 1lk, for an infinite sequence a1 , az, a3, . . . of zeros arid ones. Fig- in my macro file. Later I noticed that the infinity ure 1 shows that S can be decomposed into 256 sign 'm' of Computer Modern was too light to be a pieces congruent to AS: notice that if the dia- good match for the Euler alphabets, so I created a gram is rotated ~ount~erclockwiseby 135". we darker version 'co' and put it into euexlO with the obtain two adjacent sets congruent to (114)s. new integral signs. since (i-l)S=SU(S+l). [3] Hermann Zapf was helping to advise me during all this time. For example, he approved a draft of And now let's replay the same text again, using Chapter 1 that had been phototypeset in Concrete Concrete Roman and \baselineskip=l3pt: Roman and AMS Euler, while I was tuning things The set S is, by definition, all points that can up. Later, when he received a copy of the first print- be written as tkblak(i- 1 )k, for an infinite ing of the actual book, he saw Chapter 2 and the sequence al, az, a3, . . . of zeros and ones. Fig- other chapters for the first time; and this led him ure 1 shows that S can be decomposed into 256 to suggest several improvements that he could not pieces congruent to AS; notice that if the dia- have anticipated from Chapter 1. Chapter 2 is about , and I had used gram is rotated counterclockwise by 135", we the sign 1from Computer Modern's cmexlo font, obtain two adjacent sets congruent to (l/\/Z)S, together with its displaystyle counterpart since (i- 1)s=SU (S+ 1). [3] Equation numbers presented us with one of the most perplexing design questions. Should those numbers be typeset in Euler or cast in Concrete? After several experiments we hit on a solution that to typeset hundreds of formulas that involve sum- must be right, because it seems so obvious in retro- mation. Hermann pointed out that the capital spect: We decided to set equation numbers in an \ of Euler looks quite different-it is 'L', "oldstyle" variant of Concrete Roman, using the without beaks -so he suggested changing my sum- digits '0123456789'. The result - e.g., '(3.14)'- mation signs to look more like the L of Euler. I did was surprisingly effective. this in the second priating of the book, using in After I had been using AMS Euler for sev- text formulas and eral months and was totally conditioned to "upright mathematics:' I began to work on a chapter of the book where integral signs appear frequently. It sud- denly struck me that the traditional integral sign is visually incompatible with AMS Euler, because it in displays. Hermann also asked me to make the slopes like an italic letter. Such a slope was now product symbols less narrow, more like Euler's 'n'; quite out of character with the rest of the formulas. so I changed them So I designed a new, upright integral sign to match the spirit of the new fonts. Then I could typeset from n and n to n and Moreover, he wanted the arrows to have longer and darker arrowheads: ' +', not 'i'. And he wanted curly braces to be lighter, so that and f Tm cos x2 dxI instead of TUGboat, Volume 10 (1989), No. 1 35

All of these new characters were easy to design, us- There's also a ref file, which contains the sym- ing the conventions of Computer Modern [6], so I bolic names of equations, tables, and exercises that added them to euexlO and used them in the second may be needed for cross references. (A ref file is printing. analogous to an aux file in Bw.)

Readers of Concrete Mathematics will imme- 0 Finally, a bnx file records the page numbers of diately notice one novel feature: There are "graf- each bibliographic reference, so that I can include fiti" printed in the margins. My co-authors and I such information as a sort of index to the bibliogra- asked students who were testing the preliminary phy. That index was done automatically. book drafts to write informal comments that might be printed with the text, thereby giving the book I wouldn't want to deal with so many auxiliary files a friendly-contemporary-lifelike flavor. We weren't if I were producing a simpler book or a system for sure how such "remarks from the peanut gallery" more general consumption. But for the one-shot should be typeset, but we knew that we did want purposes of Concrete Mathematics, this multiple- to include them; in fact, we collected almost 500 file approach was most convenient. marginal notes. Roy hit on the idea of putting them We decided to use a nonstandard numbering in the znner (gutter) margin, where they would not system for tables, based on the way superhighway have too much prominence. He also sent a sample of exits are numbered in some states: Table 244, for a suitably informal typeface, on example, refers to the table on page 244. (The idea This 9pt typeface wasn't original with us, but I don't remember who which I modeled "Concrete Ro- proved to work very man Slanted Condensed" type. nicely for marginal suggested it.) Macros to accommodate this conven- To typeset such graffiti, I graffiti, where-it tion, and to update the cross-references when the \n is typeset ragged page numbers change, were not difficult to devise. introduced a %2macro into mv m format file, so that it was 'picas All of the macros I wrote for Concrete Mathe- with lOpt between matics appear in an 814-line file called gkpmac. , possible to type simply '\g Text baselines, of a graffito. \g' on whatever which (I'm sorry to admit) includes very little - line of text I wanted the marginal comment to be- umentation because it was intended only to do a gin. I did a bit of positioning by hand to ensure single job. Macro writers may like to look at this that no two comments would overlap; but my \g file as a source of ideas, so I've made it publicly macro did most of the work. For example, it au- accessible; for example, it is gkpmac . t ex tomatically decided whether to put graffiti into the at score. stanford. edu on the Arpanet. But peo- left margin or the right margin, based on an auxil- ple who attempt to use these macros should be iary 'grf' file that recorded the choice that would aware that I have not pretended to make them com- have been appropriate on the previous TEX run. plete or extremely general. For example, I imple- My macros for Concrete Mathematics cause mented a subset of B?]Ex's picture environment, Tj$ to produce not only the usual dvi file and log and used it to prepare all but one of the illustra- file corresponding to the input, but also the grf file tions in the book; but I didn't include everything just mentioned and four other auxiliary files: that LAW makes available. Moreover, I didn't need The ans file contains the text of any answers to boldface type in the mathematical formulas of Con- exercises that appeared in the material just typeset; crete Mathematics (except for the Q on page 143 such answers will be \input at an appropriate later of the second printing); so I didn't include macros time. (Page 422 of The wbook discusses a similar for accessing any of the bold fonts of AMS Euler idea. The only difference between Concrete Mathe- in math mode. In this respect, the book was not a matics and The wbook in this regard was that I perfect test, because almost half of the Euler charac- used one file per chapter in Concrete Mathematics, ters are boldface and therefore still untried. Macros while The wbook was typeset from one long file.) for bold mathematics would be easy to add, follow- ing the pattern already established in gkpmac; but The inx file contains raw material for prepar- I must leave such tasks to others, as I return to my ing the index. After everything but the index was long-delayed project of writing the remaining vol- ready, I put all the inx files together, sorted them, umes of The Art of Computer Programming. and edited the results by hand. (See pages 423- 425 of The wbook, where I describe similar index macros and explain why I don't believe in fully au- tomatic index preparation.) 36 TUGboat, Volume 10 (1989), No. 1

References to ship the character off to the Generic Format file (GF file). So, the endchar definition seemed like [I] Ronald L. Graham, Donald E. Knuth, and Oren Patashnik, Concrete Mathematics. Addison- a good spot to tell METAFONT to take whatever Wesley, 1989. character image had been created and convert it to an outline, since it is called once per character, [2] Donald E. Knuth, "Mathematical typography," right before it's shipped out, Bulletin of the American Mathematical Society Here is the macro definition I used to create (new series) 1 (1979), 337-372. outline fonts with: [3] Donald E. Knuth, Seminumerical , second edition. Addison-Wesley, 1981. me~sage~~loadingthe font outline macros."; boolean outlining; [4] Donald E. Knuth, The wbook, Volume A of Computers & Typesetting. Addison-Wesley, 1984 % only outline when told to and 1986. outlining:=false;

[5] Donald E. Knuth, The METRFONT~OO~,Vol- def outline = ume C of Computers & Typesetting. Addison- if outlining: Wesley, 1986. cull currentpicture keeping (1,infinity); [6] Donald E. Knuth, Computer Modern Type- picture v; v:=currentpicture; faces, Volume E of Computers & Typesetting. cull currentpicture keeping (1,l) Addison-Wesley, 1986. withweight 3; [7] Donald E. Knuth and Hermann Zapf, "AMS addto currentpicture also v - v Euler - A new typeface for mathematics," Schol- shifted right -V shifted left - v arly Publishing, to appear. shifted up - v shifted down; [8] David R Siegel, The Euler Project at Stan- cull currentpicture keeping (1,4); ford. Department, Stanford Uni- if (pixels-per-inch >= 600) : versity, 1985. addto currentpicture also currentpicture shifted left; addto currentpicture also currentpicture shifted up; f i showit; fi Outline fonts with METAFONT enddef ;

Doug Henderson extra-endchar:=extra-endchar & "outline"; Lately I've been feeling like no one else out there The first statement declares a boolean vari- is having any fun with METAFONT. I sure am. able named outlining. The next line initializes Recently, I came across a small gem in the rough outlining to be false, so we don't create outline in the METAFONTbook and decided to polish it up fonts by default. The definition of outline includes some. In chapter thirteen there is an interesting the line if outlining: which tests to see whether exercise (13.23, page 121) which calls for the user to the outlining feature is desired. If so, the macro replace a character by its "outline". Since it was an proceeds to punch out the pixels on the inside idea that appealed to me (double dangerous bend of our character (leaving more than one pixel for kind of fun) I set about applying the solution in the outline if using a high resolution printer or various places in the METAFONT to see phototypesetter) and show the results, and, if not, the affects. What I finally settled on was hooking it ends the if statement with the fistatement. The in as a definition extension of the endchar macro. I last statement is interesting since it shows a nifty reasoned that for each Computer Modern character way to tack on new features when creating your METAFONT produces in a font, there exists both a characters. Instead of redefining the definition of beginchar statement, with which you relate things the endchar macro with your special effects (in this like the height, width and depth, and an endchar case a character outline), just add to the defini- statement, which tells the program, among other tion of endchar with the extra-endchar statement. things, to create a grid box for proof characters and Some similar "hooks" exist for the beginchar and