
1: % texinfo.tex -- TeX macros to handle Texinfo files. 2: % 3: % Load plain if necessary, i.e., if running under initex. 4: \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi 5: % 6: \def\texinfoversion{2004-11-25.16} 7: % 8: % Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, 9: % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software 10: % Foundation, Inc. 11: % 12: % This texinfo.tex file is free software; you can redistribute it and/or 13: % modify it under the terms of the GNU General Public License as 14: % published by the Free Software Foundation; either version 2, or (at 15: % your option) any later version. 16: % 17: % This texinfo.tex file is distributed in the hope that it will be 18: % useful, but WITHOUT ANY WARRANTY; without even the implied warranty 19: % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20: % General Public License for more details. 21: % 22: % You should have received a copy of the GNU General Public License 23: % along with this texinfo.tex file; see the file COPYING. If not, write 24: % to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 25: % Boston, MA 02111-1307, USA. 26: % 27: % As a special exception, when this file is read by TeX when processing 28: % a Texinfo source document, you may use the result without 29: % restriction. (This has been our intent since Texinfo was invented.) 30: % 31: % Please try the latest version of texinfo.tex before submitting bug 32: % reports; you can get the latest version from: 33: % http://www.gnu.org/software/texinfo/ (the Texinfo home page), or 34: % ftp://tug.org/tex/texinfo.tex 35: % (and all CTAN mirrors, see http://www.ctan.org). 36: % The texinfo.tex in any given distribution could well be out 37: % of date, so if that's what you're using, please check. 38: % 39: % Send bug reports to bug-texinfo@gnu.org. Please include including a 40: % complete document in each bug report with which we can reproduce the 41: % problem. Patches are, of course, greatly appreciated. 42: % 43: % To process a Texinfo manual with TeX, it's most reliable to use the 44: % texi2dvi shell script that comes with the distribution. For a simple 45: % manual foo.texi, however, you can get away with this: 46: % tex foo.texi 47: % texindex foo.?? 48: % tex foo.texi 49: % tex foo.texi 50: % dvips foo.dvi -o # or whatever; this makes foo.ps. 51: % The extra TeX runs get the cross-reference information correct. 52: % Sometimes one run after texindex suffices, and sometimes you need more 53: % than two; texi2dvi does it as many times as necessary. 54: % 55: % It is possible to adapt texinfo.tex for other languages, to some 56: % extent. You can get the existing language-specific files from the 57: % full Texinfo distribution. 58: % 59: % The GNU Texinfo home page is http://www.gnu.org/software/texinfo. 60: 61: 62: \message{Loading texinfo [version \texinfoversion]:} 63: 64: % If in a .fmt file, print the version number 65: % and turn on active characters that we couldn't do earlier because 66: % they might have appeared in the input file name. 67: \everyjob{\message{[Texinfo version \texinfoversion]}% 68: \catcode`+=\active \catcode`\_=\active} 69: 70: \message{Basics,} 71: \chardef\other=12 72: 73: % We never want plain's \outer definition of \+ in Texinfo. 74: % For @tex, we can use \tabalign. 75: \let\+ = \relax 76: 77: % Save some plain tex macros whose names we will redefine. 78: \let\ptexb=\b 79: \let\ptexbullet=\bullet 80: \let\ptexc=\c 81: \let\ptexcomma=\, 82: \let\ptexdot=\. 83: \let\ptexdots=\dots 84: \let\ptexend=\end 85: \let\ptexequiv=\equiv 86: \let\ptexexclam=\! 87: \let\ptexfootnote=\footnote 88: \let\ptexgtr=> 89: \let\ptexhat=^ 90: \let\ptexi=\i 91: \let\ptexindent=\indent 92: \let\ptexinsert=\insert 93: \let\ptexlbrace=\{ 94: \let\ptexless=< 95: \let\ptexnewwrite\newwrite 96: \let\ptexnoindent=\noindent 97: \let\ptexplus=+ 98: \let\ptexrbrace=\} 99: \let\ptexslash=\/ 100: \let\ptexstar=\* 101: \let\ptext=\t 102: 103: % If this character appears in an error message or help string, it 104: % starts a new line in the output. 105: \newlinechar = `^^J 106: 107: % Use TeX 3.0's \inputlineno to get the line number, for better error 108: % messages, but if we're using an old version of TeX, don't do anything. 109: % 110: \ifx\inputlineno\thisisundefined 111: \let\linenumber = \empty % Pre-3.0. 112: \else 113: \def\linenumber{l.\the\inputlineno:\space} 114: \fi 115: 116: % Set up fixed words for English if not already set. 117: \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi 118: \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi 119: \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi 120: \ifx\putwordin\undefined \gdef\putwordin{in}\fi 121: \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi 122: \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi 123: \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi 124: \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi 125: \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi 126: \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi 127: \ifx\putwordof\undefined \gdef\putwordof{of}\fi 128: \ifx\putwordon\undefined \gdef\putwordon{on}\fi 129: \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi 130: \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi 131: \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi 132: \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi 133: \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi 134: \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi 135: \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi 136: % 137: \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi 138: \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi 139: \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi 140: \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi 141: \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi 142: \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi 143: \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi 144: \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi 145: \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi 146: \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi 147: \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi 148: \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi 149: % 150: \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi 151: \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi 152: \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi 153: \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi 154: \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi 155: 156: % In some macros, we cannot use the `\? notation---the left quote is 157: % in some cases the escape char. 158: \chardef\colonChar = `\: 159: \chardef\commaChar = `\, 160: \chardef\dotChar = `\. 161: \chardef\exclamChar= `\! 162: \chardef\questChar = `\? 163: \chardef\semiChar = `\; 164: \chardef\underChar = `\_ 165: 166: \chardef\spaceChar = `\ % 167: \chardef\spacecat = 10 168: \def\spaceisspace{\catcode\spaceChar=\spacecat} 169: 170: % Ignore a token. 171: % 172: \def\gobble#1{} 173: 174: % The following is used inside several \edef's. 175: \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} 176: 177: % Hyphenation fixes. 178: \hyphenation{ 179: Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script 180: ap-pen-dix bit-map bit-maps 181: data-base data-bases eshell fall-ing half-way long-est man-u-script 182: man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm 183: par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces 184: spell-ing spell-ings 185: stand-alone strong-est time-stamp time-stamps which-ever white-space 186: wide-spread wrap-around 187: } 188: 189: % Margin to add to right of even pages, to left of odd pages. 190: \newdimen\bindingoffset 191: \newdimen\normaloffset 192: \newdimen\pagewidth \newdimen\pageheight 193: 194: % For a final copy, take out the rectangles 195: % that mark overfull boxes (in case you have decided 196: % that the text looks ok even though it passes the margin). 197: % 198: \def\finalout{\overfullrule=0pt} 199: 200: % @| inserts a changebar to the left of the current line. It should 201: % surround any changed text. This approach does *not* work if the 202: % change spans more than two lines of output. To handle that, we would 203: % have adopt a much more difficult approach (putting marks into the main 204: % vertical list for the beginning and end of each change). 205: % 206: \def\|{% 207: % \vadjust can only be used in horizontal mode. 208: \leavevmode 209: % 210: % Append this vertical mode material after the current line in the output. 211: \vadjust{% 212: % We want to insert a rule with the height and depth of the current 213: % leading; that is exactly what \strutbox is supposed to record. 214: \vskip-\baselineskip 215: % 216: % \vadjust-items are inserted at the left edge of the type. So 217: % the \llap here moves out into the left-hand margin. 218: \llap{% 219: % 220: % For a thicker or thinner bar, change the `1pt'. 221: \vrule height\baselineskip width1pt 222: % 223: % This is the space between the bar and the text. 224: \hskip 12pt 225: }% 226: }% 227: } 228: 229: % Sometimes it is convenient to have everything in the transcript file 230: % and nothing on the terminal. We don't just call \tracingall here, 231: % since that produces some useless output on the terminal. We also make 232: % some effort to order the tracing commands to reduce output in the log 233: % file; cf. trace.sty in LaTeX. 234: % 235: \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% 236: \def\loggingall{% 237: \tracingstats2 238: \tracingpages1 239: \tracinglostchars2 % 2 gives us more in etex 240: \tracingparagraphs1 241: \tracingoutput1 242: \tracingmacros2 243: \tracingrestores1 244: \showboxbreadth\maxdimen \showboxdepth\maxdimen 245: \ifx\eTeXversion\undefined\else % etex gives us more logging 246: \tracingscantokens1 247: \tracingifs1 248: \tracinggroups1 249: \tracingnesting2 250: \tracingassigns1 251: \fi 252: \tracingcommands3 % 3 gives us more in etex 253: \errorcontextlines16 254: }% 255: 256: % add check for \lastpenalty to plain's definitions. If the last thing 257: % we did was a \nobreak, we don't want to insert more space. 258: % 259: \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount 260: \removelastskip\penalty-50\smallskip\fi\fi} 261: \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount 262: \removelastskip\penalty-100\medskip\fi\fi} 263: \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount 264: \removelastskip\penalty-200\bigskip\fi\fi} 265: 266: % For @cropmarks command. 267: % Do @cropmarks to get crop marks. 268: % 269: \newif\ifcropmarks 270: \let\cropmarks = \cropmarkstrue 271: % 272: % Dimensions to add cropmarks at corners. 273: % Added by P. A. MacKay, 12 Nov. 1986 274: % 275: \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines 276: \newdimen\cornerlong \cornerlong=1pc 277: \newdimen\cornerthick \cornerthick=.3pt 278: \newdimen\topandbottommargin \topandbottommargin=.75in 279: 280: % Main output routine. 281: \chardef\PAGE = 255 282: \output = {\onepageout{\pagecontents\PAGE}} 283: 284: \newbox\headlinebox 285: \newbox\footlinebox 286: 287: % \onepageout takes a vbox as an argument. Note that \pagecontents 288: % does insertions, but you have to call it yourself. 289: \def\onepageout#1{% 290: \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi 291: % 292: \ifodd\pageno \advance\hoffset by \bindingoffset 293: \else \advance\hoffset by -\bindingoffset\fi 294: % 295: % Do this outside of the \shipout so @code etc. will be expanded in 296: % the headline as they should be, not taken literally (outputting ''code). 297: \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% 298: \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% 299: % 300: {% 301: % Have to do this stuff outside the \shipout because we want it to 302: % take effect in \write's, yet the group defined by the \vbox ends 303: % before the \shipout runs. 304: % 305: \escapechar = `\\ % use backslash in output files. 306: \indexdummies % don't expand commands in the output. 307: \normalturnoffactive % \ in index entries must not stay \, e.g., if 308: % the page break happens to be in the middle of an example. 309: \shipout\vbox{% 310: % Do this early so pdf references go to the beginning of the page. 311: \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi 312: % 313: \ifcropmarks \vbox to \outervsize\bgroup 314: \hsize = \outerhsize 315: \vskip-\topandbottommargin 316: \vtop to0pt{% 317: \line{\ewtop\hfil\ewtop}% 318: \nointerlineskip 319: \line{% 320: \vbox{\moveleft\cornerthick\nstop}% 321: \hfill 322: \vbox{\moveright\cornerthick\nstop}% 323: }% 324: \vss}% 325: \vskip\topandbottommargin 326: \line\bgroup 327: \hfil % center the page within the outer (page) hsize. 328: \ifodd\pageno\hskip\bindingoffset\fi 329: \vbox\bgroup 330: \fi 331: % 332: \unvbox\headlinebox 333: \pagebody{#1}% 334: \ifdim\ht\footlinebox > 0pt 335: % Only leave this space if the footline is nonempty. 336: % (We lessened \vsize for it in \oddfootingxxx.) 337: % The \baselineskip=24pt in plain's \makefootline has no effect. 338: \vskip 2\baselineskip 339: \unvbox\footlinebox 340: \fi 341: % 342: \ifcropmarks 343: \egroup % end of \vbox\bgroup 344: \hfil\egroup % end of (centering) \line\bgroup 345: \vskip\topandbottommargin plus1fill minus1fill 346: \boxmaxdepth = \cornerthick 347: \vbox to0pt{\vss 348: \line{% 349: \vbox{\moveleft\cornerthick\nsbot}% 350: \hfill 351: \vbox{\moveright\cornerthick\nsbot}% 352: }% 353: \nointerlineskip 354: \line{\ewbot\hfil\ewbot}% 355: }% 356: \egroup % \vbox from first cropmarks clause 357: \fi 358: }% end of \shipout\vbox 359: }% end of group with \normalturnoffactive 360: \advancepageno 361: \ifnum\outputpenalty>-20000 \else\dosupereject\fi 362: } 363: 364: \newinsert\margin \dimen\margin=\maxdimen 365: 366: \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} 367: {\catcode`\@ =11 368: \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi 369: % marginal hacks, juha@viisa.uucp (Juha Takala) 370: \ifvoid\margin\else % marginal info is present 371: \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi 372: \dimen@=\dp#1 \unvbox#1 373: \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi 374: \ifr@ggedbottom \kern-\dimen@ \vfil \fi} 375: } 376: 377: % Here are the rules for the cropmarks. Note that they are 378: % offset so that the space between them is truly \outerhsize or \outervsize 379: % (P. A. MacKay, 12 November, 1986) 380: % 381: \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} 382: \def\nstop{\vbox 383: {\hrule height\cornerthick depth\cornerlong width\cornerthick}} 384: \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} 385: \def\nsbot{\vbox 386: {\hrule height\cornerlong depth\cornerthick width\cornerthick}} 387: 388: % Parse an argument, then pass it to #1. The argument is the rest of 389: % the input line (except we remove a trailing comment). #1 should be a 390: % macro which expects an ordinary undelimited TeX argument. 391: % 392: \def\parsearg{\parseargusing{}} 393: \def\parseargusing#1#2{% 394: \def\next{#2}% 395: \begingroup 396: \obeylines 397: \spaceisspace 398: #1% 399: \parseargline\empty% Insert the \empty token, see \finishparsearg below. 400: } 401: 402: {\obeylines % 403: \gdef\parseargline#1^^M{% 404: \endgroup % End of the group started in \parsearg. 405: \argremovecomment #1\comment\ArgTerm% 406: }% 407: } 408: 409: % First remove any @comment, then any @c comment. 410: \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} 411: \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} 412: 413: % Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space. 414: % 415: % \argremovec might leave us with trailing space, e.g., 416: % @end itemize @c foo 417: % This space token undergoes the same procedure and is eventually removed 418: % by \finishparsearg. 419: % 420: \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} 421: \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} 422: \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% 423: \def\temp{#3}% 424: \ifx\temp\empty 425: % We cannot use \next here, as it holds the macro to run; 426: % thus we reuse \temp. 427: \let\temp\finishparsearg 428: \else 429: \let\temp\argcheckspaces 430: \fi 431: % Put the space token in: 432: \temp#1 #3\ArgTerm 433: } 434: 435: % If a _delimited_ argument is enclosed in braces, they get stripped; so 436: % to get _exactly_ the rest of the line, we had to prevent such situation. 437: % We prepended an \empty token at the very beginning and we expand it now, 438: % just before passing the control to \next. 439: % (Similarily, we have to think about #3 of \argcheckspacesY above: it is 440: % either the null string, or it ends with \^^M---thus there is no danger 441: % that a pair of braces would be stripped. 442: % 443: % But first, we have to remove the trailing space token. 444: % 445: \def\finishparsearg#1 \ArgTerm{\expandafter\next\expandafter{#1}} 446: 447: % \parseargdef\foo{...} 448: % is roughly equivalent to 449: % \def\foo{\parsearg\Xfoo} 450: % \def\Xfoo#1{...} 451: % 452: % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my 453: % favourite TeX trick. --kasal, 16nov03 454: 455: \def\parseargdef#1{% 456: \expandafter \doparseargdef \csname\string#1\endcsname #1% 457: } 458: \def\doparseargdef#1#2{% 459: \def#2{\parsearg#1}% 460: \def#1##1% 461: } 462: 463: % Several utility definitions with active space: 464: { 465: \obeyspaces 466: \gdef\obeyedspace{ } 467: 468: % Make each space character in the input produce a normal interword 469: % space in the output. Don't allow a line break at this space, as this 470: % is used only in environments like @example, where each line of input 471: % should produce a line of output anyway. 472: % 473: \gdef\sepspaces{\obeyspaces\let =\tie} 474: 475: % If an index command is used in an @example environment, any spaces 476: % therein should become regular spaces in the raw index file, not the 477: % expansion of \tie (\leavevmode \penalty \@M \ ). 478: \gdef\unsepspaces{\let =\space} 479: } 480: 481: 482: \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} 483: 484: % Define the framework for environments in texinfo.tex. It's used like this: 485: % 486: % \envdef\foo{...} 487: % \def\Efoo{...} 488: % 489: % It's the responsibility of \envdef to insert \begingroup before the 490: % actual body; @end closes the group after calling \Efoo. \envdef also 491: % defines \thisenv, so the current environment is known; @end checks 492: % whether the environment name matches. The \checkenv macro can also be 493: % used to check whether the current environment is the one expected. 494: % 495: % Non-false conditionals (@iftex, @ifset) don't fit into this, so they 496: % are not treated as enviroments; they don't open a group. (The 497: % implementation of @end takes care not to call \endgroup in this 498: % special case.) 499: 500: 501: % At runtime, environments start with this: 502: \def\startenvironment#1{\begingroup\def\thisenv{#1}} 503: % initialize 504: \let\thisenv\empty 505: 506: % ... but they get defined via ``\envdef\foo{...}'': 507: \long\def\envdef#1#2{\def#1{\startenvironment#1#2}} 508: \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} 509: 510: % Check whether we're in the right environment: 511: \def\checkenv#1{% 512: \def\temp{#1}% 513: \ifx\thisenv\temp 514: \else 515: \badenverr 516: \fi 517: } 518: 519: % Evironment mismatch, #1 expected: 520: \def\badenverr{% 521: \errhelp = \EMsimple 522: \errmessage{This command can appear only \inenvironment\temp, 523: not \inenvironment\thisenv}% 524: } 525: \def\inenvironment#1{% 526: \ifx#1\empty 527: out of any environment% 528: \else 529: in environment \expandafter\string#1% 530: \fi 531: } 532: 533: % @end foo executes the definition of \Efoo. 534: % But first, it executes a specialized version of \checkenv 535: % 536: \parseargdef\end{% 537: \if 1\csname iscond.#1\endcsname 538: \else 539: % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03 540: \expandafter\checkenv\csname#1\endcsname 541: \csname E#1\endcsname 542: \endgroup 543: \fi 544: } 545: 546: \newhelp\EMsimple{Press RETURN to continue.} 547: 548: 549: %% Simple single-character @ commands 550: 551: % @@ prints an @ 552: % Kludge this until the fonts are right (grr). 553: \def\@{{\tt\char64}} 554: 555: % This is turned off because it was never documented 556: % and you can use @w{...} around a quote to suppress ligatures. 557: %% Define @` and @' to be the same as ` and ' 558: %% but suppressing ligatures. 559: %\def\`{{`}} 560: %\def\'{{'}} 561: 562: % Used to generate quoted braces. 563: \def\mylbrace {{\tt\char123}} 564: \def\myrbrace {{\tt\char125}} 565: \let\{=\mylbrace 566: \let\}=\myrbrace 567: \begingroup 568: % Definitions to produce \{ and \} commands for indices, 569: % and @{ and @} for the aux file. 570: \catcode`\{ = \other \catcode`\} = \other 571: \catcode`\[ = 1 \catcode`\] = 2 572: \catcode`\! = 0 \catcode`\\ = \other 573: !gdef!lbracecmd[\{]% 574: !gdef!rbracecmd[\}]% 575: !gdef!lbraceatcmd[@{]% 576: !gdef!rbraceatcmd[@}]% 577: !endgroup 578: 579: % @comma{} to avoid , parsing problems. 580: \let\comma = , 581: 582: % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent 583: % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. 584: \let\, = \c 585: \let\dotaccent = \. 586: \def\ringaccent#1{{\accent23 #1}} 587: \let\tieaccent = \t 588: \let\ubaraccent = \b 589: \let\udotaccent = \d 590: 591: % Other special characters: @questiondown @exclamdown @ordf @ordm 592: % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. 593: \def\questiondown{?`} 594: \def\exclamdown{!`} 595: \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} 596: \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} 597: 598: % Dotless i and dotless j, used for accents. 599: \def\imacro{i} 600: \def\jmacro{j} 601: \def\dotless#1{% 602: \def\temp{#1}% 603: \ifx\temp\imacro \ptexi 604: \else\ifx\temp\jmacro \j 605: \else \errmessage{@dotless can be used only with i or j}% 606: \fi\fi 607: } 608: 609: % The \TeX{} logo, as in plain, but resetting the spacing so that a 610: % period following counts as ending a sentence. (Idea found in latex.) 611: % 612: \edef\TeX{\TeX \spacefactor=1000 } 613: 614: % @LaTeX{} logo. Not quite the same results as the definition in 615: % latex.ltx, since we use a different font for the raised A; it's most 616: % convenient for us to use an explicitly smaller font, rather than using 617: % the \scriptstyle font (since we don't reset \scriptstyle and 618: % \scriptscriptstyle). 619: % 620: \def\LaTeX{% 621: L\kern-.36em 622: {\setbox0=\hbox{T}% 623: \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}% 624: \kern-.15em 625: \TeX 626: } 627: 628: % Be sure we're in horizontal mode when doing a tie, since we make space 629: % equivalent to this in @example-like environments. Otherwise, a space 630: % at the beginning of a line will start with \penalty -- and 631: % since \penalty is valid in vertical mode, we'd end up putting the 632: % penalty on the vertical list instead of in the new paragraph. 633: {\catcode`@ = 11 634: % Avoid using \@M directly, because that causes trouble 635: % if the definition is written into an index file. 636: \global\let\tiepenalty = \@M 637: \gdef\tie{\leavevmode\penalty\tiepenalty\ } 638: } 639: 640: % @: forces normal size whitespace following. 641: \def\:{\spacefactor=1000 } 642: 643: % @* forces a line break. 644: \def\*{\hfil\break\hbox{}\ignorespaces} 645: 646: % @/ allows a line break. 647: \let\/=\allowbreak 648: 649: % @. is an end-of-sentence period. 650: \def\.{.\spacefactor=3000 } 651: 652: % @! is an end-of-sentence bang. 653: \def\!{!\spacefactor=3000 } 654: 655: % @? is an end-of-sentence query. 656: \def\?{?\spacefactor=3000 } 657: 658: % @w prevents a word break. Without the \leavevmode, @w at the 659: % beginning of a paragraph, when TeX is still in vertical mode, would 660: % produce a whole line of output instead of starting the paragraph. 661: \def\w#1{\leavevmode\hbox{#1}} 662: 663: % @group ... @end group forces ... to be all on one page, by enclosing 664: % it in a TeX vbox. We use \vtop instead of \vbox to construct the box 665: % to keep its height that of a normal line. According to the rules for 666: % \topskip (p.114 of the TeXbook), the glue inserted is 667: % max (\topskip - \ht (first item), 0). If that height is large, 668: % therefore, no glue is inserted, and the space between the headline and 669: % the text is small, which looks bad. 670: % 671: % Another complication is that the group might be very large. This can 672: % cause the glue on the previous page to be unduly stretched, because it 673: % does not have much material. In this case, it's better to add an 674: % explicit \vfill so that the extra space is at the bottom. The 675: % threshold for doing this is if the group is more than \vfilllimit 676: % percent of a page (\vfilllimit can be changed inside of @tex). 677: % 678: \newbox\groupbox 679: \def\vfilllimit{0.7} 680: % 681: \envdef\group{% 682: \ifnum\catcode`\^^M=\active \else 683: \errhelp = \groupinvalidhelp 684: \errmessage{@group invalid in context where filling is enabled}% 685: \fi 686: \startsavinginserts 687: % 688: \setbox\groupbox = \vtop\bgroup 689: % Do @comment since we are called inside an environment such as 690: % @example, where each end-of-line in the input causes an 691: % end-of-line in the output. We don't want the end-of-line after 692: % the `@group' to put extra space in the output. Since @group 693: % should appear on a line by itself (according to the Texinfo 694: % manual), we don't worry about eating any user text. 695: \comment 696: } 697: % 698: % The \vtop produces a box with normal height and large depth; thus, TeX puts 699: % \baselineskip glue before it, and (when the next line of text is done) 700: % \lineskip glue after it. Thus, space below is not quite equal to space 701: % above. But it's pretty close. 702: \def\Egroup{% 703: % To get correct interline space between the last line of the group 704: % and the first line afterwards, we have to propagate \prevdepth. 705: \endgraf % Not \par, as it may have been set to \lisppar. 706: \global\dimen1 = \prevdepth 707: \egroup % End the \vtop. 708: % \dimen0 is the vertical size of the group's box. 709: \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox 710: % \dimen2 is how much space is left on the page (more or less). 711: \dimen2 = \pageheight \advance\dimen2 by -\pagetotal 712: % if the group doesn't fit on the current page, and it's a big big 713: % group, force a page break. 714: \ifdim \dimen0 > \dimen2 715: \ifdim \pagetotal < \vfilllimit\pageheight 716: \page 717: \fi 718: \fi 719: \box\groupbox 720: \prevdepth = \dimen1 721: \checkinserts 722: } 723: % 724: % TeX puts in an \escapechar (i.e., `@') at the beginning of the help 725: % message, so this ends up printing `@group can only ...'. 726: % 727: \newhelp\groupinvalidhelp{% 728: group can only be used in environments such as @example,^^J% 729: where each line of input produces a line of output.} 730: 731: % @need space-in-mils 732: % forces a page break if there is not space-in-mils remaining. 733: 734: \newdimen\mil \mil=0.001in 735: 736: % Old definition--didn't work. 737: %\parseargdef\need{\par % 738: %% This method tries to make TeX break the page naturally 739: %% if the depth of the box does not fit. 740: %{\baselineskip=0pt% 741: %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak 742: %\prevdepth=-1000pt 743: %}} 744: 745: \parseargdef\need{% 746: % Ensure vertical mode, so we don't make a big box in the middle of a 747: % paragraph. 748: \par 749: % 750: % If the @need value is less than one line space, it's useless. 751: \dimen0 = #1\mil 752: \dimen2 = \ht\strutbox 753: \advance\dimen2 by \dp\strutbox 754: \ifdim\dimen0 > \dimen2 755: % 756: % Do a \strut just to make the height of this box be normal, so the 757: % normal leading is inserted relative to the preceding line. 758: % And a page break here is fine. 759: \vtop to #1\mil{\strut\vfil}% 760: % 761: % TeX does not even consider page breaks if a penalty added to the 762: % main vertical list is 10000 or more. But in order to see if the 763: % empty box we just added fits on the page, we must make it consider 764: % page breaks. On the other hand, we don't want to actually break the 765: % page after the empty box. So we use a penalty of 9999. 766: % 767: % There is an extremely small chance that TeX will actually break the 768: % page at this \penalty, if there are no other feasible breakpoints in 769: % sight. (If the user is using lots of big @group commands, which 770: % almost-but-not-quite fill up a page, TeX will have a hard time doing 771: % good page breaking, for example.) However, I could not construct an 772: % example where a page broke at this \penalty; if it happens in a real