|
|
1.1 ! root 1: .\" @(#)e4 6.1 (Berkeley) 5/22/86 ! 2: .\" ! 3: .NH ! 4: The Language ! 5: .PP ! 6: We will not try to describe the language precisely here; ! 7: interested readers may refer to the appendix for more details. ! 8: Throughout this section, we will write expressions ! 9: exactly ! 10: as they are handed to the typesetting program (hereinafter called ! 11: .UC ``EQN'' ), ! 12: except that we won't show the delimiters ! 13: that the user types to mark the beginning and end of the expression. ! 14: The interface between ! 15: .UC EQN ! 16: and ! 17: .UC TROFF ! 18: is described at the end of this section. ! 19: .PP ! 20: As we said, typing x=y+z+1 should produce $x=y+z+1$, ! 21: and indeed it does. ! 22: Variables are made italic, operators and digits become roman, ! 23: and normal spacings between letters and operators are altered slightly ! 24: to give a more pleasing appearance. ! 25: .PP ! 26: Input is free-form. ! 27: Spaces and new lines in the input are used by ! 28: .UC EQN ! 29: to separate pieces of the input; ! 30: they are not used to create space in the output. ! 31: Thus ! 32: .P1 ! 33: x = y ! 34: + z + 1 ! 35: .P2 ! 36: also gives $x=y+z+1$. ! 37: Free-form input is easier to type initially; ! 38: subsequent editing is also easier, ! 39: for an expression may be typed as many short lines. ! 40: .PP ! 41: Extra white space can be forced into the output by several ! 42: characters of various sizes. ! 43: A tilde ``\|~\|'' gives a space equal ! 44: to the normal word spacing in text; ! 45: a circumflex gives half this much, ! 46: and a tab charcter spaces to the next tab stop. ! 47: .PP ! 48: Spaces (or tildes, etc.) ! 49: also serve to delimit pieces of the input. ! 50: For example, to get ! 51: .EQ ! 52: f(t) = 2 pi int sin ( omega t )dt ! 53: .EN ! 54: we write ! 55: .P1 ! 56: f(t) = 2 pi int sin ( omega t )dt ! 57: .P2 ! 58: Here spaces are ! 59: .ul ! 60: necessary ! 61: in the input ! 62: to indicate that ! 63: .ul ! 64: sin, pi, int, ! 65: and ! 66: .ul ! 67: omega ! 68: are special, and potentially worth special treatment. ! 69: .UC EQN ! 70: looks up each such string of characters ! 71: in a table, and if appropriate gives it a translation. ! 72: In this case, ! 73: .ul ! 74: pi ! 75: and ! 76: .ul ! 77: omega ! 78: become their greek equivalents, ! 79: .ul ! 80: int ! 81: becomes the integral sign ! 82: (which must be moved down and enlarged so it looks ``right''), ! 83: and ! 84: .ul ! 85: sin ! 86: is made roman, following conventional mathematical practice. ! 87: Parentheses, digits and operators are automatically made roman ! 88: wherever found. ! 89: .PP ! 90: Fractions are specified with the keyword ! 91: .ul ! 92: over: ! 93: .P1 ! 94: a+b over c+d+e = 1 ! 95: .P2 ! 96: produces ! 97: .EQ ! 98: a+b over c+d+e = 1 ! 99: .EN ! 100: .PP ! 101: Similarly, subscripts and superscripts are introduced by the keywords ! 102: .ul ! 103: sub ! 104: and ! 105: .ul ! 106: sup: ! 107: .EQ ! 108: x sup 2 + y sup 2 = z sup 2 ! 109: .EN ! 110: is produced by ! 111: .P1 ! 112: x sup 2 + y sup 2 = z sup 2 ! 113: .P2 ! 114: The spaces after the 2's are necessary to mark the end of ! 115: the superscripts; ! 116: similarly the keyword ! 117: .ul ! 118: sup ! 119: has to be marked off by spaces or ! 120: some equivalent delimiter. ! 121: The return to the proper baseline is automatic. ! 122: Multiple levels of subscripts or superscripts ! 123: are of course allowed: ! 124: ``x\|\|sup\|\|y\|\|sup\|\|z'' is ! 125: $x sup y sup z$. ! 126: The construct ! 127: ``something ! 128: .ul ! 129: sub ! 130: something ! 131: .ul ! 132: sup ! 133: something'' ! 134: is recognized as a special case, ! 135: so ! 136: ``x sub i sup 2'' ! 137: is ! 138: $x sub i sup 2$ instead of ${x sub i} sup 2$. ! 139: .PP ! 140: More complicated expressions can now be formed with these ! 141: primitives: ! 142: .EQ ! 143: {partial sup 2 f} over {partial x sup 2} = ! 144: x sup 2 over a sup 2 + y sup 2 over b sup 2 ! 145: .EN ! 146: is produced by ! 147: .P1 ! 148: .ce 0 ! 149: {partial sup 2 f} over {partial x sup 2} = ! 150: x sup 2 over a sup 2 + y sup 2 over b sup 2 ! 151: .P2 ! 152: Braces {} are used to group objects together; ! 153: in this case they indicate unambiguously what goes over what ! 154: on the left-hand side of the expression. ! 155: The language defines the precedence of ! 156: .ul ! 157: sup ! 158: to be higher than that of ! 159: .ul ! 160: over, ! 161: so ! 162: no braces are needed to get the correct association on the right side. ! 163: Braces can always be used when in doubt ! 164: about precedence. ! 165: .PP ! 166: The braces convention is an example of the power ! 167: of using a recursive grammar ! 168: to define the language. ! 169: It is part of the language that if a construct can appear ! 170: in some context, ! 171: then ! 172: .ul ! 173: any expression ! 174: in braces ! 175: can also occur in that context. ! 176: .PP ! 177: There is a ! 178: .ul ! 179: sqrt ! 180: operator for making square roots of the appropriate size: ! 181: ``sqrt a+b'' produces $sqrt a+b$, ! 182: and ! 183: .P1 ! 184: x = {-b +- sqrt{b sup 2 -4ac}} over 2a ! 185: .P2 ! 186: is ! 187: .EQ ! 188: x={-b +- sqrt{b sup 2 -4ac}} over 2a ! 189: .EN ! 190: Since large radicals look poor on our typesetter, ! 191: .ul ! 192: sqrt ! 193: is not useful for tall expressions. ! 194: .PP ! 195: Limits on summations, integrals and similar ! 196: constructions are specified with ! 197: the keywords ! 198: .ul ! 199: from ! 200: and ! 201: .ul ! 202: to. ! 203: To get ! 204: .EQ ! 205: sum from i=0 to inf x sub i -> 0 ! 206: .EN ! 207: we need only type ! 208: .P1 ! 209: sum from i=0 to inf x sub i -> 0 ! 210: .P2 ! 211: Centering and making the $SIGMA$ big enough and the limits smaller ! 212: are all automatic. ! 213: The ! 214: .ul ! 215: from ! 216: and ! 217: .ul ! 218: to ! 219: parts are both optional, ! 220: and the central part (e.g., the $SIGMA$) ! 221: can in fact be anything: ! 222: .P1 ! 223: lim from {x -> pi /2} ( tan~x) = inf ! 224: .P2 ! 225: is ! 226: .EQ ! 227: lim from {x -> pi /2} ( tan~x) = inf ! 228: .EN ! 229: Again, ! 230: the braces indicate just what goes into the ! 231: .ul ! 232: from ! 233: part. ! 234: .PP ! 235: There is a facility for making braces, brackets, parentheses, and vertical bars ! 236: of the right height, using the keywords ! 237: .ul ! 238: left ! 239: and ! 240: .ul ! 241: right: ! 242: .P1 ! 243: left [ x+y over 2a right ]~=~1 ! 244: .P2 ! 245: makes ! 246: .EQ ! 247: left [ x+y over 2a right ]~=~1 ! 248: .EN ! 249: A ! 250: .ul ! 251: left ! 252: need not have a corresponding ! 253: .ul ! 254: right, ! 255: as we shall see in the next example. ! 256: Any characters may follow ! 257: .ul ! 258: left ! 259: and ! 260: .ul ! 261: right, ! 262: but generally only various parentheses and bars are meaningful. ! 263: .PP ! 264: Big brackets, etc., ! 265: are often used with another facility, ! 266: called ! 267: .ul ! 268: piles, ! 269: which make vertical piles of objects. ! 270: For example, ! 271: to get ! 272: .EQ ! 273: sign (x) ~==~ left { ! 274: rpile {1 above 0 above -1} ! 275: ~~lpile {if above if above if} ! 276: ~~lpile {x>0 above x=0 above x<0} ! 277: .EN ! 278: we can type ! 279: .P1 ! 280: sign (x) ~==~ left { ! 281: rpile {1 above 0 above -1} ! 282: ~~lpile {if above if above if} ! 283: ~~lpile {x>0 above x=0 above x<0} ! 284: .P2 ! 285: The construction ``left {'' ! 286: makes a left brace big enough ! 287: to enclose the ! 288: ``rpile {...}'', ! 289: which is a right-justified pile of ! 290: ``above ... above ...''. ! 291: ``lpile'' makes a left-justified pile. ! 292: There are also centered piles. ! 293: Because of the recursive language definition, ! 294: a ! 295: pile ! 296: can contain any number of elements; ! 297: any element of a pile can of course ! 298: contain piles. ! 299: .PP ! 300: Although ! 301: .UC EQN ! 302: makes a valiant attempt ! 303: to use the right sizes and fonts, ! 304: there are times when the default assumptions ! 305: are simply not what is wanted. ! 306: For instance the italic ! 307: .ul ! 308: sign ! 309: in the previous example would conventionally ! 310: be in roman. ! 311: Slides and transparencies often require larger characters than normal text. ! 312: Thus we also provide size and font ! 313: changing commands: ! 314: ``size 12 bold {A~x~=~y}'' ! 315: will produce ! 316: $size 12 bold{ A~x~=~y}$. ! 317: .ul ! 318: Size ! 319: is followed by a number representing a character size in points. ! 320: (One point is 1/72 inch; ! 321: this paper is set in 9 point type.) ! 322: .PP ! 323: If necessary, an input string can be quoted in "...", ! 324: which turns off grammatical significance, and any font or spacing changes that might otherwise be done on it. ! 325: Thus we can say ! 326: .P1 ! 327: lim~ roman "sup" ~x sub n = 0 ! 328: .P2 ! 329: to ensure that the supremum doesn't become a superscript: ! 330: .EQ ! 331: lim~ roman "sup" ~x sub n = 0 ! 332: .EN ! 333: .PP ! 334: Diacritical marks, long a problem in traditional typesetting, ! 335: are straightforward: ! 336: .EQ ! 337: x dot under + x hat + y tilde + X hat + Y dotdot = z+Z bar ! 338: .EN ! 339: is made by typing ! 340: .P1 ! 341: x dot under + x hat + y tilde ! 342: + X hat + Y dotdot = z+Z bar ! 343: .P2 ! 344: .PP ! 345: There are also facilities for globally changing default ! 346: sizes and fonts, for example for making viewgraphs ! 347: or for setting chemical equations. ! 348: The language allows for matrices, and for lining up equations ! 349: at the same horizontal position. ! 350: .PP ! 351: Finally, there is a definition facility, ! 352: so a user can say ! 353: .P1 ! 354: define name "..." ! 355: .P2 ! 356: at any time in the document; ! 357: henceforth, any occurrence of the token ``name'' ! 358: in an expression ! 359: will be expanded into whatever was inside ! 360: the double quotes in its definition. ! 361: This lets users tailor ! 362: the language to their own specifications, ! 363: for it is quite possible to redefine ! 364: keywords ! 365: like ! 366: .ul ! 367: sup ! 368: or ! 369: .ul ! 370: over. ! 371: Section 6 shows an example of definitions. ! 372: .PP ! 373: The ! 374: .UC EQN ! 375: preprocessor reads intermixed text and equations, ! 376: and passes its output to ! 377: .UC TROFF. ! 378: Since ! 379: .UC TROFF ! 380: uses lines beginning with a period as control words ! 381: (e.g., ``.ce'' means ``center the next output line''), ! 382: .UC EQN ! 383: uses the sequence ``.EQ'' to mark the beginning of an equation and ! 384: ``.EN'' to mark the end. ! 385: The ``.EQ'' and ``.EN'' are passed through to ! 386: .UC TROFF ! 387: untouched, ! 388: so they can also be used by a knowledgeable user to ! 389: center equations, number them automatically, etc. ! 390: By default, however, ! 391: ``.EQ'' and ``.EN'' are simply ignored by ! 392: .UC TROFF , ! 393: so by default equations are printed in-line. ! 394: .PP ! 395: ``.EQ'' and ``.EN'' can be supplemented by ! 396: .UC TROFF ! 397: commands as desired; ! 398: for example, a centered display equation ! 399: can be produced with the input: ! 400: .P1 ! 401: .ce 0 ! 402: .in 5 ! 403: .ce ! 404: .EQ ! 405: x sub i = y sub i ... ! 406: .EN ! 407: .in 0 ! 408: .P2 ! 409: .PP ! 410: Since it is tedious to type ! 411: ``.EQ'' and ``.EN'' around very short expressions ! 412: (single letters, for instance), ! 413: the user can also define two characters to serve ! 414: as the left and right delimiters of expressions. ! 415: These characters are recognized anywhere in subsequent text. ! 416: For example if the left and right delimiters have both been set to ``#'', ! 417: the input: ! 418: .P1 ! 419: Let #x sub i#, #y# and #alpha# be positive ! 420: .P2 ! 421: produces: ! 422: .P1 ! 423: Let $x sub i$, $y$ and $alpha$ be positive ! 424: .P2 ! 425: .PP ! 426: Running a preprocessor is strikingly easy on ! 427: .UC UNIX. ! 428: To typeset ! 429: text stored in file ! 430: ``f\|'', ! 431: one issues the command: ! 432: .P1 ! 433: eqn f | troff ! 434: .P2 ! 435: The vertical bar connects the output ! 436: of one process ! 437: .UC (EQN) ! 438: to the input of another ! 439: .UC (TROFF) .
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.