"Fossies" - the Fresh Open Source Software Archive

Member "texinfo-6.5/doc/texinfo.tex" (27 Aug 2017, 380753 Bytes) of package /linux/misc/texinfo-6.5.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TeX and LaTeX source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 % texinfo.tex -- TeX macros to handle Texinfo files.
    2 % 
    3 % Load plain if necessary, i.e., if running under initex.
    4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
    5 %
    6 \def\texinfoversion{2017-08-23.19}
    7 %
    8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
    9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
   10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
   11 % Free Software Foundation, Inc.
   12 %
   13 % This texinfo.tex file is free software: you can redistribute it and/or
   14 % modify it under the terms of the GNU General Public License as
   15 % published by the Free Software Foundation, either version 3 of the
   16 % License, or (at your option) any later version.
   17 %
   18 % This texinfo.tex file is distributed in the hope that it will be
   19 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
   20 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   21 % General Public License for more details.
   22 %
   23 % You should have received a copy of the GNU General Public License
   24 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
   25 %
   26 % As a special exception, when this file is read by TeX when processing
   27 % a Texinfo source document, you may use the result without
   28 % restriction. This Exception is an additional permission under section 7
   29 % of the GNU General Public License, version 3 ("GPLv3").
   30 %
   31 % Please try the latest version of texinfo.tex before submitting bug
   32 % reports; you can get the latest version from:
   33 %   http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
   34 %   http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
   35 %   http://www.gnu.org/software/texinfo/ (the Texinfo home page)
   36 % The texinfo.tex in any given distribution could well be out
   37 % of date, so if that's what you're using, please check.
   38 %
   39 % Send bug reports to bug-texinfo@gnu.org.  Please include including a
   40 % complete document in each bug report with which we can reproduce the
   41 % problem.  Patches are, of course, greatly appreciated.
   42 %
   43 % To process a Texinfo manual with TeX, it's most reliable to use the
   44 % texi2dvi shell script that comes with the distribution.  For a simple
   45 % manual foo.texi, however, you can get away with this:
   46 %   tex foo.texi
   47 %   texindex foo.??
   48 %   tex foo.texi
   49 %   tex foo.texi
   50 %   dvips foo.dvi -o  # or whatever; this makes foo.ps.
   51 % The extra TeX runs get the cross-reference information correct.
   52 % Sometimes one run after texindex suffices, and sometimes you need more
   53 % than two; texi2dvi does it as many times as necessary.
   54 %
   55 % It is possible to adapt texinfo.tex for other languages, to some
   56 % extent.  You can get the existing language-specific files from the
   57 % full Texinfo distribution.
   58 %
   59 % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
   60 
   61 
   62 \message{Loading texinfo [version \texinfoversion]:}
   63 
   64 % If in a .fmt file, print the version number
   65 % and turn on active characters that we couldn't do earlier because
   66 % they might have appeared in the input file name.
   67 \everyjob{\message{[Texinfo version \texinfoversion]}%
   68   \catcode`+=\active \catcode`\_=\active}
   69 
   70 % LaTeX's \typeout.  This ensures that the messages it is used for
   71 % are identical in format to the corresponding ones from latex/pdflatex.
   72 \def\typeout{\immediate\write17}%
   73 
   74 \chardef\other=12
   75 
   76 % We never want plain's \outer definition of \+ in Texinfo.
   77 % For @tex, we can use \tabalign.
   78 \let\+ = \relax
   79 
   80 % Save some plain tex macros whose names we will redefine.
   81 \let\ptexb=\b
   82 \let\ptexbullet=\bullet
   83 \let\ptexc=\c
   84 \let\ptexcomma=\,
   85 \let\ptexdot=\.
   86 \let\ptexdots=\dots
   87 \let\ptexend=\end
   88 \let\ptexequiv=\equiv
   89 \let\ptexexclam=\!
   90 \let\ptexfootnote=\footnote
   91 \let\ptexgtr=>
   92 \let\ptexhat=^
   93 \let\ptexi=\i
   94 \let\ptexindent=\indent
   95 \let\ptexinsert=\insert
   96 \let\ptexlbrace=\{
   97 \let\ptexless=<
   98 \let\ptexnewwrite\newwrite
   99 \let\ptexnoindent=\noindent
  100 \let\ptexplus=+
  101 \let\ptexraggedright=\raggedright
  102 \let\ptexrbrace=\}
  103 \let\ptexslash=\/
  104 \let\ptexsp=\sp
  105 \let\ptexstar=\*
  106 \let\ptexsup=\sup
  107 \let\ptext=\t
  108 \let\ptextop=\top
  109 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
  110 
  111 % If this character appears in an error message or help string, it
  112 % starts a new line in the output.
  113 \newlinechar = `^^J
  114 
  115 % Use TeX 3.0's \inputlineno to get the line number, for better error
  116 % messages, but if we're using an old version of TeX, don't do anything.
  117 %
  118 \ifx\inputlineno\thisisundefined
  119   \let\linenumber = \empty % Pre-3.0.
  120 \else
  121   \def\linenumber{l.\the\inputlineno:\space}
  122 \fi
  123 
  124 % Set up fixed words for English if not already set.
  125 \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
  126 \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
  127 \ifx\putworderror\undefined     \gdef\putworderror{error}\fi
  128 \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
  129 \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
  130 \ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
  131 \ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
  132 \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
  133 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
  134 \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
  135 \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
  136 \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
  137 \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
  138 \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
  139 \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
  140 \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
  141 \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
  142 \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
  143 \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
  144 \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
  145 %
  146 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
  147 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
  148 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
  149 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
  150 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
  151 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
  152 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
  153 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
  154 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
  155 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
  156 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
  157 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
  158 %
  159 \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
  160 \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
  161 \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
  162 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
  163 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
  164 
  165 % Give the space character the catcode for a space.
  166 \def\spaceisspace{\catcode`\ =10\relax}
  167 
  168 % Likewise for ^^M, the end of line character.
  169 \def\endlineisspace{\catcode13=10\relax}
  170 
  171 \chardef\dashChar  = `\-
  172 \chardef\slashChar = `\/
  173 \chardef\underChar = `\_
  174 
  175 % Ignore a token.
  176 %
  177 \def\gobble#1{}
  178 
  179 % The following is used inside several \edef's.
  180 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
  181 
  182 % Hyphenation fixes.
  183 \hyphenation{
  184   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
  185   ap-pen-dix bit-map bit-maps
  186   data-base data-bases eshell fall-ing half-way long-est man-u-script
  187   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
  188   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
  189   spell-ing spell-ings
  190   stand-alone strong-est time-stamp time-stamps which-ever white-space
  191   wide-spread wrap-around
  192 }
  193 
  194 % Sometimes it is convenient to have everything in the transcript file
  195 % and nothing on the terminal.  We don't just call \tracingall here,
  196 % since that produces some useless output on the terminal.  We also make
  197 % some effort to order the tracing commands to reduce output in the log
  198 % file; cf. trace.sty in LaTeX.
  199 %
  200 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  201 \def\loggingall{%
  202   \tracingstats2
  203   \tracingpages1
  204   \tracinglostchars2  % 2 gives us more in etex
  205   \tracingparagraphs1
  206   \tracingoutput1
  207   \tracingmacros2
  208   \tracingrestores1
  209   \showboxbreadth\maxdimen \showboxdepth\maxdimen
  210   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
  211     \tracingscantokens1
  212     \tracingifs1
  213     \tracinggroups1
  214     \tracingnesting2
  215     \tracingassigns1
  216   \fi
  217   \tracingcommands3  % 3 gives us more in etex
  218   \errorcontextlines16
  219 }%
  220 
  221 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
  222 % aren't perfect, it's not the end of the world, being an error message,
  223 % after all.
  224 % 
  225 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
  226 \def\doerrormsg#1{\errmessage{#1}}
  227 
  228 % add check for \lastpenalty to plain's definitions.  If the last thing
  229 % we did was a \nobreak, we don't want to insert more space.
  230 %
  231 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
  232   \removelastskip\penalty-50\smallskip\fi\fi}
  233 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
  234   \removelastskip\penalty-100\medskip\fi\fi}
  235 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
  236   \removelastskip\penalty-200\bigskip\fi\fi}
  237 
  238 % Output routine
  239 %
  240 
  241 % For a final copy, take out the rectangles
  242 % that mark overfull boxes (in case you have decided
  243 % that the text looks ok even though it passes the margin).
  244 %
  245 \def\finalout{\overfullrule=0pt }
  246 
  247 % Do @cropmarks to get crop marks.
  248 %
  249 \newif\ifcropmarks
  250 \let\cropmarks = \cropmarkstrue
  251 %
  252 % Dimensions to add cropmarks at corners.
  253 % Added by P. A. MacKay, 12 Nov. 1986
  254 %
  255 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
  256 \newdimen\cornerlong  \cornerlong=1pc
  257 \newdimen\cornerthick \cornerthick=.3pt
  258 \newdimen\topandbottommargin \topandbottommargin=.75in
  259 
  260 % Output a mark which sets \thischapter, \thissection and \thiscolor.
  261 % We dump everything together because we only have one kind of mark.
  262 % This works because we only use \botmark / \topmark, not \firstmark.
  263 %
  264 % A mark contains a subexpression of the \ifcase ... \fi construct.
  265 % \get*marks macros below extract the needed part using \ifcase.
  266 %
  267 % Another complication is to let the user choose whether \thischapter
  268 % (\thissection) refers to the chapter (section) in effect at the top
  269 % of a page, or that at the bottom of a page.
  270 
  271 % \domark is called twice inside \chapmacro, to add one
  272 % mark before the section break, and one after.
  273 %   In the second call \prevchapterdefs is the same as \lastchapterdefs,
  274 % and \prevsectiondefs is the same as \lastsectiondefs.
  275 %   Then if the page is not broken at the mark, some of the previous
  276 % section appears on the page, and we can get the name of this section
  277 % from \firstmark for @everyheadingmarks top.
  278 %   @everyheadingmarks bottom uses \botmark.
  279 %
  280 % See page 260 of The TeXbook.
  281 \def\domark{%
  282   \toks0=\expandafter{\lastchapterdefs}%
  283   \toks2=\expandafter{\lastsectiondefs}%
  284   \toks4=\expandafter{\prevchapterdefs}%
  285   \toks6=\expandafter{\prevsectiondefs}%
  286   \toks8=\expandafter{\lastcolordefs}%
  287   \mark{%
  288                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
  289       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
  290     \noexpand\else \the\toks8             % 2: color marks
  291   }%
  292 }
  293 
  294 % \gettopheadingmarks, \getbottomheadingmarks,
  295 % \getcolormarks - extract needed part of mark.
  296 %
  297 % \topmark doesn't work for the very first chapter (after the title
  298 % page or the contents), so we use \firstmark there -- this gets us
  299 % the mark with the chapter defs, unless the user sneaks in, e.g.,
  300 % @setcolor (or @url, or @link, etc.) between @contents and the very
  301 % first @chapter.
  302 \def\gettopheadingmarks{%
  303   \ifcase0\topmark\fi
  304   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
  305 }
  306 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
  307 \def\getcolormarks{\ifcase2\topmark\fi}
  308 
  309 % Avoid "undefined control sequence" errors.
  310 \def\lastchapterdefs{}
  311 \def\lastsectiondefs{}
  312 \def\lastsection{}
  313 \def\prevchapterdefs{}
  314 \def\prevsectiondefs{}
  315 \def\lastcolordefs{}
  316 
  317 % Margin to add to right of even pages, to left of odd pages.
  318 \newdimen\bindingoffset
  319 \newdimen\normaloffset
  320 \newdimen\txipagewidth \newdimen\txipageheight
  321 
  322 % Main output routine.
  323 %
  324 \chardef\PAGE = 255
  325 \output = {\onepageout{\pagecontents\PAGE}}
  326 
  327 \newbox\headlinebox
  328 \newbox\footlinebox
  329 
  330 % \onepageout takes a vbox as an argument.
  331 % \shipout a vbox for a single page, adding an optional header, footer,
  332 % cropmarks, and footnote.  This also causes index entries for this page
  333 % to be written to the auxiliary files.
  334 %
  335 \def\onepageout#1{%
  336   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
  337   %
  338   \ifodd\pageno  \advance\hoffset by \bindingoffset
  339   \else \advance\hoffset by -\bindingoffset\fi
  340   %
  341   % Common context changes for both heading and footing.
  342   % Do this outside of the \shipout so @code etc. will be expanded in
  343   % the headline as they should be, not taken literally (outputting ''code).
  344   \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
  345   %
  346   % Retrieve the information for the headings from the marks in the page,
  347   % and call Plain TeX's \makeheadline and \makefootline, which use the
  348   % values in \headline and \footline.
  349   %
  350   % This is used to check if we are on the first page of a chapter.
  351   \ifcase1\topmark\fi
  352   \let\prevchaptername\thischaptername
  353   \ifcase0\firstmark\fi
  354   \let\curchaptername\thischaptername
  355   %
  356   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
  357   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
  358   %
  359   \ifx\curchaptername\prevchaptername
  360     \let\thischapterheading\thischapter
  361   \else
  362     % \thischapterheading is the same as \thischapter except it is blank
  363     % for the first page of a chapter.  This is to prevent the chapter name 
  364     % being shown twice.
  365     \def\thischapterheading{}%
  366   \fi
  367   %
  368   \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
  369   \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
  370   %
  371   {%
  372     % Set context for writing to auxiliary files like index files.
  373     % Have to do this stuff outside the \shipout because we want it to
  374     % take effect in \write's, yet the group defined by the \vbox ends
  375     % before the \shipout runs.
  376     %
  377     \indexdummies         % don't expand commands in the output.
  378     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
  379                % the page break happens to be in the middle of an example.
  380                % We don't want .vr (or whatever) entries like this:
  381                % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
  382                % "\acronym" won't work when it's read back in;
  383                % it needs to be
  384                % {\code {{\backslashcurfont }acronym}
  385     \shipout\vbox{%
  386       % Do this early so pdf references go to the beginning of the page.
  387       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
  388       %
  389       \ifcropmarks \vbox to \outervsize\bgroup
  390         \hsize = \outerhsize
  391         \vskip-\topandbottommargin
  392         \vtop to0pt{%
  393           \line{\ewtop\hfil\ewtop}%
  394           \nointerlineskip
  395           \line{%
  396             \vbox{\moveleft\cornerthick\nstop}%
  397             \hfill
  398             \vbox{\moveright\cornerthick\nstop}%
  399           }%
  400           \vss}%
  401         \vskip\topandbottommargin
  402         \line\bgroup
  403           \hfil % center the page within the outer (page) hsize.
  404           \ifodd\pageno\hskip\bindingoffset\fi
  405           \vbox\bgroup
  406       \fi
  407       %
  408       \unvbox\headlinebox
  409       \pagebody{#1}%
  410       \ifdim\ht\footlinebox > 0pt
  411         % Only leave this space if the footline is nonempty.
  412         % (We lessened \vsize for it in \oddfootingyyy.)
  413         % The \baselineskip=24pt in plain's \makefootline has no effect.
  414         \vskip 24pt
  415         \unvbox\footlinebox
  416       \fi
  417       %
  418       \ifcropmarks
  419           \egroup % end of \vbox\bgroup
  420         \hfil\egroup % end of (centering) \line\bgroup
  421         \vskip\topandbottommargin plus1fill minus1fill
  422         \boxmaxdepth = \cornerthick
  423         \vbox to0pt{\vss
  424           \line{%
  425             \vbox{\moveleft\cornerthick\nsbot}%
  426             \hfill
  427             \vbox{\moveright\cornerthick\nsbot}%
  428           }%
  429           \nointerlineskip
  430           \line{\ewbot\hfil\ewbot}%
  431         }%
  432       \egroup % \vbox from first cropmarks clause
  433       \fi
  434     }% end of \shipout\vbox
  435   }% end of group with \indexdummies
  436   \advancepageno
  437   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
  438 }
  439 
  440 \newinsert\margin \dimen\margin=\maxdimen
  441 
  442 % Main part of page, including any footnotes
  443 \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
  444 {\catcode`\@ =11
  445 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  446 % marginal hacks, juha@viisa.uucp (Juha Takala)
  447 \ifvoid\margin\else % marginal info is present
  448   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
  449 \dimen@=\dp#1\relax \unvbox#1\relax
  450 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  451 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  452 }
  453 
  454 % Here are the rules for the cropmarks.  Note that they are
  455 % offset so that the space between them is truly \outerhsize or \outervsize
  456 % (P. A. MacKay, 12 November, 1986)
  457 %
  458 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  459 \def\nstop{\vbox
  460   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  461 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  462 \def\nsbot{\vbox
  463   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  464 
  465 
  466 % Argument parsing
  467 
  468 % Parse an argument, then pass it to #1.  The argument is the rest of
  469 % the input line (except we remove a trailing comment).  #1 should be a
  470 % macro which expects an ordinary undelimited TeX argument.
  471 % For example, \def\foo{\parsearg\fooxxx}.
  472 %
  473 \def\parsearg{\parseargusing{}}
  474 \def\parseargusing#1#2{%
  475   \def\argtorun{#2}%
  476   \begingroup
  477     \obeylines
  478     \spaceisspace
  479     #1%
  480     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
  481 }
  482 
  483 {\obeylines %
  484   \gdef\parseargline#1^^M{%
  485     \endgroup % End of the group started in \parsearg.
  486     \argremovecomment #1\comment\ArgTerm%
  487   }%
  488 }
  489 
  490 % First remove any @comment, then any @c comment.  Also remove a @texinfoc
  491 % comment (see \scanmacro for details).  Pass the result on to \argcheckspaces.
  492 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
  493 \def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
  494 \def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
  495 
  496 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
  497 %
  498 % \argremovec might leave us with trailing space, e.g.,
  499 %    @end itemize  @c foo
  500 % This space token undergoes the same procedure and is eventually removed
  501 % by \finishparsearg.
  502 %
  503 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
  504 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
  505 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
  506   \def\temp{#3}%
  507   \ifx\temp\empty
  508     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
  509     \let\temp\finishparsearg
  510   \else
  511     \let\temp\argcheckspaces
  512   \fi
  513   % Put the space token in:
  514   \temp#1 #3\ArgTerm
  515 }
  516 
  517 % If a _delimited_ argument is enclosed in braces, they get stripped; so
  518 % to get _exactly_ the rest of the line, we had to prevent such situation.
  519 % We prepended an \empty token at the very beginning and we expand it now,
  520 % just before passing the control to \argtorun.
  521 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
  522 % either the null string, or it ends with \^^M---thus there is no danger
  523 % that a pair of braces would be stripped.
  524 %
  525 % But first, we have to remove the trailing space token.
  526 %
  527 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
  528 
  529 
  530 % \parseargdef - define a command taking an argument on the line
  531 %
  532 % \parseargdef\foo{...}
  533 %   is roughly equivalent to
  534 % \def\foo{\parsearg\Xfoo}
  535 % \def\Xfoo#1{...}
  536 \def\parseargdef#1{%
  537   \expandafter \doparseargdef \csname\string#1\endcsname #1%
  538 }
  539 \def\doparseargdef#1#2{%
  540   \def#2{\parsearg#1}%
  541   \def#1##1%
  542 }
  543 
  544 % Several utility definitions with active space:
  545 {
  546   \obeyspaces
  547   \gdef\obeyedspace{ }
  548 
  549   % Make each space character in the input produce a normal interword
  550   % space in the output.  Don't allow a line break at this space, as this
  551   % is used only in environments like @example, where each line of input
  552   % should produce a line of output anyway.
  553   %
  554   \gdef\sepspaces{\obeyspaces\let =\tie}
  555 
  556   % If an index command is used in an @example environment, any spaces
  557   % therein should become regular spaces in the raw index file, not the
  558   % expansion of \tie (\leavevmode \penalty \@M \ ).
  559   \gdef\unsepspaces{\let =\space}
  560 }
  561 
  562 
  563 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  564 
  565 % Define the framework for environments in texinfo.tex.  It's used like this:
  566 %
  567 %   \envdef\foo{...}
  568 %   \def\Efoo{...}
  569 %
  570 % It's the responsibility of \envdef to insert \begingroup before the
  571 % actual body; @end closes the group after calling \Efoo.  \envdef also
  572 % defines \thisenv, so the current environment is known; @end checks
  573 % whether the environment name matches.  The \checkenv macro can also be
  574 % used to check whether the current environment is the one expected.
  575 %
  576 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
  577 % are not treated as environments; they don't open a group.  (The
  578 % implementation of @end takes care not to call \endgroup in this
  579 % special case.)
  580 
  581 
  582 % At run-time, environments start with this:
  583 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
  584 % initialize
  585 \let\thisenv\empty
  586 
  587 % ... but they get defined via ``\envdef\foo{...}'':
  588 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
  589 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
  590 
  591 % Check whether we're in the right environment:
  592 \def\checkenv#1{%
  593   \def\temp{#1}%
  594   \ifx\thisenv\temp
  595   \else
  596     \badenverr
  597   \fi
  598 }
  599 
  600 % Environment mismatch, #1 expected:
  601 \def\badenverr{%
  602   \errhelp = \EMsimple
  603   \errmessage{This command can appear only \inenvironment\temp,
  604     not \inenvironment\thisenv}%
  605 }
  606 \def\inenvironment#1{%
  607   \ifx#1\empty
  608     outside of any environment%
  609   \else
  610     in environment \expandafter\string#1%
  611   \fi
  612 }
  613 
  614 % @end foo executes the definition of \Efoo.
  615 % But first, it executes a specialized version of \checkenv
  616 %
  617 \parseargdef\end{%
  618   \if 1\csname iscond.#1\endcsname
  619   \else
  620     % The general wording of \badenverr may not be ideal.
  621     \expandafter\checkenv\csname#1\endcsname
  622     \csname E#1\endcsname
  623     \endgroup
  624   \fi
  625 }
  626 
  627 \newhelp\EMsimple{Press RETURN to continue.}
  628 
  629 
  630 % Be sure we're in horizontal mode when doing a tie, since we make space
  631 % equivalent to this in @example-like environments. Otherwise, a space
  632 % at the beginning of a line will start with \penalty -- and
  633 % since \penalty is valid in vertical mode, we'd end up putting the
  634 % penalty on the vertical list instead of in the new paragraph.
  635 {\catcode`@ = 11
  636  % Avoid using \@M directly, because that causes trouble
  637  % if the definition is written into an index file.
  638  \global\let\tiepenalty = \@M
  639  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
  640 }
  641 
  642 % @: forces normal size whitespace following.
  643 \def\:{\spacefactor=1000 }
  644 
  645 % @* forces a line break.
  646 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
  647 
  648 % @/ allows a line break.
  649 \let\/=\allowbreak
  650 
  651 % @. is an end-of-sentence period.
  652 \def\.{.\spacefactor=\endofsentencespacefactor\space}
  653 
  654 % @! is an end-of-sentence bang.
  655 \def\!{!\spacefactor=\endofsentencespacefactor\space}
  656 
  657 % @? is an end-of-sentence query.
  658 \def\?{?\spacefactor=\endofsentencespacefactor\space}
  659 
  660 % @frenchspacing on|off  says whether to put extra space after punctuation.
  661 %
  662 \def\onword{on}
  663 \def\offword{off}
  664 %
  665 \parseargdef\frenchspacing{%
  666   \def\temp{#1}%
  667   \ifx\temp\onword \plainfrenchspacing
  668   \else\ifx\temp\offword \plainnonfrenchspacing
  669   \else
  670     \errhelp = \EMsimple
  671     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
  672   \fi\fi
  673 }
  674 
  675 % @w prevents a word break.  Without the \leavevmode, @w at the
  676 % beginning of a paragraph, when TeX is still in vertical mode, would
  677 % produce a whole line of output instead of starting the paragraph.
  678 \def\w#1{\leavevmode\hbox{#1}}
  679 
  680 % @group ... @end group forces ... to be all on one page, by enclosing
  681 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
  682 % to keep its height that of a normal line.  According to the rules for
  683 % \topskip (p.114 of the TeXbook), the glue inserted is
  684 % max (\topskip - \ht (first item), 0).  If that height is large,
  685 % therefore, no glue is inserted, and the space between the headline and
  686 % the text is small, which looks bad.
  687 %
  688 % Another complication is that the group might be very large.  This can
  689 % cause the glue on the previous page to be unduly stretched, because it
  690 % does not have much material.  In this case, it's better to add an
  691 % explicit \vfill so that the extra space is at the bottom.  The
  692 % threshold for doing this is if the group is more than \vfilllimit
  693 % percent of a page (\vfilllimit can be changed inside of @tex).
  694 %
  695 \newbox\groupbox
  696 \def\vfilllimit{0.7}
  697 %
  698 \envdef\group{%
  699   \ifnum\catcode`\^^M=\active \else
  700     \errhelp = \groupinvalidhelp
  701     \errmessage{@group invalid in context where filling is enabled}%
  702   \fi
  703   \startsavinginserts
  704   %
  705   \setbox\groupbox = \vtop\bgroup
  706     % Do @comment since we are called inside an environment such as
  707     % @example, where each end-of-line in the input causes an
  708     % end-of-line in the output.  We don't want the end-of-line after
  709     % the `@group' to put extra space in the output.  Since @group
  710     % should appear on a line by itself (according to the Texinfo
  711     % manual), we don't worry about eating any user text.
  712     \comment
  713 }
  714 %
  715 % The \vtop produces a box with normal height and large depth; thus, TeX puts
  716 % \baselineskip glue before it, and (when the next line of text is done)
  717 % \lineskip glue after it.  Thus, space below is not quite equal to space
  718 % above.  But it's pretty close.
  719 \def\Egroup{%
  720     % To get correct interline space between the last line of the group
  721     % and the first line afterwards, we have to propagate \prevdepth.
  722     \endgraf % Not \par, as it may have been set to \lisppar.
  723     \global\dimen1 = \prevdepth
  724   \egroup           % End the \vtop.
  725   \addgroupbox
  726   \prevdepth = \dimen1
  727   \checkinserts
  728 }
  729 
  730 \def\addgroupbox{
  731   % \dimen0 is the vertical size of the group's box.
  732   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
  733   % \dimen2 is how much space is left on the page (more or less).
  734   \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
  735   % if the group doesn't fit on the current page, and it's a big big
  736   % group, force a page break.
  737   \ifdim \dimen0 > \dimen2
  738     \ifdim \pagetotal < \vfilllimit\txipageheight
  739       \page
  740     \fi
  741   \fi
  742   \box\groupbox
  743 }
  744 
  745 %
  746 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  747 % message, so this ends up printing `@group can only ...'.
  748 %
  749 \newhelp\groupinvalidhelp{%
  750 group can only be used in environments such as @example,^^J%
  751 where each line of input produces a line of output.}
  752 
  753 % @need space-in-mils
  754 % forces a page break if there is not space-in-mils remaining.
  755 
  756 \newdimen\mil  \mil=0.001in
  757 
  758 \parseargdef\need{%
  759   % Ensure vertical mode, so we don't make a big box in the middle of a
  760   % paragraph.
  761   \par
  762   %
  763   % If the @need value is less than one line space, it's useless.
  764   \dimen0 = #1\mil
  765   \dimen2 = \ht\strutbox
  766   \advance\dimen2 by \dp\strutbox
  767   \ifdim\dimen0 > \dimen2
  768     %
  769     % Do a \strut just to make the height of this box be normal, so the
  770     % normal leading is inserted relative to the preceding line.
  771     % And a page break here is fine.
  772     \vtop to #1\mil{\strut\vfil}%
  773     %
  774     % TeX does not even consider page breaks if a penalty added to the
  775     % main vertical list is 10000 or more.  But in order to see if the
  776     % empty box we just added fits on the page, we must make it consider
  777     % page breaks.  On the other hand, we don't want to actually break the
  778     % page after the empty box.  So we use a penalty of 9999.
  779     %
  780     % There is an extremely small chance that TeX will actually break the
  781     % page at this \penalty, if there are no other feasible breakpoints in
  782     % sight.  (If the user is using lots of big @group commands, which
  783     % almost-but-not-quite fill up a page, TeX will have a hard time doing
  784     % good page breaking, for example.)  However, I could not construct an
  785     % example where a page broke at this \penalty; if it happens in a real
  786     % document, then we can reconsider our strategy.
  787     \penalty9999
  788     %
  789     % Back up by the size of the box, whether we did a page break or not.
  790     \kern -#1\mil
  791     %
  792     % Do not allow a page break right after this kern.
  793     \nobreak
  794   \fi
  795 }
  796 
  797 % @br   forces paragraph break (and is undocumented).
  798 
  799 \let\br = \par
  800 
  801 % @page forces the start of a new page.
  802 %
  803 \def\page{\par\vfill\supereject}
  804 
  805 % @exdent text....
  806 % outputs text on separate line in roman font, starting at standard page margin
  807 
  808 % This records the amount of indent in the innermost environment.
  809 % That's how much \exdent should take out.
  810 \newskip\exdentamount
  811 
  812 % This defn is used inside fill environments such as @defun.
  813 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
  814 
  815 % This defn is used inside nofill environments such as @example.
  816 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
  817   \leftline{\hskip\leftskip{\rm#1}}}}
  818 
  819 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
  820 % paragraph.  For more general purposes, use the \margin insertion
  821 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
  822 %
  823 \newskip\inmarginspacing \inmarginspacing=1cm
  824 \def\strutdepth{\dp\strutbox}
  825 %
  826 \def\doinmargin#1#2{\strut\vadjust{%
  827   \nobreak
  828   \kern-\strutdepth
  829   \vtop to \strutdepth{%
  830     \baselineskip=\strutdepth
  831     \vss
  832     % if you have multiple lines of stuff to put here, you'll need to
  833     % make the vbox yourself of the appropriate size.
  834     \ifx#1l%
  835       \llap{\ignorespaces #2\hskip\inmarginspacing}%
  836     \else
  837       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
  838     \fi
  839     \null
  840   }%
  841 }}
  842 \def\inleftmargin{\doinmargin l}
  843 \def\inrightmargin{\doinmargin r}
  844 %
  845 % @inmargin{TEXT [, RIGHT-TEXT]}
  846 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
  847 % else use TEXT for both).
  848 %
  849 \def\inmargin#1{\parseinmargin #1,,\finish}
  850 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
  851   \setbox0 = \hbox{\ignorespaces #2}%
  852   \ifdim\wd0 > 0pt
  853     \def\lefttext{#1}%  have both texts
  854     \def\righttext{#2}%
  855   \else
  856     \def\lefttext{#1}%  have only one text
  857     \def\righttext{#1}%
  858   \fi
  859   %
  860   \ifodd\pageno
  861     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
  862   \else
  863     \def\temp{\inleftmargin\lefttext}%
  864   \fi
  865   \temp
  866 }
  867 
  868 % @include FILE -- \input text of FILE.
  869 %
  870 \def\include{\parseargusing\filenamecatcodes\includezzz}
  871 \def\includezzz#1{%
  872   \pushthisfilestack
  873   \def\thisfile{#1}%
  874   {%
  875     \makevalueexpandable  % we want to expand any @value in FILE.
  876     \turnoffactive        % and allow special characters in the expansion
  877     \indexnofonts         % Allow `@@' and other weird things in file names.
  878     \wlog{texinfo.tex: doing @include of #1^^J}%
  879     \edef\temp{\noexpand\input #1 }%
  880     %
  881     % This trickery is to read FILE outside of a group, in case it makes
  882     % definitions, etc.
  883     \expandafter
  884   }\temp
  885   \popthisfilestack
  886 }
  887 \def\filenamecatcodes{%
  888   \catcode`\\=\other
  889   \catcode`~=\other
  890   \catcode`^=\other
  891   \catcode`_=\other
  892   \catcode`|=\other
  893   \catcode`<=\other
  894   \catcode`>=\other
  895   \catcode`+=\other
  896   \catcode`-=\other
  897   \catcode`\`=\other
  898   \catcode`\'=\other
  899 }
  900 
  901 \def\pushthisfilestack{%
  902   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
  903 }
  904 \def\pushthisfilestackX{%
  905   \expandafter\pushthisfilestackY\thisfile\StackTerm
  906 }
  907 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
  908   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
  909 }
  910 
  911 \def\popthisfilestack{\errthisfilestackempty}
  912 \def\errthisfilestackempty{\errmessage{Internal error:
  913   the stack of filenames is empty.}}
  914 %
  915 \def\thisfile{}
  916 
  917 % @center line
  918 % outputs that line, centered.
  919 %
  920 \parseargdef\center{%
  921   \ifhmode
  922     \let\centersub\centerH
  923   \else
  924     \let\centersub\centerV
  925   \fi
  926   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
  927   \let\centersub\relax % don't let the definition persist, just in case
  928 }
  929 \def\centerH#1{{%
  930   \hfil\break
  931   \advance\hsize by -\leftskip
  932   \advance\hsize by -\rightskip
  933   \line{#1}%
  934   \break
  935 }}
  936 %
  937 \newcount\centerpenalty
  938 \def\centerV#1{%
  939   % The idea here is the same as in \startdefun, \cartouche, etc.: if
  940   % @center is the first thing after a section heading, we need to wipe
  941   % out the negative parskip inserted by \sectionheading, but still
  942   % prevent a page break here.
  943   \centerpenalty = \lastpenalty
  944   \ifnum\centerpenalty>10000 \vskip\parskip \fi
  945   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
  946   \line{\kern\leftskip #1\kern\rightskip}%
  947 }
  948 
  949 % @sp n   outputs n lines of vertical space
  950 %
  951 \parseargdef\sp{\vskip #1\baselineskip}
  952 
  953 % @comment ...line which is ignored...
  954 % @c is the same as @comment
  955 % @ignore ... @end ignore  is another way to write a comment
  956 
  957 
  958 \def\c{\begingroup \catcode`\^^M=\active%
  959 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
  960 \cxxx}
  961 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
  962 %
  963 \let\comment\c
  964 
  965 % @paragraphindent NCHARS
  966 % We'll use ems for NCHARS, close enough.
  967 % NCHARS can also be the word `asis' or `none'.
  968 % We cannot feasibly implement @paragraphindent asis, though.
  969 %
  970 \def\asisword{asis} % no translation, these are keywords
  971 \def\noneword{none}
  972 %
  973 \parseargdef\paragraphindent{%
  974   \def\temp{#1}%
  975   \ifx\temp\asisword
  976   \else
  977     \ifx\temp\noneword
  978       \defaultparindent = 0pt
  979     \else
  980       \defaultparindent = #1em
  981     \fi
  982   \fi
  983   \parindent = \defaultparindent
  984 }
  985 
  986 % @exampleindent NCHARS
  987 % We'll use ems for NCHARS like @paragraphindent.
  988 % It seems @exampleindent asis isn't necessary, but
  989 % I preserve it to make it similar to @paragraphindent.
  990 \parseargdef\exampleindent{%
  991   \def\temp{#1}%
  992   \ifx\temp\asisword
  993   \else
  994     \ifx\temp\noneword
  995       \lispnarrowing = 0pt
  996     \else
  997       \lispnarrowing = #1em
  998     \fi
  999   \fi
 1000 }
 1001 
 1002 % @firstparagraphindent WORD
 1003 % If WORD is `none', then suppress indentation of the first paragraph
 1004 % after a section heading.  If WORD is `insert', then do indent at such
 1005 % paragraphs.
 1006 %
 1007 % The paragraph indentation is suppressed or not by calling
 1008 % \suppressfirstparagraphindent, which the sectioning commands do.
 1009 % We switch the definition of this back and forth according to WORD.
 1010 % By default, we suppress indentation.
 1011 %
 1012 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
 1013 \def\insertword{insert}
 1014 %
 1015 \parseargdef\firstparagraphindent{%
 1016   \def\temp{#1}%
 1017   \ifx\temp\noneword
 1018     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
 1019   \else\ifx\temp\insertword
 1020     \let\suppressfirstparagraphindent = \relax
 1021   \else
 1022     \errhelp = \EMsimple
 1023     \errmessage{Unknown @firstparagraphindent option `\temp'}%
 1024   \fi\fi
 1025 }
 1026 
 1027 % Here is how we actually suppress indentation.  Redefine \everypar to
 1028 % \kern backwards by \parindent, and then reset itself to empty.
 1029 %
 1030 % We also make \indent itself not actually do anything until the next
 1031 % paragraph.
 1032 %
 1033 \gdef\dosuppressfirstparagraphindent{%
 1034   \gdef\indent  {\restorefirstparagraphindent \indent}%
 1035   \gdef\noindent{\restorefirstparagraphindent \noindent}%
 1036   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
 1037 }
 1038 %
 1039 \gdef\restorefirstparagraphindent{%
 1040   \global\let\indent = \ptexindent
 1041   \global\let\noindent = \ptexnoindent
 1042   \global\everypar = {}%
 1043 }
 1044 
 1045 
 1046 % @refill is a no-op.
 1047 \let\refill=\relax
 1048 
 1049 % @setfilename INFO-FILENAME - ignored
 1050 \let\setfilename=\comment
 1051 
 1052 % @bye.
 1053 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
 1054 
 1055 
 1056 \message{pdf,}
 1057 % adobe `portable' document format
 1058 \newcount\tempnum
 1059 \newcount\lnkcount
 1060 \newtoks\filename
 1061 \newcount\filenamelength
 1062 \newcount\pgn
 1063 \newtoks\toksA
 1064 \newtoks\toksB
 1065 \newtoks\toksC
 1066 \newtoks\toksD
 1067 \newbox\boxA
 1068 \newbox\boxB
 1069 \newcount\countA
 1070 \newif\ifpdf
 1071 \newif\ifpdfmakepagedest
 1072 
 1073 %
 1074 % For LuaTeX
 1075 %
 1076 
 1077 \newif\iftxiuseunicodedestname
 1078 \txiuseunicodedestnamefalse % For pdfTeX etc.
 1079 
 1080 \ifx\luatexversion\thisisundefined
 1081 \else
 1082   % Use Unicode destination names
 1083   \txiuseunicodedestnametrue
 1084   % Escape PDF strings with converting UTF-16 from UTF-8
 1085   \begingroup
 1086     \catcode`\%=12
 1087     \directlua{
 1088       function UTF16oct(str)
 1089         tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
 1090         for c in string.utfvalues(str) do
 1091           if c < 0x10000 then
 1092             tex.sprint(
 1093               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
 1094                             string.char(0x5c) .. string.char(0x25) .. '03o',
 1095                             (c / 256), (c % 256)))
 1096           else
 1097             c = c - 0x10000
 1098             local c_hi = c / 1024 + 0xd800
 1099             local c_lo = c % 1024 + 0xdc00
 1100             tex.sprint(
 1101               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
 1102                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
 1103                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
 1104                             string.char(0x5c) .. string.char(0x25) .. '03o',
 1105                             (c_hi / 256), (c_hi % 256),
 1106                             (c_lo / 256), (c_lo % 256)))
 1107           end
 1108         end
 1109       end
 1110     }
 1111   \endgroup
 1112   \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
 1113   % Escape PDF strings without converting
 1114   \begingroup
 1115     \directlua{
 1116       function PDFescstr(str)
 1117         for c in string.bytes(str) do
 1118           if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
 1119             tex.sprint(
 1120               string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
 1121                             c))
 1122           else
 1123             tex.sprint(string.char(c))
 1124           end
 1125         end
 1126       end
 1127     }
 1128   \endgroup
 1129   \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
 1130   \ifnum\luatexversion>84
 1131     % For LuaTeX >= 0.85
 1132     \def\pdfdest{\pdfextension dest}
 1133     \let\pdfoutput\outputmode
 1134     \def\pdfliteral{\pdfextension literal}
 1135     \def\pdfcatalog{\pdfextension catalog}
 1136     \def\pdftexversion{\numexpr\pdffeedback version\relax}
 1137     \let\pdfximage\saveimageresource
 1138     \let\pdfrefximage\useimageresource
 1139     \let\pdflastximage\lastsavedimageresourceindex
 1140     \def\pdfendlink{\pdfextension endlink\relax}
 1141     \def\pdfoutline{\pdfextension outline}
 1142     \def\pdfstartlink{\pdfextension startlink}
 1143     \def\pdffontattr{\pdfextension fontattr}
 1144     \def\pdfobj{\pdfextension obj}
 1145     \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
 1146     \let\pdfpagewidth\pagewidth
 1147     \let\pdfpageheight\pageheight
 1148     \edef\pdfhorigin{\pdfvariable horigin}
 1149     \edef\pdfvorigin{\pdfvariable vorigin}
 1150   \fi
 1151 \fi
 1152 
 1153 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
 1154 % can be set).  So we test for \relax and 0 as well as being undefined.
 1155 \ifx\pdfoutput\thisisundefined
 1156 \else
 1157   \ifx\pdfoutput\relax
 1158   \else
 1159     \ifcase\pdfoutput
 1160     \else
 1161       \pdftrue
 1162     \fi
 1163   \fi
 1164 \fi
 1165 
 1166 % PDF uses PostScript string constants for the names of xref targets,
 1167 % for display in the outlines, and in other places.  Thus, we have to
 1168 % double any backslashes.  Otherwise, a name like "\node" will be
 1169 % interpreted as a newline (\n), followed by o, d, e.  Not good.
 1170 % 
 1171 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
 1172 % related messages.  The final outcome is that it is up to the TeX user
 1173 % to double the backslashes and otherwise make the string valid, so
 1174 % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
 1175 % do this reliably, so we use it.
 1176 
 1177 % #1 is a control sequence in which to do the replacements,
 1178 % which we \xdef.
 1179 \def\txiescapepdf#1{%
 1180   \ifx\pdfescapestring\thisisundefined
 1181     % No primitive available; should we give a warning or log?
 1182     % Many times it won't matter.
 1183     \xdef#1{#1}%
 1184   \else
 1185     % The expandable \pdfescapestring primitive escapes parentheses,
 1186     % backslashes, and other special chars.
 1187     \xdef#1{\pdfescapestring{#1}}%
 1188   \fi
 1189 }
 1190 \def\txiescapepdfutfsixteen#1{%
 1191   \ifx\pdfescapestrutfsixteen\thisisundefined
 1192     % No UTF-16 converting macro available.
 1193     \txiescapepdf{#1}%
 1194   \else
 1195     \xdef#1{\pdfescapestrutfsixteen{#1}}%
 1196   \fi
 1197 }
 1198 
 1199 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
 1200 with PDF output, and none of those formats could be found.  (.eps cannot
 1201 be supported due to the design of the PDF format; use regular TeX (DVI
 1202 output) for that.)}
 1203 
 1204 \ifpdf
 1205   %
 1206   % Color manipulation macros using ideas from pdfcolor.tex,
 1207   % except using rgb instead of cmyk; the latter is said to render as a
 1208   % very dark gray on-screen and a very dark halftone in print, instead
 1209   % of actual black. The dark red here is dark enough to print on paper as
 1210   % nearly black, but still distinguishable for online viewing.  We use
 1211   % black by default, though.
 1212   \def\rgbDarkRed{0.50 0.09 0.12}
 1213   \def\rgbBlack{0 0 0}
 1214   %
 1215   % rg sets the color for filling (usual text, etc.);
 1216   % RG sets the color for stroking (thin rules, e.g., normal _'s).
 1217   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
 1218   %
 1219   % Set color, and create a mark which defines \thiscolor accordingly,
 1220   % so that \makeheadline knows which color to restore.
 1221   \def\setcolor#1{%
 1222     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
 1223     \domark
 1224     \pdfsetcolor{#1}%
 1225   }
 1226   %
 1227   \def\maincolor{\rgbBlack}
 1228   \pdfsetcolor{\maincolor}
 1229   \edef\thiscolor{\maincolor}
 1230   \def\lastcolordefs{}
 1231   %
 1232   \def\makefootline{%
 1233     \baselineskip24pt
 1234     \line{\pdfsetcolor{\maincolor}\the\footline}%
 1235   }
 1236   %
 1237   \def\makeheadline{%
 1238     \vbox to 0pt{%
 1239       \vskip-22.5pt
 1240       \line{%
 1241         \vbox to8.5pt{}%
 1242         % Extract \thiscolor definition from the marks.
 1243         \getcolormarks
 1244         % Typeset the headline with \maincolor, then restore the color.
 1245         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
 1246       }%
 1247       \vss
 1248     }%
 1249     \nointerlineskip
 1250   }
 1251   %
 1252   %
 1253   \pdfcatalog{/PageMode /UseOutlines}
 1254   %
 1255   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
 1256   \def\dopdfimage#1#2#3{%
 1257     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
 1258     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
 1259     %
 1260     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
 1261     % others).  Let's try in that order, PDF first since if
 1262     % someone has a scalable image, presumably better to use that than a
 1263     % bitmap.
 1264     \let\pdfimgext=\empty
 1265     \begingroup
 1266       \openin 1 #1.pdf \ifeof 1
 1267         \openin 1 #1.PDF \ifeof 1
 1268           \openin 1 #1.png \ifeof 1
 1269             \openin 1 #1.jpg \ifeof 1
 1270               \openin 1 #1.jpeg \ifeof 1
 1271                 \openin 1 #1.JPG \ifeof 1
 1272                   \errhelp = \nopdfimagehelp
 1273                   \errmessage{Could not find image file #1 for pdf}%
 1274                 \else \gdef\pdfimgext{JPG}%
 1275                 \fi
 1276               \else \gdef\pdfimgext{jpeg}%
 1277               \fi
 1278             \else \gdef\pdfimgext{jpg}%
 1279             \fi
 1280           \else \gdef\pdfimgext{png}%
 1281           \fi
 1282         \else \gdef\pdfimgext{PDF}%
 1283         \fi
 1284       \else \gdef\pdfimgext{pdf}%
 1285       \fi
 1286       \closein 1
 1287     \endgroup
 1288     %
 1289     % without \immediate, ancient pdftex seg faults when the same image is
 1290     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
 1291     \ifnum\pdftexversion < 14
 1292       \immediate\pdfimage
 1293     \else
 1294       \immediate\pdfximage
 1295     \fi
 1296       \ifdim \wd0 >0pt width \pdfimagewidth \fi
 1297       \ifdim \wd2 >0pt height \pdfimageheight \fi
 1298       \ifnum\pdftexversion<13
 1299          #1.\pdfimgext
 1300        \else
 1301          {#1.\pdfimgext}%
 1302        \fi
 1303     \ifnum\pdftexversion < 14 \else
 1304       \pdfrefximage \pdflastximage
 1305     \fi}
 1306   %
 1307   \def\setpdfdestname#1{{%
 1308     % We have to set dummies so commands such as @code, and characters
 1309     % such as \, aren't expanded when present in a section title.
 1310     \indexnofonts
 1311     \makevalueexpandable
 1312     \turnoffactive
 1313     \iftxiuseunicodedestname
 1314       \ifx \declaredencoding \latone
 1315         % Pass through Latin-1 characters.
 1316         % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
 1317       \else
 1318         \ifx \declaredencoding \utfeight
 1319           % Pass through Unicode characters.
 1320         \else
 1321           % Use ASCII approximations in destination names.
 1322           \passthroughcharsfalse
 1323         \fi
 1324       \fi
 1325     \else
 1326       % Use ASCII approximations in destination names.
 1327       \passthroughcharsfalse
 1328     \fi
 1329     \def\pdfdestname{#1}%
 1330     \txiescapepdf\pdfdestname
 1331   }}
 1332   %
 1333   \def\setpdfoutlinetext#1{{%
 1334     \indexnofonts
 1335     \makevalueexpandable
 1336     \turnoffactive
 1337     \ifx \declaredencoding \latone
 1338       % The PDF format can use an extended form of Latin-1 in bookmark
 1339       % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
 1340       % the "PDFDocEncoding".
 1341       \passthroughcharstrue
 1342       % Pass through Latin-1 characters.
 1343       %   LuaTeX: Convert to Unicode
 1344       %   pdfTeX: Use Latin-1 as PDFDocEncoding
 1345       \def\pdfoutlinetext{#1}%
 1346     \else
 1347       \ifx \declaredencoding \utfeight
 1348         \ifx\luatexversion\thisisundefined
 1349           % For pdfTeX  with UTF-8.
 1350           % TODO: the PDF format can use UTF-16 in bookmark strings,
 1351           % but the code for this isn't done yet.
 1352           % Use ASCII approximations.
 1353           \passthroughcharsfalse
 1354           \def\pdfoutlinetext{#1}%
 1355         \else
 1356           % For LuaTeX with UTF-8.
 1357           % Pass through Unicode characters for title texts.
 1358           \passthroughcharstrue
 1359           \def\pdfoutlinetext{#1}%
 1360         \fi
 1361       \else
 1362         % For non-Latin-1 or non-UTF-8 encodings.
 1363         % Use ASCII approximations.
 1364         \passthroughcharsfalse
 1365         \def\pdfoutlinetext{#1}%
 1366       \fi
 1367     \fi
 1368     % LuaTeX: Convert to UTF-16
 1369     % pdfTeX: Use Latin-1 as PDFDocEncoding
 1370     \txiescapepdfutfsixteen\pdfoutlinetext
 1371   }}
 1372   %
 1373   \def\pdfmkdest#1{%
 1374     \setpdfdestname{#1}%
 1375     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
 1376   }
 1377   %
 1378   % used to mark target names; must be expandable.
 1379   \def\pdfmkpgn#1{#1}
 1380   %
 1381   % by default, use black for everything.
 1382   \def\urlcolor{\rgbBlack}
 1383   \def\linkcolor{\rgbBlack}
 1384   \def\endlink{\setcolor{\maincolor}\pdfendlink}
 1385   %
 1386   % Adding outlines to PDF; macros for calculating structure of outlines
 1387   % come from Petr Olsak
 1388   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
 1389     \else \csname#1\endcsname \fi}
 1390   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
 1391     \advance\tempnum by 1
 1392     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
 1393   %
 1394   % #1 is the section text, which is what will be displayed in the
 1395   % outline by the pdf viewer.  #2 is the pdf expression for the number
 1396   % of subentries (or empty, for subsubsections).  #3 is the node text,
 1397   % which might be empty if this toc entry had no corresponding node.
 1398   % #4 is the page number
 1399   %
 1400   \def\dopdfoutline#1#2#3#4{%
 1401     % Generate a link to the node text if that exists; else, use the
 1402     % page number.  We could generate a destination for the section
 1403     % text in the case where a section has no node, but it doesn't
 1404     % seem worth the trouble, since most documents are normally structured.
 1405     \setpdfoutlinetext{#1}
 1406     \setpdfdestname{#3}
 1407     \ifx\pdfdestname\empty
 1408       \def\pdfdestname{#4}%
 1409     \fi
 1410     %
 1411     \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
 1412   }
 1413   %
 1414   \def\pdfmakeoutlines{%
 1415     \begingroup
 1416       % Read toc silently, to get counts of subentries for \pdfoutline.
 1417       \def\partentry##1##2##3##4{}% ignore parts in the outlines
 1418       \def\numchapentry##1##2##3##4{%
 1419     \def\thischapnum{##2}%
 1420     \def\thissecnum{0}%
 1421     \def\thissubsecnum{0}%
 1422       }%
 1423       \def\numsecentry##1##2##3##4{%
 1424     \advancenumber{chap\thischapnum}%
 1425     \def\thissecnum{##2}%
 1426     \def\thissubsecnum{0}%
 1427       }%
 1428       \def\numsubsecentry##1##2##3##4{%
 1429     \advancenumber{sec\thissecnum}%
 1430     \def\thissubsecnum{##2}%
 1431       }%
 1432       \def\numsubsubsecentry##1##2##3##4{%
 1433     \advancenumber{subsec\thissubsecnum}%
 1434       }%
 1435       \def\thischapnum{0}%
 1436       \def\thissecnum{0}%
 1437       \def\thissubsecnum{0}%
 1438       %
 1439       % use \def rather than \let here because we redefine \chapentry et
 1440       % al. a second time, below.
 1441       \def\appentry{\numchapentry}%
 1442       \def\appsecentry{\numsecentry}%
 1443       \def\appsubsecentry{\numsubsecentry}%
 1444       \def\appsubsubsecentry{\numsubsubsecentry}%
 1445       \def\unnchapentry{\numchapentry}%
 1446       \def\unnsecentry{\numsecentry}%
 1447       \def\unnsubsecentry{\numsubsecentry}%
 1448       \def\unnsubsubsecentry{\numsubsubsecentry}%
 1449       \readdatafile{toc}%
 1450       %
 1451       % Read toc second time, this time actually producing the outlines.
 1452       % The `-' means take the \expnumber as the absolute number of
 1453       % subentries, which we calculated on our first read of the .toc above.
 1454       %
 1455       % We use the node names as the destinations.
 1456       \def\numchapentry##1##2##3##4{%
 1457         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
 1458       \def\numsecentry##1##2##3##4{%
 1459         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
 1460       \def\numsubsecentry##1##2##3##4{%
 1461         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
 1462       \def\numsubsubsecentry##1##2##3##4{% count is always zero
 1463         \dopdfoutline{##1}{}{##3}{##4}}%
 1464       %
 1465       % PDF outlines are displayed using system fonts, instead of
 1466       % document fonts.  Therefore we cannot use special characters,
 1467       % since the encoding is unknown.  For example, the eogonek from
 1468       % Latin 2 (0xea) gets translated to a | character.  Info from
 1469       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
 1470       %
 1471       % TODO this right, we have to translate 8-bit characters to
 1472       % their "best" equivalent, based on the @documentencoding.  Too
 1473       % much work for too little return.  Just use the ASCII equivalents
 1474       % we use for the index sort strings.
 1475       % 
 1476       \indexnofonts
 1477       \setupdatafile
 1478       % We can have normal brace characters in the PDF outlines, unlike
 1479       % Texinfo index files.  So set that up.
 1480       \def\{{\lbracecharliteral}%
 1481       \def\}{\rbracecharliteral}%
 1482       \catcode`\\=\active \otherbackslash
 1483       \input \tocreadfilename
 1484     \endgroup
 1485   }
 1486   {\catcode`[=1 \catcode`]=2
 1487    \catcode`{=\other \catcode`}=\other
 1488    \gdef\lbracecharliteral[{]%
 1489    \gdef\rbracecharliteral[}]%
 1490   ]
 1491   %
 1492   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
 1493     \ifx\PP\D\let\nextsp\relax
 1494     \else\let\nextsp\skipspaces
 1495       \addtokens{\filename}{\PP}%
 1496       \advance\filenamelength by 1
 1497     \fi
 1498     \nextsp}
 1499   \def\getfilename#1{%
 1500     \filenamelength=0
 1501     % If we don't expand the argument now, \skipspaces will get
 1502     % snagged on things like "@value{foo}".
 1503     \edef\temp{#1}%
 1504     \expandafter\skipspaces\temp|\relax
 1505   }
 1506   \ifnum\pdftexversion < 14
 1507     \let \startlink \pdfannotlink
 1508   \else
 1509     \let \startlink \pdfstartlink
 1510   \fi
 1511   % make a live url in pdf output.
 1512   \def\pdfurl#1{%
 1513     \begingroup
 1514       % it seems we really need yet another set of dummies; have not
 1515       % tried to figure out what each command should do in the context
 1516       % of @url.  for now, just make @/ a no-op, that's the only one
 1517       % people have actually reported a problem with.
 1518       %
 1519       \normalturnoffactive
 1520       \def\@{@}%
 1521       \let\/=\empty
 1522       \makevalueexpandable
 1523       % do we want to go so far as to use \indexnofonts instead of just
 1524       % special-casing \var here?
 1525       \def\var##1{##1}%
 1526       %
 1527       \leavevmode\setcolor{\urlcolor}%
 1528       \startlink attr{/Border [0 0 0]}%
 1529         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
 1530     \endgroup}
 1531   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
 1532   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
 1533   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
 1534   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
 1535   \def\maketoks{%
 1536     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
 1537     \ifx\first0\adn0
 1538     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
 1539     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
 1540     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
 1541     \else
 1542       \ifnum0=\countA\else\makelink\fi
 1543       \ifx\first.\let\next=\done\else
 1544         \let\next=\maketoks
 1545         \addtokens{\toksB}{\the\toksD}
 1546         \ifx\first,\addtokens{\toksB}{\space}\fi
 1547       \fi
 1548     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
 1549     \next}
 1550   \def\makelink{\addtokens{\toksB}%
 1551     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
 1552   \def\pdflink#1{%
 1553     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
 1554     \setcolor{\linkcolor}#1\endlink}
 1555   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
 1556 \else
 1557   % non-pdf mode
 1558   \let\pdfmkdest = \gobble
 1559   \let\pdfurl = \gobble
 1560   \let\endlink = \relax
 1561   \let\setcolor = \gobble
 1562   \let\pdfsetcolor = \gobble
 1563   \let\pdfmakeoutlines = \relax
 1564 \fi  % \ifx\pdfoutput
 1565 
 1566 %
 1567 % For XeTeX
 1568 %
 1569 \ifx\XeTeXrevision\thisisundefined
 1570 \else
 1571   %
 1572   % XeTeX version check
 1573   %
 1574   \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
 1575     % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
 1576     % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
 1577     % For avoiding PDF destination name replacement, we use this special
 1578     % instead of xdvipdfmx's command line option `-C 0x0010'.
 1579     \special{dvipdfmx:config C 0x0010}
 1580     % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
 1581     % It can handle Unicode destination names for PDF.
 1582     \txiuseunicodedestnametrue
 1583   \else
 1584     % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
 1585     % `dvipdfmx:config' special.
 1586     % So for avoiding PDF destination name replacement,
 1587     % xdvipdfmx's command line option `-C 0x0010' is necessary.
 1588     %
 1589     % XeTeX < 0.99995 can not handle Unicode destination names for PDF
 1590     % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
 1591     % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
 1592     \txiuseunicodedestnamefalse
 1593   \fi
 1594   %
 1595   % Color support
 1596   %
 1597   \def\rgbDarkRed{0.50 0.09 0.12}
 1598   \def\rgbBlack{0 0 0}
 1599   %
 1600   \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
 1601   %
 1602   % Set color, and create a mark which defines \thiscolor accordingly,
 1603   % so that \makeheadline knows which color to restore.
 1604   \def\setcolor#1{%
 1605     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
 1606     \domark
 1607     \pdfsetcolor{#1}%
 1608   }
 1609   %
 1610   \def\maincolor{\rgbBlack}
 1611   \pdfsetcolor{\maincolor}
 1612   \edef\thiscolor{\maincolor}
 1613   \def\lastcolordefs{}
 1614   %
 1615   \def\makefootline{%
 1616     \baselineskip24pt
 1617     \line{\pdfsetcolor{\maincolor}\the\footline}%
 1618   }
 1619   %
 1620   \def\makeheadline{%
 1621     \vbox to 0pt{%
 1622       \vskip-22.5pt
 1623       \line{%
 1624         \vbox to8.5pt{}%
 1625         % Extract \thiscolor definition from the marks.
 1626         \getcolormarks
 1627         % Typeset the headline with \maincolor, then restore the color.
 1628         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
 1629       }%
 1630       \vss
 1631     }%
 1632     \nointerlineskip
 1633   }
 1634   %
 1635   % PDF outline support
 1636   %
 1637   % Emulate pdfTeX primitive
 1638   \def\pdfdest name#1 xyz{%
 1639     \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
 1640   }
 1641   %
 1642   \def\setpdfdestname#1{{%
 1643     % We have to set dummies so commands such as @code, and characters
 1644     % such as \, aren't expanded when present in a section title.
 1645     \indexnofonts
 1646     \makevalueexpandable
 1647     \turnoffactive
 1648     \iftxiuseunicodedestname
 1649       % Pass through Unicode characters.
 1650     \else
 1651       % Use ASCII approximations in destination names.
 1652       \passthroughcharsfalse
 1653     \fi
 1654     \def\pdfdestname{#1}%
 1655     \txiescapepdf\pdfdestname
 1656   }}
 1657   %
 1658   \def\setpdfoutlinetext#1{{%
 1659     \turnoffactive
 1660     % Always use Unicode characters in title texts.
 1661     \def\pdfoutlinetext{#1}%
 1662     % For XeTeX, xdvipdfmx converts to UTF-16.
 1663     % So we do not convert.
 1664     \txiescapepdf\pdfoutlinetext
 1665   }}
 1666   %
 1667   \def\pdfmkdest#1{%
 1668     \setpdfdestname{#1}%
 1669     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
 1670   }
 1671   %
 1672   % by default, use black for everything.
 1673   \def\urlcolor{\rgbBlack}
 1674   \def\linkcolor{\rgbBlack}
 1675   \def\endlink{\setcolor{\maincolor}\pdfendlink}
 1676   %
 1677   \def\dopdfoutline#1#2#3#4{%
 1678     \setpdfoutlinetext{#1}
 1679     \setpdfdestname{#3}
 1680     \ifx\pdfdestname\empty
 1681       \def\pdfdestname{#4}%
 1682     \fi
 1683     %
 1684     \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
 1685       << /S /GoTo /D (\pdfdestname) >> >> }%
 1686   }
 1687   %
 1688   \def\pdfmakeoutlines{%
 1689     \begingroup
 1690       %
 1691       % For XeTeX, counts of subentries are not necessary.
 1692       % Therefore, we read toc only once.
 1693       %
 1694       % We use node names as destinations.
 1695       \def\partentry##1##2##3##4{}% ignore parts in the outlines
 1696       \def\numchapentry##1##2##3##4{%
 1697         \dopdfoutline{##1}{1}{##3}{##4}}%
 1698       \def\numsecentry##1##2##3##4{%
 1699         \dopdfoutline{##1}{2}{##3}{##4}}%
 1700       \def\numsubsecentry##1##2##3##4{%
 1701         \dopdfoutline{##1}{3}{##3}{##4}}%
 1702       \def\numsubsubsecentry##1##2##3##4{%
 1703         \dopdfoutline{##1}{4}{##3}{##4}}%
 1704       %
 1705       \let\appentry\numchapentry%
 1706       \let\appsecentry\numsecentry%
 1707       \let\appsubsecentry\numsubsecentry%
 1708       \let\appsubsubsecentry\numsubsubsecentry%
 1709       \let\unnchapentry\numchapentry%
 1710       \let\unnsecentry\numsecentry%
 1711       \let\unnsubsecentry\numsubsecentry%
 1712       \let\unnsubsubsecentry\numsubsubsecentry%
 1713       %
 1714       % For XeTeX, xdvipdfmx converts strings to UTF-16.
 1715       % Therefore, the encoding and the language may not be considered.
 1716       %
 1717       \indexnofonts
 1718       \setupdatafile
 1719       % We can have normal brace characters in the PDF outlines, unlike
 1720       % Texinfo index files.  So set that up.
 1721       \def\{{\lbracecharliteral}%
 1722       \def\}{\rbracecharliteral}%
 1723       \catcode`\\=\active \otherbackslash
 1724       \input \tocreadfilename
 1725     \endgroup
 1726   }
 1727   {\catcode`[=1 \catcode`]=2
 1728    \catcode`{=\other \catcode`}=\other
 1729    \gdef\lbracecharliteral[{]%
 1730    \gdef\rbracecharliteral[}]%
 1731   ]
 1732 
 1733   \special{pdf:docview << /PageMode /UseOutlines >> }
 1734   % ``\special{pdf:tounicode ...}'' is not necessary
 1735   % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
 1736   % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
 1737   % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
 1738   % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
 1739 %
 1740   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
 1741     \ifx\PP\D\let\nextsp\relax
 1742     \else\let\nextsp\skipspaces
 1743       \addtokens{\filename}{\PP}%
 1744       \advance\filenamelength by 1
 1745     \fi
 1746     \nextsp}
 1747   \def\getfilename#1{%
 1748     \filenamelength=0
 1749     % If we don't expand the argument now, \skipspaces will get
 1750     % snagged on things like "@value{foo}".
 1751     \edef\temp{#1}%
 1752     \expandafter\skipspaces\temp|\relax
 1753   }
 1754   % make a live url in pdf output.
 1755   \def\pdfurl#1{%
 1756     \begingroup
 1757       % it seems we really need yet another set of dummies; have not
 1758       % tried to figure out what each command should do in the context
 1759       % of @url.  for now, just make @/ a no-op, that's the only one
 1760       % people have actually reported a problem with.
 1761       %
 1762       \normalturnoffactive
 1763       \def\@{@}%
 1764       \let\/=\empty
 1765       \makevalueexpandable
 1766       % do we want to go so far as to use \indexnofonts instead of just
 1767       % special-casing \var here?
 1768       \def\var##1{##1}%
 1769       %
 1770       \leavevmode\setcolor{\urlcolor}%
 1771       \special{pdf:bann << /Border [0 0 0]
 1772         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
 1773     \endgroup}
 1774   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
 1775   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
 1776   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
 1777   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
 1778   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
 1779   \def\maketoks{%
 1780     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
 1781     \ifx\first0\adn0
 1782     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
 1783     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
 1784     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
 1785     \else
 1786       \ifnum0=\countA\else\makelink\fi
 1787       \ifx\first.\let\next=\done\else
 1788         \let\next=\maketoks
 1789         \addtokens{\toksB}{\the\toksD}
 1790         \ifx\first,\addtokens{\toksB}{\space}\fi
 1791       \fi
 1792     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
 1793     \next}
 1794   \def\makelink{\addtokens{\toksB}%
 1795     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
 1796   \def\pdflink#1{%
 1797     \special{pdf:bann << /Border [0 0 0]
 1798       /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
 1799     \setcolor{\linkcolor}#1\endlink}
 1800   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
 1801 %
 1802   %
 1803   % @image support
 1804   %
 1805   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
 1806   \def\doxeteximage#1#2#3{%
 1807     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
 1808     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
 1809     %
 1810     % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
 1811     % others).  Let's try in that order, PDF first since if
 1812     % someone has a scalable image, presumably better to use that than a
 1813     % bitmap.
 1814     \let\xeteximgext=\empty
 1815     \begingroup
 1816       \openin 1 #1.pdf \ifeof 1
 1817         \openin 1 #1.PDF \ifeof 1
 1818           \openin 1 #1.png \ifeof 1
 1819             \openin 1 #1.jpg \ifeof 1
 1820               \openin 1 #1.jpeg \ifeof 1
 1821                 \openin 1 #1.JPG \ifeof 1
 1822                   \errmessage{Could not find image file #1 for XeTeX}%
 1823                 \else \gdef\xeteximgext{JPG}%
 1824                 \fi
 1825               \else \gdef\xeteximgext{jpeg}%
 1826               \fi
 1827             \else \gdef\xeteximgext{jpg}%
 1828             \fi
 1829           \else \gdef\xeteximgext{png}%
 1830           \fi
 1831         \else \gdef\xeteximgext{PDF}%
 1832         \fi
 1833       \else \gdef\xeteximgext{pdf}%
 1834       \fi
 1835       \closein 1
 1836     \endgroup
 1837     %
 1838     \def\xetexpdfext{pdf}%
 1839     \ifx\xeteximgext\xetexpdfext
 1840       \XeTeXpdffile "#1".\xeteximgext ""
 1841     \else
 1842       \def\xetexpdfext{PDF}%
 1843       \ifx\xeteximgext\xetexpdfext
 1844         \XeTeXpdffile "#1".\xeteximgext ""
 1845       \else
 1846         \XeTeXpicfile "#1".\xeteximgext ""
 1847       \fi
 1848     \fi
 1849     \ifdim \wd0 >0pt width \xeteximagewidth \fi
 1850     \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
 1851   }
 1852 \fi
 1853 
 1854 
 1855 %
 1856 \message{fonts,}
 1857 
 1858 % Set the baselineskip to #1, and the lineskip and strut size
 1859 % correspondingly.  There is no deep meaning behind these magic numbers
 1860 % used as factors; they just match (closely enough) what Knuth defined.
 1861 %
 1862 \def\lineskipfactor{.08333}
 1863 \def\strutheightpercent{.70833}
 1864 \def\strutdepthpercent {.29167}
 1865 %
 1866 % can get a sort of poor man's double spacing by redefining this.
 1867 \def\baselinefactor{1}
 1868 %
 1869 \newdimen\textleading
 1870 \def\setleading#1{%
 1871   \dimen0 = #1\relax
 1872   \normalbaselineskip = \baselinefactor\dimen0
 1873   \normallineskip = \lineskipfactor\normalbaselineskip
 1874   \normalbaselines
 1875   \setbox\strutbox =\hbox{%
 1876     \vrule width0pt height\strutheightpercent\baselineskip
 1877                     depth \strutdepthpercent \baselineskip
 1878   }%
 1879 }
 1880 
 1881 % PDF CMaps.  See also LaTeX's t1.cmap.
 1882 %
 1883 % do nothing with this by default.
 1884 \expandafter\let\csname cmapOT1\endcsname\gobble
 1885 \expandafter\let\csname cmapOT1IT\endcsname\gobble
 1886 \expandafter\let\csname cmapOT1TT\endcsname\gobble
 1887 
 1888 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
 1889 % (\pdffontattr was introduced many years ago, but people still run
 1890 % older pdftex's; it's easy to conditionalize, so we do.)
 1891 \ifpdf \ifx\pdffontattr\thisisundefined \else
 1892   \begingroup
 1893     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
 1894     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
 1895 %%DocumentNeededResources: ProcSet (CIDInit)
 1896 %%IncludeResource: ProcSet (CIDInit)
 1897 %%BeginResource: CMap (TeX-OT1-0)
 1898 %%Title: (TeX-OT1-0 TeX OT1 0)
 1899 %%Version: 1.000
 1900 %%EndComments
 1901 /CIDInit /ProcSet findresource begin
 1902 12 dict begin
 1903 begincmap
 1904 /CIDSystemInfo
 1905 << /Registry (TeX)
 1906 /Ordering (OT1)
 1907 /Supplement 0
 1908 >> def
 1909 /CMapName /TeX-OT1-0 def
 1910 /CMapType 2 def
 1911 1 begincodespacerange
 1912 <00> <7F>
 1913 endcodespacerange
 1914 8 beginbfrange
 1915 <00> <01> <0393>
 1916 <09> <0A> <03A8>
 1917 <23> <26> <0023>
 1918 <28> <3B> <0028>
 1919 <3F> <5B> <003F>
 1920 <5D> <5E> <005D>
 1921 <61> <7A> <0061>
 1922 <7B> <7C> <2013>
 1923 endbfrange
 1924 40 beginbfchar
 1925 <02> <0398>
 1926 <03> <039B>
 1927 <04> <039E>
 1928 <05> <03A0>
 1929 <06> <03A3>
 1930 <07> <03D2>
 1931 <08> <03A6>
 1932 <0B> <00660066>
 1933 <0C> <00660069>
 1934 <0D> <0066006C>
 1935 <0E> <006600660069>
 1936 <0F> <00660066006C>
 1937 <10> <0131>
 1938 <11> <0237>
 1939 <12> <0060>
 1940 <13> <00B4>
 1941 <14> <02C7>
 1942 <15> <02D8>
 1943 <16> <00AF>
 1944 <17> <02DA>
 1945 <18> <00B8>
 1946 <19> <00DF>
 1947 <1A> <00E6>
 1948 <1B> <0153>
 1949 <1C> <00F8>
 1950 <1D> <00C6>
 1951 <1E> <0152>
 1952 <1F> <00D8>
 1953 <21> <0021>
 1954 <22> <201D>
 1955 <27> <2019>
 1956 <3C> <00A1>
 1957 <3D> <003D>
 1958 <3E> <00BF>
 1959 <5C> <201C>
 1960 <5F> <02D9>
 1961 <60> <2018>
 1962 <7D> <02DD>
 1963 <7E> <007E>
 1964 <7F> <00A8>
 1965 endbfchar
 1966 endcmap
 1967 CMapName currentdict /CMap defineresource pop
 1968 end
 1969 end
 1970 %%EndResource
 1971 %%EOF
 1972     }\endgroup
 1973   \expandafter\edef\csname cmapOT1\endcsname#1{%
 1974     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
 1975   }%
 1976 %
 1977 % \cmapOT1IT
 1978   \begingroup
 1979     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
 1980     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
 1981 %%DocumentNeededResources: ProcSet (CIDInit)
 1982 %%IncludeResource: ProcSet (CIDInit)
 1983 %%BeginResource: CMap (TeX-OT1IT-0)
 1984 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
 1985 %%Version: 1.000
 1986 %%EndComments
 1987 /CIDInit /ProcSet findresource begin
 1988 12 dict begin
 1989 begincmap
 1990 /CIDSystemInfo
 1991 << /Registry (TeX)
 1992 /Ordering (OT1IT)
 1993 /Supplement 0
 1994 >> def
 1995 /CMapName /TeX-OT1IT-0 def
 1996 /CMapType 2 def
 1997 1 begincodespacerange
 1998 <00> <7F>
 1999 endcodespacerange
 2000 8 beginbfrange
 2001 <00> <01> <0393>
 2002 <09> <0A> <03A8>
 2003 <25> <26> <0025>
 2004 <28> <3B> <0028>
 2005 <3F> <5B> <003F>
 2006 <5D> <5E> <005D>
 2007 <61> <7A> <0061>
 2008 <7B> <7C> <2013>
 2009 endbfrange
 2010 42 beginbfchar
 2011 <02> <0398>
 2012 <03> <039B>
 2013 <04> <039E>
 2014 <05> <03A0>
 2015 <06> <03A3>
 2016 <07> <03D2>
 2017 <08> <03A6>
 2018 <0B> <00660066>
 2019 <0C> <00660069>
 2020 <0D> <0066006C>
 2021 <0E> <006600660069>
 2022 <0F> <00660066006C>
 2023 <10> <0131>
 2024 <11> <0237>
 2025 <12> <0060>
 2026 <13> <00B4>
 2027 <14> <02C7>
 2028 <15> <02D8>
 2029 <16> <00AF>
 2030 <17> <02DA>
 2031 <18> <00B8>
 2032 <19> <00DF>
 2033 <1A> <00E6>
 2034 <1B> <0153>
 2035 <1C> <00F8>
 2036 <1D> <00C6>
 2037 <1E> <0152>
 2038 <1F> <00D8>
 2039 <21> <0021>
 2040 <22> <201D>
 2041 <23> <0023>
 2042 <24> <00A3>
 2043 <27> <2019>
 2044 <3C> <00A1>
 2045 <3D> <003D>
 2046 <3E> <00BF>
 2047 <5C> <201C>
 2048 <5F> <02D9>
 2049 <60> <2018>
 2050 <7D> <02DD>
 2051 <7E> <007E>
 2052 <7F> <00A8>
 2053 endbfchar
 2054 endcmap
 2055 CMapName currentdict /CMap defineresource pop
 2056 end
 2057 end
 2058 %%EndResource
 2059 %%EOF
 2060     }\endgroup
 2061   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
 2062     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
 2063   }%
 2064 %
 2065 % \cmapOT1TT
 2066   \begingroup
 2067     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
 2068     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
 2069 %%DocumentNeededResources: ProcSet (CIDInit)
 2070 %%IncludeResource: ProcSet (CIDInit)
 2071 %%BeginResource: CMap (TeX-OT1TT-0)
 2072 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
 2073 %%Version: 1.000
 2074 %%EndComments
 2075 /CIDInit /ProcSet findresource begin
 2076 12 dict begin
 2077 begincmap
 2078 /CIDSystemInfo
 2079 << /Registry (TeX)
 2080 /Ordering (OT1TT)
 2081 /Supplement 0
 2082 >> def
 2083 /CMapName /TeX-OT1TT-0 def
 2084 /CMapType 2 def
 2085 1 begincodespacerange
 2086 <00> <7F>
 2087 endcodespacerange
 2088 5 beginbfrange
 2089 <00> <01> <0393>
 2090 <09> <0A> <03A8>
 2091 <21> <26> <0021>
 2092 <28> <5F> <0028>
 2093 <61> <7E> <0061>
 2094 endbfrange
 2095 32 beginbfchar
 2096 <02> <0398>
 2097 <03> <039B>
 2098 <04> <039E>
 2099 <05> <03A0>
 2100 <06> <03A3>
 2101 <07> <03D2>
 2102 <08> <03A6>
 2103 <0B> <2191>
 2104 <0C> <2193>
 2105 <0D> <0027>
 2106 <0E> <00A1>
 2107 <0F> <00BF>
 2108 <10> <0131>
 2109 <11> <0237>
 2110 <12> <0060>
 2111 <13> <00B4>
 2112 <14> <02C7>
 2113 <15> <02D8>
 2114 <16> <00AF>
 2115 <17> <02DA>
 2116 <18> <00B8>
 2117 <19> <00DF>
 2118 <1A> <00E6>
 2119 <1B> <0153>
 2120 <1C> <00F8>
 2121 <1D> <00C6>
 2122 <1E> <0152>
 2123 <1F> <00D8>
 2124 <20> <2423>
 2125 <27> <2019>
 2126 <60> <2018>
 2127 <7F> <00A8>
 2128 endbfchar
 2129 endcmap
 2130 CMapName currentdict /CMap defineresource pop
 2131 end
 2132 end
 2133 %%EndResource
 2134 %%EOF
 2135     }\endgroup
 2136   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
 2137     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
 2138   }%
 2139 \fi\fi
 2140 
 2141 
 2142 % Set the font macro #1 to the font named \fontprefix#2.
 2143 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
 2144 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
 2145 % Example:
 2146 % #1 = \textrm
 2147 % #2 = \rmshape
 2148 % #3 = 10
 2149 % #4 = \mainmagstep
 2150 % #5 = OT1
 2151 %
 2152 \def\setfont#1#2#3#4#5{%
 2153   \font#1=\fontprefix#2#3 scaled #4
 2154   \csname cmap#5\endcsname#1%
 2155 }
 2156 % This is what gets called when #5 of \setfont is empty.
 2157 \let\cmap\gobble
 2158 %
 2159 % (end of cmaps)
 2160 
 2161 % Use cm as the default font prefix.
 2162 % To specify the font prefix, you must define \fontprefix
 2163 % before you read in texinfo.tex.
 2164 \ifx\fontprefix\thisisundefined
 2165 \def\fontprefix{cm}
 2166 \fi
 2167 % Support font families that don't use the same naming scheme as CM.
 2168 \def\rmshape{r}
 2169 \def\rmbshape{bx}               % where the normal face is bold
 2170 \def\bfshape{b}
 2171 \def\bxshape{bx}
 2172 \def\ttshape{tt}
 2173 \def\ttbshape{tt}
 2174 \def\ttslshape{sltt}
 2175 \def\itshape{ti}
 2176 \def\itbshape{bxti}
 2177 \def\slshape{sl}
 2178 \def\slbshape{bxsl}
 2179 \def\sfshape{ss}
 2180 \def\sfbshape{ss}
 2181 \def\scshape{csc}
 2182 \def\scbshape{csc}
 2183 
 2184 % Definitions for a main text size of 11pt.  (The default in Texinfo.)
 2185 %
 2186 \def\definetextfontsizexi{%
 2187 % Text fonts (11.2pt, magstep1).
 2188 \def\textnominalsize{11pt}
 2189 \edef\mainmagstep{\magstephalf}
 2190 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
 2191 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
 2192 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
 2193 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
 2194 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
 2195 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
 2196 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
 2197 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
 2198 \font\texti=cmmi10 scaled \mainmagstep
 2199 \font\textsy=cmsy10 scaled \mainmagstep
 2200 \def\textecsize{1095}
 2201 
 2202 % A few fonts for @defun names and args.
 2203 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
 2204 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
 2205 \setfont\defsl\slshape{10}{\magstep1}{OT1TT}
 2206 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
 2207 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
 2208 \let\ttslfont=\defttsl \let\slfont=\defsl \bf}
 2209 
 2210 % Fonts for indices, footnotes, small examples (9pt).
 2211 \def\smallnominalsize{9pt}
 2212 \setfont\smallrm\rmshape{9}{1000}{OT1}
 2213 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
 2214 \setfont\smallbf\bfshape{10}{900}{OT1}
 2215 \setfont\smallit\itshape{9}{1000}{OT1IT}
 2216 \setfont\smallsl\slshape{9}{1000}{OT1}
 2217 \setfont\smallsf\sfshape{9}{1000}{OT1}
 2218 \setfont\smallsc\scshape{10}{900}{OT1}
 2219 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
 2220 \font\smalli=cmmi9
 2221 \font\smallsy=cmsy9
 2222 \def\smallecsize{0900}
 2223 
 2224 % Fonts for small examples (8pt).
 2225 \def\smallernominalsize{8pt}
 2226 \setfont\smallerrm\rmshape{8}{1000}{OT1}
 2227 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
 2228 \setfont\smallerbf\bfshape{10}{800}{OT1}
 2229 \setfont\smallerit\itshape{8}{1000}{OT1IT}
 2230 \setfont\smallersl\slshape{8}{1000}{OT1}
 2231 \setfont\smallersf\sfshape{8}{1000}{OT1}
 2232 \setfont\smallersc\scshape{10}{800}{OT1}
 2233 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
 2234 \font\smalleri=cmmi8
 2235 \font\smallersy=cmsy8
 2236 \def\smallerecsize{0800}
 2237 
 2238 % Fonts for title page (20.4pt):
 2239 \def\titlenominalsize{20pt}
 2240 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
 2241 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
 2242 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
 2243 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
 2244 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
 2245 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
 2246 \let\titlebf=\titlerm
 2247 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
 2248 \font\titlei=cmmi12 scaled \magstep3
 2249 \font\titlesy=cmsy10 scaled \magstep4
 2250 \def\titleecsize{2074}
 2251 
 2252 % Chapter (and unnumbered) fonts (17.28pt).
 2253 \def\chapnominalsize{17pt}
 2254 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
 2255 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
 2256 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
 2257 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
 2258 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
 2259 \setfont\chapsf\sfbshape{17}{1000}{OT1}
 2260 \let\chapbf=\chaprm
 2261 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
 2262 \font\chapi=cmmi12 scaled \magstep2
 2263 \font\chapsy=cmsy10 scaled \magstep3
 2264 \def\chapecsize{1728}
 2265 
 2266 % Section fonts (14.4pt).
 2267 \def\secnominalsize{14pt}
 2268 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
 2269 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
 2270 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
 2271 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
 2272 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
 2273 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
 2274 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
 2275 \let\secbf\secrm
 2276 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
 2277 \font\seci=cmmi12 scaled \magstep1
 2278 \font\secsy=cmsy10 scaled \magstep2
 2279 \def\sececsize{1440}
 2280 
 2281 % Subsection fonts (13.15pt).
 2282 \def\ssecnominalsize{13pt}
 2283 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
 2284 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
 2285 \setfont\ssecsl\slbshape{10}{1315}{OT1}
 2286 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
 2287 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
 2288 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
 2289 \let\ssecbf\ssecrm
 2290 \setfont\ssecsc\scbshape{10}{1315}{OT1}
 2291 \font\sseci=cmmi12 scaled \magstephalf
 2292 \font\ssecsy=cmsy10 scaled 1315
 2293 \def\ssececsize{1200}
 2294 
 2295 % Reduced fonts for @acronym in text (10pt).
 2296 \def\reducednominalsize{10pt}
 2297 \setfont\reducedrm\rmshape{10}{1000}{OT1}
 2298 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
 2299 \setfont\reducedbf\bfshape{10}{1000}{OT1}
 2300 \setfont\reducedit\itshape{10}{1000}{OT1IT}
 2301 \setfont\reducedsl\slshape{10}{1000}{OT1}
 2302 \setfont\reducedsf\sfshape{10}{1000}{OT1}
 2303 \setfont\reducedsc\scshape{10}{1000}{OT1}
 2304 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
 2305 \font\reducedi=cmmi10
 2306 \font\reducedsy=cmsy10
 2307 \def\reducedecsize{1000}
 2308 
 2309 \textleading = 13.2pt % line spacing for 11pt CM
 2310 \textfonts            % reset the current fonts
 2311 \rm
 2312 } % end of 11pt text font size definitions, \definetextfontsizexi
 2313 
 2314 
 2315 % Definitions to make the main text be 10pt Computer Modern, with
 2316 % section, chapter, etc., sizes following suit.  This is for the GNU
 2317 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
 2318 % future.  Used with @smallbook, which sets the leading to 12pt.
 2319 %
 2320 \def\definetextfontsizex{%
 2321 % Text fonts (10pt).
 2322 \def\textnominalsize{10pt}
 2323 \edef\mainmagstep{1000}
 2324 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
 2325 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
 2326 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
 2327 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
 2328 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
 2329 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
 2330 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
 2331 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
 2332 \font\texti=cmmi10 scaled \mainmagstep
 2333 \font\textsy=cmsy10 scaled \mainmagstep
 2334 \def\textecsize{1000}
 2335 
 2336 % A few fonts for @defun names and args.
 2337 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
 2338 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
 2339 \setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
 2340 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
 2341 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
 2342 \let\slfont=\defsl \let\ttslfont=\defttsl \bf}
 2343 
 2344 % Fonts for indices, footnotes, small examples (9pt).
 2345 \def\smallnominalsize{9pt}
 2346 \setfont\smallrm\rmshape{9}{1000}{OT1}
 2347 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
 2348 \setfont\smallbf\bfshape{10}{900}{OT1}
 2349 \setfont\smallit\itshape{9}{1000}{OT1IT}
 2350 \setfont\smallsl\slshape{9}{1000}{OT1}
 2351 \setfont\smallsf\sfshape{9}{1000}{OT1}
 2352 \setfont\smallsc\scshape{10}{900}{OT1}
 2353 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
 2354 \font\smalli=cmmi9
 2355 \font\smallsy=cmsy9
 2356 \def\smallecsize{0900}
 2357 
 2358 % Fonts for small examples (8pt).
 2359 \def\smallernominalsize{8pt}
 2360 \setfont\smallerrm\rmshape{8}{1000}{OT1}
 2361 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
 2362 \setfont\smallerbf\bfshape{10}{800}{OT1}
 2363 \setfont\smallerit\itshape{8}{1000}{OT1IT}
 2364 \setfont\smallersl\slshape{8}{1000}{OT1}
 2365 \setfont\smallersf\sfshape{8}{1000}{OT1}
 2366 \setfont\smallersc\scshape{10}{800}{OT1}
 2367 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
 2368 \font\smalleri=cmmi8
 2369 \font\smallersy=cmsy8
 2370 \def\smallerecsize{0800}
 2371 
 2372 % Fonts for title page (20.4pt):
 2373 \def\titlenominalsize{20pt}
 2374 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
 2375 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
 2376 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
 2377 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
 2378 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
 2379 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
 2380 \let\titlebf=\titlerm
 2381 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
 2382 \font\titlei=cmmi12 scaled \magstep3
 2383 \font\titlesy=cmsy10 scaled \magstep4
 2384 \def\titleecsize{2074}
 2385 
 2386 % Chapter fonts (14.4pt).
 2387 \def\chapnominalsize{14pt}
 2388 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
 2389 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
 2390 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
 2391 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
 2392 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
 2393 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
 2394 \let\chapbf\chaprm
 2395 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
 2396 \font\chapi=cmmi12 scaled \magstep1
 2397 \font\chapsy=cmsy10 scaled \magstep2
 2398 \def\chapecsize{1440}
 2399 
 2400 % Section fonts (12pt).
 2401 \def\secnominalsize{12pt}
 2402 \setfont\secrm\rmbshape{12}{1000}{OT1}
 2403 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
 2404 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
 2405 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
 2406 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
 2407 \setfont\secsf\sfbshape{12}{1000}{OT1}
 2408 \let\secbf\secrm
 2409 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
 2410 \font\seci=cmmi12
 2411 \font\secsy=cmsy10 scaled \magstep1
 2412 \def\sececsize{1200}
 2413 
 2414 % Subsection fonts (10pt).
 2415 \def\ssecnominalsize{10pt}
 2416 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
 2417 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
 2418 \setfont\ssecsl\slbshape{10}{1000}{OT1}
 2419 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
 2420 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
 2421 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
 2422 \let\ssecbf\ssecrm
 2423 \setfont\ssecsc\scbshape{10}{1000}{OT1}
 2424 \font\sseci=cmmi10
 2425 \font\ssecsy=cmsy10
 2426 \def\ssececsize{1000}
 2427 
 2428 % Reduced fonts for @acronym in text (9pt).
 2429 \def\reducednominalsize{9pt}
 2430 \setfont\reducedrm\rmshape{9}{1000}{OT1}
 2431 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
 2432 \setfont\reducedbf\bfshape{10}{900}{OT1}
 2433 \setfont\reducedit\itshape{9}{1000}{OT1IT}
 2434 \setfont\reducedsl\slshape{9}{1000}{OT1}
 2435 \setfont\reducedsf\sfshape{9}{1000}{OT1}
 2436 \setfont\reducedsc\scshape{10}{900}{OT1}
 2437 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
 2438 \font\reducedi=cmmi9
 2439 \font\reducedsy=cmsy9
 2440 \def\reducedecsize{0900}
 2441 
 2442 \divide\parskip by 2  % reduce space between paragraphs
 2443 \textleading = 12pt   % line spacing for 10pt CM
 2444 \textfonts            % reset the current fonts
 2445 \rm
 2446 } % end of 10pt text font size definitions, \definetextfontsizex
 2447 
 2448 % Fonts for short table of contents.
 2449 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
 2450 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
 2451 \setfont\shortcontsl\slshape{12}{1000}{OT1}
 2452 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
 2453 
 2454 
 2455 % We provide the user-level command
 2456 %   @fonttextsize 10
 2457 % (or 11) to redefine the text font size.  pt is assumed.
 2458 %
 2459 \def\xiword{11}
 2460 \def\xword{10}
 2461 \def\xwordpt{10pt}
 2462 %
 2463 \parseargdef\fonttextsize{%
 2464   \def\textsizearg{#1}%
 2465   %\wlog{doing @fonttextsize \textsizearg}%
 2466   %
 2467   % Set \globaldefs so that documents can use this inside @tex, since
 2468   % makeinfo 4.8 does not support it, but we need it nonetheless.
 2469   %
 2470  \begingroup \globaldefs=1
 2471   \ifx\textsizearg\xword \definetextfontsizex
 2472   \else \ifx\textsizearg\xiword \definetextfontsizexi
 2473   \else
 2474     \errhelp=\EMsimple
 2475     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
 2476   \fi\fi
 2477  \endgroup
 2478 }
 2479 
 2480 %
 2481 % Change the current font style to #1, remembering it in \curfontstyle.
 2482 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
 2483 % italics, not bold italics.
 2484 %
 2485 \def\setfontstyle#1{%
 2486   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
 2487   \csname #1font\endcsname  % change the current font
 2488 }
 2489 
 2490 \def\rm{\fam=0 \setfontstyle{rm}}
 2491 \def\it{\fam=\itfam \setfontstyle{it}}
 2492 \def\sl{\fam=\slfam \setfontstyle{sl}}
 2493 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
 2494 \def\tt{\fam=\ttfam \setfontstyle{tt}}
 2495 
 2496 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
 2497 % So we set up a \sf.
 2498 \newfam\sffam
 2499 \def\sf{\fam=\sffam \setfontstyle{sf}}
 2500 
 2501 % We don't need math for this font style.
 2502 \def\ttsl{\setfontstyle{ttsl}}
 2503 
 2504 
 2505 % In order for the font changes to affect most math symbols and letters,
 2506 % we have to define the \textfont of the standard families.  We don't
 2507 % bother to reset \scriptfont and \scriptscriptfont; awaiting user need.
 2508 %
 2509 \def\resetmathfonts{%
 2510   \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
 2511   \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
 2512   \textfont\ttfam=\ttfont \textfont\sffam=\sffont
 2513 }
 2514 
 2515 %
 2516 
 2517 % The font-changing commands (all called \...fonts) redefine the meanings
 2518 % of \STYLEfont, instead of just \STYLE.  We do this because \STYLE needs
 2519 % to also set the current \fam for math mode.  Our \STYLE (e.g., \rm)
 2520 % commands hardwire \STYLEfont to set the current font.
 2521 %
 2522 % Each font-changing command also sets the names \lsize (one size lower)
 2523 % and \lllsize (three sizes lower).  These relative commands are used
 2524 % in, e.g., the LaTeX logo and acronyms.
 2525 %
 2526 % This all needs generalizing, badly.
 2527 %
 2528 
 2529 \def\assignfonts#1{%
 2530   \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
 2531   \expandafter\let\expandafter\itfont\csname #1it\endcsname
 2532   \expandafter\let\expandafter\slfont\csname #1sl\endcsname
 2533   \expandafter\let\expandafter\bffont\csname #1bf\endcsname
 2534   \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
 2535   \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
 2536   \expandafter\let\expandafter\sffont  \csname #1sf\endcsname
 2537   \expandafter\let\expandafter\ifont   \csname #1i\endcsname
 2538   \expandafter\let\expandafter\syfont  \csname #1sy\endcsname
 2539   \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
 2540 }
 2541 
 2542 \newif\ifrmisbold
 2543 
 2544 % Select smaller font size with the current style.  Used to change font size
 2545 % in, e.g., the LaTeX logo and acronyms.  If we are using bold fonts for
 2546 % normal roman text, also use bold fonts for roman text in the smaller size.
 2547 \def\switchtolllsize{%
 2548    \expandafter\assignfonts\expandafter{\lllsize}%
 2549    \ifrmisbold
 2550      \let\rmfont\bffont
 2551    \fi
 2552    \csname\curfontstyle\endcsname
 2553 }%
 2554 
 2555 \def\switchtolsize{%
 2556    \expandafter\assignfonts\expandafter{\lsize}%
 2557    \ifrmisbold
 2558      \let\rmfont\bffont
 2559    \fi
 2560    \csname\curfontstyle\endcsname
 2561 }%
 2562 
 2563 \def\definefontsetatsize#1#2#3#4#5{%
 2564 \expandafter\def\csname #1fonts\endcsname{%
 2565   \def\curfontsize{#1}%
 2566   \def\lsize{#2}\def\lllsize{#3}%
 2567   \csname rmisbold#5\endcsname
 2568   \assignfonts{#1}%
 2569   \resetmathfonts
 2570   \setleading{#4}%
 2571 }}
 2572 
 2573 \definefontsetatsize{text}   {reduced}{smaller}{\textleading}{false}
 2574 \definefontsetatsize{title}  {chap}   {subsec} {27pt}  {true}
 2575 \definefontsetatsize{chap}   {sec}    {text}   {19pt}  {true}
 2576 \definefontsetatsize{sec}    {subsec} {reduced}{17pt}  {true}
 2577 \definefontsetatsize{ssec}   {text}   {small}  {15pt}  {true}
 2578 \definefontsetatsize{reduced}{small}  {smaller}{10.5pt}{false}
 2579 \definefontsetatsize{small}  {smaller}{smaller}{10.5pt}{false}
 2580 \definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
 2581 
 2582 \def\titlefont#1{{\titlefonts\rm #1}}
 2583 \let\subsecfonts = \ssecfonts
 2584 \let\subsubsecfonts = \ssecfonts
 2585 
 2586 % Define these just so they can be easily changed for other fonts.
 2587 \def\angleleft{$\langle$}
 2588 \def\angleright{$\rangle$}
 2589 
 2590 % Set the fonts to use with the @small... environments.
 2591 \let\smallexamplefonts = \smallfonts
 2592 
 2593 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
 2594 % can fit this many characters:
 2595 %   8.5x11=86   smallbook=72  a4=90  a5=69
 2596 % If we use \scriptfonts (8pt), then we can fit this many characters:
 2597 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
 2598 % For me, subjectively, the few extra characters that fit aren't worth
 2599 % the additional smallness of 8pt.  So I'm making the default 9pt.
 2600 %
 2601 % By the way, for comparison, here's what fits with @example (10pt):
 2602 %   8.5x11=71  smallbook=60  a4=75  a5=58
 2603 % --karl, 24jan03.
 2604 
 2605 % Set up the default fonts, so we can use them for creating boxes.
 2606 %
 2607 \definetextfontsizexi
 2608 
 2609 
 2610 \message{markup,}
 2611 
 2612 % Check if we are currently using a typewriter font.  Since all the
 2613 % Computer Modern typewriter fonts have zero interword stretch (and
 2614 % shrink), and it is reasonable to expect all typewriter fonts to have
 2615 % this property, we can check that font parameter.
 2616 %
 2617 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
 2618 
 2619 % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
 2620 % define and register \INITMACRO to be called on markup style changes.
 2621 % \INITMACRO can check \currentmarkupstyle for the innermost
 2622 % style and the set of \ifmarkupSTYLE switches for all styles
 2623 % currently in effect.
 2624 \newif\ifmarkupvar
 2625 \newif\ifmarkupsamp
 2626 \newif\ifmarkupkey
 2627 %\newif\ifmarkupfile % @file == @samp.
 2628 %\newif\ifmarkupoption % @option == @samp.
 2629 \newif\ifmarkupcode
 2630 \newif\ifmarkupkbd
 2631 %\newif\ifmarkupenv % @env == @code.
 2632 %\newif\ifmarkupcommand % @command == @code.
 2633 \newif\ifmarkuptex % @tex (and part of @math, for now).
 2634 \newif\ifmarkupexample
 2635 \newif\ifmarkupverb
 2636 \newif\ifmarkupverbatim
 2637 
 2638 \let\currentmarkupstyle\empty
 2639 
 2640 \def\setupmarkupstyle#1{%
 2641   \csname markup#1true\endcsname
 2642   \def\currentmarkupstyle{#1}%
 2643   \markupstylesetup
 2644 }
 2645 
 2646 \let\markupstylesetup\empty
 2647 
 2648 \def\defmarkupstylesetup#1{%
 2649   \expandafter\def\expandafter\markupstylesetup
 2650     \expandafter{\markupstylesetup #1}%
 2651   \def#1%
 2652 }
 2653 
 2654 % Markup style setup for left and right quotes.
 2655 \defmarkupstylesetup\markupsetuplq{%
 2656   \expandafter\let\expandafter \temp
 2657     \csname markupsetuplq\currentmarkupstyle\endcsname
 2658   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
 2659 }
 2660 
 2661 \defmarkupstylesetup\markupsetuprq{%
 2662   \expandafter\let\expandafter \temp
 2663     \csname markupsetuprq\currentmarkupstyle\endcsname
 2664   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
 2665 }
 2666 
 2667 {
 2668 \catcode`\'=\active
 2669 \catcode`\`=\active
 2670 
 2671 \gdef\markupsetuplqdefault{\let`\lq}
 2672 \gdef\markupsetuprqdefault{\let'\rq}
 2673 
 2674 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
 2675 \gdef\markupsetcodequoteright{\let'\codequoteright}
 2676 }
 2677 
 2678 \let\markupsetuplqcode \markupsetcodequoteleft
 2679 \let\markupsetuprqcode \markupsetcodequoteright
 2680 %
 2681 \let\markupsetuplqexample \markupsetcodequoteleft
 2682 \let\markupsetuprqexample \markupsetcodequoteright
 2683 %
 2684 \let\markupsetuplqkbd     \markupsetcodequoteleft
 2685 \let\markupsetuprqkbd     \markupsetcodequoteright
 2686 %
 2687 \let\markupsetuplqsamp \markupsetcodequoteleft
 2688 \let\markupsetuprqsamp \markupsetcodequoteright
 2689 %
 2690 \let\markupsetuplqverb \markupsetcodequoteleft
 2691 \let\markupsetuprqverb \markupsetcodequoteright
 2692 %
 2693 \let\markupsetuplqverbatim \markupsetcodequoteleft
 2694 \let\markupsetuprqverbatim \markupsetcodequoteright
 2695 
 2696 % Allow an option to not use regular directed right quote/apostrophe
 2697 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
 2698 % The undirected quote is ugly, so don't make it the default, but it
 2699 % works for pasting with more pdf viewers (at least evince), the
 2700 % lilypond developers report.  xpdf does work with the regular 0x27.
 2701 %
 2702 \def\codequoteright{%
 2703   \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
 2704     \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
 2705       '%
 2706     \else \char'15 \fi
 2707   \else \char'15 \fi
 2708 }
 2709 %
 2710 % and a similar option for the left quote char vs. a grave accent.
 2711 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
 2712 % the code environments to do likewise.
 2713 %
 2714 \def\codequoteleft{%
 2715   \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
 2716     \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
 2717       % [Knuth] pp. 380,381,391
 2718       % \relax disables Spanish ligatures ?` and !` of \tt font.
 2719       \relax`%
 2720     \else \char'22 \fi
 2721   \else \char'22 \fi
 2722 }
 2723 
 2724 % Commands to set the quote options.
 2725 % 
 2726 \parseargdef\codequoteundirected{%
 2727   \def\temp{#1}%
 2728   \ifx\temp\onword
 2729     \expandafter\let\csname SETtxicodequoteundirected\endcsname
 2730       = t%
 2731   \else\ifx\temp\offword
 2732     \expandafter\let\csname SETtxicodequoteundirected\endcsname
 2733       = \relax
 2734   \else
 2735     \errhelp = \EMsimple
 2736     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
 2737   \fi\fi
 2738 }
 2739 %
 2740 \parseargdef\codequotebacktick{%
 2741   \def\temp{#1}%
 2742   \ifx\temp\onword
 2743     \expandafter\let\csname SETtxicodequotebacktick\endcsname
 2744       = t%
 2745   \else\ifx\temp\offword
 2746     \expandafter\let\csname SETtxicodequotebacktick\endcsname
 2747       = \relax
 2748   \else
 2749     \errhelp = \EMsimple
 2750     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
 2751   \fi\fi
 2752 }
 2753 
 2754 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
 2755 \def\noligaturesquoteleft{\relax\lq}
 2756 
 2757 % Count depth in font-changes, for error checks
 2758 \newcount\fontdepth \fontdepth=0
 2759 
 2760 % Font commands.
 2761 
 2762 % #1 is the font command (\sl or \it), #2 is the text to slant.
 2763 % If we are in a monospaced environment, however, 1) always use \ttsl,
 2764 % and 2) do not add an italic correction.
 2765 \def\dosmartslant#1#2{%
 2766   \ifusingtt 
 2767     {{\ttsl #2}\let\next=\relax}%
 2768     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
 2769   \next
 2770 }
 2771 \def\smartslanted{\dosmartslant\sl}
 2772 \def\smartitalic{\dosmartslant\it}
 2773 
 2774 % Output an italic correction unless \next (presumed to be the following
 2775 % character) is such as not to need one.
 2776 \def\smartitaliccorrection{%
 2777   \ifx\next,%
 2778   \else\ifx\next-%
 2779   \else\ifx\next.%
 2780   \else\ifx\next\.%
 2781   \else\ifx\next\comma%
 2782   \else\ptexslash
 2783   \fi\fi\fi\fi\fi
 2784   \aftersmartic
 2785 }
 2786 
 2787 % Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
 2788 \def\ttslanted#1{{\ttsl #1}}
 2789 
 2790 % @cite is like \smartslanted except unconditionally use \sl.  We never want
 2791 % ttsl for book titles, do we?
 2792 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
 2793 
 2794 \def\aftersmartic{}
 2795 \def\var#1{%
 2796   \let\saveaftersmartic = \aftersmartic
 2797   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
 2798   \smartslanted{#1}%
 2799 }
 2800 
 2801 \let\i=\smartitalic
 2802 \let\slanted=\smartslanted
 2803 \let\dfn=\smartslanted
 2804 \let\emph=\smartitalic
 2805 
 2806 % Explicit font changes: @r, @sc, undocumented @ii.
 2807 \def\r#1{{\rm #1}}              % roman font
 2808 \def\sc#1{{\smallcaps#1}}       % smallcaps font
 2809 \def\ii#1{{\it #1}}             % italic font
 2810 
 2811 % @b, explicit bold.  Also @strong.
 2812 \def\b#1{{\bf #1}}
 2813 \let\strong=\b
 2814 
 2815 % @sansserif, explicit sans.
 2816 \def\sansserif#1{{\sf #1}}
 2817 
 2818 % We can't just use \exhyphenpenalty, because that only has effect at
 2819 % the end of a paragraph.  Restore normal hyphenation at the end of the
 2820 % group within which \nohyphenation is presumably called.
 2821 %
 2822 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
 2823 \def\restorehyphenation{\hyphenchar\font = `- }
 2824 
 2825 % Set sfcode to normal for the chars that usually have another value.
 2826 % Can't use plain's \frenchspacing because it uses the `\x notation, and
 2827 % sometimes \x has an active definition that messes things up.
 2828 %
 2829 \catcode`@=11
 2830   \def\plainfrenchspacing{%
 2831     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
 2832     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
 2833     \def\endofsentencespacefactor{1000}% for @. and friends
 2834   }
 2835   \def\plainnonfrenchspacing{%
 2836     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
 2837     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
 2838     \def\endofsentencespacefactor{3000}% for @. and friends
 2839   }
 2840 \catcode`@=\other
 2841 \def\endofsentencespacefactor{3000}% default
 2842 
 2843 % @t, explicit typewriter.
 2844 \def\t#1{%
 2845   {\tt \rawbackslash \plainfrenchspacing #1}%
 2846   \null
 2847 }
 2848 
 2849 % @samp.
 2850 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
 2851 
 2852 % @indicateurl is \samp, that is, with quotes.
 2853 \let\indicateurl=\samp
 2854 
 2855 % @code (and similar) prints in typewriter, but with spaces the same
 2856 % size as normal in the surrounding text, without hyphenation, etc.
 2857 % This is a subroutine for that.
 2858 \def\tclose#1{%
 2859   {%
 2860     % Change normal interword space to be same as for the current font.
 2861     \spaceskip = \fontdimen2\font
 2862     %
 2863     % Switch to typewriter.
 2864     \tt
 2865     %
 2866     % But `\ ' produces the large typewriter interword space.
 2867     \def\ {{\spaceskip = 0pt{} }}%
 2868     %
 2869     % Turn off hyphenation.
 2870     \nohyphenation
 2871     %
 2872     \rawbackslash
 2873     \plainfrenchspacing
 2874     #1%
 2875   }%
 2876   \null % reset spacefactor to 1000
 2877 }
 2878 
 2879 % We *must* turn on hyphenation at `-' and `_' in @code.
 2880 % (But see \codedashfinish below.)
 2881 % Otherwise, it is too hard to avoid overfull hboxes
 2882 % in the Emacs manual, the Library manual, etc.
 2883 %
 2884 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
 2885 % both hyphenation at - and hyphenation within words.
 2886 % We must therefore turn them both off (\tclose does that)
 2887 % and arrange explicitly to hyphenate at a dash. -- rms.
 2888 {
 2889   \catcode`\-=\active \catcode`\_=\active
 2890   \catcode`\'=\active \catcode`\`=\active
 2891   \global\let'=\rq \global\let`=\lq  % default definitions
 2892   %
 2893   \global\def\code{\begingroup
 2894     \setupmarkupstyle{code}%
 2895     % The following should really be moved into \setupmarkupstyle handlers.
 2896     \catcode\dashChar=\active  \catcode\underChar=\active
 2897     \ifallowcodebreaks
 2898      \let-\codedash
 2899      \let_\codeunder
 2900     \else
 2901      \let-\normaldash
 2902      \let_\realunder
 2903     \fi
 2904     % Given -foo (with a single dash), we do not want to allow a break
 2905     % after the hyphen.
 2906     \global\let\codedashprev=\codedash
 2907     %
 2908     \codex
 2909   }
 2910   %
 2911   \gdef\codedash{\futurelet\next\codedashfinish}
 2912   \gdef\codedashfinish{%
 2913     \normaldash % always output the dash character itself.
 2914     % 
 2915     % Now, output a discretionary to allow a line break, unless
 2916     % (a) the next character is a -, or
 2917     % (b) the preceding character is a -.
 2918     % E.g., given --posix, we do not want to allow a break after either -.
 2919     % Given --foo-bar, we do want to allow a break between the - and the b.
 2920     \ifx\next\codedash \else
 2921       \ifx\codedashprev\codedash 
 2922       \else \discretionary{}{}{}\fi
 2923     \fi
 2924     % we need the space after the = for the case when \next itself is a
 2925     % space token; it would get swallowed otherwise.  As in @code{- a}.
 2926     \global\let\codedashprev= \next
 2927   }
 2928 }
 2929 \def\normaldash{-}
 2930 %
 2931 \def\codex #1{\tclose{#1}\endgroup}
 2932 
 2933 \def\codeunder{%
 2934   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
 2935   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
 2936   % will therefore expand the active definition of _, which is us
 2937   % (inside @code that is), therefore an endless loop.
 2938   \ifusingtt{\ifmmode
 2939                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
 2940              \else\normalunderscore \fi
 2941              \discretionary{}{}{}}%
 2942             {\_}%
 2943 }
 2944 
 2945 % An additional complication: the above will allow breaks after, e.g.,
 2946 % each of the four underscores in __typeof__.  This is bad.
 2947 % @allowcodebreaks provides a document-level way to turn breaking at -
 2948 % and _ on and off.
 2949 %
 2950 \newif\ifallowcodebreaks  \allowcodebreakstrue
 2951 
 2952 \def\keywordtrue{true}
 2953 \def\keywordfalse{false}
 2954 
 2955 \parseargdef\allowcodebreaks{%
 2956   \def\txiarg{#1}%
 2957   \ifx\txiarg\keywordtrue
 2958     \allowcodebreakstrue
 2959   \else\ifx\txiarg\keywordfalse
 2960     \allowcodebreaksfalse
 2961   \else
 2962     \errhelp = \EMsimple
 2963     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
 2964   \fi\fi
 2965 }
 2966 
 2967 % For @command, @env, @file, @option quotes seem unnecessary,
 2968 % so use \code rather than \samp.
 2969 \let\command=\code
 2970 \let\env=\code
 2971 \let\file=\code
 2972 \let\option=\code
 2973 
 2974 % @uref (abbreviation for `urlref') aka @url takes an optional
 2975 % (comma-separated) second argument specifying the text to display and
 2976 % an optional third arg as text to display instead of (rather than in
 2977 % addition to) the url itself.  First (mandatory) arg is the url.
 2978 
 2979 % TeX-only option to allow changing PDF output to show only the second
 2980 % arg (if given), and not the url (which is then just the link target).
 2981 \newif\ifurefurlonlylink
 2982 
 2983 % The main macro is \urefbreak, which allows breaking at expected
 2984 % places within the url.  (There used to be another version, which
 2985 % didn't support automatic breaking.)
 2986 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
 2987 \let\uref=\urefbreak
 2988 %
 2989 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
 2990 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
 2991   \unsepspaces
 2992   \pdfurl{#1}%
 2993   \setbox0 = \hbox{\ignorespaces #3}%
 2994   \ifdim\wd0 > 0pt
 2995     \unhbox0 % third arg given, show only that
 2996   \else
 2997     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
 2998     \ifdim\wd0 > 0pt
 2999       \ifpdf
 3000         % For pdfTeX and LuaTeX
 3001         \ifurefurlonlylink
 3002           % PDF plus option to not display url, show just arg
 3003           \unhbox0             
 3004         \else
 3005           % PDF, normally display both arg and url for consistency,
 3006           % visibility, if the pdf is eventually used to print, etc.
 3007           \unhbox0\ (\urefcode{#1})%
 3008         \fi
 3009       \else
 3010         \ifx\XeTeXrevision\thisisundefined
 3011           \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
 3012         \else
 3013           % For XeTeX
 3014           \ifurefurlonlylink
 3015             % PDF plus option to not display url, show just arg
 3016             \unhbox0             
 3017           \else
 3018             % PDF, normally display both arg and url for consistency,
 3019             % visibility, if the pdf is eventually used to print, etc.
 3020             \unhbox0\ (\urefcode{#1})%
 3021           \fi
 3022         \fi
 3023       \fi
 3024     \else
 3025       \urefcode{#1}% only url given, so show it
 3026     \fi
 3027   \fi
 3028   \endlink
 3029 \endgroup}
 3030 
 3031 % Allow line breaks around only a few characters (only).
 3032 \def\urefcatcodes{%
 3033   \catcode`\&=\active \catcode`\.=\active
 3034   \catcode`\#=\active \catcode`\?=\active
 3035   \catcode`\/=\active
 3036 }
 3037 {
 3038   \urefcatcodes
 3039   %
 3040   \global\def\urefcode{\begingroup
 3041     \setupmarkupstyle{code}%
 3042     \urefcatcodes
 3043     \let&\urefcodeamp
 3044     \let.\urefcodedot
 3045     \let#\urefcodehash
 3046     \let?\urefcodequest
 3047     \let/\urefcodeslash
 3048     \codex
 3049   }
 3050   %
 3051   % By default, they are just regular characters.
 3052   \global\def&{\normalamp}
 3053   \global\def.{\normaldot}
 3054   \global\def#{\normalhash}
 3055   \global\def?{\normalquest}
 3056   \global\def/{\normalslash}
 3057 }
 3058 
 3059 % we put a little stretch before and after the breakable chars, to help
 3060 % line breaking of long url's.  The unequal skips make look better in
 3061 % cmtt at least, especially for dots.
 3062 \def\urefprestretchamount{.13em}
 3063 \def\urefpoststretchamount{.1em}
 3064 \def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
 3065 \def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
 3066 %
 3067 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
 3068 \def\urefcodedot{\urefprestretch .\urefpoststretch}
 3069 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
 3070 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
 3071 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
 3072 {
 3073   \catcode`\/=\active
 3074   \global\def\urefcodeslashfinish{%
 3075     \urefprestretch \slashChar
 3076     % Allow line break only after the final / in a sequence of
 3077     % slashes, to avoid line break between the slashes in http://.
 3078     \ifx\next/\else \urefpoststretch \fi
 3079   }
 3080 }
 3081 
 3082 % One more complication: by default we'll break after the special
 3083 % characters, but some people like to break before the special chars, so
 3084 % allow that.  Also allow no breaking at all, for manual control.
 3085 % 
 3086 \parseargdef\urefbreakstyle{%
 3087   \def\txiarg{#1}%
 3088   \ifx\txiarg\wordnone
 3089     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
 3090   \else\ifx\txiarg\wordbefore
 3091     \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
 3092   \else\ifx\txiarg\wordafter
 3093     \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
 3094   \else
 3095     \errhelp = \EMsimple
 3096     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
 3097   \fi\fi\fi
 3098 }
 3099 \def\wordafter{after}
 3100 \def\wordbefore{before}
 3101 \def\wordnone{none}
 3102 
 3103 \urefbreakstyle after
 3104 
 3105 % @url synonym for @uref, since that's how everyone uses it.
 3106 %
 3107 \let\url=\uref
 3108 
 3109 % rms does not like angle brackets --karl, 17may97.
 3110 % So now @email is just like @uref, unless we are pdf.
 3111 %
 3112 %\def\email#1{\angleleft{\tt #1}\angleright}
 3113 \ifpdf
 3114   \def\email#1{\doemail#1,,\finish}
 3115   \def\doemail#1,#2,#3\finish{\begingroup
 3116     \unsepspaces
 3117     \pdfurl{mailto:#1}%
 3118     \setbox0 = \hbox{\ignorespaces #2}%
 3119     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
 3120     \endlink
 3121   \endgroup}
 3122 \else
 3123   \ifx\XeTeXrevision\thisisundefined
 3124     \let\email=\uref
 3125   \else
 3126     \def\email#1{\doemail#1,,\finish}
 3127     \def\doemail#1,#2,#3\finish{\begingroup
 3128       \unsepspaces
 3129       \pdfurl{mailto:#1}%
 3130       \setbox0 = \hbox{\ignorespaces #2}%
 3131       \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
 3132       \endlink
 3133     \endgroup}
 3134   \fi
 3135 \fi
 3136 
 3137 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
 3138 %   `example' (@kbd uses ttsl only inside of @example and friends),
 3139 %   or `code' (@kbd uses normal tty font always).
 3140 \parseargdef\kbdinputstyle{%
 3141   \def\txiarg{#1}%
 3142   \ifx\txiarg\worddistinct
 3143     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
 3144   \else\ifx\txiarg\wordexample
 3145     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
 3146   \else\ifx\txiarg\wordcode
 3147     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
 3148   \else
 3149     \errhelp = \EMsimple
 3150     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
 3151   \fi\fi\fi
 3152 }
 3153 \def\worddistinct{distinct}
 3154 \def\wordexample{example}
 3155 \def\wordcode{code}
 3156 
 3157 % Default is `distinct'.
 3158 \kbdinputstyle distinct
 3159 
 3160 % @kbd is like @code, except that if the argument is just one @key command,
 3161 % then @kbd has no effect.
 3162 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
 3163 
 3164 \def\xkey{\key}
 3165 \def\kbdsub#1#2#3\par{%
 3166   \def\one{#1}\def\three{#3}\def\threex{??}%
 3167   \ifx\one\xkey\ifx\threex\three \key{#2}%
 3168   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
 3169   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
 3170 }
 3171 
 3172 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
 3173 %\setfont\keyrm\rmshape{8}{1000}{OT1}
 3174 %\font\keysy=cmsy9
 3175 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
 3176 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
 3177 %    \vbox{\hrule\kern-0.4pt
 3178 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
 3179 %    \kern-0.4pt\hrule}%
 3180 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
 3181 
 3182 % definition of @key with no lozenge.  If the current font is already
 3183 % monospace, don't change it; that way, we respect @kbdinputstyle.  But
 3184 % if it isn't monospace, then use \tt.
 3185 %
 3186 \def\key#1{{\setupmarkupstyle{key}%
 3187   \nohyphenation
 3188   \ifmonospace\else\tt\fi
 3189   #1}\null}
 3190 
 3191 % @clicksequence{File @click{} Open ...}
 3192 \def\clicksequence#1{\begingroup #1\endgroup}
 3193 
 3194 % @clickstyle @arrow   (by default)
 3195 \parseargdef\clickstyle{\def\click{#1}}
 3196 \def\click{\arrow}
 3197 
 3198 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
 3199 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
 3200 %
 3201 \def\dmn#1{\thinspace #1}
 3202 
 3203 % @acronym for "FBI", "NATO", and the like.
 3204 % We print this one point size smaller, since it's intended for
 3205 % all-uppercase.
 3206 %
 3207 \def\acronym#1{\doacronym #1,,\finish}
 3208 \def\doacronym#1,#2,#3\finish{%
 3209   {\switchtolsize #1}%
 3210   \def\temp{#2}%
 3211   \ifx\temp\empty \else
 3212     \space ({\unsepspaces \ignorespaces \temp \unskip})%
 3213   \fi
 3214   \null % reset \spacefactor=1000
 3215 }
 3216 
 3217 % @abbr for "Comput. J." and the like.
 3218 % No font change, but don't do end-of-sentence spacing.
 3219 %
 3220 \def\abbr#1{\doabbr #1,,\finish}
 3221 \def\doabbr#1,#2,#3\finish{%
 3222   {\plainfrenchspacing #1}%
 3223   \def\temp{#2}%
 3224   \ifx\temp\empty \else
 3225     \space ({\unsepspaces \ignorespaces \temp \unskip})%
 3226   \fi
 3227   \null % reset \spacefactor=1000
 3228 }
 3229 
 3230 % @asis just yields its argument.  Used with @table, for example.
 3231 %
 3232 \def\asis#1{#1}
 3233 
 3234 % @math outputs its argument in math mode.
 3235 %
 3236 % One complication: _ usually means subscripts, but it could also mean
 3237 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
 3238 % _ active, and distinguish by seeing if the current family is \slfam,
 3239 % which is what @var uses.
 3240 {
 3241   \catcode`\_ = \active
 3242   \gdef\mathunderscore{%
 3243     \catcode`\_=\active
 3244     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
 3245   }
 3246 }
 3247 % Another complication: we want \\ (and @\) to output a math (or tt) \.
 3248 % FYI, plain.tex uses \\ as a temporary control sequence (for no
 3249 % particular reason), but this is not advertised and we don't care.
 3250 %
 3251 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
 3252 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
 3253 %
 3254 \def\math{%
 3255   \ifmmode\else % only go into math if not in math mode already
 3256     \tex
 3257     \mathunderscore
 3258     \let\\ = \mathbackslash
 3259     \mathactive
 3260     % make the texinfo accent commands work in math mode
 3261     \let\"=\ddot
 3262     \let\'=\acute
 3263     \let\==\bar
 3264     \let\^=\hat
 3265     \let\`=\grave
 3266     \let\u=\breve
 3267     \let\v=\check
 3268     \let\~=\tilde
 3269     \let\dotaccent=\dot
 3270     % have to provide another name for sup operator
 3271     \let\mathopsup=\sup
 3272   $\expandafter\finishmath\fi
 3273 }
 3274 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
 3275 
 3276 % Some active characters (such as <) are spaced differently in math.
 3277 % We have to reset their definitions in case the @math was an argument
 3278 % to a command which sets the catcodes (such as @item or @section).
 3279 %
 3280 {
 3281   \catcode`^ = \active
 3282   \catcode`< = \active
 3283   \catcode`> = \active
 3284   \catcode`+ = \active
 3285   \catcode`' = \active
 3286   \gdef\mathactive{%
 3287     \let^ = \ptexhat
 3288     \let< = \ptexless
 3289     \let> = \ptexgtr
 3290     \let+ = \ptexplus
 3291     \let' = \ptexquoteright
 3292   }
 3293 }
 3294 
 3295 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
 3296 % If in text, use math to place as sub/superscript, but switch
 3297 % into text mode, with smaller fonts.  This is a different font than the
 3298 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
 3299 % fix it (significant additions to font machinery) until someone notices.
 3300 %
 3301 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
 3302 \def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
 3303 %
 3304 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
 3305 \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
 3306 
 3307 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
 3308 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
 3309 % except specified as a normal braced arg, so no newlines to worry about.
 3310 % 
 3311 \def\outfmtnametex{tex}
 3312 %
 3313 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
 3314 \long\def\doinlinefmt#1,#2,\finish{%
 3315   \def\inlinefmtname{#1}%
 3316   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
 3317 }
 3318 % 
 3319 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
 3320 % FMTNAME is tex, else ELSE-TEXT.
 3321 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
 3322 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
 3323   \def\inlinefmtname{#1}%
 3324   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
 3325 }
 3326 %
 3327 % For raw, must switch into @tex before parsing the argument, to avoid
 3328 % setting catcodes prematurely.  Doing it this way means that, for
 3329 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
 3330 % ignored.  But this isn't important because if people want a literal
 3331 % *right* brace they would have to use a command anyway, so they may as
 3332 % well use a command to get a left brace too.  We could re-use the
 3333 % delimiter character idea from \verb, but it seems like overkill.
 3334 % 
 3335 \long\def\inlineraw{\tex \doinlineraw}
 3336 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
 3337 \def\doinlinerawtwo#1,#2,\finish{%
 3338   \def\inlinerawname{#1}%
 3339   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
 3340   \endgroup % close group opened by \tex.
 3341 }
 3342 
 3343 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
 3344 %
 3345 \long\def\inlineifset#1{\doinlineifset #1,\finish}
 3346 \long\def\doinlineifset#1,#2,\finish{%
 3347   \def\inlinevarname{#1}%
 3348   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
 3349   \else\ignorespaces#2\fi
 3350 }
 3351 
 3352 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
 3353 %
 3354 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
 3355 \long\def\doinlineifclear#1,#2,\finish{%
 3356   \def\inlinevarname{#1}%
 3357   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
 3358 }
 3359 
 3360 
 3361 \message{glyphs,}
 3362 % and logos.
 3363 
 3364 % @@ prints an @, as does @atchar{}.
 3365 \def\@{\char64 }
 3366 \let\atchar=\@
 3367 
 3368 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
 3369 \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
 3370 \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
 3371 \let\{=\lbracechar
 3372 \let\}=\rbracechar
 3373 
 3374 % @comma{} to avoid , parsing problems.
 3375 \let\comma = ,
 3376 
 3377 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
 3378 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
 3379 \let\, = \ptexc
 3380 \let\dotaccent = \ptexdot
 3381 \def\ringaccent#1{{\accent23 #1}}
 3382 \let\tieaccent = \ptext
 3383 \let\ubaraccent = \ptexb
 3384 \let\udotaccent = \d
 3385 
 3386 % Other special characters: @questiondown @exclamdown @ordf @ordm
 3387 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
 3388 \def\questiondown{?`}
 3389 \def\exclamdown{!`}
 3390 \def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
 3391 \def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
 3392 
 3393 % Dotless i and dotless j, used for accents.
 3394 \def\imacro{i}
 3395 \def\jmacro{j}
 3396 \def\dotless#1{%
 3397   \def\temp{#1}%
 3398   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
 3399   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
 3400   \else \errmessage{@dotless can be used only with i or j}%
 3401   \fi\fi
 3402 }
 3403 
 3404 % The \TeX{} logo, as in plain, but resetting the spacing so that a
 3405 % period following counts as ending a sentence.  (Idea found in latex.)
 3406 %
 3407 \edef\TeX{\TeX \spacefactor=1000 }
 3408 
 3409 % @LaTeX{} logo.  Not quite the same results as the definition in
 3410 % latex.ltx, since we use a different font for the raised A; it's most
 3411 % convenient for us to use an explicitly smaller font, rather than using
 3412 % the \scriptstyle font (since we don't reset \scriptstyle and
 3413 % \scriptscriptstyle).
 3414 %
 3415 \def\LaTeX{%
 3416   L\kern-.36em
 3417   {\setbox0=\hbox{T}%
 3418    \vbox to \ht0{\hbox{%
 3419      \ifx\textnominalsize\xwordpt
 3420        % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
 3421        % Revert to plain's \scriptsize, which is 7pt.
 3422        \count255=\the\fam $\fam\count255 \scriptstyle A$%
 3423      \else
 3424        % For 11pt, we can use our lllsize.
 3425        \switchtolllsize A%
 3426      \fi
 3427      }%
 3428      \vss
 3429   }}%
 3430   \kern-.15em
 3431   \TeX
 3432 }
 3433 
 3434 % Some math mode symbols.  Define \ensuremath to switch into math mode
 3435 % unless we are already there.  Expansion tricks may not be needed here,
 3436 % but safer, and can't hurt.
 3437 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
 3438 \def\ensuredmath#1{$\relax#1$}
 3439 %
 3440 \def\bullet{\ensuremath\ptexbullet}
 3441 \def\geq{\ensuremath\ge}
 3442 \def\leq{\ensuremath\le}
 3443 \def\minus{\ensuremath-}
 3444 
 3445 % @dots{} outputs an ellipsis using the current font.
 3446 % We do .5em per period so that it has the same spacing in the cm
 3447 % typewriter fonts as three actual period characters; on the other hand,
 3448 % in other typewriter fonts three periods are wider than 1.5em.  So do
 3449 % whichever is larger.
 3450 %
 3451 \def\dots{%
 3452   \leavevmode
 3453   \setbox0=\hbox{...}% get width of three periods
 3454   \ifdim\wd0 > 1.5em
 3455     \dimen0 = \wd0
 3456   \else
 3457     \dimen0 = 1.5em
 3458   \fi
 3459   \hbox to \dimen0{%
 3460     \hskip 0pt plus.25fil
 3461     .\hskip 0pt plus1fil
 3462     .\hskip 0pt plus1fil
 3463     .\hskip 0pt plus.5fil
 3464   }%
 3465 }
 3466 
 3467 % @enddots{} is an end-of-sentence ellipsis.
 3468 %
 3469 \def\enddots{%
 3470   \dots
 3471   \spacefactor=\endofsentencespacefactor
 3472 }
 3473 
 3474 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
 3475 %
 3476 % Since these characters are used in examples, they should be an even number of
 3477 % \tt widths. Each \tt character is 1en, so two makes it 1em.
 3478 %
 3479 \def\point{$\star$}
 3480 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
 3481 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
 3482 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
 3483 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
 3484 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
 3485 
 3486 % The @error{} command.
 3487 % Adapted from the TeXbook's \boxit.
 3488 %
 3489 \newbox\errorbox
 3490 %
 3491 {\ttfont \global\dimen0 = 3em}% Width of the box.
 3492 \dimen2 = .55pt % Thickness of rules
 3493 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
 3494 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
 3495 %
 3496 \setbox\errorbox=\hbox to \dimen0{\hfil
 3497    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
 3498    \advance\hsize by -2\dimen2 % Rules.
 3499    \vbox{%
 3500       \hrule height\dimen2
 3501       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
 3502          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
 3503          \kern3pt\vrule width\dimen2}% Space to right.
 3504       \hrule height\dimen2}
 3505     \hfil}
 3506 %
 3507 \def\error{\leavevmode\lower.7ex\copy\errorbox}
 3508 
 3509 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
 3510 %
 3511 \def\pounds{{\it\$}}
 3512 
 3513 % @euro{} comes from a separate font, depending on the current style.
 3514 % We use the free feym* fonts from the eurosym package by Henrik
 3515 % Theiling, which support regular, slanted, bold and bold slanted (and
 3516 % "outlined" (blackboard board, sort of) versions, which we don't need).
 3517 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
 3518 %
 3519 % Although only regular is the truly official Euro symbol, we ignore
 3520 % that.  The Euro is designed to be slightly taller than the regular
 3521 % font height.
 3522 %
 3523 % feymr - regular
 3524 % feymo - slanted
 3525 % feybr - bold
 3526 % feybo - bold slanted
 3527 %
 3528 % There is no good (free) typewriter version, to my knowledge.
 3529 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
 3530 % Hmm.
 3531 %
 3532 % Also doesn't work in math.  Do we need to do math with euro symbols?
 3533 % Hope not.
 3534 %
 3535 %
 3536 \def\euro{{\eurofont e}}
 3537 \def\eurofont{%
 3538   % We set the font at each command, rather than predefining it in
 3539   % \textfonts and the other font-switching commands, so that
 3540   % installations which never need the symbol don't have to have the
 3541   % font installed.
 3542   %
 3543   % There is only one designed size (nominal 10pt), so we always scale
 3544   % that to the current nominal size.
 3545   %
 3546   % By the way, simply using "at 1em" works for cmr10 and the like, but
 3547   % does not work for cmbx10 and other extended/shrunken fonts.
 3548   %
 3549   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
 3550   %
 3551   \ifx\curfontstyle\bfstylename
 3552     % bold:
 3553     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
 3554   \else
 3555     % regular:
 3556     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
 3557   \fi
 3558   \thiseurofont
 3559 }
 3560 
 3561 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
 3562 % sometimes we redefine the original macro, and the alias should reflect
 3563 % the redefinition.
 3564 %
 3565 % Use LaTeX names for the Icelandic letters.
 3566 \def\DH{{\ecfont \char"D0}} % Eth
 3567 \def\dh{{\ecfont \char"F0}} % eth
 3568 \def\TH{{\ecfont \char"DE}} % Thorn
 3569 \def\th{{\ecfont \char"FE}} % thorn
 3570 %
 3571 \def\guillemetleft{{\ecfont \char"13}}
 3572 \def\guillemotleft{\guillemetleft}
 3573 \def\guillemetright{{\ecfont \char"14}}
 3574 \def\guillemotright{\guillemetright}
 3575 \def\guilsinglleft{{\ecfont \char"0E}}
 3576 \def\guilsinglright{{\ecfont \char"0F}}
 3577 \def\quotedblbase{{\ecfont \char"12}}
 3578 \def\quotesinglbase{{\ecfont \char"0D}}
 3579 %
 3580 % This positioning is not perfect (see the ogonek LaTeX package), but
 3581 % we have the precomposed glyphs for the most common cases.  We put the
 3582 % tests to use those glyphs in the single \ogonek macro so we have fewer
 3583 % dummy definitions to worry about for index entries, etc.
 3584 %
 3585 % ogonek is also used with other letters in Lithuanian (IOU), but using
 3586 % the precomposed glyphs for those is not so easy since they aren't in
 3587 % the same EC font.
 3588 \def\ogonek#1{{%
 3589   \def\temp{#1}%
 3590   \ifx\temp\macrocharA\Aogonek
 3591   \else\ifx\temp\macrochara\aogonek
 3592   \else\ifx\temp\macrocharE\Eogonek
 3593   \else\ifx\temp\macrochare\eogonek
 3594   \else
 3595     \ecfont \setbox0=\hbox{#1}%
 3596     \ifdim\ht0=1ex\accent"0C #1%
 3597     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
 3598     \fi
 3599   \fi\fi\fi\fi
 3600   }%
 3601 }
 3602 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
 3603 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
 3604 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
 3605 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
 3606 %
 3607 % Use the European Computer Modern fonts (cm-super in outline format)
 3608 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
 3609 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
 3610 % package and follow the same conventions.
 3611 % 
 3612 \def\ecfont{\etcfont{e}}
 3613 \def\tcfont{\etcfont{t}}
 3614 %
 3615 \def\etcfont#1{%
 3616   % We can't distinguish serif/sans and italic/slanted, but this
 3617   % is used for crude hacks anyway (like adding French and German
 3618   % quotes to documents typeset with CM, where we lose kerning), so
 3619   % hopefully nobody will notice/care.
 3620   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
 3621   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
 3622   \ifmonospace
 3623     % typewriter:
 3624     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
 3625   \else
 3626     \ifx\curfontstyle\bfstylename
 3627       % bold:
 3628       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
 3629     \else
 3630       % regular:
 3631       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
 3632     \fi
 3633   \fi
 3634   \thisecfont
 3635 }
 3636 
 3637 % @registeredsymbol - R in a circle.  The font for the R should really
 3638 % be smaller yet, but lllsize is the best we can do for now.
 3639 % Adapted from the plain.tex definition of \copyright.
 3640 %
 3641 \def\registeredsymbol{%
 3642   $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
 3643                \hfil\crcr\Orb}}%
 3644     }$%
 3645 }
 3646 
 3647 % @textdegree - the normal degrees sign.
 3648 %
 3649 \def\textdegree{$^\circ$}
 3650 
 3651 % Laurent Siebenmann reports \Orb undefined with:
 3652 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
 3653 % so we'll define it if necessary.
 3654 %
 3655 \ifx\Orb\thisisundefined
 3656 \def\Orb{\mathhexbox20D}
 3657 \fi
 3658 
 3659 % Quotes.
 3660 \chardef\quotedblleft="5C
 3661 \chardef\quotedblright=`\"
 3662 \chardef\quoteleft=`\`
 3663 \chardef\quoteright=`\'
 3664 
 3665 
 3666 \message{page headings,}
 3667 
 3668 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
 3669 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
 3670 
 3671 % First the title page.  Must do @settitle before @titlepage.
 3672 \newif\ifseenauthor
 3673 \newif\iffinishedtitlepage
 3674 
 3675 % @setcontentsaftertitlepage used to do an implicit @contents or
 3676 % @shortcontents after @end titlepage, but it is now obsolete.
 3677 \def\setcontentsaftertitlepage{%
 3678   \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
 3679               command; move your @contents command if you want the contents
 3680               after the title page.}}%
 3681 \def\setshortcontentsaftertitlepage{%
 3682   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
 3683               command; move your @shortcontents and @contents commands if you 
 3684               want the contents after the title page.}}%
 3685 
 3686 \parseargdef\shorttitlepage{%
 3687   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
 3688   \endgroup\page\hbox{}\page}
 3689 
 3690 \envdef\titlepage{%
 3691   % Open one extra group, as we want to close it in the middle of \Etitlepage.
 3692   \begingroup
 3693     \parindent=0pt \textfonts
 3694     % Leave some space at the very top of the page.
 3695     \vglue\titlepagetopglue
 3696     % No rule at page bottom unless we print one at the top with @title.
 3697     \finishedtitlepagetrue
 3698     %
 3699     % Most title ``pages'' are actually two pages long, with space
 3700     % at the top of the second.  We don't want the ragged left on the second.
 3701     \let\oldpage = \page
 3702     \def\page{%
 3703       \iffinishedtitlepage\else
 3704      \finishtitlepage
 3705       \fi
 3706       \let\page = \oldpage
 3707       \page
 3708       \null
 3709     }%
 3710 }
 3711 
 3712 \def\Etitlepage{%
 3713     \iffinishedtitlepage\else
 3714     \finishtitlepage
 3715     \fi
 3716     % It is important to do the page break before ending the group,
 3717     % because the headline and footline are only empty inside the group.
 3718     % If we use the new definition of \page, we always get a blank page
 3719     % after the title page, which we certainly don't want.
 3720     \oldpage
 3721   \endgroup
 3722   %
 3723   % Need this before the \...aftertitlepage checks so that if they are
 3724   % in effect the toc pages will come out with page numbers.
 3725   \HEADINGSon
 3726 }
 3727 
 3728 \def\finishtitlepage{%
 3729   \vskip4pt \hrule height 2pt width \hsize
 3730   \vskip\titlepagebottomglue
 3731   \finishedtitlepagetrue
 3732 }
 3733 
 3734 % Settings used for typesetting titles: no hyphenation, no indentation,
 3735 % don't worry much about spacing, ragged right.  This should be used
 3736 % inside a \vbox, and fonts need to be set appropriately first. \par should
 3737 % be specified before the end of the \vbox, since a vbox is a group.
 3738 % 
 3739 \def\raggedtitlesettings{%
 3740   \rm
 3741   \hyphenpenalty=10000
 3742   \parindent=0pt
 3743   \tolerance=5000
 3744   \ptexraggedright
 3745 }
 3746 
 3747 % Macros to be used within @titlepage:
 3748 
 3749 \let\subtitlerm=\rmfont
 3750 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
 3751 
 3752 \parseargdef\title{%
 3753   \checkenv\titlepage
 3754   \vbox{\titlefonts \raggedtitlesettings #1\par}%
 3755   % print a rule at the page bottom also.
 3756   \finishedtitlepagefalse
 3757   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
 3758 }
 3759 
 3760 \parseargdef\subtitle{%
 3761   \checkenv\titlepage
 3762   {\subtitlefont \rightline{#1}}%
 3763 }
 3764 
 3765 % @author should come last, but may come many times.
 3766 % It can also be used inside @quotation.
 3767 %
 3768 \parseargdef\author{%
 3769   \def\temp{\quotation}%
 3770   \ifx\thisenv\temp
 3771     \def\quotationauthor{#1}% printed in \Equotation.
 3772   \else
 3773     \checkenv\titlepage
 3774     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
 3775     {\secfonts\rm \leftline{#1}}%
 3776   \fi
 3777 }
 3778 
 3779 
 3780 % Set up page headings and footings.
 3781 
 3782 \let\thispage=\folio
 3783 
 3784 \newtoks\evenheadline    % headline on even pages
 3785 \newtoks\oddheadline     % headline on odd pages
 3786 \newtoks\evenfootline    % footline on even pages
 3787 \newtoks\oddfootline     % footline on odd pages
 3788 
 3789 % Now make \makeheadline and \makefootline in Plain TeX use those variables
 3790 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
 3791                             \else \the\evenheadline \fi}}
 3792 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
 3793                             \else \the\evenfootline \fi}\HEADINGShook}
 3794 \let\HEADINGShook=\relax
 3795 
 3796 % Commands to set those variables.
 3797 % For example, this is what  @headings on  does
 3798 % @evenheading @thistitle|@thispage|@thischapter
 3799 % @oddheading @thischapter|@thispage|@thistitle
 3800 % @evenfooting @thisfile||
 3801 % @oddfooting ||@thisfile
 3802 
 3803 
 3804 \def\evenheading{\parsearg\evenheadingxxx}
 3805 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
 3806 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
 3807 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
 3808 
 3809 \def\oddheading{\parsearg\oddheadingxxx}
 3810 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
 3811 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
 3812 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
 3813 
 3814 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
 3815 
 3816 \def\evenfooting{\parsearg\evenfootingxxx}
 3817 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
 3818 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
 3819 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
 3820 
 3821 \def\oddfooting{\parsearg\oddfootingxxx}
 3822 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
 3823 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
 3824   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
 3825   %
 3826   % Leave some space for the footline.  Hopefully ok to assume
 3827   % @evenfooting will not be used by itself.
 3828   \global\advance\txipageheight by -12pt
 3829   \global\advance\vsize by -12pt
 3830 }
 3831 
 3832 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
 3833 
 3834 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
 3835 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
 3836 %
 3837 % The same set of arguments for:
 3838 %
 3839 % @oddheadingmarks
 3840 % @evenfootingmarks
 3841 % @oddfootingmarks
 3842 % @everyheadingmarks
 3843 % @everyfootingmarks
 3844 
 3845 % These define \getoddheadingmarks, \getevenheadingmarks,
 3846 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
 3847 % \gettopheadingmarks, \getbottomheadingmarks.
 3848 %
 3849 \def\evenheadingmarks{\headingmarks{even}{heading}}
 3850 \def\oddheadingmarks{\headingmarks{odd}{heading}}
 3851 \def\evenfootingmarks{\headingmarks{even}{footing}}
 3852 \def\oddfootingmarks{\headingmarks{odd}{footing}}
 3853 \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
 3854                           \headingmarks{odd}{heading}{#1} }
 3855 \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
 3856                           \headingmarks{odd}{footing}{#1} }
 3857 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
 3858 \def\headingmarks#1#2#3 {%
 3859   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
 3860   \global\expandafter\let\csname get#1#2marks\endcsname \temp
 3861 }
 3862 
 3863 \everyheadingmarks bottom
 3864 \everyfootingmarks bottom
 3865 
 3866 % @headings double      turns headings on for double-sided printing.
 3867 % @headings single      turns headings on for single-sided printing.
 3868 % @headings off         turns them off.
 3869 % @headings on          same as @headings double, retained for compatibility.
 3870 % @headings after       turns on double-sided headings after this page.
 3871 % @headings doubleafter turns on double-sided headings after this page.
 3872 % @headings singleafter turns on single-sided headings after this page.
 3873 % By default, they are off at the start of a document,
 3874 % and turned `on' after @end titlepage.
 3875 
 3876 \parseargdef\headings{\csname HEADINGS#1\endcsname}
 3877 
 3878 \def\headingsoff{% non-global headings elimination
 3879   \evenheadline={\hfil}\evenfootline={\hfil}%
 3880    \oddheadline={\hfil}\oddfootline={\hfil}%
 3881 }
 3882 
 3883 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
 3884 \HEADINGSoff  % it's the default
 3885 
 3886 % When we turn headings on, set the page number to 1.
 3887 % For double-sided printing, put current file name in lower left corner,
 3888 % chapter name on inside top of right hand pages, document
 3889 % title on inside top of left hand pages, and page numbers on outside top
 3890 % edge of all pages.
 3891 \def\HEADINGSdouble{%
 3892 \global\pageno=1
 3893 \global\evenfootline={\hfil}
 3894 \global\oddfootline={\hfil}
 3895 \global\evenheadline={\line{\folio\hfil\thistitle}}
 3896 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
 3897 \global\let\contentsalignmacro = \chapoddpage
 3898 }
 3899 \let\contentsalignmacro = \chappager
 3900 
 3901 % For single-sided printing, chapter title goes across top left of page,
 3902 % page number on top right.
 3903 \def\HEADINGSsingle{%
 3904 \global\pageno=1
 3905 \global\evenfootline={\hfil}
 3906 \global\oddfootline={\hfil}
 3907 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
 3908 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
 3909 \global\let\contentsalignmacro = \chappager
 3910 }
 3911 \def\HEADINGSon{\HEADINGSdouble}
 3912 
 3913 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
 3914 \let\HEADINGSdoubleafter=\HEADINGSafter
 3915 \def\HEADINGSdoublex{%
 3916 \global\evenfootline={\hfil}
 3917 \global\oddfootline={\hfil}
 3918 \global\evenheadline={\line{\folio\hfil\thistitle}}
 3919 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
 3920 \global\let\contentsalignmacro = \chapoddpage
 3921 }
 3922 
 3923 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
 3924 \def\HEADINGSsinglex{%
 3925 \global\evenfootline={\hfil}
 3926 \global\oddfootline={\hfil}
 3927 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
 3928 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
 3929 \global\let\contentsalignmacro = \chappager
 3930 }
 3931 
 3932 % Subroutines used in generating headings
 3933 % This produces Day Month Year style of output.
 3934 % Only define if not already defined, in case a txi-??.tex file has set
 3935 % up a different format (e.g., txi-cs.tex does this).
 3936 \ifx\today\thisisundefined
 3937 \def\today{%
 3938   \number\day\space
 3939   \ifcase\month
 3940   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
 3941   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
 3942   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
 3943   \fi
 3944   \space\number\year}
 3945 \fi
 3946 
 3947 % @settitle line...  specifies the title of the document, for headings.
 3948 % It generates no output of its own.
 3949 \def\thistitle{\putwordNoTitle}
 3950 \def\settitle{\parsearg{\gdef\thistitle}}
 3951 
 3952 
 3953 \message{tables,}
 3954 % Tables -- @table, @ftable, @vtable, @item(x).
 3955 
 3956 % default indentation of table text
 3957 \newdimen\tableindent \tableindent=.8in
 3958 % default indentation of @itemize and @enumerate text
 3959 \newdimen\itemindent  \itemindent=.3in
 3960 % margin between end of table item and start of table text.
 3961 \newdimen\itemmargin  \itemmargin=.1in
 3962 
 3963 % used internally for \itemindent minus \itemmargin
 3964 \newdimen\itemmax
 3965 
 3966 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
 3967 % these defs.
 3968 % They also define \itemindex
 3969 % to index the item name in whatever manner is desired (perhaps none).
 3970 
 3971 \newif\ifitemxneedsnegativevskip
 3972 
 3973 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
 3974 
 3975 \def\internalBitem{\smallbreak \parsearg\itemzzz}
 3976 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
 3977 
 3978 \def\itemzzz #1{\begingroup %
 3979   \advance\hsize by -\rightskip
 3980   \advance\hsize by -\tableindent
 3981   \setbox0=\hbox{\itemindicate{#1}}%
 3982   \itemindex{#1}%
 3983   \nobreak % This prevents a break before @itemx.
 3984   %
 3985   % If the item text does not fit in the space we have, put it on a line
 3986   % by itself, and do not allow a page break either before or after that
 3987   % line.  We do not start a paragraph here because then if the next
 3988   % command is, e.g., @kindex, the whatsit would get put into the
 3989   % horizontal list on a line by itself, resulting in extra blank space.
 3990   \ifdim \wd0>\itemmax
 3991     %
 3992     % Make this a paragraph so we get the \parskip glue and wrapping,
 3993     % but leave it ragged-right.
 3994     \begingroup
 3995       \advance\leftskip by-\tableindent
 3996       \advance\hsize by\tableindent
 3997       \advance\rightskip by0pt plus1fil\relax
 3998       \leavevmode\unhbox0\par
 3999     \endgroup
 4000     %
 4001     % We're going to be starting a paragraph, but we don't want the
 4002     % \parskip glue -- logically it's part of the @item we just started.
 4003     \nobreak \vskip-\parskip
 4004     %
 4005     % Stop a page break at the \parskip glue coming up.  However, if
 4006     % what follows is an environment such as @example, there will be no
 4007     % \parskip glue; then the negative vskip we just inserted would
 4008     % cause the example and the item to crash together.  So we use this
 4009     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
 4010     % \parskip glue after all.  Section titles are handled this way also.
 4011     %
 4012     \penalty 10001
 4013     \endgroup
 4014     \itemxneedsnegativevskipfalse
 4015   \else
 4016     % The item text fits into the space.  Start a paragraph, so that the
 4017     % following text (if any) will end up on the same line.
 4018     \noindent
 4019     % Do this with kerns and \unhbox so that if there is a footnote in
 4020     % the item text, it can migrate to the main vertical list and
 4021     % eventually be printed.
 4022     \nobreak\kern-\tableindent
 4023     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
 4024     \unhbox0
 4025     \nobreak\kern\dimen0
 4026     \endgroup
 4027     \itemxneedsnegativevskiptrue
 4028   \fi
 4029 }
 4030 
 4031 \def\item{\errmessage{@item while not in a list environment}}
 4032 \def\itemx{\errmessage{@itemx while not in a list environment}}
 4033 
 4034 % @table, @ftable, @vtable.
 4035 \envdef\table{%
 4036   \let\itemindex\gobble
 4037   \tablecheck{table}%
 4038 }
 4039 \envdef\ftable{%
 4040   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
 4041   \tablecheck{ftable}%
 4042 }
 4043 \envdef\vtable{%
 4044   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
 4045   \tablecheck{vtable}%
 4046 }
 4047 \def\tablecheck#1{%
 4048   \ifnum \the\catcode`\^^M=\active
 4049     \endgroup
 4050     \errmessage{This command won't work in this context; perhaps the problem is
 4051       that we are \inenvironment\thisenv}%
 4052     \def\next{\doignore{#1}}%
 4053   \else
 4054     \let\next\tablex
 4055   \fi
 4056   \next
 4057 }
 4058 \def\tablex#1{%
 4059   \def\itemindicate{#1}%
 4060   \parsearg\tabley
 4061 }
 4062 \def\tabley#1{%
 4063   {%
 4064     \makevalueexpandable
 4065     \edef\temp{\noexpand\tablez #1\space\space\space}%
 4066     \expandafter
 4067   }\temp \endtablez
 4068 }
 4069 \def\tablez #1 #2 #3 #4\endtablez{%
 4070   \aboveenvbreak
 4071   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
 4072   \ifnum 0#2>0 \tableindent=#2\mil \fi
 4073   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
 4074   \itemmax=\tableindent
 4075   \advance \itemmax by -\itemmargin
 4076   \advance \leftskip by \tableindent
 4077   \exdentamount=\tableindent
 4078   \parindent = 0pt
 4079   \parskip = \smallskipamount
 4080   \ifdim \parskip=0pt \parskip=2pt \fi
 4081   \let\item = \internalBitem
 4082   \let\itemx = \internalBitemx
 4083 }
 4084 \def\Etable{\endgraf\afterenvbreak}
 4085 \let\Eftable\Etable
 4086 \let\Evtable\Etable
 4087 \let\Eitemize\Etable
 4088 \let\Eenumerate\Etable
 4089 
 4090 % This is the counter used by @enumerate, which is really @itemize
 4091 
 4092 \newcount \itemno
 4093 
 4094 \envdef\itemize{\parsearg\doitemize}
 4095 
 4096 \def\doitemize#1{%
 4097   \aboveenvbreak
 4098   \itemmax=\itemindent
 4099   \advance\itemmax by -\itemmargin
 4100   \advance\leftskip by \itemindent
 4101   \exdentamount=\itemindent
 4102   \parindent=0pt
 4103   \parskip=\smallskipamount
 4104   \ifdim\parskip=0pt \parskip=2pt \fi
 4105   %
 4106   % Try typesetting the item mark so that if the document erroneously says
 4107   % something like @itemize @samp (intending @table), there's an error
 4108   % right away at the @itemize.  It's not the best error message in the
 4109   % world, but it's better than leaving it to the @item.  This means if
 4110   % the user wants an empty mark, they have to say @w{} not just @w.
 4111   \def\itemcontents{#1}%
 4112   \setbox0 = \hbox{\itemcontents}%
 4113   %
 4114   % @itemize with no arg is equivalent to @itemize @bullet.
 4115   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
 4116   %
 4117   \let\item=\itemizeitem
 4118 }
 4119 
 4120 % Definition of @item while inside @itemize and @enumerate.
 4121 %
 4122 \def\itemizeitem{%
 4123   \advance\itemno by 1  % for enumerations
 4124   {\let\par=\endgraf \smallbreak}% reasonable place to break
 4125   {%
 4126    % If the document has an @itemize directly after a section title, a
 4127    % \nobreak will be last on the list, and \sectionheading will have
 4128    % done a \vskip-\parskip.  In that case, we don't want to zero
 4129    % parskip, or the item text will crash with the heading.  On the
 4130    % other hand, when there is normal text preceding the item (as there
 4131    % usually is), we do want to zero parskip, or there would be too much
 4132    % space.  In that case, we won't have a \nobreak before.  At least
 4133    % that's the theory.
 4134    \ifnum\lastpenalty<10000 \parskip=0in \fi
 4135    \noindent
 4136    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
 4137    %
 4138    \ifinner\else
 4139      \vadjust{\penalty 1200}% not good to break after first line of item.
 4140    \fi
 4141    % We can be in inner vertical mode in a footnote, although an
 4142    % @itemize looks awful there.
 4143   }%
 4144   \flushcr
 4145 }
 4146 
 4147 % \splitoff TOKENS\endmark defines \first to be the first token in
 4148 % TOKENS, and \rest to be the remainder.
 4149 %
 4150 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
 4151 
 4152 % Allow an optional argument of an uppercase letter, lowercase letter,
 4153 % or number, to specify the first label in the enumerated list.  No
 4154 % argument is the same as `1'.
 4155 %
 4156 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
 4157 \def\enumeratey #1 #2\endenumeratey{%
 4158   % If we were given no argument, pretend we were given `1'.
 4159   \def\thearg{#1}%
 4160   \ifx\thearg\empty \def\thearg{1}\fi
 4161   %
 4162   % Detect if the argument is a single token.  If so, it might be a
 4163   % letter.  Otherwise, the only valid thing it can be is a number.
 4164   % (We will always have one token, because of the test we just made.
 4165   % This is a good thing, since \splitoff doesn't work given nothing at
 4166   % all -- the first parameter is undelimited.)
 4167   \expandafter\splitoff\thearg\endmark
 4168   \ifx\rest\empty
 4169     % Only one token in the argument.  It could still be anything.
 4170     % A ``lowercase letter'' is one whose \lccode is nonzero.
 4171     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
 4172     %   not equal to itself.
 4173     % Otherwise, we assume it's a number.
 4174     %
 4175     % We need the \relax at the end of the \ifnum lines to stop TeX from
 4176     % continuing to look for a <number>.
 4177     %
 4178     \ifnum\lccode\expandafter`\thearg=0\relax
 4179       \numericenumerate % a number (we hope)
 4180     \else
 4181       % It's a letter.
 4182       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
 4183         \lowercaseenumerate % lowercase letter
 4184       \else
 4185         \uppercaseenumerate % uppercase letter
 4186       \fi
 4187     \fi
 4188   \else
 4189     % Multiple tokens in the argument.  We hope it's a number.
 4190     \numericenumerate
 4191   \fi
 4192 }
 4193 
 4194 % An @enumerate whose labels are integers.  The starting integer is
 4195 % given in \thearg.
 4196 %
 4197 \def\numericenumerate{%
 4198   \itemno = \thearg
 4199   \startenumeration{\the\itemno}%
 4200 }
 4201 
 4202 % The starting (lowercase) letter is in \thearg.
 4203 \def\lowercaseenumerate{%
 4204   \itemno = \expandafter`\thearg
 4205   \startenumeration{%
 4206     % Be sure we're not beyond the end of the alphabet.
 4207     \ifnum\itemno=0
 4208       \errmessage{No more lowercase letters in @enumerate; get a bigger
 4209                   alphabet}%
 4210     \fi
 4211     \char\lccode\itemno
 4212   }%
 4213 }
 4214 
 4215 % The starting (uppercase) letter is in \thearg.
 4216 \def\uppercaseenumerate{%
 4217   \itemno = \expandafter`\thearg
 4218   \startenumeration{%
 4219     % Be sure we're not beyond the end of the alphabet.
 4220     \ifnum\itemno=0
 4221       \errmessage{No more uppercase letters in @enumerate; get a bigger
 4222                   alphabet}
 4223     \fi
 4224     \char\uccode\itemno
 4225   }%
 4226 }
 4227 
 4228 % Call \doitemize, adding a period to the first argument and supplying the
 4229 % common last two arguments.  Also subtract one from the initial value in
 4230 % \itemno, since @item increments \itemno.
 4231 %
 4232 \def\startenumeration#1{%
 4233   \advance\itemno by -1
 4234   \doitemize{#1.}\flushcr
 4235 }
 4236 
 4237 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
 4238 % to @enumerate.
 4239 %
 4240 \def\alphaenumerate{\enumerate{a}}
 4241 \def\capsenumerate{\enumerate{A}}
 4242 \def\Ealphaenumerate{\Eenumerate}
 4243 \def\Ecapsenumerate{\Eenumerate}
 4244 
 4245 
 4246 % @multitable macros
 4247 % Amy Hendrickson, 8/18/94, 3/6/96
 4248 %
 4249 % @multitable ... @end multitable will make as many columns as desired.
 4250 % Contents of each column will wrap at width given in preamble.  Width
 4251 % can be specified either with sample text given in a template line,
 4252 % or in percent of \hsize, the current width of text on page.
 4253 
 4254 % Table can continue over pages but will only break between lines.
 4255 
 4256 % To make preamble:
 4257 %
 4258 % Either define widths of columns in terms of percent of \hsize:
 4259 %   @multitable @columnfractions .25 .3 .45
 4260 %   @item ...
 4261 %
 4262 %   Numbers following @columnfractions are the percent of the total
 4263 %   current hsize to be used for each column. You may use as many
 4264 %   columns as desired.
 4265 
 4266 
 4267 % Or use a template:
 4268 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
 4269 %   @item ...
 4270 %   using the widest term desired in each column.
 4271 
 4272 % Each new table line starts with @item, each subsequent new column
 4273 % starts with @tab. Empty columns may be produced by supplying @tab's
 4274 % with nothing between them for as many times as empty columns are needed,
 4275 % ie, @tab@tab@tab will produce two empty columns.
 4276 
 4277 % @item, @tab do not need to be on their own lines, but it will not hurt
 4278 % if they are.
 4279 
 4280 % Sample multitable:
 4281 
 4282 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
 4283 %   @item first col stuff @tab second col stuff @tab third col
 4284 %   @item
 4285 %   first col stuff
 4286 %   @tab
 4287 %   second col stuff
 4288 %   @tab
 4289 %   third col
 4290 %   @item first col stuff @tab second col stuff
 4291 %   @tab Many paragraphs of text may be used in any column.
 4292 %
 4293 %         They will wrap at the width determined by the template.
 4294 %   @item@tab@tab This will be in third column.
 4295 %   @end multitable
 4296 
 4297 % Default dimensions may be reset by user.
 4298 % @multitableparskip is vertical space between paragraphs in table.
 4299 % @multitableparindent is paragraph indent in table.
 4300 % @multitablecolmargin is horizontal space to be left between columns.
 4301 % @multitablelinespace is space to leave between table items, baseline
 4302 %                                                            to baseline.
 4303 %   0pt means it depends on current normal line spacing.
 4304 %
 4305 \newskip\multitableparskip
 4306 \newskip\multitableparindent
 4307 \newdimen\multitablecolspace
 4308 \newskip\multitablelinespace
 4309 \multitableparskip=0pt
 4310 \multitableparindent=6pt
 4311 \multitablecolspace=12pt
 4312 \multitablelinespace=0pt
 4313 
 4314 % Macros used to set up halign preamble:
 4315 %
 4316 \let\endsetuptable\relax
 4317 \def\xendsetuptable{\endsetuptable}
 4318 \let\columnfractions\relax
 4319 \def\xcolumnfractions{\columnfractions}
 4320 \newif\ifsetpercent
 4321 
 4322 % #1 is the @columnfraction, usually a decimal number like .5, but might
 4323 % be just 1.  We just use it, whatever it is.
 4324 %
 4325 \def\pickupwholefraction#1 {%
 4326   \global\advance\colcount by 1
 4327   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
 4328   \setuptable
 4329 }
 4330 
 4331 \newcount\colcount
 4332 \def\setuptable#1{%
 4333   \def\firstarg{#1}%
 4334   \ifx\firstarg\xendsetuptable
 4335     \let\go = \relax
 4336   \else
 4337     \ifx\firstarg\xcolumnfractions
 4338       \global\setpercenttrue
 4339     \else
 4340       \ifsetpercent
 4341          \let\go\pickupwholefraction
 4342       \else
 4343          \global\advance\colcount by 1
 4344          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
 4345                    % separator; typically that is always in the input, anyway.
 4346          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
 4347       \fi
 4348     \fi
 4349     \ifx\go\pickupwholefraction
 4350       % Put the argument back for the \pickupwholefraction call, so
 4351       % we'll always have a period there to be parsed.
 4352       \def\go{\pickupwholefraction#1}%
 4353     \else
 4354       \let\go = \setuptable
 4355     \fi%
 4356   \fi
 4357   \go
 4358 }
 4359 
 4360 % multitable-only commands.
 4361 % 
 4362 % @headitem starts a heading row, which we typeset in bold.  Assignments
 4363 % have to be global since we are inside the implicit group of an
 4364 % alignment entry.  \everycr below resets \everytab so we don't have to
 4365 % undo it ourselves.
 4366 \def\headitemfont{\b}% for people to use in the template row; not changeable
 4367 \def\headitem{%
 4368   \checkenv\multitable
 4369   \crcr
 4370   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
 4371   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
 4372   \the\everytab % for the first item
 4373 }%
 4374 %
 4375 % default for tables with no headings.
 4376 \let\headitemcrhook=\relax
 4377 %
 4378 % A \tab used to include \hskip1sp.  But then the space in a template
 4379 % line is not enough.  That is bad.  So let's go back to just `&' until
 4380 % we again encounter the problem the 1sp was intended to solve.
 4381 %                   --karl, nathan@acm.org, 20apr99.
 4382 \def\tab{\checkenv\multitable &\the\everytab}%
 4383 
 4384 % @multitable ... @end multitable definitions:
 4385 %
 4386 \newtoks\everytab  % insert after every tab.
 4387 %
 4388 \envdef\multitable{%
 4389   \vskip\parskip
 4390   \startsavinginserts
 4391   %
 4392   % @item within a multitable starts a normal row.
 4393   % We use \def instead of \let so that if one of the multitable entries
 4394   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
 4395   % \endtemplate) expanding \doitemize.
 4396   \def\item{\crcr}%
 4397   %
 4398   \tolerance=9500
 4399   \hbadness=9500
 4400   \setmultitablespacing
 4401   \parskip=\multitableparskip
 4402   \parindent=\multitableparindent
 4403   \overfullrule=0pt
 4404   \global\colcount=0
 4405   %
 4406   \everycr = {%
 4407     \noalign{%
 4408       \global\everytab={}% Reset from possible headitem.
 4409       \global\colcount=0 % Reset the column counter.
 4410       %
 4411       % Check for saved footnotes, etc.:
 4412       \checkinserts
 4413       %
 4414       % Perhaps a \nobreak, then reset:
 4415       \headitemcrhook
 4416       \global\let\headitemcrhook=\relax
 4417     }%
 4418   }%
 4419   %
 4420   \parsearg\domultitable
 4421 }
 4422 \def\domultitable#1{%
 4423   % To parse everything between @multitable and @item:
 4424   \setuptable#1 \endsetuptable
 4425   %
 4426   % This preamble sets up a generic column definition, which will
 4427   % be used as many times as user calls for columns.
 4428   % \vtop will set a single line and will also let text wrap and
 4429   % continue for many paragraphs if desired.
 4430   \halign\bgroup &%
 4431     \global\advance\colcount by 1
 4432     \multistrut
 4433     \vtop{%
 4434       % Use the current \colcount to find the correct column width:
 4435       \hsize=\expandafter\csname col\the\colcount\endcsname
 4436       %
 4437       % In order to keep entries from bumping into each other
 4438       % we will add a \leftskip of \multitablecolspace to all columns after
 4439       % the first one.
 4440       %
 4441       % If a template has been used, we will add \multitablecolspace
 4442       % to the width of each template entry.
 4443       %
 4444       % If the user has set preamble in terms of percent of \hsize we will
 4445       % use that dimension as the width of the column, and the \leftskip
 4446       % will keep entries from bumping into each other.  Table will start at
 4447       % left margin and final column will justify at right margin.
 4448       %
 4449       % Make sure we don't inherit \rightskip from the outer environment.
 4450       \rightskip=0pt
 4451       \ifnum\colcount=1
 4452     % The first column will be indented with the surrounding text.
 4453     \advance\hsize by\leftskip
 4454       \else
 4455     \ifsetpercent \else
 4456       % If user has not set preamble in terms of percent of \hsize
 4457       % we will advance \hsize by \multitablecolspace.
 4458       \advance\hsize by \multitablecolspace
 4459     \fi
 4460        % In either case we will make \leftskip=\multitablecolspace:
 4461       \leftskip=\multitablecolspace
 4462       \fi
 4463       % Ignoring space at the beginning and end avoids an occasional spurious
 4464       % blank line, when TeX decides to break the line at the space before the
 4465       % box from the multistrut, so the strut ends up on a line by itself.
 4466       % For example:
 4467       % @multitable @columnfractions .11 .89
 4468       % @item @code{#}
 4469       % @tab Legal holiday which is valid in major parts of the whole country.
 4470       % Is automatically provided with highlighting sequences respectively
 4471       % marking characters.
 4472       \noindent\ignorespaces##\unskip\multistrut
 4473     }\cr
 4474 }
 4475 \def\Emultitable{%
 4476   \crcr
 4477   \egroup % end the \halign
 4478   \global\setpercentfalse
 4479 }
 4480 
 4481 \def\setmultitablespacing{%
 4482   \def\multistrut{\strut}% just use the standard line spacing
 4483   %
 4484   % Compute \multitablelinespace (if not defined by user) for use in
 4485   % \multitableparskip calculation.  We used define \multistrut based on
 4486   % this, but (ironically) that caused the spacing to be off.
 4487   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
 4488 \ifdim\multitablelinespace=0pt
 4489 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
 4490 \global\advance\multitablelinespace by-\ht0
 4491 \fi
 4492 % Test to see if parskip is larger than space between lines of
 4493 % table. If not, do nothing.
 4494 %        If so, set to same dimension as multitablelinespace.
 4495 \ifdim\multitableparskip>\multitablelinespace
 4496 \global\multitableparskip=\multitablelinespace
 4497 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
 4498                                       % than skip between lines in the table.
 4499 \fi%
 4500 \ifdim\multitableparskip=0pt
 4501 \global\multitableparskip=\multitablelinespace
 4502 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
 4503                                       % than skip between lines in the table.
 4504 \fi}
 4505 
 4506 
 4507 \message{conditionals,}
 4508 
 4509 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
 4510 % @ifnotxml always succeed.  They currently do nothing; we don't
 4511 % attempt to check whether the conditionals are properly nested.  But we
 4512 % have to remember that they are conditionals, so that @end doesn't
 4513 % attempt to close an environment group.
 4514 %
 4515 \def\makecond#1{%
 4516   \expandafter\let\csname #1\endcsname = \relax
 4517   \expandafter\let\csname iscond.#1\endcsname = 1
 4518 }
 4519 \makecond{iftex}
 4520 \makecond{ifnotdocbook}
 4521 \makecond{ifnothtml}
 4522 \makecond{ifnotinfo}
 4523 \makecond{ifnotplaintext}
 4524 \makecond{ifnotxml}
 4525 
 4526 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
 4527 %
 4528 \def\direntry{\doignore{direntry}}
 4529 \def\documentdescription{\doignore{documentdescription}}
 4530 \def\docbook{\doignore{docbook}}
 4531 \def\html{\doignore{html}}
 4532 \def\ifdocbook{\doignore{ifdocbook}}
 4533 \def\ifhtml{\doignore{ifhtml}}
 4534 \def\ifinfo{\doignore{ifinfo}}
 4535 \def\ifnottex{\doignore{ifnottex}}
 4536 \def\ifplaintext{\doignore{ifplaintext}}
 4537 \def\ifxml{\doignore{ifxml}}
 4538 \def\ignore{\doignore{ignore}}
 4539 \def\menu{\doignore{menu}}
 4540 \def\xml{\doignore{xml}}
 4541 
 4542 % Ignore text until a line `@end #1', keeping track of nested conditionals.
 4543 %
 4544 % A count to remember the depth of nesting.
 4545 \newcount\doignorecount
 4546 
 4547 \def\doignore#1{\begingroup
 4548   % Scan in ``verbatim'' mode:
 4549   \obeylines
 4550   \catcode`\@ = \other
 4551   \catcode`\{ = \other
 4552   \catcode`\} = \other
 4553   %
 4554   % Make sure that spaces turn into tokens that match what \doignoretext wants.
 4555   \spaceisspace
 4556   %
 4557   % Count number of #1's that we've seen.
 4558   \doignorecount = 0
 4559   %
 4560   % Swallow text until we reach the matching `@end #1'.
 4561   \dodoignore{#1}%
 4562 }
 4563 
 4564 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
 4565   \obeylines %
 4566   %
 4567   \gdef\dodoignore#1{%
 4568     % #1 contains the command name as a string, e.g., `ifinfo'.
 4569     %
 4570     % Define a command to find the next `@end #1'.
 4571     \long\def\doignoretext##1^^M@end #1{%
 4572       \doignoretextyyy##1^^M@#1\_STOP_}%
 4573     %
 4574     % And this command to find another #1 command, at the beginning of a
 4575     % line.  (Otherwise, we would consider a line `@c @ifset', for
 4576     % example, to count as an @ifset for nesting.)
 4577     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
 4578     %
 4579     % And now expand that command.
 4580     \doignoretext ^^M%
 4581   }%
 4582 }
 4583 
 4584 \def\doignoreyyy#1{%
 4585   \def\temp{#1}%
 4586   \ifx\temp\empty           % Nothing found.
 4587     \let\next\doignoretextzzz
 4588   \else                 % Found a nested condition, ...
 4589     \advance\doignorecount by 1
 4590     \let\next\doignoretextyyy       % ..., look for another.
 4591     % If we're here, #1 ends with ^^M\ifinfo (for example).
 4592   \fi
 4593   \next #1% the token \_STOP_ is present just after this macro.
 4594 }
 4595 
 4596 % We have to swallow the remaining "\_STOP_".
 4597 %
 4598 \def\doignoretextzzz#1{%
 4599   \ifnum\doignorecount = 0  % We have just found the outermost @end.
 4600     \let\next\enddoignore
 4601   \else             % Still inside a nested condition.
 4602     \advance\doignorecount by -1
 4603     \let\next\doignoretext      % Look for the next @end.
 4604   \fi
 4605   \next
 4606 }
 4607 
 4608 % Finish off ignored text.
 4609 { \obeylines%
 4610   % Ignore anything after the last `@end #1'; this matters in verbatim
 4611   % environments, where otherwise the newline after an ignored conditional
 4612   % would result in a blank line in the output.
 4613   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
 4614 }
 4615 
 4616 
 4617 % @set VAR sets the variable VAR to an empty value.
 4618 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
 4619 %
 4620 % Since we want to separate VAR from REST-OF-LINE (which might be
 4621 % empty), we can't just use \parsearg; we have to insert a space of our
 4622 % own to delimit the rest of the line, and then take it out again if we
 4623 % didn't need it.
 4624 % We rely on the fact that \parsearg sets \catcode`\ =10.
 4625 %
 4626 \parseargdef\set{\setyyy#1 \endsetyyy}
 4627 \def\setyyy#1 #2\endsetyyy{%
 4628   {%
 4629     \makevalueexpandable
 4630     \def\temp{#2}%
 4631     \edef\next{\gdef\makecsname{SET#1}}%
 4632     \ifx\temp\empty
 4633       \next{}%
 4634     \else
 4635       \setzzz#2\endsetzzz
 4636     \fi
 4637   }%
 4638 }
 4639 % Remove the trailing space \setxxx inserted.
 4640 \def\setzzz#1 \endsetzzz{\next{#1}}
 4641 
 4642 % @clear VAR clears (i.e., unsets) the variable VAR.
 4643 %
 4644 \parseargdef\clear{%
 4645   {%
 4646     \makevalueexpandable
 4647     \global\expandafter\let\csname SET#1\endcsname=\relax
 4648   }%
 4649 }
 4650 
 4651 % @value{foo} gets the text saved in variable foo.
 4652 \def\value{\begingroup\makevalueexpandable\valuexxx}
 4653 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
 4654 {
 4655   \catcode`\-=\active \catcode`\_=\active
 4656   %
 4657   \gdef\makevalueexpandable{%
 4658     \let\value = \expandablevalue
 4659     % We don't want these characters active, ...
 4660     \catcode`\-=\other \catcode`\_=\other
 4661     % ..., but we might end up with active ones in the argument if
 4662     % we're called from @code, as @code{@value{foo-bar_}}, though.
 4663     % So \let them to their normal equivalents.
 4664     \let-\normaldash \let_\normalunderscore
 4665   }
 4666 }
 4667 
 4668 % We have this subroutine so that we can handle at least some @value's
 4669 % properly in indexes (we call \makevalueexpandable in \indexdummies).
 4670 % The command has to be fully expandable (if the variable is set), since
 4671 % the result winds up in the index file.  This means that if the
 4672 % variable's value contains other Texinfo commands, it's almost certain
 4673 % it will fail (although perhaps we could fix that with sufficient work
 4674 % to do a one-level expansion on the result, instead of complete).
 4675 % 
 4676 % Unfortunately, this has the consequence that when _ is in the *value*
 4677 % of an @set, it does not print properly in the roman fonts (get the cmr
 4678 % dot accent at position 126 instead).  No fix comes to mind, and it's
 4679 % been this way since 2003 or earlier, so just ignore it.
 4680 % 
 4681 \def\expandablevalue#1{%
 4682   \expandafter\ifx\csname SET#1\endcsname\relax
 4683     {[No value for ``#1'']}%
 4684     \message{Variable `#1', used in @value, is not set.}%
 4685   \else
 4686     \csname SET#1\endcsname
 4687   \fi
 4688 }
 4689 
 4690 % Like \expandablevalue, but completely expandable (the \message in the
 4691 % definition above operates at the execution level of TeX).  Used when
 4692 % writing to auxiliary files, due to the expansion that \write does.
 4693 % If flag is undefined, pass through an unexpanded @value command: maybe it 
 4694 % will be set by the time it is read back in.
 4695 %
 4696 % NB flag names containing - or _ may not work here.
 4697 \def\dummyvalue#1{%
 4698   \expandafter\ifx\csname SET#1\endcsname\relax
 4699     \noexpand\value{#1}%
 4700   \else
 4701     \csname SET#1\endcsname
 4702   \fi
 4703 }
 4704 
 4705 % Used for @value's in index entries to form the sort key: expand the @value
 4706 % if possible, otherwise sort late.
 4707 \def\indexnofontsvalue#1{%
 4708   \expandafter\ifx\csname SET#1\endcsname\relax
 4709     ZZZZZZZ
 4710   \else
 4711     \csname SET#1\endcsname
 4712   \fi
 4713 }
 4714 
 4715 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
 4716 % with @set.
 4717 % 
 4718 % To get the special treatment we need for `@end ifset,' we call
 4719 % \makecond and then redefine.
 4720 %
 4721 \makecond{ifset}
 4722 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
 4723 \def\doifset#1#2{%
 4724   {%
 4725     \makevalueexpandable
 4726     \let\next=\empty
 4727     \expandafter\ifx\csname SET#2\endcsname\relax
 4728       #1% If not set, redefine \next.
 4729     \fi
 4730     \expandafter
 4731   }\next
 4732 }
 4733 \def\ifsetfail{\doignore{ifset}}
 4734 
 4735 % @ifclear VAR ... @end executes the `...' iff VAR has never been
 4736 % defined with @set, or has been undefined with @clear.
 4737 %
 4738 % The `\else' inside the `\doifset' parameter is a trick to reuse the
 4739 % above code: if the variable is not set, do nothing, if it is set,
 4740 % then redefine \next to \ifclearfail.
 4741 %
 4742 \makecond{ifclear}
 4743 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
 4744 \def\ifclearfail{\doignore{ifclear}}
 4745 
 4746 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
 4747 % without the @) is in fact defined.  We can only feasibly check at the
 4748 % TeX level, so something like `mathcode' is going to considered
 4749 % defined even though it is not a Texinfo command.
 4750 % 
 4751 \makecond{ifcommanddefined}
 4752 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
 4753 %
 4754 \def\doifcmddefined#1#2{{%
 4755     \makevalueexpandable
 4756     \let\next=\empty
 4757     \expandafter\ifx\csname #2\endcsname\relax
 4758       #1% If not defined, \let\next as above.
 4759     \fi
 4760     \expandafter
 4761   }\next
 4762 }
 4763 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
 4764 
 4765 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
 4766 \makecond{ifcommandnotdefined}
 4767 \def\ifcommandnotdefined{%
 4768   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
 4769 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
 4770 
 4771 % Set the `txicommandconditionals' variable, so documents have a way to
 4772 % test if the @ifcommand...defined conditionals are available.
 4773 \set txicommandconditionals
 4774 
 4775 % @dircategory CATEGORY  -- specify a category of the dir file
 4776 % which this file should belong to.  Ignore this in TeX.
 4777 \let\dircategory=\comment
 4778 
 4779 % @defininfoenclose.
 4780 \let\definfoenclose=\comment
 4781 
 4782 
 4783 \message{indexing,}
 4784 % Index generation facilities
 4785 
 4786 % Define \newwrite to be identical to plain tex's \newwrite
 4787 % except not \outer, so it can be used within macros and \if's.
 4788 \edef\newwrite{\makecsname{ptexnewwrite}}
 4789 
 4790 % \newindex {foo} defines an index named IX.
 4791 % It automatically defines \IXindex such that
 4792 % \IXindex ...rest of line... puts an entry in the index IX.
 4793 % It also defines \IXindfile to be the number of the output channel for
 4794 % the file that accumulates this index.  The file's extension is IX.
 4795 % The name of an index should be no more than 2 characters long
 4796 % for the sake of vms.
 4797 %
 4798 \def\newindex#1{%
 4799   \expandafter\chardef\csname#1indfile\endcsname=0
 4800   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
 4801     \noexpand\doindex{#1}}
 4802 }
 4803 
 4804 % @defindex foo  ==  \newindex{foo}
 4805 %
 4806 \def\defindex{\parsearg\newindex}
 4807 
 4808 % Define @defcodeindex, like @defindex except put all entries in @code.
 4809 %
 4810 \def\defcodeindex{\parsearg\newcodeindex}
 4811 %
 4812 \def\newcodeindex#1{%
 4813   \expandafter\chardef\csname#1indfile\endcsname=0
 4814   \expandafter\xdef\csname#1index\endcsname{%
 4815     \noexpand\docodeindex{#1}}%
 4816 }
 4817 
 4818 % The default indices:
 4819 \newindex{cp}%      concepts,
 4820 \newcodeindex{fn}%  functions,
 4821 \newcodeindex{vr}%  variables,
 4822 \newcodeindex{tp}%  types,
 4823 \newcodeindex{ky}%  keys
 4824 \newcodeindex{pg}%  and programs.
 4825 
 4826 
 4827 % @synindex foo bar    makes index foo feed into index bar.
 4828 % Do this instead of @defindex foo if you don't want it as a separate index.
 4829 %
 4830 % @syncodeindex foo bar   similar, but put all entries made for index foo
 4831 % inside @code.
 4832 %
 4833 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
 4834 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
 4835 
 4836 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
 4837 % #3 the target index (bar).
 4838 \def\dosynindex#1#2#3{%
 4839   \requireopenindexfile{#3}%
 4840   % redefine \fooindfile:
 4841   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
 4842   \expandafter\let\csname#2indfile\endcsname=\temp
 4843   % redefine \fooindex:
 4844   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
 4845 }
 4846 
 4847 % Define \doindex, the driver for all index macros.
 4848 % Argument #1 is generated by the calling \fooindex macro,
 4849 % and it is the two-letter name of the index.
 4850 
 4851 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
 4852 \def\doindexxxx #1{\doind{\indexname}{#1}}
 4853 
 4854 % like the previous two, but they put @code around the argument.
 4855 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
 4856 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
 4857 
 4858 
 4859 % Used when writing an index entry out to an index file to prevent
 4860 % expansion of Texinfo commands that can appear in an index entry.
 4861 %
 4862 \def\indexdummies{%
 4863   \escapechar = `\\     % use backslash in output files.
 4864   \definedummyletter\@%
 4865   \definedummyletter\ %
 4866   %
 4867   % For texindex which always views { and } as separators.
 4868   \def\{{\lbracechar{}}%
 4869   \def\}{\rbracechar{}}%
 4870   %
 4871   % Do the redefinitions.
 4872   \definedummies
 4873 }
 4874 
 4875 % Used for the aux and toc files, where @ is the escape character.
 4876 %
 4877 \def\atdummies{%
 4878   \definedummyletter\@%
 4879   \definedummyletter\ %
 4880   \definedummyletter\{%
 4881   \definedummyletter\}%
 4882   %
 4883   % Do the redefinitions.
 4884   \definedummies
 4885   \otherbackslash
 4886 }
 4887 
 4888 % \definedummyword defines \#1 as \string\#1\space, thus effectively
 4889 % preventing its expansion.  This is used only for control words,
 4890 % not control letters, because the \space would be incorrect for
 4891 % control characters, but is needed to separate the control word
 4892 % from whatever follows.
 4893 %
 4894 % These can be used both for control words that take an argument and
 4895 % those that do not.  If it is followed by {arg} in the input, then
 4896 % that will dutifully get written to the index (or wherever).
 4897 %
 4898 % For control letters, we have \definedummyletter, which omits the
 4899 % space.
 4900 %
 4901 \def\definedummyword  #1{\def#1{\string#1\space}}%
 4902 \def\definedummyletter#1{\def#1{\string#1}}%
 4903 \let\definedummyaccent\definedummyletter
 4904 
 4905 % Called from \indexdummies and \atdummies, to effectively prevent
 4906 % the expansion of commands.
 4907 %
 4908 \def\definedummies{%
 4909   %
 4910   \let\commondummyword\definedummyword
 4911   \let\commondummyletter\definedummyletter
 4912   \let\commondummyaccent\definedummyaccent
 4913   \commondummiesnofonts
 4914   %
 4915   \definedummyletter\_%
 4916   \definedummyletter\-%
 4917   %
 4918   % Non-English letters.
 4919   \definedummyword\AA
 4920   \definedummyword\AE
 4921   \definedummyword\DH
 4922   \definedummyword\L
 4923   \definedummyword\O
 4924   \definedummyword\OE
 4925   \definedummyword\TH
 4926   \definedummyword\aa
 4927   \definedummyword\ae
 4928   \definedummyword\dh
 4929   \definedummyword\exclamdown
 4930   \definedummyword\l
 4931   \definedummyword\o
 4932   \definedummyword\oe
 4933   \definedummyword\ordf
 4934   \definedummyword\ordm
 4935   \definedummyword\questiondown
 4936   \definedummyword\ss
 4937   \definedummyword\th
 4938   %
 4939   % Although these internal commands shouldn't show up, sometimes they do.
 4940   \definedummyword\bf
 4941   \definedummyword\gtr
 4942   \definedummyword\hat
 4943   \definedummyword\less
 4944   \definedummyword\sf
 4945   \definedummyword\sl
 4946   \definedummyword\tclose
 4947   \definedummyword\tt
 4948   %
 4949   \definedummyword\LaTeX
 4950   \definedummyword\TeX
 4951   %
 4952   % Assorted special characters.
 4953   \definedummyword\atchar
 4954   \definedummyword\arrow
 4955   \definedummyword\bullet
 4956   \definedummyword\comma
 4957   \definedummyword\copyright
 4958   \definedummyword\registeredsymbol
 4959   \definedummyword\dots
 4960   \definedummyword\enddots
 4961   \definedummyword\entrybreak
 4962   \definedummyword\equiv
 4963   \definedummyword\error
 4964   \definedummyword\euro
 4965   \definedummyword\expansion
 4966   \definedummyword\geq
 4967   \definedummyword\guillemetleft
 4968   \definedummyword\guillemetright
 4969   \definedummyword\guilsinglleft
 4970   \definedummyword\guilsinglright
 4971   \definedummyword\lbracechar
 4972   \definedummyword\leq
 4973   \definedummyword\mathopsup
 4974   \definedummyword\minus
 4975   \definedummyword\ogonek
 4976   \definedummyword\pounds
 4977   \definedummyword\point
 4978   \definedummyword\print
 4979   \definedummyword\quotedblbase
 4980   \definedummyword\quotedblleft
 4981   \definedummyword\quotedblright
 4982   \definedummyword\quoteleft
 4983   \definedummyword\quoteright
 4984   \definedummyword\quotesinglbase
 4985   \definedummyword\rbracechar
 4986   \definedummyword\result
 4987   \definedummyword\sub
 4988   \definedummyword\sup
 4989   \definedummyword\textdegree
 4990   %
 4991   % We want to disable all macros so that they are not expanded by \write.
 4992   \macrolist
 4993   \let\value\dummyvalue
 4994   %
 4995   \normalturnoffactive
 4996 }
 4997 
 4998 % \commondummiesnofonts: common to \definedummies and \indexnofonts.
 4999 % Define \commondummyletter, \commondummyaccent and \commondummyword before
 5000 % using.  Used for accents, font commands, and various control letters.
 5001 %
 5002 \def\commondummiesnofonts{%
 5003   % Control letters and accents.
 5004   \commondummyletter\!%
 5005   \commondummyaccent\"%
 5006   \commondummyaccent\'%
 5007   \commondummyletter\*%
 5008   \commondummyaccent\,%
 5009   \commondummyletter\.%
 5010   \commondummyletter\/%
 5011   \commondummyletter\:%
 5012   \commondummyaccent\=%
 5013   \commondummyletter\?%
 5014   \commondummyaccent\^%
 5015   \commondummyaccent\`%
 5016   \commondummyaccent\~%
 5017   \commondummyword\u
 5018   \commondummyword\v
 5019   \commondummyword\H
 5020   \commondummyword\dotaccent
 5021   \commondummyword\ogonek
 5022   \commondummyword\ringaccent
 5023   \commondummyword\tieaccent
 5024   \commondummyword\ubaraccent
 5025   \commondummyword\udotaccent
 5026   \commondummyword\dotless
 5027   %
 5028   % Texinfo font commands.
 5029   \commondummyword\b
 5030   \commondummyword\i
 5031   \commondummyword\r
 5032   \commondummyword\sansserif
 5033   \commondummyword\sc
 5034   \commondummyword\slanted
 5035   \commondummyword\t
 5036   %
 5037   % Commands that take arguments.
 5038   \commondummyword\abbr
 5039   \commondummyword\acronym
 5040   \commondummyword\anchor
 5041   \commondummyword\cite
 5042   \commondummyword\code
 5043   \commondummyword\command
 5044   \commondummyword\dfn
 5045   \commondummyword\dmn
 5046   \commondummyword\email
 5047   \commondummyword\emph
 5048   \commondummyword\env
 5049   \commondummyword\file
 5050   \commondummyword\image
 5051   \commondummyword\indicateurl
 5052   \commondummyword\inforef
 5053   \commondummyword\kbd
 5054   \commondummyword\key
 5055   \commondummyword\math
 5056   \commondummyword\option
 5057   \commondummyword\pxref
 5058   \commondummyword\ref
 5059   \commondummyword\samp
 5060   \commondummyword\strong
 5061   \commondummyword\tie
 5062   \commondummyword\U
 5063   \commondummyword\uref
 5064   \commondummyword\url
 5065   \commondummyword\var
 5066   \commondummyword\verb
 5067   \commondummyword\w
 5068   \commondummyword\xref
 5069 }
 5070 
 5071 % For testing: output @{ and @} in index sort strings as \{ and \}.
 5072 \newif\ifusebracesinindexes
 5073 
 5074 \let\indexlbrace\relax
 5075 \let\indexrbrace\relax
 5076 
 5077 {\catcode`\@=0
 5078 \catcode`\\=13
 5079   @gdef@backslashdisappear{@def\{}}
 5080 }
 5081 
 5082 {
 5083 \catcode`\<=13
 5084 \catcode`\-=13
 5085 \catcode`\`=13
 5086   \gdef\indexnonalnumdisappear{%
 5087     \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
 5088       % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
 5089       % (Introduced for FSFS 2nd ed.)
 5090       \let`=\empty
 5091     \fi
 5092     %
 5093     \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
 5094       \backslashdisappear
 5095     \fi
 5096     %
 5097     \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
 5098       \def-{}%
 5099     \fi
 5100     \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
 5101       \def<{}%
 5102     \fi
 5103     \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
 5104       \def\@{}%
 5105     \fi
 5106   }
 5107 
 5108   \gdef\indexnonalnumreappear{%
 5109     \useindexbackslash
 5110     \let-\normaldash
 5111     \let<\normalless
 5112     \def\@{@}%
 5113   }
 5114 }
 5115 
 5116 
 5117 % \indexnofonts is used when outputting the strings to sort the index
 5118 % by, and when constructing control sequence names.  It eliminates all
 5119 % control sequences and just writes whatever the best ASCII sort string
 5120 % would be for a given command (usually its argument).
 5121 %
 5122 \def\indexnofonts{%
 5123   % Accent commands should become @asis.
 5124   \def\commondummyaccent##1{\let##1\asis}%
 5125   % We can just ignore other control letters.
 5126   \def\commondummyletter##1{\let##1\empty}%
 5127   % All control words become @asis by default; overrides below.
 5128   \let\commondummyword\commondummyaccent
 5129   \commondummiesnofonts
 5130   %
 5131   % Don't no-op \tt, since it isn't a user-level command
 5132   % and is used in the definitions of the active chars like <, >, |, etc.
 5133   % Likewise with the other plain tex font commands.
 5134   %\let\tt=\asis
 5135   %
 5136   \def\ { }%
 5137   \def\@{@}%
 5138   \def\_{\normalunderscore}%
 5139   \def\-{}% @- shouldn't affect sorting
 5140   %
 5141   \uccode`\1=`\{ \uppercase{\def\{{1}}%
 5142   \uccode`\1=`\} \uppercase{\def\}{1}}%
 5143   \let\lbracechar\{%
 5144   \let\rbracechar\}%
 5145   %
 5146   % Non-English letters.
 5147   \def\AA{AA}%
 5148   \def\AE{AE}%
 5149   \def\DH{DZZ}%
 5150   \def\L{L}%
 5151   \def\OE{OE}%
 5152   \def\O{O}%
 5153   \def\TH{TH}%
 5154   \def\aa{aa}%
 5155   \def\ae{ae}%
 5156   \def\dh{dzz}%
 5157   \def\exclamdown{!}%
 5158   \def\l{l}%
 5159   \def\oe{oe}%
 5160   \def\ordf{a}%
 5161   \def\ordm{o}%
 5162   \def\o{o}%
 5163   \def\questiondown{?}%
 5164   \def\ss{ss}%
 5165   \def\th{th}%
 5166   %
 5167   \def\LaTeX{LaTeX}%
 5168   \def\TeX{TeX}%
 5169   %
 5170   % Assorted special characters.  \defglyph gives the control sequence a
 5171   % definition that removes the {} that follows its use.
 5172   \defglyph\atchar{@}%
 5173   \defglyph\arrow{->}%
 5174   \defglyph\bullet{bullet}%
 5175   \defglyph\comma{,}%
 5176   \defglyph\copyright{copyright}%
 5177   \defglyph\dots{...}%
 5178   \defglyph\enddots{...}%
 5179   \defglyph\equiv{==}%
 5180   \defglyph\error{error}%
 5181   \defglyph\euro{euro}%
 5182   \defglyph\expansion{==>}%
 5183   \defglyph\geq{>=}%
 5184   \defglyph\guillemetleft{<<}%
 5185   \defglyph\guillemetright{>>}%
 5186   \defglyph\guilsinglleft{<}%
 5187   \defglyph\guilsinglright{>}%
 5188   \defglyph\leq{<=}%
 5189   \defglyph\lbracechar{\{}%
 5190   \defglyph\minus{-}%
 5191   \defglyph\point{.}%
 5192   \defglyph\pounds{pounds}%
 5193   \defglyph\print{-|}%
 5194   \defglyph\quotedblbase{"}%
 5195   \defglyph\quotedblleft{"}%
 5196   \defglyph\quotedblright{"}%
 5197   \defglyph\quoteleft{`}%
 5198   \defglyph\quoteright{'}%
 5199   \defglyph\quotesinglbase{,}%
 5200   \defglyph\rbracechar{\}}%
 5201   \defglyph\registeredsymbol{R}%
 5202   \defglyph\result{=>}%
 5203   \defglyph\textdegree{o}%
 5204   %
 5205   % We need to get rid of all macros, leaving only the arguments (if present).
 5206   % Of course this is not nearly correct, but it is the best we can do for now.
 5207   % makeinfo does not expand macros in the argument to @deffn, which ends up
 5208   % writing an index entry, and texindex isn't prepared for an index sort entry
 5209   % that starts with \.
 5210   %
 5211   % Since macro invocations are followed by braces, we can just redefine them
 5212   % to take a single TeX argument.  The case of a macro invocation that
 5213   % goes to end-of-line is not handled.
 5214   %
 5215   \macrolist
 5216   \let\value\indexnofontsvalue
 5217 }
 5218 \def\defglyph#1#2{\def#1##1{#2}} % see above
 5219 
 5220 
 5221 
 5222 
 5223 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
 5224 
 5225 % Most index entries go through here, but \dosubind is the general case.
 5226 % #1 is the index name, #2 is the entry text.
 5227 \def\doind#1#2{\dosubind{#1}{#2}{}}
 5228 
 5229 % There is also \dosubind {index}{topic}{subtopic}
 5230 % which makes an entry in a two-level index such as the operation index.
 5231 % TODO: Two-level index?  Operation index?
 5232 
 5233 % Workhorse for all indexes.
 5234 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
 5235 % empty if called from \doind, as we usually are (the main exception
 5236 % is with most defuns, which call us directly).
 5237 %
 5238 \def\dosubind#1#2#3{%
 5239   \iflinks
 5240   {%
 5241     \requireopenindexfile{#1}%
 5242     % Store the main index entry text (including the third arg).
 5243     \toks0 = {#2}%
 5244     % If third arg is present, precede it with a space.
 5245     \def\thirdarg{#3}%
 5246     \ifx\thirdarg\empty \else
 5247       \toks0 = \expandafter{\the\toks0 \space #3}%
 5248     \fi
 5249     %
 5250     \edef\writeto{\csname#1indfile\endcsname}%
 5251     %
 5252     \safewhatsit\dosubindwrite
 5253   }%
 5254   \fi
 5255 }
 5256 
 5257 % Check if an index file has been opened, and if not, open it.
 5258 \def\requireopenindexfile#1{%
 5259 \ifnum\csname #1indfile\endcsname=0
 5260   \expandafter\newwrite \csname#1indfile\endcsname
 5261   \edef\suffix{#1}%
 5262   % A .fls suffix would conflict with the file extension for the output
 5263   % of -recorder, so use .f1s instead.
 5264   \ifx\suffix\indexisfl\def\suffix{f1}\fi
 5265   % Open the file
 5266   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
 5267   % Using \immediate above here prevents an object entering into the current 
 5268   % box, which could confound checks such as those in \safewhatsit for
 5269   % preceding skips.
 5270   \typeout{Writing index file \jobname.\suffix}%
 5271 \fi}
 5272 \def\indexisfl{fl}
 5273 
 5274 % Output \ as {\indexbackslash}, because \ is an escape character in
 5275 % the index files.
 5276 \let\indexbackslash=\relax
 5277 {\catcode`\@=0 \catcode`\\=\active
 5278   @gdef@useindexbackslash{@def\{{@indexbackslash}}}
 5279 }
 5280 
 5281 % Definition for writing index entry text.
 5282 \def\sortas#1{\ignorespaces}%
 5283 
 5284 % Definition for writing index entry sort key.  Should occur at the at
 5285 % the beginning of the index entry, like
 5286 %     @cindex @sortas{september} \september
 5287 % The \ignorespaces takes care of following space, but there's no way
 5288 % to remove space before it.
 5289 {
 5290 \catcode`\-=13
 5291 \gdef\indexwritesortas{%
 5292   \begingroup
 5293   \indexnonalnumreappear
 5294   \indexwritesortasxxx}
 5295 \gdef\indexwritesortasxxx#1{%
 5296   \xdef\indexsortkey{#1}\endgroup}
 5297 }
 5298 
 5299 
 5300 % Write the entry in \toks0 to the index file.
 5301 %
 5302 \def\dosubindwrite{%
 5303   % Put the index entry in the margin if desired.
 5304   \ifx\SETmarginindex\relax\else
 5305     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
 5306   \fi
 5307   %
 5308   % Remember, we are within a group.
 5309   \indexdummies % Must do this here, since \bf, etc expand at this stage
 5310   \useindexbackslash % \indexbackslash isn't defined now so it will be output 
 5311                      % as is; and it will print as backslash.
 5312   % The braces around \indexbrace are recognized by texindex.
 5313   %
 5314   % Get the string to sort by, by processing the index entry with all
 5315   % font commands turned off.
 5316   {\indexnofonts
 5317    \def\lbracechar{{\indexlbrace}}%
 5318    \def\rbracechar{{\indexrbrace}}%
 5319    \let\{=\lbracechar
 5320    \let\}=\rbracechar
 5321    \indexnonalnumdisappear
 5322    \xdef\indexsortkey{}%
 5323    \let\sortas=\indexwritesortas
 5324    \edef\temp{\the\toks0}%
 5325    \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
 5326    \ifx\indexsortkey\empty
 5327      \xdef\indexsortkey{\temp}%
 5328      \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
 5329    \fi
 5330   }%
 5331   %
 5332   % Set up the complete index entry, with both the sort key and
 5333   % the original text, including any font commands.  We write
 5334   % three arguments to \entry to the .?? file (four in the
 5335   % subentry case), texindex reduces to two when writing the .??s
 5336   % sorted result.
 5337   \edef\temp{%
 5338     \write\writeto{%
 5339       \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
 5340   }%
 5341   \temp
 5342 }
 5343 \newbox\dummybox % used above
 5344 
 5345 % Take care of unwanted page breaks/skips around a whatsit:
 5346 %
 5347 % If a skip is the last thing on the list now, preserve it
 5348 % by backing up by \lastskip, doing the \write, then inserting
 5349 % the skip again.  Otherwise, the whatsit generated by the
 5350 % \write or \pdfdest will make \lastskip zero.  The result is that
 5351 % sequences like this:
 5352 % @end defun
 5353 % @tindex whatever
 5354 % @defun ...
 5355 % will have extra space inserted, because the \medbreak in the
 5356 % start of the @defun won't see the skip inserted by the @end of
 5357 % the previous defun.
 5358 %
 5359 % But don't do any of this if we're not in vertical mode.  We
 5360 % don't want to do a \vskip and prematurely end a paragraph.
 5361 %
 5362 % Avoid page breaks due to these extra skips, too.
 5363 %
 5364 % But wait, there is a catch there:
 5365 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
 5366 % sufficient for this purpose, as it ignores stretch and shrink parts
 5367 % of the skip.  The only way seems to be to check the textual
 5368 % representation of the skip.
 5369 %
 5370 % The following is almost like \def\zeroskipmacro{0.0pt} except that
 5371 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
 5372 %
 5373 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
 5374 %
 5375 \newskip\whatsitskip
 5376 \newcount\whatsitpenalty
 5377 %
 5378 % ..., ready, GO:
 5379 %
 5380 \def\safewhatsit#1{\ifhmode
 5381   #1%
 5382  \else
 5383   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
 5384   \whatsitskip = \lastskip
 5385   \edef\lastskipmacro{\the\lastskip}%
 5386   \whatsitpenalty = \lastpenalty
 5387   %
 5388   % If \lastskip is nonzero, that means the last item was a
 5389   % skip.  And since a skip is discardable, that means this
 5390   % -\whatsitskip glue we're inserting is preceded by a
 5391   % non-discardable item, therefore it is not a potential
 5392   % breakpoint, therefore no \nobreak needed.
 5393   \ifx\lastskipmacro\zeroskipmacro
 5394   \else
 5395     \vskip-\whatsitskip
 5396   \fi
 5397   %
 5398   #1%
 5399   %
 5400   \ifx\lastskipmacro\zeroskipmacro
 5401     % If \lastskip was zero, perhaps the last item was a penalty, and
 5402     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
 5403     % to re-insert the same penalty (values >10000 are used for various
 5404     % signals); since we just inserted a non-discardable item, any
 5405     % following glue (such as a \parskip) would be a breakpoint.  For example:
 5406     %   @deffn deffn-whatever
 5407     %   @vindex index-whatever
 5408     %   Description.
 5409     % would allow a break between the index-whatever whatsit
 5410     % and the "Description." paragraph.
 5411     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
 5412   \else
 5413     % On the other hand, if we had a nonzero \lastskip,
 5414     % this make-up glue would be preceded by a non-discardable item
 5415     % (the whatsit from the \write), so we must insert a \nobreak.
 5416     \nobreak\vskip\whatsitskip
 5417   \fi
 5418 \fi}
 5419 
 5420 % The index entry written in the file actually looks like
 5421 %  \entry {sortstring}{page}{topic}
 5422 % or
 5423 %  \entry {sortstring}{page}{topic}{subtopic}
 5424 % The texindex program reads in these files and writes files
 5425 % containing these kinds of lines:
 5426 %  \initial {c}
 5427 %     before the first topic whose initial is c
 5428 %  \entry {topic}{pagelist}
 5429 %     for a topic that is used without subtopics
 5430 %  \primary {topic}
 5431 %     for the beginning of a topic that is used with subtopics
 5432 %  \secondary {subtopic}{pagelist}
 5433 %     for each subtopic.
 5434 
 5435 % Define the user-accessible indexing commands
 5436 % @findex, @vindex, @kindex, @cindex.
 5437 
 5438 \def\findex {\fnindex}
 5439 \def\kindex {\kyindex}
 5440 \def\cindex {\cpindex}
 5441 \def\vindex {\vrindex}
 5442 \def\tindex {\tpindex}
 5443 \def\pindex {\pgindex}
 5444 
 5445 \def\cindexsub {\begingroup\obeylines\cindexsub}
 5446 {\obeylines %
 5447 \gdef\cindexsub "#1" #2^^M{\endgroup %
 5448 \dosubind{cp}{#2}{#1}}}
 5449 
 5450 % Define the macros used in formatting output of the sorted index material.
 5451 
 5452 % @printindex causes a particular index (the ??s file) to get printed.
 5453 % It does not print any chapter heading (usually an @unnumbered).
 5454 %
 5455 \parseargdef\printindex{\begingroup
 5456   \dobreak \chapheadingskip{10000}%
 5457   %
 5458   \smallfonts \rm
 5459   \tolerance = 9500
 5460   \plainfrenchspacing
 5461   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
 5462   %
 5463   % See if the index file exists and is nonempty.
 5464   % Change catcode of @ here so that if the index file contains
 5465   % \initial {@}
 5466   % as its first line, TeX doesn't complain about mismatched braces
 5467   % (because it thinks @} is a control sequence).
 5468   \catcode`\@ = 12
 5469   % See comment in \requireopenindexfile.
 5470   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
 5471   \openin 1 \jobname.\indexname s
 5472   \ifeof 1
 5473     % \enddoublecolumns gets confused if there is no text in the index,
 5474     % and it loses the chapter title and the aux file entries for the
 5475     % index.  The easiest way to prevent this problem is to make sure
 5476     % there is some text.
 5477     \putwordIndexNonexistent
 5478     \typeout{No file \jobname.\indexname s.}%
 5479   \else
 5480     \catcode`\\ = 0
 5481     %
 5482     % If the index file exists but is empty, then \openin leaves \ifeof
 5483     % false.  We have to make TeX try to read something from the file, so
 5484     % it can discover if there is anything in it.
 5485     \read 1 to \thisline
 5486     \ifeof 1
 5487       \putwordIndexIsEmpty
 5488     \else
 5489       % Index files are almost Texinfo source, but we use \ as the escape
 5490       % character.  It would be better to use @, but that's too big a change
 5491       % to make right now.
 5492       \def\indexbackslash{\ttbackslash}%
 5493       \let\indexlbrace\{   % Likewise, set these sequences for braces
 5494       \let\indexrbrace\}   % used in the sort key.
 5495       \begindoublecolumns
 5496       \let\dotheinsertentrybox\dotheinsertentryboxwithpenalty
 5497       %
 5498       % Read input from the index file line by line.
 5499       \loopdo
 5500         \ifeof1 \else
 5501           \read 1 to \nextline
 5502         \fi
 5503         %
 5504         \indexinputprocessing
 5505         \thisline
 5506         %
 5507         \ifeof1\else
 5508         \let\thisline\nextline
 5509       \repeat
 5510       %%
 5511       \enddoublecolumns
 5512     \fi
 5513   \fi
 5514   \closein 1
 5515 \endgroup}
 5516 \def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
 5517 \def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
 5518 
 5519 \def\indexinputprocessing{%
 5520   \ifeof1
 5521     \let\firsttoken\relax
 5522   \else
 5523     \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
 5524     \act
 5525   \fi
 5526 }
 5527 \def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
 5528 \long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
 5529 
 5530 
 5531 % These macros are used by the sorted index file itself.
 5532 % Change them to control the appearance of the index.
 5533 
 5534 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
 5535 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
 5536 \catcode`\$=3
 5537 \gdef\initialglyphs{%
 5538   % Some changes for non-alphabetic characters.  Using the glyphs from the
 5539   % math fonts looks more consistent than the typewriter font used elsewhere
 5540   % for these characters.
 5541   \def\indexbackslash{\math{\backslash}}%
 5542   \let\\=\indexbackslash
 5543   %
 5544   % Can't get bold backslash so don't use bold forward slash
 5545   \catcode`\/=13
 5546   \def/{{\secrmnotbold \normalslash}}%
 5547   \def-{{\normaldash\normaldash}}% en dash `--'
 5548   \def^{{\chapbf \normalcaret}}%
 5549   \def~{{\chapbf \normaltilde}}%
 5550   \def\_{%
 5551      \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
 5552   \def|{$\vert$}%
 5553   \def<{$\less$}%
 5554   \def>{$\gtr$}%
 5555   \def+{$\normalplus$}%
 5556 }}
 5557 
 5558 \def\initial{%
 5559   \bgroup
 5560   \initialglyphs
 5561   \initialx
 5562 }
 5563 
 5564 \def\initialx#1{%
 5565   % Remove any glue we may have, we'll be inserting our own.
 5566   \removelastskip
 5567   %
 5568   % We like breaks before the index initials, so insert a bonus.
 5569   % The glue before the bonus allows a little bit of space at the
 5570   % bottom of a column to reduce an increase in inter-line spacing.
 5571   \nobreak
 5572   \vskip 0pt plus 5\baselineskip
 5573   \penalty -300 
 5574   \vskip 0pt plus -5\baselineskip
 5575   %
 5576   % Typeset the initial.  Making this add up to a whole number of
 5577   % baselineskips increases the chance of the dots lining up from column
 5578   % to column.  It still won't often be perfect, because of the stretch
 5579   % we need before each entry, but it's better.
 5580   %
 5581   % No shrink because it confuses \balancecolumns.
 5582   \vskip 1.67\baselineskip plus 1\baselineskip
 5583   \leftline{\secfonts \kern-0.05em \secbf #1}%
 5584   % \secfonts is inside the argument of \leftline so that the change of
 5585   % \baselineskip will not affect any glue inserted before the vbox that
 5586   % \leftline creates.
 5587   % Do our best not to break after the initial.
 5588   \nobreak
 5589   \vskip .33\baselineskip plus .1\baselineskip
 5590   \egroup % \initialglyphs
 5591 }
 5592 
 5593 \newdimen\entryrightmargin
 5594 \entryrightmargin=0pt
 5595 
 5596 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
 5597 % then page number (#2) flushed to the right margin.  It is used for index
 5598 % and table of contents entries.  The paragraph is indented by \leftskip.
 5599 %
 5600 \def\entry{%
 5601   \begingroup
 5602     %
 5603     % For pdfTeX and XeTeX.
 5604     % The redefinition of \domark stops marks being added in \pdflink to 
 5605     % preserve coloured links across page boundaries.  Otherwise the marks
 5606     % would get in the way of \lastbox in \insertentrybox.
 5607     \let\domark\relax
 5608     %
 5609     % Start a new paragraph if necessary, so our assignments below can't
 5610     % affect previous text.
 5611     \par
 5612     %
 5613     % No extra space above this paragraph.
 5614     \parskip = 0in
 5615     %
 5616     % When reading the text of entry, convert explicit line breaks
 5617     % from @* into spaces.  The user might give these in long section
 5618     % titles, for instance.
 5619     \def\*{\unskip\space\ignorespaces}%
 5620     \def\entrybreak{\hfil\break}% An undocumented command
 5621     %
 5622     % Swallow the left brace of the text (first parameter):
 5623     \afterassignment\doentry
 5624     \let\temp =
 5625 }
 5626 \def\entrybreak{\unskip\space\ignorespaces}%
 5627 \def\doentry{%
 5628     % Save the text of the entry
 5629     \global\setbox\boxA=\hbox\bgroup
 5630     \bgroup % Instead of the swallowed brace.
 5631       \noindent
 5632       \aftergroup\finishentry
 5633       % And now comes the text of the entry.
 5634       % Not absorbing as a macro argument reduces the chance of problems
 5635       % with catcodes occurring.
 5636 }
 5637 {\catcode`\@=11
 5638 \gdef\finishentry#1{%
 5639     \egroup % end box A
 5640     \dimen@ = \wd\boxA % Length of text of entry
 5641     \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
 5642     % #1 is the page number.
 5643     %
 5644     % Get the width of the page numbers, and only use
 5645     % leaders if they are present.
 5646     \global\setbox\boxB = \hbox{#1}%
 5647     \ifdim\wd\boxB = 0pt
 5648       \null\nobreak\hfill\ %
 5649     \else
 5650       %
 5651       \null\nobreak\indexdotfill % Have leaders before the page number.
 5652       %
 5653       \ifpdf
 5654         \pdfgettoks#1.%
 5655         \hskip\skip\thinshrinkable\the\toksA
 5656       \else
 5657         \ifx\XeTeXrevision\thisisundefined
 5658           \hskip\skip\thinshrinkable #1%
 5659         \else
 5660           \pdfgettoks#1.%
 5661           \hskip\skip\thinshrinkable\the\toksA
 5662         \fi
 5663       \fi
 5664     \fi
 5665     \egroup % end \boxA
 5666     \ifdim\wd\boxB = 0pt
 5667       \global\setbox\entrybox=\vbox{\unhbox\boxA}%
 5668     \else
 5669     \global\setbox\entrybox=\vbox\bgroup
 5670       % We want the text of the entries to be aligned to the left, and the
 5671       % page numbers to be aligned to the right.
 5672       %
 5673       \parindent = 0pt
 5674       \advance\leftskip by 0pt plus 1fil
 5675       \advance\leftskip by 0pt plus -1fill
 5676       \rightskip = 0pt plus -1fil
 5677       \advance\rightskip by 0pt plus 1fill
 5678       % Cause last line, which could consist of page numbers on their own
 5679       % if the list of page numbers is long, to be aligned to the right.
 5680       \parfillskip=0pt plus -1fill
 5681       %
 5682       \advance\rightskip by \entryrightmargin
 5683       % Determine how far we can stretch into the margin.
 5684       % This allows, e.g., "Appendix H  GNU Free Documentation License" to
 5685       % fit on one line in @letterpaper format.
 5686       \ifdim\entryrightmargin>2.1em
 5687         \dimen@i=2.1em
 5688       \else
 5689         \dimen@i=0em
 5690       \fi
 5691       \advance \parfillskip by 0pt minus 1\dimen@i
 5692       %
 5693       \dimen@ii = \hsize
 5694       \advance\dimen@ii by -1\leftskip
 5695       \advance\dimen@ii by -1\entryrightmargin
 5696       \advance\dimen@ii by 1\dimen@i
 5697       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
 5698       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
 5699         % Try to split the text roughly evenly.  \dimen@ will be the length of 
 5700         % the first line.
 5701         \dimen@ = 0.7\dimen@
 5702         \dimen@ii = \hsize
 5703         \ifnum\dimen@>\dimen@ii
 5704           % If the entry is too long (for example, if it needs more than
 5705           % two lines), use all the space in the first line.
 5706           \dimen@ = \dimen@ii
 5707         \fi
 5708         \advance\leftskip by 0pt plus 1fill % ragged right
 5709         \advance \dimen@ by 1\rightskip
 5710         \parshape = 2 0pt \dimen@ 0em \dimen@ii
 5711         % Ideally we'd add a finite glue at the end of the first line only,
 5712         % instead of using \parshape with explicit line lengths, but TeX
 5713         % doesn't seem to provide a way to do such a thing.
 5714         %
 5715         % Indent all lines but the first one.
 5716         \advance\leftskip by 1em
 5717         \advance\parindent by -1em
 5718       \fi\fi
 5719       \indent % start paragraph
 5720       \unhbox\boxA
 5721       %
 5722       % Do not prefer a separate line ending with a hyphen to fewer lines.
 5723       \finalhyphendemerits = 0
 5724       %
 5725       % Word spacing - no stretch
 5726       \spaceskip=\fontdimen2\font minus \fontdimen4\font
 5727       %
 5728       \linepenalty=1000  % Discourage line breaks.
 5729       \hyphenpenalty=5000  % Discourage hyphenation.
 5730       %
 5731       \par % format the paragraph
 5732     \egroup % The \vbox
 5733     \fi
 5734   \endgroup
 5735   \dotheinsertentrybox
 5736 }}
 5737 
 5738 \newskip\thinshrinkable
 5739 \skip\thinshrinkable=.15em minus .15em
 5740 
 5741 \newbox\entrybox
 5742 \def\insertentrybox{%
 5743   \ourunvbox\entrybox
 5744 }
 5745 
 5746 % default definition
 5747 \let\dotheinsertentrybox\insertentrybox
 5748 
 5749 % Use \lastbox to take apart vbox box by box, and add each sub-box
 5750 % to the current vertical list.
 5751 \def\ourunvbox#1{%
 5752 \bgroup % for local binding of \delayedbox
 5753   % Remove the last box from box #1
 5754   \global\setbox#1=\vbox{%
 5755     \unvbox#1%
 5756     \unskip % remove any glue
 5757     \unpenalty
 5758     \global\setbox\interbox=\lastbox
 5759   }%
 5760   \setbox\delayedbox=\box\interbox
 5761   \ifdim\ht#1=0pt\else
 5762     \ourunvbox#1 % Repeat on what's left of the box
 5763     \nobreak
 5764   \fi
 5765   \box\delayedbox
 5766 \egroup
 5767 }
 5768 \newbox\delayedbox
 5769 \newbox\interbox
 5770 
 5771 % Used from \printindex.  \firsttoken should be the first token
 5772 % after the \entry.  If it's not another \entry, we are at the last
 5773 % line of a group of index entries, so insert a penalty to discourage
 5774 % widowed index entries.
 5775 \def\dotheinsertentryboxwithpenalty{%
 5776   \ifx\firsttoken\isentry
 5777   \else
 5778     \penalty 9000
 5779   \fi
 5780   \insertentrybox
 5781 }
 5782 \def\isentry{\entry}%
 5783 
 5784 % Like plain.tex's \dotfill, except uses up at least 1 em.
 5785 % The filll stretch here overpowers both the fil and fill stretch to push
 5786 % the page number to the right.
 5787 \def\indexdotfill{\cleaders
 5788   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
 5789 
 5790 
 5791 \def\primary #1{\line{#1\hfil}}
 5792 
 5793 \newskip\secondaryindent \secondaryindent=0.5cm
 5794 \def\secondary#1#2{{%
 5795   \parfillskip=0in
 5796   \parskip=0in
 5797   \hangindent=1in
 5798   \hangafter=1
 5799   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
 5800   \ifpdf
 5801     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
 5802   \else
 5803     \ifx\XeTeXrevision\thisisundefined
 5804       #2
 5805     \else
 5806       \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
 5807     \fi
 5808   \fi
 5809   \par
 5810 }}
 5811 
 5812 % Define two-column mode, which we use to typeset indexes.
 5813 % Adapted from the TeXbook, page 416, which is to say,
 5814 % the manmac.tex format used to print the TeXbook itself.
 5815 \catcode`\@=11  % private names
 5816 
 5817 \newbox\partialpage
 5818 \newdimen\doublecolumnhsize
 5819 
 5820 % Use inside an output routine to save \topmark and \firstmark
 5821 \def\savemarks{%
 5822   \global\savedtopmark=\expandafter{\topmark }%
 5823   \global\savedfirstmark=\expandafter{\firstmark }%
 5824 }
 5825 \newtoks\savedtopmark
 5826 \newtoks\savedfirstmark
 5827 
 5828 % Set \topmark and \firstmark for next time \output runs.
 5829 % Can't be run from withinside \output (because any material
 5830 % added while an output routine is active, including 
 5831 % penalties, is saved for after it finishes).  The page so far
 5832 % should be empty, otherwise what's on it will be thrown away.
 5833 \def\restoremarks{%
 5834   \mark{\the\savedtopmark}%
 5835   \bgroup\output = {%
 5836     \setbox\dummybox=\box\PAGE
 5837   }abc\eject\egroup
 5838   % "abc" because output routine doesn't fire for a completely empty page.
 5839   \mark{\the\savedfirstmark}%
 5840 }
 5841 
 5842 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
 5843   % If not much space left on page, start a new page.
 5844   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
 5845   %
 5846   % Grab any single-column material above us.
 5847   \output = {%
 5848     %
 5849     % Here is a possibility not foreseen in manmac: if we accumulate a
 5850     % whole lot of material, we might end up calling this \output
 5851     % routine twice in a row (see the doublecol-lose test, which is
 5852     % essentially a couple of indexes with @setchapternewpage off).  In
 5853     % that case we just ship out what is in \partialpage with the normal
 5854     % output routine.  Generally, \partialpage will be empty when this
 5855     % runs and this will be a no-op.  See the indexspread.tex test case.
 5856     \ifvoid\partialpage \else
 5857       \onepageout{\pagecontents\partialpage}%
 5858     \fi
 5859     %
 5860     \global\setbox\partialpage = \vbox{%
 5861       % Unvbox the main output page.
 5862       \unvbox\PAGE
 5863       \kern-\topskip \kern\baselineskip
 5864     }%
 5865     \savemarks
 5866   }%
 5867   \eject % run that output routine to set \partialpage
 5868   \restoremarks
 5869   %
 5870   % We recover the two marks that the last output routine saved in order
 5871   % to propagate the information in marks added around a chapter heading,
 5872   % which could be otherwise be lost by the time the final page is output.
 5873   %
 5874   %
 5875   % Use the double-column output routine for subsequent pages.
 5876   \output = {\doublecolumnout}%
 5877   %
 5878   % Change the page size parameters.  We could do this once outside this
 5879   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
 5880   % format, but then we repeat the same computation.  Repeating a couple
 5881   % of assignments once per index is clearly meaningless for the
 5882   % execution time, so we may as well do it in one place.
 5883   %
 5884   % First we halve the line length, less a little for the gutter between
 5885   % the columns.  We compute the gutter based on the line length, so it
 5886   % changes automatically with the paper format.  The magic constant
 5887   % below is chosen so that the gutter has the same value (well, +-<1pt)
 5888   % as it did when we hard-coded it.
 5889   %
 5890   % We put the result in a separate register, \doublecolumhsize, so we
 5891   % can restore it in \pagesofar, after \hsize itself has (potentially)
 5892   % been clobbered.
 5893   %
 5894   \doublecolumnhsize = \hsize
 5895     \advance\doublecolumnhsize by -.04154\hsize
 5896     \divide\doublecolumnhsize by 2
 5897   \hsize = \doublecolumnhsize
 5898   %
 5899   % Double the \vsize as well.
 5900   \advance\vsize by -\ht\partialpage
 5901   \vsize = 2\vsize
 5902   %
 5903   % For the benefit of balancing columns
 5904   \advance\baselineskip by 0pt plus 0.5pt
 5905 }
 5906 
 5907 % The double-column output routine for all double-column pages except
 5908 % the last, which is done by \balancecolumns.
 5909 %
 5910 \def\doublecolumnout{%
 5911   %
 5912   \splittopskip=\topskip \splitmaxdepth=\maxdepth
 5913   % Get the available space for the double columns -- the normal
 5914   % (undoubled) page height minus any material left over from the
 5915   % previous page.
 5916   \dimen@ = \vsize
 5917   \divide\dimen@ by 2
 5918   %
 5919   % box0 will be the left-hand column, box2 the right.
 5920   \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
 5921   \global\advance\vsize by 2\ht\partialpage
 5922   \onepageout\pagesofar
 5923   \unvbox\PAGE
 5924   \penalty\outputpenalty
 5925 }
 5926 %
 5927 % Re-output the contents of the output page -- any previous material,
 5928 % followed by the two boxes we just split, in box0 and box2.
 5929 \def\pagesofar{%
 5930   \unvbox\partialpage
 5931   %
 5932   \hsize = \doublecolumnhsize
 5933   \wd0=\hsize \wd2=\hsize
 5934   \hbox to\txipagewidth{\box0\hfil\box2}%
 5935 }
 5936 
 5937 
 5938 % Finished with with double columns.
 5939 \def\enddoublecolumns{%
 5940   % The following penalty ensures that the page builder is exercised
 5941   % _before_ we change the output routine.  This is necessary in the
 5942   % following situation:
 5943   %
 5944   % The last section of the index consists only of a single entry.
 5945   % Before this section, \pagetotal is less than \pagegoal, so no
 5946   % break occurs before the last section starts.  However, the last
 5947   % section, consisting of \initial and the single \entry, does not
 5948   % fit on the page and has to be broken off.  Without the following
 5949   % penalty the page builder will not be exercised until \eject
 5950   % below, and by that time we'll already have changed the output
 5951   % routine to the \balancecolumns version, so the next-to-last
 5952   % double-column page will be processed with \balancecolumns, which
 5953   % is wrong:  The two columns will go to the main vertical list, with
 5954   % the broken-off section in the recent contributions.  As soon as
 5955   % the output routine finishes, TeX starts reconsidering the page
 5956   % break.  The two columns and the broken-off section both fit on the
 5957   % page, because the two columns now take up only half of the page
 5958   % goal.  When TeX sees \eject from below which follows the final
 5959   % section, it invokes the new output routine that we've set after
 5960   % \balancecolumns below; \onepageout will try to fit the two columns
 5961   % and the final section into the vbox of \txipageheight (see
 5962   % \pagebody), causing an overfull box.
 5963   %
 5964   % Note that glue won't work here, because glue does not exercise the
 5965   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
 5966   \penalty0
 5967   %
 5968   \output = {%
 5969     % Split the last of the double-column material.
 5970     \savemarks
 5971     \balancecolumns
 5972     %
 5973     % Having called \balancecolumns once, we do not
 5974     % want to call it again.  Therefore, reset \output to its normal
 5975     % definition right away.
 5976     \global\output = {\onepageout{\pagecontents\PAGE}}%
 5977   }%
 5978   \eject
 5979   \endgroup % started in \begindoublecolumns
 5980   \restoremarks
 5981   % Leave the double-column material on the current page, no automatic
 5982   % page break.
 5983   \box\balancedcolumns
 5984   %
 5985   % \pagegoal was set to the doubled \vsize above, since we restarted
 5986   % the current page.  We're now back to normal single-column
 5987   % typesetting, so reset \pagegoal to the normal \vsize.
 5988   \global\vsize = \txipageheight %
 5989   \pagegoal = \txipageheight %
 5990 }
 5991 \newbox\balancedcolumns
 5992 \setbox\balancedcolumns=\vbox{shouldnt see this}%
 5993 %
 5994 % Only called for the last of the double column material.  \doublecolumnout 
 5995 % does the others.
 5996 \def\balancecolumns{%
 5997   \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
 5998   \dimen@ = \ht0
 5999   \advance\dimen@ by \topskip
 6000   \advance\dimen@ by-\baselineskip
 6001   \ifdim\dimen@<5\baselineskip
 6002     % Don't split a short final column in two.
 6003     \setbox2=\vbox{}%
 6004   \else
 6005     \divide\dimen@ by 2 % target to split to
 6006     \dimen@ii = \dimen@
 6007     \splittopskip = \topskip
 6008     % Loop until left column is at least as high as the right column.
 6009     {%
 6010       \vbadness = 10000
 6011       \loop
 6012         \global\setbox3 = \copy0
 6013         \global\setbox1 = \vsplit3 to \dimen@
 6014       \ifdim\ht1<\ht3
 6015         \global\advance\dimen@ by 1pt
 6016       \repeat
 6017     }%
 6018     % Now the left column is in box 1, and the right column in box 3.
 6019     % Check whether the left column has come out higher than the page itself.  
 6020     % (Note that we have doubled \vsize for the double columns, so
 6021     % the actual height of the page is 0.5\vsize).
 6022     \ifdim2\ht1>\vsize
 6023       % Just split the last of the double column material roughly in half.
 6024       \setbox2=\box0
 6025       \setbox0 = \vsplit2 to \dimen@ii
 6026       \setbox0=\vbox to \dimen@ii {\unvbox0\vfill}%
 6027       \setbox2=\vbox to \dimen@ii {\unvbox2\vfill}%
 6028     \else
 6029       % Compare the heights of the two columns.
 6030       \ifdim4\ht1>5\ht3
 6031         % Column heights are too different, so don't make their bottoms
 6032         % flush with each other.
 6033         \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
 6034         \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
 6035       \else
 6036         % Make column bottoms flush with each other.
 6037         \setbox2=\vbox to\ht1{\unvbox3\unskip}%
 6038         \setbox0=\vbox to\ht1{\unvbox1\unskip}%
 6039       \fi
 6040     \fi
 6041   \fi
 6042   %
 6043   \global\setbox\balancedcolumns=\vbox{\pagesofar}%
 6044 }
 6045 \catcode`\@ = \other
 6046 
 6047 
 6048 \message{sectioning,}
 6049 % Chapters, sections, etc.
 6050 
 6051 % Let's start with @part.
 6052 \outer\parseargdef\part{\partzzz{#1}}
 6053 \def\partzzz#1{%
 6054   \chapoddpage
 6055   \null
 6056   \vskip.3\vsize  % move it down on the page a bit
 6057   \begingroup
 6058     \noindent \titlefonts\rm #1\par % the text
 6059     \let\lastnode=\empty      % no node to associate with
 6060     \writetocentry{part}{#1}{}% but put it in the toc
 6061     \headingsoff              % no headline or footline on the part page
 6062     % This outputs a mark at the end of the page that clears \thischapter
 6063     % and \thissection, as is done in \startcontents.
 6064     \let\pchapsepmacro\relax
 6065     \chapmacro{}{Yomitfromtoc}{}%
 6066     \chapoddpage
 6067   \endgroup
 6068 }
 6069 
 6070 % \unnumberedno is an oxymoron.  But we count the unnumbered
 6071 % sections so that we can refer to them unambiguously in the pdf
 6072 % outlines by their "section number".  We avoid collisions with chapter
 6073 % numbers by starting them at 10000.  (If a document ever has 10000
 6074 % chapters, we're in trouble anyway, I'm sure.)
 6075 \newcount\unnumberedno \unnumberedno = 10000
 6076 \newcount\chapno
 6077 \newcount\secno        \secno=0
 6078 \newcount\subsecno     \subsecno=0
 6079 \newcount\subsubsecno  \subsubsecno=0
 6080 
 6081 % This counter is funny since it counts through charcodes of letters A, B, ...
 6082 \newcount\appendixno  \appendixno = `\@
 6083 %
 6084 % \def\appendixletter{\char\the\appendixno}
 6085 % We do the following ugly conditional instead of the above simple
 6086 % construct for the sake of pdftex, which needs the actual
 6087 % letter in the expansion, not just typeset.
 6088 %
 6089 \def\appendixletter{%
 6090   \ifnum\appendixno=`A A%
 6091   \else\ifnum\appendixno=`B B%
 6092   \else\ifnum\appendixno=`C C%
 6093   \else\ifnum\appendixno=`D D%
 6094   \else\ifnum\appendixno=`E E%
 6095   \else\ifnum\appendixno=`F F%
 6096   \else\ifnum\appendixno=`G G%
 6097   \else\ifnum\appendixno=`H H%
 6098   \else\ifnum\appendixno=`I I%
 6099   \else\ifnum\appendixno=`J J%
 6100   \else\ifnum\appendixno=`K K%
 6101   \else\ifnum\appendixno=`L L%
 6102   \else\ifnum\appendixno=`M M%
 6103   \else\ifnum\appendixno=`N N%
 6104   \else\ifnum\appendixno=`O O%
 6105   \else\ifnum\appendixno=`P P%
 6106   \else\ifnum\appendixno=`Q Q%
 6107   \else\ifnum\appendixno=`R R%
 6108   \else\ifnum\appendixno=`S S%
 6109   \else\ifnum\appendixno=`T T%
 6110   \else\ifnum\appendixno=`U U%
 6111   \else\ifnum\appendixno=`V V%
 6112   \else\ifnum\appendixno=`W W%
 6113   \else\ifnum\appendixno=`X X%
 6114   \else\ifnum\appendixno=`Y Y%
 6115   \else\ifnum\appendixno=`Z Z%
 6116   % The \the is necessary, despite appearances, because \appendixletter is
 6117   % expanded while writing the .toc file.  \char\appendixno is not
 6118   % expandable, thus it is written literally, thus all appendixes come out
 6119   % with the same letter (or @) in the toc without it.
 6120   \else\char\the\appendixno
 6121   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
 6122   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
 6123 
 6124 % Each @chapter defines these (using marks) as the number+name, number
 6125 % and name of the chapter.  Page headings and footings can use
 6126 % these.  @section does likewise.
 6127 \def\thischapter{}
 6128 \def\thischapternum{}
 6129 \def\thischaptername{}
 6130 \def\thissection{}
 6131 \def\thissectionnum{}
 6132 \def\thissectionname{}
 6133 
 6134 \newcount\absseclevel % used to calculate proper heading level
 6135 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
 6136 
 6137 % @raisesections: treat @section as chapter, @subsection as section, etc.
 6138 \def\raisesections{\global\advance\secbase by -1}
 6139 \let\up=\raisesections % original BFox name
 6140 
 6141 % @lowersections: treat @chapter as section, @section as subsection, etc.
 6142 \def\lowersections{\global\advance\secbase by 1}
 6143 \let\down=\lowersections % original BFox name
 6144 
 6145 % we only have subsub.
 6146 \chardef\maxseclevel = 3
 6147 %
 6148 % A numbered section within an unnumbered changes to unnumbered too.
 6149 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
 6150 \chardef\unnlevel = \maxseclevel
 6151 %
 6152 % Trace whether the current chapter is an appendix or not:
 6153 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
 6154 \def\chapheadtype{N}
 6155 
 6156 % Choose a heading macro
 6157 % #1 is heading type
 6158 % #2 is heading level
 6159 % #3 is text for heading
 6160 \def\genhead#1#2#3{%
 6161   % Compute the abs. sec. level:
 6162   \absseclevel=#2
 6163   \advance\absseclevel by \secbase
 6164   % Make sure \absseclevel doesn't fall outside the range:
 6165   \ifnum \absseclevel < 0
 6166     \absseclevel = 0
 6167   \else
 6168     \ifnum \absseclevel > 3
 6169       \absseclevel = 3
 6170     \fi
 6171   \fi
 6172   % The heading type:
 6173   \def\headtype{#1}%
 6174   \if \headtype U%
 6175     \ifnum \absseclevel < \unnlevel
 6176       \chardef\unnlevel = \absseclevel
 6177     \fi
 6178   \else
 6179     % Check for appendix sections:
 6180     \ifnum \absseclevel = 0
 6181       \edef\chapheadtype{\headtype}%
 6182     \else
 6183       \if \headtype A\if \chapheadtype N%
 6184     \errmessage{@appendix... within a non-appendix chapter}%
 6185       \fi\fi
 6186     \fi
 6187     % Check for numbered within unnumbered:
 6188     \ifnum \absseclevel > \unnlevel
 6189       \def\headtype{U}%
 6190     \else
 6191       \chardef\unnlevel = 3
 6192     \fi
 6193   \fi
 6194   % Now print the heading:
 6195   \if \headtype U%
 6196     \ifcase\absseclevel
 6197     \unnumberedzzz{#3}%
 6198     \or \unnumberedseczzz{#3}%
 6199     \or \unnumberedsubseczzz{#3}%
 6200     \or \unnumberedsubsubseczzz{#3}%
 6201     \fi
 6202   \else
 6203     \if \headtype A%
 6204       \ifcase\absseclevel
 6205       \appendixzzz{#3}%
 6206       \or \appendixsectionzzz{#3}%
 6207       \or \appendixsubseczzz{#3}%
 6208       \or \appendixsubsubseczzz{#3}%
 6209       \fi
 6210     \else
 6211       \ifcase\absseclevel
 6212       \chapterzzz{#3}%
 6213       \or \seczzz{#3}%
 6214       \or \numberedsubseczzz{#3}%
 6215       \or \numberedsubsubseczzz{#3}%
 6216       \fi
 6217     \fi
 6218   \fi
 6219   \suppressfirstparagraphindent
 6220 }
 6221 
 6222 % an interface:
 6223 \def\numhead{\genhead N}
 6224 \def\apphead{\genhead A}
 6225 \def\unnmhead{\genhead U}
 6226 
 6227 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
 6228 % all lower-level sectioning counters to zero.
 6229 %
 6230 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
 6231 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
 6232 \let\chaplevelprefix = \empty
 6233 %
 6234 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
 6235 \def\chapterzzz#1{%
 6236   % section resetting is \global in case the chapter is in a group, such
 6237   % as an @include file.
 6238   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
 6239     \global\advance\chapno by 1
 6240   %
 6241   % Used for \float.
 6242   \gdef\chaplevelprefix{\the\chapno.}%
 6243   \resetallfloatnos
 6244   %
 6245   % \putwordChapter can contain complex things in translations.
 6246   \toks0=\expandafter{\putwordChapter}%
 6247   \message{\the\toks0 \space \the\chapno}%
 6248   %
 6249   % Write the actual heading.
 6250   \chapmacro{#1}{Ynumbered}{\the\chapno}%
 6251   %
 6252   % So @section and the like are numbered underneath this chapter.
 6253   \global\let\section = \numberedsec
 6254   \global\let\subsection = \numberedsubsec
 6255   \global\let\subsubsection = \numberedsubsubsec