|
|
1.1 ! root 1: %% TeX macros to handle texinfo files ! 2: ! 3: % Copyright (C) 1985, 86, 88, 90, 91, 92, 1993 Free Software Foundation, Inc. ! 4: ! 5: %This texinfo.tex file is free software; you can redistribute it and/or ! 6: %modify it under the terms of the GNU General Public License as ! 7: %published by the Free Software Foundation; either version 2, or (at ! 8: %your option) any later version. ! 9: ! 10: %This texinfo.tex file is distributed in the hope that it will be ! 11: %useful, but WITHOUT ANY WARRANTY; without even the implied warranty ! 12: %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! 13: %General Public License for more details. ! 14: ! 15: %You should have received a copy of the GNU General Public License ! 16: %along with this texinfo.tex file; see the file COPYING. If not, write ! 17: %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, ! 18: %USA. ! 19: ! 20: ! 21: %In other words, you are welcome to use, share and improve this program. ! 22: %You are forbidden to forbid anyone else to use, share and improve ! 23: %what you give them. Help stamp out software-hoarding! ! 24: ! 25: \def\texinfoversion{2.112} ! 26: \message{Loading texinfo package [Version \texinfoversion]:} ! 27: ! 28: % Print the version number if in a .fmt file. ! 29: \everyjob{\message{[Texinfo version \texinfoversion]}\message{}} ! 30: ! 31: % Save some parts of plain tex whose names we will redefine. ! 32: ! 33: \let\ptexlbrace=\{ ! 34: \let\ptexrbrace=\} ! 35: \let\ptexdots=\dots ! 36: \let\ptexdot=\. ! 37: \let\ptexstar=\* ! 38: \let\ptexend=\end ! 39: \let\ptexbullet=\bullet ! 40: \let\ptexb=\b ! 41: \let\ptexc=\c ! 42: \let\ptexi=\i ! 43: \let\ptext=\t ! 44: \let\ptexl=\l ! 45: \let\ptexL=\L ! 46: ! 47: \def\tie{\penalty 10000\ } % Save plain tex definition of ~. ! 48: ! 49: \message{Basics,} ! 50: \chardef\other=12 ! 51: ! 52: % If this character appears in an error message or help string, it ! 53: % starts a new line in the output. ! 54: \newlinechar = `^^J ! 55: ! 56: % Ignore a token. ! 57: % ! 58: \def\gobble#1{} ! 59: ! 60: \hyphenation{ap-pen-dix} ! 61: \hyphenation{mini-buf-fer mini-buf-fers} ! 62: \hyphenation{eshell} ! 63: ! 64: % Margin to add to right of even pages, to left of odd pages. ! 65: \newdimen \bindingoffset \bindingoffset=0pt ! 66: \newdimen \normaloffset \normaloffset=\hoffset ! 67: \newdimen\pagewidth \newdimen\pageheight ! 68: \pagewidth=\hsize \pageheight=\vsize ! 69: ! 70: % Sometimes it is convenient to have everything in the transcript file ! 71: % and nothing on the terminal. We don't just call \tracingall here, ! 72: % since that produces some useless output on the terminal. ! 73: % ! 74: \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% ! 75: \def\loggingall{\tracingcommands2 \tracingstats2 ! 76: \tracingpages1 \tracingoutput1 \tracinglostchars1 ! 77: \tracingmacros2 \tracingparagraphs1 \tracingrestores1 ! 78: \showboxbreadth\maxdimen\showboxdepth\maxdimen ! 79: }% ! 80: ! 81: %---------------------Begin change----------------------- ! 82: % ! 83: %%%% For @cropmarks command. ! 84: % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986 ! 85: % ! 86: \newdimen\cornerlong \newdimen\cornerthick ! 87: \newdimen \topandbottommargin ! 88: \newdimen \outerhsize \newdimen \outervsize ! 89: \cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks ! 90: \outerhsize=7in ! 91: %\outervsize=9.5in ! 92: % Alternative @smallbook page size is 9.25in ! 93: \outervsize=9.25in ! 94: \topandbottommargin=.75in ! 95: % ! 96: %---------------------End change----------------------- ! 97: ! 98: % \onepageout takes a vbox as an argument. Note that \pagecontents ! 99: % does insertions itself, but you have to call it yourself. ! 100: \chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} ! 101: \def\onepageout#1{\hoffset=\normaloffset ! 102: \ifodd\pageno \advance\hoffset by \bindingoffset ! 103: \else \advance\hoffset by -\bindingoffset\fi ! 104: {\escapechar=`\\\relax % makes sure backslash is used in output files. ! 105: \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% ! 106: {\let\hsize=\pagewidth \makefootline}}}% ! 107: \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} ! 108: ! 109: %%%% For @cropmarks command %%%% ! 110: ! 111: % Here is a modification of the main output routine for Near East Publications ! 112: % This provides right-angle cropmarks at all four corners. ! 113: % The contents of the page are centerlined into the cropmarks, ! 114: % and any desired binding offset is added as an \hskip on either ! 115: % site of the centerlined box. (P. A. MacKay, 12 November, 1986) ! 116: % ! 117: \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up ! 118: {\escapechar=`\\\relax % makes sure backslash is used in output files. ! 119: \shipout ! 120: \vbox to \outervsize{\hsize=\outerhsize ! 121: \vbox{\line{\ewtop\hfill\ewtop}} ! 122: \nointerlineskip ! 123: \line{\vbox{\moveleft\cornerthick\nstop} ! 124: \hfill ! 125: \vbox{\moveright\cornerthick\nstop}} ! 126: \vskip \topandbottommargin ! 127: \centerline{\ifodd\pageno\hskip\bindingoffset\fi ! 128: \vbox{ ! 129: {\let\hsize=\pagewidth \makeheadline} ! 130: \pagebody{#1} ! 131: {\let\hsize=\pagewidth \makefootline}} ! 132: \ifodd\pageno\else\hskip\bindingoffset\fi} ! 133: \vskip \topandbottommargin plus1fill minus1fill ! 134: \boxmaxdepth\cornerthick ! 135: \line{\vbox{\moveleft\cornerthick\nsbot} ! 136: \hfill ! 137: \vbox{\moveright\cornerthick\nsbot}} ! 138: \nointerlineskip ! 139: \vbox{\line{\ewbot\hfill\ewbot}} ! 140: }} ! 141: \advancepageno ! 142: \ifnum\outputpenalty>-20000 \else\dosupereject\fi} ! 143: % ! 144: % Do @cropmarks to get crop marks ! 145: \def\cropmarks{\let\onepageout=\croppageout } ! 146: ! 147: \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} ! 148: {\catcode`\@ =11 ! 149: \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi ! 150: \dimen@=\dp#1 \unvbox#1 ! 151: \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi ! 152: \ifr@ggedbottom \kern-\dimen@ \vfil \fi} ! 153: } ! 154: ! 155: % ! 156: % Here are the rules for the cropmarks. Note that they are ! 157: % offset so that the space between them is truly \outerhsize or \outervsize ! 158: % (P. A. MacKay, 12 November, 1986) ! 159: % ! 160: \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} ! 161: \def\nstop{\vbox ! 162: {\hrule height\cornerthick depth\cornerlong width\cornerthick}} ! 163: \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} ! 164: \def\nsbot{\vbox ! 165: {\hrule height\cornerlong depth\cornerthick width\cornerthick}} ! 166: ! 167: % Parse an argument, then pass it to #1. The argument is the rest of ! 168: % the input line (except we remove a trailing comment). #1 should be a ! 169: % macro which expects an ordinary undelimited TeX argument. ! 170: % ! 171: \def\parsearg#1{% ! 172: \let\next = #1% ! 173: \begingroup ! 174: \obeylines ! 175: \futurelet\temp\parseargx ! 176: } ! 177: ! 178: % If the next token is an obeyed space (from an @example environment or ! 179: % the like), remove it and recurse. Otherwise, we're done. ! 180: \def\parseargx{% ! 181: % \obeyedspace is defined far below, after the definition of \sepspaces. ! 182: \ifx\obeyedspace\temp ! 183: \expandafter\parseargdiscardspace ! 184: \else ! 185: \expandafter\parseargline ! 186: \fi ! 187: } ! 188: ! 189: % Remove a single space (as the delimiter token to the macro call). ! 190: {\obeyspaces % ! 191: \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} ! 192: ! 193: {\obeylines % ! 194: \gdef\parseargline#1^^M{% ! 195: \endgroup % End of the group started in \parsearg. ! 196: % ! 197: % First remove any @c comment, then any @comment. ! 198: % Result of each macro is put in \toks0. ! 199: \argremovec #1\c\relax % ! 200: \expandafter\argremovecomment \the\toks0 \comment\relax % ! 201: % ! 202: % Call the caller's macro, saved as \next in \parsearg. ! 203: \expandafter\next\expandafter{\the\toks0}% ! 204: }% ! 205: } ! 206: ! 207: % Since all \c{,omment} does is throw away the argument, we can let TeX ! 208: % do that for us. The \relax here is matched by the \relax in the call ! 209: % in \parseargline; it could be more or less anything, its purpose is ! 210: % just to delimit the argument to the \c. ! 211: \def\argremovec#1\c#2\relax{\toks0 = {#1}} ! 212: \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} ! 213: ! 214: % \argremovec{,omment} might leave us with trailing spaces, though; e.g., ! 215: % @end itemize @c foo ! 216: % will have two active spaces as part of the argument with the ! 217: % `itemize'. Here we remove all active spaces from #1, and assign the ! 218: % result to \toks0. ! 219: % ! 220: % This loses if there are any *other* active characters besides spaces ! 221: % in the argument -- _ ^ +, for example -- since they get expanded. ! 222: % Fortunately, Texinfo does not define any such commands. (If it ever ! 223: % does, the catcode of the characters in questionwill have to be changed ! 224: % here.) But this means we cannot call \removeactivespaces as part of ! 225: % \argremovec{,omment}, since @c uses \parsearg, and thus the argument ! 226: % that \parsearg gets might well have any character at all in it. ! 227: % ! 228: \def\removeactivespaces#1{% ! 229: \begingroup ! 230: \ignoreactivespaces ! 231: \edef\temp{#1}% ! 232: \global\toks0 = \expandafter{\temp}% ! 233: \endgroup ! 234: } ! 235: ! 236: % Change the active space to expand to nothing. ! 237: % ! 238: \begingroup ! 239: \obeyspaces ! 240: \gdef\ignoreactivespaces{\obeyspaces\let =\empty} ! 241: \endgroup ! 242: ! 243: ! 244: \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} ! 245: ! 246: %% These are used to keep @begin/@end levels from running away ! 247: %% Call \inENV within environments (after a \begingroup) ! 248: \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} ! 249: \def\ENVcheck{% ! 250: \ifENV\errmessage{Still within an environment. Type Return to continue.} ! 251: \endgroup\fi} % This is not perfect, but it should reduce lossage ! 252: ! 253: % @begin foo is the same as @foo, for now. ! 254: \newhelp\EMsimple{Type <Return> to continue.} ! 255: ! 256: \outer\def\begin{\parsearg\beginxxx} ! 257: ! 258: \def\beginxxx #1{% ! 259: \expandafter\ifx\csname #1\endcsname\relax ! 260: {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else ! 261: \csname #1\endcsname\fi} ! 262: ! 263: % @end foo executes the definition of \Efoo. ! 264: % ! 265: \def\end{\parsearg\endxxx} ! 266: \def\endxxx #1{% ! 267: \removeactivespaces{#1}% ! 268: \edef\endthing{\the\toks0}% ! 269: % ! 270: \expandafter\ifx\csname E\endthing\endcsname\relax ! 271: \expandafter\ifx\csname \endthing\endcsname\relax ! 272: % There's no \foo, i.e., no ``environment'' foo. ! 273: \errhelp = \EMsimple ! 274: \errmessage{Undefined command `@end \endthing'}% ! 275: \else ! 276: \unmatchedenderror\endthing ! 277: \fi ! 278: \else ! 279: % Everything's ok; the right environment has been started. ! 280: \csname E\endthing\endcsname ! 281: \fi ! 282: } ! 283: ! 284: % There is an environment #1, but it hasn't been started. Give an error. ! 285: % ! 286: \def\unmatchedenderror#1{% ! 287: \errhelp = \EMsimple ! 288: \errmessage{This `@end #1' doesn't have a matching `@#1'}% ! 289: } ! 290: ! 291: % Define the control sequence \E#1 to give an unmatched @end error. ! 292: % ! 293: \def\defineunmatchedend#1{% ! 294: \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% ! 295: } ! 296: ! 297: ! 298: % Single-spacing is done by various environments (specifically, in ! 299: % \nonfillstart and \quotations). ! 300: \newskip\singlespaceskip \singlespaceskip = \baselineskip ! 301: \def\singlespace{% ! 302: % Why was this kern here? It messes up equalizing space above and below ! 303: % environments. --karl, 6may93 ! 304: %{\advance \baselineskip by -\singlespaceskip ! 305: %\kern \baselineskip}% ! 306: \baselineskip=\singlespaceskip ! 307: } ! 308: ! 309: %% Simple single-character @ commands ! 310: ! 311: % @@ prints an @ ! 312: % Kludge this until the fonts are right (grr). ! 313: \def\@{{\tt \char '100}} ! 314: ! 315: % This is turned off because it was never documented ! 316: % and you can use @w{...} around a quote to suppress ligatures. ! 317: %% Define @` and @' to be the same as ` and ' ! 318: %% but suppressing ligatures. ! 319: %\def\`{{`}} ! 320: %\def\'{{'}} ! 321: ! 322: % Used to generate quoted braces. ! 323: ! 324: \def\mylbrace {{\tt \char '173}} ! 325: \def\myrbrace {{\tt \char '175}} ! 326: \let\{=\mylbrace ! 327: \let\}=\myrbrace ! 328: ! 329: % @: forces normal size whitespace following. ! 330: \def\:{\spacefactor=1000 } ! 331: ! 332: % @* forces a line break. ! 333: \def\*{\hfil\break\hbox{}\ignorespaces} ! 334: ! 335: % @. is an end-of-sentence period. ! 336: \def\.{.\spacefactor=3000 } ! 337: ! 338: % @w prevents a word break. Without the \leavevmode, @w at the ! 339: % beginning of a paragraph, when TeX is still in vertical mode, would ! 340: % produce a whole line of output instead of starting the paragraph. ! 341: \def\w#1{\leavevmode\hbox{#1}} ! 342: ! 343: % @group ... @end group forces ... to be all on one page, by enclosing ! 344: % it in a TeX vbox. We use \vtop instead of \vbox to construct the box ! 345: % to keep its height that of a normal line. According to the rules for ! 346: % \topskip (p.114 of the TeXbook), the glue inserted is ! 347: % max (\topskip - \ht (first item), 0). If that height is large, ! 348: % therefore, no glue is inserted, and the space between the headline and ! 349: % the text is small, which looks bad. ! 350: % ! 351: \def\group{\begingroup ! 352: \ifnum\catcode13=\active \else ! 353: \errhelp = \groupinvalidhelp ! 354: \errmessage{@group invalid in context where filling is enabled}% ! 355: \fi ! 356: % ! 357: % The \vtop we start below produces a box with normal height and large ! 358: % depth; thus, TeX puts \baselineskip glue before it, and (when the ! 359: % next line of text is done) \lineskip glue after it. (See p.82 of ! 360: % the TeXbook.) Thus, space below is not quite equal to space ! 361: % above. But it's pretty close. ! 362: \def\Egroup{% ! 363: \egroup % End the \vtop. ! 364: \endgroup % End the \group. ! 365: }% ! 366: % ! 367: \vtop\bgroup ! 368: % We have to put a strut on the last line in case the @group is in ! 369: % the midst of an example, rather than completely enclosing it. ! 370: % Otherwise, the interline space between the last line of the group ! 371: % and the first line afterwards is too small. But we can't put the ! 372: % strut in \Egroup, since there it would be on a line by itself. ! 373: % Hence this just inserts a strut at the beginning of each line. ! 374: \everypar = {\strut}% ! 375: % ! 376: % Since we have a strut on every line, we don't need any of TeX's ! 377: % normal interline spacing. ! 378: \offinterlineskip ! 379: % ! 380: % OK, but now we have to do something about blank ! 381: % lines in the input in @example-like environments, which normally ! 382: % just turn into \lisppar, which will insert no space now that we've ! 383: % turned off the interline space. Simplest is to make them be an ! 384: % empty paragraph. ! 385: \ifx\par\lisppar ! 386: \edef\par{\leavevmode \par}% ! 387: % ! 388: % Reset ^^M's definition to new definition of \par. ! 389: \obeylines ! 390: \fi ! 391: % ! 392: % We do @comment here in case we are called inside an environment, ! 393: % such as @example, where each end-of-line in the input causes an ! 394: % end-of-line in the output. We don't want the end-of-line after ! 395: % the `@group' to put extra space in the output. Since @group ! 396: % should appear on a line by itself (according to the Texinfo ! 397: % manual), we don't worry about eating any user text. ! 398: \comment ! 399: } ! 400: % ! 401: % TeX puts in an \escapechar (i.e., `@') at the beginning of the help ! 402: % message, so this ends up printing `@group can only ...'. ! 403: % ! 404: \newhelp\groupinvalidhelp{% ! 405: group can only be used in environments such as @example,^^J% ! 406: where each line of input produces a line of output.} ! 407: ! 408: % @need space-in-mils ! 409: % forces a page break if there is not space-in-mils remaining. ! 410: ! 411: \newdimen\mil \mil=0.001in ! 412: ! 413: \def\need{\parsearg\needx} ! 414: ! 415: % Old definition--didn't work. ! 416: %\def\needx #1{\par % ! 417: %% This method tries to make TeX break the page naturally ! 418: %% if the depth of the box does not fit. ! 419: %{\baselineskip=0pt% ! 420: %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000 ! 421: %\prevdepth=-1000pt ! 422: %}} ! 423: ! 424: \def\needx#1{% ! 425: % Go into vertical mode, so we don't make a big box in the middle of a ! 426: % paragraph. ! 427: \par ! 428: % ! 429: % Don't add any leading before our big empty box, but allow a page ! 430: % break, since the best break might be right here. ! 431: \allowbreak ! 432: \nointerlineskip ! 433: \vtop to #1\mil{\vfil}% ! 434: % ! 435: % TeX does not even consider page breaks if a penalty added to the ! 436: % main vertical list is 10000 or more. But in order to see if the ! 437: % empty box we just added fits on the page, we must make it consider ! 438: % page breaks. On the other hand, we don't want to actually break the ! 439: % page after the empty box. So we use a penalty of 9999. ! 440: % ! 441: % There is an extremely small chance that TeX will actually break the ! 442: % page at this \penalty, if there are no other feasible breakpoints in ! 443: % sight. (If the user is using lots of big @group commands, which ! 444: % almost-but-not-quite fill up a page, TeX will have a hard time doing ! 445: % good page breaking, for example.) However, I could not construct an ! 446: % example where a page broke at this \penalty; if it happens in a real ! 447: % document, then we can reconsider our strategy. ! 448: \penalty9999 ! 449: % ! 450: % Back up by the size of the box, whether we did a page break or not. ! 451: \kern -#1\mil ! 452: % ! 453: % Do not allow a page break right after this kern. ! 454: \nobreak ! 455: } ! 456: ! 457: % @br forces paragraph break ! 458: ! 459: \let\br = \par ! 460: ! 461: % @dots{} output some dots ! 462: ! 463: \def\dots{$\ldots$} ! 464: ! 465: % @page forces the start of a new page ! 466: ! 467: \def\page{\par\vfill\supereject} ! 468: ! 469: % @exdent text.... ! 470: % outputs text on separate line in roman font, starting at standard page margin ! 471: ! 472: % This records the amount of indent in the innermost environment. ! 473: % That's how much \exdent should take out. ! 474: \newskip\exdentamount ! 475: ! 476: % This defn is used inside fill environments such as @defun. ! 477: \def\exdent{\parsearg\exdentyyy} ! 478: \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} ! 479: ! 480: % This defn is used inside nofill environments such as @example. ! 481: \def\nofillexdent{\parsearg\nofillexdentyyy} ! 482: \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount ! 483: \leftline{\hskip\leftskip{\rm#1}}}} ! 484: ! 485: %\hbox{{\rm#1}}\hfil\break}} ! 486: ! 487: % @include file insert text of that file as input. ! 488: ! 489: \def\include{\parsearg\includezzz} ! 490: %Use \input\thisfile to avoid blank after \input, which may be an active ! 491: %char (in which case the blank would become the \input argument). ! 492: %The grouping keeps the value of \thisfile correct even when @include ! 493: %is nested. ! 494: \def\includezzz #1{\begingroup ! 495: \def\thisfile{#1}\input\thisfile ! 496: \endgroup} ! 497: ! 498: \def\thisfile{} ! 499: ! 500: % @center line outputs that line, centered ! 501: ! 502: \def\center{\parsearg\centerzzz} ! 503: \def\centerzzz #1{{\advance\hsize by -\leftskip ! 504: \advance\hsize by -\rightskip ! 505: \centerline{#1}}} ! 506: ! 507: % @sp n outputs n lines of vertical space ! 508: ! 509: \def\sp{\parsearg\spxxx} ! 510: \def\spxxx #1{\par \vskip #1\baselineskip} ! 511: ! 512: % @comment ...line which is ignored... ! 513: % @c is the same as @comment ! 514: % @ignore ... @end ignore is another way to write a comment ! 515: ! 516: \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% ! 517: \parsearg \commentxxx} ! 518: ! 519: \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } ! 520: ! 521: \let\c=\comment ! 522: ! 523: % Prevent errors for section commands. ! 524: % Used in @ignore and in failing conditionals. ! 525: \def\ignoresections{% ! 526: \let\chapter=\relax ! 527: \let\unnumbered=\relax ! 528: \let\top=\relax ! 529: \let\unnumberedsec=\relax ! 530: \let\unnumberedsection=\relax ! 531: \let\unnumberedsubsec=\relax ! 532: \let\unnumberedsubsection=\relax ! 533: \let\unnumberedsubsubsec=\relax ! 534: \let\unnumberedsubsubsection=\relax ! 535: \let\section=\relax ! 536: \let\subsec=\relax ! 537: \let\subsubsec=\relax ! 538: \let\subsection=\relax ! 539: \let\subsubsection=\relax ! 540: \let\appendix=\relax ! 541: \let\appendixsec=\relax ! 542: \let\appendixsection=\relax ! 543: \let\appendixsubsec=\relax ! 544: \let\appendixsubsection=\relax ! 545: \let\appendixsubsubsec=\relax ! 546: \let\appendixsubsubsection=\relax ! 547: \let\contents=\relax ! 548: \let\smallbook=\relax ! 549: \let\titlepage=\relax ! 550: } ! 551: ! 552: % Used in nested conditionals, where we have to parse the Texinfo source ! 553: % and so want to turn off most commands, in case they are used ! 554: % incorrectly. ! 555: % ! 556: \def\ignoremorecommands{% ! 557: \let\defcv = \relax ! 558: \let\deffn = \relax ! 559: \let\deffnx = \relax ! 560: \let\defindex = \relax ! 561: \let\defivar = \relax ! 562: \let\defmac = \relax ! 563: \let\defmethod = \relax ! 564: \let\defop = \relax ! 565: \let\defopt = \relax ! 566: \let\defspec = \relax ! 567: \let\deftp = \relax ! 568: \let\deftypefn = \relax ! 569: \let\deftypefun = \relax ! 570: \let\deftypevar = \relax ! 571: \let\deftypevr = \relax ! 572: \let\defun = \relax ! 573: \let\defvar = \relax ! 574: \let\defvr = \relax ! 575: \let\ref = \relax ! 576: \let\xref = \relax ! 577: \let\printindex = \relax ! 578: \let\pxref = \relax ! 579: \let\settitle = \relax ! 580: \let\include = \relax ! 581: \let\lowersections = \relax ! 582: \let\down = \relax ! 583: \let\raisesections = \relax ! 584: \let\up = \relax ! 585: \let\set = \relax ! 586: \let\clear = \relax ! 587: } ! 588: ! 589: % Ignore @ignore ... @end ignore. ! 590: % ! 591: \def\ignore{\doignore{ignore}} ! 592: ! 593: % Also ignore @ifinfo, @menu, and @direntry text. ! 594: % ! 595: \def\ifinfo{\doignore{ifinfo}} ! 596: \def\menu{\doignore{menu}} ! 597: \def\direntry{\doignore{direntry}} ! 598: ! 599: % Ignore text until a line `@end #1'. ! 600: % ! 601: \def\doignore#1{\begingroup ! 602: % Don't complain about control sequences we have declared \outer. ! 603: \ignoresections ! 604: % ! 605: % Define a command to swallow text until we reach `@end #1'. ! 606: \long\def\doignoretext##1\end #1{\enddoignore}% ! 607: % ! 608: % Make sure that spaces turn into tokens that match what \doignoretext wants. ! 609: \catcode32 = 10 ! 610: % ! 611: % And now expand that command. ! 612: \doignoretext ! 613: } ! 614: ! 615: % What we do to finish off ignored text. ! 616: % ! 617: \def\enddoignore{\endgroup\ignorespaces}% ! 618: ! 619: \newif\ifwarnedobs\warnedobsfalse ! 620: \def\obstexwarn{% ! 621: \ifwarnedobs\relax\else ! 622: % We need to warn folks that they may have trouble with TeX 3.0. ! 623: % This uses \immediate\write16 rather than \message to get newlines. ! 624: \immediate\write16{} ! 625: \immediate\write16{***WARNING*** for users of Unix TeX 3.0!} ! 626: \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} ! 627: \immediate\write16{If you are running another version of TeX, relax.} ! 628: \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} ! 629: \immediate\write16{ Then upgrade your TeX installation if you can.} ! 630: \immediate\write16{If you are stuck with version 3.0, run the} ! 631: \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} ! 632: \immediate\write16{ to use a workaround.} ! 633: \immediate\write16{} ! 634: \warnedobstrue ! 635: \fi ! 636: } ! 637: ! 638: % **In TeX 3.0, setting text in \nullfont hangs tex. For a ! 639: % workaround (which requires the file ``dummy.tfm'' to be installed), ! 640: % uncomment the following line: ! 641: %%%%%\font\nullfont=dummy\let\obstexwarn=\relax ! 642: ! 643: % Ignore text, except that we keep track of conditional commands for ! 644: % purposes of nesting, up to an `@end #1' command. ! 645: % ! 646: \def\nestedignore#1{% ! 647: \obstexwarn ! 648: % We must actually expand the ignored text to look for the @end ! 649: % command, so that nested ignore constructs work. Thus, we put the ! 650: % text into a \vbox and then do nothing with the result. To minimize ! 651: % the change of memory overflow, we follow the approach outlined on ! 652: % page 401 of the TeXbook: make the current font be a dummy font. ! 653: % ! 654: \setbox0 = \vbox\bgroup ! 655: % Don't complain about control sequences we have declared \outer. ! 656: \ignoresections ! 657: % ! 658: % Define `@end #1' to end the box, which will in turn undefine the ! 659: % @end command again. ! 660: \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% ! 661: % ! 662: % We are going to be parsing Texinfo commands. Most cause no ! 663: % trouble when they are used incorrectly, but some commands do ! 664: % complicated argument parsing or otherwise get confused, so we ! 665: % undefine them. ! 666: % ! 667: % We can't do anything about stray @-signs, unfortunately; ! 668: % they'll produce `undefined control sequence' errors. ! 669: \ignoremorecommands ! 670: % ! 671: % Set the current font to be \nullfont, a TeX primitive, and define ! 672: % all the font commands to also use \nullfont. We don't use ! 673: % dummy.tfm, as suggested in the TeXbook, because not all sites ! 674: % might have that installed. Therefore, math mode will still ! 675: % produce output, but that should be an extremely small amount of ! 676: % stuff compared to the main input. ! 677: % ! 678: \nullfont ! 679: \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont ! 680: \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont ! 681: \let\tensf = \nullfont ! 682: % Similarly for index fonts (mostly for their use in ! 683: % smallexample) ! 684: \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont ! 685: \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont ! 686: \let\indsf = \nullfont ! 687: % ! 688: % Don't complain when characters are missing from the fonts. ! 689: \tracinglostchars = 0 ! 690: % ! 691: % Don't bother to do space factor calculations. ! 692: \frenchspacing ! 693: % ! 694: % Don't report underfull hboxes. ! 695: \hbadness = 10000 ! 696: % ! 697: % Do minimal line-breaking. ! 698: \pretolerance = 10000 ! 699: % ! 700: % Do not execute instructions in @tex ! 701: \def\tex{\doignore{tex}} ! 702: } ! 703: ! 704: % @set VAR sets the variable VAR to an empty value. ! 705: % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. ! 706: % ! 707: % Since we want to separate VAR from REST-OF-LINE (which might be ! 708: % empty), we can't just use \parsearg; we have to insert a space of our ! 709: % own to delimit the rest of the line, and then take it out again if we ! 710: % didn't need it. ! 711: % ! 712: \def\set{\parsearg\setxxx} ! 713: \def\setxxx#1{\setyyy#1 \endsetyyy} ! 714: \def\setyyy#1 #2\endsetyyy{% ! 715: \def\temp{#2}% ! 716: \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty ! 717: \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. ! 718: \fi ! 719: } ! 720: \def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}} ! 721: ! 722: % @clear VAR clears (i.e., unsets) the variable VAR. ! 723: % ! 724: \def\clear{\parsearg\clearxxx} ! 725: \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} ! 726: ! 727: % @value{foo} gets the text saved in variable foo. ! 728: % ! 729: \def\value#1{\expandafter ! 730: \ifx\csname SET#1\endcsname\relax ! 731: {\{No value for ``#1''\}} ! 732: \else \csname SET#1\endcsname \fi} ! 733: ! 734: % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined ! 735: % with @set. ! 736: % ! 737: \def\ifset{\parsearg\ifsetxxx} ! 738: \def\ifsetxxx #1{% ! 739: \expandafter\ifx\csname SET#1\endcsname\relax ! 740: \expandafter\ifsetfail ! 741: \else ! 742: \expandafter\ifsetsucceed ! 743: \fi ! 744: } ! 745: \def\ifsetsucceed{\conditionalsucceed{ifset}} ! 746: \def\ifsetfail{\nestedignore{ifset}} ! 747: \defineunmatchedend{ifset} ! 748: ! 749: % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been ! 750: % defined with @set, or has been undefined with @clear. ! 751: % ! 752: \def\ifclear{\parsearg\ifclearxxx} ! 753: \def\ifclearxxx #1{% ! 754: \expandafter\ifx\csname SET#1\endcsname\relax ! 755: \expandafter\ifclearsucceed ! 756: \else ! 757: \expandafter\ifclearfail ! 758: \fi ! 759: } ! 760: \def\ifclearsucceed{\conditionalsucceed{ifclear}} ! 761: \def\ifclearfail{\nestedignore{ifclear}} ! 762: \defineunmatchedend{ifclear} ! 763: ! 764: % @iftex always succeeds; we read the text following, through @end ! 765: % iftex). But `@end iftex' should be valid only after an @iftex. ! 766: % ! 767: \def\iftex{\conditionalsucceed{iftex}} ! 768: \defineunmatchedend{iftex} ! 769: ! 770: % We can't just want to start a group at @iftex (for example) and end it ! 771: % at @end iftex, since then @set commands inside the conditional have no ! 772: % effect (they'd get reverted at the end of the group). So we must ! 773: % define \Eiftex to redefine itself to be its previous value. (We can't ! 774: % just define it to fail again with an ``unmatched end'' error, since ! 775: % the @ifset might be nested.) ! 776: % ! 777: \def\conditionalsucceed#1{% ! 778: \edef\temp{% ! 779: % Remember the current value of \E#1. ! 780: \let\nece{prevE#1} = \nece{E#1}% ! 781: % ! 782: % At the `@end #1', redefine \E#1 to be its previous value. ! 783: \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% ! 784: }% ! 785: \temp ! 786: } ! 787: ! 788: % We need to expand lots of \csname's, but we don't want to expand the ! 789: % control sequences after we've constructed them. ! 790: % ! 791: \def\nece#1{\expandafter\noexpand\csname#1\endcsname} ! 792: ! 793: % @asis just yields its argument. Used with @table, for example. ! 794: % ! 795: \def\asis#1{#1} ! 796: ! 797: % @math means output in math mode. ! 798: % We don't use $'s directly in the definition of \math because control ! 799: % sequences like \math are expanded when the toc file is written. Then, ! 800: % we read the toc file back, the $'s will be normal characters (as they ! 801: % should be, according to the definition of Texinfo). So we must use a ! 802: % control sequence to switch into and out of math mode. ! 803: % ! 804: % This isn't quite enough for @math to work properly in indices, but it ! 805: % seems unlikely it will ever be needed there. ! 806: % ! 807: \let\implicitmath = $ ! 808: \def\math#1{\implicitmath #1\implicitmath} ! 809: ! 810: % @bullet and @minus need the same treatment as @math, just above. ! 811: \def\bullet{\implicitmath\ptexbullet\implicitmath} ! 812: \def\minus{\implicitmath-\implicitmath} ! 813: ! 814: \def\node{\ENVcheck\parsearg\nodezzz} ! 815: \def\nodezzz#1{\nodexxx [#1,]} ! 816: \def\nodexxx[#1,#2]{\gdef\lastnode{#1}} ! 817: \let\nwnode=\node ! 818: \let\lastnode=\relax ! 819: ! 820: \def\donoderef{\ifx\lastnode\relax\else ! 821: \expandafter\expandafter\expandafter\setref{\lastnode}\fi ! 822: \let\lastnode=\relax} ! 823: ! 824: \def\unnumbnoderef{\ifx\lastnode\relax\else ! 825: \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi ! 826: \let\lastnode=\relax} ! 827: ! 828: \def\appendixnoderef{\ifx\lastnode\relax\else ! 829: \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi ! 830: \let\lastnode=\relax} ! 831: ! 832: \let\refill=\relax ! 833: ! 834: % @setfilename is done at the beginning of every texinfo file. ! 835: % So open here the files we need to have open while reading the input. ! 836: % This makes it possible to make a .fmt file for texinfo. ! 837: \def\setfilename{% ! 838: \readauxfile ! 839: \opencontents ! 840: \openindices ! 841: \fixbackslash % Turn off hack to swallow `\input texinfo'. ! 842: \global\let\setfilename=\comment % Ignore extra @setfilename cmds. ! 843: \comment % Ignore the actual filename. ! 844: } ! 845: ! 846: \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} ! 847: ! 848: \def\inforef #1{\inforefzzz #1,,,,**} ! 849: \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\ignorespaces #3{}}, ! 850: node \samp{\ignorespaces#1{}}} ! 851: ! 852: \message{fonts,} ! 853: ! 854: % Font-change commands. ! 855: ! 856: % Texinfo supports the sans serif font style, which plain TeX does not. ! 857: % So we set up a \sf analogous to plain's \rm, etc. ! 858: \newfam\sffam ! 859: \def\sf{\fam=\sffam \tensf} ! 860: \let\li = \sf % Sometimes we call it \li, not \sf. ! 861: ! 862: %% Try out Computer Modern fonts at \magstephalf ! 863: \let\mainmagstep=\magstephalf ! 864: ! 865: \ifx\bigger\relax ! 866: \let\mainmagstep=\magstep1 ! 867: \font\textrm=cmr12 ! 868: \font\texttt=cmtt12 ! 869: \else ! 870: \font\textrm=cmr10 scaled \mainmagstep ! 871: \font\texttt=cmtt10 scaled \mainmagstep ! 872: \fi ! 873: % Instead of cmb10, you many want to use cmbx10. ! 874: % cmbx10 is a prettier font on its own, but cmb10 ! 875: % looks better when embedded in a line with cmr10. ! 876: \font\textbf=cmb10 scaled \mainmagstep ! 877: \font\textit=cmti10 scaled \mainmagstep ! 878: \font\textsl=cmsl10 scaled \mainmagstep ! 879: \font\textsf=cmss10 scaled \mainmagstep ! 880: \font\textsc=cmcsc10 scaled \mainmagstep ! 881: \font\texti=cmmi10 scaled \mainmagstep ! 882: \font\textsy=cmsy10 scaled \mainmagstep ! 883: ! 884: % A few fonts for @defun, etc. ! 885: \font\defbf=cmbx10 scaled \magstep1 %was 1314 ! 886: \font\deftt=cmtt10 scaled \magstep1 ! 887: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} ! 888: ! 889: % Fonts for indices and small examples. ! 890: % We actually use the slanted font rather than the italic, ! 891: % because texinfo normally uses the slanted fonts for that. ! 892: % Do not make many font distinctions in general in the index, since they ! 893: % aren't very useful. ! 894: \font\ninett=cmtt9 ! 895: \font\indrm=cmr9 ! 896: \font\indit=cmsl9 ! 897: \let\indsl=\indit ! 898: \let\indtt=\ninett ! 899: \let\indsf=\indrm ! 900: \let\indbf=\indrm ! 901: \let\indsc=\indrm ! 902: \font\indi=cmmi9 ! 903: \font\indsy=cmsy9 ! 904: ! 905: % Fonts for headings ! 906: \font\chaprm=cmbx12 scaled \magstep2 ! 907: \font\chapit=cmti12 scaled \magstep2 ! 908: \font\chapsl=cmsl12 scaled \magstep2 ! 909: \font\chaptt=cmtt12 scaled \magstep2 ! 910: \font\chapsf=cmss12 scaled \magstep2 ! 911: \let\chapbf=\chaprm ! 912: \font\chapsc=cmcsc10 scaled\magstep3 ! 913: \font\chapi=cmmi12 scaled \magstep2 ! 914: \font\chapsy=cmsy10 scaled \magstep3 ! 915: ! 916: \font\secrm=cmbx12 scaled \magstep1 ! 917: \font\secit=cmti12 scaled \magstep1 ! 918: \font\secsl=cmsl12 scaled \magstep1 ! 919: \font\sectt=cmtt12 scaled \magstep1 ! 920: \font\secsf=cmss12 scaled \magstep1 ! 921: \font\secbf=cmbx12 scaled \magstep1 ! 922: \font\secsc=cmcsc10 scaled\magstep2 ! 923: \font\seci=cmmi12 scaled \magstep1 ! 924: \font\secsy=cmsy10 scaled \magstep2 ! 925: ! 926: % \font\ssecrm=cmbx10 scaled \magstep1 % This size an font looked bad. ! 927: % \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded. ! 928: % \font\ssecsl=cmsl10 scaled \magstep1 ! 929: % \font\ssectt=cmtt10 scaled \magstep1 ! 930: % \font\ssecsf=cmss10 scaled \magstep1 ! 931: ! 932: %\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx. ! 933: %\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than ! 934: %\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1. ! 935: %\font\ssectt=cmtt10 scaled 1315 ! 936: %\font\ssecsf=cmss10 scaled 1315 ! 937: ! 938: %\let\ssecbf=\ssecrm ! 939: ! 940: \font\ssecrm=cmbx12 scaled \magstephalf ! 941: \font\ssecit=cmti12 scaled \magstephalf ! 942: \font\ssecsl=cmsl12 scaled \magstephalf ! 943: \font\ssectt=cmtt12 scaled \magstephalf ! 944: \font\ssecsf=cmss12 scaled \magstephalf ! 945: \font\ssecbf=cmbx12 scaled \magstephalf ! 946: \font\ssecsc=cmcsc10 scaled \magstep1 ! 947: \font\sseci=cmmi12 scaled \magstephalf ! 948: \font\ssecsy=cmsy10 scaled \magstep1 ! 949: % The smallcaps and symbol fonts should actually be scaled \magstep1.5, ! 950: % but that is not a standard magnification. ! 951: ! 952: % Fonts for title page: ! 953: \font\titlerm = cmbx12 scaled \magstep3 ! 954: \let\authorrm = \secrm ! 955: ! 956: % In order for the font changes to affect most math symbols and letters, ! 957: % we have to define the \textfont of the standard families. Since ! 958: % texinfo doesn't allow for producing subscripts and superscripts, we ! 959: % don't bother to reset \scriptfont and \scriptscriptfont (which would ! 960: % also require loading a lot more fonts). ! 961: % ! 962: \def\resetmathfonts{% ! 963: \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy ! 964: \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf ! 965: \textfont\ttfam = \tentt \textfont\sffam = \tensf ! 966: } ! 967: ! 968: ! 969: % The font-changing commands redefine the meanings of \tenSTYLE, instead ! 970: % of just \STYLE. We do this so that font changes will continue to work ! 971: % in math mode, where it is the current \fam that is relevant in most ! 972: % cases, not the current. Plain TeX does, for example, ! 973: % \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need ! 974: % to redefine \bf itself. ! 975: \def\textfonts{% ! 976: \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl ! 977: \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc ! 978: \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy ! 979: \resetmathfonts} ! 980: \def\chapfonts{% ! 981: \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl ! 982: \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc ! 983: \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy ! 984: \resetmathfonts} ! 985: \def\secfonts{% ! 986: \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl ! 987: \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc ! 988: \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy ! 989: \resetmathfonts} ! 990: \def\subsecfonts{% ! 991: \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl ! 992: \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc ! 993: \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy ! 994: \resetmathfonts} ! 995: \def\indexfonts{% ! 996: \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl ! 997: \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc ! 998: \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy ! 999: \resetmathfonts} ! 1000: ! 1001: % Set up the default fonts, so we can use them for creating boxes. ! 1002: % ! 1003: \textfonts ! 1004: ! 1005: % Count depth in font-changes, for error checks ! 1006: \newcount\fontdepth \fontdepth=0 ! 1007: ! 1008: % Fonts for short table of contents. ! 1009: \font\shortcontrm=cmr12 ! 1010: \font\shortcontbf=cmbx12 ! 1011: \font\shortcontsl=cmsl12 ! 1012: ! 1013: %% Add scribe-like font environments, plus @l for inline lisp (usually sans ! 1014: %% serif) and @ii for TeX italic ! 1015: ! 1016: % \smartitalic{ARG} outputs arg in italics, followed by an italic correction ! 1017: % unless the following character is such as not to need one. ! 1018: \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} ! 1019: \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} ! 1020: ! 1021: \let\i=\smartitalic ! 1022: \let\var=\smartitalic ! 1023: \let\dfn=\smartitalic ! 1024: \let\emph=\smartitalic ! 1025: \let\cite=\smartitalic ! 1026: ! 1027: \def\b#1{{\bf #1}} ! 1028: \let\strong=\b ! 1029: ! 1030: % We can't just use \exhyphenpenalty, because that only has effect at ! 1031: % the end of a paragraph. Restore normal hyphenation at the end of the ! 1032: % group within which \nohyphenation is presumably called. ! 1033: % ! 1034: \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} ! 1035: \def\restorehyphenation{\hyphenchar\font = `- } ! 1036: ! 1037: \def\t#1{% ! 1038: {\tt \nohyphenation \rawbackslash \frenchspacing #1}% ! 1039: \null ! 1040: } ! 1041: \let\ttfont = \t ! 1042: %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null} ! 1043: \def\samp #1{`\tclose{#1}'\null} ! 1044: \def\key #1{{\tt \nohyphenation \uppercase{#1}}\null} ! 1045: \def\ctrl #1{{\tt \rawbackslash \hat}#1} ! 1046: ! 1047: \let\file=\samp ! 1048: ! 1049: % @code is a modification of @t, ! 1050: % which makes spaces the same size as normal in the surrounding text. ! 1051: \def\tclose#1{% ! 1052: {% ! 1053: % Change normal interword space to be same as for the current font. ! 1054: \spaceskip = \fontdimen2\font ! 1055: % ! 1056: % Switch to typewriter. ! 1057: \tt ! 1058: % ! 1059: % But `\ ' produces the large typewriter interword space. ! 1060: \def\ {{\spaceskip = 0pt{} }}% ! 1061: % ! 1062: % Turn off hyphenation. ! 1063: \nohyphenation ! 1064: % ! 1065: \rawbackslash ! 1066: \frenchspacing ! 1067: #1% ! 1068: }% ! 1069: \null ! 1070: } ! 1071: ! 1072: % We *must* turn on hyphenation at `-' and `_' in \code. ! 1073: % Otherwise, it is too hard to avoid overful hboxes ! 1074: % in the Emacs manual, the Library manual, etc. ! 1075: ! 1076: % Unfortunately, TeX uses one parameter (\hyphenchar) to control ! 1077: % both hyphenation at - and hyphenation within words. ! 1078: % We must therefore turn them both off (\tclose does that) ! 1079: % and arrange explicitly to hyphenate an a dash. ! 1080: % -- rms. ! 1081: { ! 1082: \catcode `\-=\active ! 1083: \catcode `\_=\active ! 1084: \global\def\code{\begingroup \catcode `\-=\active \let-\codedash \let_\codeunder \codex} ! 1085: } ! 1086: \def\codedash{-\discretionary{}{}{}} ! 1087: \def\codeunder{\normalunderscore\discretionary{}{}{}} ! 1088: \def\codex #1{\tclose{#1}\endgroup} ! 1089: ! 1090: %\let\exp=\tclose %Was temporary ! 1091: ! 1092: % @kbd is like @code, except that if the argument is just one @key command, ! 1093: % then @kbd has no effect. ! 1094: ! 1095: \def\xkey{\key} ! 1096: \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% ! 1097: \ifx\one\xkey\ifx\threex\three \key{#2}% ! 1098: \else\tclose{\look}\fi ! 1099: \else\tclose{\look}\fi} ! 1100: ! 1101: % Typeset a dimension, e.g., `in' or `pt'. The only reason for the ! 1102: % argument is to make the input look right: @dmn{pt} instead of ! 1103: % @dmn{}pt. ! 1104: % ! 1105: \def\dmn#1{\thinspace #1} ! 1106: ! 1107: \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} ! 1108: ! 1109: \def\l#1{{\li #1}\null} % ! 1110: ! 1111: \def\r#1{{\rm #1}} % roman font ! 1112: % Use of \lowercase was suggested. ! 1113: \def\sc#1{{\smallcaps#1}} % smallcaps font ! 1114: \def\ii#1{{\it #1}} % italic font ! 1115: ! 1116: \message{page headings,} ! 1117: ! 1118: \newskip\titlepagetopglue \titlepagetopglue = 1.5in ! 1119: \newskip\titlepagebottomglue \titlepagebottomglue = 2pc ! 1120: ! 1121: % First the title page. Must do @settitle before @titlepage. ! 1122: \def\titlefont#1{{\titlerm #1}} ! 1123: ! 1124: \newif\ifseenauthor ! 1125: \newif\iffinishedtitlepage ! 1126: ! 1127: \def\shorttitlepage{\parsearg\shorttitlepagezzz} ! 1128: \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% ! 1129: \endgroup\page\hbox{}\page} ! 1130: ! 1131: \def\titlepage{\begingroup \parindent=0pt \textfonts ! 1132: \let\subtitlerm=\tenrm ! 1133: % I deinstalled the following change because \cmr12 is undefined. ! 1134: % This change was not in the ChangeLog anyway. --rms. ! 1135: % \let\subtitlerm=\cmr12 ! 1136: \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% ! 1137: % ! 1138: \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% ! 1139: % ! 1140: % Leave some space at the very top of the page. ! 1141: \vglue\titlepagetopglue ! 1142: % ! 1143: % Now you can print the title using @title. ! 1144: \def\title{\parsearg\titlezzz}% ! 1145: \def\titlezzz##1{\leftline{\titlefont{##1}} ! 1146: % print a rule at the page bottom also. ! 1147: \finishedtitlepagefalse ! 1148: \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% ! 1149: % No rule at page bottom unless we print one at the top with @title. ! 1150: \finishedtitlepagetrue ! 1151: % ! 1152: % Now you can put text using @subtitle. ! 1153: \def\subtitle{\parsearg\subtitlezzz}% ! 1154: \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% ! 1155: % ! 1156: % @author should come last, but may come many times. ! 1157: \def\author{\parsearg\authorzzz}% ! 1158: \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi ! 1159: {\authorfont \leftline{##1}}}% ! 1160: % ! 1161: % Most title ``pages'' are actually two pages long, with space ! 1162: % at the top of the second. We don't want the ragged left on the second. ! 1163: \let\oldpage = \page ! 1164: \def\page{% ! 1165: \iffinishedtitlepage\else ! 1166: \finishtitlepage ! 1167: \fi ! 1168: \oldpage ! 1169: \let\page = \oldpage ! 1170: \hbox{}}% ! 1171: % \def\page{\oldpage \hbox{}} ! 1172: } ! 1173: ! 1174: \def\Etitlepage{% ! 1175: \iffinishedtitlepage\else ! 1176: \finishtitlepage ! 1177: \fi ! 1178: % It is important to do the page break before ending the group, ! 1179: % because the headline and footline are only empty inside the group. ! 1180: % If we use the new definition of \page, we always get a blank page ! 1181: % after the title page, which we certainly don't want. ! 1182: \oldpage ! 1183: \endgroup ! 1184: \HEADINGSon ! 1185: } ! 1186: ! 1187: \def\finishtitlepage{% ! 1188: \vskip4pt \hrule height 2pt width \hsize ! 1189: \vskip\titlepagebottomglue ! 1190: \finishedtitlepagetrue ! 1191: } ! 1192: ! 1193: %%% Set up page headings and footings. ! 1194: ! 1195: \let\thispage=\folio ! 1196: ! 1197: \newtoks \evenheadline % Token sequence for heading line of even pages ! 1198: \newtoks \oddheadline % Token sequence for heading line of odd pages ! 1199: \newtoks \evenfootline % Token sequence for footing line of even pages ! 1200: \newtoks \oddfootline % Token sequence for footing line of odd pages ! 1201: ! 1202: % Now make Tex use those variables ! 1203: \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline ! 1204: \else \the\evenheadline \fi}} ! 1205: \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline ! 1206: \else \the\evenfootline \fi}\HEADINGShook} ! 1207: \let\HEADINGShook=\relax ! 1208: ! 1209: % Commands to set those variables. ! 1210: % For example, this is what @headings on does ! 1211: % @evenheading @thistitle|@thispage|@thischapter ! 1212: % @oddheading @thischapter|@thispage|@thistitle ! 1213: % @evenfooting @thisfile|| ! 1214: % @oddfooting ||@thisfile ! 1215: ! 1216: \def\evenheading{\parsearg\evenheadingxxx} ! 1217: \def\oddheading{\parsearg\oddheadingxxx} ! 1218: \def\everyheading{\parsearg\everyheadingxxx} ! 1219: ! 1220: \def\evenfooting{\parsearg\evenfootingxxx} ! 1221: \def\oddfooting{\parsearg\oddfootingxxx} ! 1222: \def\everyfooting{\parsearg\everyfootingxxx} ! 1223: ! 1224: {\catcode`\@=0 % ! 1225: ! 1226: \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} ! 1227: \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% ! 1228: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} ! 1229: ! 1230: \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} ! 1231: \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% ! 1232: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} ! 1233: ! 1234: \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} ! 1235: \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% ! 1236: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} ! 1237: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} ! 1238: ! 1239: \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} ! 1240: \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% ! 1241: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} ! 1242: ! 1243: \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} ! 1244: \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% ! 1245: \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} ! 1246: ! 1247: \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} ! 1248: \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% ! 1249: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} ! 1250: \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} ! 1251: % ! 1252: }% unbind the catcode of @. ! 1253: ! 1254: % @headings double turns headings on for double-sided printing. ! 1255: % @headings single turns headings on for single-sided printing. ! 1256: % @headings off turns them off. ! 1257: % @headings on same as @headings double, retained for compatibility. ! 1258: % @headings after turns on double-sided headings after this page. ! 1259: % @headings doubleafter turns on double-sided headings after this page. ! 1260: % @headings singleafter turns on single-sided headings after this page. ! 1261: % By default, they are off. ! 1262: ! 1263: \def\headings #1 {\csname HEADINGS#1\endcsname} ! 1264: ! 1265: \def\HEADINGSoff{ ! 1266: \global\evenheadline={\hfil} \global\evenfootline={\hfil} ! 1267: \global\oddheadline={\hfil} \global\oddfootline={\hfil}} ! 1268: \HEADINGSoff ! 1269: % When we turn headings on, set the page number to 1. ! 1270: % For double-sided printing, put current file name in lower left corner, ! 1271: % chapter name on inside top of right hand pages, document ! 1272: % title on inside top of left hand pages, and page numbers on outside top ! 1273: % edge of all pages. ! 1274: \def\HEADINGSdouble{ ! 1275: %\pagealignmacro ! 1276: \global\pageno=1 ! 1277: \global\evenfootline={\hfil} ! 1278: \global\oddfootline={\hfil} ! 1279: \global\evenheadline={\line{\folio\hfil\thistitle}} ! 1280: \global\oddheadline={\line{\thischapter\hfil\folio}} ! 1281: } ! 1282: % For single-sided printing, chapter title goes across top left of page, ! 1283: % page number on top right. ! 1284: \def\HEADINGSsingle{ ! 1285: %\pagealignmacro ! 1286: \global\pageno=1 ! 1287: \global\evenfootline={\hfil} ! 1288: \global\oddfootline={\hfil} ! 1289: \global\evenheadline={\line{\thischapter\hfil\folio}} ! 1290: \global\oddheadline={\line{\thischapter\hfil\folio}} ! 1291: } ! 1292: \def\HEADINGSon{\HEADINGSdouble} ! 1293: ! 1294: \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} ! 1295: \let\HEADINGSdoubleafter=\HEADINGSafter ! 1296: \def\HEADINGSdoublex{% ! 1297: \global\evenfootline={\hfil} ! 1298: \global\oddfootline={\hfil} ! 1299: \global\evenheadline={\line{\folio\hfil\thistitle}} ! 1300: \global\oddheadline={\line{\thischapter\hfil\folio}} ! 1301: } ! 1302: ! 1303: \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} ! 1304: \def\HEADINGSsinglex{% ! 1305: \global\evenfootline={\hfil} ! 1306: \global\oddfootline={\hfil} ! 1307: \global\evenheadline={\line{\thischapter\hfil\folio}} ! 1308: \global\oddheadline={\line{\thischapter\hfil\folio}} ! 1309: } ! 1310: ! 1311: % Subroutines used in generating headings ! 1312: % Produces Day Month Year style of output. ! 1313: \def\today{\number\day\space ! 1314: \ifcase\month\or ! 1315: January\or February\or March\or April\or May\or June\or ! 1316: July\or August\or September\or October\or November\or December\fi ! 1317: \space\number\year} ! 1318: ! 1319: % Use this if you want the Month Day, Year style of output. ! 1320: %\def\today{\ifcase\month\or ! 1321: %January\or February\or March\or April\or May\or June\or ! 1322: %July\or August\or September\or October\or November\or December\fi ! 1323: %\space\number\day, \number\year} ! 1324: ! 1325: % @settitle line... specifies the title of the document, for headings ! 1326: % It generates no output of its own ! 1327: ! 1328: \def\thistitle{No Title} ! 1329: \def\settitle{\parsearg\settitlezzz} ! 1330: \def\settitlezzz #1{\gdef\thistitle{#1}} ! 1331: ! 1332: \message{tables,} ! 1333: ! 1334: % @tabs -- simple alignment ! 1335: ! 1336: % These don't work. For one thing, \+ is defined as outer. ! 1337: % So these macros cannot even be defined. ! 1338: ! 1339: %\def\tabs{\parsearg\tabszzz} ! 1340: %\def\tabszzz #1{\settabs\+#1\cr} ! 1341: %\def\tabline{\parsearg\tablinezzz} ! 1342: %\def\tablinezzz #1{\+#1\cr} ! 1343: %\def\&{&} ! 1344: ! 1345: % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). ! 1346: ! 1347: % default indentation of table text ! 1348: \newdimen\tableindent \tableindent=.8in ! 1349: % default indentation of @itemize and @enumerate text ! 1350: \newdimen\itemindent \itemindent=.3in ! 1351: % margin between end of table item and start of table text. ! 1352: \newdimen\itemmargin \itemmargin=.1in ! 1353: ! 1354: % used internally for \itemindent minus \itemmargin ! 1355: \newdimen\itemmax ! 1356: ! 1357: % Note @table, @vtable, and @vtable define @item, @itemx, etc., with ! 1358: % these defs. ! 1359: % They also define \itemindex ! 1360: % to index the item name in whatever manner is desired (perhaps none). ! 1361: ! 1362: \newif\ifitemxneedsnegativevskip ! 1363: ! 1364: \def\itemxpar{\par\ifitemxneedsnegativevskip\vskip-\parskip\nobreak\fi} ! 1365: ! 1366: \def\internalBitem{\smallbreak \parsearg\itemzzz} ! 1367: \def\internalBitemx{\itemxpar \parsearg\itemzzz} ! 1368: ! 1369: \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} ! 1370: \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} ! 1371: ! 1372: \def\internalBkitem{\smallbreak \parsearg\kitemzzz} ! 1373: \def\internalBkitemx{\itemxpar \parsearg\kitemzzz} ! 1374: ! 1375: \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% ! 1376: \itemzzz {#1}} ! 1377: ! 1378: \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% ! 1379: \itemzzz {#1}} ! 1380: ! 1381: \def\itemzzz #1{\begingroup % ! 1382: \advance\hsize by -\rightskip ! 1383: \advance\hsize by -\tableindent ! 1384: \setbox0=\hbox{\itemfont{#1}}% ! 1385: \itemindex{#1}% ! 1386: \nobreak % This prevents a break before @itemx. ! 1387: % ! 1388: % Be sure we are not still in the middle of a paragraph. ! 1389: %{\parskip = 0in ! 1390: %\par ! 1391: %}% ! 1392: % ! 1393: % If the item text does not fit in the space we have, put it on a line ! 1394: % by itself, and do not allow a page break either before or after that ! 1395: % line. We do not start a paragraph here because then if the next ! 1396: % command is, e.g., @kindex, the whatsit would get put into the ! 1397: % horizontal list on a line by itself, resulting in extra blank space. ! 1398: \ifdim \wd0>\itemmax ! 1399: % ! 1400: % Make this a paragraph so we get the \parskip glue and wrapping, ! 1401: % but leave it ragged-right. ! 1402: \begingroup ! 1403: \advance\leftskip by-\tableindent ! 1404: \advance\hsize by\tableindent ! 1405: \advance\rightskip by0pt plus1fil ! 1406: \leavevmode\unhbox0\par ! 1407: \endgroup ! 1408: % ! 1409: % We're going to be starting a paragraph, but we don't want the ! 1410: % \parskip glue -- logically it's part of the @item we just started. ! 1411: \nobreak \vskip-\parskip ! 1412: % ! 1413: % Stop a page break at the \parskip glue coming up. Unfortunately ! 1414: % we can't prevent a possible page break at the following ! 1415: % \baselineskip glue. ! 1416: \nobreak ! 1417: \endgroup ! 1418: \itemxneedsnegativevskipfalse ! 1419: \else ! 1420: % The item text fits into the space. Start a paragraph, so that the ! 1421: % following text (if any) will end up on the same line. Since that ! 1422: % text will be indented by \tableindent, we make the item text be in ! 1423: % a zero-width box. ! 1424: \noindent ! 1425: \rlap{\hskip -\tableindent\box0}\ignorespaces% ! 1426: \endgroup% ! 1427: \itemxneedsnegativevskiptrue% ! 1428: \fi ! 1429: } ! 1430: ! 1431: \def\item{\errmessage{@item while not in a table}} ! 1432: \def\itemx{\errmessage{@itemx while not in a table}} ! 1433: \def\kitem{\errmessage{@kitem while not in a table}} ! 1434: \def\kitemx{\errmessage{@kitemx while not in a table}} ! 1435: \def\xitem{\errmessage{@xitem while not in a table}} ! 1436: \def\xitemx{\errmessage{@xitemx while not in a table}} ! 1437: ! 1438: %% Contains a kludge to get @end[description] to work ! 1439: \def\description{\tablez{\dontindex}{1}{}{}{}{}} ! 1440: ! 1441: \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} ! 1442: {\obeylines\obeyspaces% ! 1443: \gdef\tablex #1^^M{% ! 1444: \tabley\dontindex#1 \endtabley}} ! 1445: ! 1446: \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} ! 1447: {\obeylines\obeyspaces% ! 1448: \gdef\ftablex #1^^M{% ! 1449: \tabley\fnitemindex#1 \endtabley ! 1450: \def\Eftable{\endgraf\afterenvbreak\endgroup}% ! 1451: \let\Etable=\relax}} ! 1452: ! 1453: \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} ! 1454: {\obeylines\obeyspaces% ! 1455: \gdef\vtablex #1^^M{% ! 1456: \tabley\vritemindex#1 \endtabley ! 1457: \def\Evtable{\endgraf\afterenvbreak\endgroup}% ! 1458: \let\Etable=\relax}} ! 1459: ! 1460: \def\dontindex #1{} ! 1461: \def\fnitemindex #1{\doind {fn}{\code{#1}}}% ! 1462: \def\vritemindex #1{\doind {vr}{\code{#1}}}% ! 1463: ! 1464: {\obeyspaces % ! 1465: \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% ! 1466: \tablez{#1}{#2}{#3}{#4}{#5}{#6}}} ! 1467: ! 1468: \def\tablez #1#2#3#4#5#6{% ! 1469: \aboveenvbreak % ! 1470: \begingroup % ! 1471: \def\Edescription{\Etable}% Neccessary kludge. ! 1472: \let\itemindex=#1% ! 1473: \ifnum 0#3>0 \advance \leftskip by #3\mil \fi % ! 1474: \ifnum 0#4>0 \tableindent=#4\mil \fi % ! 1475: \ifnum 0#5>0 \advance \rightskip by #5\mil \fi % ! 1476: \def\itemfont{#2}% ! 1477: \itemmax=\tableindent % ! 1478: \advance \itemmax by -\itemmargin % ! 1479: \advance \leftskip by \tableindent % ! 1480: \exdentamount=\tableindent ! 1481: \parindent = 0pt ! 1482: \parskip = \smallskipamount ! 1483: \ifdim \parskip=0pt \parskip=2pt \fi% ! 1484: \def\Etable{\endgraf\afterenvbreak\endgroup}% ! 1485: \let\item = \internalBitem % ! 1486: \let\itemx = \internalBitemx % ! 1487: \let\kitem = \internalBkitem % ! 1488: \let\kitemx = \internalBkitemx % ! 1489: \let\xitem = \internalBxitem % ! 1490: \let\xitemx = \internalBxitemx % ! 1491: } ! 1492: ! 1493: % This is the counter used by @enumerate, which is really @itemize ! 1494: ! 1495: \newcount \itemno ! 1496: ! 1497: \def\itemize{\parsearg\itemizezzz} ! 1498: ! 1499: \def\itemizezzz #1{% ! 1500: \begingroup % ended by the @end itemsize ! 1501: \itemizey {#1}{\Eitemize} ! 1502: } ! 1503: ! 1504: \def\itemizey #1#2{% ! 1505: \aboveenvbreak % ! 1506: \itemmax=\itemindent % ! 1507: \advance \itemmax by -\itemmargin % ! 1508: \advance \leftskip by \itemindent % ! 1509: \exdentamount=\itemindent ! 1510: \parindent = 0pt % ! 1511: \parskip = \smallskipamount % ! 1512: \ifdim \parskip=0pt \parskip=2pt \fi% ! 1513: \def#2{\endgraf\afterenvbreak\endgroup}% ! 1514: \def\itemcontents{#1}% ! 1515: \let\item=\itemizeitem} ! 1516: ! 1517: % Set sfcode to normal for the chars that usually have another value. ! 1518: % These are `.?!:;,' ! 1519: \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 ! 1520: \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } ! 1521: ! 1522: % \splitoff TOKENS\endmark defines \first to be the first token in ! 1523: % TOKENS, and \rest to be the remainder. ! 1524: % ! 1525: \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% ! 1526: ! 1527: % Allow an optional argument of an uppercase letter, lowercase letter, ! 1528: % or number, to specify the first label in the enumerated list. No ! 1529: % argument is the same as `1'. ! 1530: % ! 1531: \def\enumerate{\parsearg\enumeratezzz} ! 1532: \def\enumeratezzz #1{\enumeratey #1 \endenumeratey} ! 1533: \def\enumeratey #1 #2\endenumeratey{% ! 1534: \begingroup % ended by the @end enumerate ! 1535: % ! 1536: % If we were given no argument, pretend we were given `1'. ! 1537: \def\thearg{#1}% ! 1538: \ifx\thearg\empty \def\thearg{1}\fi ! 1539: % ! 1540: % Detect if the argument is a single token. If so, it might be a ! 1541: % letter. Otherwise, the only valid thing it can be is a number. ! 1542: % (We will always have one token, because of the test we just made. ! 1543: % This is a good thing, since \splitoff doesn't work given nothing at ! 1544: % all -- the first parameter is undelimited.) ! 1545: \expandafter\splitoff\thearg\endmark ! 1546: \ifx\rest\empty ! 1547: % Only one token in the argument. It could still be anything. ! 1548: % A ``lowercase letter'' is one whose \lccode is nonzero. ! 1549: % An ``uppercase letter'' is one whose \lccode is both nonzero, and ! 1550: % not equal to itself. ! 1551: % Otherwise, we assume it's a number. ! 1552: % ! 1553: % We need the \relax at the end of the \ifnum lines to stop TeX from ! 1554: % continuing to look for a <number>. ! 1555: % ! 1556: \ifnum\lccode\expandafter`\thearg=0\relax ! 1557: \numericenumerate % a number (we hope) ! 1558: \else ! 1559: % It's a letter. ! 1560: \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax ! 1561: \lowercaseenumerate % lowercase letter ! 1562: \else ! 1563: \uppercaseenumerate % uppercase letter ! 1564: \fi ! 1565: \fi ! 1566: \else ! 1567: % Multiple tokens in the argument. We hope it's a number. ! 1568: \numericenumerate ! 1569: \fi ! 1570: } ! 1571: ! 1572: % An @enumerate whose labels are integers. The starting integer is ! 1573: % given in \thearg. ! 1574: % ! 1575: \def\numericenumerate{% ! 1576: \itemno = \thearg ! 1577: \startenumeration{\the\itemno}% ! 1578: } ! 1579: ! 1580: % The starting (lowercase) letter is in \thearg. ! 1581: \def\lowercaseenumerate{% ! 1582: \itemno = \expandafter`\thearg ! 1583: \startenumeration{% ! 1584: % Be sure we're not beyond the end of the alphabet. ! 1585: \ifnum\itemno=0 ! 1586: \errmessage{No more lowercase letters in @enumerate; get a bigger ! 1587: alphabet}% ! 1588: \fi ! 1589: \char\lccode\itemno ! 1590: }% ! 1591: } ! 1592: ! 1593: % The starting (uppercase) letter is in \thearg. ! 1594: \def\uppercaseenumerate{% ! 1595: \itemno = \expandafter`\thearg ! 1596: \startenumeration{% ! 1597: % Be sure we're not beyond the end of the alphabet. ! 1598: \ifnum\itemno=0 ! 1599: \errmessage{No more uppercase letters in @enumerate; get a bigger ! 1600: alphabet} ! 1601: \fi ! 1602: \char\uccode\itemno ! 1603: }% ! 1604: } ! 1605: ! 1606: % Call itemizey, adding a period to the first argument and supplying the ! 1607: % common last two arguments. Also subtract one from the initial value in ! 1608: % \itemno, since @item increments \itemno. ! 1609: % ! 1610: \def\startenumeration#1{% ! 1611: \advance\itemno by -1 ! 1612: \itemizey{#1.}\Eenumerate\flushcr ! 1613: } ! 1614: ! 1615: % @alphaenumerate and @capsenumerate are abbreviations for giving an arg ! 1616: % to @enumerate. ! 1617: % ! 1618: \def\alphaenumerate{\enumerate{a}} ! 1619: \def\capsenumerate{\enumerate{A}} ! 1620: \def\Ealphaenumerate{\Eenumerate} ! 1621: \def\Ecapsenumerate{\Eenumerate} ! 1622: ! 1623: % Definition of @item while inside @itemize. ! 1624: ! 1625: \def\itemizeitem{% ! 1626: \advance\itemno by 1 ! 1627: {\let\par=\endgraf \smallbreak}% ! 1628: \ifhmode \errmessage{\in hmode at itemizeitem}\fi ! 1629: {\parskip=0in \hskip 0pt ! 1630: \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% ! 1631: \vadjust{\penalty 1200}}% ! 1632: \flushcr} ! 1633: ! 1634: \message{indexing,} ! 1635: % Index generation facilities ! 1636: ! 1637: % Define \newwrite to be identical to plain tex's \newwrite ! 1638: % except not \outer, so it can be used within \newindex. ! 1639: {\catcode`\@=11 ! 1640: \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} ! 1641: ! 1642: % \newindex {foo} defines an index named foo. ! 1643: % It automatically defines \fooindex such that ! 1644: % \fooindex ...rest of line... puts an entry in the index foo. ! 1645: % It also defines \fooindfile to be the number of the output channel for ! 1646: % the file that accumulates this index. The file's extension is foo. ! 1647: % The name of an index should be no more than 2 characters long ! 1648: % for the sake of vms. ! 1649: ! 1650: \def\newindex #1{ ! 1651: \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file ! 1652: \openout \csname#1indfile\endcsname \jobname.#1 % Open the file ! 1653: \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex ! 1654: \noexpand\doindex {#1}} ! 1655: } ! 1656: ! 1657: % @defindex foo == \newindex{foo} ! 1658: ! 1659: \def\defindex{\parsearg\newindex} ! 1660: ! 1661: % Define @defcodeindex, like @defindex except put all entries in @code. ! 1662: ! 1663: \def\newcodeindex #1{ ! 1664: \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file ! 1665: \openout \csname#1indfile\endcsname \jobname.#1 % Open the file ! 1666: \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex ! 1667: \noexpand\docodeindex {#1}} ! 1668: } ! 1669: ! 1670: \def\defcodeindex{\parsearg\newcodeindex} ! 1671: ! 1672: % @synindex foo bar makes index foo feed into index bar. ! 1673: % Do this instead of @defindex foo if you don't want it as a separate index. ! 1674: \def\synindex #1 #2 {% ! 1675: \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname ! 1676: \expandafter\let\csname#1indfile\endcsname=\synindexfoo ! 1677: \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex ! 1678: \noexpand\doindex {#2}}% ! 1679: } ! 1680: ! 1681: % @syncodeindex foo bar similar, but put all entries made for index foo ! 1682: % inside @code. ! 1683: \def\syncodeindex #1 #2 {% ! 1684: \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname ! 1685: \expandafter\let\csname#1indfile\endcsname=\synindexfoo ! 1686: \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex ! 1687: \noexpand\docodeindex {#2}}% ! 1688: } ! 1689: ! 1690: % Define \doindex, the driver for all \fooindex macros. ! 1691: % Argument #1 is generated by the calling \fooindex macro, ! 1692: % and it is "foo", the name of the index. ! 1693: ! 1694: % \doindex just uses \parsearg; it calls \doind for the actual work. ! 1695: % This is because \doind is more useful to call from other macros. ! 1696: ! 1697: % There is also \dosubind {index}{topic}{subtopic} ! 1698: % which makes an entry in a two-level index such as the operation index. ! 1699: ! 1700: \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} ! 1701: \def\singleindexer #1{\doind{\indexname}{#1}} ! 1702: ! 1703: % like the previous two, but they put @code around the argument. ! 1704: \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} ! 1705: \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} ! 1706: ! 1707: \def\indexdummies{% ! 1708: \def\_{{\realbackslash _}}% ! 1709: \def\w{\realbackslash w }% ! 1710: \def\bf{\realbackslash bf }% ! 1711: \def\rm{\realbackslash rm }% ! 1712: \def\sl{\realbackslash sl }% ! 1713: \def\sf{\realbackslash sf}% ! 1714: \def\tt{\realbackslash tt}% ! 1715: \def\gtr{\realbackslash gtr}% ! 1716: \def\less{\realbackslash less}% ! 1717: \def\hat{\realbackslash hat}% ! 1718: \def\char{\realbackslash char}% ! 1719: \def\TeX{\realbackslash TeX}% ! 1720: \def\dots{\realbackslash dots }% ! 1721: \def\copyright{\realbackslash copyright }% ! 1722: \def\tclose##1{\realbackslash tclose {##1}}% ! 1723: \def\code##1{\realbackslash code {##1}}% ! 1724: \def\samp##1{\realbackslash samp {##1}}% ! 1725: \def\t##1{\realbackslash r {##1}}% ! 1726: \def\r##1{\realbackslash r {##1}}% ! 1727: \def\i##1{\realbackslash i {##1}}% ! 1728: \def\b##1{\realbackslash b {##1}}% ! 1729: \def\cite##1{\realbackslash cite {##1}}% ! 1730: \def\key##1{\realbackslash key {##1}}% ! 1731: \def\file##1{\realbackslash file {##1}}% ! 1732: \def\var##1{\realbackslash var {##1}}% ! 1733: \def\kbd##1{\realbackslash kbd {##1}}% ! 1734: \def\dfn##1{\realbackslash dfn {##1}}% ! 1735: \def\emph##1{\realbackslash emph {##1}}% ! 1736: } ! 1737: ! 1738: % \indexnofonts no-ops all font-change commands. ! 1739: % This is used when outputting the strings to sort the index by. ! 1740: \def\indexdummyfont#1{#1} ! 1741: \def\indexdummytex{TeX} ! 1742: \def\indexdummydots{...} ! 1743: ! 1744: \def\indexnofonts{% ! 1745: \let\w=\indexdummyfont ! 1746: \let\t=\indexdummyfont ! 1747: \let\r=\indexdummyfont ! 1748: \let\i=\indexdummyfont ! 1749: \let\b=\indexdummyfont ! 1750: \let\emph=\indexdummyfont ! 1751: \let\strong=\indexdummyfont ! 1752: \let\cite=\indexdummyfont ! 1753: \let\sc=\indexdummyfont ! 1754: %Don't no-op \tt, since it isn't a user-level command ! 1755: % and is used in the definitions of the active chars like <, >, |... ! 1756: %\let\tt=\indexdummyfont ! 1757: \let\tclose=\indexdummyfont ! 1758: \let\code=\indexdummyfont ! 1759: \let\file=\indexdummyfont ! 1760: \let\samp=\indexdummyfont ! 1761: \let\kbd=\indexdummyfont ! 1762: \let\key=\indexdummyfont ! 1763: \let\var=\indexdummyfont ! 1764: \let\TeX=\indexdummytex ! 1765: \let\dots=\indexdummydots ! 1766: } ! 1767: ! 1768: % To define \realbackslash, we must make \ not be an escape. ! 1769: % We must first make another character (@) an escape ! 1770: % so we do not become unable to do a definition. ! 1771: ! 1772: {\catcode`\@=0 \catcode`\\=\other ! 1773: @gdef@realbackslash{\}} ! 1774: ! 1775: \let\indexbackslash=0 %overridden during \printindex. ! 1776: ! 1777: \def\doind #1#2{% ! 1778: {\count10=\lastpenalty % ! 1779: {\indexdummies % Must do this here, since \bf, etc expand at this stage ! 1780: \escapechar=`\\% ! 1781: {\let\folio=0% Expand all macros now EXCEPT \folio ! 1782: \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now ! 1783: % so it will be output as is; and it will print as backslash in the indx. ! 1784: % ! 1785: % Now process the index-string once, with all font commands turned off, ! 1786: % to get the string to sort the index by. ! 1787: {\indexnofonts ! 1788: \xdef\temp1{#2}% ! 1789: }% ! 1790: % Now produce the complete index entry. We process the index-string again, ! 1791: % this time with font commands expanded, to get what to print in the index. ! 1792: \edef\temp{% ! 1793: \write \csname#1indfile\endcsname{% ! 1794: \realbackslash entry {\temp1}{\folio}{#2}}}% ! 1795: \temp }% ! 1796: }\penalty\count10}} ! 1797: ! 1798: \def\dosubind #1#2#3{% ! 1799: {\count10=\lastpenalty % ! 1800: {\indexdummies % Must do this here, since \bf, etc expand at this stage ! 1801: \escapechar=`\\% ! 1802: {\let\folio=0% ! 1803: \def\rawbackslashxx{\indexbackslash}% ! 1804: % ! 1805: % Now process the index-string once, with all font commands turned off, ! 1806: % to get the string to sort the index by. ! 1807: {\indexnofonts ! 1808: \xdef\temp1{#2 #3}% ! 1809: }% ! 1810: % Now produce the complete index entry. We process the index-string again, ! 1811: % this time with font commands expanded, to get what to print in the index. ! 1812: \edef\temp{% ! 1813: \write \csname#1indfile\endcsname{% ! 1814: \realbackslash entry {\temp1}{\folio}{#2}{#3}}}% ! 1815: \temp }% ! 1816: }\penalty\count10}} ! 1817: ! 1818: % The index entry written in the file actually looks like ! 1819: % \entry {sortstring}{page}{topic} ! 1820: % or ! 1821: % \entry {sortstring}{page}{topic}{subtopic} ! 1822: % The texindex program reads in these files and writes files ! 1823: % containing these kinds of lines: ! 1824: % \initial {c} ! 1825: % before the first topic whose initial is c ! 1826: % \entry {topic}{pagelist} ! 1827: % for a topic that is used without subtopics ! 1828: % \primary {topic} ! 1829: % for the beginning of a topic that is used with subtopics ! 1830: % \secondary {subtopic}{pagelist} ! 1831: % for each subtopic. ! 1832: ! 1833: % Define the user-accessible indexing commands ! 1834: % @findex, @vindex, @kindex, @cindex. ! 1835: ! 1836: \def\findex {\fnindex} ! 1837: \def\kindex {\kyindex} ! 1838: \def\cindex {\cpindex} ! 1839: \def\vindex {\vrindex} ! 1840: \def\tindex {\tpindex} ! 1841: \def\pindex {\pgindex} ! 1842: ! 1843: \def\cindexsub {\begingroup\obeylines\cindexsub} ! 1844: {\obeylines % ! 1845: \gdef\cindexsub "#1" #2^^M{\endgroup % ! 1846: \dosubind{cp}{#2}{#1}}} ! 1847: ! 1848: % Define the macros used in formatting output of the sorted index material. ! 1849: ! 1850: % This is what you call to cause a particular index to get printed. ! 1851: % Write ! 1852: % @unnumbered Function Index ! 1853: % @printindex fn ! 1854: ! 1855: \def\printindex{\parsearg\doprintindex} ! 1856: ! 1857: \def\doprintindex#1{% ! 1858: \tex ! 1859: \dobreak \chapheadingskip {10000} ! 1860: \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other ! 1861: \catcode`\$=\other\catcode`\_=\other ! 1862: \catcode`\~=\other ! 1863: % ! 1864: % The following don't help, since the chars were translated ! 1865: % when the raw index was written, and their fonts were discarded ! 1866: % due to \indexnofonts. ! 1867: %\catcode`\"=\active ! 1868: %\catcode`\^=\active ! 1869: %\catcode`\_=\active ! 1870: %\catcode`\|=\active ! 1871: %\catcode`\<=\active ! 1872: %\catcode`\>=\active ! 1873: % % ! 1874: \def\indexbackslash{\rawbackslashxx} ! 1875: \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt ! 1876: \begindoublecolumns ! 1877: % ! 1878: % See if the index file exists and is nonempty. ! 1879: \openin 1 \jobname.#1s ! 1880: \ifeof 1 ! 1881: % \enddoublecolumns gets confused if there is no text in the index, ! 1882: % and it loses the chapter title and the aux file entries for the ! 1883: % index. The easiest way to prevent this problem is to make sure ! 1884: % there is some text. ! 1885: (Index is nonexistent) ! 1886: \else ! 1887: % ! 1888: % If the index file exists but is empty, then \openin leaves \ifeof ! 1889: % false. We have to make TeX try to read something from the file, so ! 1890: % it can discover if there is anything in it. ! 1891: \read 1 to \temp ! 1892: \ifeof 1 ! 1893: (Index is empty) ! 1894: \else ! 1895: \input \jobname.#1s ! 1896: \fi ! 1897: \fi ! 1898: \closein 1 ! 1899: \enddoublecolumns ! 1900: \Etex ! 1901: } ! 1902: ! 1903: % These macros are used by the sorted index file itself. ! 1904: % Change them to control the appearance of the index. ! 1905: ! 1906: % Same as \bigskipamount except no shrink. ! 1907: % \balancecolumns gets confused if there is any shrink. ! 1908: \newskip\initialskipamount \initialskipamount 12pt plus4pt ! 1909: ! 1910: \def\initial #1{% ! 1911: {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt ! 1912: \ifdim\lastskip<\initialskipamount ! 1913: \removelastskip \penalty-200 \vskip \initialskipamount\fi ! 1914: \line{\secbf#1\hfill}\kern 2pt\penalty10000}} ! 1915: ! 1916: % This typesets a paragraph consisting of #1, dot leaders, and then #2 ! 1917: % flush to the right margin. It is used for index and table of contents ! 1918: % entries. The paragraph is indented by \leftskip. ! 1919: % ! 1920: \def\entry #1#2{\begingroup ! 1921: % ! 1922: % Start a new paragraph if necessary, so our assignments below can't ! 1923: % affect previous text. ! 1924: \par ! 1925: % ! 1926: % Do not fill out the last line with white space. ! 1927: \parfillskip = 0in ! 1928: % ! 1929: % No extra space above this paragraph. ! 1930: \parskip = 0in ! 1931: % ! 1932: % Do not prefer a separate line ending with a hyphen to fewer lines. ! 1933: \finalhyphendemerits = 0 ! 1934: % ! 1935: % \hangindent is only relevant when the entry text and page number ! 1936: % don't both fit on one line. In that case, bob suggests starting the ! 1937: % dots pretty far over on the line. Unfortunately, a large ! 1938: % indentation looks wrong when the entry text itself is broken across ! 1939: % lines. So we use a small indentation and put up with long leaders. ! 1940: % ! 1941: % \hangafter is reset to 1 (which is the value we want) at the start ! 1942: % of each paragraph, so we need not do anything with that. ! 1943: \hangindent=2em ! 1944: % ! 1945: % When the entry text needs to be broken, just fill out the first line ! 1946: % with blank space. ! 1947: \rightskip = 0pt plus1fil ! 1948: % ! 1949: % Start a ``paragraph'' for the index entry so the line breaking ! 1950: % parameters we've set above will have an effect. ! 1951: \noindent ! 1952: % ! 1953: % Insert the text of the index entry. TeX will do line-breaking on it. ! 1954: #1% ! 1955: % If there are no page numbers, don't output a line of dots. ! 1956: \def\tempa{#2} ! 1957: \def\tempb{} ! 1958: \ifx\tempa\tempb\ \else ! 1959: % ! 1960: % If we must, put the page number on a line of its own, and fill out ! 1961: % this line with blank space. (The \hfil is overwhelmed with the ! 1962: % fill leaders glue in \indexdotfill if the page number does fit.) ! 1963: \hfil\penalty50 ! 1964: \null\nobreak\indexdotfill % Have leaders before the page number. ! 1965: % ! 1966: % The `\ ' here is removed by the implicit \unskip that TeX does as ! 1967: % part of (the primitive) \par. Without it, a spurious underfull ! 1968: % \hbox ensues. ! 1969: \ #2% The page number ends the paragraph. ! 1970: \fi% ! 1971: \par ! 1972: \endgroup} ! 1973: ! 1974: % Like \dotfill except takes at least 1 em. ! 1975: \def\indexdotfill{\cleaders ! 1976: \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill} ! 1977: ! 1978: \def\primary #1{\line{#1\hfil}} ! 1979: ! 1980: \newskip\secondaryindent \secondaryindent=0.5cm ! 1981: ! 1982: \def\secondary #1#2{ ! 1983: {\parfillskip=0in \parskip=0in ! 1984: \hangindent =1in \hangafter=1 ! 1985: \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par ! 1986: }} ! 1987: ! 1988: %% Define two-column mode, which is used in indexes. ! 1989: %% Adapted from the TeXbook, page 416. ! 1990: \catcode `\@=11 ! 1991: ! 1992: \newbox\partialpage ! 1993: ! 1994: \newdimen\doublecolumnhsize ! 1995: ! 1996: \def\begindoublecolumns{\begingroup ! 1997: % Grab any single-column material above us. ! 1998: \output = {\global\setbox\partialpage ! 1999: =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}% ! 2000: \eject ! 2001: % ! 2002: % Now switch to the double-column output routine. ! 2003: \output={\doublecolumnout}% ! 2004: % ! 2005: % Change the page size parameters. We could do this once outside this ! 2006: % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 ! 2007: % format, but then we repeat the same computation. Repeating a couple ! 2008: % of assignments once per index is clearly meaningless for the ! 2009: % execution time, so we may as well do it once. ! 2010: % ! 2011: % First we halve the line length, less a little for the gutter between ! 2012: % the columns. We compute the gutter based on the line length, so it ! 2013: % changes automatically with the paper format. The magic constant ! 2014: % below is chosen so that the gutter has the same value (well, +- < ! 2015: % 1pt) as it did when we hard-coded it. ! 2016: % ! 2017: % We put the result in a separate register, \doublecolumhsize, so we ! 2018: % can restore it in \pagesofar, after \hsize itself has (potentially) ! 2019: % been clobbered. ! 2020: % ! 2021: \doublecolumnhsize = \hsize ! 2022: \advance\doublecolumnhsize by -.04154\hsize ! 2023: \divide\doublecolumnhsize by 2 ! 2024: \hsize = \doublecolumnhsize ! 2025: % ! 2026: % Double the \vsize as well. (We don't need a separate register here, ! 2027: % since nobody clobbers \vsize.) ! 2028: \vsize = 2\vsize ! 2029: \doublecolumnpagegoal ! 2030: } ! 2031: ! 2032: \def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage} ! 2033: ! 2034: \def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth ! 2035: \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage ! 2036: \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1} ! 2037: \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3} ! 2038: \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi ! 2039: \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi ! 2040: } ! 2041: \def\doublecolumnpagegoal{% ! 2042: \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@ ! 2043: } ! 2044: \def\pagesofar{\unvbox\partialpage % ! 2045: \hsize=\doublecolumnhsize % have to restore this since output routine ! 2046: \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} ! 2047: \def\doublecolumnout{% ! 2048: \setbox5=\copy255 ! 2049: {\vbadness=10000 \doublecolumnsplit} ! 2050: \ifvbox255 ! 2051: \setbox0=\vtop to\dimen@{\unvbox0} ! 2052: \setbox2=\vtop to\dimen@{\unvbox2} ! 2053: \onepageout\pagesofar \unvbox255 \penalty\outputpenalty ! 2054: \else ! 2055: \setbox0=\vbox{\unvbox5} ! 2056: \ifvbox0 ! 2057: \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip ! 2058: \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth ! 2059: {\vbadness=10000 ! 2060: \loop \global\setbox5=\copy0 ! 2061: \setbox1=\vsplit5 to\dimen@ ! 2062: \setbox3=\vsplit5 to\dimen@ ! 2063: \ifvbox5 \global\advance\dimen@ by1pt \repeat ! 2064: \setbox0=\vbox to\dimen@{\unvbox1} ! 2065: \setbox2=\vbox to\dimen@{\unvbox3} ! 2066: \global\setbox\partialpage=\vbox{\pagesofar} ! 2067: \doublecolumnpagegoal ! 2068: } ! 2069: \fi ! 2070: \fi ! 2071: } ! 2072: ! 2073: \catcode `\@=\other ! 2074: \message{sectioning,} ! 2075: % Define chapters, sections, etc. ! 2076: ! 2077: \newcount \chapno ! 2078: \newcount \secno \secno=0 ! 2079: \newcount \subsecno \subsecno=0 ! 2080: \newcount \subsubsecno \subsubsecno=0 ! 2081: ! 2082: % This counter is funny since it counts through charcodes of letters A, B, ... ! 2083: \newcount \appendixno \appendixno = `\@ ! 2084: \def\appendixletter{\char\the\appendixno} ! 2085: ! 2086: \newwrite \contentsfile ! 2087: % This is called from \setfilename. ! 2088: \def\opencontents{\openout \contentsfile = \jobname.toc} ! 2089: ! 2090: % Each @chapter defines this as the name of the chapter. ! 2091: % page headings and footings can use it. @section does likewise ! 2092: ! 2093: \def\thischapter{} \def\thissection{} ! 2094: \def\seccheck#1{\if \pageno<0 % ! 2095: \errmessage{@#1 not allowed after generating table of contents}\fi ! 2096: % ! 2097: } ! 2098: ! 2099: \def\chapternofonts{% ! 2100: \let\rawbackslash=\relax% ! 2101: \let\frenchspacing=\relax% ! 2102: \def\result{\realbackslash result} ! 2103: \def\equiv{\realbackslash equiv} ! 2104: \def\expansion{\realbackslash expansion} ! 2105: \def\print{\realbackslash print} ! 2106: \def\TeX{\realbackslash TeX} ! 2107: \def\dots{\realbackslash dots} ! 2108: \def\copyright{\realbackslash copyright} ! 2109: \def\tt{\realbackslash tt} ! 2110: \def\bf{\realbackslash bf } ! 2111: \def\w{\realbackslash w} ! 2112: \def\less{\realbackslash less} ! 2113: \def\gtr{\realbackslash gtr} ! 2114: \def\hat{\realbackslash hat} ! 2115: \def\char{\realbackslash char} ! 2116: \def\tclose##1{\realbackslash tclose {##1}} ! 2117: \def\code##1{\realbackslash code {##1}} ! 2118: \def\samp##1{\realbackslash samp {##1}} ! 2119: \def\r##1{\realbackslash r {##1}} ! 2120: \def\b##1{\realbackslash b {##1}} ! 2121: \def\key##1{\realbackslash key {##1}} ! 2122: \def\file##1{\realbackslash file {##1}} ! 2123: \def\kbd##1{\realbackslash kbd {##1}} ! 2124: % These are redefined because @smartitalic wouldn't work inside xdef. ! 2125: \def\i##1{\realbackslash i {##1}} ! 2126: \def\cite##1{\realbackslash cite {##1}} ! 2127: \def\var##1{\realbackslash var {##1}} ! 2128: \def\emph##1{\realbackslash emph {##1}} ! 2129: \def\dfn##1{\realbackslash dfn {##1}} ! 2130: } ! 2131: ! 2132: \newcount\absseclevel % used to calculate proper heading level ! 2133: \newcount\secbase\secbase=0 % @raise/lowersections modify this count ! 2134: ! 2135: % @raisesections: treat @section as chapter, @subsection as section, etc. ! 2136: \def\raisesections{\global\advance\secbase by -1} ! 2137: \let\up=\raisesections % original BFox name ! 2138: ! 2139: % @lowersections: treat @chapter as section, @section as subsection, etc. ! 2140: \def\lowersections{\global\advance\secbase by 1} ! 2141: \let\down=\lowersections % original BFox name ! 2142: ! 2143: % Choose a numbered-heading macro ! 2144: % #1 is heading level if unmodified by @raisesections or @lowersections ! 2145: % #2 is text for heading ! 2146: \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 ! 2147: \ifcase\absseclevel ! 2148: \chapterzzz{#2} ! 2149: \or ! 2150: \seczzz{#2} ! 2151: \or ! 2152: \numberedsubseczzz{#2} ! 2153: \or ! 2154: \numberedsubsubseczzz{#2} ! 2155: \else ! 2156: \ifnum \absseclevel<0 ! 2157: \chapterzzz{#2} ! 2158: \else ! 2159: \numberedsubsubseczzz{#2} ! 2160: \fi ! 2161: \fi ! 2162: } ! 2163: ! 2164: % like \numhead, but chooses appendix heading levels ! 2165: \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 ! 2166: \ifcase\absseclevel ! 2167: \appendixzzz{#2} ! 2168: \or ! 2169: \appendixsectionzzz{#2} ! 2170: \or ! 2171: \appendixsubseczzz{#2} ! 2172: \or ! 2173: \appendixsubsubseczzz{#2} ! 2174: \else ! 2175: \ifnum \absseclevel<0 ! 2176: \appendixzzz{#2} ! 2177: \else ! 2178: \appendixsubsubseczzz{#2} ! 2179: \fi ! 2180: \fi ! 2181: } ! 2182: ! 2183: % like \numhead, but chooses numberless heading levels ! 2184: \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 ! 2185: \ifcase\absseclevel ! 2186: \unnumberedzzz{#2} ! 2187: \or ! 2188: \unnumberedseczzz{#2} ! 2189: \or ! 2190: \unnumberedsubseczzz{#2} ! 2191: \or ! 2192: \unnumberedsubsubseczzz{#2} ! 2193: \else ! 2194: \ifnum \absseclevel<0 ! 2195: \unnumberedzzz{#2} ! 2196: \else ! 2197: \unnumberedsubsubseczzz{#2} ! 2198: \fi ! 2199: \fi ! 2200: } ! 2201: ! 2202: ! 2203: \def\thischaptername{No Chapter Title} ! 2204: \outer\def\chapter{\parsearg\chapteryyy} ! 2205: \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz ! 2206: \def\chapterzzz #1{\seccheck{chapter}% ! 2207: \secno=0 \subsecno=0 \subsubsecno=0 ! 2208: \global\advance \chapno by 1 \message{Chapter \the\chapno}% ! 2209: \chapmacro {#1}{\the\chapno}% ! 2210: \gdef\thissection{#1}% ! 2211: \gdef\thischaptername{#1}% ! 2212: % We don't substitute the actual chapter name into \thischapter ! 2213: % because we don't want its macros evaluated now. ! 2214: \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}% ! 2215: {\chapternofonts% ! 2216: \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% ! 2217: \escapechar=`\\% ! 2218: \write \contentsfile \temp % ! 2219: \donoderef % ! 2220: \global\let\section = \numberedsec ! 2221: \global\let\subsection = \numberedsubsec ! 2222: \global\let\subsubsection = \numberedsubsubsec ! 2223: }} ! 2224: ! 2225: \outer\def\appendix{\parsearg\appendixyyy} ! 2226: \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz ! 2227: \def\appendixzzz #1{\seccheck{appendix}% ! 2228: \secno=0 \subsecno=0 \subsubsecno=0 ! 2229: \global\advance \appendixno by 1 \message{Appendix \appendixletter}% ! 2230: \chapmacro {#1}{Appendix \appendixletter}% ! 2231: \gdef\thissection{#1}% ! 2232: \gdef\thischaptername{#1}% ! 2233: \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}% ! 2234: {\chapternofonts% ! 2235: \edef\temp{{\realbackslash chapentry ! 2236: {#1}{Appendix \appendixletter}{\noexpand\folio}}}% ! 2237: \escapechar=`\\% ! 2238: \write \contentsfile \temp % ! 2239: \appendixnoderef % ! 2240: \global\let\section = \appendixsec ! 2241: \global\let\subsection = \appendixsubsec ! 2242: \global\let\subsubsection = \appendixsubsubsec ! 2243: }} ! 2244: ! 2245: \outer\def\top{\parsearg\unnumberedyyy} ! 2246: \outer\def\unnumbered{\parsearg\unnumberedyyy} ! 2247: \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz ! 2248: \def\unnumberedzzz #1{\seccheck{unnumbered}% ! 2249: \secno=0 \subsecno=0 \subsubsecno=0 ! 2250: % ! 2251: % This used to be simply \message{#1}, but TeX fully expands the ! 2252: % argument to \message. Therefore, if #1 contained @-commands, TeX ! 2253: % expanded them. For example, in `@unnumbered The @cite{Book}', TeX ! 2254: % expanded @cite (which turns out to cause errors because \cite is meant ! 2255: % to be executed, not expanded). ! 2256: % ! 2257: % Anyway, we don't want the fully-expanded definition of @cite to appear ! 2258: % as a result of the \message, we just want `@cite' itself. We use ! 2259: % \the<toks register> to achieve this: TeX expands \the<toks> only once, ! 2260: % simply yielding the contents of the <toks register>. ! 2261: \toks0 = {#1}\message{(\the\toks0)}% ! 2262: % ! 2263: \unnumbchapmacro {#1}% ! 2264: \gdef\thischapter{#1}\gdef\thissection{#1}% ! 2265: {\chapternofonts% ! 2266: \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}% ! 2267: \escapechar=`\\% ! 2268: \write \contentsfile \temp % ! 2269: \unnumbnoderef % ! 2270: \global\let\section = \unnumberedsec ! 2271: \global\let\subsection = \unnumberedsubsec ! 2272: \global\let\subsubsection = \unnumberedsubsubsec ! 2273: }} ! 2274: ! 2275: \outer\def\numberedsec{\parsearg\secyyy} ! 2276: \def\secyyy #1{\numhead1{#1}} % normally calls seczzz ! 2277: \def\seczzz #1{\seccheck{section}% ! 2278: \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % ! 2279: \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% ! 2280: {\chapternofonts% ! 2281: \edef\temp{{\realbackslash secentry % ! 2282: {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% ! 2283: \escapechar=`\\% ! 2284: \write \contentsfile \temp % ! 2285: \donoderef % ! 2286: \penalty 10000 % ! 2287: }} ! 2288: ! 2289: \outer\def\appenixsection{\parsearg\appendixsecyyy} ! 2290: \outer\def\appendixsec{\parsearg\appendixsecyyy} ! 2291: \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz ! 2292: \def\appendixsectionzzz #1{\seccheck{appendixsection}% ! 2293: \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % ! 2294: \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% ! 2295: {\chapternofonts% ! 2296: \edef\temp{{\realbackslash secentry % ! 2297: {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}% ! 2298: \escapechar=`\\% ! 2299: \write \contentsfile \temp % ! 2300: \appendixnoderef % ! 2301: \penalty 10000 % ! 2302: }} ! 2303: ! 2304: \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} ! 2305: \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz ! 2306: \def\unnumberedseczzz #1{\seccheck{unnumberedsec}% ! 2307: \plainsecheading {#1}\gdef\thissection{#1}% ! 2308: {\chapternofonts% ! 2309: \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}% ! 2310: \escapechar=`\\% ! 2311: \write \contentsfile \temp % ! 2312: \unnumbnoderef % ! 2313: \penalty 10000 % ! 2314: }} ! 2315: ! 2316: \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} ! 2317: \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz ! 2318: \def\numberedsubseczzz #1{\seccheck{subsection}% ! 2319: \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % ! 2320: \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% ! 2321: {\chapternofonts% ! 2322: \edef\temp{{\realbackslash subsecentry % ! 2323: {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% ! 2324: \escapechar=`\\% ! 2325: \write \contentsfile \temp % ! 2326: \donoderef % ! 2327: \penalty 10000 % ! 2328: }} ! 2329: ! 2330: \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} ! 2331: \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz ! 2332: \def\appendixsubseczzz #1{\seccheck{appendixsubsec}% ! 2333: \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % ! 2334: \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% ! 2335: {\chapternofonts% ! 2336: \edef\temp{{\realbackslash subsecentry % ! 2337: {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% ! 2338: \escapechar=`\\% ! 2339: \write \contentsfile \temp % ! 2340: \appendixnoderef % ! 2341: \penalty 10000 % ! 2342: }} ! 2343: ! 2344: \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} ! 2345: \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz ! 2346: \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% ! 2347: \plainsecheading {#1}\gdef\thissection{#1}% ! 2348: {\chapternofonts% ! 2349: \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}% ! 2350: \escapechar=`\\% ! 2351: \write \contentsfile \temp % ! 2352: \unnumbnoderef % ! 2353: \penalty 10000 % ! 2354: }} ! 2355: ! 2356: \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} ! 2357: \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz ! 2358: \def\numberedsubsubseczzz #1{\seccheck{subsubsection}% ! 2359: \gdef\thissection{#1}\global\advance \subsubsecno by 1 % ! 2360: \subsubsecheading {#1} ! 2361: {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% ! 2362: {\chapternofonts% ! 2363: \edef\temp{{\realbackslash subsubsecentry % ! 2364: {#1} ! 2365: {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} ! 2366: {\noexpand\folio}}}% ! 2367: \escapechar=`\\% ! 2368: \write \contentsfile \temp % ! 2369: \donoderef % ! 2370: \penalty 10000 % ! 2371: }} ! 2372: ! 2373: \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} ! 2374: \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz ! 2375: \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% ! 2376: \gdef\thissection{#1}\global\advance \subsubsecno by 1 % ! 2377: \subsubsecheading {#1} ! 2378: {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% ! 2379: {\chapternofonts% ! 2380: \edef\temp{{\realbackslash subsubsecentry{#1}% ! 2381: {\appendixletter} ! 2382: {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% ! 2383: \escapechar=`\\% ! 2384: \write \contentsfile \temp % ! 2385: \appendixnoderef % ! 2386: \penalty 10000 % ! 2387: }} ! 2388: ! 2389: \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} ! 2390: \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz ! 2391: \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% ! 2392: \plainsecheading {#1}\gdef\thissection{#1}% ! 2393: {\chapternofonts% ! 2394: \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}% ! 2395: \escapechar=`\\% ! 2396: \write \contentsfile \temp % ! 2397: \unnumbnoderef % ! 2398: \penalty 10000 % ! 2399: }} ! 2400: ! 2401: % These are variants which are not "outer", so they can appear in @ifinfo. ! 2402: % Actually, they should now be obsolete; ordinary section commands should work. ! 2403: \def\infotop{\parsearg\unnumberedzzz} ! 2404: \def\infounnumbered{\parsearg\unnumberedzzz} ! 2405: \def\infounnumberedsec{\parsearg\unnumberedseczzz} ! 2406: \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} ! 2407: \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} ! 2408: ! 2409: \def\infoappendix{\parsearg\appendixzzz} ! 2410: \def\infoappendixsec{\parsearg\appendixseczzz} ! 2411: \def\infoappendixsubsec{\parsearg\appendixsubseczzz} ! 2412: \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} ! 2413: ! 2414: \def\infochapter{\parsearg\chapterzzz} ! 2415: \def\infosection{\parsearg\sectionzzz} ! 2416: \def\infosubsection{\parsearg\subsectionzzz} ! 2417: \def\infosubsubsection{\parsearg\subsubsectionzzz} ! 2418: ! 2419: % These macros control what the section commands do, according ! 2420: % to what kind of chapter we are in (ordinary, appendix, or unnumbered). ! 2421: % Define them by default for a numbered chapter. ! 2422: \global\let\section = \numberedsec ! 2423: \global\let\subsection = \numberedsubsec ! 2424: \global\let\subsubsection = \numberedsubsubsec ! 2425: ! 2426: % Define @majorheading, @heading and @subheading ! 2427: ! 2428: % NOTE on use of \vbox for chapter headings, section headings, and ! 2429: % such: ! 2430: % 1) We use \vbox rather than the earlier \line to permit ! 2431: % overlong headings to fold. ! 2432: % 2) \hyphenpenalty is set to 10000 because hyphenation in a ! 2433: % heading is obnoxious; this forbids it. ! 2434: % 3) Likewise, headings look best if no \parindent is used, and ! 2435: % if justification is not attempted. Hence \raggedright. ! 2436: ! 2437: ! 2438: \def\majorheading{\parsearg\majorheadingzzz} ! 2439: \def\majorheadingzzz #1{% ! 2440: {\advance\chapheadingskip by 10pt \chapbreak }% ! 2441: {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 ! 2442: \parindent=0pt\raggedright ! 2443: \rm #1\hfill}}\bigskip \par\penalty 200} ! 2444: ! 2445: \def\chapheading{\parsearg\chapheadingzzz} ! 2446: \def\chapheadingzzz #1{\chapbreak % ! 2447: {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 ! 2448: \parindent=0pt\raggedright ! 2449: \rm #1\hfill}}\bigskip \par\penalty 200} ! 2450: ! 2451: \def\heading{\parsearg\secheadingi} ! 2452: ! 2453: \def\subheading{\parsearg\subsecheadingi} ! 2454: ! 2455: \def\subsubheading{\parsearg\subsubsecheadingi} ! 2456: ! 2457: % These macros generate a chapter, section, etc. heading only ! 2458: % (including whitespace, linebreaking, etc. around it), ! 2459: % given all the information in convenient, parsed form. ! 2460: ! 2461: %%% Args are the skip and penalty (usually negative) ! 2462: \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} ! 2463: ! 2464: \def\setchapterstyle #1 {\csname CHAPF#1\endcsname} ! 2465: ! 2466: %%% Define plain chapter starts, and page on/off switching for it ! 2467: % Parameter controlling skip before chapter headings (if needed) ! 2468: ! 2469: \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt ! 2470: ! 2471: \def\chapbreak{\dobreak \chapheadingskip {-4000}} ! 2472: \def\chappager{\par\vfill\supereject} ! 2473: \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} ! 2474: ! 2475: \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} ! 2476: ! 2477: \def\CHAPPAGoff{ ! 2478: \global\let\pchapsepmacro=\chapbreak ! 2479: \global\let\pagealignmacro=\chappager} ! 2480: ! 2481: \def\CHAPPAGon{ ! 2482: \global\let\pchapsepmacro=\chappager ! 2483: \global\let\pagealignmacro=\chappager ! 2484: \global\def\HEADINGSon{\HEADINGSsingle}} ! 2485: ! 2486: \def\CHAPPAGodd{ ! 2487: \global\let\pchapsepmacro=\chapoddpage ! 2488: \global\let\pagealignmacro=\chapoddpage ! 2489: \global\def\HEADINGSon{\HEADINGSdouble}} ! 2490: ! 2491: \CHAPPAGon ! 2492: ! 2493: \def\CHAPFplain{ ! 2494: \global\let\chapmacro=\chfplain ! 2495: \global\let\unnumbchapmacro=\unnchfplain} ! 2496: ! 2497: \def\chfplain #1#2{% ! 2498: \pchapsepmacro ! 2499: {% ! 2500: \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 ! 2501: \parindent=0pt\raggedright ! 2502: \rm #2\enspace #1}% ! 2503: }% ! 2504: \bigskip ! 2505: \penalty5000 ! 2506: } ! 2507: ! 2508: \def\unnchfplain #1{% ! 2509: \pchapsepmacro % ! 2510: {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 ! 2511: \parindent=0pt\raggedright ! 2512: \rm #1\hfill}}\bigskip \par\penalty 10000 % ! 2513: } ! 2514: \CHAPFplain % The default ! 2515: ! 2516: \def\unnchfopen #1{% ! 2517: \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 ! 2518: \parindent=0pt\raggedright ! 2519: \rm #1\hfill}}\bigskip \par\penalty 10000 % ! 2520: } ! 2521: ! 2522: \def\chfopen #1#2{\chapoddpage {\chapfonts ! 2523: \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% ! 2524: \par\penalty 5000 % ! 2525: } ! 2526: ! 2527: \def\CHAPFopen{ ! 2528: \global\let\chapmacro=\chfopen ! 2529: \global\let\unnumbchapmacro=\unnchfopen} ! 2530: ! 2531: % Parameter controlling skip before section headings. ! 2532: ! 2533: \newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt ! 2534: \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} ! 2535: ! 2536: \newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt ! 2537: \def\secheadingbreak{\dobreak \secheadingskip {-1000}} ! 2538: ! 2539: % @paragraphindent is defined for the Info formatting commands only. ! 2540: \let\paragraphindent=\comment ! 2541: ! 2542: % Section fonts are the base font at magstep2, which produces ! 2543: % a size a bit more than 14 points in the default situation. ! 2544: ! 2545: \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} ! 2546: \def\plainsecheading #1{\secheadingi {#1}} ! 2547: \def\secheadingi #1{{\advance \secheadingskip by \parskip % ! 2548: \secheadingbreak}% ! 2549: {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 ! 2550: \parindent=0pt\raggedright ! 2551: \rm #1\hfill}}% ! 2552: \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } ! 2553: ! 2554: ! 2555: % Subsection fonts are the base font at magstep1, ! 2556: % which produces a size of 12 points. ! 2557: ! 2558: \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} ! 2559: \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % ! 2560: \subsecheadingbreak}% ! 2561: {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 ! 2562: \parindent=0pt\raggedright ! 2563: \rm #1\hfill}}% ! 2564: \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } ! 2565: ! 2566: \def\subsubsecfonts{\subsecfonts} % Maybe this should change: ! 2567: % Perhaps make sssec fonts scaled ! 2568: % magstep half ! 2569: \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} ! 2570: \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % ! 2571: \subsecheadingbreak}% ! 2572: {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 ! 2573: \parindent=0pt\raggedright ! 2574: \rm #1\hfill}}% ! 2575: \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} ! 2576: ! 2577: ! 2578: \message{toc printing,} ! 2579: ! 2580: % Finish up the main text and prepare to read what we've written ! 2581: % to \contentsfile. ! 2582: ! 2583: \newskip\contentsrightmargin \contentsrightmargin=1in ! 2584: \def\startcontents#1{% ! 2585: \pagealignmacro ! 2586: \immediate\closeout \contentsfile ! 2587: \ifnum \pageno>0 ! 2588: \pageno = -1 % Request roman numbered pages. ! 2589: \fi ! 2590: % Don't need to put `Contents' or `Short Contents' in the headline. ! 2591: % It is abundantly clear what they are. ! 2592: \unnumbchapmacro{#1}\def\thischapter{}% ! 2593: \begingroup % Set up to handle contents files properly. ! 2594: \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 ! 2595: \raggedbottom % Worry more about breakpoints than the bottom. ! 2596: \advance\hsize by -\contentsrightmargin % Don't use the full line length. ! 2597: } ! 2598: ! 2599: ! 2600: % Normal (long) toc. ! 2601: \outer\def\contents{% ! 2602: \startcontents{Table of Contents}% ! 2603: \input \jobname.toc ! 2604: \endgroup ! 2605: \vfill \eject ! 2606: } ! 2607: ! 2608: % And just the chapters. ! 2609: \outer\def\summarycontents{% ! 2610: \startcontents{Short Contents}% ! 2611: % ! 2612: \let\chapentry = \shortchapentry ! 2613: \let\unnumbchapentry = \shortunnumberedentry ! 2614: % We want a true roman here for the page numbers. ! 2615: \secfonts ! 2616: \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl ! 2617: \rm ! 2618: \advance\baselineskip by 1pt % Open it up a little. ! 2619: \def\secentry ##1##2##3##4{} ! 2620: \def\unnumbsecentry ##1##2{} ! 2621: \def\subsecentry ##1##2##3##4##5{} ! 2622: \def\unnumbsubsecentry ##1##2{} ! 2623: \def\subsubsecentry ##1##2##3##4##5##6{} ! 2624: \def\unnumbsubsubsecentry ##1##2{} ! 2625: \input \jobname.toc ! 2626: \endgroup ! 2627: \vfill \eject ! 2628: } ! 2629: \let\shortcontents = \summarycontents ! 2630: ! 2631: % These macros generate individual entries in the table of contents. ! 2632: % The first argument is the chapter or section name. ! 2633: % The last argument is the page number. ! 2634: % The arguments in between are the chapter number, section number, ... ! 2635: ! 2636: % Chapter-level things, for both the long and short contents. ! 2637: \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} ! 2638: ! 2639: % See comments in \dochapentry re vbox and related settings ! 2640: \def\shortchapentry#1#2#3{% ! 2641: \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% ! 2642: } ! 2643: ! 2644: % Typeset the label for a chapter or appendix for the short contents. ! 2645: % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. ! 2646: % We could simplify the code here by writing out an \appendixentry ! 2647: % command in the toc file for appendices, instead of using \chapentry ! 2648: % for both, but it doesn't seem worth it. ! 2649: \setbox0 = \hbox{\shortcontrm Appendix } ! 2650: \newdimen\shortappendixwidth \shortappendixwidth = \wd0 ! 2651: ! 2652: \def\shortchaplabel#1{% ! 2653: % We typeset #1 in a box of constant width, regardless of the text of ! 2654: % #1, so the chapter titles will come out aligned. ! 2655: \setbox0 = \hbox{#1}% ! 2656: \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi ! 2657: % ! 2658: % This space should be plenty, since a single number is .5em, and the ! 2659: % widest letter (M) is 1em, at least in the Computer Modern fonts. ! 2660: % (This space doesn't include the extra space that gets added after ! 2661: % the label; that gets put in in \shortchapentry above.) ! 2662: \advance\dimen0 by 1.1em ! 2663: \hbox to \dimen0{#1\hfil}% ! 2664: } ! 2665: ! 2666: \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} ! 2667: \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} ! 2668: ! 2669: % Sections. ! 2670: \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} ! 2671: \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} ! 2672: ! 2673: % Subsections. ! 2674: \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} ! 2675: \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} ! 2676: ! 2677: % And subsubsections. ! 2678: \def\subsubsecentry#1#2#3#4#5#6{% ! 2679: \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} ! 2680: \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} ! 2681: ! 2682: ! 2683: % This parameter controls the indentation of the various levels. ! 2684: \newdimen\tocindent \tocindent = 3pc ! 2685: ! 2686: % Now for the actual typesetting. In all these, #1 is the text and #2 is the ! 2687: % page number. ! 2688: % ! 2689: % If the toc has to be broken over pages, we would want to be at chapters ! 2690: % if at all possible; hence the \penalty. ! 2691: \def\dochapentry#1#2{% ! 2692: \penalty-300 \vskip\baselineskip ! 2693: \begingroup ! 2694: \chapentryfonts ! 2695: \tocentry{#1}{\dopageno{#2}}% ! 2696: \endgroup ! 2697: \nobreak\vskip .25\baselineskip ! 2698: } ! 2699: ! 2700: \def\dosecentry#1#2{\begingroup ! 2701: \secentryfonts \leftskip=\tocindent ! 2702: \tocentry{#1}{\dopageno{#2}}% ! 2703: \endgroup} ! 2704: ! 2705: \def\dosubsecentry#1#2{\begingroup ! 2706: \subsecentryfonts \leftskip=2\tocindent ! 2707: \tocentry{#1}{\dopageno{#2}}% ! 2708: \endgroup} ! 2709: ! 2710: \def\dosubsubsecentry#1#2{\begingroup ! 2711: \subsubsecentryfonts \leftskip=3\tocindent ! 2712: \tocentry{#1}{\dopageno{#2}}% ! 2713: \endgroup} ! 2714: ! 2715: % Final typesetting of a toc entry; we use the same \entry macro as for ! 2716: % the index entries, but we want to suppress hyphenation here. (We ! 2717: % can't do that in the \entry macro, since index entries might consist ! 2718: % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) ! 2719: % ! 2720: \def\tocentry#1#2{\begingroup ! 2721: \hyphenpenalty = 10000 ! 2722: \entry{#1}{#2}% ! 2723: \endgroup} ! 2724: ! 2725: % Space between chapter (or whatever) number and the title. ! 2726: \def\labelspace{\hskip1em \relax} ! 2727: ! 2728: \def\dopageno#1{{\rm #1}} ! 2729: \def\doshortpageno#1{{\rm #1}} ! 2730: ! 2731: \def\chapentryfonts{\secfonts \rm} ! 2732: \def\secentryfonts{\textfonts} ! 2733: \let\subsecentryfonts = \textfonts ! 2734: \let\subsubsecentryfonts = \textfonts ! 2735: ! 2736: ! 2737: \message{environments,} ! 2738: ! 2739: % Since these characters are used in examples, it should be an even number of ! 2740: % \tt widths. Each \tt character is 1en, so two makes it 1em. ! 2741: % Furthermore, these definitions must come after we define our fonts. ! 2742: \newbox\dblarrowbox \newbox\longdblarrowbox ! 2743: \newbox\pushcharbox \newbox\bullbox ! 2744: \newbox\equivbox \newbox\errorbox ! 2745: ! 2746: \let\ptexequiv = \equiv ! 2747: ! 2748: %{\tentt ! 2749: %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} ! 2750: %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} ! 2751: %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} ! 2752: %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} ! 2753: % Adapted from the manmac format (p.420 of TeXbook) ! 2754: %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex ! 2755: % depth .1ex\hfil} ! 2756: %} ! 2757: ! 2758: \def\point{$\star$} ! 2759: ! 2760: \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} ! 2761: \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} ! 2762: \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} ! 2763: ! 2764: \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} ! 2765: ! 2766: % Adapted from the TeXbook's \boxit. ! 2767: {\tentt \global\dimen0 = 3em}% Width of the box. ! 2768: \dimen2 = .55pt % Thickness of rules ! 2769: % The text. (`r' is open on the right, `e' somewhat less so on the left.) ! 2770: \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} ! 2771: ! 2772: \global\setbox\errorbox=\hbox to \dimen0{\hfil ! 2773: \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. ! 2774: \advance\hsize by -2\dimen2 % Rules. ! 2775: \vbox{ ! 2776: \hrule height\dimen2 ! 2777: \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. ! 2778: \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. ! 2779: \kern3pt\vrule width\dimen2}% Space to right. ! 2780: \hrule height\dimen2} ! 2781: \hfil} ! 2782: ! 2783: % The @error{} command. ! 2784: \def\error{\leavevmode\lower.7ex\copy\errorbox} ! 2785: ! 2786: % @tex ... @end tex escapes into raw Tex temporarily. ! 2787: % One exception: @ is still an escape character, so that @end tex works. ! 2788: % But \@ or @@ will get a plain tex @ character. ! 2789: ! 2790: \def\tex{\begingroup ! 2791: \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 ! 2792: \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 ! 2793: \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie ! 2794: \catcode `\%=14 ! 2795: \catcode 43=12 ! 2796: \catcode`\"=12 ! 2797: \catcode`\==12 ! 2798: \catcode`\|=12 ! 2799: \catcode`\<=12 ! 2800: \catcode`\>=12 ! 2801: \escapechar=`\\ ! 2802: % ! 2803: \let\{=\ptexlbrace ! 2804: \let\}=\ptexrbrace ! 2805: \let\.=\ptexdot ! 2806: \let\*=\ptexstar ! 2807: \let\dots=\ptexdots ! 2808: \def\@{@}% ! 2809: \let\bullet=\ptexbullet ! 2810: \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl ! 2811: \let\L=\ptexL ! 2812: % ! 2813: \let\Etex=\endgroup} ! 2814: ! 2815: % Define @lisp ... @endlisp. ! 2816: % @lisp does a \begingroup so it can rebind things, ! 2817: % including the definition of @endlisp (which normally is erroneous). ! 2818: ! 2819: % Amount to narrow the margins by for @lisp. ! 2820: \newskip\lispnarrowing \lispnarrowing=0.4in ! 2821: ! 2822: % This is the definition that ^^M gets inside @lisp, @example, and other ! 2823: % such environments. \null is better than a space, since it doesn't ! 2824: % have any width. ! 2825: \def\lisppar{\null\endgraf} ! 2826: ! 2827: % Make each space character in the input produce a normal interword ! 2828: % space in the output. Don't allow a line break at this space, as this ! 2829: % is used only in environments like @example, where each line of input ! 2830: % should produce a line of output anyway. ! 2831: % ! 2832: {\obeyspaces % ! 2833: \gdef\sepspaces{\obeyspaces\let =\tie}} ! 2834: ! 2835: % Define \obeyedspace to be our active space, whatever it is. This is ! 2836: % for use in \parsearg. ! 2837: {\sepspaces % ! 2838: \global\let\obeyedspace= } ! 2839: ! 2840: % This space is always present above and below environments. ! 2841: \newskip\envskipamount \envskipamount = 0pt ! 2842: ! 2843: % Make spacing and below environment symmetrical. We use \parskip here ! 2844: % to help in doing that, since in @example-like environments \parskip ! 2845: % is reset to zero; thus the \afterenvbreak inserts no space -- but the ! 2846: % start of the next paragraph will insert \parskip ! 2847: % ! 2848: \def\aboveenvbreak{{\advance\envskipamount by \parskip ! 2849: \endgraf \ifdim\lastskip<\envskipamount ! 2850: \removelastskip \penalty-50 \vskip\envskipamount \fi}} ! 2851: ! 2852: \let\afterenvbreak = \aboveenvbreak ! 2853: ! 2854: % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. ! 2855: \let\nonarrowing=\relax ! 2856: ! 2857: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 2858: % \cartouche: draw rectangle w/rounded corners around argument ! 2859: \font\circle=lcircle10 ! 2860: \newdimen\circthick ! 2861: \newdimen\cartouter\newdimen\cartinner ! 2862: \newskip\normbskip\newskip\normpskip\newskip\normlskip ! 2863: \circthick=\fontdimen8\circle ! 2864: % ! 2865: \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth ! 2866: \def\ctr{{\hskip 6pt\circle\char'010}} ! 2867: \def\cbl{{\circle\char'012\hskip -6pt}} ! 2868: \def\cbr{{\hskip 6pt\circle\char'011}} ! 2869: \def\carttop{\hbox to \cartouter{\hskip\lskip ! 2870: \ctl\leaders\hrule height\circthick\hfil\ctr ! 2871: \hskip\rskip}} ! 2872: \def\cartbot{\hbox to \cartouter{\hskip\lskip ! 2873: \cbl\leaders\hrule height\circthick\hfil\cbr ! 2874: \hskip\rskip}} ! 2875: % ! 2876: \newskip\lskip\newskip\rskip ! 2877: ! 2878: \long\def\cartouche{% ! 2879: \begingroup ! 2880: \lskip=\leftskip \rskip=\rightskip ! 2881: \leftskip=0pt\rightskip=0pt %we want these *outside*. ! 2882: \cartinner=\hsize \advance\cartinner by-\lskip ! 2883: \advance\cartinner by-\rskip ! 2884: \cartouter=\hsize ! 2885: \advance\cartouter by 18pt % allow for 3pt kerns on either ! 2886: % side, and for 6pt waste from ! 2887: % each corner char ! 2888: \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip ! 2889: % Flag to tell @lisp, etc., not to narrow margin. ! 2890: \let\nonarrowing=\comment ! 2891: \vbox\bgroup ! 2892: \baselineskip=0pt\parskip=0pt\lineskip=0pt ! 2893: \carttop ! 2894: \hbox\bgroup ! 2895: \hskip\lskip ! 2896: \vrule\kern3pt ! 2897: \vbox\bgroup ! 2898: \hsize=\cartinner ! 2899: \kern3pt ! 2900: \begingroup ! 2901: \baselineskip=\normbskip ! 2902: \lineskip=\normlskip ! 2903: \parskip=\normpskip ! 2904: \vskip -\parskip ! 2905: \def\Ecartouche{% ! 2906: \endgroup ! 2907: \kern3pt ! 2908: \egroup ! 2909: \kern3pt\vrule ! 2910: \hskip\rskip ! 2911: \egroup ! 2912: \cartbot ! 2913: \egroup ! 2914: \endgroup ! 2915: }} ! 2916: ! 2917: ! 2918: % This macro is called at the beginning of all the @example variants, ! 2919: % inside a group. ! 2920: \def\nonfillstart{% ! 2921: \aboveenvbreak ! 2922: \inENV % This group ends at the end of the body ! 2923: \hfuzz = 12pt % Don't be fussy ! 2924: \sepspaces % Make spaces be word-separators rather than space tokens. ! 2925: \singlespace ! 2926: \let\par = \lisppar % don't ignore blank lines ! 2927: \obeylines % each line of input is a line of output ! 2928: \parskip = 0pt ! 2929: \parindent = 0pt ! 2930: \emergencystretch = 0pt % don't try to avoid overfull boxes ! 2931: % @cartouche defines \nonarrowing to inhibit narrowing ! 2932: % at next level down. ! 2933: \ifx\nonarrowing\relax ! 2934: \advance \leftskip by \lispnarrowing ! 2935: \exdentamount=\lispnarrowing ! 2936: \let\exdent=\nofillexdent ! 2937: \let\nonarrowing=\relax ! 2938: \fi ! 2939: } ! 2940: ! 2941: % To ending an @example-like environment, we first end the paragraph ! 2942: % (via \afterenvbreak's vertical glue), and then the group. That way we ! 2943: % keep the zero \parskip that the environments set -- \parskip glue ! 2944: % will be inserted at the beginning of the next paragraph in the ! 2945: % document, after the environment. ! 2946: % ! 2947: \def\nonfillfinish{\afterenvbreak\endgroup}% ! 2948: ! 2949: % This macro is ! 2950: \def\lisp{\begingroup ! 2951: \nonfillstart ! 2952: \let\Elisp = \nonfillfinish ! 2953: \tt ! 2954: \rawbackslash % have \ input char produce \ char from current font ! 2955: \gobble ! 2956: } ! 2957: ! 2958: % Define the \E... control sequence only if we are inside the ! 2959: % environment, so the error checking in \end will work. ! 2960: % ! 2961: % We must call \lisp last in the definition, since it reads the ! 2962: % return following the @example (or whatever) command. ! 2963: % ! 2964: \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} ! 2965: \def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp} ! 2966: \def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp} ! 2967: ! 2968: % @smallexample and @smalllisp. This is not used unless the @smallbook ! 2969: % command is given. Originally contributed by Pavel@xerox. ! 2970: % ! 2971: \def\smalllispx{\begingroup ! 2972: \nonfillstart ! 2973: \let\Esmalllisp = \nonfillfinish ! 2974: \let\Esmallexample = \nonfillfinish ! 2975: % ! 2976: % Smaller interline space and fonts for small examples. ! 2977: \baselineskip 10pt ! 2978: \indexfonts \tt ! 2979: \rawbackslash % output the \ character from the current font ! 2980: \gobble ! 2981: } ! 2982: ! 2983: % This is @display; same as @lisp except use roman font. ! 2984: % ! 2985: \def\display{\begingroup ! 2986: \nonfillstart ! 2987: \let\Edisplay = \nonfillfinish ! 2988: \gobble ! 2989: } ! 2990: ! 2991: % This is @format; same as @display except don't narrow margins. ! 2992: % ! 2993: \def\format{\begingroup ! 2994: \let\nonarrowing = t ! 2995: \nonfillstart ! 2996: \let\Eformat = \nonfillfinish ! 2997: \gobble ! 2998: } ! 2999: ! 3000: % @flushleft (same as @format) and @flushright. ! 3001: % ! 3002: \def\flushleft{\begingroup ! 3003: \let\nonarrowing = t ! 3004: \nonfillstart ! 3005: \let\Eflushleft = \nonfillfinish ! 3006: \gobble ! 3007: } ! 3008: \def\flushright{\begingroup ! 3009: \let\nonarrowing = t ! 3010: \nonfillstart ! 3011: \let\Eflushright = \nonfillfinish ! 3012: \advance\leftskip by 0pt plus 1fill ! 3013: \gobble} ! 3014: ! 3015: % @quotation does normal linebreaking and narrows the margins. ! 3016: % ! 3017: \def\quotation{% ! 3018: \begingroup\inENV %This group ends at the end of the @quotation body ! 3019: {\parskip=0pt % because we will skip by \parskip too, later ! 3020: \aboveenvbreak}% ! 3021: \singlespace ! 3022: \parindent=0pt ! 3023: \let\Equotation = \nonfillfinish ! 3024: % @cartouche defines \nonarrowing to inhibit narrowing ! 3025: % at next level down. ! 3026: \ifx\nonarrowing\relax ! 3027: \advance \leftskip by \lispnarrowing ! 3028: \advance \rightskip by \lispnarrowing ! 3029: \exdentamount=\lispnarrowing ! 3030: \let\nonarrowing=\relax ! 3031: \fi} ! 3032: ! 3033: \message{defuns,} ! 3034: % Define formatter for defuns ! 3035: % First, allow user to change definition object font (\df) internally ! 3036: \def\setdeffont #1 {\csname DEF#1\endcsname} ! 3037: ! 3038: \newskip\defbodyindent \defbodyindent=.4in ! 3039: \newskip\defargsindent \defargsindent=50pt ! 3040: \newskip\deftypemargin \deftypemargin=12pt ! 3041: \newskip\deflastargmargin \deflastargmargin=18pt ! 3042: ! 3043: \newcount\parencount ! 3044: % define \functionparens, which makes ( and ) and & do special things. ! 3045: % \functionparens affects the group it is contained in. ! 3046: \def\activeparens{% ! 3047: \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active ! 3048: \catcode`\[=\active \catcode`\]=\active} ! 3049: ! 3050: % Make control sequences which act like normal parenthesis chars. ! 3051: \let\lparen = ( \let\rparen = ) ! 3052: ! 3053: {\activeparens % Now, smart parens don't turn on until &foo (see \amprm) ! 3054: ! 3055: % Be sure that we always have a definition for `(', etc. For example, ! 3056: % if the fn name has parens in it, \boldbrax will not be in effect yet, ! 3057: % so TeX would otherwise complain about undefined control sequence. ! 3058: \global\let(=\lparen \global\let)=\rparen ! 3059: \global\let[=\lbrack \global\let]=\rbrack ! 3060: ! 3061: \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } ! 3062: \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} ! 3063: ! 3064: % Definitions of (, ) and & used in args for functions. ! 3065: % This is the definition of ( outside of all parentheses. ! 3066: \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested % ! 3067: \global\advance\parencount by 1 } ! 3068: % ! 3069: % This is the definition of ( when already inside a level of parens. ! 3070: \gdef\opnested{\char`\(\global\advance\parencount by 1 } ! 3071: % ! 3072: \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. ! 3073: % also in that case restore the outer-level definition of (. ! 3074: \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi ! 3075: \global\advance \parencount by -1 } ! 3076: % If we encounter &foo, then turn on ()-hacking afterwards ! 3077: \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } ! 3078: % ! 3079: \gdef\normalparens{\boldbrax\let&=\ampnr} ! 3080: } % End of definition inside \activeparens ! 3081: %% These parens (in \boldbrax) actually are a little bolder than the ! 3082: %% contained text. This is especially needed for [ and ] ! 3083: \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&} ! 3084: \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} ! 3085: ! 3086: % First, defname, which formats the header line itself. ! 3087: % #1 should be the function name. ! 3088: % #2 should be the type of definition, such as "Function". ! 3089: ! 3090: \def\defname #1#2{% ! 3091: % Get the values of \leftskip and \rightskip as they were ! 3092: % outside the @def... ! 3093: \dimen2=\leftskip ! 3094: \advance\dimen2 by -\defbodyindent ! 3095: \dimen3=\rightskip ! 3096: \advance\dimen3 by -\defbodyindent ! 3097: \noindent % ! 3098: \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% ! 3099: \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line ! 3100: \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations ! 3101: \parshape 2 0in \dimen0 \defargsindent \dimen1 % ! 3102: % Now output arg 2 ("Function" or some such) ! 3103: % ending at \deftypemargin from the right margin, ! 3104: % but stuck inside a box of width 0 so it does not interfere with linebreaking ! 3105: {% Adjust \hsize to exclude the ambient margins, ! 3106: % so that \rightline will obey them. ! 3107: \advance \hsize by -\dimen2 \advance \hsize by -\dimen3 ! 3108: \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% ! 3109: % Make all lines underfull and no complaints: ! 3110: \tolerance=10000 \hbadness=10000 ! 3111: \advance\leftskip by -\defbodyindent ! 3112: \exdentamount=\defbodyindent ! 3113: {\df #1}\enskip % Generate function name ! 3114: } ! 3115: ! 3116: % Actually process the body of a definition ! 3117: % #1 should be the terminating control sequence, such as \Edefun. ! 3118: % #2 should be the "another name" control sequence, such as \defunx. ! 3119: % #3 should be the control sequence that actually processes the header, ! 3120: % such as \defunheader. ! 3121: ! 3122: \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody ! 3123: \medbreak % ! 3124: % Define the end token that this defining construct specifies ! 3125: % so that it will exit this group. ! 3126: \def#1{\endgraf\endgroup\medbreak}% ! 3127: \def#2{\begingroup\obeylines\activeparens\spacesplit#3}% ! 3128: \parindent=0in ! 3129: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent ! 3130: \exdentamount=\defbodyindent ! 3131: \begingroup % ! 3132: \catcode 61=\active % 61 is `=' ! 3133: \obeylines\activeparens\spacesplit#3} ! 3134: ! 3135: \def\defmethparsebody #1#2#3#4 {\begingroup\inENV % ! 3136: \medbreak % ! 3137: % Define the end token that this defining construct specifies ! 3138: % so that it will exit this group. ! 3139: \def#1{\endgraf\endgroup\medbreak}% ! 3140: \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% ! 3141: \parindent=0in ! 3142: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent ! 3143: \exdentamount=\defbodyindent ! 3144: \begingroup\obeylines\activeparens\spacesplit{#3{#4}}} ! 3145: ! 3146: \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % ! 3147: \medbreak % ! 3148: % Define the end token that this defining construct specifies ! 3149: % so that it will exit this group. ! 3150: \def#1{\endgraf\endgroup\medbreak}% ! 3151: \def#2##1 ##2 {\def#4{##1}% ! 3152: \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% ! 3153: \parindent=0in ! 3154: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent ! 3155: \exdentamount=\defbodyindent ! 3156: \begingroup\obeylines\activeparens\spacesplit{#3{#5}}} ! 3157: ! 3158: % These parsing functions are similar to the preceding ones ! 3159: % except that they do not make parens into active characters. ! 3160: % These are used for "variables" since they have no arguments. ! 3161: ! 3162: \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody ! 3163: \medbreak % ! 3164: % Define the end token that this defining construct specifies ! 3165: % so that it will exit this group. ! 3166: \def#1{\endgraf\endgroup\medbreak}% ! 3167: \def#2{\begingroup\obeylines\spacesplit#3}% ! 3168: \parindent=0in ! 3169: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent ! 3170: \exdentamount=\defbodyindent ! 3171: \begingroup % ! 3172: \catcode 61=\active % ! 3173: \obeylines\spacesplit#3} ! 3174: ! 3175: % This is used for \def{tp,vr}parsebody. It could probably be used for ! 3176: % some of the others, too, with some judicious conditionals. ! 3177: % ! 3178: \def\parsebodycommon#1#2#3{% ! 3179: \begingroup\inENV % ! 3180: \medbreak % ! 3181: % Define the end token that this defining construct specifies ! 3182: % so that it will exit this group. ! 3183: \def#1{\endgraf\endgroup\medbreak}% ! 3184: \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% ! 3185: \parindent=0in ! 3186: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent ! 3187: \exdentamount=\defbodyindent ! 3188: \begingroup\obeylines ! 3189: } ! 3190: ! 3191: \def\defvrparsebody#1#2#3#4 {% ! 3192: \parsebodycommon{#1}{#2}{#3}% ! 3193: \spacesplit{#3{#4}}% ! 3194: } ! 3195: ! 3196: % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the ! 3197: % type is just `struct', because we lose the braces in `{struct ! 3198: % termios}' when \spacesplit reads its undelimited argument. Sigh. ! 3199: % \let\deftpparsebody=\defvrparsebody ! 3200: % ! 3201: % So, to get around this, we put \empty in with the type name. That ! 3202: % way, TeX won't find exactly `{...}' as an undelimited argument, and ! 3203: % won't strip off the braces. ! 3204: % ! 3205: \def\deftpparsebody #1#2#3#4 {% ! 3206: \parsebodycommon{#1}{#2}{#3}% ! 3207: \spacesplit{\parsetpheaderline{#3{#4}}}\empty ! 3208: } ! 3209: ! 3210: % Fine, but then we have to eventually remove the \empty *and* the ! 3211: % braces (if any). That's what this does, putting the result in \tptemp. ! 3212: % ! 3213: \def\removeemptybraces\empty#1\relax{\def\tptemp{#1}}% ! 3214: ! 3215: % After \spacesplit has done its work, this is called -- #1 is the final ! 3216: % thing to call, #2 the type name (which starts with \empty), and #3 ! 3217: % (which might be empty) the arguments. ! 3218: % ! 3219: \def\parsetpheaderline#1#2#3{% ! 3220: \removeemptybraces#2\relax ! 3221: #1{\tptemp}{#3}% ! 3222: }% ! 3223: ! 3224: \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % ! 3225: \medbreak % ! 3226: % Define the end token that this defining construct specifies ! 3227: % so that it will exit this group. ! 3228: \def#1{\endgraf\endgroup\medbreak}% ! 3229: \def#2##1 ##2 {\def#4{##1}% ! 3230: \begingroup\obeylines\spacesplit{#3{##2}}}% ! 3231: \parindent=0in ! 3232: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent ! 3233: \exdentamount=\defbodyindent ! 3234: \begingroup\obeylines\spacesplit{#3{#5}}} ! 3235: ! 3236: % Split up #2 at the first space token. ! 3237: % call #1 with two arguments: ! 3238: % the first is all of #2 before the space token, ! 3239: % the second is all of #2 after that space token. ! 3240: % If #2 contains no space token, all of it is passed as the first arg ! 3241: % and the second is passed as empty. ! 3242: ! 3243: {\obeylines ! 3244: \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% ! 3245: \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% ! 3246: \ifx\relax #3% ! 3247: #1{#2}{}\else #1{#2}{#3#4}\fi}} ! 3248: ! 3249: % So much for the things common to all kinds of definitions. ! 3250: ! 3251: % Define @defun. ! 3252: ! 3253: % First, define the processing that is wanted for arguments of \defun ! 3254: % Use this to expand the args and terminate the paragraph they make up ! 3255: ! 3256: \def\defunargs #1{\functionparens \sl ! 3257: % Expand, preventing hyphenation at `-' chars. ! 3258: % Note that groups don't affect changes in \hyphenchar. ! 3259: \hyphenchar\tensl=0 ! 3260: #1% ! 3261: \hyphenchar\tensl=45 ! 3262: \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi% ! 3263: \interlinepenalty=10000 ! 3264: \advance\rightskip by 0pt plus 1fil ! 3265: \endgraf\penalty 10000\vskip -\parskip\penalty 10000% ! 3266: } ! 3267: ! 3268: \def\deftypefunargs #1{% ! 3269: % Expand, preventing hyphenation at `-' chars. ! 3270: % Note that groups don't affect changes in \hyphenchar. ! 3271: \functionparens ! 3272: \code{#1}% ! 3273: \interlinepenalty=10000 ! 3274: \advance\rightskip by 0pt plus 1fil ! 3275: \endgraf\penalty 10000\vskip -\parskip\penalty 10000% ! 3276: } ! 3277: ! 3278: % Do complete processing of one @defun or @defunx line already parsed. ! 3279: ! 3280: % @deffn Command forward-char nchars ! 3281: ! 3282: \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} ! 3283: ! 3284: \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% ! 3285: \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % ! 3286: \catcode 61=\other % Turn off change made in \defparsebody ! 3287: } ! 3288: ! 3289: % @defun == @deffn Function ! 3290: ! 3291: \def\defun{\defparsebody\Edefun\defunx\defunheader} ! 3292: ! 3293: \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index ! 3294: \begingroup\defname {#1}{Function}% ! 3295: \defunargs {#2}\endgroup % ! 3296: \catcode 61=\other % Turn off change made in \defparsebody ! 3297: } ! 3298: ! 3299: % @deftypefun int foobar (int @var{foo}, float @var{bar}) ! 3300: ! 3301: \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} ! 3302: ! 3303: % #1 is the data type. #2 is the name and args. ! 3304: \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} ! 3305: % #1 is the data type, #2 the name, #3 the args. ! 3306: \def\deftypefunheaderx #1#2 #3\relax{% ! 3307: \doind {fn}{\code{#2}}% Make entry in function index ! 3308: \begingroup\defname {\code{#1} #2}{Function}% ! 3309: \deftypefunargs {#3}\endgroup % ! 3310: \catcode 61=\other % Turn off change made in \defparsebody ! 3311: } ! 3312: ! 3313: % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) ! 3314: ! 3315: \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} ! 3316: ! 3317: % #1 is the classification. #2 is the data type. #3 is the name and args. ! 3318: \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} ! 3319: % #1 is the classification, #2 the data type, #3 the name, #4 the args. ! 3320: \def\deftypefnheaderx #1#2#3 #4\relax{% ! 3321: \doind {fn}{\code{#3}}% Make entry in function index ! 3322: \begingroup ! 3323: \normalparens % notably, turn off `&' magic, which prevents ! 3324: % at least some C++ text from working ! 3325: \defname {\code{#2} #3}{#1}% ! 3326: \deftypefunargs {#4}\endgroup % ! 3327: \catcode 61=\other % Turn off change made in \defparsebody ! 3328: } ! 3329: ! 3330: % @defmac == @deffn Macro ! 3331: ! 3332: \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} ! 3333: ! 3334: \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index ! 3335: \begingroup\defname {#1}{Macro}% ! 3336: \defunargs {#2}\endgroup % ! 3337: \catcode 61=\other % Turn off change made in \defparsebody ! 3338: } ! 3339: ! 3340: % @defspec == @deffn Special Form ! 3341: ! 3342: \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} ! 3343: ! 3344: \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index ! 3345: \begingroup\defname {#1}{Special Form}% ! 3346: \defunargs {#2}\endgroup % ! 3347: \catcode 61=\other % Turn off change made in \defparsebody ! 3348: } ! 3349: ! 3350: % This definition is run if you use @defunx ! 3351: % anywhere other than immediately after a @defun or @defunx. ! 3352: ! 3353: \def\deffnx #1 {\errmessage{@deffnx in invalid context}} ! 3354: \def\defunx #1 {\errmessage{@defunx in invalid context}} ! 3355: \def\defmacx #1 {\errmessage{@defmacx in invalid context}} ! 3356: \def\defspecx #1 {\errmessage{@defspecx in invalid context}} ! 3357: \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} ! 3358: \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} ! 3359: ! 3360: % @defmethod, and so on ! 3361: ! 3362: % @defop {Funny Method} foo-class frobnicate argument ! 3363: ! 3364: \def\defop #1 {\def\defoptype{#1}% ! 3365: \defopparsebody\Edefop\defopx\defopheader\defoptype} ! 3366: ! 3367: \def\defopheader #1#2#3{% ! 3368: \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index ! 3369: \begingroup\defname {#2}{\defoptype{} on #1}% ! 3370: \defunargs {#3}\endgroup % ! 3371: } ! 3372: ! 3373: % @defmethod == @defop Method ! 3374: ! 3375: \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} ! 3376: ! 3377: \def\defmethodheader #1#2#3{% ! 3378: \dosubind {fn}{\code{#2}}{on #1}% entry in function index ! 3379: \begingroup\defname {#2}{Method on #1}% ! 3380: \defunargs {#3}\endgroup % ! 3381: } ! 3382: ! 3383: % @defcv {Class Option} foo-class foo-flag ! 3384: ! 3385: \def\defcv #1 {\def\defcvtype{#1}% ! 3386: \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} ! 3387: ! 3388: \def\defcvarheader #1#2#3{% ! 3389: \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index ! 3390: \begingroup\defname {#2}{\defcvtype{} of #1}% ! 3391: \defvarargs {#3}\endgroup % ! 3392: } ! 3393: ! 3394: % @defivar == @defcv {Instance Variable} ! 3395: ! 3396: \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} ! 3397: ! 3398: \def\defivarheader #1#2#3{% ! 3399: \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index ! 3400: \begingroup\defname {#2}{Instance Variable of #1}% ! 3401: \defvarargs {#3}\endgroup % ! 3402: } ! 3403: ! 3404: % These definitions are run if you use @defmethodx, etc., ! 3405: % anywhere other than immediately after a @defmethod, etc. ! 3406: ! 3407: \def\defopx #1 {\errmessage{@defopx in invalid context}} ! 3408: \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} ! 3409: \def\defcvx #1 {\errmessage{@defcvx in invalid context}} ! 3410: \def\defivarx #1 {\errmessage{@defivarx in invalid context}} ! 3411: ! 3412: % Now @defvar ! 3413: ! 3414: % First, define the processing that is wanted for arguments of @defvar. ! 3415: % This is actually simple: just print them in roman. ! 3416: % This must expand the args and terminate the paragraph they make up ! 3417: \def\defvarargs #1{\normalparens #1% ! 3418: \interlinepenalty=10000 ! 3419: \endgraf\penalty 10000\vskip -\parskip\penalty 10000} ! 3420: ! 3421: % @defvr Counter foo-count ! 3422: ! 3423: \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} ! 3424: ! 3425: \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% ! 3426: \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} ! 3427: ! 3428: % @defvar == @defvr Variable ! 3429: ! 3430: \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} ! 3431: ! 3432: \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index ! 3433: \begingroup\defname {#1}{Variable}% ! 3434: \defvarargs {#2}\endgroup % ! 3435: } ! 3436: ! 3437: % @defopt == @defvr {User Option} ! 3438: ! 3439: \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} ! 3440: ! 3441: \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index ! 3442: \begingroup\defname {#1}{User Option}% ! 3443: \defvarargs {#2}\endgroup % ! 3444: } ! 3445: ! 3446: % @deftypevar int foobar ! 3447: ! 3448: \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} ! 3449: ! 3450: % #1 is the data type. #2 is the name. ! 3451: \def\deftypevarheader #1#2{% ! 3452: \doind {vr}{\code{#2}}% Make entry in variables index ! 3453: \begingroup\defname {\code{#1} #2}{Variable}% ! 3454: \interlinepenalty=10000 ! 3455: \endgraf\penalty 10000\vskip -\parskip\penalty 10000 ! 3456: \endgroup} ! 3457: ! 3458: % @deftypevr {Global Flag} int enable ! 3459: ! 3460: \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} ! 3461: ! 3462: \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% ! 3463: \begingroup\defname {\code{#2} #3}{#1} ! 3464: \interlinepenalty=10000 ! 3465: \endgraf\penalty 10000\vskip -\parskip\penalty 10000 ! 3466: \endgroup} ! 3467: ! 3468: % This definition is run if you use @defvarx ! 3469: % anywhere other than immediately after a @defvar or @defvarx. ! 3470: ! 3471: \def\defvrx #1 {\errmessage{@defvrx in invalid context}} ! 3472: \def\defvarx #1 {\errmessage{@defvarx in invalid context}} ! 3473: \def\defoptx #1 {\errmessage{@defoptx in invalid context}} ! 3474: \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} ! 3475: \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} ! 3476: ! 3477: % Now define @deftp ! 3478: % Args are printed in bold, a slight difference from @defvar. ! 3479: ! 3480: \def\deftpargs #1{\bf \defvarargs{#1}} ! 3481: ! 3482: % @deftp Class window height width ... ! 3483: ! 3484: \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} ! 3485: ! 3486: \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% ! 3487: \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} ! 3488: ! 3489: % This definition is run if you use @deftpx, etc ! 3490: % anywhere other than immediately after a @deftp, etc. ! 3491: ! 3492: \def\deftpx #1 {\errmessage{@deftpx in invalid context}} ! 3493: ! 3494: \message{cross reference,} ! 3495: % Define cross-reference macros ! 3496: \newwrite \auxfile ! 3497: ! 3498: \newif\ifhavexrefs % True if xref values are known. ! 3499: \newif\ifwarnedxrefs % True if we warned once that they aren't known. ! 3500: ! 3501: % \setref{foo} defines a cross-reference point named foo. ! 3502: ! 3503: \def\setref#1{% ! 3504: \dosetq{#1-title}{Ytitle}% ! 3505: \dosetq{#1-pg}{Ypagenumber}% ! 3506: \dosetq{#1-snt}{Ysectionnumberandtype}} ! 3507: ! 3508: \def\unnumbsetref#1{% ! 3509: \dosetq{#1-title}{Ytitle}% ! 3510: \dosetq{#1-pg}{Ypagenumber}% ! 3511: \dosetq{#1-snt}{Ynothing}} ! 3512: ! 3513: \def\appendixsetref#1{% ! 3514: \dosetq{#1-title}{Ytitle}% ! 3515: \dosetq{#1-pg}{Ypagenumber}% ! 3516: \dosetq{#1-snt}{Yappendixletterandtype}} ! 3517: ! 3518: % \xref, \pxref, and \ref generate cross-references to specified points. ! 3519: % For \xrefX, #1 is the node name, #2 the name of the Info ! 3520: % cross-reference, #3 the printed node name, #4 the name of the Info ! 3521: % file, #5 the name of the printed manual. All but the node name can be ! 3522: % omitted. ! 3523: % ! 3524: \def\pxref#1{see \xrefX[#1,,,,,,,]} ! 3525: \def\xref#1{See \xrefX[#1,,,,,,,]} ! 3526: \def\ref#1{\xrefX[#1,,,,,,,]} ! 3527: \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup% ! 3528: \def\printedmanual{\ignorespaces #5}% ! 3529: \def\printednodename{\ignorespaces #3}% ! 3530: % ! 3531: \setbox1=\hbox{\printedmanual}% ! 3532: \setbox0=\hbox{\printednodename}% ! 3533: \ifdim \wd0=0pt% ! 3534: % No printed node name was explicitly given. ! 3535: \ifx SETxref-automatic-section-title % ! 3536: % This line should make the actual chapter or section title appear inside ! 3537: % the square brackets. Use the real section title if we have it. ! 3538: \ifdim \wd1>0pt% ! 3539: % It is in another manual, so we don't have it. ! 3540: \def\printednodename{\ignorespaces #1} \else% ! 3541: % We know the real title if we have the xref values. ! 3542: \ifhavexrefs \def\printednodename{\refx{#1-title}}% ! 3543: % Otherwise just copy the Info node name. ! 3544: \else \def\printednodename{\ignorespaces #1} \fi% ! 3545: \fi\def\printednodename{#1-title}% ! 3546: \else% This line just uses the node name. ! 3547: \def\printednodename{\ignorespaces #1}% ! 3548: \fi% ends \ifx SETxref-automatic-section-title ! 3549: \fi% ends \ifdim \wd0 ! 3550: % ! 3551: % ! 3552: % If we use \unhbox0 and \unhbox1 to print the node names, TeX does ! 3553: % not insert empty discretionaries after hyphens, which means that it ! 3554: % will not find a line break at a hyphen in a node names. Since some ! 3555: % manuals are best written with fairly long node names, containing ! 3556: % hyphens, this is a loss. Therefore, we simply give the text of ! 3557: % the node name again, so it is as if TeX is seeing it for the first ! 3558: % time. ! 3559: \ifdim \wd1>0pt ! 3560: section ``\printednodename'' in \cite{\printedmanual}% ! 3561: \else% ! 3562: \turnoffactive% ! 3563: \refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}% ! 3564: \fi ! 3565: \endgroup} ! 3566: ! 3567: % \dosetq is the interface for calls from other macros ! 3568: ! 3569: % Use \turnoffactive so that punctuation chars such as underscore ! 3570: % work in node names. ! 3571: \def\dosetq #1#2{{\let\folio=0 \turnoffactive% ! 3572: \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% ! 3573: \next}} ! 3574: ! 3575: % \internalsetq {foo}{page} expands into ! 3576: % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} ! 3577: % When the aux file is read, ' is the escape character ! 3578: ! 3579: \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} ! 3580: ! 3581: % Things to be expanded by \internalsetq ! 3582: ! 3583: \def\Ypagenumber{\folio} ! 3584: ! 3585: \def\Ytitle{\thissection} ! 3586: ! 3587: \def\Ynothing{} ! 3588: ! 3589: \def\Ysectionnumberandtype{% ! 3590: \ifnum\secno=0 Chapter\xreftie\the\chapno % ! 3591: \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno % ! 3592: \else \ifnum \subsubsecno=0 % ! 3593: Section\xreftie\the\chapno.\the\secno.\the\subsecno % ! 3594: \else % ! 3595: Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % ! 3596: \fi \fi \fi } ! 3597: ! 3598: \def\Yappendixletterandtype{% ! 3599: \ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}% ! 3600: \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno % ! 3601: \else \ifnum \subsubsecno=0 % ! 3602: Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno % ! 3603: \else % ! 3604: Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % ! 3605: \fi \fi \fi } ! 3606: ! 3607: \gdef\xreftie{'tie} ! 3608: ! 3609: % Use TeX 3.0's \inputlineno to get the line number, for better error ! 3610: % messages, but if we're using an old version of TeX, don't do anything. ! 3611: % ! 3612: \ifx\inputlineno\thisisundefined ! 3613: \let\linenumber = \empty % Non-3.0. ! 3614: \else ! 3615: \def\linenumber{\the\inputlineno:\space} ! 3616: \fi ! 3617: ! 3618: % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. ! 3619: % If its value is nonempty, SUFFIX is output afterward. ! 3620: ! 3621: \def\refx#1#2{% ! 3622: \expandafter\ifx\csname X#1\endcsname\relax ! 3623: % If not defined, say something at least. ! 3624: $\langle$un\-de\-fined$\rangle$% ! 3625: \ifhavexrefs ! 3626: \message{\linenumber Undefined cross reference `#1'.}% ! 3627: \else ! 3628: \ifwarnedxrefs\else ! 3629: \global\warnedxrefstrue ! 3630: \message{Cross reference values unknown; you must run TeX again.}% ! 3631: \fi ! 3632: \fi ! 3633: \else ! 3634: % It's defined, so just use it. ! 3635: \csname X#1\endcsname ! 3636: \fi ! 3637: #2% Output the suffix in any case. ! 3638: } ! 3639: ! 3640: % Read the last existing aux file, if any. No error if none exists. ! 3641: ! 3642: % This is the macro invoked by entries in the aux file. ! 3643: \def\xrdef #1#2{ ! 3644: {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} ! 3645: ! 3646: \def\readauxfile{% ! 3647: \begingroup ! 3648: \catcode `\^^@=\other ! 3649: \catcode `\&=\other ! 3650: \catcode `\=\other ! 3651: \catcode `\^^C=\other ! 3652: \catcode `\^^D=\other ! 3653: \catcode `\^^E=\other ! 3654: \catcode `\^^F=\other ! 3655: \catcode `\^^G=\other ! 3656: \catcode `\^^H=\other ! 3657: \catcode `\=\other ! 3658: \catcode `\^^L=\other ! 3659: \catcode `\=\other ! 3660: \catcode `\=\other ! 3661: \catcode `\=\other ! 3662: \catcode `\=\other ! 3663: \catcode `\=\other ! 3664: \catcode `\=\other ! 3665: \catcode `\=\other ! 3666: \catcode `\=\other ! 3667: \catcode `\=\other ! 3668: \catcode `\=\other ! 3669: \catcode `\=\other ! 3670: \catcode `\=\other ! 3671: \catcode 26=\other ! 3672: \catcode `\^^[=\other ! 3673: \catcode `\^^\=\other ! 3674: \catcode `\^^]=\other ! 3675: \catcode `\^^^=\other ! 3676: \catcode `\^^_=\other ! 3677: \catcode `\@=\other ! 3678: \catcode `\^=\other ! 3679: \catcode `\~=\other ! 3680: \catcode `\[=\other ! 3681: \catcode `\]=\other ! 3682: \catcode`\"=\other ! 3683: \catcode`\_=\other ! 3684: \catcode`\|=\other ! 3685: \catcode`\<=\other ! 3686: \catcode`\>=\other ! 3687: \catcode `\$=\other ! 3688: \catcode `\#=\other ! 3689: \catcode `\&=\other ! 3690: % `\+ does not work, so use 43. ! 3691: \catcode 43=\other ! 3692: % the aux file uses ' as the escape. ! 3693: % Turn off \ as an escape so we do not lose on ! 3694: % entries which were dumped with control sequences in their names. ! 3695: % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ ! 3696: % Reference to such entries still does not work the way one would wish, ! 3697: % but at least they do not bomb out when the aux file is read in. ! 3698: \catcode `\{=1 \catcode `\}=2 ! 3699: \catcode `\%=\other ! 3700: \catcode `\'=0 ! 3701: \catcode `\\=\other ! 3702: \openin 1 \jobname.aux ! 3703: \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue ! 3704: \global\warnedobstrue ! 3705: \fi ! 3706: % Open the new aux file. Tex will close it automatically at exit. ! 3707: \openout \auxfile=\jobname.aux ! 3708: \endgroup} ! 3709: ! 3710: ! 3711: % Footnotes. ! 3712: ! 3713: \newcount \footnoteno ! 3714: ! 3715: % The trailing space in the following definition for supereject is ! 3716: % vital for proper filling; pages come out unaligned when you do a ! 3717: % pagealignmacro call if that space before the closing brace is ! 3718: % removed. ! 3719: \def\supereject{\par\penalty -20000\footnoteno =0 } ! 3720: ! 3721: % @footnotestyle is meaningful for info output only.. ! 3722: \let\footnotestyle=\comment ! 3723: ! 3724: \let\ptexfootnote=\footnote ! 3725: ! 3726: {\catcode `\@=11 ! 3727: % ! 3728: % Auto-number footnotes. Otherwise like plain. ! 3729: \gdef\footnote{% ! 3730: \global\advance\footnoteno by \@ne ! 3731: \edef\thisfootno{$^{\the\footnoteno}$}% ! 3732: % ! 3733: % In case the footnote comes at the end of a sentence, preserve the ! 3734: % extra spacing after we do the footnote number. ! 3735: \let\@sf\empty ! 3736: \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi ! 3737: % ! 3738: % Remove inadvertent blank space before typesetting the footnote number. ! 3739: \unskip ! 3740: \thisfootno\@sf ! 3741: \footnotezzz ! 3742: }% ! 3743: ! 3744: % Don't bother with the trickery in plain.tex to not require the ! 3745: % footnote text as a parameter. Our footnotes don't need to be so general. ! 3746: % ! 3747: \long\gdef\footnotezzz#1{\insert\footins{% ! 3748: % We want to typeset this text as a normal paragraph, even if the ! 3749: % footnote reference occurs in (for example) a display environment. ! 3750: % So reset some parameters. ! 3751: \interlinepenalty\interfootnotelinepenalty ! 3752: \splittopskip\ht\strutbox % top baseline for broken footnotes ! 3753: \splitmaxdepth\dp\strutbox ! 3754: \floatingpenalty\@MM ! 3755: \leftskip\z@skip ! 3756: \rightskip\z@skip ! 3757: \spaceskip\z@skip ! 3758: \xspaceskip\z@skip ! 3759: \parindent\defaultparindent ! 3760: % ! 3761: % Hang the footnote text off the number. ! 3762: \hang ! 3763: \textindent{\thisfootno}% ! 3764: % ! 3765: % Don't crash into the line above the footnote text. Since this ! 3766: % expands into a box, it must come within the paragraph, lest it ! 3767: % provide a place where TeX can split the footnote. ! 3768: \footstrut ! 3769: #1\strut}% ! 3770: } ! 3771: ! 3772: }%end \catcode `\@=11 ! 3773: ! 3774: % Set the baselineskip to #1, and the lineskip and strut size ! 3775: % correspondingly. There is no deep meaning behind these magic numbers ! 3776: % used as factors; they just match (closely enough) what Knuth defined. ! 3777: % ! 3778: \def\lineskipfactor{.08333} ! 3779: \def\strutheightpercent{.70833} ! 3780: \def\strutdepthpercent {.29167} ! 3781: % ! 3782: \def\setleading#1{% ! 3783: \normalbaselineskip = #1\relax ! 3784: \normallineskip = \lineskipfactor\normalbaselineskip ! 3785: \normalbaselines ! 3786: \setbox\strutbox =\hbox{% ! 3787: \vrule width0pt height\strutheightpercent\baselineskip ! 3788: depth \strutdepthpercent \baselineskip ! 3789: }% ! 3790: } ! 3791: ! 3792: % @| inserts a changebar to the left of the current line. It should ! 3793: % surround any changed text. This approach does *not* work if the ! 3794: % change spans more than two lines of output. To handle that, we would ! 3795: % have adopt a much more difficult approach (putting marks into the main ! 3796: % vertical list for the beginning and end of each change). ! 3797: % ! 3798: \def\|{% ! 3799: % \vadjust can only be used in horizontal mode. ! 3800: \leavevmode ! 3801: % ! 3802: % Append this vertical mode material after the current line in the output. ! 3803: \vadjust{% ! 3804: % We want to insert a rule with the height and depth of the current ! 3805: % leading; that is exactly what \strutbox is supposed to record. ! 3806: \vskip-\baselineskip ! 3807: % ! 3808: % \vadjust-items are inserted at the left edge of the type. So ! 3809: % the \llap here moves out into the left-hand margin. ! 3810: \llap{% ! 3811: % ! 3812: % For a thicker or thinner bar, change the `1pt'. ! 3813: \vrule height\baselineskip width1pt ! 3814: % ! 3815: % This is the space between the bar and the text. ! 3816: \hskip 12pt ! 3817: }% ! 3818: }% ! 3819: } ! 3820: ! 3821: % For a final copy, take out the rectangles ! 3822: % that mark overfull boxes (in case you have decided ! 3823: % that the text looks ok even though it passes the margin). ! 3824: % ! 3825: \def\finalout{\overfullrule=0pt} ! 3826: ! 3827: ! 3828: % End of control word definitions. ! 3829: ! 3830: \message{and turning on texinfo input format.} ! 3831: ! 3832: \def\openindices{% ! 3833: \newindex{cp}% ! 3834: \newcodeindex{fn}% ! 3835: \newcodeindex{vr}% ! 3836: \newcodeindex{tp}% ! 3837: \newcodeindex{ky}% ! 3838: \newcodeindex{pg}% ! 3839: } ! 3840: ! 3841: % Set some numeric style parameters, for 8.5 x 11 format. ! 3842: ! 3843: %\hsize = 6.5in ! 3844: \newdimen\defaultparindent \defaultparindent = 15pt ! 3845: \parindent = \defaultparindent ! 3846: \parskip 18pt plus 1pt ! 3847: \setleading{15pt} ! 3848: \advance\topskip by 1.2cm ! 3849: ! 3850: % Prevent underfull vbox error messages. ! 3851: \vbadness=10000 ! 3852: ! 3853: % Following George Bush, just get rid of widows and orphans. ! 3854: \widowpenalty=10000 ! 3855: \clubpenalty=10000 ! 3856: ! 3857: % Use TeX 3.0's \emergencystretch to help line breaking, but if we're ! 3858: % using an old version of TeX, don't do anything. We want the amount of ! 3859: % stretch added to depend on the line length, hence the dependence on ! 3860: % \hsize. This makes it come to about 9pt for the 8.5x11 format. ! 3861: % ! 3862: \ifx\emergencystretch\thisisundefined ! 3863: % Allow us to assign to \emergencystretch anyway. ! 3864: \def\emergencystretch{\dimen0}% ! 3865: \else ! 3866: \emergencystretch = \hsize ! 3867: \divide\emergencystretch by 45 ! 3868: \fi ! 3869: ! 3870: % Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) ! 3871: \def\smallbook{ ! 3872: ! 3873: % These values for secheadingskip and subsecheadingskip are ! 3874: % experiments. RJC 7 Aug 1992 ! 3875: \global\secheadingskip = 17pt plus 6pt minus 3pt ! 3876: \global\subsecheadingskip = 14pt plus 6pt minus 3pt ! 3877: ! 3878: \global\lispnarrowing = 0.3in ! 3879: \setleading{12pt} ! 3880: \advance\topskip by -1cm ! 3881: \global\parskip 3pt plus 1pt ! 3882: \global\hsize = 5in ! 3883: \global\vsize=7.5in ! 3884: \global\tolerance=700 ! 3885: \global\hfuzz=1pt ! 3886: \global\contentsrightmargin=0pt ! 3887: ! 3888: \global\pagewidth=\hsize ! 3889: \global\pageheight=\vsize ! 3890: ! 3891: \global\let\smalllisp=\smalllispx ! 3892: \global\let\smallexample=\smalllispx ! 3893: \global\def\Esmallexample{\Esmalllisp} ! 3894: } ! 3895: ! 3896: % Use @afourpaper to print on European A4 paper. ! 3897: \def\afourpaper{ ! 3898: \global\tolerance=700 ! 3899: \global\hfuzz=1pt ! 3900: \setleading{12pt} ! 3901: \global\parskip 15pt plus 1pt ! 3902: ! 3903: \global\vsize= 53\baselineskip ! 3904: \advance\vsize by \topskip ! 3905: %\global\hsize= 5.85in % A4 wide 10pt ! 3906: \global\hsize= 6.5in ! 3907: \global\outerhsize=\hsize ! 3908: \global\advance\outerhsize by 0.5in ! 3909: \global\outervsize=\vsize ! 3910: \global\advance\outervsize by 0.6in ! 3911: ! 3912: \global\pagewidth=\hsize ! 3913: \global\pageheight=\vsize ! 3914: } ! 3915: ! 3916: % Define macros to output various characters with catcode for normal text. ! 3917: \catcode`\"=\other ! 3918: \catcode`\~=\other ! 3919: \catcode`\^=\other ! 3920: \catcode`\_=\other ! 3921: \catcode`\|=\other ! 3922: \catcode`\<=\other ! 3923: \catcode`\>=\other ! 3924: \catcode`\+=\other ! 3925: \def\normaldoublequote{"} ! 3926: \def\normaltilde{~} ! 3927: \def\normalcaret{^} ! 3928: \def\normalunderscore{_} ! 3929: \def\normalverticalbar{|} ! 3930: \def\normalless{<} ! 3931: \def\normalgreater{>} ! 3932: \def\normalplus{+} ! 3933: ! 3934: % This macro is used to make a character print one way in ttfont ! 3935: % where it can probably just be output, and another way in other fonts, ! 3936: % where something hairier probably needs to be done. ! 3937: % ! 3938: % #1 is what to print if we are indeed using \tt; #2 is what to print ! 3939: % otherwise. Since all the Computer Modern typewriter fonts have zero ! 3940: % interword stretch (and shrink), and it is reasonable to expect all ! 3941: % typewriter fonts to have this, we can check that font parameter. ! 3942: % ! 3943: \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} ! 3944: ! 3945: % Turn off all special characters except @ ! 3946: % (and those which the user can use as if they were ordinary). ! 3947: % Most of these we simply print from the \tt font, but for some, we can ! 3948: % use math or other variants that look better in normal text. ! 3949: ! 3950: \catcode`\"=\active ! 3951: \def\activedoublequote{{\tt \char '042}} ! 3952: \let"=\activedoublequote ! 3953: \catcode`\~=\active ! 3954: \def~{{\tt \char '176}} ! 3955: \chardef\hat=`\^ ! 3956: \catcode`\^=\active ! 3957: \def^{{\tt \hat}} ! 3958: ! 3959: \catcode`\_=\active ! 3960: \def_{\ifusingtt\normalunderscore\_} ! 3961: % Subroutine for the previous macro. ! 3962: \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} ! 3963: ! 3964: % \lvvmode is equivalent in function to \leavevmode. ! 3965: % Using \leavevmode runs into trouble when written out to ! 3966: % an index file due to the expansion of \leavevmode into ``\unhbox ! 3967: % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our ! 3968: % magic tricks with @. ! 3969: \def\lvvmode{\vbox to 0pt{}} ! 3970: ! 3971: \catcode`\|=\active ! 3972: \def|{{\tt \char '174}} ! 3973: \chardef \less=`\< ! 3974: \catcode`\<=\active ! 3975: \def<{{\tt \less}} ! 3976: \chardef \gtr=`\> ! 3977: \catcode`\>=\active ! 3978: \def>{{\tt \gtr}} ! 3979: \catcode`\+=\active ! 3980: \def+{{\tt \char 43}} ! 3981: %\catcode 27=\active ! 3982: %\def^^[{$\diamondsuit$} ! 3983: ! 3984: % Used sometimes to turn off (effectively) the active characters ! 3985: % even after parsing them. ! 3986: \def\turnoffactive{\let"=\normaldoublequote ! 3987: \let~=\normaltilde ! 3988: \let^=\normalcaret ! 3989: \let_=\normalunderscore ! 3990: \let|=\normalverticalbar ! 3991: \let<=\normalless ! 3992: \let>=\normalgreater ! 3993: \let+=\normalplus} ! 3994: ! 3995: % Set up an active definition for =, but don't enable it most of the time. ! 3996: {\catcode`\==\active ! 3997: \global\def={{\tt \char 61}}} ! 3998: ! 3999: \catcode`\@=0 ! 4000: ! 4001: % \rawbackslashxx output one backslash character in current font ! 4002: \global\chardef\rawbackslashxx=`\\ ! 4003: %{\catcode`\\=\other ! 4004: %@gdef@rawbackslashxx{\}} ! 4005: ! 4006: % \rawbackslash redefines \ as input to do \rawbackslashxx. ! 4007: {\catcode`\\=\active ! 4008: @gdef@rawbackslash{@let\=@rawbackslashxx }} ! 4009: ! 4010: % \normalbackslash outputs one backslash in fixed width font. ! 4011: \def\normalbackslash{{\tt\rawbackslashxx}} ! 4012: ! 4013: % Say @foo, not \foo, in error messages. ! 4014: \escapechar=`\@ ! 4015: ! 4016: % \catcode 17=0 % Define control-q ! 4017: \catcode`\\=\active ! 4018: ! 4019: % If a .fmt file is being used, we don't want the `\input texinfo' to show up. ! 4020: % That is what \eatinput is for; after that, the `\' should revert to printing ! 4021: % a backslash. ! 4022: % ! 4023: @gdef@eatinput input texinfo{@fixbackslash} ! 4024: @global@let\ = @eatinput ! 4025: ! 4026: % On the other hand, perhaps the file did not have a `\input texinfo'. Then ! 4027: % the first `\{ in the file would cause an error. This macro tries to fix ! 4028: % that, assuming it is called before the first `\' could plausibly occur. ! 4029: % ! 4030: @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi} ! 4031: ! 4032: %% These look ok in all fonts, so just make them not special. The @rm below ! 4033: %% makes sure that the current font starts out as the newly loaded cmr10 ! 4034: @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other ! 4035: ! 4036: @textfonts ! 4037: @rm ! 4038: ! 4039: @c Local variables: ! 4040: @c page-delimiter: "^\\\\message" ! 4041: @c End:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.