[BACK]Return to texinfo.tex CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp

Annotation of OpenXM_contrib/gmp/texinfo.tex, Revision 1.1.1.2

1.1.1.2 ! maekawa     1: % texinfo.tex -- TeX macros to handle Texinfo files.
        !             2: %
        !             3: % Load plain if necessary, i.e., if running under initex.
1.1       maekawa     4: \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
1.1.1.2 ! maekawa     5: %
        !             6: \def\texinfoversion{1999-03-31.13}%
        !             7: %
        !             8: % Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
        !             9: % Free Software Foundation, Inc.
        !            10: %
        !            11: % This texinfo.tex file is free software; you can redistribute it and/or
        !            12: % modify it under the terms of the GNU General Public License as
        !            13: % published by the Free Software Foundation; either version 2, or (at
        !            14: % your option) any later version.
        !            15: %
        !            16: % This texinfo.tex file is distributed in the hope that it will be
        !            17: % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
        !            18: % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        !            19: % General Public License for more details.
        !            20: %
        !            21: % You should have received a copy of the GNU General Public License
        !            22: % along with this texinfo.tex file; see the file COPYING.  If not, write
        !            23: % to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
        !            24: % Boston, MA 02111-1307, USA.
        !            25: %
        !            26: % In other words, you are welcome to use, share and improve this program.
        !            27: % You are forbidden to forbid anyone else to use, share and improve
        !            28: % what you give them.   Help stamp out software-hoarding!
        !            29: %
        !            30: % Please try the latest version of texinfo.tex before submitting bug
        !            31: % reports; you can get the latest version from:
        !            32: %   ftp://ftp.gnu.org/pub/gnu/texinfo.tex
        !            33: %   (and all GNU mirrors, see http://www.gnu.org/order/ftp.html)
        !            34: %   ftp://tug.org/tex/texinfo.tex
        !            35: %   ftp://ctan.org/macros/texinfo/texinfo.tex
        !            36: %   (and all CTAN mirrors, finger ctan@ctan.org for a list).
        !            37: %   /home/gd/gnu/doc/texinfo.tex on the GNU machines.
        !            38: % The texinfo.tex in any given Texinfo distribution could well be out
        !            39: % of date, so if that's what you're using, please check.
        !            40: % There is a small home page for Texinfo at http://texinfo.org/.
        !            41: %
        !            42: % Send bug reports to bug-texinfo@gnu.org.  Please include including a
        !            43: % complete document in each bug report with which we can reproduce the
        !            44: % problem.  Patches are, of course, greatly appreciated.
        !            45: %
        !            46: % To process a Texinfo manual with TeX, it's most reliable to use the
        !            47: % texi2dvi shell script that comes with the distribution.  For a simple
        !            48: % manual foo.texi, however, you can get away with this:
        !            49: %   tex foo.texi
        !            50: %   texindex foo.??
        !            51: %   tex foo.texi
        !            52: %   tex foo.texi
        !            53: %   dvips foo.dvi -o # or whatever, to process the dvi file; this makes foo.ps.
        !            54: % The extra runs of TeX get the cross-reference information correct.
        !            55: % Sometimes one run after texindex suffices, and sometimes you need more
        !            56: % than two; texi2dvi does it as many times as necessary.
        !            57: %
        !            58: % It is possible to adapt texinfo.tex for other languages.  You can get
        !            59: % the existing language-specific files from ftp://ftp.gnu.org/gnu/texinfo/.
1.1       maekawa    60:
1.1.1.2 ! maekawa    61: \message{Loading texinfo [version \texinfoversion]:}
1.1       maekawa    62:
                     63: % If in a .fmt file, print the version number
                     64: % and turn on active characters that we couldn't do earlier because
                     65: % they might have appeared in the input file name.
1.1.1.2 ! maekawa    66: \everyjob{\message{[Texinfo version \texinfoversion]}%
1.1       maekawa    67:   \catcode`+=\active \catcode`\_=\active}
                     68:
                     69: % Save some parts of plain tex whose names we will redefine.
                     70:
                     71: \let\ptexb=\b
1.1.1.2 ! maekawa    72: \let\ptexbullet=\bullet
1.1       maekawa    73: \let\ptexc=\c
1.1.1.2 ! maekawa    74: \let\ptexcomma=\,
        !            75: \let\ptexdot=\.
        !            76: \let\ptexdots=\dots
        !            77: \let\ptexend=\end
        !            78: \let\ptexequiv=\equiv
        !            79: \let\ptexexclam=\!
1.1       maekawa    80: \let\ptexi=\i
1.1.1.2 ! maekawa    81: \let\ptexlbrace=\{
        !            82: \let\ptexrbrace=\}
        !            83: \let\ptexstar=\*
1.1       maekawa    84: \let\ptext=\t
                     85:
1.1.1.2 ! maekawa    86: % We never want plain's outer \+ definition in Texinfo.
        !            87: % For @tex, we can use \tabalign.
        !            88: \let\+ = \relax
        !            89:
1.1       maekawa    90:
                     91: \message{Basics,}
                     92: \chardef\other=12
                     93:
                     94: % If this character appears in an error message or help string, it
                     95: % starts a new line in the output.
                     96: \newlinechar = `^^J
                     97:
1.1.1.2 ! maekawa    98: % Set up fixed words for English if not already set.
        !            99: \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
        !           100: \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
        !           101: \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
        !           102: \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
        !           103: \ifx\putwordIndexIsEmpty\undefined     \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
        !           104: \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
        !           105: \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
        !           106: \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
        !           107: \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
        !           108: \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
        !           109: \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
        !           110: \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
        !           111: \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
        !           112: \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
        !           113: \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
        !           114: \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
        !           115: \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
        !           116: \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
        !           117: \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
        !           118: %
        !           119: \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
        !           120: \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
        !           121: \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
        !           122: \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
        !           123: \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
        !           124: \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
        !           125: \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
        !           126: \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
        !           127: \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
        !           128: \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
        !           129: \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
        !           130: \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
        !           131: %
        !           132: \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
        !           133: \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
        !           134: \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
        !           135: \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
        !           136: \ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi
        !           137: \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
        !           138: \ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi
1.1       maekawa   139:
                    140: % Ignore a token.
                    141: %
                    142: \def\gobble#1{}
                    143:
                    144: \hyphenation{ap-pen-dix}
                    145: \hyphenation{mini-buf-fer mini-buf-fers}
                    146: \hyphenation{eshell}
1.1.1.2 ! maekawa   147: \hyphenation{white-space}
1.1       maekawa   148:
                    149: % Margin to add to right of even pages, to left of odd pages.
1.1.1.2 ! maekawa   150: \newdimen \bindingoffset
        !           151: \newdimen \normaloffset
1.1       maekawa   152: \newdimen\pagewidth \newdimen\pageheight
                    153:
                    154: % Sometimes it is convenient to have everything in the transcript file
                    155: % and nothing on the terminal.  We don't just call \tracingall here,
                    156: % since that produces some useless output on the terminal.
                    157: %
                    158: \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
1.1.1.2 ! maekawa   159: \ifx\eTeXversion\undefined
1.1       maekawa   160: \def\loggingall{\tracingcommands2 \tracingstats2
                    161:    \tracingpages1 \tracingoutput1 \tracinglostchars1
                    162:    \tracingmacros2 \tracingparagraphs1 \tracingrestores1
                    163:    \showboxbreadth\maxdimen\showboxdepth\maxdimen
                    164: }%
1.1.1.2 ! maekawa   165: \else
        !           166: \def\loggingall{\tracingcommands3 \tracingstats2
        !           167:    \tracingpages1 \tracingoutput1 \tracinglostchars1
        !           168:    \tracingmacros2 \tracingparagraphs1 \tracingrestores1
        !           169:    \tracingscantokens1 \tracingassigns1 \tracingifs1
        !           170:    \tracinggroups1 \tracingnesting2
        !           171:    \showboxbreadth\maxdimen\showboxdepth\maxdimen
        !           172: }%
        !           173: \fi
1.1       maekawa   174:
1.1.1.2 ! maekawa   175: % For @cropmarks command.
        !           176: % Do @cropmarks to get crop marks.
1.1       maekawa   177: %
1.1.1.2 ! maekawa   178: \newif\ifcropmarks
        !           179: \let\cropmarks = \cropmarkstrue
1.1       maekawa   180: %
1.1.1.2 ! maekawa   181: % Dimensions to add cropmarks at corners.
        !           182: % Added by P. A. MacKay, 12 Nov. 1986
1.1       maekawa   183: %
1.1.1.2 ! maekawa   184: \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
        !           185: \newdimen\cornerlong  \cornerlong=1pc
        !           186: \newdimen\cornerthick \cornerthick=.3pt
        !           187: \newdimen\topandbottommargin \topandbottommargin=.75in
        !           188:
        !           189: % Main output routine.
        !           190: \chardef\PAGE = 255
        !           191: \output = {\onepageout{\pagecontents\PAGE}}
        !           192:
        !           193: \newbox\headlinebox
        !           194: \newbox\footlinebox
1.1       maekawa   195:
                    196: % \onepageout takes a vbox as an argument.  Note that \pagecontents
1.1.1.2 ! maekawa   197: % does insertions, but you have to call it yourself.
        !           198: \def\onepageout#1{%
        !           199:   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
        !           200:   %
        !           201:   \ifodd\pageno  \advance\hoffset by \bindingoffset
        !           202:   \else \advance\hoffset by -\bindingoffset\fi
        !           203:   %
        !           204:   % Do this outside of the \shipout so @code etc. will be expanded in
        !           205:   % the headline as they should be, not taken literally (outputting ''code).
        !           206:   \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
        !           207:   \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
        !           208:   %
        !           209:   {%
        !           210:     % Have to do this stuff outside the \shipout because we want it to
        !           211:     % take effect in \write's, yet the group defined by the \vbox ends
        !           212:     % before the \shipout runs.
        !           213:     %
        !           214:     \escapechar = `\\     % use backslash in output files.
        !           215:     \indexdummies         % don't expand commands in the output.
        !           216:     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
        !           217:                    % the page break happens to be in the middle of an example.
        !           218:     \shipout\vbox{%
        !           219:       \ifcropmarks \vbox to \outervsize\bgroup
        !           220:         \hsize = \outerhsize
        !           221:         \vskip-\topandbottommargin
        !           222:         \vtop to0pt{%
        !           223:           \line{\ewtop\hfil\ewtop}%
        !           224:           \nointerlineskip
        !           225:           \line{%
        !           226:             \vbox{\moveleft\cornerthick\nstop}%
        !           227:             \hfill
        !           228:             \vbox{\moveright\cornerthick\nstop}%
        !           229:           }%
        !           230:           \vss}%
        !           231:         \vskip\topandbottommargin
        !           232:         \line\bgroup
        !           233:           \hfil % center the page within the outer (page) hsize.
        !           234:           \ifodd\pageno\hskip\bindingoffset\fi
        !           235:           \vbox\bgroup
        !           236:       \fi
        !           237:       %
        !           238:       \unvbox\headlinebox
        !           239:       \pagebody{#1}%
        !           240:       \ifdim\ht\footlinebox > 0pt
        !           241:         % Only leave this space if the footline is nonempty.
        !           242:         % (We lessened \vsize for it in \oddfootingxxx.)
        !           243:         % The \baselineskip=24pt in plain's \makefootline has no effect.
        !           244:         \vskip 2\baselineskip
        !           245:         \unvbox\footlinebox
        !           246:       \fi
        !           247:       %
        !           248:       \ifcropmarks
        !           249:           \egroup % end of \vbox\bgroup
        !           250:         \hfil\egroup % end of (centering) \line\bgroup
        !           251:         \vskip\topandbottommargin plus1fill minus1fill
        !           252:         \boxmaxdepth = \cornerthick
        !           253:         \vbox to0pt{\vss
        !           254:           \line{%
        !           255:             \vbox{\moveleft\cornerthick\nsbot}%
        !           256:             \hfill
        !           257:             \vbox{\moveright\cornerthick\nsbot}%
        !           258:           }%
        !           259:           \nointerlineskip
        !           260:           \line{\ewbot\hfil\ewbot}%
        !           261:         }%
        !           262:       \egroup % \vbox from first cropmarks clause
        !           263:       \fi
        !           264:     }% end of \shipout\vbox
        !           265:   }% end of group with \turnoffactive
1.1       maekawa   266:   \advancepageno
1.1.1.2 ! maekawa   267:   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
        !           268: }
1.1       maekawa   269:
                    270: \newinsert\margin \dimen\margin=\maxdimen
                    271:
                    272: \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
                    273: {\catcode`\@ =11
                    274: \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
                    275: % marginal hacks, juha@viisa.uucp (Juha Takala)
                    276: \ifvoid\margin\else % marginal info is present
                    277:   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
                    278: \dimen@=\dp#1 \unvbox#1
                    279: \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
                    280: \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
                    281: }
                    282:
                    283: % Here are the rules for the cropmarks.  Note that they are
                    284: % offset so that the space between them is truly \outerhsize or \outervsize
                    285: % (P. A. MacKay, 12 November, 1986)
                    286: %
                    287: \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
                    288: \def\nstop{\vbox
                    289:   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
                    290: \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
                    291: \def\nsbot{\vbox
                    292:   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
                    293:
                    294: % Parse an argument, then pass it to #1.  The argument is the rest of
                    295: % the input line (except we remove a trailing comment).  #1 should be a
                    296: % macro which expects an ordinary undelimited TeX argument.
                    297: %
                    298: \def\parsearg#1{%
                    299:   \let\next = #1%
                    300:   \begingroup
                    301:     \obeylines
                    302:     \futurelet\temp\parseargx
                    303: }
                    304:
                    305: % If the next token is an obeyed space (from an @example environment or
                    306: % the like), remove it and recurse.  Otherwise, we're done.
                    307: \def\parseargx{%
                    308:   % \obeyedspace is defined far below, after the definition of \sepspaces.
                    309:   \ifx\obeyedspace\temp
                    310:     \expandafter\parseargdiscardspace
                    311:   \else
                    312:     \expandafter\parseargline
                    313:   \fi
                    314: }
                    315:
                    316: % Remove a single space (as the delimiter token to the macro call).
                    317: {\obeyspaces %
                    318:  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
                    319:
                    320: {\obeylines %
                    321:   \gdef\parseargline#1^^M{%
                    322:     \endgroup % End of the group started in \parsearg.
                    323:     %
                    324:     % First remove any @c comment, then any @comment.
                    325:     % Result of each macro is put in \toks0.
                    326:     \argremovec #1\c\relax %
                    327:     \expandafter\argremovecomment \the\toks0 \comment\relax %
                    328:     %
                    329:     % Call the caller's macro, saved as \next in \parsearg.
                    330:     \expandafter\next\expandafter{\the\toks0}%
                    331:   }%
                    332: }
                    333:
                    334: % Since all \c{,omment} does is throw away the argument, we can let TeX
                    335: % do that for us.  The \relax here is matched by the \relax in the call
                    336: % in \parseargline; it could be more or less anything, its purpose is
                    337: % just to delimit the argument to the \c.
                    338: \def\argremovec#1\c#2\relax{\toks0 = {#1}}
                    339: \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
                    340:
                    341: % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
                    342: %    @end itemize  @c foo
                    343: % will have two active spaces as part of the argument with the
                    344: % `itemize'.  Here we remove all active spaces from #1, and assign the
                    345: % result to \toks0.
                    346: %
                    347: % This loses if there are any *other* active characters besides spaces
                    348: % in the argument -- _ ^ +, for example -- since they get expanded.
                    349: % Fortunately, Texinfo does not define any such commands.  (If it ever
                    350: % does, the catcode of the characters in questionwill have to be changed
                    351: % here.)  But this means we cannot call \removeactivespaces as part of
                    352: % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
                    353: % that \parsearg gets might well have any character at all in it.
                    354: %
                    355: \def\removeactivespaces#1{%
                    356:   \begingroup
                    357:     \ignoreactivespaces
                    358:     \edef\temp{#1}%
                    359:     \global\toks0 = \expandafter{\temp}%
                    360:   \endgroup
                    361: }
                    362:
                    363: % Change the active space to expand to nothing.
                    364: %
                    365: \begingroup
                    366:   \obeyspaces
                    367:   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
                    368: \endgroup
                    369:
                    370:
                    371: \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
                    372:
                    373: %% These are used to keep @begin/@end levels from running away
                    374: %% Call \inENV within environments (after a \begingroup)
                    375: \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
                    376: \def\ENVcheck{%
1.1.1.2 ! maekawa   377: \ifENV\errmessage{Still within an environment; press RETURN to continue}
1.1       maekawa   378: \endgroup\fi} % This is not perfect, but it should reduce lossage
                    379:
                    380: % @begin foo  is the same as @foo, for now.
1.1.1.2 ! maekawa   381: \newhelp\EMsimple{Press RETURN to continue.}
1.1       maekawa   382:
                    383: \outer\def\begin{\parsearg\beginxxx}
                    384:
                    385: \def\beginxxx #1{%
                    386: \expandafter\ifx\csname #1\endcsname\relax
                    387: {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
                    388: \csname #1\endcsname\fi}
                    389:
                    390: % @end foo executes the definition of \Efoo.
                    391: %
                    392: \def\end{\parsearg\endxxx}
                    393: \def\endxxx #1{%
                    394:   \removeactivespaces{#1}%
                    395:   \edef\endthing{\the\toks0}%
                    396:   %
                    397:   \expandafter\ifx\csname E\endthing\endcsname\relax
                    398:     \expandafter\ifx\csname \endthing\endcsname\relax
                    399:       % There's no \foo, i.e., no ``environment'' foo.
                    400:       \errhelp = \EMsimple
                    401:       \errmessage{Undefined command `@end \endthing'}%
                    402:     \else
                    403:       \unmatchedenderror\endthing
                    404:     \fi
                    405:   \else
                    406:     % Everything's ok; the right environment has been started.
                    407:     \csname E\endthing\endcsname
                    408:   \fi
                    409: }
                    410:
                    411: % There is an environment #1, but it hasn't been started.  Give an error.
                    412: %
                    413: \def\unmatchedenderror#1{%
                    414:   \errhelp = \EMsimple
                    415:   \errmessage{This `@end #1' doesn't have a matching `@#1'}%
                    416: }
                    417:
                    418: % Define the control sequence \E#1 to give an unmatched @end error.
                    419: %
                    420: \def\defineunmatchedend#1{%
                    421:   \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
                    422: }
                    423:
                    424:
                    425: % Single-spacing is done by various environments (specifically, in
                    426: % \nonfillstart and \quotations).
                    427: \newskip\singlespaceskip \singlespaceskip = 12.5pt
                    428: \def\singlespace{%
                    429:   % Why was this kern here?  It messes up equalizing space above and below
                    430:   % environments.  --karl, 6may93
                    431:   %{\advance \baselineskip by -\singlespaceskip
                    432:   %\kern \baselineskip}%
                    433:   \setleading \singlespaceskip
                    434: }
                    435:
                    436: %% Simple single-character @ commands
                    437:
                    438: % @@ prints an @
                    439: % Kludge this until the fonts are right (grr).
1.1.1.2 ! maekawa   440: \def\@{{\tt\char64}}
1.1       maekawa   441:
                    442: % This is turned off because it was never documented
                    443: % and you can use @w{...} around a quote to suppress ligatures.
                    444: %% Define @` and @' to be the same as ` and '
                    445: %% but suppressing ligatures.
                    446: %\def\`{{`}}
                    447: %\def\'{{'}}
                    448:
                    449: % Used to generate quoted braces.
1.1.1.2 ! maekawa   450: \def\mylbrace {{\tt\char123}}
        !           451: \def\myrbrace {{\tt\char125}}
1.1       maekawa   452: \let\{=\mylbrace
                    453: \let\}=\myrbrace
1.1.1.2 ! maekawa   454: \begingroup
        !           455:   % Definitions to produce actual \{ & \} command in an index.
        !           456:   \catcode`\{ = 12 \catcode`\} = 12
        !           457:   \catcode`\[ = 1 \catcode`\] = 2
        !           458:   \catcode`\@ = 0 \catcode`\\ = 12
        !           459:   @gdef@lbracecmd[\{]%
        !           460:   @gdef@rbracecmd[\}]%
        !           461: @endgroup
        !           462:
        !           463: % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
        !           464: % Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H.
        !           465: \let\, = \c
        !           466: \let\dotaccent = \.
        !           467: \def\ringaccent#1{{\accent23 #1}}
        !           468: \let\tieaccent = \t
        !           469: \let\ubaraccent = \b
        !           470: \let\udotaccent = \d
        !           471:
        !           472: % Other special characters: @questiondown @exclamdown
        !           473: % Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss.
        !           474: \def\questiondown{?`}
        !           475: \def\exclamdown{!`}
        !           476:
        !           477: % Dotless i and dotless j, used for accents.
        !           478: \def\imacro{i}
        !           479: \def\jmacro{j}
        !           480: \def\dotless#1{%
        !           481:   \def\temp{#1}%
        !           482:   \ifx\temp\imacro \ptexi
        !           483:   \else\ifx\temp\jmacro \j
        !           484:   \else \errmessage{@dotless can be used only with i or j}%
        !           485:   \fi\fi
        !           486: }
        !           487:
        !           488: % Be sure we're in horizontal mode when doing a tie, since we make space
        !           489: % equivalent to this in @example-like environments. Otherwise, a space
        !           490: % at the beginning of a line will start with \penalty -- and
        !           491: % since \penalty is valid in vertical mode, we'd end up putting the
        !           492: % penalty on the vertical list instead of in the new paragraph.
        !           493: {\catcode`@ = 11
        !           494:  % Avoid using \@M directly, because that causes trouble
        !           495:  % if the definition is written into an index file.
        !           496:  \global\let\tiepenalty = \@M
        !           497:  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
        !           498: }
1.1       maekawa   499:
                    500: % @: forces normal size whitespace following.
                    501: \def\:{\spacefactor=1000 }
                    502:
                    503: % @* forces a line break.
                    504: \def\*{\hfil\break\hbox{}\ignorespaces}
                    505:
                    506: % @. is an end-of-sentence period.
                    507: \def\.{.\spacefactor=3000 }
                    508:
                    509: % @! is an end-of-sentence bang.
1.1.1.2 ! maekawa   510: \def\!{!\spacefactor=3000 }
1.1       maekawa   511:
                    512: % @? is an end-of-sentence query.
1.1.1.2 ! maekawa   513: \def\?{?\spacefactor=3000 }
1.1       maekawa   514:
                    515: % @w prevents a word break.  Without the \leavevmode, @w at the
                    516: % beginning of a paragraph, when TeX is still in vertical mode, would
                    517: % produce a whole line of output instead of starting the paragraph.
                    518: \def\w#1{\leavevmode\hbox{#1}}
                    519:
                    520: % @group ... @end group forces ... to be all on one page, by enclosing
                    521: % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
                    522: % to keep its height that of a normal line.  According to the rules for
                    523: % \topskip (p.114 of the TeXbook), the glue inserted is
                    524: % max (\topskip - \ht (first item), 0).  If that height is large,
                    525: % therefore, no glue is inserted, and the space between the headline and
                    526: % the text is small, which looks bad.
                    527: %
                    528: \def\group{\begingroup
                    529:   \ifnum\catcode13=\active \else
                    530:     \errhelp = \groupinvalidhelp
                    531:     \errmessage{@group invalid in context where filling is enabled}%
                    532:   \fi
                    533:   %
                    534:   % The \vtop we start below produces a box with normal height and large
                    535:   % depth; thus, TeX puts \baselineskip glue before it, and (when the
                    536:   % next line of text is done) \lineskip glue after it.  (See p.82 of
                    537:   % the TeXbook.)  Thus, space below is not quite equal to space
                    538:   % above.  But it's pretty close.
                    539:   \def\Egroup{%
                    540:     \egroup           % End the \vtop.
                    541:     \endgroup         % End the \group.
                    542:   }%
                    543:   %
                    544:   \vtop\bgroup
                    545:     % We have to put a strut on the last line in case the @group is in
                    546:     % the midst of an example, rather than completely enclosing it.
                    547:     % Otherwise, the interline space between the last line of the group
                    548:     % and the first line afterwards is too small.  But we can't put the
                    549:     % strut in \Egroup, since there it would be on a line by itself.
                    550:     % Hence this just inserts a strut at the beginning of each line.
                    551:     \everypar = {\strut}%
                    552:     %
                    553:     % Since we have a strut on every line, we don't need any of TeX's
                    554:     % normal interline spacing.
                    555:     \offinterlineskip
                    556:     %
                    557:     % OK, but now we have to do something about blank
                    558:     % lines in the input in @example-like environments, which normally
                    559:     % just turn into \lisppar, which will insert no space now that we've
                    560:     % turned off the interline space.  Simplest is to make them be an
                    561:     % empty paragraph.
                    562:     \ifx\par\lisppar
                    563:       \edef\par{\leavevmode \par}%
                    564:       %
                    565:       % Reset ^^M's definition to new definition of \par.
                    566:       \obeylines
                    567:     \fi
                    568:     %
                    569:     % Do @comment since we are called inside an environment such as
                    570:     % @example, where each end-of-line in the input causes an
                    571:     % end-of-line in the output.  We don't want the end-of-line after
                    572:     % the `@group' to put extra space in the output.  Since @group
                    573:     % should appear on a line by itself (according to the Texinfo
                    574:     % manual), we don't worry about eating any user text.
                    575:     \comment
                    576: }
                    577: %
                    578: % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
                    579: % message, so this ends up printing `@group can only ...'.
                    580: %
                    581: \newhelp\groupinvalidhelp{%
                    582: group can only be used in environments such as @example,^^J%
                    583: where each line of input produces a line of output.}
                    584:
                    585: % @need space-in-mils
                    586: % forces a page break if there is not space-in-mils remaining.
                    587:
                    588: \newdimen\mil  \mil=0.001in
                    589:
                    590: \def\need{\parsearg\needx}
                    591:
                    592: % Old definition--didn't work.
                    593: %\def\needx #1{\par %
                    594: %% This method tries to make TeX break the page naturally
                    595: %% if the depth of the box does not fit.
                    596: %{\baselineskip=0pt%
1.1.1.2 ! maekawa   597: %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
1.1       maekawa   598: %\prevdepth=-1000pt
                    599: %}}
                    600:
                    601: \def\needx#1{%
                    602:   % Go into vertical mode, so we don't make a big box in the middle of a
                    603:   % paragraph.
                    604:   \par
                    605:   %
                    606:   % Don't add any leading before our big empty box, but allow a page
                    607:   % break, since the best break might be right here.
                    608:   \allowbreak
                    609:   \nointerlineskip
                    610:   \vtop to #1\mil{\vfil}%
                    611:   %
                    612:   % TeX does not even consider page breaks if a penalty added to the
                    613:   % main vertical list is 10000 or more.  But in order to see if the
                    614:   % empty box we just added fits on the page, we must make it consider
                    615:   % page breaks.  On the other hand, we don't want to actually break the
                    616:   % page after the empty box.  So we use a penalty of 9999.
                    617:   %
                    618:   % There is an extremely small chance that TeX will actually break the
                    619:   % page at this \penalty, if there are no other feasible breakpoints in
                    620:   % sight.  (If the user is using lots of big @group commands, which
                    621:   % almost-but-not-quite fill up a page, TeX will have a hard time doing
                    622:   % good page breaking, for example.)  However, I could not construct an
                    623:   % example where a page broke at this \penalty; if it happens in a real
                    624:   % document, then we can reconsider our strategy.
                    625:   \penalty9999
                    626:   %
                    627:   % Back up by the size of the box, whether we did a page break or not.
                    628:   \kern -#1\mil
                    629:   %
                    630:   % Do not allow a page break right after this kern.
                    631:   \nobreak
                    632: }
                    633:
                    634: % @br   forces paragraph break
                    635:
                    636: \let\br = \par
                    637:
1.1.1.2 ! maekawa   638: % @dots{} output an ellipsis using the current font.
        !           639: % We do .5em per period so that it has the same spacing in a typewriter
        !           640: % font as three actual period characters.
        !           641: %
        !           642: \def\dots{%
        !           643:   \leavevmode
        !           644:   \hbox to 1.5em{%
        !           645:     \hskip 0pt plus 0.25fil minus 0.25fil
        !           646:     .\hss.\hss.%
        !           647:     \hskip 0pt plus 0.5fil minus 0.5fil
        !           648:   }%
        !           649: }
1.1       maekawa   650:
1.1.1.2 ! maekawa   651: % @enddots{} is an end-of-sentence ellipsis.
        !           652: %
        !           653: \def\enddots{%
        !           654:   \leavevmode
        !           655:   \hbox to 2em{%
        !           656:     \hskip 0pt plus 0.25fil minus 0.25fil
        !           657:     .\hss.\hss.\hss.%
        !           658:     \hskip 0pt plus 0.5fil minus 0.5fil
        !           659:   }%
        !           660:   \spacefactor=3000
        !           661: }
1.1       maekawa   662:
                    663:
1.1.1.2 ! maekawa   664: % @page    forces the start of a new page
        !           665: %
1.1       maekawa   666: \def\page{\par\vfill\supereject}
                    667:
                    668: % @exdent text....
                    669: % outputs text on separate line in roman font, starting at standard page margin
                    670:
                    671: % This records the amount of indent in the innermost environment.
                    672: % That's how much \exdent should take out.
                    673: \newskip\exdentamount
                    674:
                    675: % This defn is used inside fill environments such as @defun.
                    676: \def\exdent{\parsearg\exdentyyy}
                    677: \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
                    678:
                    679: % This defn is used inside nofill environments such as @example.
                    680: \def\nofillexdent{\parsearg\nofillexdentyyy}
                    681: \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
                    682: \leftline{\hskip\leftskip{\rm#1}}}}
                    683:
                    684: % @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
                    685:
                    686: \def\inmargin#1{%
                    687: \strut\vadjust{\nobreak\kern-\strutdepth
                    688:   \vtop to \strutdepth{\baselineskip\strutdepth\vss
                    689:   \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
                    690: \newskip\inmarginspacing \inmarginspacing=1cm
                    691: \def\strutdepth{\dp\strutbox}
                    692:
                    693: %\hbox{{\rm#1}}\hfil\break}}
                    694:
                    695: % @include file    insert text of that file as input.
                    696: % Allow normal characters that  we make active in the argument (a file name).
                    697: \def\include{\begingroup
                    698:   \catcode`\\=12
                    699:   \catcode`~=12
                    700:   \catcode`^=12
                    701:   \catcode`_=12
                    702:   \catcode`|=12
                    703:   \catcode`<=12
                    704:   \catcode`>=12
                    705:   \catcode`+=12
                    706:   \parsearg\includezzz}
                    707: % Restore active chars for included file.
                    708: \def\includezzz#1{\endgroup\begingroup
                    709:   % Read the included file in a group so nested @include's work.
                    710:   \def\thisfile{#1}%
                    711:   \input\thisfile
                    712: \endgroup}
                    713:
                    714: \def\thisfile{}
                    715:
                    716: % @center line   outputs that line, centered
                    717:
                    718: \def\center{\parsearg\centerzzz}
                    719: \def\centerzzz #1{{\advance\hsize by -\leftskip
                    720: \advance\hsize by -\rightskip
                    721: \centerline{#1}}}
                    722:
                    723: % @sp n   outputs n lines of vertical space
                    724:
                    725: \def\sp{\parsearg\spxxx}
1.1.1.2 ! maekawa   726: \def\spxxx #1{\vskip #1\baselineskip}
1.1       maekawa   727:
                    728: % @comment ...line which is ignored...
                    729: % @c is the same as @comment
                    730: % @ignore ... @end ignore  is another way to write a comment
                    731:
1.1.1.2 ! maekawa   732: \def\comment{\begingroup \catcode`\^^M=\other%
        !           733: \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
        !           734: \commentxxx}
        !           735: {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
1.1       maekawa   736:
                    737: \let\c=\comment
                    738:
1.1.1.2 ! maekawa   739: % @paragraphindent NCHARS
        !           740: % We'll use ems for NCHARS, close enough.
        !           741: % We cannot implement @paragraphindent asis, though.
        !           742: %
        !           743: \def\asisword{asis} % no translation, these are keywords
        !           744: \def\noneword{none}
1.1       maekawa   745: %
1.1.1.2 ! maekawa   746: \def\paragraphindent{\parsearg\doparagraphindent}
        !           747: \def\doparagraphindent#1{%
        !           748:   \def\temp{#1}%
        !           749:   \ifx\temp\asisword
1.1       maekawa   750:   \else
1.1.1.2 ! maekawa   751:     \ifx\temp\noneword
        !           752:       \defaultparindent = 0pt
        !           753:     \else
        !           754:       \defaultparindent = #1em
        !           755:     \fi
1.1       maekawa   756:   \fi
1.1.1.2 ! maekawa   757:   \parindent = \defaultparindent
1.1       maekawa   758: }
                    759:
1.1.1.2 ! maekawa   760: % @exampleindent NCHARS
        !           761: % We'll use ems for NCHARS like @paragraphindent.
        !           762: % It seems @exampleindent asis isn't necessary, but
        !           763: % I preserve it to make it similar to @paragraphindent.
        !           764: \def\exampleindent{\parsearg\doexampleindent}
        !           765: \def\doexampleindent#1{%
        !           766:   \def\temp{#1}%
        !           767:   \ifx\temp\asisword
1.1       maekawa   768:   \else
1.1.1.2 ! maekawa   769:     \ifx\temp\noneword
        !           770:       \lispnarrowing = 0pt
        !           771:     \else
        !           772:       \lispnarrowing = #1em
        !           773:     \fi
1.1       maekawa   774:   \fi
                    775: }
                    776:
                    777: % @asis just yields its argument.  Used with @table, for example.
                    778: %
                    779: \def\asis#1{#1}
                    780:
                    781: % @math means output in math mode.
                    782: % We don't use $'s directly in the definition of \math because control
                    783: % sequences like \math are expanded when the toc file is written.  Then,
                    784: % we read the toc file back, the $'s will be normal characters (as they
                    785: % should be, according to the definition of Texinfo).  So we must use a
                    786: % control sequence to switch into and out of math mode.
                    787: %
                    788: % This isn't quite enough for @math to work properly in indices, but it
                    789: % seems unlikely it will ever be needed there.
                    790: %
                    791: \let\implicitmath = $
                    792: \def\math#1{\implicitmath #1\implicitmath}
                    793:
                    794: % @bullet and @minus need the same treatment as @math, just above.
                    795: \def\bullet{\implicitmath\ptexbullet\implicitmath}
                    796: \def\minus{\implicitmath-\implicitmath}
                    797:
