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