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