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