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