|
|
1.1 root 1: %% TeX macros to handle texinfo files
2:
3: % Copyright (C) 1985, 1986, 1988, 1990, 1991 Free Software Foundation, Inc.
4:
5: %This texinfo.tex file is free software; you can redistribute it and/or
6: %modify it under the terms of the GNU General Public License as
7: %published by the Free Software Foundation; either version 2, or (at
8: %your option) any later version.
9:
10: %This texinfo.tex file is distributed in the hope that it will be
11: %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12: %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: %General Public License for more details.
14:
15: %You should have received a copy of the GNU General Public License
16: %along with this texinfo.tex file; see the file COPYING. If not, write
17: %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
18: %USA.
19:
20:
21: %In other words, you are welcome to use, share and improve this program.
22: %You are forbidden to forbid anyone else to use, share and improve
23: %what you give them. Help stamp out software-hoarding!
24:
1.1.1.2 ! root 25: \def\texinfoversion{2.65}
1.1 root 26: \message{Loading texinfo package [Version \texinfoversion]:}
27: \message{}
28:
29: % Print the version number if in a .fmt file.
30: \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
31:
32: % Save some parts of plain tex whose names we will redefine.
33:
34: \let\ptexlbrace=\{
35: \let\ptexrbrace=\}
36: \let\ptexdots=\dots
37: \let\ptexdot=\.
38: \let\ptexstar=\*
39: \let\ptexend=\end
40: \let\ptexbullet=\bullet
41: \let\ptexb=\b
42: \let\ptexc=\c
43: \let\ptexi=\i
44: \let\ptext=\t
45: \let\ptexl=\l
46: \let\ptexL=\L
47:
48: \def\tie{\penalty 10000\ } % Save plain tex definition of ~.
49:
50: \message{Basics,}
51: \chardef\other=12
52:
53: \hyphenation{ap-pen-dix}
54: \hyphenation{mini-buf-fer mini-buf-fers}
55: \hyphenation{eshell}
56:
57: % Margin to add to right of even pages, to left of odd pages.
58: \newdimen \bindingoffset \bindingoffset=0pt
59: \newdimen \normaloffset \normaloffset=\hoffset
60: \newdimen\pagewidth \newdimen\pageheight
61: \pagewidth=\hsize \pageheight=\vsize
62:
63: %---------------------Begin change-----------------------
64: %
65: %%%% For @cropmarks command.
66: % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
67: %
68: \newdimen\cornerlong \newdimen\cornerthick
69: \newdimen \topandbottommargin
70: \newdimen \outerhsize \newdimen \outervsize
71: \cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks
72: \outerhsize=7in
73: %\outervsize=9.5in
74: % Alternative @smallbook page size is 9.25in
75: \outervsize=9.25in
76: \topandbottommargin=.75in
77: %
78: %---------------------End change-----------------------
79:
80: % \onepageout takes a vbox as an argument. Note that \pagecontents
81: % does insertions itself, but you have to call it yourself.
82: \chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}}
83: \def\onepageout#1{\hoffset=\normaloffset
84: \ifodd\pageno \advance\hoffset by \bindingoffset
85: \else \advance\hoffset by -\bindingoffset\fi
86: {\escapechar=`\\\relax % makes sure backslash is used in output files.
87: \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
88: {\let\hsize=\pagewidth \makefootline}}}%
89: \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
90:
91: %%%% For @cropmarks command %%%%
92:
93: % Here is a modification of the main output routine for Near East Publications
94: % This provides right-angle cropmarks at all four corners.
95: % The contents of the page are centerlined into the cropmarks,
96: % and any desired binding offset is added as an \hskip on either
97: % site of the centerlined box. (P. A. MacKay, 12 November, 1986)
98: %
99: \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
100: \shipout
101: \vbox to \outervsize{\hsize=\outerhsize
102: \vbox{\line{\ewtop\hfill\ewtop}}
103: \nointerlineskip
104: \line{\vbox{\moveleft\cornerthick\nstop}
105: \hfill
106: \vbox{\moveright\cornerthick\nstop}}
107: \vskip \topandbottommargin
108: \centerline{\ifodd\pageno\hskip\bindingoffset\fi
109: \vbox{
110: {\let\hsize=\pagewidth \makeheadline}
111: \pagebody{#1}
112: {\let\hsize=\pagewidth \makefootline}}
113: \ifodd\pageno\else\hskip\bindingoffset\fi}
114: \vskip \topandbottommargin plus1fill minus1fill
115: \boxmaxdepth\cornerthick
116: \line{\vbox{\moveleft\cornerthick\nsbot}
117: \hfill
118: \vbox{\moveright\cornerthick\nsbot}}
119: \nointerlineskip
120: \vbox{\line{\ewbot\hfill\ewbot}}
121: }
122: \advancepageno
123: \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
124: %
125: % Do @cropmarks to get crop marks
126: \def\cropmarks{\let\onepageout=\croppageout }
127:
128: \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
129: {\catcode`\@ =11
130: \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
131: \dimen@=\dp#1 \unvbox#1
132: \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
133: \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
134: }
135:
136: %
137: % Here are the rules for the cropmarks. Note that they are
138: % offset so that the space between them is truly \outerhsize or \outervsize
139: % (P. A. MacKay, 12 November, 1986)
140: %
141: \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
142: \def\nstop{\vbox
143: {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
144: \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
145: \def\nsbot{\vbox
146: {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
147:
148: % Parse an argument, then pass it to #1.
149: % The argument can be delimited with [...] or with "..." or braces
150: % or it can be a whole line.
151: % #1 should be a macro which expects
152: % an ordinary undelimited TeX argument.
153:
154: \def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx}
155:
156: \def\parseargx{%
157: \ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else%
158: \aftergroup \parseargline %
159: \fi \endgroup}
160:
161: {\obeyspaces %
162: \gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}}
163:
164: \gdef\obeyedspace{\ }
165:
166: \def\parseargline{\begingroup \obeylines \parsearglinex}
167: {\obeylines %
168: \gdef\parsearglinex #1^^M{\endgroup \next {#1}}}
169:
170: \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
171:
172: %% These are used to keep @begin/@end levels from running away
173: %% Call \inENV within environments (after a \begingroup)
174: \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
175: \def\ENVcheck{%
176: \ifENV\errmessage{Still within an environment. Type Return to continue.}
177: \endgroup\fi} % This is not perfect, but it should reduce lossage
178:
179: % @begin foo is the same as @foo, for now.
180: \newhelp\EMsimple{Type <Return> to continue}
181:
182: \outer\def\begin{\parsearg\beginxxx}
183:
184: \def\beginxxx #1{%
185: \expandafter\ifx\csname #1\endcsname\relax
186: {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
187: \csname #1\endcsname\fi}
188:
189: %% @end foo executes the definition of \Efoo.
190: %% foo can be delimited by doublequotes or brackets.
191:
192: \def\end{\parsearg\endxxx}
193:
194: \def\endxxx #1{%
195: \expandafter\ifx\csname E#1\endcsname\relax
196: \expandafter\ifx\csname #1\endcsname\relax
197: \errmessage{Undefined command @end #1}\else
198: \errorE{#1}\fi\fi
199: \csname E#1\endcsname}
200: \def\errorE#1{
201: {\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}}
202:
203: % Single-spacing is done by various environments.
204:
205: \newskip\singlespaceskip \singlespaceskip = \baselineskip
206: \def\singlespace{%
207: {\advance \baselineskip by -\singlespaceskip
208: \kern \baselineskip}%
209: \baselineskip=\singlespaceskip
210: }
211:
212: %% Simple single-character @ commands
213:
214: % @@ prints an @
215: % Kludge this until the fonts are right (grr).
216: \def\@{{\tt \char '100}}
217:
218: % Define @` and @' to be the same as ` and '
219: % but suppressing ligatures.
220: \def\`{{`}}
221: \def\'{{'}}
222:
223: % Used to generate quoted braces.
224:
225: \def\mylbrace {{\tt \char '173}}
226: \def\myrbrace {{\tt \char '175}}
227: \let\{=\mylbrace
228: \let\}=\myrbrace
229:
230: % @: forces normal size whitespace following.
231: \def\:{\spacefactor=1000 }
232:
233: % @* forces a line break.
234: \def\*{\hfil\break\hbox{}\ignorespaces}
235:
236: % @. is an end-of-sentence period.
237: \def\.{.\spacefactor=3000 }
238:
239: % @w prevents a word break
240: \def\w #1{\hbox{#1}}
241:
242: % @group ... @end group forces ... to be all on one page.
243:
244: \def\group{\begingroup% \inENV ???
245: \ifnum\catcode13=\active \else
246: \errmessage{@group invalid in context where filling is enabled}\fi
247: \def \Egroup{\egroup\endgroup}
248: \vbox\bgroup}
249:
250: % @need space-in-mils
251: % forces a page break if there is not space-in-mils remaining.
252:
253: \newdimen\mil \mil=0.001in
254:
255: \def\need{\parsearg\needx}
256:
257: \def\needx #1{\par %
258: % This method tries to make TeX break the page naturally
259: % if the depth of the box does not fit.
260: {\baselineskip=0pt%
261: \vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
262: \prevdepth=-1000pt
263: }}
264:
265: % @br forces paragraph break
266:
267: \let\br = \par
268:
269: % @dots{} output some dots
270:
271: \def\dots{$\ldots$}
272:
273: % @page forces the start of a new page
274:
275: \def\page{\par\vfill\supereject}
276:
277: % @exdent text....
278: % outputs text on separate line in roman font, starting at standard page margin
279:
280: \def\exdent{\errmessage{@exdent in filled text}}
281: % @lisp, etc, define \exdent locally from \internalexdent
282:
283: {\obeyspaces
284: \gdef\internalexdent{\parsearg\exdentzzz}}
285:
286: \def\exdentzzz #1{{\advance \leftskip by -\lispnarrowing
287: \advance \hsize by -\leftskip
288: \advance \hsize by -\rightskip
289: \leftline{{\rm#1}}}}
290:
291: % @include file insert text of that file as input.
292:
293: \def\include{\parsearg\includezzz}
294: \def\includezzz #1{{\def\thisfile{#1}\input #1
295: }}
296:
297: \def\thisfile{}
298:
299: % @center line outputs that line, centered
300:
301: \def\center{\parsearg\centerzzz}
302: \def\centerzzz #1{{\advance\hsize by -\leftskip
303: \advance\hsize by -\rightskip
304: \centerline{#1}}}
305:
306: % @sp n outputs n lines of vertical space
307:
308: \def\sp{\parsearg\spxxx}
309: \def\spxxx #1{\par \vskip #1\baselineskip}
310:
311: % @comment ...line which is ignored...
312: % @c is the same as @comment
313: % @ignore ... @end ignore is another way to write a comment
314:
315: \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
316: \parsearg \commentxxx}
317:
318: \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
319:
320: \let\c=\comment
321:
322: % Prevent errors for section commands.
323: % Used in @ignore and in failing conditionals.
324: \def\ignoresections{%
325: \let\chapter=\relax
326: \let\unnumbered=\relax
327: \let\top=\relax
328: \let\unnumberedsec=\relax
329: \let\unnumberedsection=\relax
330: \let\unnumberedsubsec=\relax
331: \let\unnumberedsubsection=\relax
332: \let\unnumberedsubsubsec=\relax
333: \let\unnumberedsubsubsection=\relax
334: \let\section=\relax
335: \let\subsec=\relax
336: \let\subsubsec=\relax
337: \let\subsection=\relax
338: \let\subsubsection=\relax
339: \let\appendix=\relax
340: \let\appendixsec=\relax
341: \let\appendixsection=\relax
342: \let\appendixsubsec=\relax
343: \let\appendixsubsection=\relax
344: \let\appendixsubsubsec=\relax
345: \let\appendixsubsubsection=\relax
346: \let\contents=\relax
347: \let\smallbook=\relax
348: \let\titlepage=\relax
349: }
350:
351: \def\ignore{\begingroup\ignoresections
352: % Make sure that spaces turn into tokens that match what \ignorexxx wants.
353: \catcode32=10
354: \ignorexxx}
355: \long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces}
356:
357: \def\direntry{\begingroup\direntryxxx}
358: \long\def\direntryxxx #1\end direntry{\endgroup\ignorespaces}
359:
360: % Conditionals to test whether a flag is set.
361:
362: \def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx}
363:
364: \def\ifsetxxx #1{\endgroup
365: \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail
366: \else \let\temp=\relax \fi
367: \temp}
368: \def\Eifset{}
369: \def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx}
370: \long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces}
371:
372: \def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx}
373:
374: \def\ifclearxxx #1{\endgroup
375: \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax
376: \else \let\temp=\ifclearfail \fi
377: \temp}
378: \def\Eifclear{}
379: \def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx}
380: \long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces}
381:
382: % @set foo to set the flag named foo.
383: % @clear foo to clear the flag named foo.
384: \def\set{\parsearg\setxxx}
385: \def\setxxx #1{
386: \expandafter\let\csname IF#1\endcsname=\set}
387:
388: \def\clear{\parsearg\clearxxx}
389: \def\clearxxx #1{
390: \expandafter\let\csname IF#1\endcsname=\relax}
391:
392: % Some texinfo constructs that are trivial in tex
393:
394: \def\iftex{}
395: \def\Eiftex{}
396: \def\ifinfo{\begingroup\ignoresections\ifinfoxxx}
397: \long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces}
398:
399: \long\def\menu #1\end menu{}
400: \def\asis#1{#1}
401:
402: % @math means output in math mode.
403: % We don't use $'s directly in the definition of \math because control
404: % sequences like \math are expanded when the toc file is written. Then,
405: % we read the toc file back, the $'s will be normal characters (as they
406: % should be, according to the definition of Texinfo). So we must use a
407: % control sequence to switch into and out of math mode.
408: %
409: % This isn't quite enough for @math to work properly in indices, but it
410: % seems unlikely it will ever be needed there.
411: %
412: \let\implicitmath = $
413: \def\math#1{\implicitmath #1\implicitmath}
414:
415: \def\node{\ENVcheck\parsearg\nodezzz}
416: \def\nodezzz#1{\nodexxx [#1,]}
417: \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
418: \let\lastnode=\relax
419:
420: \def\donoderef{\ifx\lastnode\relax\else
421: \expandafter\expandafter\expandafter\setref{\lastnode}\fi
422: \let\lastnode=\relax}
423:
424: \def\unnumbnoderef{\ifx\lastnode\relax\else
425: \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
426: \let\lastnode=\relax}
427:
428: \def\appendixnoderef{\ifx\lastnode\relax\else
429: \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
430: \let\lastnode=\relax}
431:
432: \let\refill=\relax
433:
434: % @setfilename is done at the beginning of every texinfo file.
435: % So open here the files we need to have open while reading the input.
436: % This makes it possible to make a .fmt file for texinfo.
437: \def\setfilename{%
438: \readauxfile
439: \opencontents
440: \openindices
441: \fixbackslash % Turn off hack to swallow `\input texinfo'.
442: \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
443: \comment % Ignore the actual filename.
444: }
445:
446: \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
447:
448: \def\inforef #1{\inforefzzz #1,,,,**}
449: \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}},
450: node \samp{\losespace#1{}}}
451: \def\losespace #1{#1}
452:
453: \message{fonts,}
454:
455: % Font-change commands.
456:
457: % Texinfo supports the sans serif font style, which plain TeX does not.
458: % So we set up a \sf analogous to plain's \rm, etc.
459: \newfam\sffam
460: \def\sf{\fam=\sffam \tensf}
461: \let\li = \sf % Sometimes we call it \li, not \sf.
462:
463: %% Try out Computer Modern fonts at \magstephalf
464: \let\mainmagstep=\magstephalf
465:
466: \ifx\bigger\relax
467: \let\mainmagstep=\magstep1
468: \font\textrm=cmr12
469: \font\texttt=cmtt12
470: \else
471: \font\textrm=cmr10 scaled \mainmagstep
472: \font\texttt=cmtt10 scaled \mainmagstep
473: \fi
474: % Instead of cmb10, you many want to use cmbx10.
475: % cmbx10 is a prettier font on its own, but cmb10
476: % looks better when embedded in a line with cmr10.
477: \font\textbf=cmb10 scaled \mainmagstep
478: \font\textit=cmti10 scaled \mainmagstep
479: \font\textsl=cmsl10 scaled \mainmagstep
480: \font\textsf=cmss10 scaled \mainmagstep
481: \font\textsc=cmcsc10 scaled \mainmagstep
482: \font\texti=cmmi10 scaled \mainmagstep
483: \font\textsy=cmsy10 scaled \mainmagstep
484:
485: % A few fonts for @defun, etc.
486: \font\defbf=cmbx10 scaled \magstep1 %was 1314
487: \font\deftt=cmtt10 scaled \magstep1
488: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
489:
490: % Fonts for indices and small examples.
491: % We actually use the slanted font rather than the italic,
492: % because texinfo normally uses the slanted fonts for that.
493: % Do not make many font distinctions in general in the index, since they
494: % aren't very useful.
495: \font\ninett=cmtt9
496: \font\indrm=cmr9
497: \font\indit=cmsl9
498: \let\indsl=\indit
499: \let\indtt=\ninett
500: \let\indsf=\indrm
501: \let\indbf=\indrm
502: \let\indsc=\indrm
503: \font\indi=cmmi9
504: \font\indsy=cmsy9
505:
506: % Fonts for headings
507: \font\chaprm=cmbx12 scaled \magstep2
508: \font\chapit=cmti12 scaled \magstep2
509: \font\chapsl=cmsl12 scaled \magstep2
510: \font\chaptt=cmtt12 scaled \magstep2
511: \font\chapsf=cmss12 scaled \magstep2
512: \let\chapbf=\chaprm
513: \font\chapsc=cmcsc10 scaled\magstep3
514: \font\chapi=cmmi12 scaled \magstep2
515: \font\chapsy=cmsy10 scaled \magstep3
516:
517: \font\secrm=cmbx12 scaled \magstep1
518: \font\secit=cmti12 scaled \magstep1
519: \font\secsl=cmsl12 scaled \magstep1
520: \font\sectt=cmtt12 scaled \magstep1
521: \font\secsf=cmss12 scaled \magstep1
522: \font\secbf=cmbx12 scaled \magstep1
523: \font\secsc=cmcsc10 scaled\magstep2
524: \font\seci=cmmi12 scaled \magstep1
525: \font\secsy=cmsy10 scaled \magstep2
526:
527: % \font\ssecrm=cmbx10 scaled \magstep1 % This size an font looked bad.
528: % \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded.
529: % \font\ssecsl=cmsl10 scaled \magstep1
530: % \font\ssectt=cmtt10 scaled \magstep1
531: % \font\ssecsf=cmss10 scaled \magstep1
532:
533: %\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx.
534: %\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than
535: %\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1.
536: %\font\ssectt=cmtt10 scaled 1315
537: %\font\ssecsf=cmss10 scaled 1315
538:
539: %\let\ssecbf=\ssecrm
540:
541: \font\ssecrm=cmbx12 scaled \magstephalf
542: \font\ssecit=cmti12 scaled \magstephalf
543: \font\ssecsl=cmsl12 scaled \magstephalf
544: \font\ssectt=cmtt12 scaled \magstephalf
545: \font\ssecsf=cmss12 scaled \magstephalf
546: \font\ssecbf=cmbx12 scaled \magstephalf
547: \font\ssecsc=cmcsc10 scaled \magstep1
548: \font\sseci=cmmi12 scaled \magstephalf
549: \font\ssecsy=cmsy10 scaled \magstep1
550: % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
551: % but that is not a standard magnification.
552:
553: % Fonts for title page:
554: \font\titlerm = cmbx12 scaled \magstep3
555: \let\authorrm = \secrm
556:
557: % In order for the font changes to affect most math symbols and letters,
558: % we have to define the \textfont of the standard families. Since
559: % texinfo doesn't allow for producing subscripts and superscripts, we
560: % don't bother to reset \scriptfont and \scriptscriptfont (which would
561: % also require loading a lot more fonts).
562: %
563: \def\resetmathfonts{%
564: \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
565: \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
566: \textfont\ttfam = \tentt \textfont\sffam = \tensf
567: }
568:
569:
570: % The font-changing commands redefine the meanings of \tenSTYLE, instead
571: % of just \STYLE. We do this so that font changes will continue to work
572: % in math mode, where it is the current \fam that is relevant in most
573: % cases, not the current. Plain TeX does, for example,
574: % \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need
575: % to redefine \bf itself.
576: \def\textfonts{%
577: \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
578: \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
579: \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
580: \resetmathfonts}
581: \def\chapfonts{%
582: \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
583: \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
584: \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
585: \resetmathfonts}
586: \def\secfonts{%
587: \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
588: \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
589: \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
590: \resetmathfonts}
591: \def\subsecfonts{%
592: \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
593: \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
594: \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
595: \resetmathfonts}
596: \def\indexfonts{%
597: \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
598: \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
599: \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
600: \resetmathfonts}
601:
602: % Set up the default fonts, so we can use them for creating boxes.
603: %
604: \textfonts
605:
606: % Count depth in font-changes, for error checks
607: \newcount\fontdepth \fontdepth=0
608:
609: % Fonts for short table of contents.
610: \font\shortcontrm=cmr12
611: \font\shortcontbf=cmbx12
612: \font\shortcontsl=cmsl12
613:
614: %% Add scribe-like font environments, plus @l for inline lisp (usually sans
615: %% serif) and @ii for TeX italic
616:
617: % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
618: % unless the following character is such as not to need one.
619: \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
620: \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
621:
622: \let\i=\smartitalic
623: \let\var=\smartitalic
624: \let\dfn=\smartitalic
625: \let\emph=\smartitalic
626: \let\cite=\smartitalic
627:
628: \def\b#1{{\bf #1}}
629: \let\strong=\b
630:
631: \def\t#1{{\tt \exhyphenpenalty=10000\rawbackslash \frenchspacing #1}\null}
632: \let\ttfont = \t
633: %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
634: \def\samp #1{`\tclose{#1}'\null}
635: \def\key #1{{\tt \exhyphenpenalty=10000\uppercase{#1}}\null}
636: \def\ctrl #1{{\tt \rawbackslash \hat}#1}
637:
638: \let\file=\samp
639:
640: % @code is a modification of @t,
641: % which makes spaces the same size as normal in the surrounding text.
642: \newdimen\tclosesave
643: \newdimen\tcloserm
644: \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
645: \fontdimen2\font=\tcloserm
646: % prevent breaking lines at hyphens.
647: \exhyphenpenalty=10000
648: \def\ {{\fontdimen2\font=\tclosesave{} }}%
649: \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
650: \let\code=\tclose
651: %\let\exp=\tclose %Was temporary
652:
653: % @kbd is like @code, except that if the argument is just one @key command,
654: % then @kbd has no effect.
655:
656: \def\xkey{\key}
657: \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
658: \ifx\one\xkey\ifx\threex\three \key{#2}%
659: \else\tclose{\look}\fi
660: \else\tclose{\look}\fi}
661:
662: % Typeset a dimension, e.g., `in' or `pt'. The only reason for the
663: % argument is to make the input look right: @dmn{pt} instead of
664: % @dmn{}pt.
665: %
666: \def\dmn#1{\thinspace #1}
667:
668: \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
669:
670: \def\l#1{{\li #1}\null} %
671:
672: \def\r#1{{\rm #1}} % roman font
673: % Use of \lowercase was suggested.
674: \def\sc#1{{\smallcaps#1}} % smallcaps font
675: \def\ii#1{{\it #1}} % italic font
676:
677: \message{page headings,}
678:
679: \newskip\titlepagetopglue \titlepagetopglue = 1.5in
680: \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
681:
682: % First the title page. Must do @settitle before @titlepage.
683: \def\titlefont#1{{\titlerm #1}}
684:
685: \newtoks\realeverypar
686: \newif\ifseenauthor
687: \newif\iffinishedtitlepage
688:
689: \def\titlepage{\begingroup \parindent=0pt \textfonts
690: \let\subtitlerm=\tenrm
691: % I deinstalled the following change because \cmr12 is undefined.
692: % This change was not in the ChangeLog anyway. --rms.
693: % \let\subtitlerm=\cmr12
694: \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
695: %
696: \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
697: %
698: % Leave some space at the very top of the page.
699: \vglue\titlepagetopglue
700: %
701: % Now you can print the title using @title.
702: \def\title{\parsearg\titlezzz}%
703: \def\titlezzz##1{\leftline{\titlefont{##1}}
704: % print a rule at the page bottom also.
705: \finishedtitlepagefalse
706: \vskip4pt \hrule height 4pt \vskip4pt}%
707: % No rule at page bottom unless we print one at the top with @title.
708: \finishedtitlepagetrue
709: %
710: % Now you can put text using @subtitle.
711: \def\subtitle{\parsearg\subtitlezzz}%
712: \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
713: %
714: % @author should come last, but may come many times.
715: \def\author{\parsearg\authorzzz}%
716: \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
717: {\authorfont \leftline{##1}}}%
718: %
719: % Most title ``pages'' are actually two pages long, with space
720: % at the top of the second. We don't want the ragged left on the second.
721: \let\oldpage = \page
722: \def\page{%
723: \iffinishedtitlepage\else
724: \finishtitlepage
725: \fi
726: \oldpage
727: \let\page = \oldpage
728: \hbox{}}%
729: % \def\page{\oldpage \hbox{}}
730: }
731:
732: \def\Etitlepage{%
733: \iffinishedtitlepage\else
734: \finishtitlepage
735: \fi
736: % It is important to do the page break before ending the group,
737: % because the headline and footline are only empty inside the group.
738: % If we use the new definition of \page, we always get a blank page
739: % after the title page, which we certainly don't want.
740: \oldpage
741: \endgroup
742: \HEADINGSon
743: }
744:
745: \def\finishtitlepage{%
746: \vskip4pt \hrule height 2pt
747: \vskip\titlepagebottomglue
748: \finishedtitlepagetrue
749: }
750:
751: %%% Set up page headings and footings.
752:
753: \let\thispage=\folio
754:
755: \newtoks \evenheadline % Token sequence for heading line of even pages
756: \newtoks \oddheadline % Token sequence for heading line of odd pages
757: \newtoks \evenfootline % Token sequence for footing line of even pages
758: \newtoks \oddfootline % Token sequence for footing line of odd pages
759:
760: % Now make Tex use those variables
761: \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
762: \else \the\evenheadline \fi}}
763: \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
764: \else \the\evenfootline \fi}\HEADINGShook}
765: \let\HEADINGShook=\relax
766:
767: % Commands to set those variables.
768: % For example, this is what @headings on does
769: % @evenheading @thistitle|@thispage|@thischapter
770: % @oddheading @thischapter|@thispage|@thistitle
771: % @evenfooting @thisfile||
772: % @oddfooting ||@thisfile
773:
774: \def\evenheading{\parsearg\evenheadingxxx}
775: \def\oddheading{\parsearg\oddheadingxxx}
776: \def\everyheading{\parsearg\everyheadingxxx}
777:
778: \def\evenfooting{\parsearg\evenfootingxxx}
779: \def\oddfooting{\parsearg\oddfootingxxx}
780: \def\everyfooting{\parsearg\everyfootingxxx}
781:
782: {\catcode`\@=0 %
783:
784: \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
785: \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
786: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
787:
788: \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
789: \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
790: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
791:
792: \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
793: \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
794: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
795: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
796:
797: \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
798: \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
799: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
800:
801: \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
802: \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
803: \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
804:
805: \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
806: \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
807: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
808: \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
809: %
810: }% unbind the catcode of @.
811:
812: % @headings double turns headings on for double-sided printing.
813: % @headings single turns headings on for single-sided printing.
814: % @headings off turns them off.
815: % @headings on same as @headings double, retained for compatibility.
816: % @headings after turns on double-sided headings after this page.
817: % @headings doubleafter turns on double-sided headings after this page.
818: % @headings singleafter turns on single-sided headings after this page.
819: % By default, they are off.
820:
821: \def\headings #1 {\csname HEADINGS#1\endcsname}
822:
823: \def\HEADINGSoff{
824: \global\evenheadline={\hfil} \global\evenfootline={\hfil}
825: \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
826: \HEADINGSoff
827: % When we turn headings on, set the page number to 1.
828: % For double-sided printing, put current file name in lower left corner,
829: % chapter name on inside top of right hand pages, document
830: % title on inside top of left hand pages, and page numbers on outside top
831: % edge of all pages.
832: \def\HEADINGSdouble{
833: %\pagealignmacro
834: \global\pageno=1
835: \global\evenfootline={\hfil}
836: \global\oddfootline={\hfil}
837: \global\evenheadline={\line{\folio\hfil\thistitle}}
838: \global\oddheadline={\line{\thischapter\hfil\folio}}
839: }
840: % For single-sided printing, chapter title goes across top left of page,
841: % page number on top right.
842: \def\HEADINGSsingle{
843: %\pagealignmacro
844: \global\pageno=1
845: \global\evenfootline={\hfil}
846: \global\oddfootline={\hfil}
847: \global\evenheadline={\line{\thischapter\hfil\folio}}
848: \global\oddheadline={\line{\thischapter\hfil\folio}}
849: }
850: \def\HEADINGSon{\HEADINGSdouble}
851:
852: \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
853: \let\HEADINGSdoubleafter=\HEADINGSafter
854: \def\HEADINGSdoublex{%
855: \global\evenfootline={\hfil}
856: \global\oddfootline={\hfil}
857: \global\evenheadline={\line{\folio\hfil\thistitle}}
858: \global\oddheadline={\line{\thischapter\hfil\folio}}
859: }
860:
861: \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
862: \def\HEADINGSsinglex{%
863: \global\evenfootline={\hfil}
864: \global\oddfootline={\hfil}
865: \global\evenheadline={\line{\thischapter\hfil\folio}}
866: \global\oddheadline={\line{\thischapter\hfil\folio}}
867: }
868:
869: % Subroutines used in generating headings
870: % Produces Day Month Year style of output.
871: \def\today{\number\day\space
872: \ifcase\month\or
873: January\or February\or March\or April\or May\or June\or
874: July\or August\or September\or October\or November\or December\fi
875: \space\number\year}
876:
877: % Use this if you want the Month Day, Year style of output.
878: %\def\today{\ifcase\month\or
879: %January\or February\or March\or April\or May\or June\or
880: %July\or August\or September\or October\or November\or December\fi
881: %\space\number\day, \number\year}
882:
883: % @settitle line... specifies the title of the document, for headings
884: % It generates no output of its own
885:
886: \def\thistitle{No Title}
887: \def\settitle{\parsearg\settitlezzz}
888: \def\settitlezzz #1{\gdef\thistitle{#1}}
889:
890: \message{tables,}
891:
892: % @tabs -- simple alignment
893:
894: % These don't work. For one thing, \+ is defined as outer.
895: % So these macros cannot even be defined.
896:
897: %\def\tabs{\parsearg\tabszzz}
898: %\def\tabszzz #1{\settabs\+#1\cr}
899: %\def\tabline{\parsearg\tablinezzz}
900: %\def\tablinezzz #1{\+#1\cr}
901: %\def\&{&}
902:
903: % Tables -- @table, @ftable, @item(x), @kitem(x), @xitem(x).
904:
905: % default indentation of table text
906: \newdimen\tableindent \tableindent=.8in
907: % default indentation of @itemize and @enumerate text
908: \newdimen\itemindent \itemindent=.3in
909: % margin between end of table item and start of table text.
910: \newdimen\itemmargin \itemmargin=.1in
911:
912: % used internally for \itemindent minus \itemmargin
913: \newdimen\itemmax
914:
915: % Note @table and @ftable define @item, @itemx, etc., with these defs.
916: % They also define \itemindex
917: % to index the item name in whatever manner is desired (perhaps none).
918:
919: \def\internalBitem{\smallbreak \parsearg\itemzzz}
920: \def\internalBitemx{\par \parsearg\itemzzz}
921:
922: \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
923: \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
924:
925: \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
926: \def\internalBkitemx{\par \parsearg\kitemzzz}
927:
928: \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
929: \itemzzz {#1}}
930:
931: \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
932: \itemzzz {#1}}
933:
934: \def\itemzzz #1{\begingroup %
935: \advance\hsize by -\rightskip
936: \advance\hsize by -\tableindent
937: \setbox0=\hbox{\itemfont{#1}}%
938: \itemindex{#1}%
939: \nobreak % This prevents a break before @itemx.
940: %
941: % Be sure we are not still in the middle of a paragraph.
942: \parskip=0in
943: \par
944: %
945: % If the item text does not fit in the space we have, put it on a line
946: % by itself, and do not allow a page break either before or after that
947: % line. We do not start a paragraph here because then if the next
948: % command is, e.g., @kindex, the whatsit would get put into the
949: % horizontal list on a line by itself, resulting in extra blank space.
950: \ifdim \wd0>\itemmax
951: \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0
952: \nobreak
953: \else
954: % The item text fits into the space. Start a paragraph, so that the
955: % following text (if any) will end up on the same line. Since that
956: % text will be indented by \tableindent, we make the item text be in
957: % a zero-width box.
958: \noindent
959: \rlap{\hskip -\tableindent\box0}%
960: \fi
961: \endgroup
962: }
963:
964: \def\item{\errmessage{@item while not in a table}}
965: \def\itemx{\errmessage{@itemx while not in a table}}
966: \def\kitem{\errmessage{@kitem while not in a table}}
967: \def\kitemx{\errmessage{@kitemx while not in a table}}
968: \def\xitem{\errmessage{@xitem while not in a table}}
969: \def\xitemx{\errmessage{@xitemx while not in a table}}
970:
971: %% Contains a kludge to get @end[description] to work
972: \def\description{\tablez{\dontindex}{1}{}{}{}{}}
973:
974: \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
975: {\obeylines\obeyspaces%
976: \gdef\tablex #1^^M{%
977: \tabley\dontindex#1 \endtabley}}
978:
979: \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
980: {\obeylines\obeyspaces%
981: \gdef\ftablex #1^^M{%
982: \tabley\fnitemindex#1 \endtabley
983: \def\Eftable{\endgraf\endgroup\afterenvbreak}%
984: \let\Etable=\relax}}
985:
986: \def\dontindex #1{}
987: \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
988:
989: {\obeyspaces %
990: \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
991: \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
992:
993: \def\tablez #1#2#3#4#5#6{%
994: \aboveenvbreak %
995: \begingroup %
996: \def\Edescription{\Etable}% Neccessary kludge.
997: \let\itemindex=#1%
998: \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
999: \ifnum 0#4>0 \tableindent=#4\mil \fi %
1000: \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
1001: \def\itemfont{#2}%
1002: \itemmax=\tableindent %
1003: \advance \itemmax by -\itemmargin %
1004: \advance \leftskip by \tableindent %
1005: \parindent = 0pt
1006: \parskip = \smallskipamount
1007: \ifdim \parskip=0pt \parskip=2pt \fi%
1008: \def\Etable{\endgraf\endgroup\afterenvbreak}%
1009: \let\item = \internalBitem %
1010: \let\itemx = \internalBitemx %
1011: \let\kitem = \internalBkitem %
1012: \let\kitemx = \internalBkitemx %
1013: \let\xitem = \internalBxitem %
1014: \let\xitemx = \internalBxitemx %
1015: }
1016:
1017: % This is the counter used by @enumerate, which is really @itemize
1018:
1019: \newcount \itemno
1020:
1021: \def\itemize{\parsearg\itemizezzz}
1022:
1023: \def\itemizezzz #1{%
1024: \begingroup % ended by the @end itemsize
1025: \itemizey {#1}{\Eitemize}
1026: }
1027:
1028: \def\itemizey #1#2{%
1029: \aboveenvbreak %
1030: \itemmax=\itemindent %
1031: \advance \itemmax by -\itemmargin %
1032: \advance \leftskip by \itemindent %
1033: \parindent = 0pt %
1034: \parskip = \smallskipamount %
1035: \ifdim \parskip=0pt \parskip=2pt \fi%
1036: \def#2{\endgraf\endgroup\afterenvbreak}%
1037: \def\itemcontents{#1}%
1038: \let\item=\itemizeitem}
1039:
1040: \def\bullet{$\ptexbullet$}
1041: \def\minus{$-$}
1042:
1043: % Set sfcode to normal for the chars that usually have another value.
1044: % These are `.?!:;,'
1045: \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
1046: \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
1047:
1048: % \splitoff TOKENS\endmark defines \first to be the first token in
1049: % TOKENS, and \rest to be the remainder.
1050: %
1051: \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
1052:
1053: % Allow an optional argument of an uppercase letter, lowercase letter,
1054: % or number, to specify the first label in the enumerated list. No
1055: % argument is the same as `1'.
1056: %
1057: \def\enumerate{\parsearg\enumeratezzz}
1058: \def\enumeratezzz #1{\enumeratey #1 \endenumeratey}
1059: \def\enumeratey #1 #2\endenumeratey{%
1060: \begingroup % ended by the @end enumerate
1061: %
1062: % If we were given no argument, pretend we were given `1'.
1063: \def\thearg{#1}%
1064: \ifx\thearg\empty \def\thearg{1}\fi
1065: %
1066: % Detect if the argument is a single token. If so, it might be a
1067: % letter. Otherwise, the only valid thing it can be is a number.
1068: % (We will always have one token, because of the test we just made.
1069: % This is a good thing, since \splitoff doesn't work given nothing at
1070: % all -- the first parameter is undelimited.)
1071: \expandafter\splitoff\thearg\endmark
1072: \ifx\rest\empty
1073: % Only one token in the argument. It could still be anything.
1074: % A ``lowercase letter'' is one whose \lccode is nonzero.
1075: % An ``uppercase letter'' is one whose \lccode is both nonzero, and
1076: % not equal to itself.
1077: % Otherwise, we assume it's a number.
1078: %
1079: % We need the \relax at the end of the \ifnum lines to stop TeX from
1080: % continuing to look for a <number>.
1081: %
1082: \ifnum\lccode\expandafter`\thearg=0\relax
1083: \numericenumerate % a number (we hope)
1084: \else
1085: % It's a letter.
1086: \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
1087: \lowercaseenumerate % lowercase letter
1088: \else
1089: \uppercaseenumerate % uppercase letter
1090: \fi
1091: \fi
1092: \else
1093: % Multiple tokens in the argument. We hope it's a number.
1094: \numericenumerate
1095: \fi
1096: }
1097:
1098: % An @enumerate whose labels are integers. The starting integer is
1099: % given in \thearg.
1100: %
1101: \def\numericenumerate{%
1102: \itemno = \thearg
1103: \startenumeration{\the\itemno}%
1104: }
1105:
1106: % The starting (lowercase) letter is in \thearg.
1107: \def\lowercaseenumerate{%
1108: \itemno = \expandafter`\thearg
1109: \startenumeration{%
1110: % Be sure we're not beyond the end of the alphabet.
1111: \ifnum\itemno=0
1112: \errmessage{No more lowercase letters in @enumerate; get a bigger
1113: alphabet}%
1114: \fi
1115: \char\lccode\itemno
1116: }%
1117: }
1118:
1119: % The starting (uppercase) letter is in \thearg.
1120: \def\uppercaseenumerate{%
1121: \itemno = \expandafter`\thearg
1122: \startenumeration{%
1123: % Be sure we're not beyond the end of the alphabet.
1124: \ifnum\itemno=0
1125: \errmessage{No more uppercase letters in @enumerate; get a bigger
1126: alphabet}
1127: \fi
1128: \char\uccode\itemno
1129: }%
1130: }
1131:
1132: % Call itemizey, adding a period to the first argument and supplying the
1133: % common last two arguments. Also subtract one from the initial value in
1134: % \itemno, since @item increments \itemno.
1135: %
1136: \def\startenumeration#1{%
1137: \advance\itemno by -1
1138: \itemizey{#1.}\Eenumerate\flushcr
1139: }
1140:
1141: % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
1142: % to @enumerate.
1143: %
1144: \def\alphaenumerate{\enumerate{a}}
1145: \def\capsenumerate{\enumerate{A}}
1146: \def\Ealphaenumerate{\Eenumerate}
1147: \def\Ecapsenumerate{\Eenumerate}
1148:
1149: % Definition of @item while inside @itemize.
1150:
1151: \def\itemizeitem{%
1152: \advance\itemno by 1
1153: {\let\par=\endgraf \smallbreak}%
1154: \ifhmode \errmessage{\in hmode at itemizeitem}\fi
1155: {\parskip=0in \hskip 0pt
1156: \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
1157: \vadjust{\penalty 1200}}%
1158: \flushcr}
1159:
1160: \message{indexing,}
1161: % Index generation facilities
1162:
1163: % Define \newwrite to be identical to plain tex's \newwrite
1164: % except not \outer, so it can be used within \newindex.
1165: {\catcode`\@=11
1166: \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
1167:
1168: % \newindex {foo} defines an index named foo.
1169: % It automatically defines \fooindex such that
1170: % \fooindex ...rest of line... puts an entry in the index foo.
1171: % It also defines \fooindfile to be the number of the output channel for
1172: % the file that accumulates this index. The file's extension is foo.
1173: % The name of an index should be no more than 2 characters long
1174: % for the sake of vms.
1175:
1176: \def\newindex #1{
1177: \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
1178: \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
1179: \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
1180: \noexpand\doindex {#1}}
1181: }
1182:
1183: % @defindex foo == \newindex{foo}
1184:
1185: \def\defindex{\parsearg\newindex}
1186:
1187: % Define @defcodeindex, like @defindex except put all entries in @code.
1188:
1189: \def\newcodeindex #1{
1190: \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
1191: \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
1192: \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
1193: \noexpand\docodeindex {#1}}
1194: }
1195:
1196: \def\defcodeindex{\parsearg\newcodeindex}
1197:
1198: % @synindex foo bar makes index foo feed into index bar.
1199: % Do this instead of @defindex foo if you don't want it as a separate index.
1200: \def\synindex #1 #2 {%
1201: \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
1202: \expandafter\let\csname#1indfile\endcsname=\synindexfoo
1203: \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
1204: \noexpand\doindex {#2}}%
1205: }
1206:
1207: % @syncodeindex foo bar similar, but put all entries made for index foo
1208: % inside @code.
1209: \def\syncodeindex #1 #2 {%
1210: \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
1211: \expandafter\let\csname#1indfile\endcsname=\synindexfoo
1212: \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex
1213: \noexpand\docodeindex {#2}}%
1214: }
1215:
1216: % Define \doindex, the driver for all \fooindex macros.
1217: % Argument #1 is generated by the calling \fooindex macro,
1218: % and it is "foo", the name of the index.
1219:
1220: % \doindex just uses \parsearg; it calls \doind for the actual work.
1221: % This is because \doind is more useful to call from other macros.
1222:
1223: % There is also \dosubind {index}{topic}{subtopic}
1224: % which makes an entry in a two-level index such as the operation index.
1225:
1226: \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
1227: \def\singleindexer #1{\doind{\indexname}{#1}}
1228:
1229: % like the previous two, but they put @code around the argument.
1230: \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
1231: \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
1232:
1233: \def\indexdummies{%
1234: \def\_{{\realbackslash _}}%
1235: \def\w{\realbackslash w }%
1236: \def\bf{\realbackslash bf }%
1237: \def\rm{\realbackslash rm }%
1238: \def\sl{\realbackslash sl }%
1239: \def\sf{\realbackslash sf}%
1240: \def\tt{\realbackslash tt}%
1241: \def\gtr{\realbackslash gtr}%
1242: \def\less{\realbackslash less}%
1243: \def\hat{\realbackslash hat}%
1244: \def\char{\realbackslash char}%
1245: \def\TeX{\realbackslash TeX}%
1246: \def\dots{\realbackslash dots }%
1247: \def\copyright{\realbackslash copyright }%
1248: \def\tclose##1{\realbackslash tclose {##1}}%
1249: \def\code##1{\realbackslash code {##1}}%
1250: \def\samp##1{\realbackslash samp {##1}}%
1251: \def\t##1{\realbackslash r {##1}}%
1252: \def\r##1{\realbackslash r {##1}}%
1253: \def\i##1{\realbackslash i {##1}}%
1254: \def\b##1{\realbackslash b {##1}}%
1255: \def\cite##1{\realbackslash cite {##1}}%
1256: \def\key##1{\realbackslash key {##1}}%
1257: \def\file##1{\realbackslash file {##1}}%
1258: \def\var##1{\realbackslash var {##1}}%
1259: \def\kbd##1{\realbackslash kbd {##1}}%
1260: }
1261:
1262: % \indexnofonts no-ops all font-change commands.
1263: % This is used when outputting the strings to sort the index by.
1264: \def\indexdummyfont#1{#1}
1265: \def\indexdummytex{TeX}
1266: \def\indexdummydots{...}
1267:
1268: \def\indexnofonts{%
1269: \let\w=\indexdummyfont
1270: \let\t=\indexdummyfont
1271: \let\r=\indexdummyfont
1272: \let\i=\indexdummyfont
1273: \let\b=\indexdummyfont
1274: \let\emph=\indexdummyfont
1275: \let\strong=\indexdummyfont
1276: \let\cite=\indexdummyfont
1277: \let\sc=\indexdummyfont
1278: %Don't no-op \tt, since it isn't a user-level command
1279: % and is used in the definitions of the active chars like <, >, |...
1280: %\let\tt=\indexdummyfont
1281: \let\tclose=\indexdummyfont
1282: \let\code=\indexdummyfont
1283: \let\file=\indexdummyfont
1284: \let\samp=\indexdummyfont
1285: \let\kbd=\indexdummyfont
1286: \let\key=\indexdummyfont
1287: \let\var=\indexdummyfont
1288: \let\TeX=\indexdummytex
1289: \let\dots=\indexdummydots
1290: }
1291:
1292: % To define \realbackslash, we must make \ not be an escape.
1293: % We must first make another character (@) an escape
1294: % so we do not become unable to do a definition.
1295:
1296: {\catcode`\@=0 \catcode`\\=\other
1297: @gdef@realbackslash{\}}
1298:
1299: \let\indexbackslash=0 %overridden during \printindex.
1300:
1301: \def\doind #1#2{%
1302: {\count10=\lastpenalty %
1303: {\indexdummies % Must do this here, since \bf, etc expand at this stage
1304: \escapechar=`\\%
1305: {\let\folio=0% Expand all macros now EXCEPT \folio
1306: \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
1307: % so it will be output as is; and it will print as backslash in the indx.
1308: %
1309: % Now process the index-string once, with all font commands turned off,
1310: % to get the string to sort the index by.
1311: {\indexnofonts
1312: \xdef\temp1{#2}%
1313: }%
1314: % Now produce the complete index entry. We process the index-string again,
1315: % this time with font commands expanded, to get what to print in the index.
1316: \edef\temp{%
1317: \write \csname#1indfile\endcsname{%
1318: \realbackslash entry {\temp1}{\folio}{#2}}}%
1319: \temp }%
1320: }\penalty\count10}}
1321:
1322: \def\dosubind #1#2#3{%
1323: {\count10=\lastpenalty %
1324: {\indexdummies % Must do this here, since \bf, etc expand at this stage
1325: \escapechar=`\\%
1326: {\let\folio=0%
1327: \def\rawbackslashxx{\indexbackslash}%
1328: %
1329: % Now process the index-string once, with all font commands turned off,
1330: % to get the string to sort the index by.
1331: {\indexnofonts
1332: \xdef\temp1{#2 #3}%
1333: }%
1334: % Now produce the complete index entry. We process the index-string again,
1335: % this time with font commands expanded, to get what to print in the index.
1336: \edef\temp{%
1337: \write \csname#1indfile\endcsname{%
1338: \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
1339: \temp }%
1340: }\penalty\count10}}
1341:
1342: % The index entry written in the file actually looks like
1343: % \entry {sortstring}{page}{topic}
1344: % or
1345: % \entry {sortstring}{page}{topic}{subtopic}
1346: % The texindex program reads in these files and writes files
1347: % containing these kinds of lines:
1348: % \initial {c}
1349: % before the first topic whose initial is c
1350: % \entry {topic}{pagelist}
1351: % for a topic that is used without subtopics
1352: % \primary {topic}
1353: % for the beginning of a topic that is used with subtopics
1354: % \secondary {subtopic}{pagelist}
1355: % for each subtopic.
1356:
1357: % Define the user-accessible indexing commands
1358: % @findex, @vindex, @kindex, @cindex.
1359:
1360: \def\findex {\fnindex}
1361: \def\kindex {\kyindex}
1362: \def\cindex {\cpindex}
1363: \def\vindex {\vrindex}
1364: \def\tindex {\tpindex}
1365: \def\pindex {\pgindex}
1366:
1367: \def\cindexsub {\begingroup\obeylines\cindexsub}
1368: {\obeylines %
1369: \gdef\cindexsub "#1" #2^^M{\endgroup %
1370: \dosubind{cp}{#2}{#1}}}
1371:
1372: % Define the macros used in formatting output of the sorted index material.
1373:
1374: % This is what you call to cause a particular index to get printed.
1375: % Write
1376: % @unnumbered Function Index
1377: % @printindex fn
1378:
1379: \def\printindex{\parsearg\doprintindex}
1380:
1381: \def\doprintindex#1{%
1382: \tex
1383: \dobreak \chapheadingskip {10000}
1384: \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
1385: \catcode`\$=\other\catcode`\_=\other
1386: \catcode`\~=\other
1387: %
1388: % The following don't help, since the chars were translated
1389: % when the raw index was written, and their fonts were discarded
1390: % due to \indexnofonts.
1391: %\catcode`\"=\active
1392: %\catcode`\^=\active
1393: %\catcode`\_=\active
1394: %\catcode`\|=\active
1395: %\catcode`\<=\active
1396: %\catcode`\>=\active
1397: % %
1398: \def\indexbackslash{\rawbackslashxx}
1399: \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
1400: \begindoublecolumns
1401: %
1402: % See if the index file exists and is nonempty.
1403: \openin 1 \jobname.#1s
1404: \ifeof 1
1405: % \enddoublecolumns gets confused if there is no text in the index,
1406: % and it loses the chapter title and the aux file entries for the
1407: % index. The easiest way to prevent this problem is to make sure
1408: % there is some text.
1409: (Index is nonexistent)
1410: \else
1411: %
1412: % If the index file exists but is empty, then \openin leaves \ifeof
1413: % false. We have to make TeX try to read something from the file, so
1414: % it can discover if there is anything in it.
1415: \read 1 to \temp
1416: \ifeof 1
1417: (Index is empty)
1418: \else
1419: \input \jobname.#1s
1420: \fi
1421: \fi
1422: \closein 1
1423: \enddoublecolumns
1424: \Etex
1425: }
1426:
1427: % These macros are used by the sorted index file itself.
1428: % Change them to control the appearance of the index.
1429:
1430: % Same as \bigskipamount except no shrink.
1431: % \balancecolumns gets confused if there is any shrink.
1432: \newskip\initialskipamount \initialskipamount 12pt plus4pt
1433:
1434: \def\initial #1{%
1435: {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
1436: \ifdim\lastskip<\initialskipamount
1437: \removelastskip \penalty-200 \vskip \initialskipamount\fi
1438: \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
1439:
1440: \def\entry #1#2{
1441: {\parfillskip=0in \parskip=0in \parindent=0in
1442: \hangindent=1in \hangafter=1%
1443: \noindent\hbox{#1}\indexdotfill #2\par
1444: }}
1445:
1446: % Like \dotfill except takes at least 1 em.
1447: \def\indexdotfill{\cleaders
1448: \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill}
1449:
1450: \def\primary #1{\line{#1\hfil}}
1451:
1452: \newskip\secondaryindent \secondaryindent=0.5cm
1453:
1454: \def\secondary #1#2{
1455: {\parfillskip=0in \parskip=0in
1456: \hangindent =1in \hangafter=1
1457: \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
1458: }}
1459:
1460: %% Define two-column mode, which is used in indexes.
1461: %% Adapted from the TeXBook, page 416
1462: \catcode `\@=11
1463:
1464: \newbox\partialpage
1465:
1466: \newdimen\doublecolumnhsize \doublecolumnhsize = 3.11in
1467: \newdimen\doublecolumnvsize \doublecolumnvsize = 19.1in
1468: \newdimen\availdimen@
1469:
1470: \def\begindoublecolumns{\begingroup
1471: \output={\global\setbox\partialpage=
1472: \vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject
1473: \output={\doublecolumnout}%
1474: \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize}
1475: \def\enddoublecolumns{\output={\balancecolumns}\eject
1476: \endgroup \pagegoal=\vsize}
1477:
1478: \def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
1479: \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
1480: \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
1481: \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
1482: \def\pagesofar{\unvbox\partialpage %
1483: \hsize=\doublecolumnhsize % have to restore this since output routine
1484: % changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
1485: \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
1486: \def\balancecolumns{%
1487: % Unset the glue.
1488: \setbox255=\vbox{\unvbox255}
1489: \dimen@=\ht255
1490: \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
1491: \divide\dimen@ by2
1492: \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage
1493: % If the remaining data is too big for one page,
1494: % output one page normally, then work with what remains.
1495: \ifdim \dimen@>\availdimen@
1496: {
1497: \splittopskip=\topskip \splitmaxdepth=\maxdepth
1498: \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
1499: \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
1500: \onepageout\pagesofar
1501: }
1502: % Recompute size of what remains, in case we just output some of it.
1503: \dimen@=\ht255
1504: \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
1505: \divide\dimen@ by2
1506: \fi
1507: \setbox0=\vbox{\unvbox255}
1508: \splittopskip=\topskip
1509: {\vbadness=10000 \loop \global\setbox3=\copy0
1510: \global\setbox1=\vsplit3 to\dimen@
1511: \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
1512: \setbox0=\vbox to\dimen@{\unvbox1} \setbox2=\vbox to\dimen@{\unvbox3}
1513: \pagesofar}
1514:
1515: \catcode `\@=\other
1516: \message{sectioning,}
1517: % Define chapters, sections, etc.
1518:
1519: \newcount \chapno
1520: \newcount \secno \secno=0
1521: \newcount \subsecno \subsecno=0
1522: \newcount \subsubsecno \subsubsecno=0
1523:
1524: % This counter is funny since it counts through charcodes of letters A, B, ...
1525: \newcount \appendixno \appendixno = `\@
1526: \def\appendixletter{\char\the\appendixno}
1527:
1528: \newwrite \contentsfile
1529: % This is called from \setfilename.
1530: \def\opencontents{\openout \contentsfile = \jobname.toc}
1531:
1532: % Each @chapter defines this as the name of the chapter.
1533: % page headings and footings can use it. @section does likewise
1534:
1535: \def\thischapter{} \def\thissection{}
1536: \def\seccheck#1{\if \pageno<0 %
1537: \errmessage{@#1 not allowed after generating table of contents}\fi
1538: %
1539: }
1540:
1541: \def\chapternofonts{%
1542: \let\rawbackslash=\relax%
1543: \let\frenchspacing=\relax%
1544: \def\TeX{\realbackslash TeX}
1545: \def\dots{\realbackslash dots}
1546: \def\copyright{\realbackslash copyright}
1547: \def\tt{\realbackslash tt}
1548: \def\bf{\realbackslash bf }
1549: \def\w{\realbackslash w}
1550: \def\less{\realbackslash less}
1551: \def\gtr{\realbackslash gtr}
1552: \def\hat{\realbackslash hat}
1553: \def\char{\realbackslash char}
1554: \def\tclose##1{\realbackslash tclose {##1}}
1555: \def\code##1{\realbackslash code {##1}}
1556: \def\samp##1{\realbackslash samp {##1}}
1557: \def\r##1{\realbackslash r {##1}}
1558: \def\b##1{\realbackslash b {##1}}
1559: \def\key##1{\realbackslash key {##1}}
1560: \def\file##1{\realbackslash file {##1}}
1561: \def\kbd##1{\realbackslash kbd {##1}}
1562: % These are redefined because @smartitalic wouldn't work inside xdef.
1563: \def\i##1{\realbackslash i {##1}}
1564: \def\cite##1{\realbackslash cite {##1}}
1565: \def\var##1{\realbackslash var {##1}}
1566: \def\emph##1{\realbackslash emph {##1}}
1567: \def\dfn##1{\realbackslash dfn {##1}}
1568: }
1569:
1570: \def\thischaptername{No Chapter Title}
1571: \outer\def\chapter{\parsearg\chapterzzz}
1572: \def\chapterzzz #1{\seccheck{chapter}%
1573: \secno=0 \subsecno=0 \subsubsecno=0
1574: \global\advance \chapno by 1 \message{Chapter \the\chapno}%
1575: \chapmacro {#1}{\the\chapno}%
1576: \gdef\thissection{#1}%
1577: \gdef\thischaptername{#1}%
1578: % We don't substitute the actual chapter name into \thischapter
1579: % because we don't want its macros evaluated now.
1580: \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
1581: {\chapternofonts%
1582: \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
1583: \escapechar=`\\%
1584: \write \contentsfile \temp %
1585: \donoderef %
1586: \global\let\section = \numberedsec
1587: \global\let\subsection = \numberedsubsec
1588: \global\let\subsubsection = \numberedsubsubsec
1589: }}
1590:
1591: \outer\def\appendix{\parsearg\appendixzzz}
1592: \def\appendixzzz #1{\seccheck{appendix}%
1593: \secno=0 \subsecno=0 \subsubsecno=0
1594: \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
1595: \chapmacro {#1}{Appendix \appendixletter}%
1596: \gdef\thissection{#1}%
1597: \gdef\thischaptername{#1}%
1598: \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
1599: {\chapternofonts%
1600: \edef\temp{{\realbackslash chapentry
1601: {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
1602: \escapechar=`\\%
1603: \write \contentsfile \temp %
1604: \appendixnoderef %
1605: \global\let\section = \appendixsec
1606: \global\let\subsection = \appendixsubsec
1607: \global\let\subsubsection = \appendixsubsubsec
1608: }}
1609:
1610: \outer\def\top{\parsearg\unnumberedzzz}
1611: \outer\def\unnumbered{\parsearg\unnumberedzzz}
1612: \def\unnumberedzzz #1{\seccheck{unnumbered}%
1613: \secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
1614: \unnumbchapmacro {#1}%
1615: \gdef\thischapter{#1}\gdef\thissection{#1}%
1616: {\chapternofonts%
1617: \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
1618: \escapechar=`\\%
1619: \write \contentsfile \temp %
1620: \unnumbnoderef %
1621: \global\let\section = \unnumberedsec
1622: \global\let\subsection = \unnumberedsubsec
1623: \global\let\subsubsection = \unnumberedsubsubsec
1624: }}
1625:
1626: \outer\def\numberedsec{\parsearg\seczzz}
1627: \def\seczzz #1{\seccheck{section}%
1628: \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
1629: \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
1630: {\chapternofonts%
1631: \edef\temp{{\realbackslash secentry %
1632: {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
1633: \escapechar=`\\%
1634: \write \contentsfile \temp %
1635: \donoderef %
1636: \penalty 10000 %
1637: }}
1638:
1639: \outer\def\appendixsection{\parsearg\appendixsectionzzz}
1640: \outer\def\appendixsec{\parsearg\appendixsectionzzz}
1641: \def\appendixsectionzzz #1{\seccheck{appendixsection}%
1642: \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
1643: \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
1644: {\chapternofonts%
1645: \edef\temp{{\realbackslash secentry %
1646: {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
1647: \escapechar=`\\%
1648: \write \contentsfile \temp %
1649: \appendixnoderef %
1650: \penalty 10000 %
1651: }}
1652:
1653: \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
1654: \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
1655: \plainsecheading {#1}\gdef\thissection{#1}%
1656: {\chapternofonts%
1657: \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
1658: \escapechar=`\\%
1659: \write \contentsfile \temp %
1660: \unnumbnoderef %
1661: \penalty 10000 %
1662: }}
1663:
1664: \outer\def\numberedsubsec{\parsearg\numberedsubseczzz}
1665: \def\numberedsubseczzz #1{\seccheck{subsection}%
1666: \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
1667: \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
1668: {\chapternofonts%
1669: \edef\temp{{\realbackslash subsecentry %
1670: {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
1671: \escapechar=`\\%
1672: \write \contentsfile \temp %
1673: \donoderef %
1674: \penalty 10000 %
1675: }}
1676:
1677: \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
1678: \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
1679: \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
1680: \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
1681: {\chapternofonts%
1682: \edef\temp{{\realbackslash subsecentry %
1683: {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
1684: \escapechar=`\\%
1685: \write \contentsfile \temp %
1686: \appendixnoderef %
1687: \penalty 10000 %
1688: }}
1689:
1690: \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
1691: \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
1692: \plainsecheading {#1}\gdef\thissection{#1}%
1693: {\chapternofonts%
1694: \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
1695: \escapechar=`\\%
1696: \write \contentsfile \temp %
1697: \unnumbnoderef %
1698: \penalty 10000 %
1699: }}
1700:
1701: \outer\def\numberedsubsubsec{\parsearg\numberedsubsubseczzz}
1702: \def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
1703: \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
1704: \subsubsecheading {#1}
1705: {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
1706: {\chapternofonts%
1707: \edef\temp{{\realbackslash subsubsecentry %
1708: {#1}
1709: {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
1710: {\noexpand\folio}}}%
1711: \escapechar=`\\%
1712: \write \contentsfile \temp %
1713: \donoderef %
1714: \penalty 10000 %
1715: }}
1716:
1717: \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
1718: \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
1719: \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
1720: \subsubsecheading {#1}
1721: {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
1722: {\chapternofonts%
1723: \edef\temp{{\realbackslash subsubsecentry{#1}%
1724: {\appendixletter}
1725: {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
1726: \escapechar=`\\%
1727: \write \contentsfile \temp %
1728: \appendixnoderef %
1729: \penalty 10000 %
1730: }}
1731:
1732: \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
1733: \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
1734: \plainsecheading {#1}\gdef\thissection{#1}%
1735: {\chapternofonts%
1736: \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
1737: \escapechar=`\\%
1738: \write \contentsfile \temp %
1739: \unnumbnoderef %
1740: \penalty 10000 %
1741: }}
1742:
1743: % These are variants which are not "outer", so they can appear in @ifinfo.
1744: % Actually, they should now be obsolete; ordinary section commands should work.
1745: \def\infotop{\parsearg\unnumberedzzz}
1746: \def\infounnumbered{\parsearg\unnumberedzzz}
1747: \def\infounnumberedsec{\parsearg\unnumberedseczzz}
1748: \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
1749: \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
1750:
1751: \def\infoappendix{\parsearg\appendixzzz}
1752: \def\infoappendixsec{\parsearg\appendixseczzz}
1753: \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
1754: \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
1755:
1756: \def\infochapter{\parsearg\chapterzzz}
1757: \def\infosection{\parsearg\sectionzzz}
1758: \def\infosubsection{\parsearg\subsectionzzz}
1759: \def\infosubsubsection{\parsearg\subsubsectionzzz}
1760:
1761: % These macros control what the section commands do, according
1762: % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
1763: % Define them by default for a numbered chapter.
1764: \global\let\section = \numberedsec
1765: \global\let\subsection = \numberedsubsec
1766: \global\let\subsubsection = \numberedsubsubsec
1767:
1768: % Define @majorheading, @heading and @subheading
1769:
1770: % NOTE on use of \vbox for chapter headings, section headings, and
1771: % such:
1772: % 1) We use \vbox rather than the earlier \line to permit
1773: % overlong headings to fold.
1774: % 2) \hyphenpenalty is set to 10000 because hyphenation in a
1775: % heading is obnoxious; this forbids it.
1776: % 3) Likewise, headings look best if no \parindent is used, and
1777: % if justification is not attempted. Hence \raggedright.
1778:
1779:
1780: \def\majorheading{\parsearg\majorheadingzzz}
1781: \def\majorheadingzzz #1{%
1782: {\advance\chapheadingskip by 10pt \chapbreak }%
1783: {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
1784: \parindent=0pt\raggedright
1785: \rm #1\hfill}}\bigskip \par\penalty 200}
1786:
1787: \def\chapheading{\parsearg\chapheadingzzz}
1788: \def\chapheadingzzz #1{\chapbreak %
1789: {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
1790: \parindent=0pt\raggedright
1791: \rm #1\hfill}}\bigskip \par\penalty 200}
1792:
1793: \def\heading{\parsearg\secheadingi}
1794:
1795: \def\subheading{\parsearg\subsecheadingi}
1796:
1797: \def\subsubheading{\parsearg\subsubsecheadingi}
1798:
1799: % These macros generate a chapter, section, etc. heading only
1800: % (including whitespace, linebreaking, etc. around it),
1801: % given all the information in convenient, parsed form.
1802:
1803: %%% Args are the skip and penalty (usually negative)
1804: \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
1805:
1806: \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
1807:
1808: %%% Define plain chapter starts, and page on/off switching for it
1809: % Parameter controlling skip before chapter headings (if needed)
1810:
1811: \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
1812:
1813: \def\chapbreak{\dobreak \chapheadingskip {-4000}}
1814: \def\chappager{\par\vfill\supereject}
1815: \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
1816:
1817: \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
1818:
1819: \def\CHAPPAGoff{
1820: \global\let\pchapsepmacro=\chapbreak
1821: \global\let\pagealignmacro=\chappager}
1822:
1823: \def\CHAPPAGon{
1824: \global\let\pchapsepmacro=\chappager
1825: \global\let\pagealignmacro=\chappager
1826: \global\def\HEADINGSon{\HEADINGSsingle}}
1827:
1828: \def\CHAPPAGodd{
1829: \global\let\pchapsepmacro=\chapoddpage
1830: \global\let\pagealignmacro=\chapoddpage
1831: \global\def\HEADINGSon{\HEADINGSdouble}}
1832:
1833: \CHAPPAGon
1834:
1835: \def\CHAPFplain{
1836: \global\let\chapmacro=\chfplain
1837: \global\let\unnumbchapmacro=\unnchfplain}
1838:
1839: \def\chfplain #1#2{%
1840: \pchapsepmacro
1841: {%
1842: \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
1843: \parindent=0pt\raggedright
1844: \rm #2\enspace #1}%
1845: }%
1846: \bigskip
1847: \penalty5000
1848: }
1849:
1850: \def\unnchfplain #1{%
1851: \pchapsepmacro %
1852: {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
1853: \parindent=0pt\raggedright
1854: \rm #1\hfill}}\bigskip \par\penalty 10000 %
1855: }
1856: \CHAPFplain % The default
1857:
1858: \def\unnchfopen #1{%
1859: \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
1860: \parindent=0pt\raggedright
1861: \rm #1\hfill}}\bigskip \par\penalty 10000 %
1862: }
1863:
1864: \def\chfopen #1#2{\chapoddpage {\chapfonts
1865: \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
1866: \par\penalty 5000 %
1867: }
1868:
1869: \def\CHAPFopen{
1870: \global\let\chapmacro=\chfopen
1871: \global\let\unnumbchapmacro=\unnchfopen}
1872:
1873: % Parameter controlling skip before section headings.
1874:
1875: \newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt
1876: \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
1877:
1878: \newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt
1879: \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
1880:
1881: % @paragraphindent is defined for the Info formatting commands only.
1882: \let\paragraphindent=\comment
1883:
1884: % Section fonts are the base font at magstep2, which produces
1885: % a size a bit more than 14 points in the default situation.
1886:
1887: \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
1888: \def\plainsecheading #1{\secheadingi {#1}}
1889: \def\secheadingi #1{{\advance \secheadingskip by \parskip %
1890: \secheadingbreak}%
1891: {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
1892: \parindent=0pt\raggedright
1893: \rm #1\hfill}}%
1894: \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
1895:
1896:
1897: % Subsection fonts are the base font at magstep1,
1898: % which produces a size of 12 points.
1899:
1900: \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
1901: \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
1902: \subsecheadingbreak}%
1903: {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
1904: \parindent=0pt\raggedright
1905: \rm #1\hfill}}%
1906: \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
1907:
1908: \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
1909: % Perhaps make sssec fonts scaled
1910: % magstep half
1911: \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
1912: \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
1913: \subsecheadingbreak}%
1914: {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
1915: \parindent=0pt\raggedright
1916: \rm #1\hfill}}%
1917: \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
1918:
1919:
1920: \message{toc printing,}
1921:
1922: % Finish up the main text and prepare to read what we've written
1923: % to \contentsfile.
1924:
1925: \newskip\contentsrightmargin \contentsrightmargin=1in
1926: \def\startcontents#1{%
1927: \ifnum \pageno>0
1928: \pagealignmacro
1929: \immediate\closeout \contentsfile
1930: \pageno = -1 % Request roman numbered pages.
1931: \fi
1932: % Don't need to put `Contents' or `Short Contents' in the headline.
1933: % It is abundantly clear what they are.
1934: \unnumbchapmacro{#1}\def\thischapter{}%
1935: \begingroup % Set up to handle contents files properly.
1936: \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
1937: \raggedbottom % Worry more about breakpoints than the bottom.
1938: \advance\hsize by -\contentsrightmargin % Don't use the full line length.
1939: }
1940:
1941:
1942: % Normal (long) toc.
1943: \outer\def\contents{%
1944: \startcontents{Table of Contents}%
1945: \input \jobname.toc
1946: \endgroup
1947: \vfill \eject
1948: }
1949:
1950: % And just the chapters.
1951: \outer\def\summarycontents{%
1952: \startcontents{Short Contents}%
1953: %
1954: \let\chapentry = \shortchapentry
1955: \let\unnumbchapentry = \shortunnumberedentry
1956: % We want a true roman here for the page numbers.
1957: \secfonts
1958: \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
1959: \rm
1960: \advance\baselineskip by 1pt % Open it up a little.
1961: \def\secentry ##1##2##3##4{}
1962: \def\unnumbsecentry ##1##2{}
1963: \def\subsecentry ##1##2##3##4##5{}
1964: \def\unnumbsubsecentry ##1##2{}
1965: \def\subsubsecentry ##1##2##3##4##5##6{}
1966: \def\unnumbsubsubsecentry ##1##2{}
1967: \input \jobname.toc
1968: \endgroup
1969: \vfill \eject
1970: }
1971: \let\shortcontents = \summarycontents
1972:
1973: % These macros generate individual entries in the table of contents.
1974: % The first argument is the chapter or section name.
1975: % The last argument is the page number.
1976: % The arguments in between are the chapter number, section number, ...
1977:
1978: % Chapter-level things, for both the long and short contents.
1979: \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
1980:
1981: % See comments in \dochapentry re vbox and related settings
1982: \def\shortchapentry#1#2#3{%
1983: \vbox{\hyphenpenalty=10000\tolerance=5000
1984: \parindent=0pt\strut\raggedright
1985: {#2\labelspace #1}\dotfill\doshortpageno{#3}}%
1986: }
1987:
1988: \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
1989: \def\shortunnumberedentry#1#2{%
1990: \vbox{\hyphenpenalty=10000\tolerance=5000
1991: \parindent=0pt\strut\raggedright
1992: #1\dotfill\doshortpageno{#2}}%
1993: }
1994:
1995: % Sections.
1996: \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
1997: \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
1998:
1999: % Subsections.
2000: \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
2001: \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
2002:
2003: % And subsubsections.
2004: \def\subsubsecentry#1#2#3#4#5#6{%
2005: \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
2006: \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
2007:
2008:
2009: % This parameter controls the indentation of the various levels.
2010: \newdimen\tocindent \tocindent = 3pc
2011:
2012: % Now for the actual typesetting. In all these, #1 is the text and #2 is the
2013: % page number.
2014: %
2015: % If the toc has to be broken over pages, we would want to be at chapters
2016: % if at all possible; hence the \penalty.
2017: \def\dochapentry#1#2{%
2018: \penalty-300 \vskip\baselineskip
2019: % This \vbox (and similar ones in dosecentry etc.) used to be a
2020: % \line; changed to permit linebreaks for long headings. See
2021: % comments above \majorheading. Here we also use \strut to
2022: % keep the top end of the vbox from jamming up against the previous
2023: % entry in the table of contents.
2024: \vbox{\chapentryfonts
2025: \hyphenpenalty=10000\tolerance=5000 % this line and next introduced
2026: \parindent=0pt\strut\raggedright % with \line -> \vbox change
2027: #1\dotfill
2028: \dopageno{#2}}%
2029: \nobreak\vskip .25\baselineskip
2030: }
2031:
2032: \def\dosecentry#1#2{%
2033: \vbox{\secentryfonts \leftskip=\tocindent
2034: \hyphenpenalty=10000\tolerance=5000
2035: \parindent=0pt\strut\raggedright #1\dotfill
2036: \dopageno{#2}}%
2037: }
2038:
2039: \def\dosubsecentry#1#2{%
2040: \vbox{\subsecentryfonts \leftskip=2\tocindent
2041: \hyphenpenalty=10000\tolerance=5000
2042: \parindent=0pt\strut\raggedright #1\dotfill
2043: \dopageno{#2}}%
2044: }
2045:
2046: \def\dosubsubsecentry#1#2{%
2047: \vbox{\subsubsecentryfonts \leftskip=3\tocindent
2048: \hyphenpenalty=10000\tolerance=5000
2049: \parindent=0pt\strut\raggedright #1\dotfill
2050: \dopageno{#2}}%
2051: }
2052:
2053: % Space between chapter (or whatever) number and the title.
2054: \def\labelspace{\hskip1em \relax}
2055:
2056: \def\dopageno#1{{\rm #1}}
2057: \def\doshortpageno#1{{\rm #1}}
2058:
2059: \def\chapentryfonts{\secfonts \rm}
2060: \def\secentryfonts{\textfonts}
2061: \let\subsecentryfonts = \textfonts
2062: \let\subsubsecentryfonts = \textfonts
2063:
2064:
2065: \message{environments,}
2066:
2067: % Since these characters are used in examples, it should be an even number of
2068: % \tt widths. Each \tt character is 1en, so two makes it 1em.
2069: % Furthermore, these definitions must come after we define our fonts.
2070: \newbox\dblarrowbox \newbox\longdblarrowbox
2071: \newbox\pushcharbox \newbox\bullbox
2072: \newbox\equivbox \newbox\errorbox
2073:
2074: \let\ptexequiv = \equiv
2075:
1.1.1.2 ! root 2076: %{\tentt
! 2077: %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
! 2078: %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
! 2079: %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
! 2080: %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
1.1 root 2081: % Adapted from the manmac format (p.420 of TeXbook)
1.1.1.2 ! root 2082: %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
! 2083: % depth .1ex\hfil}
! 2084: %}
1.1 root 2085:
2086: \def\point{$\star$}
2087:
1.1.1.2 ! root 2088: \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
! 2089: \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
! 2090: \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
1.1 root 2091:
1.1.1.2 ! root 2092: \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
1.1 root 2093:
2094: % Adapted from the TeXbook's \boxit.
2095: {\tentt \global\dimen0 = 3em}% Width of the box.
2096: \dimen2 = .55pt % Thickness of rules
2097: % The text. (`r' is open on the right, `e' somewhat less so on the left.)
2098: \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
2099:
2100: \global\setbox\errorbox=\hbox to \dimen0{\hfil
2101: \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
2102: \advance\hsize by -2\dimen2 % Rules.
2103: \vbox{
2104: \hrule height\dimen2
2105: \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
2106: \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
2107: \kern3pt\vrule width\dimen2}% Space to right.
2108: \hrule height\dimen2}
2109: \hfil}
2110:
2111: % The @error{} command.
2112: \def\error{\leavevmode\lower.7ex\copy\errorbox}
2113:
2114: % @tex ... @end tex escapes into raw Tex temporarily.
2115: % One exception: @ is still an escape character, so that @end tex works.
2116: % But \@ or @@ will get a plain tex @ character.
2117:
2118: \def\tex{\begingroup
2119: \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
2120: \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
2121: \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
2122: \catcode `\%=14
2123: \catcode 43=12
2124: \catcode`\"=12
2125: \catcode`\==12
2126: \catcode`\|=12
2127: \catcode`\<=12
2128: \catcode`\>=12
2129: \escapechar=`\\
2130: %
2131: \let\{=\ptexlbrace
2132: \let\}=\ptexrbrace
2133: \let\.=\ptexdot
2134: \let\*=\ptexstar
2135: \let\dots=\ptexdots
2136: \def\@{@}%
2137: \let\bullet=\ptexbullet
2138: \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
2139: \let\L=\ptexL
2140: %
2141: \let\Etex=\endgroup}
2142:
2143: % Define @lisp ... @endlisp.
2144: % @lisp does a \begingroup so it can rebind things,
2145: % including the definition of @endlisp (which normally is erroneous).
2146:
2147: % Amount to narrow the margins by for @lisp.
2148: \newskip\lispnarrowing \lispnarrowing=0.4in
2149:
2150: % This is the definition that ^M gets inside @lisp
2151: % phr: changed space to \null, to avoid overfull hbox problems.
2152: {\obeyspaces%
2153: \gdef\lisppar{\null\endgraf}}
2154:
2155: % Cause \obeyspaces to make each Space cause a word-separation
2156: % rather than the default which is that it acts punctuation.
2157: % This is because space in tt font looks funny.
2158: {\obeyspaces %
2159: \gdef\sepspaces{\def {\ }}}
2160:
2161: \newskip\aboveenvskipamount \aboveenvskipamount= 0pt
2162: \def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip
2163: \endgraf \ifdim\lastskip<\aboveenvskipamount
2164: \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}}
2165:
2166: \def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount
2167: \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}
2168:
2169: % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins.
2170: \let\nonarrowing=\relax
2171:
2172: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2173: % \cartouche: draw rectangle w/rounded corners around argument
2174: \font\circle=lcircle10
2175: \newdimen\circthick
2176: \newdimen\cartouter\newdimen\cartinner
2177: \newskip\normbskip\newskip\normpskip\newskip\normlskip
2178: \circthick=\fontdimen8\circle
2179: %
2180: \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
2181: \def\ctr{{\hskip 6pt\circle\char'010}}
2182: \def\cbl{{\circle\char'012\hskip -6pt}}
2183: \def\cbr{{\hskip 6pt\circle\char'011}}
2184: \def\carttop{\hbox to \cartouter{\hskip\lskip
2185: \ctl\leaders\hrule height\circthick\hfil\ctr
2186: \hskip\rskip}}
2187: \def\cartbot{\hbox to \cartouter{\hskip\lskip
2188: \cbl\leaders\hrule height\circthick\hfil\cbr
2189: \hskip\rskip}}
2190: %
2191: \newskip\lskip\newskip\rskip
2192:
2193: \long\def\cartouche{%
2194: \begingroup
2195: \lskip=\leftskip \rskip=\rightskip
2196: \leftskip=0pt\rightskip=0pt %we want these *outside*.
2197: \cartinner=\hsize \advance\cartinner by-\lskip
2198: \advance\cartinner by-\rskip
2199: \cartouter=\hsize
2200: \advance\cartouter by 18pt % allow for 3pt kerns on either
2201: % side, and for 6pt waste from
2202: % each corner char
2203: \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
2204: % Flag to tell @lisp, etc., not to narrow margin.
2205: \let\nonarrowing=\comment
2206: \vbox\bgroup
2207: \baselineskip=0pt\parskip=0pt\lineskip=0pt
2208: \carttop
2209: \hbox\bgroup
2210: \hskip\lskip
2211: \vrule\kern3pt
2212: \vbox\bgroup
2213: \hsize=\cartinner
2214: \kern3pt
2215: \begingroup
2216: \baselineskip=\normbskip
2217: \lineskip=\normlskip
2218: \parskip=\normpskip
2219: \vskip -\parskip
2220: \def\Ecartouche{%
2221: \endgroup
2222: \kern3pt
2223: \egroup
2224: \kern3pt\vrule
2225: \hskip\rskip
2226: \egroup
2227: \cartbot
2228: \egroup
2229: \endgroup
2230: }}
2231:
2232: \def\lisp{\aboveenvbreak
2233: \begingroup\inENV % This group ends at the end of the @lisp body
2234: \hfuzz=12truept % Don't be fussy
2235: % Make spaces be word-separators rather than space tokens.
2236: \sepspaces %
2237: % Single space lines
2238: \singlespace %
2239: % The following causes blank lines not to be ignored
2240: % by adding a space to the end of each line.
2241: \let\par=\lisppar
2242: \def\Elisp{\endgroup\afterenvbreak}%
2243: \parskip=0pt
2244: % @cartouche defines \nonarrowing to inhibit narrowing
2245: % at next level down.
2246: \ifx\nonarrowing\relax
2247: \advance \leftskip by \lispnarrowing
2248: \let\nonarrowing=\relax
2249: \fi
2250: \parindent=0pt
2251: \let\exdent=\internalexdent
2252: \obeyspaces \obeylines \tt \rawbackslash
2253: \def\next##1{}\next}
2254:
2255:
2256: \let\example=\lisp
2257: \def\Eexample{\Elisp}
2258:
2259: \let\smallexample=\lisp
2260: \def\Esmallexample{\Elisp}
2261:
2262: % Macro for 9 pt. examples, necessary to print with 5" lines.
2263: % From Pavel@xerox. This is not really used unless the
2264: % @smallbook command is given.
2265:
2266: \def\smalllispx{\aboveenvbreak\begingroup\inENV
2267: % This group ends at the end of the @lisp body
2268: \hfuzz=12truept % Don't be fussy
2269: % Make spaces be word-separators rather than space tokens.
2270: \sepspaces %
2271: % Single space lines
2272: \singlespace %
2273: % The following causes blank lines not to be ignored
2274: % by adding a space to the end of each line.
2275: \let\par=\lisppar
2276: \def\Esmalllisp{\endgroup\afterenvbreak}%
2277: \parskip=0pt
2278: % @cartouche defines \nonarrowing to inhibit narrowing
2279: % at next level down.
2280: \ifx\nonarrowing\relax
2281: \advance \leftskip by \lispnarrowing
2282: \let\nonarrowing=\relax
2283: \fi
2284: \parindent=0pt
2285: \let\exdent=\internalexdent
2286: \obeyspaces \obeylines \ninett \indexfonts \rawbackslash
2287: \def\next##1{}\next}
2288:
2289: % This is @display; same as @lisp except use roman font.
2290:
2291: \def\display{\begingroup\inENV %This group ends at the end of the @display body
2292: \aboveenvbreak
2293: % Make spaces be word-separators rather than space tokens.
2294: \sepspaces %
2295: % Single space lines
2296: \singlespace %
2297: % The following causes blank lines not to be ignored
2298: % by adding a space to the end of each line.
2299: \let\par=\lisppar
2300: \def\Edisplay{\endgroup\afterenvbreak}%
2301: \parskip=0pt
2302: % @cartouche defines \nonarrowing to inhibit narrowing
2303: % at next level down.
2304: \ifx\nonarrowing\relax
2305: \advance \leftskip by \lispnarrowing
2306: \let\nonarrowing=\relax
2307: \fi
2308: \parindent=0pt
2309: \let\exdent=\internalexdent
2310: \obeyspaces \obeylines
2311: \def\next##1{}\next}
2312:
2313: % This is @format; same as @lisp except use roman font and don't narrow margins
2314:
2315: \def\format{\begingroup\inENV %This group ends at the end of the @format body
2316: \aboveenvbreak
2317: % Make spaces be word-separators rather than space tokens.
2318: \sepspaces %
2319: \singlespace %
2320: % The following causes blank lines not to be ignored
2321: % by adding a space to the end of each line.
2322: \let\par=\lisppar
2323: \def\Eformat{\endgroup\afterenvbreak}
2324: \parskip=0pt \parindent=0pt
2325: \obeyspaces \obeylines
2326: \def\next##1{}\next}
2327:
2328: % @flushleft and @flushright
2329:
2330: \def\flushleft{%
2331: \begingroup\inENV %This group ends at the end of the @format body
2332: \aboveenvbreak
2333: % Make spaces be word-separators rather than space tokens.
2334: \sepspaces %
2335: % The following causes blank lines not to be ignored
2336: % by adding a space to the end of each line.
2337: % This also causes @ to work when the directive name
2338: % is terminated by end of line.
2339: \let\par=\lisppar
2340: \def\Eflushleft{\endgroup\afterenvbreak}%
2341: \parskip=0pt \parindent=0pt
2342: \obeyspaces \obeylines
2343: \def\next##1{}\next}
2344:
2345: \def\flushright{%
2346: \begingroup\inENV %This group ends at the end of the @format body
2347: \aboveenvbreak
2348: % Make spaces be word-separators rather than space tokens.
2349: \sepspaces %
2350: % The following causes blank lines not to be ignored
2351: % by adding a space to the end of each line.
2352: % This also causes @ to work when the directive name
2353: % is terminated by end of line.
2354: \let\par=\lisppar
2355: \def\Eflushright{\endgroup\afterenvbreak}%
2356: \parskip=0pt \parindent=0pt
2357: \advance \leftskip by 0pt plus 1fill
2358: \obeyspaces \obeylines
2359: \def\next##1{}\next}
2360:
2361: % @quotation - narrow the margins.
2362:
2363: \def\quotation{%
2364: \begingroup\inENV %This group ends at the end of the @quotation body
2365: {\parskip=0pt % because we will skip by \parskip too, later
2366: \aboveenvbreak}%
2367: \singlespace
2368: \parindent=0pt
2369: \def\Equotation{\par\endgroup\afterenvbreak}%
2370: % @cartouche defines \nonarrowing to inhibit narrowing
2371: % at next level down.
2372: \ifx\nonarrowing\relax
2373: \advance \leftskip by \lispnarrowing
2374: \advance \rightskip by \lispnarrowing
2375: \let\nonarrowing=\relax
2376: \fi}
2377:
2378: \message{defuns,}
2379: % Define formatter for defuns
2380: % First, allow user to change definition object font (\df) internally
2381: \def\setdeffont #1 {\csname DEF#1\endcsname}
2382:
2383: \newskip\defbodyindent \defbodyindent=.4in
2384: \newskip\defargsindent \defargsindent=50pt
2385: \newskip\deftypemargin \deftypemargin=12pt
2386: \newskip\deflastargmargin \deflastargmargin=18pt
2387:
2388: \newcount\parencount
2389: % define \functionparens, which makes ( and ) and & do special things.
2390: % \functionparens affects the group it is contained in.
2391: \def\activeparens{%
2392: \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
2393: \catcode`\[=\active \catcode`\]=\active}
2394: {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
2395: \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
2396: \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
2397:
2398: % Definitions of (, ) and & used in args for functions.
2399: % This is the definition of ( outside of all parentheses.
2400: \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
2401: \global\advance\parencount by 1 }
2402: %
2403: % This is the definition of ( when already inside a level of parens.
2404: \gdef\opnested{\char`\(\global\advance\parencount by 1 }
2405: %
2406: \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
2407: % also in that case restore the outer-level definition of (.
2408: \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
2409: \global\advance \parencount by -1 }
2410: % If we encounter &foo, then turn on ()-hacking afterwards
2411: \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
2412: %
2413: \gdef\normalparens{\boldbrax\let&=\ampnr}
2414: } % End of definition inside \activeparens
2415: %% These parens (in \boldbrax) actually are a little bolder than the
2416: %% contained text. This is especially needed for [ and ]
2417: \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
2418: \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
2419:
2420: % First, defname, which formats the header line itself.
2421: % #1 should be the function name.
2422: % #2 should be the type of definition, such as "Function".
2423:
2424: \def\defname #1#2{%
2425: % Get the values of \leftskip and \rightskip as they were
2426: % outside the @def...
2427: \dimen2=\leftskip
2428: \advance\dimen2 by -\defbodyindent
2429: \dimen3=\rightskip
2430: \advance\dimen3 by -\defbodyindent
2431: \noindent %
2432: \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
2433: \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
2434: \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
2435: \parshape 2 0in \dimen0 \defargsindent \dimen1 %
2436: % Now output arg 2 ("Function" or some such)
2437: % ending at \deftypemargin from the right margin,
2438: % but stuck inside a box of width 0 so it does not interfere with linebreaking
2439: {% Adjust \hsize to exclude the ambient margins,
2440: % so that \rightline will obey them.
2441: \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
2442: \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
2443: % Make all lines underfull and no complaints:
2444: \tolerance=10000 \hbadness=10000
2445: \advance\leftskip by -\defbodyindent
2446: {\df #1}\enskip % Generate function name
2447: }
2448:
2449: % Actually process the body of a definition
2450: % #1 should be the terminating control sequence, such as \Edefun.
2451: % #2 should be the "another name" control sequence, such as \defunx.
2452: % #3 should be the control sequence that actually processes the header,
2453: % such as \defunheader.
2454:
2455: \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
2456: \medbreak %
2457: % Define the end token that this defining construct specifies
2458: % so that it will exit this group.
2459: \def#1{\endgraf\endgroup\medbreak}%
2460: \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
2461: \parindent=0in
2462: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
2463: \begingroup %
2464: \catcode 61=\active %
2465: \obeylines\activeparens\spacesplit#3}
2466:
2467: \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
2468: \medbreak %
2469: % Define the end token that this defining construct specifies
2470: % so that it will exit this group.
2471: \def#1{\endgraf\endgroup\medbreak}%
2472: \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
2473: \parindent=0in
2474: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
2475: \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
2476:
2477: \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
2478: \medbreak %
2479: % Define the end token that this defining construct specifies
2480: % so that it will exit this group.
2481: \def#1{\endgraf\endgroup\medbreak}%
2482: \def#2##1 ##2 {\def#4{##1}%
2483: \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
2484: \parindent=0in
2485: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
2486: \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
2487:
2488: % These parsing functions are similar to the preceding ones
2489: % except that they do not make parens into active characters.
2490: % These are used for "variables" since they have no arguments.
2491:
2492: \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
2493: \medbreak %
2494: % Define the end token that this defining construct specifies
2495: % so that it will exit this group.
2496: \def#1{\endgraf\endgroup\medbreak}%
2497: \def#2{\begingroup\obeylines\spacesplit#3}%
2498: \parindent=0in
2499: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
2500: \begingroup %
2501: \catcode 61=\active %
2502: \obeylines\spacesplit#3}
2503:
2504: \def\defvrparsebody #1#2#3#4 {\begingroup\inENV %
2505: \medbreak %
2506: % Define the end token that this defining construct specifies
2507: % so that it will exit this group.
2508: \def#1{\endgraf\endgroup\medbreak}%
2509: \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
2510: \parindent=0in
2511: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
2512: \begingroup\obeylines\spacesplit{#3{#4}}}
2513:
2514: \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
2515: \medbreak %
2516: % Define the end token that this defining construct specifies
2517: % so that it will exit this group.
2518: \def#1{\endgraf\endgroup\medbreak}%
2519: \def#2##1 ##2 {\def#4{##1}%
2520: \begingroup\obeylines\spacesplit{#3{##2}}}%
2521: \parindent=0in
2522: \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
2523: \begingroup\obeylines\spacesplit{#3{#5}}}
2524:
2525: % Split up #2 at the first space token.
2526: % call #1 with two arguments:
2527: % the first is all of #2 before the space token,
2528: % the second is all of #2 after that space token.
2529: % If #2 contains no space token, all of it is passed as the first arg
2530: % and the second is passed as empty.
2531:
2532: {\obeylines
2533: \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
2534: \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
2535: \ifx\relax #3%
2536: #1{#2}{}\else #1{#2}{#3#4}\fi}}
2537:
2538: % So much for the things common to all kinds of definitions.
2539:
2540: % Define @defun.
2541:
2542: % First, define the processing that is wanted for arguments of \defun
2543: % Use this to expand the args and terminate the paragraph they make up
2544:
2545: \def\defunargs #1{\functionparens \sl
2546: % Expand, preventing hyphenation at `-' chars.
2547: % Note that groups don't affect changes in \hyphenchar.
2548: \hyphenchar\tensl=0
2549: #1%
2550: \hyphenchar\tensl=45
2551: \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
2552: \interlinepenalty=10000
2553: \advance\rightskip by 0pt plus 1fil
2554: \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
2555: }
2556:
2557: \def\deftypefunargs #1{%
2558: % Expand, preventing hyphenation at `-' chars.
2559: % Note that groups don't affect changes in \hyphenchar.
2560: \functionparens
2561: \code{#1}%
2562: \interlinepenalty=10000
2563: \advance\rightskip by 0pt plus 1fil
2564: \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
2565: }
2566:
2567: % Do complete processing of one @defun or @defunx line already parsed.
2568:
2569: % @deffn Command forward-char nchars
2570:
2571: \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
2572:
2573: \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
2574: \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
2575: \catcode 61=\other % Turn off change made in \defparsebody
2576: }
2577:
2578: % @defun == @deffn Function
2579:
2580: \def\defun{\defparsebody\Edefun\defunx\defunheader}
2581:
2582: \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
2583: \begingroup\defname {#1}{Function}%
2584: \defunargs {#2}\endgroup %
2585: \catcode 61=\other % Turn off change made in \defparsebody
2586: }
2587:
2588: % @deftypefun int foobar (int @var{foo}, float @var{bar})
2589:
2590: \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
2591:
2592: % #1 is the data type. #2 is the name and args.
2593: \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
2594: % #1 is the data type, #2 the name, #3 the args.
2595: \def\deftypefunheaderx #1#2 #3\relax{%
2596: \doind {fn}{\code{#2}}% Make entry in function index
2597: \begingroup\defname {\code{#1} #2}{Function}%
2598: \deftypefunargs {#3}\endgroup %
2599: \catcode 61=\other % Turn off change made in \defparsebody
2600: }
2601:
2602: % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
2603:
2604: \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
2605:
2606: % #1 is the classification. #2 is the data type. #3 is the name and args.
2607: \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
2608: % #1 is the classification, #2 the data type, #3 the name, #4 the args.
2609: \def\deftypefnheaderx #1#2#3 #4\relax{%
2610: \doind {fn}{\code{#3}}% Make entry in function index
2611: \begingroup\defname {\code{#2} #3}{#1}%
2612: \deftypefunargs {#4}\endgroup %
2613: \catcode 61=\other % Turn off change made in \defparsebody
2614: }
2615:
2616: % @defmac == @deffn Macro
2617:
2618: \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
2619:
2620: \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
2621: \begingroup\defname {#1}{Macro}%
2622: \defunargs {#2}\endgroup %
2623: \catcode 61=\other % Turn off change made in \defparsebody
2624: }
2625:
2626: % @defspec == @deffn Special Form
2627:
2628: \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
2629:
2630: \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
2631: \begingroup\defname {#1}{Special Form}%
2632: \defunargs {#2}\endgroup %
2633: \catcode 61=\other % Turn off change made in \defparsebody
2634: }
2635:
2636: % This definition is run if you use @defunx
2637: % anywhere other than immediately after a @defun or @defunx.
2638:
2639: \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
2640: \def\defunx #1 {\errmessage{@defunx in invalid context}}
2641: \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
2642: \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
2643: \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
2644: \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
2645:
2646: % @defmethod, and so on
2647:
2648: % @defop {Funny Method} foo-class frobnicate argument
2649:
2650: \def\defop #1 {\def\defoptype{#1}%
2651: \defopparsebody\Edefop\defopx\defopheader\defoptype}
2652:
2653: \def\defopheader #1#2#3{%
2654: \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
2655: \begingroup\defname {#2}{\defoptype{} on #1}%
2656: \defunargs {#3}\endgroup %
2657: }
2658:
2659: % @defmethod == @defop Method
2660:
2661: \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
2662:
2663: \def\defmethodheader #1#2#3{%
2664: \dosubind {fn}{\code{#2}}{on #1}% entry in function index
2665: \begingroup\defname {#2}{Method on #1}%
2666: \defunargs {#3}\endgroup %
2667: }
2668:
2669: % @defcv {Class Option} foo-class foo-flag
2670:
2671: \def\defcv #1 {\def\defcvtype{#1}%
2672: \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
2673:
2674: \def\defcvarheader #1#2#3{%
2675: \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
2676: \begingroup\defname {#2}{\defcvtype{} of #1}%
2677: \defvarargs {#3}\endgroup %
2678: }
2679:
2680: % @defivar == @defcv {Instance Variable}
2681:
2682: \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
2683:
2684: \def\defivarheader #1#2#3{%
2685: \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
2686: \begingroup\defname {#2}{Instance Variable of #1}%
2687: \defvarargs {#3}\endgroup %
2688: }
2689:
2690: % These definitions are run if you use @defmethodx, etc.,
2691: % anywhere other than immediately after a @defmethod, etc.
2692:
2693: \def\defopx #1 {\errmessage{@defopx in invalid context}}
2694: \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
2695: \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
2696: \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
2697:
2698: % Now @defvar
2699:
2700: % First, define the processing that is wanted for arguments of @defvar.
2701: % This is actually simple: just print them in roman.
2702: % This must expand the args and terminate the paragraph they make up
2703: \def\defvarargs #1{\normalparens #1%
2704: \interlinepenalty=10000
2705: \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
2706:
2707: % @defvr Counter foo-count
2708:
2709: \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
2710:
2711: \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
2712: \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
2713:
2714: % @defvar == @defvr Variable
2715:
2716: \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
2717:
2718: \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
2719: \begingroup\defname {#1}{Variable}%
2720: \defvarargs {#2}\endgroup %
2721: }
2722:
2723: % @defopt == @defvr {User Option}
2724:
2725: \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
2726:
2727: \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
2728: \begingroup\defname {#1}{User Option}%
2729: \defvarargs {#2}\endgroup %
2730: }
2731:
2732: % @deftypevar int foobar
2733:
2734: \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
2735:
2736: % #1 is the data type. #2 is the name.
2737: \def\deftypevarheader #1#2{%
2738: \doind {vr}{\code{#2}}% Make entry in variables index
2739: \begingroup\defname {\code{#1} #2}{Variable}%
2740: \interlinepenalty=10000
2741: \endgraf\penalty 10000\vskip -\parskip\penalty 10000
2742: \endgroup}
2743:
2744: % @deftypevr {Global Flag} int enable
2745:
2746: \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
2747:
2748: \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
2749: \begingroup\defname {\code{#2} #3}{#1}
2750: \interlinepenalty=10000
2751: \endgraf\penalty 10000\vskip -\parskip\penalty 10000
2752: \endgroup}
2753:
2754: % This definition is run if you use @defvarx
2755: % anywhere other than immediately after a @defvar or @defvarx.
2756:
2757: \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
2758: \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
2759: \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
2760: \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
2761: \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
2762:
2763: % Now define @deftp
2764: % Args are printed in bold, a slight difference from @defvar.
2765:
2766: \def\deftpargs #1{\bf \defvarargs{#1}}
2767:
2768: % @deftp Class window height width ...
2769:
2770: \def\deftp{\defvrparsebody\Edeftp\deftpx\deftpheader}
2771:
2772: \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
2773: \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
2774:
2775: % This definition is run if you use @deftpx, etc
2776: % anywhere other than immediately after a @deftp, etc.
2777:
2778: \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
2779:
2780: \message{cross reference,}
2781: % Define cross-reference macros
2782: \newwrite \auxfile
2783:
2784: \newif\ifhavexrefs % True if xref values are known.
2785: \newif\ifwarnedxrefs % True if we warned once that they aren't known.
2786:
2787: % \setref{foo} defines a cross-reference point named foo.
2788:
2789: \def\setref#1{%
2790: %\dosetq{#1-title}{Ytitle}%
2791: \dosetq{#1-pg}{Ypagenumber}%
2792: \dosetq{#1-snt}{Ysectionnumberandtype}}
2793:
2794: \def\unnumbsetref#1{%
2795: %\dosetq{#1-title}{Ytitle}%
2796: \dosetq{#1-pg}{Ypagenumber}%
2797: \dosetq{#1-snt}{Ynothing}}
2798:
2799: \def\appendixsetref#1{%
2800: %\dosetq{#1-title}{Ytitle}%
2801: \dosetq{#1-pg}{Ypagenumber}%
2802: \dosetq{#1-snt}{Yappendixletterandtype}}
2803:
2804: % \xref, \pxref, and \ref generate cross-references to specified points.
2805: % For \xrefX, #1 is the node name, #2 the name of the Info
2806: % cross-reference, #3 the printed node name, #4 the name of the Info
2807: % file, #5 the name of the printed manual. All but the node name can be
2808: % omitted.
2809: %
2810: \def\pxref#1{see \xrefX[#1,,,,,,,]}
2811: \def\xref#1{See \xrefX[#1,,,,,,,]}
2812: \def\ref#1{\xrefX[#1,,,,,,,]}
2813: \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
2814: \def\printedmanual{\ignorespaces #5}%
2815: \def\printednodename{\ignorespaces #3}%
2816: %
2817: \setbox1=\hbox{\printedmanual}%
2818: \setbox0=\hbox{\printednodename}%
2819: \ifdim \wd0=0pt%
2820: \def\printednodename{\ignorespaces #1}%
2821: %%% Uncommment the following line to make the actual chapter or section title
2822: %%% appear inside the square brackets.
2823: %\def\printednodename{#1-title}%
2824: \fi%
2825: %
2826: %
2827: % If we use \unhbox0 and \unhbox1 to print the node names, TeX does
2828: % not insert empty discretionaries after hyphens, which means that it
2829: % will not find a line break at a hyphen in a node names. Since some
2830: % manuals are best written with fairly long node names, containing
2831: % hyphens, this is a loss. Therefore, we simply give the text of
2832: % the node name again, so it is as if TeX is seeing it for the first
2833: % time.
2834: \ifdim \wd1>0pt
2835: section ``\printednodename'' in \cite{\printedmanual}%
2836: \else%
2837: \turnoffactive%
2838: \refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}%
2839: \fi
2840: \endgroup}
2841:
2842: % \dosetq is the interface for calls from other macros
2843:
2844: % Use \turnoffactive so that punctuation chars such as underscore
2845: % work in node names.
2846: \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
2847: \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
2848: \next}}
2849:
2850: % \internalsetq {foo}{page} expands into
2851: % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
2852: % When the aux file is read, ' is the escape character
2853:
2854: \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
2855:
2856: % Things to be expanded by \internalsetq
2857:
2858: \def\Ypagenumber{\folio}
2859:
2860: \def\Ytitle{\thischapter}
2861:
2862: \def\Ynothing{}
2863:
2864: \def\Ysectionnumberandtype{%
2865: \ifnum\secno=0 Chapter\xreftie\the\chapno %
2866: \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
2867: \else \ifnum \subsubsecno=0 %
2868: Section\xreftie\the\chapno.\the\secno.\the\subsecno %
2869: \else %
2870: Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
2871: \fi \fi \fi }
2872:
2873: \def\Yappendixletterandtype{%
2874: \ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}%
2875: \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
2876: \else \ifnum \subsubsecno=0 %
2877: Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
2878: \else %
2879: Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
2880: \fi \fi \fi }
2881:
2882: \gdef\xreftie{'tie}
2883:
2884: % Use TeX 3.0's \inputlineno to get the line number, for better error
2885: % messages, but if we're using an old version of TeX, don't do anything.
2886: %
2887: \ifx\inputlineno\thisisundefined
2888: \let\linenumber = \empty % Non-3.0.
2889: \else
2890: \def\linenumber{\the\inputlineno:\space}
2891: \fi
2892:
2893: % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
2894: % If its value is nonempty, SUFFIX is output afterward.
2895:
2896: \def\refx#1#2{%
2897: \expandafter\ifx\csname X#1\endcsname\relax
2898: % If not defined, say something at least.
2899: $\langle$un\-de\-fined$\rangle$%
2900: \ifhavexrefs
2901: \message{\linenumber Undefined cross reference `#1'.}%
2902: \else
2903: \ifwarnedxrefs\else
2904: \global\warnedxrefstrue
2905: \message{Cross reference values unknown; you must run TeX again.}%
2906: \fi
2907: \fi
2908: \else
2909: % It's defined, so just use it.
2910: \csname X#1\endcsname
2911: \fi
2912: #2% Output the suffix in any case.
2913: }
2914:
2915: % Read the last existing aux file, if any. No error if none exists.
2916:
2917: % This is the macro invoked by entries in the aux file.
2918: \def\xrdef #1#2{
2919: {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
2920:
2921: \def\readauxfile{%
2922: \begingroup
2923: \catcode `\^^@=\other
2924: \catcode `\&=\other
2925: \catcode `\=\other
2926: \catcode `\^^C=\other
2927: \catcode `\^^D=\other
2928: \catcode `\^^E=\other
2929: \catcode `\^^F=\other
2930: \catcode `\^^G=\other
2931: \catcode `\^^H=\other
2932: \catcode `\=\other
2933: \catcode `\^^L=\other
2934: \catcode `\=\other
2935: \catcode `\=\other
2936: \catcode `\=\other
2937: \catcode `\=\other
2938: \catcode `\=\other
2939: \catcode `\=\other
2940: \catcode `\=\other
2941: \catcode `\=\other
2942: \catcode `\=\other
2943: \catcode `\=\other
2944: \catcode `\=\other
2945: \catcode `\=\other
2946: \catcode 26=\other
2947: \catcode `\^^[=\other
2948: \catcode `\^^\=\other
2949: \catcode `\^^]=\other
2950: \catcode `\^^^=\other
2951: \catcode `\^^_=\other
2952: \catcode `\@=\other
2953: \catcode `\^=\other
2954: \catcode `\~=\other
2955: \catcode `\[=\other
2956: \catcode `\]=\other
2957: \catcode`\"=\other
2958: \catcode`\_=\other
2959: \catcode`\|=\other
2960: \catcode`\<=\other
2961: \catcode`\>=\other
2962: \catcode `\$=\other
2963: \catcode `\#=\other
2964: \catcode `\&=\other
2965: % the aux file uses ' as the escape.
2966: % Turn off \ as an escape so we do not lose on
2967: % entries which were dumped with control sequences in their names.
2968: % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
2969: % Reference to such entries still does not work the way one would wish,
2970: % but at least they do not bomb out when the aux file is read in.
2971: \catcode `\{=1 \catcode `\}=2
2972: \catcode `\%=\other
2973: \catcode `\'=0
2974: \catcode `\\=\other
2975: \openin 1 \jobname.aux
2976: \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
2977: \fi
2978: % Open the new aux file. Tex will close it automatically at exit.
2979: \openout \auxfile=\jobname.aux
2980: \endgroup}
2981:
2982:
2983: % Footnotes.
2984:
2985: \newcount \footnoteno
2986:
2987: \def\supereject{\par\penalty -20000\footnoteno =0 }
2988:
2989: % @footnotestyle is meaningful for info output only..
2990: \let\footnotestyle=\comment
2991:
2992: \let\ptexfootnote=\footnote
2993:
2994: {\catcode `\@=11
2995: \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
2996: \unskip
2997: \edef\thisfootno{$^{\the\footnoteno}$}%
2998: \let\@sf\empty
2999: \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
3000: \thisfootno\@sf \footnotezzz{#1}}
3001: % \parsearg\footnotezzz}
3002:
3003: \long\gdef\footnotezzz #1{\insert\footins{
3004: \interlinepenalty\interfootnotelinepenalty
3005: \splittopskip\ht\strutbox % top baseline for broken footnotes
3006: \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
3007: \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
3008: \footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}}
3009:
3010: }%end \catcode `\@=11
3011:
3012: % End of control word definitions.
3013:
3014: \message{and turning on texinfo input format.}
3015:
3016: \def\openindices{%
3017: \newindex{cp}%
3018: \newcodeindex{fn}%
3019: \newcodeindex{vr}%
3020: \newcodeindex{tp}%
3021: \newcodeindex{ky}%
3022: \newcodeindex{pg}%
3023: }
3024:
3025: % Set some numeric style parameters, for 8.5 x 11 format.
3026:
3027: %\hsize = 6.5in
3028: \newdimen\defaultparindent \defaultparindent = 15pt
3029: \parindent = \defaultparindent
3030: \parskip 18pt plus 1pt
3031: \baselineskip 15pt
3032: \advance\topskip by 1.2cm
3033:
3034: % Prevent underfull vbox error messages.
3035: \vbadness=10000
3036:
3037: % Following George Bush, just get rid of widows and orphans.
1.1.1.2 ! root 3038: \widowpenalty=10000
! 3039: \clubpenalty=10000
1.1 root 3040:
3041: % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
3042: % using an old version of TeX, don't do anything. We want the amount of
3043: % stretch added to depend on the line length, hence the dependence on
3044: % \hsize. This makes it come to about 9pt for the 8.5x11 format.
3045: %
3046: \ifx\emergencystretch\thisisundefined \else
3047: \emergencystretch = \hsize
3048: \divide\emergencystretch by 45
3049: \fi
3050:
3051: % Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25)
3052: \def\smallbook{
3053: \global\lispnarrowing = 0.3in
3054: \global\baselineskip 12pt
3055: \global\parskip 3pt plus 1pt
3056: \global\hsize = 5in
3057: \global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in
3058: \global\vsize=7.5in
3059: \global\tolerance=700
3060: \global\hfuzz=1pt
3061: \global\contentsrightmargin=0pt
3062:
3063: \global\pagewidth=\hsize
3064: \global\pageheight=\vsize
3065:
3066: \global\let\smalllisp=\smalllispx
3067: \global\let\smallexample=\smalllispx
3068: \global\def\Esmallexample{\Esmalllisp}
3069: }
3070:
3071: % Use @afourpaper to print on European A4 paper.
3072: \def\afourpaper{
3073: \global\tolerance=700
3074: \global\hfuzz=1pt
3075: \global\baselineskip=12pt
3076: \global\parskip 15pt plus 1pt
3077:
3078: \global\vsize= 53\baselineskip
3079: \advance\vsize by \topskip
3080: %\global\hsize= 5.85in % A4 wide 10pt
3081: \global\hsize= 6.5in
3082: \global\outerhsize=\hsize
3083: \global\advance\outerhsize by 0.5in
3084: \global\outervsize=\vsize
3085: \global\advance\outervsize by 0.6in
3086: \global\doublecolumnhsize=\hsize
3087: \global\divide\doublecolumnhsize by 2
3088: \global\advance\doublecolumnhsize by -0.1in
3089: \global\doublecolumnvsize=\vsize
3090: \global\multiply\doublecolumnvsize by 2
3091: \global\advance\doublecolumnvsize by 0.1in
3092:
3093: \global\pagewidth=\hsize
3094: \global\pageheight=\vsize
3095: }
3096:
3097: %% For a final copy, take out the rectangles
3098: %% that mark overfull boxes (in case you have decided
3099: %% that the text looks ok even though it passes the margin).
3100: \def\finalout{\overfullrule=0pt}
3101:
3102: % Define macros to output various characters with catcode for normal text.
3103: \catcode`\"=\other
3104: \catcode`\~=\other
3105: \catcode`\^=\other
3106: \catcode`\_=\other
3107: \catcode`\|=\other
3108: \catcode`\<=\other
3109: \catcode`\>=\other
3110: \catcode`\+=\other
3111: \def\normaldoublequote{"}
3112: \def\normaltilde{~}
3113: \def\normalcaret{^}
3114: \def\normalunderscore{_}
3115: \def\normalverticalbar{|}
3116: \def\normalless{<}
3117: \def\normalgreater{>}
3118: \def\normalplus{+}
3119:
3120: % This macro is used to make a character print one way in ttfont
3121: % where it can probably just be output, and another way in other fonts,
3122: % where something hairier probably needs to be done.
3123: %
3124: % #1 is what to print if we are indeed using \tt; #2 is what to print
3125: % otherwise. Since all the Computer Modern typewriter fonts have zero
3126: % interword stretch (and shrink), and it is reasonable to expect all
3127: % typewriter fonts to have this, we can check that font parameter.
3128: %
3129: \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
3130:
3131: % Turn off all special characters except @
3132: % (and those which the user can use as if they were ordinary).
3133: % Most of these we simply print from the \tt font, but for some, we can
3134: % use math or other variants that look better in normal text.
3135:
3136: \catcode`\"=\active
3137: \def\activedoublequote{{\tt \char '042}}
3138: \let"=\activedoublequote
3139: \catcode`\~=\active
3140: \def~{{\tt \char '176}}
3141: \chardef\hat=`\^
3142: \catcode`\^=\active
3143: \def^{{\tt \hat}}
3144:
3145: \catcode`\_=\active
3146: \def_{\ifusingtt\normalunderscore\_}
3147: % Subroutine for the previous macro.
3148: \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
3149:
3150: % \lvvmode is equivalent in function to \leavevmode.
3151: % Using \leavevmode runs into trouble when written out to
3152: % an index file due to the expansion of \leavevmode into ``\unhbox
3153: % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
3154: % magic tricks with @.
3155: \def\lvvmode{\vbox to 0pt{}}
3156:
3157: \catcode`\|=\active
3158: \def|{{\tt \char '174}}
3159: \chardef \less=`\<
3160: \catcode`\<=\active
3161: \def<{{\tt \less}}
3162: \chardef \gtr=`\>
3163: \catcode`\>=\active
3164: \def>{{\tt \gtr}}
3165: \catcode`\+=\active
3166: \def+{{\tt \char 43}}
3167: %\catcode 27=\active
3168: %\def^^[{$\diamondsuit$}
3169:
3170: % Used sometimes to turn off (effectively) the active characters
3171: % even after parsing them.
3172: \def\turnoffactive{\let"=\normaldoublequote
3173: \let~=\normaltilde
3174: \let^=\normalcaret
3175: \let_=\normalunderscore
3176: \let|=\normalverticalbar
3177: \let<=\normalless
3178: \let>=\normalgreater
3179: \let+=\normalplus}
3180:
3181: % Set up an active definition for =, but don't enable it most of the time.
3182: {\catcode`\==\active
3183: \global\def={{\tt \char 61}}}
3184:
3185: \catcode`\@=0
3186:
3187: % \rawbackslashxx output one backslash character in current font
3188: \global\chardef\rawbackslashxx=`\\
3189: %{\catcode`\\=\other
3190: %@gdef@rawbackslashxx{\}}
3191:
3192: % \rawbackslash redefines \ as input to do \rawbackslashxx.
3193: {\catcode`\\=\active
3194: @gdef@rawbackslash{@let\=@rawbackslashxx }}
3195:
3196: % \normalbackslash outputs one backslash in fixed width font.
3197: \def\normalbackslash{{\tt\rawbackslashxx}}
3198:
3199: % Say @foo, not \foo, in error messages.
3200: \escapechar=`\@
3201:
3202: % \catcode 17=0 % Define control-q
3203: \catcode`\\=\active
3204:
3205: % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
3206: % That is what \eatinput is for; after that, the `\' should revert to printing
3207: % a backslash.
3208: %
3209: @gdef@eatinput input texinfo{@fixbackslash}
3210: @global@let\ = @eatinput
3211:
3212: % On the other hand, perhaps the file did not have a `\input texinfo'. Then
3213: % the first `\{ in the file would cause an error. This macro tries to fix
3214: % that, assuming it is called before the first `\' could plausibly occur.
3215: %
3216: @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
3217:
3218: %% These look ok in all fonts, so just make them not special. The @rm below
3219: %% makes sure that the current font starts out as the newly loaded cmr10
3220: @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
3221:
3222: @textfonts
3223: @rm
3224:
3225: @c Local variables:
3226: @c page-delimiter: "^\\\\message"
3227: @c End:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.