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