1.1.1.2 ! maekawa   798: % @refill is a no-op.
1.1       maekawa   799: \let\refill=\relax
                    800:
1.1.1.2 ! maekawa   801: % If working on a large document in chapters, it is convenient to
        !           802: % be able to disable indexing, cross-referencing, and contents, for test runs.
        !           803: % This is done with @novalidate (before @setfilename).
        !           804: %
        !           805: \newif\iflinks \linkstrue % by default we want the aux files.
        !           806: \let\novalidate = \linksfalse
        !           807:
1.1       maekawa   808: % @setfilename is done at the beginning of every texinfo file.
                    809: % So open here the files we need to have open while reading the input.
                    810: % This makes it possible to make a .fmt file for texinfo.
                    811: \def\setfilename{%
1.1.1.2 ! maekawa   812:    \iflinks
        !           813:      \readauxfile
        !           814:    \fi % \openindices needs to do some work in any case.
1.1       maekawa   815:    \openindices
                    816:    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
                    817:    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
1.1.1.2 ! maekawa   818:    %
        !           819:    % If texinfo.cnf is present on the system, read it.
        !           820:    % Useful for site-wide @afourpaper, etc.
        !           821:    % Just to be on the safe side, close the input stream before the \input.
        !           822:    \openin 1 texinfo.cnf
        !           823:    \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi
        !           824:    \closein1
        !           825:    \temp
        !           826:    %
1.1       maekawa   827:    \comment % Ignore the actual filename.
                    828: }
                    829:
1.1.1.2 ! maekawa   830: % Called from \setfilename.
        !           831: %
        !           832: \def\openindices{%
        !           833:   \newindex{cp}%
        !           834:   \newcodeindex{fn}%
        !           835:   \newcodeindex{vr}%
        !           836:   \newcodeindex{tp}%
        !           837:   \newcodeindex{ky}%
        !           838:   \newcodeindex{pg}%
        !           839: }
1.1       maekawa   840:
1.1.1.2 ! maekawa   841: % @bye.
        !           842: \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1.1       maekawa   843:
                    844:
                    845: \message{fonts,}
                    846: % Font-change commands.
                    847:
1.1.1.2 ! maekawa   848: % Texinfo sort of supports the sans serif font style, which plain TeX does not.
1.1       maekawa   849: % So we set up a \sf analogous to plain's \rm, etc.
                    850: \newfam\sffam
                    851: \def\sf{\fam=\sffam \tensf}
                    852: \let\li = \sf % Sometimes we call it \li, not \sf.
                    853:
                    854: % We don't need math for this one.
                    855: \def\ttsl{\tenttsl}
                    856:
1.1.1.2 ! maekawa   857: % Use Computer Modern fonts at \magstephalf (11pt).
        !           858: \newcount\mainmagstep
        !           859: \mainmagstep=\magstephalf
1.1       maekawa   860:
                    861: % Set the font macro #1 to the font named #2, adding on the
                    862: % specified font prefix (normally `cm').
                    863: % #3 is the font's design size, #4 is a scale factor
                    864: \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
                    865:
                    866: % Use cm as the default font prefix.
                    867: % To specify the font prefix, you must define \fontprefix
                    868: % before you read in texinfo.tex.
                    869: \ifx\fontprefix\undefined
                    870: \def\fontprefix{cm}
                    871: \fi
                    872: % Support font families that don't use the same naming scheme as CM.
                    873: \def\rmshape{r}
1.1.1.2 ! maekawa   874: \def\rmbshape{bx}               %where the normal face is bold
1.1       maekawa   875: \def\bfshape{b}
                    876: \def\bxshape{bx}
                    877: \def\ttshape{tt}
                    878: \def\ttbshape{tt}
                    879: \def\ttslshape{sltt}
                    880: \def\itshape{ti}
                    881: \def\itbshape{bxti}
                    882: \def\slshape{sl}
                    883: \def\slbshape{bxsl}
                    884: \def\sfshape{ss}
                    885: \def\sfbshape{ss}
                    886: \def\scshape{csc}
                    887: \def\scbshape{csc}
                    888:
                    889: \ifx\bigger\relax
                    890: \let\mainmagstep=\magstep1
                    891: \setfont\textrm\rmshape{12}{1000}
                    892: \setfont\texttt\ttshape{12}{1000}
                    893: \else
                    894: \setfont\textrm\rmshape{10}{\mainmagstep}
                    895: \setfont\texttt\ttshape{10}{\mainmagstep}
                    896: \fi
                    897: % Instead of cmb10, you many want to use cmbx10.
                    898: % cmbx10 is a prettier font on its own, but cmb10
                    899: % looks better when embedded in a line with cmr10.
                    900: \setfont\textbf\bfshape{10}{\mainmagstep}
                    901: \setfont\textit\itshape{10}{\mainmagstep}
                    902: \setfont\textsl\slshape{10}{\mainmagstep}
                    903: \setfont\textsf\sfshape{10}{\mainmagstep}
                    904: \setfont\textsc\scshape{10}{\mainmagstep}
                    905: \setfont\textttsl\ttslshape{10}{\mainmagstep}
                    906: \font\texti=cmmi10 scaled \mainmagstep
                    907: \font\textsy=cmsy10 scaled \mainmagstep
                    908:
                    909: % A few fonts for @defun, etc.
                    910: \setfont\defbf\bxshape{10}{\magstep1} %was 1314
                    911: \setfont\deftt\ttshape{10}{\magstep1}
                    912: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
                    913:
1.1.1.2 ! maekawa   914: % Fonts for indices and small examples (9pt).
1.1       maekawa   915: % We actually use the slanted font rather than the italic,
                    916: % because texinfo normally uses the slanted fonts for that.
                    917: % Do not make many font distinctions in general in the index, since they
                    918: % aren't very useful.
                    919: \setfont\ninett\ttshape{9}{1000}
1.1.1.2 ! maekawa   920: \setfont\ninettsl\ttslshape{10}{900}
1.1       maekawa   921: \setfont\indrm\rmshape{9}{1000}
1.1.1.2 ! maekawa   922: \setfont\indit\itshape{9}{1000}
        !           923: \setfont\indsl\slshape{9}{1000}
1.1       maekawa   924: \let\indtt=\ninett
1.1.1.2 ! maekawa   925: \let\indttsl=\ninettsl
1.1       maekawa   926: \let\indsf=\indrm
                    927: \let\indbf=\indrm
                    928: \setfont\indsc\scshape{10}{900}
                    929: \font\indi=cmmi9
                    930: \font\indsy=cmsy9
                    931:
1.1.1.2 ! maekawa   932: % Fonts for title page:
        !           933: \setfont\titlerm\rmbshape{12}{\magstep3}
        !           934: \setfont\titleit\itbshape{10}{\magstep4}
        !           935: \setfont\titlesl\slbshape{10}{\magstep4}
        !           936: \setfont\titlett\ttbshape{12}{\magstep3}
        !           937: \setfont\titlettsl\ttslshape{10}{\magstep4}
        !           938: \setfont\titlesf\sfbshape{17}{\magstep1}
        !           939: \let\titlebf=\titlerm
        !           940: \setfont\titlesc\scbshape{10}{\magstep4}
        !           941: \font\titlei=cmmi12 scaled \magstep3
        !           942: \font\titlesy=cmsy10 scaled \magstep4
        !           943: \def\authorrm{\secrm}
        !           944:
        !           945: % Chapter (and unnumbered) fonts (17.28pt).
1.1       maekawa   946: \setfont\chaprm\rmbshape{12}{\magstep2}
                    947: \setfont\chapit\itbshape{10}{\magstep3}
                    948: \setfont\chapsl\slbshape{10}{\magstep3}
                    949: \setfont\chaptt\ttbshape{12}{\magstep2}
                    950: \setfont\chapttsl\ttslshape{10}{\magstep3}
1.1.1.2 ! maekawa   951: \setfont\chapsf\sfbshape{17}{1000}
1.1       maekawa   952: \let\chapbf=\chaprm
                    953: \setfont\chapsc\scbshape{10}{\magstep3}
                    954: \font\chapi=cmmi12 scaled \magstep2
                    955: \font\chapsy=cmsy10 scaled \magstep3
                    956:
1.1.1.2 ! maekawa   957: % Section fonts (14.4pt).
1.1       maekawa   958: \setfont\secrm\rmbshape{12}{\magstep1}
                    959: \setfont\secit\itbshape{10}{\magstep2}
                    960: \setfont\secsl\slbshape{10}{\magstep2}
                    961: \setfont\sectt\ttbshape{12}{\magstep1}
                    962: \setfont\secttsl\ttslshape{10}{\magstep2}
                    963: \setfont\secsf\sfbshape{12}{\magstep1}
                    964: \let\secbf\secrm
                    965: \setfont\secsc\scbshape{10}{\magstep2}
                    966: \font\seci=cmmi12 scaled \magstep1
                    967: \font\secsy=cmsy10 scaled \magstep2
                    968:
                    969: % \setfont\ssecrm\bxshape{10}{\magstep1}    % This size an font looked bad.
                    970: % \setfont\ssecit\itshape{10}{\magstep1}    % The letters were too crowded.
                    971: % \setfont\ssecsl\slshape{10}{\magstep1}
                    972: % \setfont\ssectt\ttshape{10}{\magstep1}
                    973: % \setfont\ssecsf\sfshape{10}{\magstep1}
                    974:
1.1.1.2 ! maekawa   975: %\setfont\ssecrm\bfshape{10}{1315}      % Note the use of cmb rather than cmbx.
        !           976: %\setfont\ssecit\itshape{10}{1315}      % Also, the size is a little larger than
        !           977: %\setfont\ssecsl\slshape{10}{1315}      % being scaled magstep1.
1.1       maekawa   978: %\setfont\ssectt\ttshape{10}{1315}
                    979: %\setfont\ssecsf\sfshape{10}{1315}
                    980:
                    981: %\let\ssecbf=\ssecrm
                    982:
1.1.1.2 ! maekawa   983: % Subsection fonts (13.15pt).
1.1       maekawa   984: \setfont\ssecrm\rmbshape{12}{\magstephalf}
                    985: \setfont\ssecit\itbshape{10}{1315}
                    986: \setfont\ssecsl\slbshape{10}{1315}
                    987: \setfont\ssectt\ttbshape{12}{\magstephalf}
1.1.1.2 ! maekawa   988: \setfont\ssecttsl\ttslshape{10}{1315}
1.1       maekawa   989: \setfont\ssecsf\sfbshape{12}{\magstephalf}
                    990: \let\ssecbf\ssecrm
                    991: \setfont\ssecsc\scbshape{10}{\magstep1}
                    992: \font\sseci=cmmi12 scaled \magstephalf
1.1.1.2 ! maekawa   993: \font\ssecsy=cmsy10 scaled 1315
1.1       maekawa   994: % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
                    995: % but that is not a standard magnification.
                    996:
                    997: % In order for the font changes to affect most math symbols and letters,
                    998: % we have to define the \textfont of the standard families.  Since
                    999: % texinfo doesn't allow for producing subscripts and superscripts, we
                   1000: % don't bother to reset \scriptfont and \scriptscriptfont (which would
                   1001: % also require loading a lot more fonts).
                   1002: %
                   1003: \def\resetmathfonts{%
                   1004:   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
                   1005:   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
                   1006:   \textfont\ttfam = \tentt \textfont\sffam = \tensf
                   1007: }
                   1008:
                   1009:
                   1010: % The font-changing commands redefine the meanings of \tenSTYLE, instead
                   1011: % of just \STYLE.  We do this so that font changes will continue to work
                   1012: % in math mode, where it is the current \fam that is relevant in most
                   1013: % cases, not the current font.  Plain TeX does \def\bf{\fam=\bffam
                   1014: % \tenbf}, for example.  By redefining \tenbf, we obviate the need to
                   1015: % redefine \bf itself.
                   1016: \def\textfonts{%
                   1017:   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
                   1018:   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
                   1019:   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
                   1020:   \resetmathfonts}
1.1.1.2 ! maekawa  1021: \def\titlefonts{%
        !          1022:   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
        !          1023:   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
        !          1024:   \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
        !          1025:   \let\tenttsl=\titlettsl
        !          1026:   \resetmathfonts \setleading{25pt}}
        !          1027: \def\titlefont#1{{\titlefonts\rm #1}}
1.1       maekawa  1028: \def\chapfonts{%
                   1029:   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
                   1030:   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
                   1031:   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl
1.1.1.2 ! maekawa  1032:   \resetmathfonts \setleading{19pt}}
1.1       maekawa  1033: \def\secfonts{%
                   1034:   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
                   1035:   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
                   1036:   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl
1.1.1.2 ! maekawa  1037:   \resetmathfonts \setleading{16pt}}
1.1       maekawa  1038: \def\subsecfonts{%
                   1039:   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
                   1040:   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
                   1041:   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl
1.1.1.2 ! maekawa  1042:   \resetmathfonts \setleading{15pt}}
        !          1043: \let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf?
1.1       maekawa  1044: \def\indexfonts{%
                   1045:   \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
                   1046:   \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
                   1047:   \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl
1.1.1.2 ! maekawa  1048:   \resetmathfonts \setleading{12pt}}
1.1       maekawa  1049:
                   1050: % Set up the default fonts, so we can use them for creating boxes.
                   1051: %
                   1052: \textfonts
                   1053:
1.1.1.2 ! maekawa  1054: % Define these so they can be easily changed for other fonts.
        !          1055: \def\angleleft{$\langle$}
        !          1056: \def\angleright{$\rangle$}
        !          1057:
1.1       maekawa  1058: % Count depth in font-changes, for error checks
                   1059: \newcount\fontdepth \fontdepth=0
                   1060:
                   1061: % Fonts for short table of contents.
                   1062: \setfont\shortcontrm\rmshape{12}{1000}
                   1063: \setfont\shortcontbf\bxshape{12}{1000}
                   1064: \setfont\shortcontsl\slshape{12}{1000}
                   1065:
                   1066: %% Add scribe-like font environments, plus @l for inline lisp (usually sans
                   1067: %% serif) and @ii for TeX italic
                   1068:
                   1069: % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
                   1070: % unless the following character is such as not to need one.
                   1071: \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
1.1.1.2 ! maekawa  1072: \def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx}
        !          1073: \def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx}
1.1       maekawa  1074:
                   1075: \let\i=\smartitalic
1.1.1.2 ! maekawa  1076: \let\var=\smartslanted
        !          1077: \let\dfn=\smartslanted
1.1       maekawa  1078: \let\emph=\smartitalic
1.1.1.2 ! maekawa  1079: \let\cite=\smartslanted
1.1       maekawa  1080:
                   1081: \def\b#1{{\bf #1}}
                   1082: \let\strong=\b
                   1083:
                   1084: % We can't just use \exhyphenpenalty, because that only has effect at
                   1085: % the end of a paragraph.  Restore normal hyphenation at the end of the
                   1086: % group within which \nohyphenation is presumably called.
                   1087: %
                   1088: \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
                   1089: \def\restorehyphenation{\hyphenchar\font = `- }
                   1090:
                   1091: \def\t#1{%
                   1092:   {\tt \rawbackslash \frenchspacing #1}%
                   1093:   \null
                   1094: }
                   1095: \let\ttfont=\t
1.1.1.2 ! maekawa  1096: \def\samp#1{`\tclose{#1}'\null}
        !          1097: \setfont\smallrm\rmshape{8}{1000}
        !          1098: \font\smallsy=cmsy9
        !          1099: \def\key#1{{\smallrm\textfont2=\smallsy \leavevmode\hbox{%
        !          1100:   \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
        !          1101:     \vbox{\hrule\kern-0.4pt
        !          1102:      \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
        !          1103:     \kern-0.4pt\hrule}%
        !          1104:   \kern-.06em\raise0.4pt\hbox{\angleright}}}}
        !          1105: % The old definition, with no lozenge:
        !          1106: %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
1.1       maekawa  1107: \def\ctrl #1{{\tt \rawbackslash \hat}#1}
                   1108:
