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