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