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