1.1.1.2 ! maekawa  1109: % @file, @option are the same as @samp.
1.1       maekawa  1110: \let\file=\samp
1.1.1.2 ! maekawa  1111: \let\option=\samp
1.1       maekawa  1112:
                   1113: % @code is a modification of @t,
                   1114: % which makes spaces the same size as normal in the surrounding text.
                   1115: \def\tclose#1{%
                   1116:   {%
                   1117:     % Change normal interword space to be same as for the current font.
                   1118:     \spaceskip = \fontdimen2\font
                   1119:     %
                   1120:     % Switch to typewriter.
                   1121:     \tt
                   1122:     %
                   1123:     % But `\ ' produces the large typewriter interword space.
                   1124:     \def\ {{\spaceskip = 0pt{} }}%
                   1125:     %
                   1126:     % Turn off hyphenation.
                   1127:     \nohyphenation
                   1128:     %
                   1129:     \rawbackslash
                   1130:     \frenchspacing
                   1131:     #1%
                   1132:   }%
                   1133:   \null
                   1134: }
                   1135:
                   1136: % We *must* turn on hyphenation at `-' and `_' in \code.
                   1137: % Otherwise, it is too hard to avoid overfull hboxes
                   1138: % in the Emacs manual, the Library manual, etc.
                   1139:
                   1140: % Unfortunately, TeX uses one parameter (\hyphenchar) to control
                   1141: % both hyphenation at - and hyphenation within words.
                   1142: % We must therefore turn them both off (\tclose does that)
1.1.1.2 ! maekawa  1143: % and arrange explicitly to hyphenate at a dash.
1.1       maekawa  1144: %  -- rms.
                   1145: {
1.1.1.2 ! maekawa  1146:   \catcode`\-=\active
        !          1147:   \catcode`\_=\active
        !          1148:   %
        !          1149:   \global\def\code{\begingroup
        !          1150:     \catcode`\-=\active \let-\codedash
        !          1151:     \catcode`\_=\active \let_\codeunder
        !          1152:     \codex
        !          1153:   }
        !          1154:   %
        !          1155:   % If we end up with any active - characters when handling the index,
        !          1156:   % just treat them as a normal -.
        !          1157:   \global\def\indexbreaks{\catcode`\-=\active \let-\realdash}
1.1       maekawa  1158: }
                   1159:
                   1160: \def\realdash{-}
                   1161: \def\codedash{-\discretionary{}{}{}}
1.1.1.2 ! maekawa  1162: \def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}}
1.1       maekawa  1163: \def\codex #1{\tclose{#1}\endgroup}
                   1164:
                   1165: %\let\exp=\tclose  %Was temporary
                   1166:
                   1167: % @kbd is like @code, except that if the argument is just one @key command,
                   1168: % then @kbd has no effect.
1.1.1.2 ! maekawa  1169:
        !          1170: % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
        !          1171: %   `example' (@kbd uses ttsl only inside of @example and friends),
        !          1172: %   or `code' (@kbd uses normal tty font always).
        !          1173: \def\kbdinputstyle{\parsearg\kbdinputstylexxx}
        !          1174: \def\kbdinputstylexxx#1{%
        !          1175:   \def\arg{#1}%
        !          1176:   \ifx\arg\worddistinct
        !          1177:     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
        !          1178:   \else\ifx\arg\wordexample
        !          1179:     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
        !          1180:   \else\ifx\arg\wordcode
        !          1181:     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
        !          1182:   \fi\fi\fi
        !          1183: }
        !          1184: \def\worddistinct{distinct}
        !          1185: \def\wordexample{example}
        !          1186: \def\wordcode{code}
        !          1187:
        !          1188: % Default is kbdinputdistinct.  (Too much of a hassle to call the macro,
        !          1189: % the catcodes are wrong for parsearg to work.)
        !          1190: \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
        !          1191:
1.1       maekawa  1192: \def\xkey{\key}
                   1193: \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
                   1194: \ifx\one\xkey\ifx\threex\three \key{#2}%
1.1.1.2 ! maekawa  1195: \else{\tclose{\kbdfont\look}}\fi
        !          1196: \else{\tclose{\kbdfont\look}}\fi}
        !          1197:
        !          1198: % For @url, @env, @command quotes seem unnecessary, so use \code.
        !          1199: \let\url=\code
        !          1200: \let\env=\code
        !          1201: \let\command=\code
        !          1202:
        !          1203: % @uref (abbreviation for `urlref') takes an optional (comma-separated)
        !          1204: % second argument specifying the text to display and an optional third
        !          1205: % arg as text to display instead of (rather than in addition to) the url
        !          1206: % itself.  First (mandatory) arg is the url.  Perhaps eventually put in
        !          1207: % a hypertex \special here.
        !          1208: %
        !          1209: \def\uref#1{\douref #1,,,\finish}
        !          1210: \def\douref#1,#2,#3,#4\finish{%
        !          1211:   \setbox0 = \hbox{\ignorespaces #3}%
        !          1212:   \ifdim\wd0 > 0pt
        !          1213:     \unhbox0 % third arg given, show only that
        !          1214:   \else
        !          1215:     \setbox0 = \hbox{\ignorespaces #2}%
        !          1216:     \ifdim\wd0 > 0pt
        !          1217:       \unhbox0\ (\code{#1})% second arg given, show both it and url
        !          1218:     \else
        !          1219:       \code{#1}% only url given, so show it
        !          1220:     \fi
        !          1221:   \fi
        !          1222: }
        !          1223:
        !          1224: % rms does not like the angle brackets --karl, 17may97.
        !          1225: % So now @email is just like @uref.
        !          1226: %\def\email#1{\angleleft{\tt #1}\angleright}
        !          1227: \let\email=\uref
1.1       maekawa  1228:
                   1229: % Check if we are currently using a typewriter font.  Since all the
                   1230: % Computer Modern typewriter fonts have zero interword stretch (and
                   1231: % shrink), and it is reasonable to expect all typewriter fonts to have
                   1232: % this property, we can check that font parameter.
1.1.1.2 ! maekawa  1233: %
1.1       maekawa  1234: \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
                   1235:
                   1236: % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
1.1.1.2 ! maekawa  1237: % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
1.1       maekawa  1238: %
                   1239: \def\dmn#1{\thinspace #1}
                   1240:
                   1241: \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
                   1242:
1.1.1.2 ! maekawa  1243: % @l was never documented to mean ``switch to the Lisp font'',
        !          1244: % and it is not used as such in any manual I can find.  We need it for
        !          1245: % Polish suppressed-l.  --karl, 22sep96.
        !          1246: %\def\l#1{{\li #1}\null}
        !          1247:
        !          1248: % Explicit font changes: @r, @sc, undocumented @ii.
        !          1249: \def\r#1{{\rm #1}}              % roman font
        !          1250: \def\sc#1{{\smallcaps#1}}       % smallcaps font
        !          1251: \def\ii#1{{\it #1}}             % italic font
        !          1252:
        !          1253: % @acronym downcases the argument and prints in smallcaps.
        !          1254: \def\acronym#1{{\smallcaps \lowercase{#1}}}
        !          1255:
        !          1256: % @pounds{} is a sterling sign.
        !          1257: \def\pounds{{\it\$}}
1.1       maekawa  1258:
                   1259:
                   1260: \message{page headings,}
                   1261:
                   1262: \newskip\titlepagetopglue \titlepagetopglue = 1.5in
                   1263: \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
                   1264:
                   1265: % First the title page.  Must do @settitle before @titlepage.
                   1266: \newif\ifseenauthor
                   1267: \newif\iffinishedtitlepage
                   1268:
1.1.1.2 ! maekawa  1269: % Do an implicit @contents or @shortcontents after @end titlepage if the
        !          1270: % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
        !          1271: %
        !          1272: \newif\ifsetcontentsaftertitlepage
        !          1273:  \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
        !          1274: \newif\ifsetshortcontentsaftertitlepage
        !          1275:  \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
        !          1276:
1.1       maekawa  1277: \def\shorttitlepage{\parsearg\shorttitlepagezzz}
                   1278: \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
1.1.1.2 ! maekawa  1279:         \endgroup\page\hbox{}\page}
1.1       maekawa  1280:
                   1281: \def\titlepage{\begingroup \parindent=0pt \textfonts
                   1282:    \let\subtitlerm=\tenrm
                   1283:    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
                   1284:    %
                   1285:    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
                   1286:    %
                   1287:    % Leave some space at the very top of the page.
                   1288:    \vglue\titlepagetopglue
                   1289:    %
                   1290:    % Now you can print the title using @title.
                   1291:    \def\title{\parsearg\titlezzz}%
1.1.1.2 ! maekawa  1292:    \def\titlezzz##1{\leftline{\titlefonts\rm ##1}
        !          1293:                     % print a rule at the page bottom also.
        !          1294:                     \finishedtitlepagefalse
        !          1295:                     \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
1.1       maekawa  1296:    % No rule at page bottom unless we print one at the top with @title.
                   1297:    \finishedtitlepagetrue
                   1298:    %
                   1299:    % Now you can put text using @subtitle.
                   1300:    \def\subtitle{\parsearg\subtitlezzz}%
                   1301:    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
                   1302:    %
                   1303:    % @author should come last, but may come many times.
                   1304:    \def\author{\parsearg\authorzzz}%
                   1305:    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
                   1306:       {\authorfont \leftline{##1}}}%
                   1307:    %
                   1308:    % Most title ``pages'' are actually two pages long, with space
                   1309:    % at the top of the second.  We don't want the ragged left on the second.
                   1310:    \let\oldpage = \page
                   1311:    \def\page{%
                   1312:       \iffinishedtitlepage\else
1.1.1.2 ! maekawa  1313:          \finishtitlepage
1.1       maekawa  1314:       \fi
                   1315:       \oldpage
                   1316:       \let\page = \oldpage
                   1317:       \hbox{}}%
                   1318: %   \def\page{\oldpage \hbox{}}
                   1319: }
                   1320:
                   1321: \def\Etitlepage{%
                   1322:    \iffinishedtitlepage\else
                   1323:       \finishtitlepage
                   1324:    \fi
                   1325:    % It is important to do the page break before ending the group,
                   1326:    % because the headline and footline are only empty inside the group.
                   1327:    % If we use the new definition of \page, we always get a blank page
                   1328:    % after the title page, which we certainly don't want.
                   1329:    \oldpage
                   1330:    \endgroup
1.1.1.2 ! maekawa  1331:    %
        !          1332:    % If they want short, they certainly want long too.
        !          1333:    \ifsetshortcontentsaftertitlepage
        !          1334:      \shortcontents
        !          1335:      \contents
        !          1336:      \global\let\shortcontents = \relax
        !          1337:      \global\let\contents = \relax
        !          1338:    \fi
        !          1339:    %
        !          1340:    \ifsetcontentsaftertitlepage
        !          1341:      \contents
        !          1342:      \global\let\contents = \relax
        !          1343:      \global\let\shortcontents = \relax
        !          1344:    \fi
        !          1345:    %
1.1       maekawa  1346:    \HEADINGSon
                   1347: }
                   1348:
                   1349: \def\finishtitlepage{%
                   1350:    \vskip4pt \hrule height 2pt width \hsize
                   1351:    \vskip\titlepagebottomglue
                   1352:    \finishedtitlepagetrue
                   1353: }
                   1354:
                   1355: %%% Set up page headings and footings.
                   1356:
                   1357: \let\thispage=\folio
                   1358:
1.1.1.2 ! maekawa  1359: \newtoks\evenheadline    % headline on even pages
        !          1360: \newtoks\oddheadline     % headline on odd pages
        !          1361: \newtoks\evenfootline    % footline on even pages
        !          1362: \newtoks\oddfootline     % footline on odd pages
1.1       maekawa  1363:
                   1364: % Now make Tex use those variables
                   1365: \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
                   1366:                             \else \the\evenheadline \fi}}
                   1367: \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
                   1368:                             \else \the\evenfootline \fi}\HEADINGShook}
                   1369: \let\HEADINGShook=\relax
                   1370:
                   1371: % Commands to set those variables.
                   1372: % For example, this is what  @headings on  does
                   1373: % @evenheading @thistitle|@thispage|@thischapter
                   1374: % @oddheading @thischapter|@thispage|@thistitle
                   1375: % @evenfooting @thisfile||
                   1376: % @oddfooting ||@thisfile
                   1377:
                   1378: \def\evenheading{\parsearg\evenheadingxxx}
                   1379: \def\oddheading{\parsearg\oddheadingxxx}
                   1380: \def\everyheading{\parsearg\everyheadingxxx}
                   1381:
                   1382: \def\evenfooting{\parsearg\evenfootingxxx}
                   1383: \def\oddfooting{\parsearg\oddfootingxxx}
                   1384: \def\everyfooting{\parsearg\everyfootingxxx}
                   1385:
                   1386: {\catcode`\@=0 %
                   1387:
                   1388: \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
                   1389: \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
                   1390: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
                   1391:
                   1392: \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
                   1393: \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
                   1394: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
                   1395:
1.1.1.2 ! maekawa  1396: \gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
1.1       maekawa  1397:
                   1398: \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
                   1399: \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
                   1400: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
                   1401:
                   1402: \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
                   1403: \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
1.1.1.2 ! maekawa  1404:   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
        !          1405:   %
        !          1406:   % Leave some space for the footline.  Hopefully ok to assume
        !          1407:   % @evenfooting will not be used by itself.
        !          1408:   \global\advance\pageheight by -\baselineskip
        !          1409:   \global\advance\vsize by -\baselineskip
        !          1410: }
1.1       maekawa  1411:
1.1.1.2 ! maekawa  1412: \gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}}
1.1       maekawa  1413: %
                   1414: }% unbind the catcode of @.
                   1415:
1.1.1.2 ! maekawa  1416: % @headings double      turns headings on for double-sided printing.
        !          1417: % @headings single      turns headings on for single-sided printing.
        !          1418: % @headings off         turns them off.
        !          1419: % @headings on          same as @headings double, retained for compatibility.
        !          1420: % @headings after       turns on double-sided headings after this page.
        !          1421: % @headings doubleafter turns on double-sided headings after this page.
1.1       maekawa  1422: % @headings singleafter turns on single-sided headings after this page.
1.1.1.2 ! maekawa  1423: % By default, they are off at the start of a document,
        !          1424: % and turned `on' after @end titlepage.
1.1       maekawa  1425:
                   1426: \def\headings #1 {\csname HEADINGS#1\endcsname}
                   1427:
                   1428: \def\HEADINGSoff{
                   1429: \global\evenheadline={\hfil} \global\evenfootline={\hfil}
                   1430: \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
                   1431: \HEADINGSoff
                   1432: % When we turn headings on, set the page number to 1.
                   1433: % For double-sided printing, put current file name in lower left corner,
                   1434: % chapter name on inside top of right hand pages, document
                   1435: % title on inside top of left hand pages, and page numbers on outside top
                   1436: % edge of all pages.
                   1437: \def\HEADINGSdouble{
                   1438: \global\pageno=1
                   1439: \global\evenfootline={\hfil}
                   1440: \global\oddfootline={\hfil}
                   1441: \global\evenheadline={\line{\folio\hfil\thistitle}}
                   1442: \global\oddheadline={\line{\thischapter\hfil\folio}}
1.1.1.2 ! maekawa  1443: \global\let\contentsalignmacro = \chapoddpage
1.1       maekawa  1444: }
1.1.1.2 ! maekawa  1445: \let\contentsalignmacro = \chappager
        !          1446:
1.1       maekawa  1447: % For single-sided printing, chapter title goes across top left of page,
                   1448: % page number on top right.
                   1449: \def\HEADINGSsingle{
                   1450: \global\pageno=1
                   1451: \global\evenfootline={\hfil}
                   1452: \global\oddfootline={\hfil}
                   1453: \global\evenheadline={\line{\thischapter\hfil\folio}}
                   1454: \global\oddheadline={\line{\thischapter\hfil\folio}}
1.1.1.2 ! maekawa  1455: \global\let\contentsalignmacro = \chappager
1.1       maekawa  1456: }
                   1457: \def\HEADINGSon{\HEADINGSdouble}
                   1458:
                   1459: \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
                   1460: \let\HEADINGSdoubleafter=\HEADINGSafter
                   1461: \def\HEADINGSdoublex{%
                   1462: \global\evenfootline={\hfil}
                   1463: \global\oddfootline={\hfil}
                   1464: \global\evenheadline={\line{\folio\hfil\thistitle}}
                   1465: \global\oddheadline={\line{\thischapter\hfil\folio}}
1.1.1.2 ! maekawa  1466: \global\let\contentsalignmacro = \chapoddpage
1.1       maekawa  1467: }
                   1468:
                   1469: \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
                   1470: \def\HEADINGSsinglex{%
                   1471: \global\evenfootline={\hfil}
                   1472: \global\oddfootline={\hfil}
                   1473: \global\evenheadline={\line{\thischapter\hfil\folio}}
                   1474: \global\oddheadline={\line{\thischapter\hfil\folio}}
1.1.1.2 ! maekawa  1475: \global\let\contentsalignmacro = \chappager
1.1       maekawa  1476: }
                   1477:
                   1478: % Subroutines used in generating headings
                   1479: % Produces Day Month Year style of output.
1.1.1.2 ! maekawa  1480: \def\today{%
        !          1481:   \number\day\space
        !          1482:   \ifcase\month
        !          1483:   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
        !          1484:   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
        !          1485:   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
        !          1486:   \fi
        !          1487:   \space\number\year}
1.1       maekawa  1488:
1.1.1.2 ! maekawa  1489: % @settitle line...  specifies the title of the document, for headings.
        !          1490: % It generates no output of its own.
        !          1491: \def\thistitle{\putwordNoTitle}
1.1       maekawa  1492: \def\settitle{\parsearg\settitlezzz}
                   1493: \def\settitlezzz #1{\gdef\thistitle{#1}}
                   1494:
                   1495:
1.1.1.2 ! maekawa  1496: \message{tables,}
1.1       maekawa  1497: % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
                   1498:
                   1499: % default indentation of table text
                   1500: \newdimen\tableindent \tableindent=.8in
                   1501: % default indentation of @itemize and @enumerate text
                   1502: \newdimen\itemindent  \itemindent=.3in
                   1503: % margin between end of table item and start of table text.
                   1504: \newdimen\itemmargin  \itemmargin=.1in
                   1505:
                   1506: % used internally for \itemindent minus \itemmargin
                   1507: \newdimen\itemmax
                   1508:
                   1509: % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
                   1510: % these defs.
                   1511: % They also define \itemindex
                   1512: % to index the item name in whatever manner is desired (perhaps none).
                   1513:
                   1514: \newif\ifitemxneedsnegativevskip
                   1515:
                   1516: \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
                   1517:
                   1518: \def\internalBitem{\smallbreak \parsearg\itemzzz}
                   1519: \def\internalBitemx{\itemxpar \parsearg\itemzzz}
                   1520:
                   1521: \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
                   1522: \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
                   1523:
                   1524: \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
                   1525: \def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
                   1526:
                   1527: \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
                   1528:                  \itemzzz {#1}}
                   1529:
                   1530: \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
                   1531:                  \itemzzz {#1}}
                   1532:
                   1533: \def\itemzzz #1{\begingroup %
                   1534:   \advance\hsize by -\rightskip
                   1535:   \advance\hsize by -\tableindent
                   1536:   \setbox0=\hbox{\itemfont{#1}}%
                   1537:   \itemindex{#1}%
                   1538:   \nobreak % This prevents a break before @itemx.
                   1539:   %
                   1540:   % If the item text does not fit in the space we have, put it on a line
                   1541:   % by itself, and do not allow a page break either before or after that
                   1542:   % line.  We do not start a paragraph here because then if the next
                   1543:   % command is, e.g., @kindex, the whatsit would get put into the
                   1544:   % horizontal list on a line by itself, resulting in extra blank space.
                   1545:   \ifdim \wd0>\itemmax
                   1546:     %
                   1547:     % Make this a paragraph so we get the \parskip glue and wrapping,
                   1548:     % but leave it ragged-right.
                   1549:     \begingroup
                   1550:       \advance\leftskip by-\tableindent
                   1551:       \advance\hsize by\tableindent
                   1552:       \advance\rightskip by0pt plus1fil
                   1553:       \leavevmode\unhbox0\par
                   1554:     \endgroup
                   1555:     %
                   1556:     % We're going to be starting a paragraph, but we don't want the
                   1557:     % \parskip glue -- logically it's part of the @item we just started.
                   1558:     \nobreak \vskip-\parskip
                   1559:     %
                   1560:     % Stop a page break at the \parskip glue coming up.  Unfortunately
                   1561:     % we can't prevent a possible page break at the following
                   1562:     % \baselineskip glue.
                   1563:     \nobreak
                   1564:     \endgroup
                   1565:     \itemxneedsnegativevskipfalse
                   1566:   \else
                   1567:     % The item text fits into the space.  Start a paragraph, so that the
1.1.1.2 ! maekawa  1568:     % following text (if any) will end up on the same line.
1.1       maekawa  1569:     \noindent
1.1.1.2 ! maekawa  1570:     % Do this with kerns and \unhbox so that if there is a footnote in
        !          1571:     % the item text, it can migrate to the main vertical list and
        !          1572:     % eventually be printed.
        !          1573:     \nobreak\kern-\tableindent
        !          1574:     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
        !          1575:     \unhbox0
        !          1576:     \nobreak\kern\dimen0
        !          1577:     \endgroup
        !          1578:     \itemxneedsnegativevskiptrue
1.1       maekawa  1579:   \fi
                   1580: }
                   1581:
                   1582: \def\item{\errmessage{@item while not in a table}}
                   1583: \def\itemx{\errmessage{@itemx while not in a table}}
                   1584: \def\kitem{\errmessage{@kitem while not in a table}}
                   1585: \def\kitemx{\errmessage{@kitemx while not in a table}}
                   1586: \def\xitem{\errmessage{@xitem while not in a table}}
                   1587: \def\xitemx{\errmessage{@xitemx while not in a table}}
                   1588:
1.1.1.2 ! maekawa  1589: % Contains a kludge to get @end[description] to work.
1.1       maekawa  1590: \def\description{\tablez{\dontindex}{1}{}{}{}{}}
                   1591:
1.1.1.2 ! maekawa  1592: % @table, @ftable, @vtable.
1.1       maekawa  1593: \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
                   1594: {\obeylines\obeyspaces%
                   1595: \gdef\tablex #1^^M{%
                   1596: \tabley\dontindex#1        \endtabley}}
                   1597:
                   1598: \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
                   1599: {\obeylines\obeyspaces%
                   1600: \gdef\ftablex #1^^M{%
                   1601: \tabley\fnitemindex#1        \endtabley
                   1602: \def\Eftable{\endgraf\afterenvbreak\endgroup}%
                   1603: \let\Etable=\relax}}
                   1604:
                   1605: \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
                   1606: {\obeylines\obeyspaces%
                   1607: \gdef\vtablex #1^^M{%
                   1608: \tabley\vritemindex#1        \endtabley
                   1609: \def\Evtable{\endgraf\afterenvbreak\endgroup}%
                   1610: \let\Etable=\relax}}
                   1611:
                   1612: \def\dontindex #1{}
                   1613: \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
                   1614: \def\vritemindex #1{\doind {vr}{\code{#1}}}%
                   1615:
                   1616: {\obeyspaces %
                   1617: \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
                   1618: \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
                   1619:
                   1620: \def\tablez #1#2#3#4#5#6{%
                   1621: \aboveenvbreak %
                   1622: \begingroup %
                   1623: \def\Edescription{\Etable}% Necessary kludge.
                   1624: \let\itemindex=#1%
                   1625: \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
                   1626: \ifnum 0#4>0 \tableindent=#4\mil \fi %
                   1627: \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
                   1628: \def\itemfont{#2}%
                   1629: \itemmax=\tableindent %
                   1630: \advance \itemmax by -\itemmargin %
                   1631: \advance \leftskip by \tableindent %
                   1632: \exdentamount=\tableindent
                   1633: \parindent = 0pt
                   1634: \parskip = \smallskipamount
                   1635: \ifdim \parskip=0pt \parskip=2pt \fi%
                   1636: \def\Etable{\endgraf\afterenvbreak\endgroup}%
                   1637: \let\item = \internalBitem %
                   1638: \let\itemx = \internalBitemx %
                   1639: \let\kitem = \internalBkitem %
                   1640: \let\kitemx = \internalBkitemx %
                   1641: \let\xitem = \internalBxitem %
                   1642: \let\xitemx = \internalBxitemx %
                   1643: }
                   1644:
                   1645: % This is the counter used by @enumerate, which is really @itemize
                   1646:
                   1647: \newcount \itemno
                   1648:
                   1649: \def\itemize{\parsearg\itemizezzz}
                   1650:
                   1651: \def\itemizezzz #1{%
1.1.1.2 ! maekawa  1652:   \begingroup % ended by the @end itemize
1.1       maekawa  1653:   \itemizey {#1}{\Eitemize}
                   1654: }
                   1655:
                   1656: \def\itemizey #1#2{%
                   1657: \aboveenvbreak %
                   1658: \itemmax=\itemindent %
                   1659: \advance \itemmax by -\itemmargin %
                   1660: \advance \leftskip by \itemindent %
                   1661: \exdentamount=\itemindent
                   1662: \parindent = 0pt %
                   1663: \parskip = \smallskipamount %
                   1664: \ifdim \parskip=0pt \parskip=2pt \fi%
                   1665: \def#2{\endgraf\afterenvbreak\endgroup}%
                   1666: \def\itemcontents{#1}%
                   1667: \let\item=\itemizeitem}
                   1668:
                   1669: % Set sfcode to normal for the chars that usually have another value.
                   1670: % These are `.?!:;,'
                   1671: \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
                   1672:   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
                   1673:
                   1674: % \splitoff TOKENS\endmark defines \first to be the first token in
                   1675: % TOKENS, and \rest to be the remainder.
                   1676: %
                   1677: \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
                   1678:
                   1679: % Allow an optional argument of an uppercase letter, lowercase letter,
                   1680: % or number, to specify the first label in the enumerated list.  No
                   1681: % argument is the same as `1'.
                   1682: %
                   1683: \def\enumerate{\parsearg\enumeratezzz}
                   1684: \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
                   1685: \def\enumeratey #1 #2\endenumeratey{%
                   1686:   \begingroup % ended by the @end enumerate
                   1687:   %
                   1688:   % If we were given no argument, pretend we were given `1'.
                   1689:   \def\thearg{#1}%
                   1690:   \ifx\thearg\empty \def\thearg{1}\fi
                   1691:   %
                   1692:   % Detect if the argument is a single token.  If so, it might be a
                   1693:   % letter.  Otherwise, the only valid thing it can be is a number.
                   1694:   % (We will always have one token, because of the test we just made.
                   1695:   % This is a good thing, since \splitoff doesn't work given nothing at
                   1696:   % all -- the first parameter is undelimited.)
                   1697:   \expandafter\splitoff\thearg\endmark
                   1698:   \ifx\rest\empty
                   1699:     % Only one token in the argument.  It could still be anything.
                   1700:     % A ``lowercase letter'' is one whose \lccode is nonzero.
                   1701:     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
                   1702:     %   not equal to itself.
                   1703:     % Otherwise, we assume it's a number.
                   1704:     %
                   1705:     % We need the \relax at the end of the \ifnum lines to stop TeX from
                   1706:     % continuing to look for a <number>.
                   1707:     %
                   1708:     \ifnum\lccode\expandafter`\thearg=0\relax
                   1709:       \numericenumerate % a number (we hope)
                   1710:     \else
                   1711:       % It's a letter.
                   1712:       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
                   1713:         \lowercaseenumerate % lowercase letter
                   1714:       \else
                   1715:         \uppercaseenumerate % uppercase letter
                   1716:       \fi
                   1717:     \fi
                   1718:   \else
                   1719:     % Multiple tokens in the argument.  We hope it's a number.
                   1720:     \numericenumerate
                   1721:   \fi
                   1722: }
                   1723:
                   1724: % An @enumerate whose labels are integers.  The starting integer is
                   1725: % given in \thearg.
                   1726: %
                   1727: \def\numericenumerate{%
                   1728:   \itemno = \thearg
                   1729:   \startenumeration{\the\itemno}%
                   1730: }
                   1731:
                   1732: % The starting (lowercase) letter is in \thearg.
                   1733: \def\lowercaseenumerate{%
                   1734:   \itemno = \expandafter`\thearg
                   1735:   \startenumeration{%
                   1736:     % Be sure we're not beyond the end of the alphabet.
                   1737:     \ifnum\itemno=0
                   1738:       \errmessage{No more lowercase letters in @enumerate; get a bigger
                   1739:                   alphabet}%
                   1740:     \fi
                   1741:     \char\lccode\itemno
                   1742:   }%
                   1743: }
                   1744:
                   1745: % The starting (uppercase) letter is in \thearg.
                   1746: \def\uppercaseenumerate{%
                   1747:   \itemno = \expandafter`\thearg
                   1748:   \startenumeration{%
                   1749:     % Be sure we're not beyond the end of the alphabet.
                   1750:     \ifnum\itemno=0
                   1751:       \errmessage{No more uppercase letters in @enumerate; get a bigger
                   1752:                   alphabet}
                   1753:     \fi
                   1754:     \char\uccode\itemno
                   1755:   }%
                   1756: }
                   1757:
                   1758: % Call itemizey, adding a period to the first argument and supplying the
                   1759: % common last two arguments.  Also subtract one from the initial value in
                   1760: % \itemno, since @item increments \itemno.
                   1761: %
                   1762: \def\startenumeration#1{%
                   1763:   \advance\itemno by -1
                   1764:   \itemizey{#1.}\Eenumerate\flushcr
                   1765: }
                   1766:
                   1767: % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
                   1768: % to @enumerate.
                   1769: %
                   1770: \def\alphaenumerate{\enumerate{a}}
                   1771: \def\capsenumerate{\enumerate{A}}
                   1772: \def\Ealphaenumerate{\Eenumerate}
                   1773: \def\Ecapsenumerate{\Eenumerate}
                   1774:
                   1775: % Definition of @item while inside @itemize.
                   1776:
                   1777: \def\itemizeitem{%
                   1778: \advance\itemno by 1
                   1779: {\let\par=\endgraf \smallbreak}%
1.1.1.2 ! maekawa  1780: \ifhmode \errmessage{In hmode at itemizeitem}\fi
1.1       maekawa  1781: {\parskip=0in \hskip 0pt
                   1782: \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
                   1783: \vadjust{\penalty 1200}}%
                   1784: \flushcr}
                   1785:
                   1786: % @multitable macros
                   1787: % Amy Hendrickson, 8/18/94, 3/6/96
                   1788: %
                   1789: % @multitable ... @end multitable will make as many columns as desired.
                   1790: % Contents of each column will wrap at width given in preamble.  Width
                   1791: % can be specified either with sample text given in a template line,
                   1792: % or in percent of \hsize, the current width of text on page.
                   1793:
                   1794: % Table can continue over pages but will only break between lines.
                   1795:
                   1796: % To make preamble:
                   1797: %
1.1.1.2 ! maekawa  1798: % Either define widths of columns in terms of percent of \hsize:
1.1       maekawa  1799: %   @multitable @columnfractions .25 .3 .45
                   1800: %   @item ...
                   1801: %
                   1802: %   Numbers following @columnfractions are the percent of the total
                   1803: %   current hsize to be used for each column. You may use as many
                   1804: %   columns as desired.
                   1805:
1.1.1.2 ! maekawa  1806:
1.1       maekawa  1807: % Or use a template:
                   1808: %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
                   1809: %   @item ...
                   1810: %   using the widest term desired in each column.
                   1811: %
                   1812: % For those who want to use more than one line's worth of words in
                   1813: % the preamble, break the line within one argument and it
                   1814: % will parse correctly, i.e.,
                   1815: %
1.1.1.2 ! maekawa  1816: %     @multitable {Column 1 template} {Column 2 template} {Column 3
1.1       maekawa  1817: %      template}
                   1818: % Not:
1.1.1.2 ! maekawa  1819: %     @multitable {Column 1 template} {Column 2 template}
1.1       maekawa  1820: %      {Column 3 template}
                   1821:
1.1.1.2 ! maekawa  1822: % Each new table line starts with @item, each subsequent new column
1.1       maekawa  1823: % starts with @tab. Empty columns may be produced by supplying @tab's
                   1824: % with nothing between them for as many times as empty columns are needed,
                   1825: % ie, @tab@tab@tab will produce two empty columns.
                   1826:
1.1.1.2 ! maekawa  1827: % @item, @tab, @multitable or @end multitable do not need to be on their
1.1       maekawa  1828: % own lines, but it will not hurt if they are.
                   1829:
                   1830: % Sample multitable:
                   1831:
                   1832: %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
                   1833: %   @item first col stuff @tab second col stuff @tab third col
1.1.1.2 ! maekawa  1834: %   @item
        !          1835: %   first col stuff
        !          1836: %   @tab
        !          1837: %   second col stuff
        !          1838: %   @tab
        !          1839: %   third col
        !          1840: %   @item first col stuff @tab second col stuff
1.1       maekawa  1841: %   @tab Many paragraphs of text may be used in any column.
1.1.1.2 ! maekawa  1842: %
1.1       maekawa  1843: %         They will wrap at the width determined by the template.
                   1844: %   @item@tab@tab This will be in third column.
                   1845: %   @end multitable
                   1846:
                   1847: % Default dimensions may be reset by user.
                   1848: % @multitableparskip is vertical space between paragraphs in table.
                   1849: % @multitableparindent is paragraph indent in table.
                   1850: % @multitablecolmargin is horizontal space to be left between columns.
                   1851: % @multitablelinespace is space to leave between table items, baseline
                   1852: %                                                            to baseline.
                   1853: %   0pt means it depends on current normal line spacing.
1.1.1.2 ! maekawa  1854: %
        !          1855: \newskip\multitableparskip
        !          1856: \newskip\multitableparindent
        !          1857: \newdimen\multitablecolspace
        !          1858: \newskip\multitablelinespace
        !          1859: \multitableparskip=0pt
        !          1860: \multitableparindent=6pt
        !          1861: \multitablecolspace=12pt
        !          1862: \multitablelinespace=0pt
        !          1863:
        !          1864: % Macros used to set up halign preamble:
        !          1865: %
        !          1866: \let\endsetuptable\relax
        !          1867: \def\xendsetuptable{\endsetuptable}
        !          1868: \let\columnfractions\relax
        !          1869: \def\xcolumnfractions{\columnfractions}
        !          1870: \newif\ifsetpercent
        !          1871:
        !          1872: % #1 is the part of the @columnfraction before the decimal point, which
        !          1873: % is presumably either 0 or the empty string (but we don't check, we
        !          1874: % just throw it away).  #2 is the decimal part, which we use as the
        !          1875: % percent of \hsize for this column.
        !          1876: \def\pickupwholefraction#1.#2 {%
        !          1877:   \global\advance\colcount by 1
        !          1878:   \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}%
        !          1879:   \setuptable
        !          1880: }
        !          1881:
        !          1882: \newcount\colcount
        !          1883: \def\setuptable#1{%
        !          1884:   \def\firstarg{#1}%
        !          1885:   \ifx\firstarg\xendsetuptable
        !          1886:     \let\go = \relax
        !          1887:   \else
        !          1888:     \ifx\firstarg\xcolumnfractions
        !          1889:       \global\setpercenttrue
        !          1890:     \else
        !          1891:       \ifsetpercent
        !          1892:          \let\go\pickupwholefraction
        !          1893:       \else
        !          1894:          \global\advance\colcount by 1
        !          1895:          \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator;
        !          1896:                             % typically that is always in the input, anyway.
        !          1897:          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
        !          1898:       \fi
        !          1899:     \fi
        !          1900:     \ifx\go\pickupwholefraction
        !          1901:       % Put the argument back for the \pickupwholefraction call, so
        !          1902:       % we'll always have a period there to be parsed.
        !          1903:       \def\go{\pickupwholefraction#1}%
        !          1904:     \else
        !          1905:       \let\go = \setuptable
        !          1906:     \fi%
        !          1907:   \fi
        !          1908:   \go
        !          1909: }
        !          1910:
        !          1911: % multitable syntax
        !          1912: \def\tab{&\hskip1sp\relax} % 2/2/96
        !          1913:                            % tiny skip here makes sure this column space is
        !          1914:                            % maintained, even if it is never used.
        !          1915:
        !          1916: % @multitable ... @end multitable definitions:
        !          1917: %
        !          1918: \def\multitable{\parsearg\dotable}
        !          1919: \def\dotable#1{\bgroup
        !          1920:   \vskip\parskip
        !          1921:   \let\item\crcr
        !          1922:   \tolerance=9500
        !          1923:   \hbadness=9500
        !          1924:   \setmultitablespacing
        !          1925:   \parskip=\multitableparskip
        !          1926:   \parindent=\multitableparindent
        !          1927:   \overfullrule=0pt
        !          1928:   \global\colcount=0
        !          1929:   \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}%
        !          1930:   %
        !          1931:   % To parse everything between @multitable and @item:
        !          1932:   \setuptable#1 \endsetuptable
        !          1933:   %
        !          1934:   % \everycr will reset column counter, \colcount, at the end of
        !          1935:   % each line. Every column entry will cause \colcount to advance by one.
        !          1936:   % The table preamble
        !          1937:   % looks at the current \colcount to find the correct column width.
        !          1938:   \everycr{\noalign{%
        !          1939:   %
        !          1940:   % \filbreak%% keeps underfull box messages off when table breaks over pages.
        !          1941:   % Maybe so, but it also creates really weird page breaks when the table
        !          1942:   % breaks over pages. Wouldn't \vfil be better?  Wait until the problem
        !          1943:   % manifests itself, so it can be fixed for real --karl.
        !          1944:     \global\colcount=0\relax}}%
        !          1945:   %
        !          1946:   % This preamble sets up a generic column definition, which will
        !          1947:   % be used as many times as user calls for columns.
        !          1948:   % \vtop will set a single line and will also let text wrap and
        !          1949:   % continue for many paragraphs if desired.
        !          1950:   \halign\bgroup&\global\advance\colcount by 1\relax
        !          1951:     \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
        !          1952:   %
        !          1953:   % In order to keep entries from bumping into each other
        !          1954:   % we will add a \leftskip of \multitablecolspace to all columns after
        !          1955:   % the first one.
        !          1956:   %
        !          1957:   % If a template has been used, we will add \multitablecolspace
        !          1958:   % to the width of each template entry.
        !          1959:   %
        !          1960:   % If the user has set preamble in terms of percent of \hsize we will
        !          1961:   % use that dimension as the width of the column, and the \leftskip
        !          1962:   % will keep entries from bumping into each other.  Table will start at
        !          1963:   % left margin and final column will justify at right margin.
        !          1964:   %
        !          1965:   % Make sure we don't inherit \rightskip from the outer environment.
        !          1966:   \rightskip=0pt
        !          1967:   \ifnum\colcount=1
        !          1968:     % The first column will be indented with the surrounding text.
        !          1969:     \advance\hsize by\leftskip
        !          1970:   \else
        !          1971:     \ifsetpercent \else
        !          1972:       % If user has not set preamble in terms of percent of \hsize
        !          1973:       % we will advance \hsize by \multitablecolspace.
        !          1974:       \advance\hsize by \multitablecolspace
        !          1975:     \fi
        !          1976:    % In either case we will make \leftskip=\multitablecolspace:
        !          1977:   \leftskip=\multitablecolspace
        !          1978:   \fi
        !          1979:   % Ignoring space at the beginning and end avoids an occasional spurious
        !          1980:   % blank line, when TeX decides to break the line at the space before the
        !          1981:   % box from the multistrut, so the strut ends up on a line by itself.
        !          1982:   % For example:
        !          1983:   % @multitable @columnfractions .11 .89
        !          1984:   % @item @code{#}
        !          1985:   % @tab Legal holiday which is valid in major parts of the whole country.
        !          1986:   % Is automatically provided with highlighting sequences respectively marking
        !          1987:   % characters.
        !          1988:   \noindent\ignorespaces##\unskip\multistrut}\cr
        !          1989: }
        !          1990:
        !          1991: \def\setmultitablespacing{% test to see if user has set \multitablelinespace.
        !          1992: % If so, do nothing. If not, give it an appropriate dimension based on
        !          1993: % current baselineskip.
        !          1994: \ifdim\multitablelinespace=0pt
        !          1995: %% strut to put in table in case some entry doesn't have descenders,
        !          1996: %% to keep lines equally spaced
        !          1997: \let\multistrut = \strut
        !          1998: %% Test to see if parskip is larger than space between lines of
        !          1999: %% table. If not, do nothing.
        !          2000: %%        If so, set to same dimension as multitablelinespace.
        !          2001: \else
        !          2002: \gdef\multistrut{\vrule height\multitablelinespace depth\dp0
        !          2003: width0pt\relax} \fi
        !          2004: \ifdim\multitableparskip>\multitablelinespace
        !          2005: \global\multitableparskip=\multitablelinespace
        !          2006: \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
        !          2007:                                       %% than skip between lines in the table.
        !          2008: \fi%
        !          2009: \ifdim\multitableparskip=0pt
        !          2010: \global\multitableparskip=\multitablelinespace
        !          2011: \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
        !          2012:                                       %% than skip between lines in the table.
        !          2013: \fi}
        !          2014:
        !          2015:
        !          2016: \message{conditionals,}
        !          2017: % Prevent errors for section commands.
        !          2018: % Used in @ignore and in failing conditionals.
        !          2019: \def\ignoresections{%
        !          2020:   \let\chapter=\relax
        !          2021:   \let\unnumbered=\relax
        !          2022:   \let\top=\relax
        !          2023:   \let\unnumberedsec=\relax
        !          2024:   \let\unnumberedsection=\relax
        !          2025:   \let\unnumberedsubsec=\relax
        !          2026:   \let\unnumberedsubsection=\relax
        !          2027:   \let\unnumberedsubsubsec=\relax
        !          2028:   \let\unnumberedsubsubsection=\relax
        !          2029:   \let\section=\relax
        !          2030:   \let\subsec=\relax
        !          2031:   \let\subsubsec=\relax
        !          2032:   \let\subsection=\relax
        !          2033:   \let\subsubsection=\relax
        !          2034:   \let\appendix=\relax
        !          2035:   \let\appendixsec=\relax
        !          2036:   \let\appendixsection=\relax
        !          2037:   \let\appendixsubsec=\relax
        !          2038:   \let\appendixsubsection=\relax
        !          2039:   \let\appendixsubsubsec=\relax
        !          2040:   \let\appendixsubsubsection=\relax
        !          2041:   \let\contents=\relax
        !          2042:   \let\smallbook=\relax
        !          2043:   \let\titlepage=\relax
        !          2044: }
        !          2045:
        !          2046: % Used in nested conditionals, where we have to parse the Texinfo source
        !          2047: % and so want to turn off most commands, in case they are used
        !          2048: % incorrectly.
        !          2049: %
        !          2050: \def\ignoremorecommands{%
        !          2051:   \let\defcodeindex = \relax
        !          2052:   \let\defcv = \relax
        !          2053:   \let\deffn = \relax
        !          2054:   \let\deffnx = \relax
        !          2055:   \let\defindex = \relax
        !          2056:   \let\defivar = \relax
        !          2057:   \let\defmac = \relax
        !          2058:   \let\defmethod = \relax
        !          2059:   \let\defop = \relax
        !          2060:   \let\defopt = \relax
        !          2061:   \let\defspec = \relax
        !          2062:   \let\deftp = \relax
        !          2063:   \let\deftypefn = \relax
        !          2064:   \let\deftypefun = \relax
        !          2065:   \let\deftypeivar = \relax
        !          2066:   \let\deftypevar = \relax
        !          2067:   \let\deftypevr = \relax
        !          2068:   \let\defun = \relax
        !          2069:   \let\defvar = \relax
        !          2070:   \let\defvr = \relax
        !          2071:   \let\ref = \relax
        !          2072:   \let\xref = \relax
        !          2073:   \let\printindex = \relax
        !          2074:   \let\pxref = \relax
        !          2075:   \let\settitle = \relax
        !          2076:   \let\setchapternewpage = \relax
        !          2077:   \let\setchapterstyle = \relax
        !          2078:   \let\everyheading = \relax
        !          2079:   \let\evenheading = \relax
        !          2080:   \let\oddheading = \relax
        !          2081:   \let\everyfooting = \relax
        !          2082:   \let\evenfooting = \relax
        !          2083:   \let\oddfooting = \relax
        !          2084:   \let\headings = \relax
        !          2085:   \let\include = \relax
        !          2086:   \let\lowersections = \relax
        !          2087:   \let\down = \relax
        !          2088:   \let\raisesections = \relax
        !          2089:   \let\up = \relax
        !          2090:   \let\set = \relax
        !          2091:   \let\clear = \relax
        !          2092:   \let\item = \relax
        !          2093: }
        !          2094:
        !          2095: % Ignore @ignore ... @end ignore.
        !          2096: %
        !          2097: \def\ignore{\doignore{ignore}}
        !          2098:
        !          2099: % Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text.
        !          2100: %
        !          2101: \def\ifinfo{\doignore{ifinfo}}
        !          2102: \def\ifhtml{\doignore{ifhtml}}
        !          2103: \def\ifnottex{\doignore{ifnottex}}
        !          2104: \def\html{\doignore{html}}
        !          2105: \def\menu{\doignore{menu}}
        !          2106: \def\direntry{\doignore{direntry}}
        !          2107:
        !          2108: % @dircategory CATEGORY  -- specify a category of the dir file
        !          2109: % which this file should belong to.  Ignore this in TeX.
        !          2110: \let\dircategory = \comment
        !          2111:
        !          2112: % Ignore text until a line `@end #1'.
        !          2113: %
        !          2114: \def\doignore#1{\begingroup
        !          2115:   % Don't complain about control sequences we have declared \outer.
        !          2116:   \ignoresections
        !          2117:   %
        !          2118:   % Define a command to swallow text until we reach `@end #1'.
        !          2119:   % This @ is a catcode 12 token (that is the normal catcode of @ in
        !          2120:   % this texinfo.tex file).  We change the catcode of @ below to match.
        !          2121:   \long\def\doignoretext##1@end #1{\enddoignore}%
        !          2122:   %
        !          2123:   % Make sure that spaces turn into tokens that match what \doignoretext wants.
        !          2124:   \catcode32 = 10
        !          2125:   %
        !          2126:   % Ignore braces, too, so mismatched braces don't cause trouble.
        !          2127:   \catcode`\{ = 9
        !          2128:   \catcode`\} = 9
        !          2129:   %
        !          2130:   % We must not have @c interpreted as a control sequence.
        !          2131:   \catcode`\@ = 12
        !          2132:   %
        !          2133:   % Make the letter c a comment character so that the rest of the line
        !          2134:   % will be ignored. This way, the document can have (for example)
        !          2135:   %   @c @end ifinfo
        !          2136:   % and the @end ifinfo will be properly ignored.
        !          2137:   % (We've just changed @ to catcode 12.)
        !          2138:   \catcode`\c = 14
        !          2139:   %
        !          2140:   % And now expand that command.
        !          2141:   \doignoretext
        !          2142: }
        !          2143:
        !          2144: % What we do to finish off ignored text.
        !          2145: %
        !          2146: \def\enddoignore{\endgroup\ignorespaces}%
        !          2147:
        !          2148: \newif\ifwarnedobs\warnedobsfalse
        !          2149: \def\obstexwarn{%
        !          2150:   \ifwarnedobs\relax\else
        !          2151:   % We need to warn folks that they may have trouble with TeX 3.0.
        !          2152:   % This uses \immediate\write16 rather than \message to get newlines.
        !          2153:     \immediate\write16{}
        !          2154:     \immediate\write16{WARNING: for users of Unix TeX 3.0!}
        !          2155:     \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
        !          2156:     \immediate\write16{If you are running another version of TeX, relax.}
        !          2157:     \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
        !          2158:     \immediate\write16{  Then upgrade your TeX installation if you can.}
        !          2159:     \immediate\write16{  (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
        !          2160:     \immediate\write16{If you are stuck with version 3.0, run the}
        !          2161:     \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
        !          2162:     \immediate\write16{  to use a workaround.}
        !          2163:     \immediate\write16{}
        !          2164:     \global\warnedobstrue
        !          2165:     \fi
        !          2166: }
        !          2167:
        !          2168: % **In TeX 3.0, setting text in \nullfont hangs tex.  For a
        !          2169: % workaround (which requires the file ``dummy.tfm'' to be installed),
        !          2170: % uncomment the following line:
        !          2171: %%%%%\font\nullfont=dummy\let\obstexwarn=\relax
        !          2172:
        !          2173: % Ignore text, except that we keep track of conditional commands for
        !          2174: % purposes of nesting, up to an `@end #1' command.
        !          2175: %
        !          2176: \def\nestedignore#1{%
        !          2177:   \obstexwarn
        !          2178:   % We must actually expand the ignored text to look for the @end
        !          2179:   % command, so that nested ignore constructs work.  Thus, we put the
        !          2180:   % text into a \vbox and then do nothing with the result.  To minimize
        !          2181:   % the change of memory overflow, we follow the approach outlined on
        !          2182:   % page 401 of the TeXbook: make the current font be a dummy font.
        !          2183:   %
        !          2184:   \setbox0 = \vbox\bgroup
        !          2185:     % Don't complain about control sequences we have declared \outer.
        !          2186:     \ignoresections
        !          2187:     %
        !          2188:     % Define `@end #1' to end the box, which will in turn undefine the
        !          2189:     % @end command again.
        !          2190:     \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
        !          2191:     %
        !          2192:     % We are going to be parsing Texinfo commands.  Most cause no
        !          2193:     % trouble when they are used incorrectly, but some commands do
        !          2194:     % complicated argument parsing or otherwise get confused, so we
        !          2195:     % undefine them.
        !          2196:     %
        !          2197:     % We can't do anything about stray @-signs, unfortunately;
        !          2198:     % they'll produce `undefined control sequence' errors.
        !          2199:     \ignoremorecommands
        !          2200:     %
        !          2201:     % Set the current font to be \nullfont, a TeX primitive, and define
        !          2202:     % all the font commands to also use \nullfont.  We don't use
        !          2203:     % dummy.tfm, as suggested in the TeXbook, because not all sites
        !          2204:     % might have that installed.  Therefore, math mode will still
        !          2205:     % produce output, but that should be an extremely small amount of
        !          2206:     % stuff compared to the main input.
        !          2207:     %
        !          2208:     \nullfont
        !          2209:     \let\tenrm = \nullfont  \let\tenit = \nullfont  \let\tensl = \nullfont
        !          2210:     \let\tenbf = \nullfont  \let\tentt = \nullfont  \let\smallcaps = \nullfont
        !          2211:     \let\tensf = \nullfont
        !          2212:     % Similarly for index fonts (mostly for their use in
        !          2213:     % smallexample)
        !          2214:     \let\indrm = \nullfont  \let\indit = \nullfont  \let\indsl = \nullfont
        !          2215:     \let\indbf = \nullfont  \let\indtt = \nullfont  \let\indsc = \nullfont
        !          2216:     \let\indsf = \nullfont
        !          2217:     %
        !          2218:     % Don't complain when characters are missing from the fonts.
        !          2219:     \tracinglostchars = 0
        !          2220:     %
        !          2221:     % Don't bother to do space factor calculations.
        !          2222:     \frenchspacing
        !          2223:     %
        !          2224:     % Don't report underfull hboxes.
        !          2225:     \hbadness = 10000
        !          2226:     %
        !          2227:     % Do minimal line-breaking.
        !          2228:     \pretolerance = 10000
        !          2229:     %
        !          2230:     % Do not execute instructions in @tex
        !          2231:     \def\tex{\doignore{tex}}%
        !          2232:     % Do not execute macro definitions.
        !          2233:     % `c' is a comment character, so the word `macro' will get cut off.
        !          2234:     \def\macro{\doignore{ma}}%
        !          2235: }
1.1       maekawa  2236:
1.1.1.2 ! maekawa  2237: % @set VAR sets the variable VAR to an empty value.
        !          2238: % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
        !          2239: %
        !          2240: % Since we want to separate VAR from REST-OF-LINE (which might be
        !          2241: % empty), we can't just use \parsearg; we have to insert a space of our
        !          2242: % own to delimit the rest of the line, and then take it out again if we
        !          2243: % didn't need it.  Make sure the catcode of space is correct to avoid
        !          2244: % losing inside @example, for instance.
        !          2245: %
        !          2246: \def\set{\begingroup\catcode` =10
        !          2247:   \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
        !          2248:   \parsearg\setxxx}
        !          2249: \def\setxxx#1{\setyyy#1 \endsetyyy}
        !          2250: \def\setyyy#1 #2\endsetyyy{%
        !          2251:   \def\temp{#2}%
        !          2252:   \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
        !          2253:   \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
        !          2254:   \fi
        !          2255:   \endgroup
        !          2256: }
        !          2257: % Can't use \xdef to pre-expand #2 and save some time, since \temp or
        !          2258: % \next or other control sequences that we've defined might get us into
        !          2259: % an infinite loop. Consider `@set foo @cite{bar}'.
        !          2260: \def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
1.1       maekawa  2261:
1.1.1.2 ! maekawa  2262: % @clear VAR clears (i.e., unsets) the variable VAR.
        !          2263: %
        !          2264: \def\clear{\parsearg\clearxxx}
        !          2265: \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
1.1       maekawa  2266:
1.1.1.2 ! maekawa  2267: % @value{foo} gets the text saved in variable foo.
        !          2268: {
        !          2269:   \catcode`\_ = \active
        !          2270:   %
        !          2271:   % We might end up with active _ or - characters in the argument if
        !          2272:   % we're called from @code, as @code{@value{foo-bar_}}.  So \let any
        !          2273:   % such active characters to their normal equivalents.
        !          2274:   \gdef\value{\begingroup
        !          2275:     \catcode`\-=12 \catcode`\_=12
        !          2276:     \indexbreaks \let_\normalunderscore
        !          2277:     \valuexxx}
        !          2278: }
        !          2279: \def\valuexxx#1{\expandablevalue{#1}\endgroup}
        !          2280:
        !          2281: % We have this subroutine so that we can handle at least some @value's
        !          2282: % properly in indexes (we \let\value to this in \indexdummies).  Ones
        !          2283: % whose names contain - or _ still won't work, but we can't do anything
        !          2284: % about that.  The command has to be fully expandable, since the result
        !          2285: % winds up in the index file.  This means that if the variable's value
        !          2286: % contains other Texinfo commands, it's almost certain it will fail
        !          2287: % (although perhaps we could fix that with sufficient work to do a
        !          2288: % one-level expansion on the result, instead of complete).
        !          2289: %
        !          2290: \def\expandablevalue#1{%
        !          2291:   \expandafter\ifx\csname SET#1\endcsname\relax
        !          2292:     {[No value for ``#1'']}%
        !          2293:   \else
        !          2294:     \csname SET#1\endcsname
        !          2295:   \fi
        !          2296: }
1.1       maekawa  2297:
1.1.1.2 ! maekawa  2298: % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
        !          2299: % with @set.
        !          2300: %
        !          2301: \def\ifset{\parsearg\ifsetxxx}
        !          2302: \def\ifsetxxx #1{%
        !          2303:   \expandafter\ifx\csname SET#1\endcsname\relax
        !          2304:     \expandafter\ifsetfail
        !          2305:   \else
        !          2306:     \expandafter\ifsetsucceed
        !          2307:   \fi
        !          2308: }
        !          2309: \def\ifsetsucceed{\conditionalsucceed{ifset}}
        !          2310: \def\ifsetfail{\nestedignore{ifset}}
        !          2311: \defineunmatchedend{ifset}
1.1       maekawa  2312:
1.1.1.2 ! maekawa  2313: % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
        !          2314: % defined with @set, or has been undefined with @clear.
        !          2315: %
        !          2316: \def\ifclear{\parsearg\ifclearxxx}
        !          2317: \def\ifclearxxx #1{%
        !          2318:   \expandafter\ifx\csname SET#1\endcsname\relax
        !          2319:     \expandafter\ifclearsucceed
1.1       maekawa  2320:   \else
1.1.1.2 ! maekawa  2321:     \expandafter\ifclearfail
        !          2322:   \fi
        !          2323: }
        !          2324: \def\ifclearsucceed{\conditionalsucceed{ifclear}}
        !          2325: \def\ifclearfail{\nestedignore{ifclear}}
        !          2326: \defineunmatchedend{ifclear}
1.1       maekawa  2327:
1.1.1.2 ! maekawa  2328: % @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text
        !          2329: % following, through the first @end iftex (etc.).  Make `@end iftex'
        !          2330: % (etc.) valid only after an @iftex.
        !          2331: %
        !          2332: \def\iftex{\conditionalsucceed{iftex}}
        !          2333: \def\ifnothtml{\conditionalsucceed{ifnothtml}}
        !          2334: \def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
        !          2335: \defineunmatchedend{iftex}
        !          2336: \defineunmatchedend{ifnothtml}
        !          2337: \defineunmatchedend{ifnotinfo}
1.1       maekawa  2338:
1.1.1.2 ! maekawa  2339: % We can't just want to start a group at @iftex (for example) and end it
        !          2340: % at @end iftex, since then @set commands inside the conditional have no
        !          2341: % effect (they'd get reverted at the end of the group).  So we must
        !          2342: % define \Eiftex to redefine itself to be its previous value.  (We can't
        !          2343: % just define it to fail again with an ``unmatched end'' error, since
        !          2344: % the @ifset might be nested.)
        !          2345: %
        !          2346: \def\conditionalsucceed#1{%
        !          2347:   \edef\temp{%
        !          2348:     % Remember the current value of \E#1.
        !          2349:     \let\nece{prevE#1} = \nece{E#1}%
        !          2350:     %
        !          2351:     % At the `@end #1', redefine \E#1 to be its previous value.
        !          2352:     \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
        !          2353:   }%
        !          2354:   \temp
        !          2355: }
1.1       maekawa  2356:
1.1.1.2 ! maekawa  2357: % We need to expand lots of \csname's, but we don't want to expand the
        !          2358: % control sequences after we've constructed them.
        !          2359: %
        !          2360: \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
1.1       maekawa  2361:
1.1.1.2 ! maekawa  2362: % @defininfoenclose.
        !          2363: \let\definfoenclose=\comment
1.1       maekawa  2364:
                   2365:
                   2366: \message{indexing,}
                   2367: % Index generation facilities
                   2368:
                   2369: % Define \newwrite to be identical to plain tex's \newwrite
                   2370: % except not \outer, so it can be used within \newindex.
                   2371: {\catcode`\@=11
                   2372: \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
                   2373:
                   2374: % \newindex {foo} defines an index named foo.
                   2375: % It automatically defines \fooindex such that
                   2376: % \fooindex ...rest of line... puts an entry in the index foo.
                   2377: % It also defines \fooindfile to be the number of the output channel for
1.1.1.2 ! maekawa  2378: % the file that accumulates this index.  The file's extension is foo.
1.1       maekawa  2379: % The name of an index should be no more than 2 characters long
                   2380: % for the sake of vms.
1.1.1.2 ! maekawa  2381: %
        !          2382: \def\newindex#1{%
        !          2383:   \iflinks
        !          2384:     \expandafter\newwrite \csname#1indfile\endcsname
        !          2385:     \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
        !          2386:   \fi
        !          2387:   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
        !          2388:     \noexpand\doindex{#1}}
1.1       maekawa  2389: }
                   2390:
                   2391: % @defindex foo  ==  \newindex{foo}
                   2392:
                   2393: \def\defindex{\parsearg\newindex}
                   2394:
                   2395: % Define @defcodeindex, like @defindex except put all entries in @code.
                   2396:
1.1.1.2 ! maekawa  2397: \def\newcodeindex#1{%
        !          2398:   \iflinks
        !          2399:     \expandafter\newwrite \csname#1indfile\endcsname
        !          2400:     \openout \csname#1indfile\endcsname \jobname.#1
        !          2401:   \fi
        !          2402:   \expandafter\xdef\csname#1index\endcsname{%
        !          2403:     \noexpand\docodeindex{#1}}
1.1       maekawa  2404: }
                   2405:
                   2406: \def\defcodeindex{\parsearg\newcodeindex}
                   2407:
                   2408: % @synindex foo bar    makes index foo feed into index bar.
                   2409: % Do this instead of @defindex foo if you don't want it as a separate index.
1.1.1.2 ! maekawa  2410: % The \closeout helps reduce unnecessary open files; the limit on the
        !          2411: % Acorn RISC OS is a mere 16 files.
        !          2412: \def\synindex#1 #2 {%
        !          2413:   \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
        !          2414:   \expandafter\closeout\csname#1indfile\endcsname
        !          2415:   \expandafter\let\csname#1indfile\endcsname=\synindexfoo
        !          2416:   \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
        !          2417:     \noexpand\doindex{#2}}%
1.1       maekawa  2418: }
                   2419:
                   2420: % @syncodeindex foo bar   similar, but put all entries made for index foo
                   2421: % inside @code.
1.1.1.2 ! maekawa  2422: \def\syncodeindex#1 #2 {%
        !          2423:   \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
        !          2424:   \expandafter\closeout\csname#1indfile\endcsname
        !          2425:   \expandafter\let\csname#1indfile\endcsname=\synindexfoo
        !          2426:   \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
        !          2427:     \noexpand\docodeindex{#2}}%
1.1       maekawa  2428: }
                   2429:
                   2430: % Define \doindex, the driver for all \fooindex macros.
                   2431: % Argument #1 is generated by the calling \fooindex macro,
                   2432: %  and it is "foo", the name of the index.
                   2433:
                   2434: % \doindex just uses \parsearg; it calls \doind for the actual work.
                   2435: % This is because \doind is more useful to call from other macros.
                   2436:
                   2437: % There is also \dosubind {index}{topic}{subtopic}
                   2438: % which makes an entry in a two-level index such as the operation index.
                   2439:
                   2440: \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
                   2441: \def\singleindexer #1{\doind{\indexname}{#1}}
                   2442:
                   2443: % like the previous two, but they put @code around the argument.
                   2444: \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
                   2445: \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
                   2446:
                   2447: \def\indexdummies{%
1.1.1.2 ! maekawa  2448: \def\ { }%
1.1       maekawa  2449: % Take care of the plain tex accent commands.
                   2450: \def\"{\realbackslash "}%
                   2451: \def\`{\realbackslash `}%
                   2452: \def\'{\realbackslash '}%
                   2453: \def\^{\realbackslash ^}%
                   2454: \def\~{\realbackslash ~}%
                   2455: \def\={\realbackslash =}%
                   2456: \def\b{\realbackslash b}%
                   2457: \def\c{\realbackslash c}%
                   2458: \def\d{\realbackslash d}%
                   2459: \def\u{\realbackslash u}%
                   2460: \def\v{\realbackslash v}%
                   2461: \def\H{\realbackslash H}%
                   2462: % Take care of the plain tex special European modified letters.
                   2463: \def\oe{\realbackslash oe}%
                   2464: \def\ae{\realbackslash ae}%
                   2465: \def\aa{\realbackslash aa}%
                   2466: \def\OE{\realbackslash OE}%
                   2467: \def\AE{\realbackslash AE}%
                   2468: \def\AA{\realbackslash AA}%
                   2469: \def\o{\realbackslash o}%
                   2470: \def\O{\realbackslash O}%
                   2471: \def\l{\realbackslash l}%
                   2472: \def\L{\realbackslash L}%
                   2473: \def\ss{\realbackslash ss}%
                   2474: % Take care of texinfo commands likely to appear in an index entry.
1.1.1.2 ! maekawa  2475: % (Must be a way to avoid doing expansion at all, and thus not have to
        !          2476: % laboriously list every single command here.)
        !          2477: \def\@{@}% will be @@ when we switch to @ as escape char.
        !          2478: % Need these in case \tex is in effect and \{ is a \delimiter again.
        !          2479: % But can't use \lbracecmd and \rbracecmd because texindex assumes
        !          2480: % braces and backslashes are used only as delimiters.
        !          2481: \let\{ = \mylbrace
        !          2482: \let\} = \myrbrace
1.1       maekawa  2483: \def\_{{\realbackslash _}}%
                   2484: \def\w{\realbackslash w }%
                   2485: \def\bf{\realbackslash bf }%
1.1.1.2 ! maekawa  2486: %\def\rm{\realbackslash rm }%
1.1       maekawa  2487: \def\sl{\realbackslash sl }%
                   2488: \def\sf{\realbackslash sf}%
                   2489: \def\tt{\realbackslash tt}%
                   2490: \def\gtr{\realbackslash gtr}%
                   2491: \def\less{\realbackslash less}%
                   2492: \def\hat{\realbackslash hat}%
                   2493: \def\TeX{\realbackslash TeX}%
                   2494: \def\dots{\realbackslash dots }%
1.1.1.2 ! maekawa  2495: \def\result{\realbackslash result}%
        !          2496: \def\equiv{\realbackslash equiv}%
        !          2497: \def\expansion{\realbackslash expansion}%
        !          2498: \def\print{\realbackslash print}%
        !          2499: \def\error{\realbackslash error}%
        !          2500: \def\point{\realbackslash point}%
        !          2501: \def\copyright{\realbackslash copyright}%
1.1       maekawa  2502: \def\tclose##1{\realbackslash tclose {##1}}%
                   2503: \def\code##1{\realbackslash code {##1}}%
1.1.1.2 ! maekawa  2504: \def\uref##1{\realbackslash uref {##1}}%
        !          2505: \def\url##1{\realbackslash url {##1}}%
        !          2506: \def\env##1{\realbackslash env {##1}}%
        !          2507: \def\command##1{\realbackslash command {##1}}%
        !          2508: \def\option##1{\realbackslash option {##1}}%
        !          2509: \def\dotless##1{\realbackslash dotless {##1}}%
1.1       maekawa  2510: \def\samp##1{\realbackslash samp {##1}}%
1.1.1.2 ! maekawa  2511: \def\,##1{\realbackslash ,{##1}}%
        !          2512: \def\t##1{\realbackslash t {##1}}%
1.1       maekawa  2513: \def\r##1{\realbackslash r {##1}}%
                   2514: \def\i##1{\realbackslash i {##1}}%
                   2515: \def\b##1{\realbackslash b {##1}}%
1.1.1.2 ! maekawa  2516: \def\sc##1{\realbackslash sc {##1}}%
1.1       maekawa  2517: \def\cite##1{\realbackslash cite {##1}}%
                   2518: \def\key##1{\realbackslash key {##1}}%
                   2519: \def\file##1{\realbackslash file {##1}}%
                   2520: \def\var##1{\realbackslash var {##1}}%
                   2521: \def\kbd##1{\realbackslash kbd {##1}}%
                   2522: \def\dfn##1{\realbackslash dfn {##1}}%
                   2523: \def\emph##1{\realbackslash emph {##1}}%
1.1.1.2 ! maekawa  2524: \def\acronym##1{\realbackslash acronym {##1}}%
        !          2525: %
        !          2526: % Handle some cases of @value -- where the variable name does not
        !          2527: % contain - or _, and the value does not contain any
        !          2528: % (non-fully-expandable) commands.
        !          2529: \let\value = \expandablevalue
        !          2530: %
1.1       maekawa  2531: \unsepspaces
1.1.1.2 ! maekawa  2532: % Turn off macro expansion
        !          2533: \turnoffmacros
1.1       maekawa  2534: }
                   2535:
                   2536: % If an index command is used in an @example environment, any spaces
                   2537: % therein should become regular spaces in the raw index file, not the
                   2538: % expansion of \tie (\\leavevmode \penalty \@M \ ).
                   2539: {\obeyspaces
                   2540:  \gdef\unsepspaces{\obeyspaces\let =\space}}
                   2541:
                   2542: % \indexnofonts no-ops all font-change commands.
                   2543: % This is used when outputting the strings to sort the index by.
                   2544: \def\indexdummyfont#1{#1}
                   2545: \def\indexdummytex{TeX}
                   2546: \def\indexdummydots{...}
                   2547:
                   2548: \def\indexnofonts{%
                   2549: % Just ignore accents.
1.1.1.2 ! maekawa  2550: \let\,=\indexdummyfont
1.1       maekawa  2551: \let\"=\indexdummyfont
                   2552: \let\`=\indexdummyfont
                   2553: \let\'=\indexdummyfont
                   2554: \let\^=\indexdummyfont
                   2555: \let\~=\indexdummyfont
                   2556: \let\==\indexdummyfont
                   2557: \let\b=\indexdummyfont
                   2558: \let\c=\indexdummyfont
                   2559: \let\d=\indexdummyfont
                   2560: \let\u=\indexdummyfont
                   2561: \let\v=\indexdummyfont
                   2562: \let\H=\indexdummyfont
1.1.1.2 ! maekawa  2563: \let\dotless=\indexdummyfont
1.1       maekawa  2564: % Take care of the plain tex special European modified letters.
                   2565: \def\oe{oe}%
                   2566: \def\ae{ae}%
                   2567: \def\aa{aa}%
                   2568: \def\OE{OE}%
                   2569: \def\AE{AE}%
                   2570: \def\AA{AA}%
                   2571: \def\o{o}%
                   2572: \def\O{O}%
                   2573: \def\l{l}%
                   2574: \def\L{L}%
                   2575: \def\ss{ss}%
                   2576: \let\w=\indexdummyfont
                   2577: \let\t=\indexdummyfont
                   2578: \let\r=\indexdummyfont
                   2579: \let\i=\indexdummyfont
                   2580: \let\b=\indexdummyfont
                   2581: \let\emph=\indexdummyfont
                   2582: \let\strong=\indexdummyfont
                   2583: \let\cite=\indexdummyfont
                   2584: \let\sc=\indexdummyfont
                   2585: %Don't no-op \tt, since it isn't a user-level command
                   2586: % and is used in the definitions of the active chars like <, >, |...
                   2587: %\let\tt=\indexdummyfont
                   2588: \let\tclose=\indexdummyfont
                   2589: \let\code=\indexdummyfont
1.1.1.2 ! maekawa  2590: \let\url=\indexdummyfont
        !          2591: \let\uref=\indexdummyfont
        !          2592: \let\env=\indexdummyfont
        !          2593: \let\command=\indexdummyfont
        !          2594: \let\option=\indexdummyfont
1.1       maekawa  2595: \let\file=\indexdummyfont
                   2596: \let\samp=\indexdummyfont
                   2597: \let\kbd=\indexdummyfont
                   2598: \let\key=\indexdummyfont
                   2599: \let\var=\indexdummyfont
                   2600: \let\TeX=\indexdummytex
                   2601: \let\dots=\indexdummydots
1.1.1.2 ! maekawa  2602: \def\@{@}%
1.1       maekawa  2603: }
                   2604:
                   2605: % To define \realbackslash, we must make \ not be an escape.
                   2606: % We must first make another character (@) an escape
                   2607: % so we do not become unable to do a definition.
                   2608:
                   2609: {\catcode`\@=0 \catcode`\\=\other
1.1.1.2 ! maekawa  2610:  @gdef@realbackslash{\}}
1.1       maekawa  2611:
                   2612: \let\indexbackslash=0  %overridden during \printindex.
1.1.1.2 ! maekawa  2613: \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
1.1       maekawa  2614:
1.1.1.2 ! maekawa  2615: % For \ifx comparisons.
        !          2616: \def\emptymacro{\empty}
        !          2617:
        !          2618: % Most index entries go through here, but \dosubind is the general case.
        !          2619: %
        !          2620: \def\doind#1#2{\dosubind{#1}{#2}\empty}
        !          2621:
        !          2622: % Workhorse for all \fooindexes.
        !          2623: % #1 is name of index, #2 is stuff to put there, #3 is subentry --
        !          2624: % \empty if called from \doind, as we usually are.  The main exception
        !          2625: % is with defuns, which call us directly.
        !          2626: %
        !          2627: \def\dosubind#1#2#3{%
        !          2628:   % Put the index entry in the margin if desired.
        !          2629:   \ifx\SETmarginindex\relax\else
        !          2630:     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
        !          2631:   \fi
        !          2632:   {%
        !          2633:     \count255=\lastpenalty
        !          2634:     {%
        !          2635:       \indexdummies % Must do this here, since \bf, etc expand at this stage
        !          2636:       \escapechar=`\\
        !          2637:       {%
        !          2638:         \let\folio = 0% We will expand all macros now EXCEPT \folio.
        !          2639:         \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
        !          2640:         % so it will be output as is; and it will print as backslash.
        !          2641:         %
        !          2642:         \def\thirdarg{#3}%
        !          2643:         %
        !          2644:         % If third arg is present, precede it with space in sort key.
        !          2645:         \ifx\thirdarg\emptymacro
        !          2646:           \let\subentry = \empty
        !          2647:         \else
        !          2648:           \def\subentry{ #3}%
        !          2649:         \fi
        !          2650:         %
        !          2651:         % First process the index entry with all font commands turned
        !          2652:         % off to get the string to sort by.
        !          2653:         {\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
        !          2654:         %
        !          2655:         % Now the real index entry with the fonts.
        !          2656:         \toks0 = {#2}%
        !          2657:         %
        !          2658:         % If third (subentry) arg is present, add it to the index
        !          2659:         % string.  And include a space.
        !          2660:         \ifx\thirdarg\emptymacro \else
        !          2661:           \toks0 = \expandafter{\the\toks0 \space #3}%
        !          2662:         \fi
        !          2663:         %
        !          2664:         % Set up the complete index entry, with both the sort key
        !          2665:         % and the original text, including any font commands.  We write
        !          2666:         % three arguments to \entry to the .?? file, texindex reduces to
        !          2667:         % two when writing the .??s sorted result.
        !          2668:         \edef\temp{%
        !          2669:           \write\csname#1indfile\endcsname{%
        !          2670:             \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
        !          2671:         }%
        !          2672:         %
        !          2673:         % If a skip is the last thing on the list now, preserve it
        !          2674:         % by backing up by \lastskip, doing the \write, then inserting
        !          2675:         % the skip again.  Otherwise, the whatsit generated by the
        !          2676:         % \write will make \lastskip zero.  The result is that sequences
        !          2677:         % like this:
        !          2678:         % @end defun
        !          2679:         % @tindex whatever
        !          2680:         % @defun ...
        !          2681:         % will have extra space inserted, because the \medbreak in the
        !          2682:         % start of the @defun won't see the skip inserted by the @end of
        !          2683:         % the previous defun.
        !          2684:         %
        !          2685:         % But don't do any of this if we're not in vertical mode.  We
        !          2686:         % don't want to do a \vskip and prematurely end a paragraph.
        !          2687:         %
        !          2688:         % Avoid page breaks due to these extra skips, too.
        !          2689:         %
        !          2690:         \iflinks
        !          2691:           \ifvmode
        !          2692:             \skip0 = \lastskip
        !          2693:             \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
        !          2694:           \fi
        !          2695:           %
        !          2696:           \temp % do the write
        !          2697:           %
        !          2698:           %
        !          2699:           \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
        !          2700:         \fi
        !          2701:       }%
        !          2702:     }%
        !          2703:     \penalty\count255
        !          2704:   }%
        !          2705: }
1.1       maekawa  2706:
                   2707: % The index entry written in the file actually looks like
                   2708: %  \entry {sortstring}{page}{topic}
                   2709: % or
                   2710: %  \entry {sortstring}{page}{topic}{subtopic}
                   2711: % The texindex program reads in these files and writes files
                   2712: % containing these kinds of lines:
                   2713: %  \initial {c}
                   2714: %     before the first topic whose initial is c
                   2715: %  \entry {topic}{pagelist}
                   2716: %     for a topic that is used without subtopics
                   2717: %  \primary {topic}
                   2718: %     for the beginning of a topic that is used with subtopics
                   2719: %  \secondary {subtopic}{pagelist}
                   2720: %     for each subtopic.
                   2721:
                   2722: % Define the user-accessible indexing commands
                   2723: % @findex, @vindex, @kindex, @cindex.
                   2724:
                   2725: \def\findex {\fnindex}
                   2726: \def\kindex {\kyindex}
                   2727: \def\cindex {\cpindex}
                   2728: \def\vindex {\vrindex}
                   2729: \def\tindex {\tpindex}
                   2730: \def\pindex {\pgindex}
                   2731:
                   2732: \def\cindexsub {\begingroup\obeylines\cindexsub}
                   2733: {\obeylines %
                   2734: \gdef\cindexsub "#1" #2^^M{\endgroup %
                   2735: \dosubind{cp}{#2}{#1}}}
                   2736:
                   2737: % Define the macros used in formatting output of the sorted index material.
                   2738:
1.1.1.2 ! maekawa  2739: % @printindex causes a particular index (the ??s file) to get printed.
        !          2740: % It does not print any chapter heading (usually an @unnumbered).
        !          2741: %
1.1       maekawa  2742: \def\printindex{\parsearg\doprintindex}
1.1.1.2 ! maekawa  2743: \def\doprintindex#1{\begingroup
        !          2744:   \dobreak \chapheadingskip{10000}%
1.1       maekawa  2745:   %
1.1.1.2 ! maekawa  2746:   \indexfonts \rm
        !          2747:   \tolerance = 9500
        !          2748:   \indexbreaks
1.1       maekawa  2749:   %
                   2750:   % See if the index file exists and is nonempty.
1.1.1.2 ! maekawa  2751:   % Change catcode of @ here so that if the index file contains
        !          2752:   % \initial {@}
        !          2753:   % as its first line, TeX doesn't complain about mismatched braces
        !          2754:   % (because it thinks @} is a control sequence).
        !          2755:   \catcode`\@ = 11
1.1       maekawa  2756:   \openin 1 \jobname.#1s
                   2757:   \ifeof 1
                   2758:     % \enddoublecolumns gets confused if there is no text in the index,
                   2759:     % and it loses the chapter title and the aux file entries for the
                   2760:     % index.  The easiest way to prevent this problem is to make sure
                   2761:     % there is some text.
1.1.1.2 ! maekawa  2762:     \putwordIndexNonexistent
        !          2763:   \else
1.1       maekawa  2764:     %
                   2765:     % If the index file exists but is empty, then \openin leaves \ifeof
                   2766:     % false.  We have to make TeX try to read something from the file, so
                   2767:     % it can discover if there is anything in it.
                   2768:     \read 1 to \temp
                   2769:     \ifeof 1
1.1.1.2 ! maekawa  2770:       \putwordIndexIsEmpty
1.1       maekawa  2771:     \else
1.1.1.2 ! maekawa  2772:       % Index files are almost Texinfo source, but we use \ as the escape
        !          2773:       % character.  It would be better to use @, but that's too big a change
        !          2774:       % to make right now.
        !          2775:       \def\indexbackslash{\rawbackslashxx}%
        !          2776:       \catcode`\\ = 0
        !          2777:       \escapechar = `\\
        !          2778:       \begindoublecolumns
1.1       maekawa  2779:       \input \jobname.#1s
1.1.1.2 ! maekawa  2780:       \enddoublecolumns
1.1       maekawa  2781:     \fi
                   2782:   \fi
                   2783:   \closein 1
1.1.1.2 ! maekawa  2784: \endgroup}
1.1       maekawa  2785:
                   2786: % These macros are used by the sorted index file itself.
                   2787: % Change them to control the appearance of the index.
                   2788:
1.1.1.2 ! maekawa  2789: \def\initial#1{{%
        !          2790:   % Some minor font changes for the special characters.
        !          2791:   \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
        !          2792:   %
        !          2793:   % Remove any glue we may have, we'll be inserting our own.
        !          2794:   \removelastskip
        !          2795:   %
        !          2796:   % We like breaks before the index initials, so insert a bonus.
        !          2797:   \penalty -300
        !          2798:   %
        !          2799:   % Typeset the initial.  Making this add up to a whole number of
        !          2800:   % baselineskips increases the chance of the dots lining up from column
        !          2801:   % to column.  It still won't often be perfect, because of the stretch
        !          2802:   % we need before each entry, but it's better.
        !          2803:   %
        !          2804:   % No shrink because it confuses \balancecolumns.
        !          2805:   \vskip 1.67\baselineskip plus .5\baselineskip
        !          2806:   \leftline{\secbf #1}%
        !          2807:   \vskip .33\baselineskip plus .1\baselineskip
        !          2808:   %
        !          2809:   % Do our best not to break after the initial.
        !          2810:   \nobreak
        !          2811: }}
1.1       maekawa  2812:
                   2813: % This typesets a paragraph consisting of #1, dot leaders, and then #2
                   2814: % flush to the right margin.  It is used for index and table of contents
                   2815: % entries.  The paragraph is indented by \leftskip.
                   2816: %
1.1.1.2 ! maekawa  2817: \def\entry#1#2{\begingroup
1.1       maekawa  2818:   %
                   2819:   % Start a new paragraph if necessary, so our assignments below can't
                   2820:   % affect previous text.
                   2821:   \par
                   2822:   %
                   2823:   % Do not fill out the last line with white space.
                   2824:   \parfillskip = 0in
                   2825:   %
                   2826:   % No extra space above this paragraph.
                   2827:   \parskip = 0in
                   2828:   %
                   2829:   % Do not prefer a separate line ending with a hyphen to fewer lines.
                   2830:   \finalhyphendemerits = 0
                   2831:   %
                   2832:   % \hangindent is only relevant when the entry text and page number
                   2833:   % don't both fit on one line.  In that case, bob suggests starting the
                   2834:   % dots pretty far over on the line.  Unfortunately, a large
                   2835:   % indentation looks wrong when the entry text itself is broken across
                   2836:   % lines.  So we use a small indentation and put up with long leaders.
                   2837:   %
                   2838:   % \hangafter is reset to 1 (which is the value we want) at the start
                   2839:   % of each paragraph, so we need not do anything with that.
1.1.1.2 ! maekawa  2840:   \hangindent = 2em
1.1       maekawa  2841:   %
                   2842:   % When the entry text needs to be broken, just fill out the first line
                   2843:   % with blank space.
                   2844:   \rightskip = 0pt plus1fil
                   2845:   %
1.1.1.2 ! maekawa  2846:   % A bit of stretch before each entry for the benefit of balancing columns.
        !          2847:   \vskip 0pt plus1pt
        !          2848:   %
1.1       maekawa  2849:   % Start a ``paragraph'' for the index entry so the line breaking
                   2850:   % parameters we've set above will have an effect.
                   2851:   \noindent
                   2852:   %
                   2853:   % Insert the text of the index entry.  TeX will do line-breaking on it.
                   2854:   #1%
                   2855:   % The following is kludged to not output a line of dots in the index if
                   2856:   % there are no page numbers.  The next person who breaks this will be
                   2857:   % cursed by a Unix daemon.
                   2858:   \def\tempa{{\rm }}%
                   2859:   \def\tempb{#2}%
                   2860:   \edef\tempc{\tempa}%
                   2861:   \edef\tempd{\tempb}%
                   2862:   \ifx\tempc\tempd\ \else%
                   2863:     %
                   2864:     % If we must, put the page number on a line of its own, and fill out
                   2865:     % this line with blank space.  (The \hfil is overwhelmed with the
                   2866:     % fill leaders glue in \indexdotfill if the page number does fit.)
                   2867:     \hfil\penalty50
                   2868:     \null\nobreak\indexdotfill % Have leaders before the page number.
                   2869:     %
                   2870:     % The `\ ' here is removed by the implicit \unskip that TeX does as
                   2871:     % part of (the primitive) \par.  Without it, a spurious underfull
                   2872:     % \hbox ensues.
                   2873:     \ #2% The page number ends the paragraph.
                   2874:   \fi%
                   2875:   \par
                   2876: \endgroup}
                   2877:
                   2878: % Like \dotfill except takes at least 1 em.
                   2879: \def\indexdotfill{\cleaders
                   2880:   \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
                   2881:
                   2882: \def\primary #1{\line{#1\hfil}}
                   2883:
                   2884: \newskip\secondaryindent \secondaryindent=0.5cm
                   2885:
                   2886: \def\secondary #1#2{
                   2887: {\parfillskip=0in \parskip=0in
                   2888: \hangindent =1in \hangafter=1
                   2889: \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
                   2890: }}
                   2891:
1.1.1.2 ! maekawa  2892: % Define two-column mode, which we use to typeset indexes.
        !          2893: % Adapted from the TeXbook, page 416, which is to say,
        !          2894: % the manmac.tex format used to print the TeXbook itself.
        !          2895: \catcode`\@=11
1.1       maekawa  2896:
                   2897: \newbox\partialpage
                   2898: \newdimen\doublecolumnhsize
                   2899:
1.1.1.2 ! maekawa  2900: \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
1.1       maekawa  2901:   % Grab any single-column material above us.
1.1.1.2 ! maekawa  2902:   \output = {%
        !          2903:     %
        !          2904:     % Here is a possibility not foreseen in manmac: if we accumulate a
        !          2905:     % whole lot of material, we might end up calling this \output
        !          2906:     % routine twice in a row (see the doublecol-lose test, which is
        !          2907:     % essentially a couple of indexes with @setchapternewpage off).  In
        !          2908:     % that case we just ship out what is in \partialpage with the normal
        !          2909:     % output routine.  Generally, \partialpage will be empty when this
        !          2910:     % runs and this will be a no-op.  See the indexspread.tex test case.
        !          2911:     \ifvoid\partialpage \else
        !          2912:       \onepageout{\pagecontents\partialpage}%
        !          2913:     \fi
        !          2914:     %
        !          2915:     \global\setbox\partialpage = \vbox{%
        !          2916:       % Unvbox the main output page.
        !          2917:       \unvbox\PAGE
        !          2918:       \kern-\topskip \kern\baselineskip
        !          2919:     }%
        !          2920:   }%
        !          2921:   \eject % run that output routine to set \partialpage
1.1       maekawa  2922:   %
1.1.1.2 ! maekawa  2923:   % Use the double-column output routine for subsequent pages.
        !          2924:   \output = {\doublecolumnout}%
1.1       maekawa  2925:   %
                   2926:   % Change the page size parameters.  We could do this once outside this
                   2927:   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
                   2928:   % format, but then we repeat the same computation.  Repeating a couple
                   2929:   % of assignments once per index is clearly meaningless for the
1.1.1.2 ! maekawa  2930:   % execution time, so we may as well do it in one place.
1.1       maekawa  2931:   %
                   2932:   % First we halve the line length, less a little for the gutter between
                   2933:   % the columns.  We compute the gutter based on the line length, so it
                   2934:   % changes automatically with the paper format.  The magic constant
1.1.1.2 ! maekawa  2935:   % below is chosen so that the gutter has the same value (well, +-<1pt)
        !          2936:   % as it did when we hard-coded it.
1.1       maekawa  2937:   %
                   2938:   % We put the result in a separate register, \doublecolumhsize, so we
                   2939:   % can restore it in \pagesofar, after \hsize itself has (potentially)
                   2940:   % been clobbered.
                   2941:   %
                   2942:   \doublecolumnhsize = \hsize
                   2943:     \advance\doublecolumnhsize by -.04154\hsize
                   2944:     \divide\doublecolumnhsize by 2
                   2945:   \hsize = \doublecolumnhsize
                   2946:   %
                   2947:   % Double the \vsize as well.  (We don't need a separate register here,
                   2948:   % since nobody clobbers \vsize.)
1.1.1.2 ! maekawa  2949:   \advance\vsize by -\ht\partialpage
1.1       maekawa  2950:   \vsize = 2\vsize
                   2951: }
                   2952:
1.1.1.2 ! maekawa  2953: % The double-column output routine for all double-column pages except
        !          2954: % the last.
        !          2955: %
1.1       maekawa  2956: \def\doublecolumnout{%
1.1.1.2 ! maekawa  2957:   \splittopskip=\topskip \splitmaxdepth=\maxdepth
        !          2958:   % Get the available space for the double columns -- the normal
        !          2959:   % (undoubled) page height minus any material left over from the
        !          2960:   % previous page.
        !          2961:   \dimen@ = \vsize
        !          2962:   \divide\dimen@ by 2
        !          2963:   %
        !          2964:   % box0 will be the left-hand column, box2 the right.
        !          2965:   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
        !          2966:   \onepageout\pagesofar
        !          2967:   \unvbox255
        !          2968:   \penalty\outputpenalty
        !          2969: }
        !          2970: \def\pagesofar{%
        !          2971:   % Re-output the contents of the output page -- any previous material,
        !          2972:   % followed by the two boxes we just split, in box0 and box2.
        !          2973:   \unvbox\partialpage
        !          2974:   %
        !          2975:   \hsize = \doublecolumnhsize
        !          2976:   \wd0=\hsize \wd2=\hsize
        !          2977:   \hbox to\pagewidth{\box0\hfil\box2}%
        !          2978: }
        !          2979: \def\enddoublecolumns{%
        !          2980:   \output = {%
        !          2981:     % Split the last of the double-column material.  Leave it on the
        !          2982:     % current page, no automatic page break.
        !          2983:     \balancecolumns
        !          2984:     %
        !          2985:     % If we end up splitting too much material for the current page,
        !          2986:     % though, there will be another page break right after this \output
        !          2987:     % invocation ends.  Having called \balancecolumns once, we do not
        !          2988:     % want to call it again.  Therefore, reset \output to its normal
        !          2989:     % definition right away.  (We hope \balancecolumns will never be
        !          2990:     % called on to balance too much material, but if it is, this makes
        !          2991:     % the output somewhat more palatable.)
        !          2992:     \global\output = {\onepageout{\pagecontents\PAGE}}%
        !          2993:   }%
        !          2994:   \eject
        !          2995:   \endgroup % started in \begindoublecolumns
        !          2996:   %
        !          2997:   % \pagegoal was set to the doubled \vsize above, since we restarted
        !          2998:   % the current page.  We're now back to normal single-column
        !          2999:   % typesetting, so reset \pagegoal to the normal \vsize (after the
        !          3000:   % \endgroup where \vsize got restored).
        !          3001:   \pagegoal = \vsize
        !          3002: }
        !          3003: \def\balancecolumns{%
        !          3004:   % Called at the end of the double column material.
        !          3005:   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
        !          3006:   \dimen@ = \ht0
        !          3007:   \advance\dimen@ by \topskip
        !          3008:   \advance\dimen@ by-\baselineskip
        !          3009:   \divide\dimen@ by 2 % target to split to
        !          3010:   %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
        !          3011:   \splittopskip = \topskip
        !          3012:   % Loop until we get a decent breakpoint.
        !          3013:   {%
        !          3014:     \vbadness = 10000
        !          3015:     \loop
        !          3016:       \global\setbox3 = \copy0
        !          3017:       \global\setbox1 = \vsplit3 to \dimen@
        !          3018:     \ifdim\ht3>\dimen@
        !          3019:       \global\advance\dimen@ by 1pt
        !          3020:     \repeat
        !          3021:   }%
        !          3022:   %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
        !          3023:   \setbox0=\vbox to\dimen@{\unvbox1}%
        !          3024:   \setbox2=\vbox to\dimen@{\unvbox3}%
        !          3025:   %
        !          3026:   \pagesofar
1.1       maekawa  3027: }
1.1.1.2 ! maekawa  3028: \catcode`\@ = \other
        !          3029:
1.1       maekawa  3030:
                   3031: \message{sectioning,}
                   3032: % Define chapters, sections, etc.
                   3033:
1.1.1.2 ! maekawa  3034: \newcount\chapno
        !          3035: \newcount\secno        \secno=0
        !          3036: \newcount\subsecno     \subsecno=0
        !          3037: \newcount\subsubsecno  \subsubsecno=0
1.1       maekawa  3038:
                   3039: % This counter is funny since it counts through charcodes of letters A, B, ...
1.1.1.2 ! maekawa  3040: \newcount\appendixno  \appendixno = `\@
        !          3041: \def\appendixletter{\char\appendixno}
1.1       maekawa  3042:
                   3043: % Each @chapter defines this as the name of the chapter.
1.1.1.2 ! maekawa  3044: % page headings and footings can use it.  @section does likewise.
        !          3045: \def\thischapter{}
        !          3046: \def\thissection{}
1.1       maekawa  3047:
                   3048: \newcount\absseclevel % used to calculate proper heading level
                   3049: \newcount\secbase\secbase=0 % @raise/lowersections modify this count
                   3050:
                   3051: % @raisesections: treat @section as chapter, @subsection as section, etc.
                   3052: \def\raisesections{\global\advance\secbase by -1}
                   3053: \let\up=\raisesections % original BFox name
                   3054:
                   3055: % @lowersections: treat @chapter as section, @section as subsection, etc.
                   3056: \def\lowersections{\global\advance\secbase by 1}
                   3057: \let\down=\lowersections % original BFox name
                   3058:
                   3059: % Choose a numbered-heading macro
                   3060: % #1 is heading level if unmodified by @raisesections or @lowersections
                   3061: % #2 is text for heading
                   3062: \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
                   3063: \ifcase\absseclevel
                   3064:   \chapterzzz{#2}
                   3065: \or
                   3066:   \seczzz{#2}
                   3067: \or
                   3068:   \numberedsubseczzz{#2}
                   3069: \or
                   3070:   \numberedsubsubseczzz{#2}
                   3071: \else
                   3072:   \ifnum \absseclevel<0
                   3073:     \chapterzzz{#2}
                   3074:   \else
                   3075:     \numberedsubsubseczzz{#2}
                   3076:   \fi
                   3077: \fi
                   3078: }
                   3079:
                   3080: % like \numhead, but chooses appendix heading levels
                   3081: \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
                   3082: \ifcase\absseclevel
                   3083:   \appendixzzz{#2}
                   3084: \or
                   3085:   \appendixsectionzzz{#2}
                   3086: \or
                   3087:   \appendixsubseczzz{#2}
                   3088: \or
                   3089:   \appendixsubsubseczzz{#2}
                   3090: \else
                   3091:   \ifnum \absseclevel<0
                   3092:     \appendixzzz{#2}
                   3093:   \else
                   3094:     \appendixsubsubseczzz{#2}
                   3095:   \fi
                   3096: \fi
                   3097: }
                   3098:
                   3099: % like \numhead, but chooses numberless heading levels
                   3100: \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
                   3101: \ifcase\absseclevel
                   3102:   \unnumberedzzz{#2}
                   3103: \or
                   3104:   \unnumberedseczzz{#2}
                   3105: \or
                   3106:   \unnumberedsubseczzz{#2}
                   3107: \or
                   3108:   \unnumberedsubsubseczzz{#2}
                   3109: \else
                   3110:   \ifnum \absseclevel<0
                   3111:     \unnumberedzzz{#2}
                   3112:   \else
                   3113:     \unnumberedsubsubseczzz{#2}
                   3114:   \fi
                   3115: \fi
                   3116: }
                   3117:
1.1.1.2 ! maekawa  3118: % @chapter, @appendix, @unnumbered.
1.1       maekawa  3119: \def\thischaptername{No Chapter Title}
                   3120: \outer\def\chapter{\parsearg\chapteryyy}
                   3121: \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
1.1.1.2 ! maekawa  3122: \def\chapterzzz #1{%
1.1       maekawa  3123: \secno=0 \subsecno=0 \subsubsecno=0
1.1.1.2 ! maekawa  3124: \global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
1.1       maekawa  3125: \chapmacro {#1}{\the\chapno}%
                   3126: \gdef\thissection{#1}%
                   3127: \gdef\thischaptername{#1}%
                   3128: % We don't substitute the actual chapter name into \thischapter
                   3129: % because we don't want its macros evaluated now.
                   3130: \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
1.1.1.2 ! maekawa  3131: \toks0 = {#1}%
        !          3132: \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
        !          3133:                                   {\the\chapno}}}%
        !          3134: \temp
        !          3135: \donoderef
1.1       maekawa  3136: \global\let\section = \numberedsec
                   3137: \global\let\subsection = \numberedsubsec
                   3138: \global\let\subsubsection = \numberedsubsubsec
1.1.1.2 ! maekawa  3139: }
1.1       maekawa  3140:
                   3141: \outer\def\appendix{\parsearg\appendixyyy}
                   3142: \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
1.1.1.2 ! maekawa  3143: \def\appendixzzz #1{%
1.1       maekawa  3144: \secno=0 \subsecno=0 \subsubsecno=0
1.1.1.2 ! maekawa  3145: \global\advance \appendixno by 1
        !          3146: \message{\putwordAppendix\space \appendixletter}%
1.1       maekawa  3147: \chapmacro {#1}{\putwordAppendix{} \appendixletter}%
                   3148: \gdef\thissection{#1}%
                   3149: \gdef\thischaptername{#1}%
                   3150: \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
1.1.1.2 ! maekawa  3151: \toks0 = {#1}%
        !          3152: \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
        !          3153:                        {\putwordAppendix{} \appendixletter}}}%
        !          3154: \temp
        !          3155: \appendixnoderef
1.1       maekawa  3156: \global\let\section = \appendixsec
                   3157: \global\let\subsection = \appendixsubsec
                   3158: \global\let\subsubsection = \appendixsubsubsec
1.1.1.2 ! maekawa  3159: }
1.1       maekawa  3160:
                   3161: % @centerchap is like @unnumbered, but the heading is centered.
                   3162: \outer\def\centerchap{\parsearg\centerchapyyy}
                   3163: \def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
                   3164:
1.1.1.2 ! maekawa  3165: % @top is like @unnumbered.
1.1       maekawa  3166: \outer\def\top{\parsearg\unnumberedyyy}
1.1.1.2 ! maekawa  3167:
1.1       maekawa  3168: \outer\def\unnumbered{\parsearg\unnumberedyyy}
                   3169: \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
1.1.1.2 ! maekawa  3170: \def\unnumberedzzz #1{%
1.1       maekawa  3171: \secno=0 \subsecno=0 \subsubsecno=0
                   3172: %
                   3173: % This used to be simply \message{#1}, but TeX fully expands the
                   3174: % argument to \message.  Therefore, if #1 contained @-commands, TeX
                   3175: % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
                   3176: % expanded @cite (which turns out to cause errors because \cite is meant
                   3177: % to be executed, not expanded).
                   3178: %
                   3179: % Anyway, we don't want the fully-expanded definition of @cite to appear
                   3180: % as a result of the \message, we just want `@cite' itself.  We use
                   3181: % \the<toks register> to achieve this: TeX expands \the<toks> only once,
1.1.1.2 ! maekawa  3182: % simply yielding the contents of <toks register>.  (We also do this for
        !          3183: % the toc entries.)
1.1       maekawa  3184: \toks0 = {#1}\message{(\the\toks0)}%
                   3185: %
                   3186: \unnumbchapmacro {#1}%
                   3187: \gdef\thischapter{#1}\gdef\thissection{#1}%
1.1.1.2 ! maekawa  3188: \toks0 = {#1}%
        !          3189: \edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}%
        !          3190: \temp
        !          3191: \unnumbnoderef
1.1       maekawa  3192: \global\let\section = \unnumberedsec
                   3193: \global\let\subsection = \unnumberedsubsec
                   3194: \global\let\subsubsection = \unnumberedsubsubsec
1.1.1.2 ! maekawa  3195: }
1.1       maekawa  3196:
1.1.1.2 ! maekawa  3197: % Sections.
1.1       maekawa  3198: \outer\def\numberedsec{\parsearg\secyyy}
                   3199: \def\secyyy #1{\numhead1{#1}} % normally calls seczzz
1.1.1.2 ! maekawa  3200: \def\seczzz #1{%
1.1       maekawa  3201: \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
                   3202: \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
1.1.1.2 ! maekawa  3203: \toks0 = {#1}%
        !          3204: \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
        !          3205:                                   {\the\chapno}{\the\secno}}}%
        !          3206: \temp
        !          3207: \donoderef
        !          3208: \nobreak
        !          3209: }
1.1       maekawa  3210:
                   3211: \outer\def\appendixsection{\parsearg\appendixsecyyy}
                   3212: \outer\def\appendixsec{\parsearg\appendixsecyyy}
                   3213: \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
1.1.1.2 ! maekawa  3214: \def\appendixsectionzzz #1{%
1.1       maekawa  3215: \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
                   3216: \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
1.1.1.2 ! maekawa  3217: \toks0 = {#1}%
        !          3218: \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
        !          3219:                                   {\appendixletter}{\the\secno}}}%
        !          3220: \temp
        !          3221: \appendixnoderef
        !          3222: \nobreak
        !          3223: }
1.1       maekawa  3224:
                   3225: \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
                   3226: \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
1.1.1.2 ! maekawa  3227: \def\unnumberedseczzz #1{%
1.1       maekawa  3228: \plainsecheading {#1}\gdef\thissection{#1}%
1.1.1.2 ! maekawa  3229: \toks0 = {#1}%
        !          3230: \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}%
        !          3231: \temp
        !          3232: \unnumbnoderef
        !          3233: \nobreak
        !          3234: }
1.1       maekawa  3235:
1.1.1.2 ! maekawa  3236: % Subsections.
1.1       maekawa  3237: \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
                   3238: \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
1.1.1.2 ! maekawa  3239: \def\numberedsubseczzz #1{%
1.1       maekawa  3240: \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
                   3241: \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
1.1.1.2 ! maekawa  3242: \toks0 = {#1}%
        !          3243: \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
        !          3244:                                     {\the\chapno}{\the\secno}{\the\subsecno}}}%
        !          3245: \temp
        !          3246: \donoderef
        !          3247: \nobreak
        !          3248: }
1.1       maekawa  3249:
                   3250: \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
                   3251: \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
1.1.1.2 ! maekawa  3252: \def\appendixsubseczzz #1{%
1.1       maekawa  3253: \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
                   3254: \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
1.1.1.2 ! maekawa  3255: \toks0 = {#1}%
        !          3256: \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
        !          3257:                                 {\appendixletter}{\the\secno}{\the\subsecno}}}%
        !          3258: \temp
        !          3259: \appendixnoderef
        !          3260: \nobreak
        !          3261: }
1.1       maekawa  3262:
                   3263: \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
                   3264: \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
1.1.1.2 ! maekawa  3265: \def\unnumberedsubseczzz #1{%
        !          3266: \plainsubsecheading {#1}\gdef\thissection{#1}%
        !          3267: \toks0 = {#1}%
        !          3268: \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
        !          3269:                                     {\the\toks0}}}%
        !          3270: \temp
        !          3271: \unnumbnoderef
        !          3272: \nobreak
        !          3273: }
1.1       maekawa  3274:
1.1.1.2 ! maekawa  3275: % Subsubsections.
1.1       maekawa  3276: \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
                   3277: \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
1.1.1.2 ! maekawa  3278: \def\numberedsubsubseczzz #1{%
1.1       maekawa  3279: \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
                   3280: \subsubsecheading {#1}
                   3281:   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
1.1.1.2 ! maekawa  3282: \toks0 = {#1}%
        !          3283: \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
        !          3284:   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
        !          3285: \temp
        !          3286: \donoderef
        !          3287: \nobreak
        !          3288: }
1.1       maekawa  3289:
                   3290: \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
                   3291: \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
1.1.1.2 ! maekawa  3292: \def\appendixsubsubseczzz #1{%
1.1       maekawa  3293: \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
                   3294: \subsubsecheading {#1}
                   3295:   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
1.1.1.2 ! maekawa  3296: \toks0 = {#1}%
        !          3297: \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
        !          3298:   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
        !          3299: \temp
        !          3300: \appendixnoderef
        !          3301: \nobreak
        !          3302: }
1.1       maekawa  3303:
                   3304: \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
                   3305: \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
1.1.1.2 ! maekawa  3306: \def\unnumberedsubsubseczzz #1{%
        !          3307: \plainsubsubsecheading {#1}\gdef\thissection{#1}%
        !          3308: \toks0 = {#1}%
        !          3309: \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
        !          3310:                                     {\the\toks0}}}%
        !          3311: \temp
        !          3312: \unnumbnoderef
        !          3313: \nobreak
        !          3314: }
1.1       maekawa  3315:
                   3316: % These are variants which are not "outer", so they can appear in @ifinfo.
                   3317: % Actually, they should now be obsolete; ordinary section commands should work.
                   3318: \def\infotop{\parsearg\unnumberedzzz}
                   3319: \def\infounnumbered{\parsearg\unnumberedzzz}
                   3320: \def\infounnumberedsec{\parsearg\unnumberedseczzz}
                   3321: \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
                   3322: \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
                   3323:
                   3324: \def\infoappendix{\parsearg\appendixzzz}
                   3325: \def\infoappendixsec{\parsearg\appendixseczzz}
                   3326: \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
                   3327: \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
                   3328:
                   3329: \def\infochapter{\parsearg\chapterzzz}
                   3330: \def\infosection{\parsearg\sectionzzz}
                   3331: \def\infosubsection{\parsearg\subsectionzzz}
                   3332: \def\infosubsubsection{\parsearg\subsubsectionzzz}
                   3333:
                   3334: % These macros control what the section commands do, according
                   3335: % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
                   3336: % Define them by default for a numbered chapter.
                   3337: \global\let\section = \numberedsec
                   3338: \global\let\subsection = \numberedsubsec
                   3339: \global\let\subsubsection = \numberedsubsubsec
                   3340:
                   3341: % Define @majorheading, @heading and @subheading
                   3342:
1.1.1.2 ! maekawa  3343: % NOTE on use of \vbox for chapter headings, section headings, and such:
        !          3344: %       1) We use \vbox rather than the earlier \line to permit
        !          3345: %          overlong headings to fold.
        !          3346: %       2) \hyphenpenalty is set to 10000 because hyphenation in a
        !          3347: %          heading is obnoxious; this forbids it.
1.1       maekawa  3348: %       3) Likewise, headings look best if no \parindent is used, and
                   3349: %          if justification is not attempted.  Hence \raggedright.
                   3350:
                   3351:
                   3352: \def\majorheading{\parsearg\majorheadingzzz}
                   3353: \def\majorheadingzzz #1{%
                   3354: {\advance\chapheadingskip by 10pt \chapbreak }%
                   3355: {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
                   3356:                   \parindent=0pt\raggedright
                   3357:                   \rm #1\hfill}}\bigskip \par\penalty 200}
                   3358:
                   3359: \def\chapheading{\parsearg\chapheadingzzz}
                   3360: \def\chapheadingzzz #1{\chapbreak %
                   3361: {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
                   3362:                   \parindent=0pt\raggedright
                   3363:                   \rm #1\hfill}}\bigskip \par\penalty 200}
                   3364:
1.1.1.2 ! maekawa  3365: % @heading, @subheading, @subsubheading.
        !          3366: \def\heading{\parsearg\plainsecheading}
        !          3367: \def\subheading{\parsearg\plainsubsecheading}
        !          3368: \def\subsubheading{\parsearg\plainsubsubsecheading}
1.1       maekawa  3369:
                   3370: % These macros generate a chapter, section, etc. heading only
                   3371: % (including whitespace, linebreaking, etc. around it),
                   3372: % given all the information in convenient, parsed form.
                   3373:
                   3374: %%% Args are the skip and penalty (usually negative)
                   3375: \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
                   3376:
                   3377: \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
                   3378:
                   3379: %%% Define plain chapter starts, and page on/off switching for it
                   3380: % Parameter controlling skip before chapter headings (if needed)
                   3381:
1.1.1.2 ! maekawa  3382: \newskip\chapheadingskip
1.1       maekawa  3383:
                   3384: \def\chapbreak{\dobreak \chapheadingskip {-4000}}
                   3385: \def\chappager{\par\vfill\supereject}
                   3386: \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
                   3387:
                   3388: \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
                   3389:
1.1.1.2 ! maekawa  3390: \def\CHAPPAGoff{%
        !          3391: \global\let\contentsalignmacro = \chappager
1.1       maekawa  3392: \global\let\pchapsepmacro=\chapbreak
                   3393: \global\let\pagealignmacro=\chappager}
                   3394:
1.1.1.2 ! maekawa  3395: \def\CHAPPAGon{%
        !          3396: \global\let\contentsalignmacro = \chappager
1.1       maekawa  3397: \global\let\pchapsepmacro=\chappager
                   3398: \global\let\pagealignmacro=\chappager
                   3399: \global\def\HEADINGSon{\HEADINGSsingle}}
                   3400:
                   3401: \def\CHAPPAGodd{
1.1.1.2 ! maekawa  3402: \global\let\contentsalignmacro = \chapoddpage
1.1       maekawa  3403: \global\let\pchapsepmacro=\chapoddpage
                   3404: \global\let\pagealignmacro=\chapoddpage
                   3405: \global\def\HEADINGSon{\HEADINGSdouble}}
                   3406:
                   3407: \CHAPPAGon
                   3408:
                   3409: \def\CHAPFplain{
                   3410: \global\let\chapmacro=\chfplain
                   3411: \global\let\unnumbchapmacro=\unnchfplain
                   3412: \global\let\centerchapmacro=\centerchfplain}
                   3413:
1.1.1.2 ! maekawa  3414: % Plain chapter opening.
        !          3415: % #1 is the text, #2 the chapter number or empty if unnumbered.
        !          3416: \def\chfplain#1#2{%
1.1       maekawa  3417:   \pchapsepmacro
                   3418:   {%
1.1.1.2 ! maekawa  3419:     \chapfonts \rm
        !          3420:     \def\chapnum{#2}%
        !          3421:     \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
        !          3422:     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
        !          3423:           \hangindent = \wd0 \centerparametersmaybe
        !          3424:           \unhbox0 #1\par}%
1.1       maekawa  3425:   }%
1.1.1.2 ! maekawa  3426:   \nobreak\bigskip % no page break after a chapter title
        !          3427:   \nobreak
1.1       maekawa  3428: }
                   3429:
1.1.1.2 ! maekawa  3430: % Plain opening for unnumbered.
        !          3431: \def\unnchfplain#1{\chfplain{#1}{}}
1.1       maekawa  3432:
1.1.1.2 ! maekawa  3433: % @centerchap -- centered and unnumbered.
        !          3434: \let\centerparametersmaybe = \relax
        !          3435: \def\centerchfplain#1{{%
        !          3436:   \def\centerparametersmaybe{%
        !          3437:     \advance\rightskip by 3\rightskip
        !          3438:     \leftskip = \rightskip
        !          3439:     \parfillskip = 0pt
        !          3440:   }%
        !          3441:   \chfplain{#1}{}%
        !          3442: }}
1.1       maekawa  3443:
                   3444: \CHAPFplain % The default
                   3445:
                   3446: \def\unnchfopen #1{%
                   3447: \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
                   3448:                        \parindent=0pt\raggedright
1.1.1.2 ! maekawa  3449:                        \rm #1\hfill}}\bigskip \par\nobreak
1.1       maekawa  3450: }
                   3451:
                   3452: \def\chfopen #1#2{\chapoddpage {\chapfonts
                   3453: \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
                   3454: \par\penalty 5000 %
                   3455: }
                   3456:
                   3457: \def\centerchfopen #1{%
                   3458: \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
                   3459:                        \parindent=0pt
1.1.1.2 ! maekawa  3460:                        \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
1.1       maekawa  3461: }
                   3462:
                   3463: \def\CHAPFopen{
                   3464: \global\let\chapmacro=\chfopen
                   3465: \global\let\unnumbchapmacro=\unnchfopen
                   3466: \global\let\centerchapmacro=\centerchfopen}
                   3467:
                   3468:
1.1.1.2 ! maekawa  3469: % Section titles.
        !          3470: \newskip\secheadingskip
1.1       maekawa  3471: \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
1.1.1.2 ! maekawa  3472: \def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
        !          3473: \def\plainsecheading#1{\sectionheading{sec}{}{#1}}
        !          3474:
        !          3475: % Subsection titles.
        !          3476: \newskip \subsecheadingskip
        !          3477: \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
        !          3478: \def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
        !          3479: \def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
1.1       maekawa  3480:
1.1.1.2 ! maekawa  3481: % Subsubsection titles.
        !          3482: \let\subsubsecheadingskip = \subsecheadingskip
        !          3483: \let\subsubsecheadingbreak = \subsecheadingbreak
        !          3484: \def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
        !          3485: \def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
1.1       maekawa  3486:
                   3487:
1.1.1.2 ! maekawa  3488: % Print any size section title.
        !          3489: %
        !          3490: % #1 is the section type (sec/subsec/subsubsec), #2 is the section
        !          3491: % number (maybe empty), #3 the text.
        !          3492: \def\sectionheading#1#2#3{%
        !          3493:   {%
        !          3494:     \expandafter\advance\csname #1headingskip\endcsname by \parskip
        !          3495:     \csname #1headingbreak\endcsname
        !          3496:   }%
        !          3497:   {%
        !          3498:     % Switch to the right set of fonts.
        !          3499:     \csname #1fonts\endcsname \rm
        !          3500:     %
        !          3501:     % Only insert the separating space if we have a section number.
        !          3502:     \def\secnum{#2}%
        !          3503:     \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
        !          3504:     %
        !          3505:     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
        !          3506:           \hangindent = \wd0 % zero if no section number
        !          3507:           \unhbox0 #3}%
        !          3508:   }%
        !          3509:   \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
        !          3510: }
1.1       maekawa  3511:
                   3512:
1.1.1.2 ! maekawa  3513: \message{toc,}
        !          3514: \newwrite\tocfile
1.1       maekawa  3515:
1.1.1.2 ! maekawa  3516: % Write an entry to the toc file, opening it if necessary.
        !          3517: % Called from @chapter, etc.  We supply {\folio} at the end of the
        !          3518: % argument, which will end up as the last argument to the \...entry macro.
        !          3519: %
        !          3520: % We open the .toc file here instead of at @setfilename or any other
        !          3521: % given time so that @contents can be put in the document anywhere.
        !          3522: %
        !          3523: \newif\iftocfileopened
        !          3524: \def\writetocentry#1{%
        !          3525:   \iftocfileopened\else
        !          3526:     \immediate\openout\tocfile = \jobname.toc
        !          3527:     \global\tocfileopenedtrue
        !          3528:   \fi
        !          3529:   \iflinks \write\tocfile{#1{\folio}}\fi
        !          3530: }
1.1       maekawa  3531:
                   3532: \newskip\contentsrightmargin \contentsrightmargin=1in
1.1.1.2 ! maekawa  3533: \newcount\savepageno
        !          3534: \newcount\lastnegativepageno \lastnegativepageno = -1
        !          3535:
        !          3536: % Finish up the main text and prepare to read what we've written
        !          3537: % to \tocfile.
        !          3538: %
1.1       maekawa  3539: \def\startcontents#1{%
1.1.1.2 ! maekawa  3540:    % If @setchapternewpage on, and @headings double, the contents should
        !          3541:    % start on an odd page, unlike chapters.  Thus, we maintain
        !          3542:    % \contentsalignmacro in parallel with \pagealignmacro.
        !          3543:    % From: Torbjorn Granlund <tege@matematik.su.se>
        !          3544:    \contentsalignmacro
        !          3545:    \immediate\closeout\tocfile
        !          3546:    %
1.1       maekawa  3547:    % Don't need to put `Contents' or `Short Contents' in the headline.
                   3548:    % It is abundantly clear what they are.
                   3549:    \unnumbchapmacro{#1}\def\thischapter{}%
1.1.1.2 ! maekawa  3550:    \savepageno = \pageno
        !          3551:    \begingroup                  % Set up to handle contents files properly.
1.1       maekawa  3552:       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
1.1.1.2 ! maekawa  3553:       % We can't do this, because then an actual ^ in a section
        !          3554:       % title fails, e.g., @chapter ^ -- exponentiation.  --karl, 9jul97.
        !          3555:       %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
1.1       maekawa  3556:       \raggedbottom             % Worry more about breakpoints than the bottom.
                   3557:       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
1.1.1.2 ! maekawa  3558:       %
        !          3559:       % Roman numerals for page numbers.
        !          3560:       \ifnum \pageno>0 \pageno = \lastnegativepageno \fi
1.1       maekawa  3561: }
                   3562:
                   3563:
                   3564: % Normal (long) toc.
1.1.1.2 ! maekawa  3565: \def\contents{%
        !          3566:    \startcontents{\putwordTOC}%
        !          3567:      \openin 1 \jobname.toc
        !          3568:      \ifeof 1 \else
        !          3569:        \closein 1
        !          3570:        \input \jobname.toc
        !          3571:      \fi
        !          3572:      \vfill \eject
        !          3573:      \contentsalignmacro % in case @setchapternewpage odd is in effect
1.1       maekawa  3574:    \endgroup
1.1.1.2 ! maekawa  3575:    \lastnegativepageno = \pageno
        !          3576:    \pageno = \savepageno
1.1       maekawa  3577: }
                   3578:
                   3579: % And just the chapters.
1.1.1.2 ! maekawa  3580: \def\summarycontents{%
        !          3581:    \startcontents{\putwordShortTOC}%
1.1       maekawa  3582:       %
                   3583:       \let\chapentry = \shortchapentry
                   3584:       \let\unnumbchapentry = \shortunnumberedentry
                   3585:       % We want a true roman here for the page numbers.
                   3586:       \secfonts
                   3587:       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
                   3588:       \rm
1.1.1.2 ! maekawa  3589:       \hyphenpenalty = 10000
1.1       maekawa  3590:       \advance\baselineskip by 1pt % Open it up a little.
                   3591:       \def\secentry ##1##2##3##4{}
                   3592:       \def\unnumbsecentry ##1##2{}
                   3593:       \def\subsecentry ##1##2##3##4##5{}
                   3594:       \def\unnumbsubsecentry ##1##2{}
                   3595:       \def\subsubsecentry ##1##2##3##4##5##6{}
                   3596:       \def\unnumbsubsubsecentry ##1##2{}
1.1.1.2 ! maekawa  3597:       \openin 1 \jobname.toc
        !          3598:       \ifeof 1 \else
        !          3599:         \closein 1
        !          3600:         \input \jobname.toc
        !          3601:       \fi
        !          3602:      \vfill \eject
        !          3603:      \contentsalignmacro % in case @setchapternewpage odd is in effect
1.1       maekawa  3604:    \endgroup
1.1.1.2 ! maekawa  3605:    \lastnegativepageno = \pageno
        !          3606:    \pageno = \savepageno
1.1       maekawa  3607: }
                   3608: \let\shortcontents = \summarycontents
                   3609:
                   3610: % These macros generate individual entries in the table of contents.
                   3611: % The first argument is the chapter or section name.
                   3612: % The last argument is the page number.
                   3613: % The arguments in between are the chapter number, section number, ...
                   3614:
                   3615: % Chapter-level things, for both the long and short contents.
                   3616: \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
                   3617:
                   3618: % See comments in \dochapentry re vbox and related settings
                   3619: \def\shortchapentry#1#2#3{%
                   3620:   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
                   3621: }
                   3622:
                   3623: % Typeset the label for a chapter or appendix for the short contents.
                   3624: % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
                   3625: % We could simplify the code here by writing out an \appendixentry
                   3626: % command in the toc file for appendices, instead of using \chapentry
                   3627: % for both, but it doesn't seem worth it.
                   3628: \setbox0 = \hbox{\shortcontrm \putwordAppendix }
                   3629: \newdimen\shortappendixwidth \shortappendixwidth = \wd0
                   3630:
                   3631: \def\shortchaplabel#1{%
                   3632:   % We typeset #1 in a box of constant width, regardless of the text of
                   3633:   % #1, so the chapter titles will come out aligned.
                   3634:   \setbox0 = \hbox{#1}%
                   3635:   \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
                   3636:   %
                   3637:   % This space should be plenty, since a single number is .5em, and the
                   3638:   % widest letter (M) is 1em, at least in the Computer Modern fonts.
                   3639:   % (This space doesn't include the extra space that gets added after
1.1.1.2 ! maekawa  3640:   % the label; that gets put in by \shortchapentry above.)
1.1       maekawa  3641:   \advance\dimen0 by 1.1em
                   3642:   \hbox to \dimen0{#1\hfil}%
                   3643: }
                   3644:
                   3645: \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
                   3646: \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
                   3647:
                   3648: % Sections.
                   3649: \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
                   3650: \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
                   3651:
                   3652: % Subsections.
                   3653: \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
                   3654: \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
                   3655:
                   3656: % And subsubsections.
                   3657: \def\subsubsecentry#1#2#3#4#5#6{%
                   3658:   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
                   3659: \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
                   3660:
                   3661: % This parameter controls the indentation of the various levels.
                   3662: \newdimen\tocindent \tocindent = 3pc
                   3663:
                   3664: % Now for the actual typesetting. In all these, #1 is the text and #2 is the
                   3665: % page number.
                   3666: %
1.1.1.2 ! maekawa  3667: % If the toc has to be broken over pages, we want it to be at chapters
1.1       maekawa  3668: % if at all possible; hence the \penalty.
                   3669: \def\dochapentry#1#2{%
1.1.1.2 ! maekawa  3670:    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
1.1       maekawa  3671:    \begingroup
                   3672:      \chapentryfonts
                   3673:      \tocentry{#1}{\dopageno{#2}}%
                   3674:    \endgroup
1.1.1.2 ! maekawa  3675:    \nobreak\vskip .25\baselineskip plus.1\baselineskip
1.1       maekawa  3676: }
                   3677:
                   3678: \def\dosecentry#1#2{\begingroup
                   3679:   \secentryfonts \leftskip=\tocindent
                   3680:   \tocentry{#1}{\dopageno{#2}}%
                   3681: \endgroup}
                   3682:
                   3683: \def\dosubsecentry#1#2{\begingroup
                   3684:   \subsecentryfonts \leftskip=2\tocindent
                   3685:   \tocentry{#1}{\dopageno{#2}}%
                   3686: \endgroup}
                   3687:
                   3688: \def\dosubsubsecentry#1#2{\begingroup
                   3689:   \subsubsecentryfonts \leftskip=3\tocindent
                   3690:   \tocentry{#1}{\dopageno{#2}}%
                   3691: \endgroup}
                   3692:
                   3693: % Final typesetting of a toc entry; we use the same \entry macro as for
                   3694: % the index entries, but we want to suppress hyphenation here.  (We
                   3695: % can't do that in the \entry macro, since index entries might consist
                   3696: % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
                   3697: \def\tocentry#1#2{\begingroup
1.1.1.2 ! maekawa  3698:   \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks
        !          3699:   % Do not use \turnoffactive in these arguments.  Since the toc is
        !          3700:   % typeset in cmr, so characters such as _ would come out wrong; we
        !          3701:   % have to do the usual translation tricks.
        !          3702:   \entry{#1}{#2}%
1.1       maekawa  3703: \endgroup}
                   3704:
                   3705: % Space between chapter (or whatever) number and the title.
                   3706: \def\labelspace{\hskip1em \relax}
                   3707:
                   3708: \def\dopageno#1{{\rm #1}}
                   3709: \def\doshortpageno#1{{\rm #1}}
                   3710:
                   3711: \def\chapentryfonts{\secfonts \rm}
                   3712: \def\secentryfonts{\textfonts}
                   3713: \let\subsecentryfonts = \textfonts
                   3714: \let\subsubsecentryfonts = \textfonts
                   3715:
                   3716:
                   3717: \message{environments,}
                   3718:
                   3719: % Since these characters are used in examples, it should be an even number of
                   3720: % \tt widths. Each \tt character is 1en, so two makes it 1em.
                   3721: % Furthermore, these definitions must come after we define our fonts.
                   3722: \newbox\dblarrowbox    \newbox\longdblarrowbox
                   3723: \newbox\pushcharbox    \newbox\bullbox
                   3724: \newbox\equivbox       \newbox\errorbox
                   3725:
                   3726: %{\tentt
                   3727: %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
                   3728: %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
                   3729: %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
                   3730: %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
                   3731: % Adapted from the manmac format (p.420 of TeXbook)
                   3732: %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
                   3733: %                                      depth .1ex\hfil}
                   3734: %}
                   3735:
1.1.1.2 ! maekawa  3736: % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
1.1       maekawa  3737: \def\point{$\star$}
                   3738: \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
                   3739: \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
                   3740: \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
                   3741: \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
                   3742:
                   3743: % Adapted from the TeXbook's \boxit.
                   3744: {\tentt \global\dimen0 = 3em}% Width of the box.
                   3745: \dimen2 = .55pt % Thickness of rules
                   3746: % The text. (`r' is open on the right, `e' somewhat less so on the left.)
                   3747: \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
                   3748:
                   3749: \global\setbox\errorbox=\hbox to \dimen0{\hfil
                   3750:    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
                   3751:    \advance\hsize by -2\dimen2 % Rules.
                   3752:    \vbox{
                   3753:       \hrule height\dimen2
                   3754:       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
                   3755:          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
                   3756:          \kern3pt\vrule width\dimen2}% Space to right.
                   3757:       \hrule height\dimen2}
                   3758:     \hfil}
                   3759:
                   3760: % The @error{} command.
                   3761: \def\error{\leavevmode\lower.7ex\copy\errorbox}
                   3762:
                   3763: % @tex ... @end tex    escapes into raw Tex temporarily.
                   3764: % One exception: @ is still an escape character, so that @end tex works.
                   3765: % But \@ or @@ will get a plain tex @ character.
                   3766:
                   3767: \def\tex{\begingroup
1.1.1.2 ! maekawa  3768:   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
        !          3769:   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
        !          3770:   \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
        !          3771:   \catcode `\%=14
        !          3772:   \catcode 43=12 % plus
        !          3773:   \catcode`\"=12
        !          3774:   \catcode`\==12
        !          3775:   \catcode`\|=12
        !          3776:   \catcode`\<=12
        !          3777:   \catcode`\>=12
        !          3778:   \escapechar=`\\
        !          3779:   %
        !          3780:   \let\b=\ptexb
        !          3781:   \let\bullet=\ptexbullet
        !          3782:   \let\c=\ptexc
        !          3783:   \let\,=\ptexcomma
        !          3784:   \let\.=\ptexdot
        !          3785:   \let\dots=\ptexdots
        !          3786:   \let\equiv=\ptexequiv
        !          3787:   \let\!=\ptexexclam
        !          3788:   \let\i=\ptexi
        !          3789:   \let\{=\ptexlbrace
        !          3790:   \let\+=\tabalign
        !          3791:   \let\}=\ptexrbrace
        !          3792:   \let\*=\ptexstar
        !          3793:   \let\t=\ptext
        !          3794:   %
        !          3795:   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
        !          3796:   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
        !          3797:   \def\@{@}%
1.1       maekawa  3798: \let\Etex=\endgroup}
                   3799:
                   3800: % Define @lisp ... @endlisp.
                   3801: % @lisp does a \begingroup so it can rebind things,
                   3802: % including the definition of @endlisp (which normally is erroneous).
                   3803:
                   3804: % Amount to narrow the margins by for @lisp.
                   3805: \newskip\lispnarrowing \lispnarrowing=0.4in
                   3806:
                   3807: % This is the definition that ^^M gets inside @lisp, @example, and other
                   3808: % such environments.  \null is better than a space, since it doesn't
                   3809: % have any width.
                   3810: \def\lisppar{\null\endgraf}
                   3811:
                   3812: % Make each space character in the input produce a normal interword
                   3813: % space in the output.  Don't allow a line break at this space, as this
                   3814: % is used only in environments like @example, where each line of input
                   3815: % should produce a line of output anyway.
                   3816: %
                   3817: {\obeyspaces %
                   3818: \gdef\sepspaces{\obeyspaces\let =\tie}}
                   3819:
                   3820: % Define \obeyedspace to be our active space, whatever it is.  This is
                   3821: % for use in \parsearg.
                   3822: {\sepspaces%
                   3823: \global\let\obeyedspace= }
                   3824:
                   3825: % This space is always present above and below environments.
                   3826: \newskip\envskipamount \envskipamount = 0pt
                   3827:
                   3828: % Make spacing and below environment symmetrical.  We use \parskip here
                   3829: % to help in doing that, since in @example-like environments \parskip
                   3830: % is reset to zero; thus the \afterenvbreak inserts no space -- but the
                   3831: % start of the next paragraph will insert \parskip
                   3832: %
                   3833: \def\aboveenvbreak{{\advance\envskipamount by \parskip
                   3834: \endgraf \ifdim\lastskip<\envskipamount
                   3835: \removelastskip \penalty-50 \vskip\envskipamount \fi}}
                   3836:
                   3837: \let\afterenvbreak = \aboveenvbreak
                   3838:
                   3839: % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
                   3840: \let\nonarrowing=\relax
                   3841:
1.1.1.2 ! maekawa  3842: % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
        !          3843: % environment contents.
1.1       maekawa  3844: \font\circle=lcircle10
                   3845: \newdimen\circthick
                   3846: \newdimen\cartouter\newdimen\cartinner
                   3847: \newskip\normbskip\newskip\normpskip\newskip\normlskip
                   3848: \circthick=\fontdimen8\circle
                   3849: %
                   3850: \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
                   3851: \def\ctr{{\hskip 6pt\circle\char'010}}
                   3852: \def\cbl{{\circle\char'012\hskip -6pt}}
                   3853: \def\cbr{{\hskip 6pt\circle\char'011}}
                   3854: \def\carttop{\hbox to \cartouter{\hskip\lskip
1.1.1.2 ! maekawa  3855:         \ctl\leaders\hrule height\circthick\hfil\ctr
        !          3856:         \hskip\rskip}}
1.1       maekawa  3857: \def\cartbot{\hbox to \cartouter{\hskip\lskip
1.1.1.2 ! maekawa  3858:         \cbl\leaders\hrule height\circthick\hfil\cbr
        !          3859:         \hskip\rskip}}
1.1       maekawa  3860: %
                   3861: \newskip\lskip\newskip\rskip
                   3862:
                   3863: \long\def\cartouche{%
                   3864: \begingroup
1.1.1.2 ! maekawa  3865:         \lskip=\leftskip \rskip=\rightskip
        !          3866:         \leftskip=0pt\rightskip=0pt %we want these *outside*.
        !          3867:         \cartinner=\hsize \advance\cartinner by-\lskip
        !          3868:                           \advance\cartinner by-\rskip
        !          3869:         \cartouter=\hsize
        !          3870:         \advance\cartouter by 18.4pt % allow for 3pt kerns on either
        !          3871: %                                    side, and for 6pt waste from
        !          3872: %                                    each corner char, and rule thickness
        !          3873:         \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
        !          3874:         % Flag to tell @lisp, etc., not to narrow margin.
        !          3875:         \let\nonarrowing=\comment
        !          3876:         \vbox\bgroup
        !          3877:                 \baselineskip=0pt\parskip=0pt\lineskip=0pt
        !          3878:                 \carttop
        !          3879:                 \hbox\bgroup
        !          3880:                         \hskip\lskip
        !          3881:                         \vrule\kern3pt
        !          3882:                         \vbox\bgroup
        !          3883:                                 \hsize=\cartinner
        !          3884:                                 \kern3pt
        !          3885:                                 \begingroup
        !          3886:                                         \baselineskip=\normbskip
        !          3887:                                         \lineskip=\normlskip
        !          3888:                                         \parskip=\normpskip
        !          3889:                                         \vskip -\parskip
1.1       maekawa  3890: \def\Ecartouche{%
1.1.1.2 ! maekawa  3891:                                 \endgroup
        !          3892:                                 \kern3pt
        !          3893:                         \egroup
        !          3894:                         \kern3pt\vrule
        !          3895:                         \hskip\rskip
        !          3896:                 \egroup
        !          3897:                 \cartbot
        !          3898:         \egroup
1.1       maekawa  3899: \endgroup
                   3900: }}
                   3901:
                   3902:
                   3903: % This macro is called at the beginning of all the @example variants,
                   3904: % inside a group.
                   3905: \def\nonfillstart{%
                   3906:   \aboveenvbreak
                   3907:   \inENV % This group ends at the end of the body
                   3908:   \hfuzz = 12pt % Don't be fussy
                   3909:   \sepspaces % Make spaces be word-separators rather than space tokens.
                   3910:   \singlespace
                   3911:   \let\par = \lisppar % don't ignore blank lines
                   3912:   \obeylines % each line of input is a line of output
                   3913:   \parskip = 0pt
                   3914:   \parindent = 0pt
                   3915:   \emergencystretch = 0pt % don't try to avoid overfull boxes
                   3916:   % @cartouche defines \nonarrowing to inhibit narrowing
                   3917:   % at next level down.
                   3918:   \ifx\nonarrowing\relax
                   3919:     \advance \leftskip by \lispnarrowing
                   3920:     \exdentamount=\lispnarrowing
                   3921:     \let\exdent=\nofillexdent
                   3922:     \let\nonarrowing=\relax
                   3923:   \fi
                   3924: }
                   3925:
1.1.1.2 ! maekawa  3926: % Define the \E... control sequence only if we are inside the particular
        !          3927: % environment, so the error checking in \end will work.
1.1       maekawa  3928: %
1.1.1.2 ! maekawa  3929: % To end an @example-like environment, we first end the paragraph (via
        !          3930: % \afterenvbreak's vertical glue), and then the group.  That way we keep
        !          3931: % the zero \parskip that the environments set -- \parskip glue will be
        !          3932: % inserted at the beginning of the next paragraph in the document, after
        !          3933: % the environment.
        !          3934: %
        !          3935: \def\nonfillfinish{\afterenvbreak\endgroup}
1.1       maekawa  3936:
1.1.1.2 ! maekawa  3937: % @lisp: indented, narrowed, typewriter font.
1.1       maekawa  3938: \def\lisp{\begingroup
                   3939:   \nonfillstart
                   3940:   \let\Elisp = \nonfillfinish
                   3941:   \tt
1.1.1.2 ! maekawa  3942:   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
        !          3943:   \gobble       % eat return
1.1       maekawa  3944: }
                   3945:
1.1.1.2 ! maekawa  3946: % @example: Same as @lisp.
1.1       maekawa  3947: \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
                   3948:
1.1.1.2 ! maekawa  3949: % @small... is usually equivalent to the non-small (@smallbook
        !          3950: % redefines).  We must call \example (or whatever) last in the
        !          3951: % definition, since it reads the return following the @example (or
        !          3952: % whatever) command.
        !          3953: %
        !          3954: % This actually allows (for example) @end display inside an
        !          3955: % @smalldisplay.  Too bad, but makeinfo will catch the error anyway.
        !          3956: %
        !          3957: \def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display}
        !          3958: \def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp}
        !          3959: \def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format}
        !          3960: \def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
        !          3961:
        !          3962: % Real @smallexample and @smalllisp (when @smallbook): use smaller fonts.
        !          3963: % Originally contributed by Pavel@xerox.
1.1       maekawa  3964: \def\smalllispx{\begingroup
1.1.1.2 ! maekawa  3965:   \def\Esmalllisp{\nonfillfinish\endgroup}%
        !          3966:   \def\Esmallexample{\nonfillfinish\endgroup}%
        !          3967:   \indexfonts
        !          3968:   \lisp
1.1       maekawa  3969: }
                   3970:
1.1.1.2 ! maekawa  3971: % @display: same as @lisp except keep current font.
1.1       maekawa  3972: %
                   3973: \def\display{\begingroup
                   3974:   \nonfillstart
                   3975:   \let\Edisplay = \nonfillfinish
                   3976:   \gobble
                   3977: }
                   3978:
1.1.1.2 ! maekawa  3979: % @smalldisplay (when @smallbook): @display plus smaller fonts.
        !          3980: %
        !          3981: \def\smalldisplayx{\begingroup
        !          3982:   \def\Esmalldisplay{\nonfillfinish\endgroup}%
        !          3983:   \indexfonts \rm
        !          3984:   \display
        !          3985: }
        !          3986:
        !          3987: % @format: same as @display except don't narrow margins.
1.1       maekawa  3988: %
                   3989: \def\format{\begingroup
                   3990:   \let\nonarrowing = t
                   3991:   \nonfillstart
                   3992:   \let\Eformat = \nonfillfinish
                   3993:   \gobble
                   3994: }
                   3995:
1.1.1.2 ! maekawa  3996: % @smallformat (when @smallbook): @format plus smaller fonts.
1.1       maekawa  3997: %
1.1.1.2 ! maekawa  3998: \def\smallformatx{\begingroup
        !          3999:   \def\Esmallformat{\nonfillfinish\endgroup}%
        !          4000:   \indexfonts \rm
        !          4001:   \format
1.1       maekawa  4002: }
1.1.1.2 ! maekawa  4003:
        !          4004: % @flushleft (same as @format).
        !          4005: %
        !          4006: \def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format}
        !          4007:
        !          4008: % @flushright.
        !          4009: %
1.1       maekawa  4010: \def\flushright{\begingroup
                   4011:   \let\nonarrowing = t
                   4012:   \nonfillstart
                   4013:   \let\Eflushright = \nonfillfinish
                   4014:   \advance\leftskip by 0pt plus 1fill
1.1.1.2 ! maekawa  4015:   \gobble
        !          4016: }
1.1       maekawa  4017:
                   4018: % @quotation does normal linebreaking (hence we can't use \nonfillstart)
                   4019: % and narrows the margins.
                   4020: %
                   4021: \def\quotation{%
                   4022:   \begingroup\inENV %This group ends at the end of the @quotation body
                   4023:   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
                   4024:   \singlespace
                   4025:   \parindent=0pt
                   4026:   % We have retained a nonzero parskip for the environment, since we're
                   4027:   % doing normal filling. So to avoid extra space below the environment...
                   4028:   \def\Equotation{\parskip = 0pt \nonfillfinish}%
                   4029:   %
                   4030:   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
                   4031:   \ifx\nonarrowing\relax
                   4032:     \advance\leftskip by \lispnarrowing
                   4033:     \advance\rightskip by \lispnarrowing
                   4034:     \exdentamount = \lispnarrowing
                   4035:     \let\nonarrowing = \relax
                   4036:   \fi
                   4037: }
                   4038:
1.1.1.2 ! maekawa  4039:
1.1       maekawa  4040: \message{defuns,}
                   4041: % Define formatter for defuns
                   4042: % First, allow user to change definition object font (\df) internally
                   4043: \def\setdeffont #1 {\csname DEF#1\endcsname}
                   4044:
                   4045: \newskip\defbodyindent \defbodyindent=.4in
                   4046: \newskip\defargsindent \defargsindent=50pt
                   4047: \newskip\deftypemargin \deftypemargin=12pt
                   4048: \newskip\deflastargmargin \deflastargmargin=18pt
                   4049:
                   4050: \newcount\parencount
                   4051: % define \functionparens, which makes ( and ) and & do special things.
                   4052: % \functionparens affects the group it is contained in.
                   4053: \def\activeparens{%
                   4054: \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
                   4055: \catcode`\[=\active \catcode`\]=\active}
                   4056:
                   4057: % Make control sequences which act like normal parenthesis chars.
                   4058: \let\lparen = ( \let\rparen = )
                   4059:
                   4060: {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
                   4061:
                   4062: % Be sure that we always have a definition for `(', etc.  For example,
                   4063: % if the fn name has parens in it, \boldbrax will not be in effect yet,
                   4064: % so TeX would otherwise complain about undefined control sequence.
                   4065: \global\let(=\lparen \global\let)=\rparen
                   4066: \global\let[=\lbrack \global\let]=\rbrack
                   4067:
                   4068: \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
                   4069: \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
                   4070: % This is used to turn on special parens
                   4071: % but make & act ordinary (given that it's active).
                   4072: \gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
                   4073:
                   4074: % Definitions of (, ) and & used in args for functions.
                   4075: % This is the definition of ( outside of all parentheses.
1.1.1.2 ! maekawa  4076: \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
        !          4077:   \global\advance\parencount by 1
        !          4078: }
1.1       maekawa  4079: %
                   4080: % This is the definition of ( when already inside a level of parens.
                   4081: \gdef\opnested{\char`\(\global\advance\parencount by 1 }
                   4082: %
                   4083: \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
1.1.1.2 ! maekawa  4084:   % also in that case restore the outer-level definition of (.
        !          4085:   \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
        !          4086:   \global\advance \parencount by -1 }
1.1       maekawa  4087: % If we encounter &foo, then turn on ()-hacking afterwards
                   4088: \gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
                   4089: %
                   4090: \gdef\normalparens{\boldbrax\let&=\ampnr}
                   4091: } % End of definition inside \activeparens
                   4092: %% These parens (in \boldbrax) actually are a little bolder than the
                   4093: %% contained text.  This is especially needed for [ and ]
1.1.1.2 ! maekawa  4094: \def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
        !          4095: \def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
        !          4096: \let\ampnr = \&
        !          4097: \def\lbrb{{\bf\char`\[}}
        !          4098: \def\rbrb{{\bf\char`\]}}
        !          4099:
        !          4100: % Active &'s sneak into the index arguments, so make sure it's defined.
        !          4101: {
        !          4102:   \catcode`& = 13
        !          4103:   \global\let& = \ampnr
        !          4104: }
1.1       maekawa  4105:
                   4106: % First, defname, which formats the header line itself.
                   4107: % #1 should be the function name.
                   4108: % #2 should be the type of definition, such as "Function".
                   4109:
                   4110: \def\defname #1#2{%
                   4111: % Get the values of \leftskip and \rightskip as they were
                   4112: % outside the @def...
                   4113: \dimen2=\leftskip
                   4114: \advance\dimen2 by -\defbodyindent
1.1.1.2 ! maekawa  4115: \noindent
1.1       maekawa  4116: \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
                   4117: \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
                   4118: \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
1.1.1.2 ! maekawa  4119: \parshape 2 0in \dimen0 \defargsindent \dimen1
1.1       maekawa  4120: % Now output arg 2 ("Function" or some such)
                   4121: % ending at \deftypemargin from the right margin,
                   4122: % but stuck inside a box of width 0 so it does not interfere with linebreaking
                   4123: {% Adjust \hsize to exclude the ambient margins,
                   4124: % so that \rightline will obey them.
1.1.1.2 ! maekawa  4125: \advance \hsize by -\dimen2
        !          4126: \rlap{\rightline{{\rm #2}\hskip -1.25pc }}}%
1.1       maekawa  4127: % Make all lines underfull and no complaints:
                   4128: \tolerance=10000 \hbadness=10000
                   4129: \advance\leftskip by -\defbodyindent
                   4130: \exdentamount=\defbodyindent
                   4131: {\df #1}\enskip        % Generate function name
                   4132: }
                   4133:
                   4134: % Actually process the body of a definition
                   4135: % #1 should be the terminating control sequence, such as \Edefun.
                   4136: % #2 should be the "another name" control sequence, such as \defunx.
                   4137: % #3 should be the control sequence that actually processes the header,
                   4138: %    such as \defunheader.
                   4139:
                   4140: \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
                   4141: \medbreak %
                   4142: % Define the end token that this defining construct specifies
                   4143: % so that it will exit this group.
                   4144: \def#1{\endgraf\endgroup\medbreak}%
                   4145: \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
                   4146: \parindent=0in
1.1.1.2 ! maekawa  4147: \advance\leftskip by \defbodyindent
1.1       maekawa  4148: \exdentamount=\defbodyindent
                   4149: \begingroup %
                   4150: \catcode 61=\active % 61 is `='
                   4151: \obeylines\activeparens\spacesplit#3}
                   4152:
1.1.1.2 ! maekawa  4153: % #1 is the \E... control sequence to end the definition (which we define).
        !          4154: % #2 is the \...x control sequence for consecutive fns (which we define).
        !          4155: % #3 is the control sequence to call to resume processing.
        !          4156: % #4, delimited by the space, is the class name.
        !          4157: %
        !          4158: \def\defmethparsebody#1#2#3#4 {\begingroup\inENV %
1.1       maekawa  4159: \medbreak %
                   4160: % Define the end token that this defining construct specifies
                   4161: % so that it will exit this group.
                   4162: \def#1{\endgraf\endgroup\medbreak}%
                   4163: \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
                   4164: \parindent=0in
1.1.1.2 ! maekawa  4165: \advance\leftskip by \defbodyindent
1.1       maekawa  4166: \exdentamount=\defbodyindent
                   4167: \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
                   4168:
1.1.1.2 ! maekawa  4169: % @deftypemethod has an extra argument that nothing else does.  Sigh.
        !          4170: % #1 is the \E... control sequence to end the definition (which we define).
        !          4171: % #2 is the \...x control sequence for consecutive fns (which we define).
        !          4172: % #3 is the control sequence to call to resume processing.
        !          4173: % #4, delimited by the space, is the class name.
        !          4174: % #5 is the method's return type.
        !          4175: %
        !          4176: \def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV %
        !          4177: \medbreak %
        !          4178: % Define the end token that this defining construct specifies
        !          4179: % so that it will exit this group.
        !          4180: \def#1{\endgraf\endgroup\medbreak}%
        !          4181: \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
        !          4182: \parindent=0in
        !          4183: \advance\leftskip by \defbodyindent
        !          4184: \exdentamount=\defbodyindent
        !          4185: \begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}}
        !          4186:
1.1       maekawa  4187: \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
                   4188: \medbreak %
                   4189: % Define the end token that this defining construct specifies
                   4190: % so that it will exit this group.
                   4191: \def#1{\endgraf\endgroup\medbreak}%
                   4192: \def#2##1 ##2 {\def#4{##1}%
                   4193: \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
                   4194: \parindent=0in
1.1.1.2 ! maekawa  4195: \advance\leftskip by \defbodyindent
1.1       maekawa  4196: \exdentamount=\defbodyindent
                   4197: \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
                   4198:
                   4199: % These parsing functions are similar to the preceding ones
                   4200: % except that they do not make parens into active characters.
                   4201: % These are used for "variables" since they have no arguments.
                   4202:
                   4203: \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
                   4204: \medbreak %
                   4205: % Define the end token that this defining construct specifies
                   4206: % so that it will exit this group.
                   4207: \def#1{\endgraf\endgroup\medbreak}%
                   4208: \def#2{\begingroup\obeylines\spacesplit#3}%
                   4209: \parindent=0in
1.1.1.2 ! maekawa  4210: \advance\leftskip by \defbodyindent
1.1       maekawa  4211: \exdentamount=\defbodyindent
                   4212: \begingroup %
                   4213: \catcode 61=\active %
                   4214: \obeylines\spacesplit#3}
                   4215:
                   4216: % This is used for \def{tp,vr}parsebody.  It could probably be used for
                   4217: % some of the others, too, with some judicious conditionals.
1.1.1.2 ! maekawa  4218: %
1.1       maekawa  4219: \def\parsebodycommon#1#2#3{%
                   4220:   \begingroup\inENV %
                   4221:   \medbreak %
                   4222:   % Define the end token that this defining construct specifies
                   4223:   % so that it will exit this group.
                   4224:   \def#1{\endgraf\endgroup\medbreak}%
                   4225:   \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
                   4226:   \parindent=0in
1.1.1.2 ! maekawa  4227:   \advance\leftskip by \defbodyindent
1.1       maekawa  4228:   \exdentamount=\defbodyindent
                   4229:   \begingroup\obeylines
                   4230: }
                   4231:
                   4232: \def\defvrparsebody#1#2#3#4 {%
                   4233:   \parsebodycommon{#1}{#2}{#3}%
                   4234:   \spacesplit{#3{#4}}%
                   4235: }
                   4236:
                   4237: % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
                   4238: % type is just `struct', because we lose the braces in `{struct
                   4239: % termios}' when \spacesplit reads its undelimited argument.  Sigh.
                   4240: % \let\deftpparsebody=\defvrparsebody
                   4241: %
                   4242: % So, to get around this, we put \empty in with the type name.  That
                   4243: % way, TeX won't find exactly `{...}' as an undelimited argument, and
                   4244: % won't strip off the braces.
                   4245: %
                   4246: \def\deftpparsebody #1#2#3#4 {%
                   4247:   \parsebodycommon{#1}{#2}{#3}%
                   4248:   \spacesplit{\parsetpheaderline{#3{#4}}}\empty
                   4249: }
                   4250:
                   4251: % Fine, but then we have to eventually remove the \empty *and* the
1.1.1.2 ! maekawa  4252: % braces (if any).  That's what this does.
        !          4253: %
        !          4254: \def\removeemptybraces\empty#1\relax{#1}
1.1       maekawa  4255:
                   4256: % After \spacesplit has done its work, this is called -- #1 is the final
                   4257: % thing to call, #2 the type name (which starts with \empty), and #3
                   4258: % (which might be empty) the arguments.
1.1.1.2 ! maekawa  4259: %
1.1       maekawa  4260: \def\parsetpheaderline#1#2#3{%
1.1.1.2 ! maekawa  4261:   #1{\removeemptybraces#2\relax}{#3}%
1.1       maekawa  4262: }%
                   4263:
                   4264: \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
                   4265: \medbreak %
                   4266: % Define the end token that this defining construct specifies
                   4267: % so that it will exit this group.
                   4268: \def#1{\endgraf\endgroup\medbreak}%
                   4269: \def#2##1 ##2 {\def#4{##1}%
                   4270: \begingroup\obeylines\spacesplit{#3{##2}}}%
                   4271: \parindent=0in
1.1.1.2 ! maekawa  4272: \advance\leftskip by \defbodyindent
1.1       maekawa  4273: \exdentamount=\defbodyindent
                   4274: \begingroup\obeylines\spacesplit{#3{#5}}}
                   4275:
                   4276: % Split up #2 at the first space token.
                   4277: % call #1 with two arguments:
                   4278: %  the first is all of #2 before the space token,
                   4279: %  the second is all of #2 after that space token.
                   4280: % If #2 contains no space token, all of it is passed as the first arg
                   4281: % and the second is passed as empty.
                   4282:
                   4283: {\obeylines
                   4284: \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
                   4285: \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
                   4286: \ifx\relax #3%
                   4287: #1{#2}{}\else #1{#2}{#3#4}\fi}}
                   4288:
                   4289: % So much for the things common to all kinds of definitions.
                   4290:
                   4291: % Define @defun.
                   4292:
                   4293: % First, define the processing that is wanted for arguments of \defun
                   4294: % Use this to expand the args and terminate the paragraph they make up
                   4295:
                   4296: \def\defunargs #1{\functionparens \sl
                   4297: % Expand, preventing hyphenation at `-' chars.
                   4298: % Note that groups don't affect changes in \hyphenchar.
                   4299: \hyphenchar\tensl=0
                   4300: #1%
                   4301: \hyphenchar\tensl=45
1.1.1.2 ! maekawa  4302: \ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
1.1       maekawa  4303: \interlinepenalty=10000
                   4304: \advance\rightskip by 0pt plus 1fil
1.1.1.2 ! maekawa  4305: \endgraf\nobreak\vskip -\parskip\nobreak
1.1       maekawa  4306: }
                   4307:
                   4308: \def\deftypefunargs #1{%
                   4309: % Expand, preventing hyphenation at `-' chars.
                   4310: % Note that groups don't affect changes in \hyphenchar.
                   4311: % Use \boldbraxnoamp, not \functionparens, so that & is not special.
                   4312: \boldbraxnoamp
                   4313: \tclose{#1}% avoid \code because of side effects on active chars
                   4314: \interlinepenalty=10000
                   4315: \advance\rightskip by 0pt plus 1fil
1.1.1.2 ! maekawa  4316: \endgraf\nobreak\vskip -\parskip\nobreak
1.1       maekawa  4317: }
                   4318:
                   4319: % Do complete processing of one @defun or @defunx line already parsed.
                   4320:
                   4321: % @deffn Command forward-char nchars
                   4322:
                   4323: \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
                   4324:
                   4325: \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
                   4326: \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
                   4327: \catcode 61=\other % Turn off change made in \defparsebody
                   4328: }
                   4329:
                   4330: % @defun == @deffn Function
                   4331:
                   4332: \def\defun{\defparsebody\Edefun\defunx\defunheader}
                   4333:
                   4334: \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
1.1.1.2 ! maekawa  4335: \begingroup\defname {#1}{\putwordDeffunc}%
1.1       maekawa  4336: \defunargs {#2}\endgroup %
                   4337: \catcode 61=\other % Turn off change made in \defparsebody
                   4338: }
                   4339:
                   4340: % @deftypefun int foobar (int @var{foo}, float @var{bar})
                   4341:
                   4342: \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
                   4343:
                   4344: % #1 is the data type.  #2 is the name and args.
                   4345: \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
                   4346: % #1 is the data type, #2 the name, #3 the args.
                   4347: \def\deftypefunheaderx #1#2 #3\relax{%
                   4348: \doind {fn}{\code{#2}}% Make entry in function index
1.1.1.2 ! maekawa  4349: \begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypefun}%
1.1       maekawa  4350: \deftypefunargs {#3}\endgroup %
                   4351: \catcode 61=\other % Turn off change made in \defparsebody
                   4352: }
                   4353:
                   4354: % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
                   4355:
                   4356: \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
                   4357:
                   4358: % \defheaderxcond#1\relax$$$
                   4359: % puts #1 in @code, followed by a space, but does nothing if #1 is null.
                   4360: \def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi}
                   4361:
                   4362: % #1 is the classification.  #2 is the data type.  #3 is the name and args.
                   4363: \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
                   4364: % #1 is the classification, #2 the data type, #3 the name, #4 the args.
                   4365: \def\deftypefnheaderx #1#2#3 #4\relax{%
                   4366: \doind {fn}{\code{#3}}% Make entry in function index
                   4367: \begingroup
                   4368: \normalparens % notably, turn off `&' magic, which prevents
                   4369: %               at least some C++ text from working
                   4370: \defname {\defheaderxcond#2\relax$$$#3}{#1}%
                   4371: \deftypefunargs {#4}\endgroup %
                   4372: \catcode 61=\other % Turn off change made in \defparsebody
                   4373: }
                   4374:
                   4375: % @defmac == @deffn Macro
                   4376:
                   4377: \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
                   4378:
                   4379: \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
1.1.1.2 ! maekawa  4380: \begingroup\defname {#1}{\putwordDefmac}%
1.1       maekawa  4381: \defunargs {#2}\endgroup %
                   4382: \catcode 61=\other % Turn off change made in \defparsebody
                   4383: }
                   4384:
                   4385: % @defspec == @deffn Special Form
                   4386:
                   4387: \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
                   4388:
                   4389: \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
1.1.1.2 ! maekawa  4390: \begingroup\defname {#1}{\putwordDefspec}%
1.1       maekawa  4391: \defunargs {#2}\endgroup %
                   4392: \catcode 61=\other % Turn off change made in \defparsebody
                   4393: }
                   4394:
1.1.1.2 ! maekawa  4395: % @defop CATEGORY CLASS OPERATION ARG...
        !          4396: %
1.1       maekawa  4397: \def\defop #1 {\def\defoptype{#1}%
                   4398: \defopparsebody\Edefop\defopx\defopheader\defoptype}
1.1.1.2 ! maekawa  4399: %
1.1       maekawa  4400: \def\defopheader #1#2#3{%
1.1.1.2 ! maekawa  4401: \dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index
        !          4402: \begingroup\defname {#2}{\defoptype\ \putwordon\ #1}%
1.1       maekawa  4403: \defunargs {#3}\endgroup %
                   4404: }
                   4405:
1.1.1.2 ! maekawa  4406: % @deftypemethod CLASS RETURN-TYPE METHOD ARG...
        !          4407: %
        !          4408: \def\deftypemethod{%
        !          4409:   \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
        !          4410: %
        !          4411: % #1 is the class name, #2 the data type, #3 the method name, #4 the args.
        !          4412: \def\deftypemethodheader#1#2#3#4{%
        !          4413:   \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
        !          4414:   \begingroup
        !          4415:     \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}%
        !          4416:     \deftypefunargs{#4}%
        !          4417:   \endgroup
        !          4418: }
1.1       maekawa  4419:
1.1.1.2 ! maekawa  4420: % @deftypeivar CLASS TYPE VARNAME
        !          4421: %
        !          4422: \def\deftypeivar{%
        !          4423:   \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader}
        !          4424: %
        !          4425: % #1 is the class name, #2 the data type, #3 the variable name.
        !          4426: \def\deftypeivarheader#1#2#3{%
        !          4427:   \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
        !          4428:   \begingroup
        !          4429:     \defname{#3}{\putwordInstanceVariableof\ \code{#1}}%
        !          4430:     \defvarargs{#3}%
        !          4431:   \endgroup
        !          4432: }
1.1       maekawa  4433:
1.1.1.2 ! maekawa  4434: % @defmethod == @defop Method
        !          4435: %
        !          4436: \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
        !          4437: %
        !          4438: % #1 is the class name, #2 the method name, #3 the args.
        !          4439: \def\defmethodheader#1#2#3{%
        !          4440:   \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index
        !          4441:   \begingroup
        !          4442:     \defname{#2}{\putwordMethodon\ \code{#1}}%
        !          4443:     \defunargs{#3}%
        !          4444:   \endgroup
1.1       maekawa  4445: }
                   4446:
                   4447: % @defcv {Class Option} foo-class foo-flag
                   4448:
                   4449: \def\defcv #1 {\def\defcvtype{#1}%
                   4450: \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
                   4451:
                   4452: \def\defcvarheader #1#2#3{%
1.1.1.2 ! maekawa  4453: \dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index
        !          4454: \begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}%
1.1       maekawa  4455: \defvarargs {#3}\endgroup %
                   4456: }
                   4457:
1.1.1.2 ! maekawa  4458: % @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME
        !          4459: %
1.1       maekawa  4460: \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
1.1.1.2 ! maekawa  4461: %
        !          4462: \def\defivarheader#1#2#3{%
        !          4463:   \dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index
        !          4464:   \begingroup
        !          4465:     \defname{#2}{\putwordInstanceVariableof\ #1}%
        !          4466:     \defvarargs{#3}%
        !          4467:   \endgroup
1.1       maekawa  4468: }
                   4469:
1.1.1.2 ! maekawa  4470: % @defvar
1.1       maekawa  4471: % First, define the processing that is wanted for arguments of @defvar.
                   4472: % This is actually simple: just print them in roman.
                   4473: % This must expand the args and terminate the paragraph they make up
                   4474: \def\defvarargs #1{\normalparens #1%
                   4475: \interlinepenalty=10000
1.1.1.2 ! maekawa  4476: \endgraf\nobreak\vskip -\parskip\nobreak}
1.1       maekawa  4477:
                   4478: % @defvr Counter foo-count
                   4479:
                   4480: \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
                   4481:
                   4482: \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
                   4483: \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
                   4484:
                   4485: % @defvar == @defvr Variable
                   4486:
                   4487: \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
                   4488:
                   4489: \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
1.1.1.2 ! maekawa  4490: \begingroup\defname {#1}{\putwordDefvar}%
1.1       maekawa  4491: \defvarargs {#2}\endgroup %
                   4492: }
                   4493:
                   4494: % @defopt == @defvr {User Option}
                   4495:
                   4496: \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
                   4497:
                   4498: \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
1.1.1.2 ! maekawa  4499: \begingroup\defname {#1}{\putwordDefopt}%
1.1       maekawa  4500: \defvarargs {#2}\endgroup %
                   4501: }
                   4502:
                   4503: % @deftypevar int foobar
                   4504:
                   4505: \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
                   4506:
1.1.1.2 ! maekawa  4507: % #1 is the data type.  #2 is the name, perhaps followed by text that
        !          4508: % is actually part of the data type, which should not be put into the index.
1.1       maekawa  4509: \def\deftypevarheader #1#2{%
1.1.1.2 ! maekawa  4510: \dovarind#2 \relax% Make entry in variables index
        !          4511: \begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypevar}%
1.1       maekawa  4512: \interlinepenalty=10000
1.1.1.2 ! maekawa  4513: \endgraf\nobreak\vskip -\parskip\nobreak
1.1       maekawa  4514: \endgroup}
1.1.1.2 ! maekawa  4515: \def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
1.1       maekawa  4516:
                   4517: % @deftypevr {Global Flag} int enable
                   4518:
                   4519: \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
                   4520:
1.1.1.2 ! maekawa  4521: \def\deftypevrheader #1#2#3{\dovarind#3 \relax%
1.1       maekawa  4522: \begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1}
                   4523: \interlinepenalty=10000
1.1.1.2 ! maekawa  4524: \endgraf\nobreak\vskip -\parskip\nobreak
1.1       maekawa  4525: \endgroup}
                   4526:
                   4527: % Now define @deftp
                   4528: % Args are printed in bold, a slight difference from @defvar.
                   4529:
                   4530: \def\deftpargs #1{\bf \defvarargs{#1}}
                   4531:
                   4532: % @deftp Class window height width ...
                   4533:
                   4534: \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
                   4535:
                   4536: \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
                   4537: \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
                   4538:
1.1.1.2 ! maekawa  4539: % These definitions are used if you use @defunx (etc.)
        !          4540: % anywhere other than immediately after a @defun or @defunx.
        !          4541: %
        !          4542: \def\defcvx#1 {\errmessage{@defcvx in invalid context}}
        !          4543: \def\deffnx#1 {\errmessage{@deffnx in invalid context}}
        !          4544: \def\defivarx#1 {\errmessage{@defivarx in invalid context}}
        !          4545: \def\defmacx#1 {\errmessage{@defmacx in invalid context}}
        !          4546: \def\defmethodx#1 {\errmessage{@defmethodx in invalid context}}
        !          4547: \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
        !          4548: \def\defopx#1 {\errmessage{@defopx in invalid context}}
        !          4549: \def\defspecx#1 {\errmessage{@defspecx in invalid context}}
        !          4550: \def\deftpx#1 {\errmessage{@deftpx in invalid context}}
        !          4551: \def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}}
        !          4552: \def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}}
        !          4553: \def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}}
        !          4554: \def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}}
        !          4555: \def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}}
        !          4556: \def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}}
        !          4557: \def\defunx#1 {\errmessage{@defunx in invalid context}}
        !          4558: \def\defvarx#1 {\errmessage{@defvarx in invalid context}}
        !          4559: \def\defvrx#1 {\errmessage{@defvrx in invalid context}}
        !          4560:
        !          4561:
        !          4562: \message{macros,}
        !          4563: % @macro.
        !          4564:
        !          4565: % To do this right we need a feature of e-TeX, \scantokens,
        !          4566: % which we arrange to emulate with a temporary file in ordinary TeX.
        !          4567: \ifx\eTeXversion\undefined
        !          4568:  \newwrite\macscribble
        !          4569:  \def\scanmacro#1{%
        !          4570:    \begingroup \newlinechar`\^^M
        !          4571:    % Undo catcode changes of \startcontents and \doprintindex
        !          4572:    \catcode`\@=0 \catcode`\\=12 \escapechar=`\@
        !          4573:    % Append \endinput to make sure that TeX does not see the ending newline.
        !          4574:    \toks0={#1\endinput}%
        !          4575:    \immediate\openout\macscribble=\jobname.tmp
        !          4576:    \immediate\write\macscribble{\the\toks0}%
        !          4577:    \immediate\closeout\macscribble
        !          4578:    \let\xeatspaces\eatspaces
        !          4579:    \input \jobname.tmp
        !          4580:    \endgroup
        !          4581: }
        !          4582: \else
        !          4583: \def\scanmacro#1{%
        !          4584: \begingroup \newlinechar`\^^M
        !          4585: % Undo catcode changes of \startcontents and \doprintindex
        !          4586: \catcode`\@=0 \catcode`\\=12 \escapechar=`\@
        !          4587: \let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup}
        !          4588: \fi
        !          4589:
        !          4590: \newcount\paramno   % Count of parameters
        !          4591: \newtoks\macname    % Macro name
        !          4592: \newif\ifrecursive  % Is it recursive?
        !          4593: \def\macrolist{}    % List of all defined macros in the form
        !          4594:                     % \do\macro1\do\macro2...
        !          4595:
        !          4596: % Utility routines.
        !          4597: % Thisdoes \let #1 = #2, except with \csnames.
        !          4598: \def\cslet#1#2{%
        !          4599: \expandafter\expandafter
        !          4600: \expandafter\let
        !          4601: \expandafter\expandafter
        !          4602: \csname#1\endcsname
        !          4603: \csname#2\endcsname}
        !          4604:
        !          4605: % Trim leading and trailing spaces off a string.
        !          4606: % Concepts from aro-bend problem 15 (see CTAN).
        !          4607: {\catcode`\@=11
        !          4608: \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
        !          4609: \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
        !          4610: \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
        !          4611: \def\unbrace#1{#1}
        !          4612: \unbrace{\gdef\trim@@@ #1 } #2@{#1}
        !          4613: }
        !          4614:
        !          4615: % Trim a single trailing ^^M off a string.
        !          4616: {\catcode`\^^M=12\catcode`\Q=3%
        !          4617: \gdef\eatcr #1{\eatcra #1Q^^MQ}%
        !          4618: \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
        !          4619: \gdef\eatcrb#1Q#2Q{#1}%
        !          4620: }
        !          4621:
        !          4622: % Macro bodies are absorbed as an argument in a context where
        !          4623: % all characters are catcode 10, 11 or 12, except \ which is active
        !          4624: % (as in normal texinfo). It is necessary to change the definition of \.
        !          4625:
        !          4626: % It's necessary to have hard CRs when the macro is executed. This is
        !          4627: % done by  making ^^M (\endlinechar) catcode 12 when reading the macro
        !          4628: % body, and then making it the \newlinechar in \scanmacro.
        !          4629:
        !          4630: \def\macrobodyctxt{%
        !          4631:   \catcode`\~=12
        !          4632:   \catcode`\^=12
        !          4633:   \catcode`\_=12
        !          4634:   \catcode`\|=12
        !          4635:   \catcode`\<=12
        !          4636:   \catcode`\>=12
        !          4637:   \catcode`\+=12
        !          4638:   \catcode`\{=12
        !          4639:   \catcode`\}=12
        !          4640:   \catcode`\@=12
        !          4641:   \catcode`\^^M=12
        !          4642:   \usembodybackslash}
        !          4643:
        !          4644: \def\macroargctxt{%
        !          4645:   \catcode`\~=12
        !          4646:   \catcode`\^=12
        !          4647:   \catcode`\_=12
        !          4648:   \catcode`\|=12
        !          4649:   \catcode`\<=12
        !          4650:   \catcode`\>=12
        !          4651:   \catcode`\+=12
        !          4652:   \catcode`\@=12
        !          4653:   \catcode`\\=12}
        !          4654:
        !          4655: % \mbodybackslash is the definition of \ in @macro bodies.
        !          4656: % It maps \foo\ => \csname macarg.foo\endcsname => #N
        !          4657: % where N is the macro parameter number.
        !          4658: % We define \csname macarg.\endcsname to be \realbackslash, so
        !          4659: % \\ in macro replacement text gets you a backslash.
        !          4660:
        !          4661: {\catcode`@=0 @catcode`@\=@active
        !          4662:  @gdef@usembodybackslash{@let\=@mbodybackslash}
        !          4663:  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
        !          4664: }
        !          4665: \expandafter\def\csname macarg.\endcsname{\realbackslash}
        !          4666:
        !          4667: \def\macro{\recursivefalse\parsearg\macroxxx}
        !          4668: \def\rmacro{\recursivetrue\parsearg\macroxxx}
        !          4669:
        !          4670: \def\macroxxx#1{%
        !          4671:   \getargs{#1}%           now \macname is the macname and \argl the arglist
        !          4672:   \ifx\argl\empty       % no arguments
        !          4673:      \paramno=0%
        !          4674:   \else
        !          4675:      \expandafter\parsemargdef \argl;%
        !          4676:   \fi
        !          4677:   \if1\csname ismacro.\the\macname\endcsname
        !          4678:      \message{Warning: redefining \the\macname}%
        !          4679:   \else
        !          4680:      \expandafter\ifx\csname \the\macname\endcsname \relax
        !          4681:      \else \errmessage{The name \the\macname\space is reserved}\fi
        !          4682:      \global\cslet{macsave.\the\macname}{\the\macname}%
        !          4683:      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
        !          4684:      % Add the macroname to \macrolist
        !          4685:      \toks0 = \expandafter{\macrolist\do}%
        !          4686:      \xdef\macrolist{\the\toks0
        !          4687:        \expandafter\noexpand\csname\the\macname\endcsname}%
        !          4688:   \fi
        !          4689:   \begingroup \macrobodyctxt
        !          4690:   \ifrecursive \expandafter\parsermacbody
        !          4691:   \else \expandafter\parsemacbody
        !          4692:   \fi}
        !          4693:
        !          4694: \def\unmacro{\parsearg\unmacroxxx}
        !          4695: \def\unmacroxxx#1{%
        !          4696:   \if1\csname ismacro.#1\endcsname
        !          4697:     \global\cslet{#1}{macsave.#1}%
        !          4698:     \global\expandafter\let \csname ismacro.#1\endcsname=0%
        !          4699:     % Remove the macro name from \macrolist
        !          4700:     \begingroup
        !          4701:       \edef\tempa{\expandafter\noexpand\csname#1\endcsname}%
        !          4702:       \def\do##1{%
        !          4703:         \def\tempb{##1}%
        !          4704:         \ifx\tempa\tempb
        !          4705:           % remove this
        !          4706:         \else
        !          4707:           \toks0 = \expandafter{\newmacrolist\do}%
        !          4708:           \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}%
        !          4709:         \fi}%
        !          4710:       \def\newmacrolist{}%
        !          4711:       % Execute macro list to define \newmacrolist
        !          4712:       \macrolist
        !          4713:       \global\let\macrolist\newmacrolist
        !          4714:     \endgroup
        !          4715:   \else
        !          4716:     \errmessage{Macro #1 not defined}%
        !          4717:   \fi
        !          4718: }
        !          4719:
        !          4720: % This makes use of the obscure feature that if the last token of a
        !          4721: % <parameter list> is #, then the preceding argument is delimited by
        !          4722: % an opening brace, and that opening brace is not consumed.
        !          4723: \def\getargs#1{\getargsxxx#1{}}
        !          4724: \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
        !          4725: \def\getmacname #1 #2\relax{\macname={#1}}
        !          4726: \def\getmacargs#1{\def\argl{#1}}
        !          4727:
        !          4728: % Parse the optional {params} list.  Set up \paramno and \paramlist
        !          4729: % so \defmacro knows what to do.  Define \macarg.blah for each blah
        !          4730: % in the params list, to be ##N where N is the position in that list.
        !          4731: % That gets used by \mbodybackslash (above).
        !          4732:
        !          4733: % We need to get `macro parameter char #' into several definitions.
        !          4734: % The technique used is stolen from LaTeX:  let \hash be something
        !          4735: % unexpandable, insert that wherever you need a #, and then redefine
        !          4736: % it to # just before using the token list produced.
        !          4737: %
        !          4738: % The same technique is used to protect \eatspaces till just before
        !          4739: % the macro is used.
        !          4740:
        !          4741: \def\parsemargdef#1;{\paramno=0\def\paramlist{}%
        !          4742:         \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
        !          4743: \def\parsemargdefxxx#1,{%
        !          4744:   \if#1;\let\next=\relax
        !          4745:   \else \let\next=\parsemargdefxxx
        !          4746:     \advance\paramno by 1%
        !          4747:     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
        !          4748:         {\xeatspaces{\hash\the\paramno}}%
        !          4749:     \edef\paramlist{\paramlist\hash\the\paramno,}%
        !          4750:   \fi\next}
        !          4751:
        !          4752: % These two commands read recursive and nonrecursive macro bodies.
        !          4753: % (They're different since rec and nonrec macros end differently.)
        !          4754:
        !          4755: \long\def\parsemacbody#1@end macro%
        !          4756: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
        !          4757: \long\def\parsermacbody#1@end rmacro%
        !          4758: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
        !          4759:
        !          4760: % This defines the macro itself. There are six cases: recursive and
        !          4761: % nonrecursive macros of zero, one, and many arguments.
        !          4762: % Much magic with \expandafter here.
        !          4763: % \xdef is used so that macro definitions will survive the file
        !          4764: % they're defined in; @include reads the file inside a group.
        !          4765: \def\defmacro{%
        !          4766:   \let\hash=##% convert placeholders to macro parameter chars
        !          4767:   \ifrecursive
        !          4768:     \ifcase\paramno
        !          4769:     % 0
        !          4770:       \expandafter\xdef\csname\the\macname\endcsname{%
        !          4771:         \noexpand\scanmacro{\temp}}%
        !          4772:     \or % 1
        !          4773:       \expandafter\xdef\csname\the\macname\endcsname{%
        !          4774:          \bgroup\noexpand\macroargctxt
        !          4775:          \noexpand\braceorline
        !          4776:          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
        !          4777:       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
        !          4778:          \egroup\noexpand\scanmacro{\temp}}%
        !          4779:     \else % many
        !          4780:       \expandafter\xdef\csname\the\macname\endcsname{%
        !          4781:          \bgroup\noexpand\macroargctxt
        !          4782:          \noexpand\csname\the\macname xx\endcsname}%
        !          4783:       \expandafter\xdef\csname\the\macname xx\endcsname##1{%
        !          4784:           \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
        !          4785:       \expandafter\expandafter
        !          4786:       \expandafter\xdef
        !          4787:       \expandafter\expandafter
        !          4788:         \csname\the\macname xxx\endcsname
        !          4789:           \paramlist{\egroup\noexpand\scanmacro{\temp}}%
        !          4790:     \fi
        !          4791:   \else
        !          4792:     \ifcase\paramno
        !          4793:     % 0
        !          4794:       \expandafter\xdef\csname\the\macname\endcsname{%
        !          4795:         \noexpand\norecurse{\the\macname}%
        !          4796:         \noexpand\scanmacro{\temp}\egroup}%
        !          4797:     \or % 1
        !          4798:       \expandafter\xdef\csname\the\macname\endcsname{%
        !          4799:          \bgroup\noexpand\macroargctxt
        !          4800:          \noexpand\braceorline
        !          4801:          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
        !          4802:       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
        !          4803:         \egroup
        !          4804:         \noexpand\norecurse{\the\macname}%
        !          4805:         \noexpand\scanmacro{\temp}\egroup}%
        !          4806:     \else % many
        !          4807:       \expandafter\xdef\csname\the\macname\endcsname{%
        !          4808:          \bgroup\noexpand\macroargctxt
        !          4809:          \expandafter\noexpand\csname\the\macname xx\endcsname}%
        !          4810:       \expandafter\xdef\csname\the\macname xx\endcsname##1{%
        !          4811:           \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
        !          4812:       \expandafter\expandafter
        !          4813:       \expandafter\xdef
        !          4814:       \expandafter\expandafter
        !          4815:       \csname\the\macname xxx\endcsname
        !          4816:       \paramlist{%
        !          4817:           \egroup
        !          4818:           \noexpand\norecurse{\the\macname}%
        !          4819:           \noexpand\scanmacro{\temp}\egroup}%
        !          4820:     \fi
        !          4821:   \fi}
        !          4822:
        !          4823: \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
        !          4824:
        !          4825: % \braceorline decides whether the next nonwhitespace character is a
        !          4826: % {.  If so it reads up to the closing }, if not, it reads the whole
        !          4827: % line.  Whatever was read is then fed to the next control sequence
        !          4828: % as an argument (by \parsebrace or \parsearg)
        !          4829: \def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
        !          4830: \def\braceorlinexxx{%
        !          4831:   \ifx\nchar\bgroup\else
        !          4832:     \expandafter\parsearg
        !          4833:   \fi \next}
        !          4834:
        !          4835: % We mant to disable all macros during \shipout so that they are not
        !          4836: % expanded by \write.
        !          4837: \def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}%
        !          4838:   \edef\next{\macrolist}\expandafter\endgroup\next}
        !          4839:
1.1       maekawa  4840:
1.1.1.2 ! maekawa  4841: % @alias.
        !          4842: \def\alias#1=#2{\gdef#1{#2}}
1.1       maekawa  4843:
                   4844:
1.1.1.2 ! maekawa  4845: \message{cross references,}
        !          4846: \newwrite\auxfile
        !          4847:
        !          4848: \newif\ifhavexrefs    % True if xref values are known.
1.1       maekawa  4849: \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
                   4850:
1.1.1.2 ! maekawa  4851: % @inforef is relatively simple.
        !          4852: \def\inforef #1{\inforefzzz #1,,,,**}
        !          4853: \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
        !          4854:   node \samp{\ignorespaces#1{}}}
        !          4855:
        !          4856: % @node's job is to define \lastnode.
        !          4857: \def\node{\ENVcheck\parsearg\nodezzz}
        !          4858: \def\nodezzz#1{\nodexxx [#1,]}
        !          4859: \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
        !          4860: \let\nwnode=\node
        !          4861: \let\lastnode=\relax
        !          4862:
        !          4863: % The sectioning commands (@chapter, etc.) call these.
        !          4864: \def\donoderef{%
        !          4865:   \ifx\lastnode\relax\else
        !          4866:     \expandafter\expandafter\expandafter\setref{\lastnode}%
        !          4867:       {Ysectionnumberandtype}%
        !          4868:     \global\let\lastnode=\relax
        !          4869:   \fi
        !          4870: }
        !          4871: \def\unnumbnoderef{%
        !          4872:   \ifx\lastnode\relax\else
        !          4873:     \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}%
        !          4874:     \global\let\lastnode=\relax
        !          4875:   \fi
        !          4876: }
        !          4877: \def\appendixnoderef{%
        !          4878:   \ifx\lastnode\relax\else
        !          4879:     \expandafter\expandafter\expandafter\setref{\lastnode}%
        !          4880:       {Yappendixletterandtype}%
        !          4881:     \global\let\lastnode=\relax
        !          4882:   \fi
        !          4883: }
        !          4884:
        !          4885:
        !          4886: % @anchor{NAME} -- define xref target at arbitrary point.
        !          4887: %
        !          4888: { \catcode`\@ = 11
        !          4889: % From latex.ltx, to make @anchor truely invisible.
        !          4890: \newdimen\@savsk
        !          4891: \newcount\@savsf
        !          4892: \gdef\@bsphack{\relax
        !          4893:   \ifhmode \@savsk\lastskip \@savsf\spacefactor \fi
        !          4894: }
        !          4895: \gdef\@esphack{\relax
        !          4896:   \ifhmode \spacefactor\@savsf
        !          4897:     \ifdim\@savsk>\z@ \ignorespaces \fi
        !          4898:   \fi
        !          4899: }
        !          4900: \gdef\anchor#1{\@bsphack \setref{#1}{Ynothing}\@esphack}
        !          4901: }
        !          4902:
        !          4903: % \setref{NAME}{SNT} defines a cross-reference point NAME, namely
        !          4904: % NAME-title, NAME-pg, and NAME-SNT.  Called from \foonoderef.  We have
        !          4905: % to set \indexdummies so commands such as @code in a section title
        !          4906: % aren't expanded.  It would be nicer not to expand the titles in the
        !          4907: % first place, but there's so many layers that that is hard to do.
        !          4908: %
        !          4909: \def\setref#1#2{{%
        !          4910:   \indexdummies
        !          4911:   \dosetq{#1-title}{Ytitle}%
        !          4912:   \dosetq{#1-pg}{Ypagenumber}%
        !          4913:   \dosetq{#1-snt}{#2}%
        !          4914: }}
1.1       maekawa  4915:
1.1.1.2 ! maekawa  4916: % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
        !          4917: % the node name, #2 the name of the Info cross-reference, #3 the printed
        !          4918: % node name, #4 the name of the Info file, #5 the name of the printed
        !          4919: % manual.  All but the node name can be omitted.
1.1       maekawa  4920: %
                   4921: \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
                   4922: \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
                   4923: \def\ref#1{\xrefX[#1,,,,,,,]}
                   4924: \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
                   4925:   \def\printedmanual{\ignorespaces #5}%
                   4926:   \def\printednodename{\ignorespaces #3}%
                   4927:   \setbox1=\hbox{\printedmanual}%
                   4928:   \setbox0=\hbox{\printednodename}%
                   4929:   \ifdim \wd0 = 0pt
                   4930:     % No printed node name was explicitly given.
                   4931:     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
                   4932:       % Use the node name inside the square brackets.
                   4933:       \def\printednodename{\ignorespaces #1}%
                   4934:     \else
                   4935:       % Use the actual chapter/section title appear inside
                   4936:       % the square brackets.  Use the real section title if we have it.
1.1.1.2 ! maekawa  4937:       \ifdim \wd1 > 0pt
1.1       maekawa  4938:         % It is in another manual, so we don't have it.
                   4939:         \def\printednodename{\ignorespaces #1}%
                   4940:       \else
                   4941:         \ifhavexrefs
                   4942:           % We know the real title if we have the xref values.
                   4943:           \def\printednodename{\refx{#1-title}{}}%
                   4944:         \else
                   4945:           % Otherwise just copy the Info node name.
                   4946:           \def\printednodename{\ignorespaces #1}%
                   4947:         \fi%
                   4948:       \fi
                   4949:     \fi
                   4950:   \fi
                   4951:   %
                   4952:   % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
                   4953:   % insert empty discretionaries after hyphens, which means that it will
                   4954:   % not find a line break at a hyphen in a node names.  Since some manuals
                   4955:   % are best written with fairly long node names, containing hyphens, this
                   4956:   % is a loss.  Therefore, we give the text of the node name again, so it
                   4957:   % is as if TeX is seeing it for the first time.
                   4958:   \ifdim \wd1 > 0pt
1.1.1.2 ! maekawa  4959:     \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}%
1.1       maekawa  4960:   \else
                   4961:     % _ (for example) has to be the character _ for the purposes of the
                   4962:     % control sequence corresponding to the node, but it has to expand
                   4963:     % into the usual \leavevmode...\vrule stuff for purposes of
                   4964:     % printing. So we \turnoffactive for the \refx-snt, back on for the
                   4965:     % printing, back off for the \refx-pg.
1.1.1.2 ! maekawa  4966:     {\normalturnoffactive
        !          4967:      % Only output a following space if the -snt ref is nonempty; for
        !          4968:      % @unnumbered and @anchor, it won't be.
        !          4969:      \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
        !          4970:      \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
        !          4971:     }%
        !          4972:     % [mynode],
        !          4973:     [\printednodename],\space
        !          4974:     % page 3
1.1       maekawa  4975:     \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
                   4976:   \fi
                   4977: \endgroup}
                   4978:
                   4979: % \dosetq is the interface for calls from other macros
                   4980:
1.1.1.2 ! maekawa  4981: % Use \normalturnoffactive so that punctuation chars such as underscore
        !          4982: % and backslash work in node names.  (\turnoffactive doesn't do \.)
        !          4983: \def\dosetq#1#2{%
        !          4984:   {\let\folio=0%
        !          4985:    \normalturnoffactive
        !          4986:    \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
        !          4987:    \iflinks
        !          4988:      \next
        !          4989:    \fi
        !          4990:   }%
        !          4991: }
1.1       maekawa  4992:
                   4993: % \internalsetq {foo}{page} expands into
                   4994: % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
                   4995: % When the aux file is read, ' is the escape character
                   4996:
                   4997: \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
                   4998:
                   4999: % Things to be expanded by \internalsetq
                   5000:
                   5001: \def\Ypagenumber{\folio}
                   5002:
                   5003: \def\Ytitle{\thissection}
                   5004:
                   5005: \def\Ynothing{}
                   5006:
                   5007: \def\Ysectionnumberandtype{%
                   5008: \ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
                   5009: \else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
                   5010: \else \ifnum \subsubsecno=0 %
                   5011: \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
                   5012: \else %
                   5013: \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
                   5014: \fi \fi \fi }
                   5015:
                   5016: \def\Yappendixletterandtype{%
                   5017: \ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
                   5018: \else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
                   5019: \else \ifnum \subsubsecno=0 %
                   5020: \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
                   5021: \else %
                   5022: \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
                   5023: \fi \fi \fi }
                   5024:
                   5025: \gdef\xreftie{'tie}
                   5026:
                   5027: % Use TeX 3.0's \inputlineno to get the line number, for better error
                   5028: % messages, but if we're using an old version of TeX, don't do anything.
                   5029: %
                   5030: \ifx\inputlineno\thisisundefined
                   5031:   \let\linenumber = \empty % Non-3.0.
                   5032: \else
                   5033:   \def\linenumber{\the\inputlineno:\space}
                   5034: \fi
                   5035:
                   5036: % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
                   5037: % If its value is nonempty, SUFFIX is output afterward.
                   5038:
                   5039: \def\refx#1#2{%
                   5040:   \expandafter\ifx\csname X#1\endcsname\relax
                   5041:     % If not defined, say something at least.
1.1.1.2 ! maekawa  5042:     \angleleft un\-de\-fined\angleright
        !          5043:     \iflinks
        !          5044:       \ifhavexrefs
        !          5045:         \message{\linenumber Undefined cross reference `#1'.}%
        !          5046:       \else
        !          5047:         \ifwarnedxrefs\else
        !          5048:           \global\warnedxrefstrue
        !          5049:           \message{Cross reference values unknown; you must run TeX again.}%
        !          5050:         \fi
1.1       maekawa  5051:       \fi
                   5052:     \fi
                   5053:   \else
                   5054:     % It's defined, so just use it.
                   5055:     \csname X#1\endcsname
                   5056:   \fi
                   5057:   #2% Output the suffix in any case.
                   5058: }
                   5059:
                   5060: % This is the macro invoked by entries in the aux file.
1.1.1.2 ! maekawa  5061: %
        !          5062: \def\xrdef#1{\begingroup
        !          5063:   % Reenable \ as an escape while reading the second argument.
        !          5064:   \catcode`\\ = 0
        !          5065:   \afterassignment\endgroup
        !          5066:   \expandafter\gdef\csname X#1\endcsname
        !          5067: }
1.1       maekawa  5068:
1.1.1.2 ! maekawa  5069: % Read the last existing aux file, if any.  No error if none exists.
        !          5070: \def\readauxfile{\begingroup
        !          5071:   \catcode`\^^@=\other
        !          5072:   \catcode`\^^A=\other
        !          5073:   \catcode`\^^B=\other
        !          5074:   \catcode`\^^C=\other
        !          5075:   \catcode`\^^D=\other
        !          5076:   \catcode`\^^E=\other
        !          5077:   \catcode`\^^F=\other
        !          5078:   \catcode`\^^G=\other
        !          5079:   \catcode`\^^H=\other
        !          5080:   \catcode`\^^K=\other
        !          5081:   \catcode`\^^L=\other
        !          5082:   \catcode`\^^N=\other
        !          5083:   \catcode`\^^P=\other
        !          5084:   \catcode`\^^Q=\other
        !          5085:   \catcode`\^^R=\other
        !          5086:   \catcode`\^^S=\other
        !          5087:   \catcode`\^^T=\other
        !          5088:   \catcode`\^^U=\other
        !          5089:   \catcode`\^^V=\other
        !          5090:   \catcode`\^^W=\other
        !          5091:   \catcode`\^^X=\other
        !          5092:   \catcode`\^^Z=\other
        !          5093:   \catcode`\^^[=\other
        !          5094:   \catcode`\^^\=\other
        !          5095:   \catcode`\^^]=\other
        !          5096:   \catcode`\^^^=\other
        !          5097:   \catcode`\^^_=\other
        !          5098:   \catcode`\@=\other
        !          5099:   \catcode`\^=\other
        !          5100:   % It was suggested to define this as 7, which would allow ^^e4 etc.
        !          5101:   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
        !          5102:   % supported in the main text, it doesn't seem desirable.  Furthermore,
        !          5103:   % that is not enough: for node names that actually contain a ^
        !          5104:   % character, we would end up writing a line like this: 'xrdef {'hat
        !          5105:   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
        !          5106:   % argument, and \hat is not an expandable control sequence.  It could
        !          5107:   % all be worked out, but why?  Either we support ^^ or we don't.
        !          5108:   %
        !          5109:   % The other change necessary for this was to define \auxhat:
        !          5110:   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
        !          5111:   % and then to call \auxhat in \setq.
        !          5112:   %
        !          5113:   \catcode`\~=\other
        !          5114:   \catcode`\[=\other
        !          5115:   \catcode`\]=\other
        !          5116:   \catcode`\"=\other
        !          5117:   \catcode`\_=\other
        !          5118:   \catcode`\|=\other
        !          5119:   \catcode`\<=\other
        !          5120:   \catcode`\>=\other
        !          5121:   \catcode`\$=\other
        !          5122:   \catcode`\#=\other
        !          5123:   \catcode`\&=\other
        !          5124:   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
        !          5125:   % Make the characters 128-255 be printing characters
        !          5126:   {%
        !          5127:     \count 1=128
        !          5128:     \def\loop{%
        !          5129:       \catcode\count 1=\other
        !          5130:       \advance\count 1 by 1
        !          5131:       \ifnum \count 1<256 \loop \fi
        !          5132:     }%
1.1       maekawa  5133:   }%
1.1.1.2 ! maekawa  5134:   % The aux file uses ' as the escape (for now).
        !          5135:   % Turn off \ as an escape so we do not lose on
        !          5136:   % entries which were dumped with control sequences in their names.
        !          5137:   % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
        !          5138:   % Reference to such entries still does not work the way one would wish,
        !          5139:   % but at least they do not bomb out when the aux file is read in.
        !          5140:   \catcode`\{=1
        !          5141:   \catcode`\}=2
        !          5142:   \catcode`\%=\other
        !          5143:   \catcode`\'=0
        !          5144:   \catcode`\\=\other
        !          5145:   %
        !          5146:   \openin 1 \jobname.aux
        !          5147:   \ifeof 1 \else
        !          5148:     \closein 1
        !          5149:     \input \jobname.aux
        !          5150:     \global\havexrefstrue
        !          5151:     \global\warnedobstrue
        !          5152:   \fi
        !          5153:   % Open the new aux file.  TeX will close it automatically at exit.
        !          5154:   \openout\auxfile=\jobname.aux
1.1       maekawa  5155: \endgroup}
                   5156:
                   5157:
                   5158: % Footnotes.
                   5159:
                   5160: \newcount \footnoteno
                   5161:
                   5162: % The trailing space in the following definition for supereject is
                   5163: % vital for proper filling; pages come out unaligned when you do a
                   5164: % pagealignmacro call if that space before the closing brace is
1.1.1.2 ! maekawa  5165: % removed. (Generally, numeric constants should always be followed by a
        !          5166: % space to prevent strange expansion errors.)
1.1       maekawa  5167: \def\supereject{\par\penalty -20000\footnoteno =0 }
                   5168:
1.1.1.2 ! maekawa  5169: % @footnotestyle is meaningful for info output only.
1.1       maekawa  5170: \let\footnotestyle=\comment
                   5171:
                   5172: \let\ptexfootnote=\footnote
                   5173:
                   5174: {\catcode `\@=11
                   5175: %
                   5176: % Auto-number footnotes.  Otherwise like plain.
                   5177: \gdef\footnote{%
                   5178:   \global\advance\footnoteno by \@ne
                   5179:   \edef\thisfootno{$^{\the\footnoteno}$}%
                   5180:   %
                   5181:   % In case the footnote comes at the end of a sentence, preserve the
                   5182:   % extra spacing after we do the footnote number.
                   5183:   \let\@sf\empty
                   5184:   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
                   5185:   %
                   5186:   % Remove inadvertent blank space before typesetting the footnote number.
                   5187:   \unskip
                   5188:   \thisfootno\@sf
                   5189:   \footnotezzz
                   5190: }%
                   5191:
                   5192: % Don't bother with the trickery in plain.tex to not require the
                   5193: % footnote text as a parameter.  Our footnotes don't need to be so general.
                   5194: %
1.1.1.2 ! maekawa  5195: % Oh yes, they do; otherwise, @ifset and anything else that uses
        !          5196: % \parseargline fail inside footnotes because the tokens are fixed when
        !          5197: % the footnote is read.  --karl, 16nov96.
        !          5198: %
        !          5199: \long\gdef\footnotezzz{\insert\footins\bgroup
1.1       maekawa  5200:   % We want to typeset this text as a normal paragraph, even if the
                   5201:   % footnote reference occurs in (for example) a display environment.
                   5202:   % So reset some parameters.
                   5203:   \interlinepenalty\interfootnotelinepenalty
                   5204:   \splittopskip\ht\strutbox % top baseline for broken footnotes
                   5205:   \splitmaxdepth\dp\strutbox
                   5206:   \floatingpenalty\@MM
                   5207:   \leftskip\z@skip
                   5208:   \rightskip\z@skip
                   5209:   \spaceskip\z@skip
                   5210:   \xspaceskip\z@skip
                   5211:   \parindent\defaultparindent
                   5212:   %
                   5213:   % Hang the footnote text off the number.
                   5214:   \hang
                   5215:   \textindent{\thisfootno}%
                   5216:   %
                   5217:   % Don't crash into the line above the footnote text.  Since this
                   5218:   % expands into a box, it must come within the paragraph, lest it
                   5219:   % provide a place where TeX can split the footnote.
                   5220:   \footstrut
1.1.1.2 ! maekawa  5221:   \futurelet\next\fo@t
1.1       maekawa  5222: }
1.1.1.2 ! maekawa  5223: \def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
        !          5224:   \else\let\next\f@t\fi \next}
        !          5225: \def\f@@t{\bgroup\aftergroup\@foot\let\next}
        !          5226: \def\f@t#1{#1\@foot}
        !          5227: \def\@foot{\strut\egroup}
1.1       maekawa  5228:
                   5229: }%end \catcode `\@=11
                   5230:
                   5231: % Set the baselineskip to #1, and the lineskip and strut size
                   5232: % correspondingly.  There is no deep meaning behind these magic numbers
                   5233: % used as factors; they just match (closely enough) what Knuth defined.
                   5234: %
                   5235: \def\lineskipfactor{.08333}
                   5236: \def\strutheightpercent{.70833}
                   5237: \def\strutdepthpercent {.29167}
                   5238: %
                   5239: \def\setleading#1{%
                   5240:   \normalbaselineskip = #1\relax
                   5241:   \normallineskip = \lineskipfactor\normalbaselineskip
                   5242:   \normalbaselines
                   5243:   \setbox\strutbox =\hbox{%
                   5244:     \vrule width0pt height\strutheightpercent\baselineskip
                   5245:                     depth \strutdepthpercent \baselineskip
                   5246:   }%
                   5247: }
                   5248:
                   5249: % @| inserts a changebar to the left of the current line.  It should
                   5250: % surround any changed text.  This approach does *not* work if the
                   5251: % change spans more than two lines of output.  To handle that, we would
                   5252: % have adopt a much more difficult approach (putting marks into the main
                   5253: % vertical list for the beginning and end of each change).
                   5254: %
                   5255: \def\|{%
                   5256:   % \vadjust can only be used in horizontal mode.
                   5257:   \leavevmode
                   5258:   %
                   5259:   % Append this vertical mode material after the current line in the output.
                   5260:   \vadjust{%
                   5261:     % We want to insert a rule with the height and depth of the current
                   5262:     % leading; that is exactly what \strutbox is supposed to record.
                   5263:     \vskip-\baselineskip
                   5264:     %
                   5265:     % \vadjust-items are inserted at the left edge of the type.  So
                   5266:     % the \llap here moves out into the left-hand margin.
                   5267:     \llap{%
                   5268:       %
                   5269:       % For a thicker or thinner bar, change the `1pt'.
                   5270:       \vrule height\baselineskip width1pt
                   5271:       %
                   5272:       % This is the space between the bar and the text.
                   5273:       \hskip 12pt
                   5274:     }%
                   5275:   }%
                   5276: }
                   5277:
                   5278: % For a final copy, take out the rectangles
                   5279: % that mark overfull boxes (in case you have decided
                   5280: % that the text looks ok even though it passes the margin).
                   5281: %
                   5282: \def\finalout{\overfullrule=0pt}
                   5283:
1.1.1.2 ! maekawa  5284: % @image.  We use the macros from epsf.tex to support this.
        !          5285: % If epsf.tex is not installed and @image is used, we complain.
        !          5286: %
        !          5287: % Check for and read epsf.tex up front.  If we read it only at @image
        !          5288: % time, we might be inside a group, and then its definitions would get
        !          5289: % undone and the next image would fail.
        !          5290: \openin 1 = epsf.tex
        !          5291: \ifeof 1 \else
        !          5292:   \closein 1
        !          5293:   % Do not bother showing banner with post-v2.7 epsf.tex (available in
        !          5294:   % doc/epsf.tex until it shows up on ctan).
        !          5295:   \def\epsfannounce{\toks0 = }%
        !          5296:   \input epsf.tex
        !          5297: \fi
        !          5298: %
        !          5299: % We will only complain once about lack of epsf.tex.
        !          5300: \newif\ifwarnednoepsf
        !          5301: \newhelp\noepsfhelp{epsf.tex must be installed for images to
        !          5302:   work.  It is also included in the Texinfo distribution, or you can get
        !          5303:   it from ftp://tug.org/tex/epsf.tex.}
        !          5304: %
        !          5305: \def\image#1{%
        !          5306:   \ifx\epsfbox\undefined
        !          5307:     \ifwarnednoepsf \else
        !          5308:       \errhelp = \noepsfhelp
        !          5309:       \errmessage{epsf.tex not found, images will be ignored}%
        !          5310:       \global\warnednoepsftrue
        !          5311:     \fi
        !          5312:   \else
        !          5313:     \imagexxx #1,,,\finish
        !          5314:   \fi
        !          5315: }
        !          5316: %
        !          5317: % Arguments to @image:
        !          5318: % #1 is (mandatory) image filename; we tack on .eps extension.
        !          5319: % #2 is (optional) width, #3 is (optional) height.
        !          5320: % #4 is just the usual extra ignored arg for parsing this stuff.
        !          5321: \def\imagexxx#1,#2,#3,#4\finish{%
        !          5322:   \ifx\pdfoutput\undefined
        !          5323:     % \epsfbox itself resets \epsf?size at each figure.
        !          5324:     \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
        !          5325:     \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
        !          5326:     \begingroup
        !          5327:       \catcode`\^^M = 5 % in case we're inside an example
        !          5328:       % If the image is by itself, center it.
        !          5329:       \ifvmode
        !          5330:         \nobreak\bigskip
        !          5331:         % Usually we'll have text after the image which will insert
        !          5332:         % \parskip glue, so insert it here too to equalize the space
        !          5333:         % above and below.
        !          5334:         \nobreak\vskip\parskip
        !          5335:         \nobreak
        !          5336:         \centerline{\epsfbox{#1.eps}}%
        !          5337:         \bigbreak
        !          5338:       \else
        !          5339:         % In the middle of a paragraph, no extra space.
        !          5340:         \epsfbox{#1.eps}%
        !          5341:       \fi
        !          5342:     \endgroup
        !          5343:   \else
        !          5344:     \centerline{\pdfimage #1.pdf}%
        !          5345:   \fi
        !          5346: }
1.1       maekawa  5347:
                   5348:
1.1.1.2 ! maekawa  5349: \message{localization,}
1.1       maekawa  5350:
1.1.1.2 ! maekawa  5351: % @documentlanguage is usually given very early, just after
        !          5352: % @setfilename.  If done too late, it may not override everything
        !          5353: % properly.  Single argument is the language abbreviation.
        !          5354: % It would be nice if we could set up a hyphenation file here.
        !          5355: %
        !          5356: \def\documentlanguage{\parsearg\dodocumentlanguage}
        !          5357: \def\dodocumentlanguage#1{%
        !          5358:   \tex % read txi-??.tex file in plain TeX.
        !          5359:   % Read the file if it exists.
        !          5360:   \openin 1 txi-#1.tex
        !          5361:   \ifeof1
        !          5362:     \errhelp = \nolanghelp
        !          5363:     \errmessage{Cannot read language file txi-#1.tex}%
        !          5364:     \let\temp = \relax
        !          5365:   \else
        !          5366:     \def\temp{\input txi-#1.tex }%
        !          5367:   \fi
        !          5368:   \temp
        !          5369:   \endgroup
1.1       maekawa  5370: }
1.1.1.2 ! maekawa  5371: \newhelp\nolanghelp{The given language definition file cannot be found or
        !          5372: is empty.  Maybe you need to install it?  In the current directory
        !          5373: should work if nowhere else does.}
        !          5374:
        !          5375:
        !          5376: % @documentencoding should change something in TeX eventually, most
        !          5377: % likely, but for now just recognize it.
        !          5378: \let\documentencoding = \comment
1.1       maekawa  5379:
                   5380:
1.1.1.2 ! maekawa  5381: % Page size parameters.
        !          5382: %
1.1       maekawa  5383: \newdimen\defaultparindent \defaultparindent = 15pt
1.1.1.2 ! maekawa  5384:
        !          5385: \chapheadingskip = 15pt plus 4pt minus 2pt
        !          5386: \secheadingskip = 12pt plus 3pt minus 2pt
        !          5387: \subsecheadingskip = 9pt plus 2pt minus 2pt
1.1       maekawa  5388:
                   5389: % Prevent underfull vbox error messages.
1.1.1.2 ! maekawa  5390: \vbadness = 10000
        !          5391:
        !          5392: % Don't be so finicky about underfull hboxes, either.
        !          5393: \hbadness = 2000
1.1       maekawa  5394:
                   5395: % Following George Bush, just get rid of widows and orphans.
                   5396: \widowpenalty=10000
                   5397: \clubpenalty=10000
                   5398:
                   5399: % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
                   5400: % using an old version of TeX, don't do anything.  We want the amount of
                   5401: % stretch added to depend on the line length, hence the dependence on
1.1.1.2 ! maekawa  5402: % \hsize.  We call this whenever the paper size is set.
1.1       maekawa  5403: %
1.1.1.2 ! maekawa  5404: \def\setemergencystretch{%
        !          5405:   \ifx\emergencystretch\thisisundefined
        !          5406:     % Allow us to assign to \emergencystretch anyway.
        !          5407:     \def\emergencystretch{\dimen0}%
        !          5408:   \else
        !          5409:     \emergencystretch = \hsize
        !          5410:     \divide\emergencystretch by 40
        !          5411:   \fi
        !          5412: }
1.1       maekawa  5413:
1.1.1.2 ! maekawa  5414: % Parameters in order: 1) textheight; 2) textwidth; 3) voffset;
        !          5415: % 4) hoffset; 5) binding offset; 6) topskip.  Then whoever calls us can
        !          5416: % set \parskip and call \setleading for \baselineskip.
        !          5417: %
        !          5418: \def\internalpagesizes#1#2#3#4#5#6{%
        !          5419:   \voffset = #3\relax
        !          5420:   \topskip = #6\relax
        !          5421:   \splittopskip = \topskip
        !          5422:   %
        !          5423:   \vsize = #1\relax
        !          5424:   \advance\vsize by \topskip
        !          5425:   \outervsize = \vsize
        !          5426:   \advance\outervsize by 2\topandbottommargin
        !          5427:   \pageheight = \vsize
        !          5428:   %
        !          5429:   \hsize = #2\relax
        !          5430:   \outerhsize = \hsize
        !          5431:   \advance\outerhsize by 0.5in
        !          5432:   \pagewidth = \hsize
        !          5433:   %
        !          5434:   \normaloffset = #4\relax
        !          5435:   \bindingoffset = #5\relax
        !          5436:   %
        !          5437:   \parindent = \defaultparindent
        !          5438:   \setemergencystretch
        !          5439: }
        !          5440:
        !          5441: % @letterpaper (the default).
        !          5442: \def\letterpaper{{\globaldefs = 1
        !          5443:   \parskip = 3pt plus 2pt minus 1pt
        !          5444:   \setleading{13.2pt}%
        !          5445:   %
        !          5446:   % If page is nothing but text, make it come out even.
        !          5447:   \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}%
        !          5448: }}
1.1       maekawa  5449:
1.1.1.2 ! maekawa  5450: % Use @smallbook to reset parameters for 7x9.5 (or so) format.
        !          5451: \def\smallbook{{\globaldefs = 1
        !          5452:   \parskip = 2pt plus 1pt
        !          5453:   \setleading{12pt}%
        !          5454:   %
        !          5455:   \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}%
        !          5456:   %
        !          5457:   \lispnarrowing = 0.3in
        !          5458:   \tolerance = 700
        !          5459:   \hfuzz = 1pt
        !          5460:   \contentsrightmargin = 0pt
        !          5461:   \deftypemargin = 0pt
        !          5462:   \defbodyindent = .5cm
        !          5463:   %
        !          5464:   \let\smalldisplay = \smalldisplayx
        !          5465:   \let\smallexample = \smalllispx
        !          5466:   \let\smallformat = \smallformatx
        !          5467:   \let\smalllisp = \smalllispx
        !          5468: }}
1.1       maekawa  5469:
                   5470: % Use @afourpaper to print on European A4 paper.
1.1.1.2 ! maekawa  5471: \def\afourpaper{{\globaldefs = 1
        !          5472:   \setleading{12pt}%
        !          5473:   \parskip = 3pt plus 2pt minus 1pt
        !          5474:   %
        !          5475:   \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}%
        !          5476:   %
        !          5477:   \tolerance = 700
        !          5478:   \hfuzz = 1pt
        !          5479: }}
1.1       maekawa  5480:
                   5481: % A specific text layout, 24x15cm overall, intended for A4 paper.  Top margin
                   5482: % 29mm, hence bottom margin 28mm, nominal side margin 3cm.
1.1.1.2 ! maekawa  5483: \def\afourlatex{{\globaldefs = 1
        !          5484:   \setleading{13.6pt}%
        !          5485:   %
        !          5486:   \afourpaper
        !          5487:   \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}%
        !          5488:   %
        !          5489:   \globaldefs = 0
        !          5490: }}
1.1       maekawa  5491:
                   5492: % Use @afourwide to print on European A4 paper in wide format.
1.1.1.2 ! maekawa  5493: \def\afourwide{%
        !          5494:   \afourpaper
        !          5495:   \internalpagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}%
        !          5496:   %
        !          5497:   \globaldefs = 0
        !          5498: }
        !          5499:
        !          5500: % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
        !          5501: % Perhaps we should allow setting the margins, \topskip, \parskip,
        !          5502: % and/or leading, also. Or perhaps we should compute them somehow.
        !          5503: %
        !          5504: \def\pagesizes{\parsearg\pagesizesxxx}
        !          5505: \def\pagesizesxxx#1{\pagesizesyyy #1,,\finish}
        !          5506: \def\pagesizesyyy#1,#2,#3\finish{{%
        !          5507:   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
        !          5508:   \globaldefs = 1
        !          5509:   %
        !          5510:   \parskip = 3pt plus 2pt minus 1pt
        !          5511:   \setleading{13.2pt}%
        !          5512:   %
        !          5513:   \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}%
        !          5514: }}
        !          5515:
        !          5516: % Set default to letter.
        !          5517: %
        !          5518: \letterpaper
        !          5519:
        !          5520: \message{and turning on texinfo input format.}
1.1       maekawa  5521:
                   5522: % Define macros to output various characters with catcode for normal text.
                   5523: \catcode`\"=\other
                   5524: \catcode`\~=\other
                   5525: \catcode`\^=\other
                   5526: \catcode`\_=\other
                   5527: \catcode`\|=\other
                   5528: \catcode`\<=\other
                   5529: \catcode`\>=\other
                   5530: \catcode`\+=\other
1.1.1.2 ! maekawa  5531: \catcode`\$=\other
1.1       maekawa  5532: \def\normaldoublequote{"}
                   5533: \def\normaltilde{~}
                   5534: \def\normalcaret{^}
                   5535: \def\normalunderscore{_}
                   5536: \def\normalverticalbar{|}
                   5537: \def\normalless{<}
                   5538: \def\normalgreater{>}
                   5539: \def\normalplus{+}
1.1.1.2 ! maekawa  5540: \def\normaldollar{$}
1.1       maekawa  5541:
                   5542: % This macro is used to make a character print one way in ttfont
                   5543: % where it can probably just be output, and another way in other fonts,
                   5544: % where something hairier probably needs to be done.
                   5545: %
                   5546: % #1 is what to print if we are indeed using \tt; #2 is what to print
                   5547: % otherwise.  Since all the Computer Modern typewriter fonts have zero
                   5548: % interword stretch (and shrink), and it is reasonable to expect all
                   5549: % typewriter fonts to have this, we can check that font parameter.
                   5550: %
1.1.1.2 ! maekawa  5551: \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
        !          5552:
        !          5553: % Same as above, but check for italic font.  Actually this also catches
        !          5554: % non-italic slanted fonts since it is impossible to distinguish them from
        !          5555: % italic fonts.  But since this is only used by $ and it uses \sl anyway
        !          5556: % this is not a problem.
        !          5557: \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
1.1       maekawa  5558:
                   5559: % Turn off all special characters except @
                   5560: % (and those which the user can use as if they were ordinary).
                   5561: % Most of these we simply print from the \tt font, but for some, we can
                   5562: % use math or other variants that look better in normal text.
                   5563:
                   5564: \catcode`\"=\active
1.1.1.2 ! maekawa  5565: \def\activedoublequote{{\tt\char34}}
1.1       maekawa  5566: \let"=\activedoublequote
                   5567: \catcode`\~=\active
1.1.1.2 ! maekawa  5568: \def~{{\tt\char126}}
1.1       maekawa  5569: \chardef\hat=`\^
                   5570: \catcode`\^=\active
                   5571: \def^{{\tt \hat}}
                   5572:
                   5573: \catcode`\_=\active
                   5574: \def_{\ifusingtt\normalunderscore\_}
                   5575: % Subroutine for the previous macro.
                   5576: \def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
                   5577:
                   5578: \catcode`\|=\active
1.1.1.2 ! maekawa  5579: \def|{{\tt\char124}}
1.1       maekawa  5580: \chardef \less=`\<
                   5581: \catcode`\<=\active
                   5582: \def<{{\tt \less}}
                   5583: \chardef \gtr=`\>
                   5584: \catcode`\>=\active
                   5585: \def>{{\tt \gtr}}
                   5586: \catcode`\+=\active
                   5587: \def+{{\tt \char 43}}
1.1.1.2 ! maekawa  5588: \catcode`\$=\active
        !          5589: \def${\ifusingit{{\sl\$}}\normaldollar}
1.1       maekawa  5590: %\catcode 27=\active
                   5591: %\def^^[{$\diamondsuit$}
                   5592:
                   5593: % Set up an active definition for =, but don't enable it most of the time.
                   5594: {\catcode`\==\active
                   5595: \global\def={{\tt \char 61}}}
                   5596:
                   5597: \catcode`+=\active
                   5598: \catcode`\_=\active
                   5599:
                   5600: % If a .fmt file is being used, characters that might appear in a file
                   5601: % name cannot be active until we have parsed the command line.
                   5602: % So turn them off again, and have \everyjob (or @setfilename) turn them on.
                   5603: % \otherifyactive is called near the end of this file.
                   5604: \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
                   5605:
                   5606: \catcode`\@=0
                   5607:
                   5608: % \rawbackslashxx output one backslash character in current font
                   5609: \global\chardef\rawbackslashxx=`\\
                   5610: %{\catcode`\\=\other
                   5611: %@gdef@rawbackslashxx{\}}
                   5612:
                   5613: % \rawbackslash redefines \ as input to do \rawbackslashxx.
                   5614: {\catcode`\\=\active
                   5615: @gdef@rawbackslash{@let\=@rawbackslashxx }}
                   5616:
                   5617: % \normalbackslash outputs one backslash in fixed width font.
                   5618: \def\normalbackslash{{\tt\rawbackslashxx}}
                   5619:
                   5620: % \catcode 17=0   % Define control-q
                   5621: \catcode`\\=\active
                   5622:
                   5623: % Used sometimes to turn off (effectively) the active characters
                   5624: % even after parsing them.
                   5625: @def@turnoffactive{@let"=@normaldoublequote
                   5626: @let\=@realbackslash
                   5627: @let~=@normaltilde
                   5628: @let^=@normalcaret
                   5629: @let_=@normalunderscore
                   5630: @let|=@normalverticalbar
                   5631: @let<=@normalless
                   5632: @let>=@normalgreater
1.1.1.2 ! maekawa  5633: @let+=@normalplus
        !          5634: @let$=@normaldollar}
1.1       maekawa  5635:
                   5636: @def@normalturnoffactive{@let"=@normaldoublequote
                   5637: @let\=@normalbackslash
                   5638: @let~=@normaltilde
                   5639: @let^=@normalcaret
                   5640: @let_=@normalunderscore
                   5641: @let|=@normalverticalbar
                   5642: @let<=@normalless
                   5643: @let>=@normalgreater
1.1.1.2 ! maekawa  5644: @let+=@normalplus
        !          5645: @let$=@normaldollar}
1.1       maekawa  5646:
                   5647: % Make _ and + \other characters, temporarily.
                   5648: % This is canceled by @fixbackslash.
                   5649: @otherifyactive
                   5650:
                   5651: % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
                   5652: % That is what \eatinput is for; after that, the `\' should revert to printing
                   5653: % a backslash.
                   5654: %
                   5655: @gdef@eatinput input texinfo{@fixbackslash}
                   5656: @global@let\ = @eatinput
                   5657:
                   5658: % On the other hand, perhaps the file did not have a `\input texinfo'. Then
                   5659: % the first `\{ in the file would cause an error. This macro tries to fix
                   5660: % that, assuming it is called before the first `\' could plausibly occur.
                   5661: % Also back turn on active characters that might appear in the input
                   5662: % file name, in case not using a pre-dumped format.
                   5663: %
1.1.1.2 ! maekawa  5664: @gdef@fixbackslash{%
        !          5665:   @ifx\@eatinput @let\ = @normalbackslash @fi
        !          5666:   @catcode`+=@active
        !          5667:   @catcode`@_=@active
        !          5668: }
        !          5669:
        !          5670: % Say @foo, not \foo, in error messages.
        !          5671: @escapechar = `@@
1.1       maekawa  5672:
1.1.1.2 ! maekawa  5673: % These look ok in all fonts, so just make them not special.
        !          5674: @catcode`@& = @other
        !          5675: @catcode`@# = @other
        !          5676: @catcode`@% = @other
1.1       maekawa  5677:
1.1.1.2 ! maekawa  5678: @c Set initial fonts.
1.1       maekawa  5679: @textfonts
                   5680: @rm
                   5681:
1.1.1.2 ! maekawa  5682:
1.1       maekawa  5683: @c Local variables:
1.1.1.2 ! maekawa  5684: @c eval: (add-hook 'write-file-hooks 'time-stamp)
1.1       maekawa  5685: @c page-delimiter: "^\\\\message"
1.1.1.2 ! maekawa  5686: @c time-stamp-start: "def\\\\texinfoversion{"
        !          5687: @c time-stamp-format: "%:y-%02m-%02d.%H"
        !          5688: @c time-stamp-end: "}"
1.1       maekawa  5689: @c End:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>